From f077a4a9f027b938bd091583e3ec34725cba428c Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 18 Dec 2002 00:53:21 +0000 Subject: Update. 2002-12-17 Jakub Jelinek * malloc/thread-m.h (mutex_init, mutex_lock, mutex_trylock, mutex_unlock): If not building NPTL, use __libc_maybe_call2 if available, otherwise __libc_maybe_call. * sysdeps/unix/sysv/linux/x86_64/recv.c: Add support for cancellation handling. * sysdeps/unix/sysv/linux/x86_64/send.c: Likewise. --- malloc/thread-m.h | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'malloc/thread-m.h') diff --git a/malloc/thread-m.h b/malloc/thread-m.h index 34fea0e7d4..49db784c52 100644 --- a/malloc/thread-m.h +++ b/malloc/thread-m.h @@ -35,21 +35,42 @@ #ifdef PTHREAD_MUTEX_INITIALIZER -/* mutex */ __libc_lock_define (typedef, mutex_t) -/* Even if not linking with libpthread, ensure usability of mutex as - an `in use' flag, see also the NO_THREADS case below. Assume - pthread_mutex_t is at least one int wide. */ +#if defined(LLL_LOCK_INITIALIZER) && !defined(NOT_IN_libc) + +/* Assume NPTL. */ + +#define mutex_init(m) __libc_lock_init (*(m)) +#define mutex_lock(m) __libc_lock_lock (*(m)) +#define mutex_trylock(m) __libc_lock_trylock (*(m)) +#define mutex_unlock(m) __libc_lock_unlock (*(m)) + +#elif defined(__libc_maybe_call2) #define mutex_init(m) \ - __libc_lock_init (*m) + __libc_maybe_call2 (pthread_mutex_init, (m, NULL), (*(int *)(m) = 0)) #define mutex_lock(m) \ - __libc_lock_lock (*m) + __libc_maybe_call2 (pthread_mutex_lock, (m), ((*(int *)(m) = 1), 0)) #define mutex_trylock(m) \ - __libc_lock_trylock (*m) + __libc_maybe_call2 (pthread_mutex_trylock, (m), \ + (*(int *)(m) ? 1 : ((*(int *)(m) = 1), 0))) #define mutex_unlock(m) \ - __libc_lock_unlock (*m) + __libc_maybe_call2 (pthread_mutex_unlock, (m), (*(int *)(m) = 0)) + +#else + +#define mutex_init(m) \ + __libc_maybe_call (__pthread_mutex_init, (m, NULL), (*(int *)(m) = 0)) +#define mutex_lock(m) \ + __libc_maybe_call (__pthread_mutex_lock, (m), ((*(int *)(m) = 1), 0)) +#define mutex_trylock(m) \ + __libc_maybe_call (__pthread_mutex_trylock, (m), \ + (*(int *)(m) ? 1 : ((*(int *)(m) = 1), 0))) +#define mutex_unlock(m) \ + __libc_maybe_call (__pthread_mutex_unlock, (m), (*(int *)(m) = 0)) + +#endif #define thread_atfork(prepare, parent, child) \ (__pthread_atfork != NULL ? __pthread_atfork(prepare, parent, child) : 0) -- cgit v1.2.3