aboutsummaryrefslogtreecommitdiff
path: root/malloc
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-12-12 01:01:43 +0000
committerUlrich Drepper <drepper@redhat.com>2002-12-12 01:01:43 +0000
commitf494b70b551e1d2e6d4ce4f5eec41b366cea77c1 (patch)
tree4bfa85967d6f00ff9ffdb131b1435ff178e2e4b1 /malloc
parentfdb933e2553b89cc23807a37028658a44a1df50a (diff)
downloadglibc-f494b70b551e1d2e6d4ce4f5eec41b366cea77c1.tar
glibc-f494b70b551e1d2e6d4ce4f5eec41b366cea77c1.tar.gz
glibc-f494b70b551e1d2e6d4ce4f5eec41b366cea77c1.tar.bz2
glibc-f494b70b551e1d2e6d4ce4f5eec41b366cea77c1.zip
Update.
2002-12-11 Ulrich Drepper <drepper@redhat.com> * malloc/thread-m.h: Remove thread_id type and MUTEX_INITIALIZER definitions. Not needed. [_LIBC]: Use definitions from libc-lock.h instead of referencing pthread routines directly. * malloc/arena.c (ptmalloc_unlock_all2): Don't add (void) to mutex_init calls. (arena_get2): Don't look at return value of mutex_lock.
Diffstat (limited to 'malloc')
-rw-r--r--malloc/thread-m.h31
1 files changed, 5 insertions, 26 deletions
diff --git a/malloc/thread-m.h b/malloc/thread-m.h
index 3fec10afad..34fea0e7d4 100644
--- a/malloc/thread-m.h
+++ b/malloc/thread-m.h
@@ -35,29 +35,21 @@
#ifdef PTHREAD_MUTEX_INITIALIZER
-typedef pthread_t thread_id;
-
/* mutex */
-typedef pthread_mutex_t mutex_t;
-
-#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+__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. */
#define mutex_init(m) \
- (__pthread_mutex_init != NULL \
- ? __pthread_mutex_init (m, NULL) : (*(int *)(m) = 0))
+ __libc_lock_init (*m)
#define mutex_lock(m) \
- (__pthread_mutex_lock != NULL \
- ? __pthread_mutex_lock (m) : ((*(int *)(m) = 1), 0))
+ __libc_lock_lock (*m)
#define mutex_trylock(m) \
- (__pthread_mutex_trylock != NULL \
- ? __pthread_mutex_trylock (m) : (*(int *)(m) ? 1 : ((*(int *)(m) = 1), 0)))
+ __libc_lock_trylock (*m)
#define mutex_unlock(m) \
- (__pthread_mutex_unlock != NULL \
- ? __pthread_mutex_unlock (m) : (*(int*)(m) = 0))
+ __libc_lock_unlock (*m)
#define thread_atfork(prepare, parent, child) \
(__pthread_atfork != NULL ? __pthread_atfork(prepare, parent, child) : 0)
@@ -114,8 +106,6 @@ __libc_tsd_define (static, MALLOC) /* declaration/common definition */
#include <pthread.h>
-typedef pthread_t thread_id;
-
/* mutex */
#if (defined __i386__ || defined __x86_64__) && defined __GNUC__ && \
!defined USE_NO_SPINLOCKS
@@ -128,7 +118,6 @@ typedef struct {
int pad0_;
} mutex_t;
-#define MUTEX_INITIALIZER { 0 }
#define mutex_init(m) ((m)->lock = 0)
static inline int mutex_lock(mutex_t *m) {
int cnt = 0, r;
@@ -174,7 +163,6 @@ static inline int mutex_unlock(mutex_t *m) {
/* Normal pthread mutex. */
typedef pthread_mutex_t mutex_t;
-#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#define mutex_init(m) pthread_mutex_init(m, NULL)
#define mutex_lock(m) pthread_mutex_lock(m)
#define mutex_trylock(m) pthread_mutex_trylock(m)
@@ -218,9 +206,6 @@ typedef pthread_key_t tsd_key_t;
#include <thread.h>
-typedef thread_t thread_id;
-
-#define MUTEX_INITIALIZER { 0 }
#define mutex_init(m) mutex_init(m, USYNC_THREAD, NULL)
/*
@@ -244,11 +229,8 @@ typedef void *tsd_key_t[256];
#include <sys/prctl.h>
#include <abi_mutex.h>
-typedef int thread_id;
-
typedef abilock_t mutex_t;
-#define MUTEX_INITIALIZER { 0 }
#define mutex_init(m) init_lock(m)
#define mutex_lock(m) (spin_lock(m), 0)
#define mutex_trylock(m) acquire_lock(m)
@@ -270,8 +252,6 @@ int tsd_key_next;
#ifdef NO_THREADS /* No threads, provide dummy macros */
-typedef int thread_id;
-
/* The mutex functions used to do absolutely nothing, i.e. lock,
trylock and unlock would always just return 0. However, even
without any concurrently active threads, a mutex can be used
@@ -280,7 +260,6 @@ typedef int thread_id;
be based on atomic test-and-set operations, for example. */
typedef int mutex_t;
-#define MUTEX_INITIALIZER 0
#define mutex_init(m) (*(m) = 0)
#define mutex_lock(m) ((*(m) = 1), 0)
#define mutex_trylock(m) (*(m) ? 1 : ((*(m) = 1), 0))