[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32892 - libmicrohttpd/src/include
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32892 - libmicrohttpd/src/include |
Date: |
Fri, 4 Apr 2014 13:19:41 +0200 |
Author: Karlson2k
Date: 2014-04-04 13:19:41 +0200 (Fri, 04 Apr 2014)
New Revision: 32892
Modified:
libmicrohttpd/src/include/platform.h
libmicrohttpd/src/include/platform_interface.h
Log:
W32: use critical section instead of waitable object as MHD require
synchronization only within one process
Modified: libmicrohttpd/src/include/platform.h
===================================================================
--- libmicrohttpd/src/include/platform.h 2014-04-04 10:22:05 UTC (rev
32891)
+++ libmicrohttpd/src/include/platform.h 2014-04-04 11:19:41 UTC (rev
32892)
@@ -59,6 +59,9 @@
#error "Headers for Windows XP or later are required"
#endif // _WIN32_WINNT < 0x0501
#endif // _WIN32_WINNT
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif /* !WIN32_LEAN_AND_MEAN */
#endif // _WIN32
#include <stdio.h>
Modified: libmicrohttpd/src/include/platform_interface.h
===================================================================
--- libmicrohttpd/src/include/platform_interface.h 2014-04-04 10:22:05 UTC
(rev 32891)
+++ libmicrohttpd/src/include/platform_interface.h 2014-04-04 11:19:41 UTC
(rev 32892)
@@ -141,9 +141,8 @@
#if defined(_WIN32) && !defined(__CYGWIN__)
#define MHD_W32_MUTEX_ 1
-/* 'void*' is the same as 'HANDLE'
- * this way allow typedef without including "windows.h" */
-typedef void* MHD_mutex_;
+#include <windows.h>
+typedef CRITICAL_SECTION MHD_mutex_;
#elif defined(HAVE_PTHREAD_H)
#define MHD_PTHREAD_MUTEX_ 1
typedef pthread_mutex_t MHD_mutex_;
@@ -166,7 +165,7 @@
* @return #MHD_YES on success, #MHD_NO on failure
*/
#define MHD_mutex_create_(mutex) \
- ((NULL != (mutex) && NULL != (*(mutex) = CreateMutex(NULL, FALSE, NULL))) ?
MHD_YES : MHD_NO)
+ ((NULL != (mutex) && 0 !=
InitializeCriticalSectionAndSpinCount((mutex),2000)) ? MHD_YES : MHD_NO)
#endif
#if defined(MHD_PTHREAD_MUTEX_)
@@ -184,7 +183,7 @@
* @return #MHD_YES on success, #MHD_NO on failure
*/
#define MHD_mutex_destroy_(mutex) \
- ((NULL != (mutex) && 0 != CloseHandle(*(mutex)) && NULL == (*(mutex) =
NULL)) ? MHD_YES : MHD_NO)
+ ((NULL != (mutex)) ? (DeleteCriticalSection(mutex), MHD_YES) : MHD_NO)
#endif
#if defined(MHD_PTHREAD_MUTEX_)
@@ -206,7 +205,7 @@
* @return #MHD_YES on success, #MHD_NO on failure
*/
#define MHD_mutex_lock_(mutex) \
- ((NULL != (mutex) && WAIT_OBJECT_0 == WaitForSingleObject(*(mutex),
INFINITE)) ? MHD_YES : MHD_NO)
+ ((NULL != (mutex)) ? (EnterCriticalSection((mutex)), MHD_YES) : MHD_NO)
#endif
#if defined(MHD_PTHREAD_MUTEX_)
@@ -228,7 +227,7 @@
* mutex was not locked.
*/
#define MHD_mutex_trylock_(mutex) \
- ((NULL != (mutex) && WAIT_OBJECT_0 == WaitForSingleObject(*(mutex), 0)) ?
MHD_YES : MHD_NO)
+ ((NULL != (mutex) && 0 != TryEnterCriticalSection ((mutex))) ? MHD_YES :
MHD_NO)
#endif
#if defined(MHD_PTHREAD_MUTEX_)
@@ -246,7 +245,7 @@
* @return #MHD_YES on success, #MHD_NO on failure
*/
#define MHD_mutex_unlock_(mutex) \
- ((NULL != (mutex) && 0 != ReleaseMutex(*(mutex))) ? MHD_YES : MHD_NO)
+ ((NULL != (mutex)) ? (LeaveCriticalSection((mutex)), MHD_YES) : MHD_NO)
#endif
#endif // MHD_PLATFORM_INTERFACE_H
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32892 - libmicrohttpd/src/include,
gnunet <=