summaryrefslogtreecommitdiff
path: root/libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@uclibc-ng.org>2016-05-18 18:41:24 +0200
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2016-05-18 18:41:24 +0200
commit6a8ccc95528f5e86a8770ed15ce89609b5b3dee9 (patch)
treebbd4df35b4d4a6a8b00d7a5e61fb2668b850ad62 /libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h
parent398a27a5b323956344b4f831d892fed3bd9813c7 (diff)
remove linuxthreads.new, rename linuxthreads.old
Linuxthreads.new isn't really useful with the existence of NPTL/TLS for well supported architectures. There is no reason to use LT.new for ARM/MIPS or other architectures supporting NPTL/TLS. It is not available for noMMU architectures like Blackfin or FR-V. To simplify the live of the few uClibc-ng developers, LT.new is removed and LT.old is renamed to LT. LINUXTHREADS_OLD -> UCLIBC_HAS_LINUXTHREADS
Diffstat (limited to 'libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h')
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h63
1 files changed, 35 insertions, 28 deletions
diff --git a/libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h b/libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h
index 855efff12..a7c0249cf 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h
@@ -1,5 +1,5 @@
/* libc-internal interface for mutex locks. LinuxThreads version.
- Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003,2006
+ Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -29,7 +29,7 @@
/* Mutex type. */
#if defined(_LIBC) || defined(_IO_MTSAFE_IO)
typedef pthread_mutex_t __libc_lock_t;
-typedef struct { pthread_mutex_t mutex; } __libc_lock_recursive_t;
+typedef pthread_mutex_t __libc_lock_recursive_t;
# ifdef __USE_UNIX98
typedef pthread_rwlock_t __libc_rwlock_t;
# else
@@ -131,15 +131,39 @@ typedef pthread_key_t __libc_key_t;
#define __libc_rwlock_init(NAME) \
(__libc_maybe_call (__pthread_rwlock_init, (&(NAME), NULL), 0));
+/* Same as last but this time we initialize an adaptive mutex. */
+#if defined _LIBC && !defined NOT_IN_libc && defined SHARED
+#define __libc_lock_init_adaptive(NAME) \
+ ({ \
+ (NAME).__m_count = 0; \
+ (NAME).__m_owner = NULL; \
+ (NAME).__m_kind = PTHREAD_MUTEX_ADAPTIVE_NP; \
+ (NAME).__m_lock.__status = 0; \
+ (NAME).__m_lock.__spinlock = __LT_SPINLOCK_INIT; \
+ 0; })
+#else
+#define __libc_lock_init_adaptive(NAME) \
+ do { \
+ if (__pthread_mutex_init != NULL) \
+ { \
+ pthread_mutexattr_t __attr; \
+ __pthread_mutexattr_init (&__attr); \
+ __pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_ADAPTIVE_NP); \
+ __pthread_mutex_init (&(NAME), &__attr); \
+ __pthread_mutexattr_destroy (&__attr); \
+ } \
+ } while (0);
+#endif
+
/* Same as last but this time we initialize a recursive mutex. */
#if defined _LIBC && !defined NOT_IN_libc && defined SHARED
#define __libc_lock_init_recursive(NAME) \
({ \
- (NAME).mutex.__m_count = 0; \
- (NAME).mutex.__m_owner = NULL; \
- (NAME).mutex.__m_kind = PTHREAD_MUTEX_RECURSIVE_NP; \
- (NAME).mutex.__m_lock.__status = 0; \
- (NAME).mutex.__m_lock.__spinlock = __LT_SPINLOCK_INIT; \
+ (NAME).__m_count = 0; \
+ (NAME).__m_owner = NULL; \
+ (NAME).__m_kind = PTHREAD_MUTEX_RECURSIVE_NP; \
+ (NAME).__m_lock.__status = 0; \
+ (NAME).__m_lock.__spinlock = __LT_SPINLOCK_INIT; \
0; })
#else
#define __libc_lock_init_recursive(NAME) \
@@ -149,7 +173,7 @@ typedef pthread_key_t __libc_key_t;
pthread_mutexattr_t __attr; \
__pthread_mutexattr_init (&__attr); \
__pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_RECURSIVE_NP); \
- __pthread_mutex_init (&(NAME).mutex, &__attr); \
+ __pthread_mutex_init (&(NAME), &__attr); \
__pthread_mutexattr_destroy (&__attr); \
} \
} while (0);
@@ -202,23 +226,6 @@ typedef pthread_key_t __libc_key_t;
/* Unlock the recursive named lock variable. */
#define __libc_lock_unlock_recursive(NAME) __libc_lock_unlock ((NAME).mutex)
-#if defined _LIBC && defined SHARED
-# define __rtld_lock_default_lock_recursive(lock) \
- ++((pthread_mutex_t *)(lock))->__m_count;
-
-# define __rtld_lock_default_unlock_recursive(lock) \
- --((pthread_mutex_t *)(lock))->__m_count;
-
-# define __rtld_lock_lock_recursive(NAME) \
- GL(dl_rtld_lock_recursive) (&(NAME).mutex)
-
-# define __rtld_lock_unlock_recursive(NAME) \
- GL(dl_rtld_unlock_recursive) (&(NAME).mutex)
-#else
-#define __rtld_lock_lock_recursive(NAME) __libc_lock_lock_recursive (NAME)
-#define __rtld_lock_unlock_recursive(NAME) __libc_lock_unlock_recursive (NAME)
-#endif
-
/* Define once control variable. */
#if PTHREAD_ONCE_INIT == 0
/* Special case for static variables where we can avoid the initialization
@@ -237,7 +244,7 @@ typedef pthread_key_t __libc_key_t;
__pthread_once (&(ONCE_CONTROL), (INIT_FUNCTION)); \
else if ((ONCE_CONTROL) == PTHREAD_ONCE_INIT) { \
INIT_FUNCTION (); \
- (ONCE_CONTROL) = 2; \
+ (ONCE_CONTROL) = !PTHREAD_ONCE_INIT; \
} \
} while (0)
@@ -263,6 +270,7 @@ typedef pthread_key_t __libc_key_t;
_pthread_cleanup_pop_restore (&_buffer, (DOIT)); \
}
+#if 0
#define __libc_cleanup_push(fct, arg) \
{ struct _pthread_cleanup_buffer _buffer; \
__libc_maybe_call (_pthread_cleanup_push, (&_buffer, (fct), (arg)), 0)
@@ -270,6 +278,7 @@ typedef pthread_key_t __libc_key_t;
#define __libc_cleanup_pop(execute) \
__libc_maybe_call (_pthread_cleanup_pop, (&_buffer, execute), 0); \
}
+#endif
/* Create thread-specific key. */
#define __libc_key_create(KEY, DESTRUCTOR) \
@@ -367,7 +376,6 @@ weak_extern (BP_SYM (__pthread_key_create))
weak_extern (BP_SYM (__pthread_setspecific))
weak_extern (BP_SYM (__pthread_getspecific))
weak_extern (BP_SYM (__pthread_once))
-weak_extern (__pthread_initialize)
weak_extern (__pthread_atfork)
weak_extern (BP_SYM (_pthread_cleanup_push))
weak_extern (BP_SYM (_pthread_cleanup_pop))
@@ -392,7 +400,6 @@ weak_extern (BP_SYM (_pthread_cleanup_pop_restore))
# pragma weak __pthread_setspecific
# pragma weak __pthread_getspecific
# pragma weak __pthread_once
-# pragma weak __pthread_initialize
# pragma weak __pthread_atfork
# pragma weak _pthread_cleanup_push_defer
# pragma weak _pthread_cleanup_pop_restore