diff options
author | Siddhesh Poyarekar <siddhesh@redhat.com> | 2013-06-15 12:24:15 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@redhat.com> | 2013-06-15 12:24:15 +0530 |
commit | 61dd6208fb1e59a423b6dfa712a3c896c34b2590 (patch) | |
tree | 3417035a17046120bfedeafe2e7db9e366380101 /nptl/pthread_attr_getstacksize.c | |
parent | 601eb33debf0c7548f52ba72cec4b3f362105e39 (diff) | |
download | glibc-61dd6208fb1e59a423b6dfa712a3c896c34b2590.tar.gz glibc-61dd6208fb1e59a423b6dfa712a3c896c34b2590.tar.xz glibc-61dd6208fb1e59a423b6dfa712a3c896c34b2590.zip |
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.
Diffstat (limited to 'nptl/pthread_attr_getstacksize.c')
-rw-r--r-- | nptl/pthread_attr_getstacksize.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/nptl/pthread_attr_getstacksize.c b/nptl/pthread_attr_getstacksize.c index 42d3f8f44c..84c31cd6e4 100644 --- a/nptl/pthread_attr_getstacksize.c +++ b/nptl/pthread_attr_getstacksize.c @@ -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; } |