diff options
author | Florian Weimer <fweimer@redhat.com> | 2020-05-18 17:58:30 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2020-06-02 10:32:23 +0200 |
commit | 8111c457b8c4f1c113a8475e3da38bd88270ab37 (patch) | |
tree | eff19f2e42e11bb4349d8583b00ecf748a984699 /nptl/pthread_create.c | |
parent | dd05e154accfd3b9cd5984fa8419ffbd4edd90da (diff) | |
download | glibc-8111c457b8c4f1c113a8475e3da38bd88270ab37.tar glibc-8111c457b8c4f1c113a8475e3da38bd88270ab37.tar.gz glibc-8111c457b8c4f1c113a8475e3da38bd88270ab37.tar.bz2 glibc-8111c457b8c4f1c113a8475e3da38bd88270ab37.zip |
nptl: Use __pthread_getattr_default_np in pthread_create
This removes another instance of custom attribute copying code.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'nptl/pthread_create.c')
-rw-r--r-- | nptl/pthread_create.c | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index a43089065c..347d510707 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -613,32 +613,14 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr, const struct pthread_attr *iattr = (struct pthread_attr *) attr; struct pthread_attr default_attr; - bool free_cpuset = false; + bool destroy_default_attr = false; bool c11 = (attr == ATTR_C11_THREAD); if (iattr == NULL || c11) { - lll_lock (__default_pthread_attr_lock, LLL_PRIVATE); - default_attr = __default_pthread_attr; - size_t cpusetsize = default_attr.cpusetsize; - if (cpusetsize > 0) - { - cpu_set_t *cpuset; - if (__glibc_likely (__libc_use_alloca (cpusetsize))) - cpuset = __alloca (cpusetsize); - else - { - cpuset = malloc (cpusetsize); - if (cpuset == NULL) - { - lll_unlock (__default_pthread_attr_lock, LLL_PRIVATE); - return ENOMEM; - } - free_cpuset = true; - } - memcpy (cpuset, default_attr.cpuset, cpusetsize); - default_attr.cpuset = cpuset; - } - lll_unlock (__default_pthread_attr_lock, LLL_PRIVATE); + int ret = __pthread_getattr_default_np ((pthread_attr_t *) &default_attr); + if (ret != 0) + return ret; + destroy_default_attr = true; iattr = &default_attr; } @@ -869,8 +851,8 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr, } out: - if (__glibc_unlikely (free_cpuset)) - free (default_attr.cpuset); + if (destroy_default_attr) + __pthread_attr_destroy ((pthread_attr_t *) &default_attr); return retval; } |