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