about summary refs log tree commit diff
path: root/linuxthreads/sysdeps/pthread/bits/libc-lock.h
diff options
context:
space:
mode:
Diffstat (limited to 'linuxthreads/sysdeps/pthread/bits/libc-lock.h')
-rw-r--r--linuxthreads/sysdeps/pthread/bits/libc-lock.h23
1 files changed, 16 insertions, 7 deletions
diff --git a/linuxthreads/sysdeps/pthread/bits/libc-lock.h b/linuxthreads/sysdeps/pthread/bits/libc-lock.h
index d0e9a8d9b4..41bca4de3f 100644
--- a/linuxthreads/sysdeps/pthread/bits/libc-lock.h
+++ b/linuxthreads/sysdeps/pthread/bits/libc-lock.h
@@ -48,12 +48,21 @@ typedef pthread_key_t __libc_key_t;
 
 /* Define an initialized lock variable NAME with storage class CLASS.
 
-   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.  */
-#define __libc_lock_define_initialized(CLASS,NAME) \
+   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.) */
+
+#if LT_SPINLOCK_INIT == 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 = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
 #define __libc_rwlock_define_initialized(CLASS,NAME) \
   CLASS __libc_rwlock_t NAME = PTHREAD_RWLOCK_INITIALIZER;
 
@@ -143,9 +152,9 @@ typedef pthread_key_t __libc_key_t;
   do {									      \
     if (__pthread_once != NULL)						      \
       __pthread_once (&(ONCE_CONTROL), (INIT_FUNCTION));		      \
-    else if ((ONCE_CONTROL) == 0) {					      \
+    else if ((ONCE_CONTROL) == PTHREAD_ONCE_INIT) {			      \
       INIT_FUNCTION ();							      \
-      (ONCE_CONTROL) = 1;						      \
+      (ONCE_CONTROL) = !PTHREAD_ONCE_INIT;				      \
     }									      \
   } while (0)