aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/mhd_locks.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/mhd_locks.h')
-rw-r--r--src/microhttpd/mhd_locks.h47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/microhttpd/mhd_locks.h b/src/microhttpd/mhd_locks.h
index 21db56c4..8c9b0844 100644
--- a/src/microhttpd/mhd_locks.h
+++ b/src/microhttpd/mhd_locks.h
@@ -59,14 +59,15 @@
59# include <stdlib.h> 59# include <stdlib.h>
60/* Simple implementation of MHD_PANIC, to be used outside lib */ 60/* Simple implementation of MHD_PANIC, to be used outside lib */
61# define MHD_PANIC(msg) do { fprintf (stderr, \ 61# define MHD_PANIC(msg) do { fprintf (stderr, \
62 "Abnormal termination at %d line in file %s: %s\n", \ 62 "Abnormal termination at %d line in file %s: %s\n", \
63 (int)__LINE__, __FILE__, msg); abort();} while(0) 63 (int) __LINE__, __FILE__, msg); abort (); \
64} while (0)
64#endif /* ! MHD_PANIC */ 65#endif /* ! MHD_PANIC */
65 66
66#if defined(MHD_PTHREAD_MUTEX_) 67#if defined(MHD_PTHREAD_MUTEX_)
67 typedef pthread_mutex_t MHD_mutex_; 68typedef pthread_mutex_t MHD_mutex_;
68#elif defined(MHD_W32_MUTEX_) 69#elif defined(MHD_W32_MUTEX_)
69 typedef CRITICAL_SECTION MHD_mutex_; 70typedef CRITICAL_SECTION MHD_mutex_;
70#endif 71#endif
71 72
72#if defined(MHD_PTHREAD_MUTEX_) 73#if defined(MHD_PTHREAD_MUTEX_)
@@ -75,14 +76,15 @@
75 * @param pmutex pointer to the mutex 76 * @param pmutex pointer to the mutex
76 * @return nonzero on success, zero otherwise 77 * @return nonzero on success, zero otherwise
77 */ 78 */
78#define MHD_mutex_init_(pmutex) (!(pthread_mutex_init((pmutex), NULL))) 79#define MHD_mutex_init_(pmutex) (! (pthread_mutex_init ((pmutex), NULL)))
79#elif defined(MHD_W32_MUTEX_) 80#elif defined(MHD_W32_MUTEX_)
80/** 81/**
81 * Initialise new mutex. 82 * Initialise new mutex.
82 * @param pmutex pointer to mutex 83 * @param pmutex pointer to mutex
83 * @return nonzero on success, zero otherwise 84 * @return nonzero on success, zero otherwise
84 */ 85 */
85#define MHD_mutex_init_(pmutex) (InitializeCriticalSectionAndSpinCount((pmutex),16)) 86#define MHD_mutex_init_(pmutex) (InitializeCriticalSectionAndSpinCount ( \
87 (pmutex),16))
86#endif 88#endif
87 89
88#if defined(MHD_PTHREAD_MUTEX_) 90#if defined(MHD_PTHREAD_MUTEX_)
@@ -90,7 +92,8 @@
90/** 92/**
91 * Define static mutex and statically initialise it. 93 * Define static mutex and statically initialise it.
92 */ 94 */
93# define MHD_MUTEX_STATIC_DEFN_INIT_(m) static MHD_mutex_ m = PTHREAD_MUTEX_INITIALIZER 95# define MHD_MUTEX_STATIC_DEFN_INIT_(m) static MHD_mutex_ m = \
96 PTHREAD_MUTEX_INITIALIZER
94# endif /* PTHREAD_MUTEX_INITIALIZER */ 97# endif /* PTHREAD_MUTEX_INITIALIZER */
95#endif 98#endif
96 99
@@ -100,14 +103,14 @@
100 * @param pmutex pointer to mutex 103 * @param pmutex pointer to mutex
101 * @return nonzero on success, zero otherwise 104 * @return nonzero on success, zero otherwise
102 */ 105 */
103#define MHD_mutex_destroy_(pmutex) (!(pthread_mutex_destroy((pmutex)))) 106#define MHD_mutex_destroy_(pmutex) (! (pthread_mutex_destroy ((pmutex))))
104#elif defined(MHD_W32_MUTEX_) 107#elif defined(MHD_W32_MUTEX_)
105/** 108/**
106 * Destroy previously initialised mutex. 109 * Destroy previously initialised mutex.
107 * @param pmutex pointer to mutex 110 * @param pmutex pointer to mutex
108 * @return Always nonzero 111 * @return Always nonzero
109 */ 112 */
110#define MHD_mutex_destroy_(pmutex) (DeleteCriticalSection((pmutex)), !0) 113#define MHD_mutex_destroy_(pmutex) (DeleteCriticalSection ((pmutex)), ! 0)
111#endif 114#endif
112 115
113/** 116/**
@@ -116,9 +119,9 @@
116 * @param pmutex pointer to mutex 119 * @param pmutex pointer to mutex
117 */ 120 */
118#define MHD_mutex_destroy_chk_(pmutex) do { \ 121#define MHD_mutex_destroy_chk_(pmutex) do { \
119 if (!MHD_mutex_destroy_(pmutex)) \ 122 if (! MHD_mutex_destroy_ (pmutex)) \
120 MHD_PANIC(_("Failed to destroy mutex.\n")); \ 123 MHD_PANIC (_ ("Failed to destroy mutex.\n")); \
121 } while(0) 124} while (0)
122 125
123 126
124#if defined(MHD_PTHREAD_MUTEX_) 127#if defined(MHD_PTHREAD_MUTEX_)
@@ -129,7 +132,7 @@
129 * @param pmutex pointer to mutex 132 * @param pmutex pointer to mutex
130 * @return nonzero on success, zero otherwise 133 * @return nonzero on success, zero otherwise
131 */ 134 */
132#define MHD_mutex_lock_(pmutex) (!(pthread_mutex_lock((pmutex)))) 135#define MHD_mutex_lock_(pmutex) (! (pthread_mutex_lock ((pmutex))))
133#elif defined(MHD_W32_MUTEX_) 136#elif defined(MHD_W32_MUTEX_)
134/** 137/**
135 * Acquire lock on previously initialised mutex. 138 * Acquire lock on previously initialised mutex.
@@ -138,7 +141,7 @@
138 * @param pmutex pointer to mutex 141 * @param pmutex pointer to mutex
139 * @return Always nonzero 142 * @return Always nonzero
140 */ 143 */
141#define MHD_mutex_lock_(pmutex) (EnterCriticalSection((pmutex)), !0) 144#define MHD_mutex_lock_(pmutex) (EnterCriticalSection ((pmutex)), ! 0)
142#endif 145#endif
143 146
144/** 147/**
@@ -149,9 +152,9 @@
149 * @param pmutex pointer to mutex 152 * @param pmutex pointer to mutex
150 */ 153 */
151#define MHD_mutex_lock_chk_(pmutex) do { \ 154#define MHD_mutex_lock_chk_(pmutex) do { \
152 if (!MHD_mutex_lock_(pmutex)) \ 155 if (! MHD_mutex_lock_ (pmutex)) \
153 MHD_PANIC(_("Failed to lock mutex.\n")); \ 156 MHD_PANIC (_ ("Failed to lock mutex.\n")); \
154 } while(0) 157} while (0)
155 158
156#if defined(MHD_PTHREAD_MUTEX_) 159#if defined(MHD_PTHREAD_MUTEX_)
157/** 160/**
@@ -159,14 +162,14 @@
159 * @param pmutex pointer to mutex 162 * @param pmutex pointer to mutex
160 * @return nonzero on success, zero otherwise 163 * @return nonzero on success, zero otherwise
161 */ 164 */
162#define MHD_mutex_unlock_(pmutex) (!(pthread_mutex_unlock((pmutex)))) 165#define MHD_mutex_unlock_(pmutex) (! (pthread_mutex_unlock ((pmutex))))
163#elif defined(MHD_W32_MUTEX_) 166#elif defined(MHD_W32_MUTEX_)
164/** 167/**
165 * Unlock previously initialised and locked mutex. 168 * Unlock previously initialised and locked mutex.
166 * @param pmutex pointer to mutex 169 * @param pmutex pointer to mutex
167 * @return Always nonzero 170 * @return Always nonzero
168 */ 171 */
169#define MHD_mutex_unlock_(pmutex) (LeaveCriticalSection((pmutex)), !0) 172#define MHD_mutex_unlock_(pmutex) (LeaveCriticalSection ((pmutex)), ! 0)
170#endif 173#endif
171 174
172/** 175/**
@@ -175,9 +178,9 @@
175 * @param pmutex pointer to mutex 178 * @param pmutex pointer to mutex
176 */ 179 */
177#define MHD_mutex_unlock_chk_(pmutex) do { \ 180#define MHD_mutex_unlock_chk_(pmutex) do { \
178 if (!MHD_mutex_unlock_(pmutex)) \ 181 if (! MHD_mutex_unlock_ (pmutex)) \
179 MHD_PANIC(_("Failed to unlock mutex.\n")); \ 182 MHD_PANIC (_ ("Failed to unlock mutex.\n")); \
180 } while(0) 183} while (0)
181 184
182 185
183#endif /* ! MHD_LOCKS_H */ 186#endif /* ! MHD_LOCKS_H */