mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
New API to set default thread attributes
This patch introduces two new convenience functions to set the default thread attributes used for creating threads. This allows a programmer to set the default thread attributes just once in a process and then run pthread_create without additional attributes.
This commit is contained in:
@ -30,9 +30,17 @@ __pthread_attr_getstacksize (attr, stacksize)
|
||||
assert (sizeof (*attr) >= sizeof (struct pthread_attr));
|
||||
iattr = (struct pthread_attr *) attr;
|
||||
|
||||
size_t size = iattr->stacksize;
|
||||
|
||||
/* If the user has not set a stack size we return what the system
|
||||
will use as the default. */
|
||||
*stacksize = iattr->stacksize ?: __default_pthread_attr.stacksize;
|
||||
if (size == 0)
|
||||
{
|
||||
lll_lock (__default_pthread_attr_lock, LLL_PRIVATE);
|
||||
size = __default_pthread_attr.stacksize;
|
||||
lll_unlock (__default_pthread_attr_lock, LLL_PRIVATE);
|
||||
}
|
||||
*stacksize = size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user