diff options
| author | Waldemar Brodkorb <wbx@openadk.org> | 2015-02-14 23:00:19 -0600 | 
|---|---|---|
| committer | Waldemar Brodkorb <wbx@openadk.org> | 2015-02-14 23:00:19 -0600 | 
| commit | 6b6ede3d15f04fe825cfa9f697507457e3640344 (patch) | |
| tree | efe9bf75eaf2200f89087ed0ef2ef350549ccd6d /libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h | |
| parent | f972c2262fd4efc2bbf9789dce145bb705acec24 (diff) | |
resolve merge
Diffstat (limited to 'libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h')
| -rw-r--r-- | libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h | 65 | 
1 files changed, 36 insertions, 29 deletions
diff --git a/libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h b/libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h index 855efff12..8833e343d 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. @@ -23,13 +23,13 @@  #include <pthread.h>  #if defined _LIBC && !defined NOT_IN_libc -#include <linuxthreads/internals.h> +#include <linuxthreads.old/internals.h>  #endif  /* 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  | 
