1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** POSIX wrapper for THREADX */
16 /** */
17 /** */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 /* Include necessary system files. */
23
24 #include "tx_api.h" /* Threadx API */
25 #include "pthread.h" /* Posix API */
26 #include "px_int.h" /* Posix helper functions */
27
28
29 /**************************************************************************/
30 /* */
31 /* FUNCTION RELEASE */
32 /* */
33 /* pthread_attr_getstack PORTABLE C */
34 /* 6.1.7 */
35 /* AUTHOR */
36 /* */
37 /* William E. Lamie, Microsoft Corporation */
38 /* */
39 /* DESCRIPTION */
40 /* */
41 /* This function gets the thread creation stack attributes stackaddr */
42 /* and stacksize in the attr object. */
43 /* The stack attributes specify the area of storage to be used for the*/
44 /* created thread's stack. The base (lowest addressable byte) of the */
45 /* storage shall be stackaddr , and the size of the storage shall be */
46 /* stacksize bytes. */
47 /* */
48 /* INPUT */
49 /* */
50 /* attr Address of the thread attributes */
51 /* stackaddr Pointer to hold Address of stack */
52 /* stacksize Holds the stack size */
53 /* */
54 /* OUTPUT */
55 /* */
56 /* 0 if successful */
57 /* Value in case of any error */
58 /* */
59 /* CALLS */
60 /* */
61 /* None */
62 /* */
63 /* CALLED BY */
64 /* */
65 /* Application Code */
66 /* */
67 /* RELEASE HISTORY */
68 /* */
69 /* DATE NAME DESCRIPTION */
70 /* */
71 /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
72 /* */
73 /**************************************************************************/
pthread_attr_getstack(pthread_attr_t * attr,void ** stackaddr,size_t * stacksize)74 INT pthread_attr_getstack( pthread_attr_t *attr,void **stackaddr,
75 size_t *stacksize)
76 {
77 /* First check the attribute object is already destroyed? */
78 if (attr->inuse == TX_FALSE)
79 {
80 posix_errno = EINVAL;
81 posix_set_pthread_errno(EINVAL);
82 return(EINVAL);
83 }
84 else
85 {
86 *stackaddr = attr->stack_address;
87 *stacksize = attr->stack_size ;
88 return(OK);
89 }
90 }
91