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.
This commit is contained in:
Ulrich Drepper 2002-12-12 01:01:43 +00:00
parent fdb933e255
commit f494b70b55
2 changed files with 15 additions and 26 deletions

View file

@ -1,3 +1,13 @@
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.
2002-12-11 Roland McGrath <roland@redhat.com>
* csu/Makefile ($(objpfx)elf-init.oS): New target, just clone

View file

@ -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))