lib: posix: support for pthread_attr_setstacksize
Support pthread_attr_setstacksize(3). See https://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_attr_getstacksize.html Fixes #44722 Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
This commit is contained in:
parent
2faa6f5c0b
commit
7c583bbf8f
2 changed files with 23 additions and 0 deletions
|
|
@ -64,6 +64,9 @@ struct posix_thread {
|
|||
/* Passed to pthread_once */
|
||||
#define PTHREAD_ONCE_INIT 1
|
||||
|
||||
/* The minimum allowable stack size */
|
||||
#define PTHREAD_STACK_MIN Z_KERNEL_STACK_SIZE_ADJUST(0)
|
||||
|
||||
/**
|
||||
* @brief Declare a pthread condition variable
|
||||
*
|
||||
|
|
@ -483,6 +486,7 @@ static inline int pthread_rwlockattr_init(pthread_rwlockattr_t *attr)
|
|||
}
|
||||
|
||||
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize);
|
||||
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
|
||||
int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
|
||||
int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy);
|
||||
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
|
||||
|
|
|
|||
|
|
@ -552,6 +552,25 @@ int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize)
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set stack size attribute in thread attributes object.
|
||||
*
|
||||
* See IEEE 1003.1
|
||||
*/
|
||||
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
|
||||
{
|
||||
if ((attr == NULL) || (attr->initialized == 0U)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (stacksize < PTHREAD_STACK_MIN) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
attr->stacksize = stacksize;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get stack attributes in thread attributes object.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue