@@ -202,6 +202,33 @@ int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize);
202202 */
203203int pthread_attr_setstacksize (pthread_attr_t * attr , size_t stacksize );
204204
205+ /**
206+ * @brief Query set stacksize for new pthread.
207+ * @param[in] attr Attribute set to query.
208+ * @param[out] stackaddr Pointer to previously assigned stack, or `NULL` for dynamic allocation.
209+ * @param[out] stacksize Assigned or default stack size, resp.
210+ * @returns 0, this invocation cannot fail
211+ */
212+ int pthread_attr_getstack (pthread_attr_t * attr , void * * stackaddr , size_t * stacksize );
213+
214+ /**
215+ * @brief Set address and stack size of the stack to use for the new pthread.
216+ * @details This function requires setting the address as well as the size
217+ * since only setting the address will make the implementation
218+ * on some architectures impossible.
219+ * If `*stackaddr == NULL`, then the stack is dynamically allocated with malloc().
220+ * No two running threads may operate on the same stack.
221+ * The stack of a zombie thread (i.e. a non-detached thread that exited but was not yet joined)
222+ * may in theory be reused even before joining, though there might be problems
223+ * if the stack was preempted before pthread_exit() completed.
224+ * @param[in,out] attr Attribute set to operate on.
225+ * @param[in] stackaddr Static stack to use, or `NULL` for dynamic allocation.
226+ * @param[in] stacksize Size of the stack of the new thread.
227+ * Supply `0` to use the default value.
228+ * @returns 0, this invocation cannot fail
229+ */
230+ int pthread_attr_setstack (pthread_attr_t * attr , void * stackaddr , size_t stacksize );
231+
205232#ifdef __cplusplus
206233}
207234#endif
0 commit comments