00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _THREAD_H_
00020 #define _THREAD_H_
00021
00022
00023
00024
00025
00026 #ifdef _REENTRANT
00027
00028 #include <pthread.h>
00029
00030
00031
00032
00033
00034 #define mutex_debug 0
00035
00036 #define mutex_lock(st) do { \
00037 if (mutex_debug) \
00038 printf("%s takes the lock\n", __func__); \
00039 (void) pthread_mutex_lock(&st->mutex); \
00040 } while (0)
00041
00042 #define mutex_unlock(st) do { \
00043 if (mutex_debug) \
00044 printf(" %s releases the lock\n", __func__); \
00045 (void) pthread_mutex_unlock(&st->mutex); \
00046 } while (0)
00047
00048
00049 #else
00050
00051
00052
00053 #define pthread_noop (0)
00054 #define pthread_t int
00055 #define pthread_key_t int
00056 #define pthread_mutex_t int
00057 #define pthread_mutex_init(x,y) pthread_noop
00058 #define pthread_mutex_lock(x) pthread_noop
00059 #define pthread_mutex_unlock(x) pthread_noop
00060 #define pthread_key_create(x,y) pthread_noop
00061 #define pthread_key_delete(x) pthread_noop
00062 #define pthread_getspecific(x) pthread_noop
00063 #define pthread_setspecific(x,y) pthread_noop
00064 #define pthread_sigmask(x,y,z) setsigmask(x,y,z)
00065 #define mutex_lock(x) do { ; } while (0)
00066 #define mutex_unlock(x) do { ; } while (0)
00067
00068
00069 #define pthread_once_t int
00070 #define PTHREAD_ONCE_INIT 0
00071 #define pthread_once(var,func) (*var = 1)
00072 #define FIXME_pthread_once(var,func) do { \
00073 if (!*var) \
00074 { func(); *var = 1; } \
00075 } while (0)
00076
00077
00078
00079
00080
00081
00082 #define FIXME pthread_cleanup_push(x,y) pthread_noop
00083
00084 #endif
00085
00086 #endif