diff options
author | Ulrich Drepper <drepper@redhat.com> | 2002-01-31 03:41:25 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2002-01-31 03:41:25 +0000 |
commit | d6b5d570a3255d8dc80e07c3674594574cd98fe7 (patch) | |
tree | 36e05b0d065614559820d2a4f43bb1076ea5cfa1 /malloc/thread-m.h | |
parent | 1b4575aefaaa43adfed4658f7d66de587f12120e (diff) | |
download | glibc-d6b5d570a3255d8dc80e07c3674594574cd98fe7.tar glibc-d6b5d570a3255d8dc80e07c3674594574cd98fe7.tar.gz glibc-d6b5d570a3255d8dc80e07c3674594574cd98fe7.tar.bz2 glibc-d6b5d570a3255d8dc80e07c3674594574cd98fe7.zip |
Update.
2002-01-30 Ulrich Drepper <drepper@redhat.com>
* Versions.def [ld]: Add GLIBC_2.3.
* elf/dl-addr.c: Move global variables for SHARED code in struct
_rtld_global. Export this struct, remove all exports for the
signal variables.
* elf/dl-close.c: Likewise.
* elf/dl-conflict.c: Likewise.
* elf/dl-debug.c: Likewise.
* elf/dl-deps.c: Likewise.
* elf/dl-dst.h: Likewise.
* elf/dl-error.c: Likewise.
* elf/dl-fini.c: Likewise.
* elf/dl-init.c: Likewise.
* elf/dl-iteratephdr.c: Likewise.
* elf/dl-libc.c: Likewise.
* elf/dl-load.c: Likewise.
* elf/dl-lookup.c: Likewise.
* elf/dl-minimal.c: Likewise.
* elf/dl-object.c: Likewise.
* elf/dl-open.c: Likewise.
* elf/dl-profile.c: Likewise.
* elf/dl-profstub.c: Likewise.
* elf/dl-reloc.c: Likewise.
* elf/dl-runtime.c: Likewise.
* elf/dl-support.c: Likewise.
* elf/dl-sym.c: Likewise.
* elf/dl-version.c: Likewise.
* elf/do-lookup.h: Likewise.
* elf/do-rel.h: Likewise.
* elf/dynamic-link.h: Likewise.
* elf/rtld.c: Likewise.
* sysdeps/generic/dl-cache.c: Likewise.
* sysdeps/generic/dl-sysdep.c: Likewise.
* sysdeps/generic/ldsodefs.h: Likewise.
* sysdeps/generic/libc-start.c: Likewise.
* sysdeps/i386/dl-machine.h: Likewise.
* sysdeps/ia64/dl-fptr.c: Likewise.
* sysdeps/ia64/dl-machine.h: Likewise.
* sysdeps/unix/sysv/linux/dl-librecon.h: Likewise.
* sysdeps/unix/sysv/linux/dl-origin.c: Likewise.
* sysdeps/unix/sysv/linux/dl-osinfo.h: Likewise.
* sysdeps/unix/sysv/linux/getclktck.c: Likewise.
* sysdeps/unix/sysv/linux/getpagesize.c: Likewise.
* sysdeps/unix/sysv/linux/i386/dl-librecon.h: Likewise.
* sysdeps/unix/sysv/linux/ia64/dl-static.c: Likewise.
* sysdeps/unix/sysv/linux/ia64/getpagesize.c: Likewise.
* malloc/thread-m.h: Spinlock definitions for x86/x86_64.
Diffstat (limited to 'malloc/thread-m.h')
-rw-r--r-- | malloc/thread-m.h | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/malloc/thread-m.h b/malloc/thread-m.h index 145730c8c3..9cbfb497b8 100644 --- a/malloc/thread-m.h +++ b/malloc/thread-m.h @@ -1,8 +1,8 @@ /* Basic platform-independent macro definitions for mutexes and thread-specific data. - Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Wolfram Gloger <wmglo@dent.med.uni-muenchen.de>, 1996. + Contributed by Wolfram Gloger <wg@malloc.de>, 2001. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -117,6 +117,61 @@ __libc_tsd_define (, MALLOC) /* declaration/common definition */ typedef pthread_t thread_id; /* mutex */ +#if (defined __i386__ || defined __x86_64__) && defined __GNUC__ && \ + !defined USE_NO_SPINLOCKS + +#include <time.h> + +/* Use fast inline spinlocks. */ +typedef struct { + volatile unsigned int lock; + 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; + struct timespec tm; + + for(;;) { + __asm__ __volatile__ + ("xchgl %0, %1" + : "=r"(r), "=m"(m->lock) + : "0"(1), "m"(m->lock) + : "memory"); + if(!r) + return 0; + if(cnt < 50) { + sched_yield(); + cnt++; + } else { + tm.tv_sec = 0; + tm.tv_nsec = 2000001; + nanosleep(&tm, NULL); + cnt = 0; + } + } +} +static inline int mutex_trylock(mutex_t *m) { + int r; + + __asm__ __volatile__ + ("xchgl %0, %1" + : "=r"(r), "=m"(m->lock) + : "0"(1), "m"(m->lock) + : "memory"); + return r; +} +static inline int mutex_unlock(mutex_t *m) { + m->lock = 0; + __asm __volatile ("" : "=m" (m->lock) : "0" (m->lock)); + return 0; +} + +#else + +/* Normal pthread mutex. */ typedef pthread_mutex_t mutex_t; #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER @@ -125,6 +180,8 @@ typedef pthread_mutex_t mutex_t; #define mutex_trylock(m) pthread_mutex_trylock(m) #define mutex_unlock(m) pthread_mutex_unlock(m) +#endif /* (__i386__ || __x86_64__) && __GNUC__ && !USE_NO_SPINLOCKS */ + /* thread specific data */ #if defined(__sgi) || defined(USE_TSD_DATA_HACK) |