42 #ifdef MHD_USE_THREADS 44 #if defined(MHD_USE_W32_THREADS) 45 # define MHD_W32_MUTEX_ 1 46 # ifndef WIN32_LEAN_AND_MEAN 47 # define WIN32_LEAN_AND_MEAN 1 50 #elif defined(HAVE_PTHREAD_H) && defined(MHD_USE_POSIX_THREADS) 51 # define MHD_PTHREAD_MUTEX_ 1 54 # define HAVE_CONFIG_H 1 56 # error No base mutex API is available. 65 # define MHD_PANIC(msg) \ 66 do { fprintf (stderr, \ 67 "Abnormal termination at %d line in file %s: %s\n", \ 68 (int) __LINE__, __FILE__, msg); abort (); \ 72 #if defined(MHD_PTHREAD_MUTEX_) 73 typedef pthread_mutex_t MHD_mutex_;
74 #elif defined(MHD_W32_MUTEX_) 75 typedef CRITICAL_SECTION MHD_mutex_;
78 #if defined(MHD_PTHREAD_MUTEX_) 84 #define MHD_mutex_init_(pmutex) (! (pthread_mutex_init ((pmutex), NULL))) 85 #elif defined(MHD_W32_MUTEX_) 91 #define MHD_mutex_init_(pmutex) \ 92 (InitializeCriticalSectionAndSpinCount ((pmutex),16)) 95 #if defined(MHD_PTHREAD_MUTEX_) 96 # if defined(PTHREAD_MUTEX_INITIALIZER) 100 # define MHD_MUTEX_STATIC_DEFN_INIT_(m) \ 101 static MHD_mutex_ m = PTHREAD_MUTEX_INITIALIZER 105 #if defined(MHD_PTHREAD_MUTEX_) 111 #define MHD_mutex_destroy_(pmutex) (! (pthread_mutex_destroy ((pmutex)))) 112 #elif defined(MHD_W32_MUTEX_) 118 #define MHD_mutex_destroy_(pmutex) (DeleteCriticalSection ((pmutex)), ! 0) 126 #define MHD_mutex_destroy_chk_(pmutex) do { \ 127 if (! MHD_mutex_destroy_ (pmutex)) \ 128 MHD_PANIC (_ ("Failed to destroy mutex.\n")); \ 132 #if defined(MHD_PTHREAD_MUTEX_) 140 #define MHD_mutex_lock_(pmutex) (! (pthread_mutex_lock ((pmutex)))) 141 #elif defined(MHD_W32_MUTEX_) 149 #define MHD_mutex_lock_(pmutex) (EnterCriticalSection ((pmutex)), ! 0) 159 #define MHD_mutex_lock_chk_(pmutex) do { \ 160 if (! MHD_mutex_lock_ (pmutex)) \ 161 MHD_PANIC (_ ("Failed to lock mutex.\n")); \ 164 #if defined(MHD_PTHREAD_MUTEX_) 170 #define MHD_mutex_unlock_(pmutex) (! (pthread_mutex_unlock ((pmutex)))) 171 #elif defined(MHD_W32_MUTEX_) 177 #define MHD_mutex_unlock_(pmutex) (LeaveCriticalSection ((pmutex)), ! 0) 185 #define MHD_mutex_unlock_chk_(pmutex) do { \ 186 if (! MHD_mutex_unlock_ (pmutex)) \ 187 MHD_PANIC (_ ("Failed to unlock mutex.\n")); \ 192 #define MHD_mutex_init_(ignore) (! 0) 193 #define MHD_mutex_destroy_(ignore) (! 0) 194 #define MHD_mutex_destroy_chk_(ignore) (void)0 195 #define MHD_mutex_lock_(ignore) (! 0) 196 #define MHD_mutex_lock_chk_(ignore) (void)0 197 #define MHD_mutex_unlock_(ignore) (! 0) 198 #define MHD_mutex_unlock_chk_(ignore) (void)0 additional automatic macros for MHD_config.h