]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Assume LLL_LOCK_INITIALIZER is 0
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 22 Feb 2019 15:10:26 +0000 (12:10 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 14 May 2019 11:44:03 +0000 (08:44 -0300)
Since hppa is not an outlier anymore regarding LLL_LOCK_INITIALIZER value,
we can now assume it 0 for all architectures.

Checked on a build for all major ABIs.

* nptl/nptl-init.c (__pthread_initialize_minimal_internal): Remove
initialization for LLL_LOCK_INITIALIZER different than 0.
* nptl/old_pthread_cond_broadcast.c (__pthread_cond_broadcast_2_0):
Assume LLL_LOCK_INITIALIZER being 0.
* nptl/old_pthread_cond_signal.c (__pthread_cond_signal_2_0): Likewise.
* nptl/old_pthread_cond_timedwait.c (__pthread_cond_timedwait_2_0):
Likewise.
* nptl/old_pthread_cond_wait.c (__pthread_cond_wait_2_0): Likewise.
* sysdeps/nptl/libc-lockP.h (__libc_lock_define_initialized): Likewise.

ChangeLog
nptl/nptl-init.c
nptl/old_pthread_cond_broadcast.c
nptl/old_pthread_cond_signal.c
nptl/old_pthread_cond_timedwait.c
nptl/old_pthread_cond_wait.c
sysdeps/nptl/libc-lockP.h

index 6a26dad64f46ddca256cb41ca3dca2fdd712807e..4cb846f476f73a938047a3d57058cb40757ff286 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2019-05-14  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
+       * nptl/nptl-init.c (__pthread_initialize_minimal_internal): Remove
+       initialization for LLL_LOCK_INITIALIZER different than 0.
+       * nptl/old_pthread_cond_broadcast.c (__pthread_cond_broadcast_2_0):
+       Assume LLL_LOCK_INITIALIZER being 0.
+       * nptl/old_pthread_cond_signal.c (__pthread_cond_signal_2_0): Likewise.
+       * nptl/old_pthread_cond_timedwait.c (__pthread_cond_timedwait_2_0):
+       Likewise.
+       * nptl/old_pthread_cond_wait.c (__pthread_cond_wait_2_0): Likewise.
+       * sysdeps/nptl/libc-lockP.h (__libc_lock_define_initialized): Likewise.
+
        * nptl/lowlevellock.c (__lll_lock_wait, __lll_lock_wait_private):
        Optimize futex call and add systemtap probe.
 
index b845c6e45d1ea0f5a46f66b338b8d1e53a5e7a00..2926558b912f3c59feb4e740e88ea55803bc8442 100644 (file)
@@ -265,8 +265,6 @@ __pthread_initialize_minimal_internal (void)
   __pthread_initialize_pids (pd);
   THREAD_SETMEM (pd, specific[0], &pd->specific_1stblock[0]);
   THREAD_SETMEM (pd, user_stack, true);
-  if (LLL_LOCK_INITIALIZER != 0)
-    THREAD_SETMEM (pd, lock, LLL_LOCK_INITIALIZER);
 
   /* Initialize the robust mutex data.  */
   {
index f561eb941f6142193feb16f7276c1325b86753bd..04f285a1b1c8cb5caa5d3a36e902bfb1a113638a 100644 (file)
@@ -31,18 +31,9 @@ __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond)
     {
       pthread_cond_t *newcond;
 
-#if LLL_LOCK_INITIALIZER == 0
       newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1);
       if (newcond == NULL)
        return ENOMEM;
-#else
-      newcond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t));
-      if (newcond == NULL)
-       return ENOMEM;
-
-      /* Initialize the condvar.  */
-      (void) pthread_cond_init (newcond, NULL);
-#endif
 
       if (atomic_compare_and_exchange_bool_acq (&cond->cond, newcond, NULL))
        /* Somebody else just initialized the condvar.  */
index a167c8addc1e01f6b9aa0c62c5ae417216929386..9b67cb8a54d8d71f144e2c99819685c831828da2 100644 (file)
@@ -31,18 +31,9 @@ __pthread_cond_signal_2_0 (pthread_cond_2_0_t *cond)
     {
       pthread_cond_t *newcond;
 
-#if LLL_LOCK_INITIALIZER == 0
       newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1);
       if (newcond == NULL)
        return ENOMEM;
-#else
-      newcond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t));
-      if (newcond == NULL)
-       return ENOMEM;
-
-      /* Initialize the condvar.  */
-      (void) pthread_cond_init (newcond, NULL);
-#endif
 
       if (atomic_compare_and_exchange_bool_acq (&cond->cond, newcond, NULL))
        /* Somebody else just initialized the condvar.  */
index f920320b13cc95958afb50cab5f779cd83c9102d..a1fde85825522ff9e74557a282eaa9d11cc23f01 100644 (file)
@@ -32,18 +32,9 @@ __pthread_cond_timedwait_2_0 (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex,
     {
       pthread_cond_t *newcond;
 
-#if LLL_LOCK_INITIALIZER == 0
       newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1);
       if (newcond == NULL)
        return ENOMEM;
-#else
-      newcond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t));
-      if (newcond == NULL)
-       return ENOMEM;
-
-      /* Initialize the condvar.  */
-      (void) pthread_cond_init (newcond, NULL);
-#endif
 
       if (atomic_compare_and_exchange_bool_acq (&cond->cond, newcond, NULL))
        /* Somebody else just initialized the condvar.  */
index 2be41b36d6be5d3b9c8d777b8bcfefbc2f898a5f..bb65340a17296f83a7fee7fb523d626d0ec480e9 100644 (file)
@@ -31,18 +31,9 @@ __pthread_cond_wait_2_0 (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex)
     {
       pthread_cond_t *newcond;
 
-#if LLL_LOCK_INITIALIZER == 0
       newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1);
       if (newcond == NULL)
        return ENOMEM;
-#else
-      newcond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t));
-      if (newcond == NULL)
-       return ENOMEM;
-
-      /* Initialize the condvar.  */
-      (void) pthread_cond_init (newcond, NULL);
-#endif
 
       if (atomic_compare_and_exchange_bool_acq (&cond->cond, newcond, NULL))
        /* Somebody else just initialized the condvar.  */
index fc1bfe57e504fcd4fed4eb91133b8c18d77314be..07d583f11a18322ce8bbe4beacef4ea63846bcf5 100644 (file)
@@ -71,23 +71,12 @@ typedef pthread_key_t __libc_key_t;
    For the C library we take a deeper look at the initializer.  For
    this implementation all fields are initialized to zero.  Therefore
    we don't initialize the variable which allows putting it into the
-   BSS section.  (Except on PA-RISC and other odd architectures, where
-   initialized locks must be set to one due to the lack of normal
-   atomic operations.) */
+   BSS section.  */
 
+_Static_assert (LLL_LOCK_INITIALIZER == 0, "LLL_LOCK_INITIALIZER != 0");
 #define _LIBC_LOCK_INITIALIZER LLL_LOCK_INITIALIZER
-#if IS_IN (libc) || IS_IN (libpthread)
-# if LLL_LOCK_INITIALIZER == 0
-#  define __libc_lock_define_initialized(CLASS,NAME) \
-  CLASS __libc_lock_t NAME;
-# else
-#  define __libc_lock_define_initialized(CLASS,NAME) \
-  CLASS __libc_lock_t NAME = LLL_LOCK_INITIALIZER;
-# endif
-#else
-# define __libc_lock_define_initialized(CLASS,NAME) \
+#define __libc_lock_define_initialized(CLASS,NAME) \
   CLASS __libc_lock_t NAME;
-#endif
 
 #define __libc_rwlock_define_initialized(CLASS,NAME) \
   CLASS __libc_rwlock_t NAME = PTHREAD_RWLOCK_INITIALIZER;