25 #ifndef _PTHREAD_MALLOC_MACHINE_H
26 #define _PTHREAD_MALLOC_MACHINE_H
30 #undef thread_atfork_static
33 #if (defined __i386__ || defined __x86_64__) && defined __GNUC__ && \
34 !defined USE_NO_SPINLOCKS
40 volatile unsigned int lock;
44 #define MUTEX_INITIALIZER { 0 }
45 #define mutex_init(m) ((m)->lock = 0)
46 static inline int mutex_lock(mutex_t *m) {
53 :
"=r"(r),
"=m"(m->lock)
54 :
"0"(1),
"m"(m->lock)
69 static inline int mutex_trylock(mutex_t *m) {
74 :
"=r"(r),
"=m"(m->lock)
75 :
"0"(1),
"m"(m->lock)
79 static inline int mutex_unlock(mutex_t *m) {
81 __asm __volatile__ (
"" : : :
"memory");
88 typedef pthread_mutex_t mutex_t;
90 #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
91 #define mutex_init(m) pthread_mutex_init(m, NULL)
92 #define mutex_lock(m) pthread_mutex_lock(m)
93 #define mutex_trylock(m) pthread_mutex_trylock(m)
94 #define mutex_unlock(m) pthread_mutex_unlock(m)
99 #if defined(__sgi) || defined(USE_TSD_DATA_HACK)
106 typedef void *tsd_key_t[256];
107 #define tsd_key_create(key, destr) do { \
109 for(i=0; i<256; i++) (*key)[i] = 0; \
111 #define tsd_setspecific(key, data) \
112 (key[(unsigned)pthread_self() % 256] = (data))
113 #define tsd_getspecific(key, vptr) \
114 (vptr = key[(unsigned)pthread_self() % 256])
118 typedef pthread_key_t tsd_key_t;
120 #define tsd_key_create(key, destr) pthread_key_create(key, destr)
121 #define tsd_setspecific(key, data) pthread_setspecific(key, data)
122 #define tsd_getspecific(key, vptr) (vptr = pthread_getspecific(key))
127 #define thread_atfork(prepare, parent, child) \
128 pthread_atfork(prepare, parent, child)
130 #include <sysdeps/generic/malloc-machine.h>
Definition: ompi_time.h:160