diff options
Diffstat (limited to 'src/include/platform_interface.h')
-rw-r--r-- | src/include/platform_interface.h | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/include/platform_interface.h b/src/include/platform_interface.h index 9739e078..368e5f34 100644 --- a/src/include/platform_interface.h +++ b/src/include/platform_interface.h | |||
@@ -139,11 +139,45 @@ | |||
139 | #define MHD_random_() MHD_W32_random_() | 139 | #define MHD_random_() MHD_W32_random_() |
140 | #endif | 140 | #endif |
141 | 141 | ||
142 | #if defined(_WIN32) && !defined(__CYGWIN__) | 142 | #if defined(MHD_USE_POSIX_THREADS) |
143 | typedef pthread_t MHD_thread_handle_; | ||
144 | #elif defined(MHD_USE_W32_THREADS) | ||
145 | #include <windows.h> | ||
146 | typedef HANDLE MHD_thread_handle_; | ||
147 | #else | ||
148 | #error "No threading API is available." | ||
149 | #endif | ||
150 | |||
151 | #if defined(MHD_USE_POSIX_THREADS) | ||
152 | #define MHD_THRD_RTRN_TYPE_ void* | ||
153 | #define MHD_THRD_CALL_SPEC_ | ||
154 | #elif defined(MHD_USE_W32_THREADS) | ||
155 | #define MHD_THRD_RTRN_TYPE_ DWORD | ||
156 | #define MHD_THRD_CALL_SPEC_ WINAPI | ||
157 | #endif | ||
158 | |||
159 | #if defined(MHD_USE_POSIX_THREADS) | ||
160 | /** | ||
161 | * Wait until specified thread is ended | ||
162 | * @param thread ID to watch | ||
163 | * @return zero on success, nonzero on failure | ||
164 | */ | ||
165 | #define MHD_join_thread_(thread) pthread_join((thread), NULL) | ||
166 | #elif defined(MHD_USE_W32_THREADS) | ||
167 | /** | ||
168 | * Wait until specified thread is ended | ||
169 | * Close thread handle on success | ||
170 | * @param thread handle to watch | ||
171 | * @return zero on success, nonzero on failure | ||
172 | */ | ||
173 | #define MHD_join_thread_(thread) (WAIT_OBJECT_0 == WaitForSingleObject((thread), INFINITE) ? (CloseHandle((thread)), 0) : 1 ) | ||
174 | #endif | ||
175 | |||
176 | #if defined(MHD_USE_W32_THREADS) | ||
143 | #define MHD_W32_MUTEX_ 1 | 177 | #define MHD_W32_MUTEX_ 1 |
144 | #include <windows.h> | 178 | #include <windows.h> |
145 | typedef CRITICAL_SECTION MHD_mutex_; | 179 | typedef CRITICAL_SECTION MHD_mutex_; |
146 | #elif defined(HAVE_PTHREAD_H) | 180 | #elif defined(HAVE_PTHREAD_H) && defined(MHD_USE_POSIX_THREADS) |
147 | #define MHD_PTHREAD_MUTEX_ 1 | 181 | #define MHD_PTHREAD_MUTEX_ 1 |
148 | typedef pthread_mutex_t MHD_mutex_; | 182 | typedef pthread_mutex_t MHD_mutex_; |
149 | #else | 183 | #else |