]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nptl/pthread_setspecific.c
Add per-thread cache to malloc
[thirdparty/glibc.git] / nptl / pthread_setspecific.c
index b6e66b5f22033d6fff853190f1915809770e9b64..214af3b661d243362b54dc3c85b5c08dd51c8da9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2017 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -13,9 +13,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
 #include <stdlib.h>
@@ -23,9 +22,7 @@
 
 
 int
-__pthread_setspecific (key, value)
-     pthread_key_t key;
-     const void *value;
+__pthread_setspecific (pthread_key_t key, const void *value)
 {
   struct pthread *self;
   unsigned int idx1st;
@@ -37,7 +34,7 @@ __pthread_setspecific (key, value)
 
   /* Special case access to the first 2nd-level block.  This is the
      usual case.  */
-  if (__builtin_expect (key < PTHREAD_KEY_2NDLEVEL_SIZE, 1))
+  if (__glibc_likely (key < PTHREAD_KEY_2NDLEVEL_SIZE))
     {
       /* Verify the key is sane.  */
       if (KEY_UNUSED ((seq = __pthread_keys[key].seq)))
@@ -52,8 +49,8 @@ __pthread_setspecific (key, value)
     }
   else
     {
-      if (KEY_UNUSED ((seq = __pthread_keys[key].seq))
-         || key >= PTHREAD_KEYS_MAX)
+      if (key >= PTHREAD_KEYS_MAX
+         || KEY_UNUSED ((seq = __pthread_keys[key].seq)))
        /* Not valid.  */
        return EINVAL;
 
@@ -92,5 +89,5 @@ __pthread_setspecific (key, value)
 
   return 0;
 }
-strong_alias (__pthread_setspecific, pthread_setspecific)
-strong_alias (__pthread_setspecific, __pthread_setspecific_internal)
+weak_alias (__pthread_setspecific, pthread_setspecific)
+hidden_def (__pthread_setspecific)