aboutsummaryrefslogtreecommitdiff
path: root/malloc
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-12-18 00:53:21 +0000
committerUlrich Drepper <drepper@redhat.com>2002-12-18 00:53:21 +0000
commitf077a4a9f027b938bd091583e3ec34725cba428c (patch)
tree6052d47da431d7cd5e745dab1a908a5f54ffbfc7 /malloc
parenta7d5c29129aab547faff1fd2cfe0d9095ec4689b (diff)
downloadglibc-f077a4a9f027b938bd091583e3ec34725cba428c.tar
glibc-f077a4a9f027b938bd091583e3ec34725cba428c.tar.gz
glibc-f077a4a9f027b938bd091583e3ec34725cba428c.tar.bz2
glibc-f077a4a9f027b938bd091583e3ec34725cba428c.zip
Update.
2002-12-17 Jakub Jelinek <jakub@redhat.com> * 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.
Diffstat (limited to 'malloc')
-rw-r--r--malloc/thread-m.h37
1 files changed, 29 insertions, 8 deletions
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)