Merge pull request #2274 from esdrubal/udpclientreceive
[mono.git] / mono / io-layer / semaphores.c
index 229e313070fafd1dca012819feedce3f8864e04a..01179f4d18244f0e3469aeecc5d6a1a0a90de149 100644 (file)
 
 #include <mono/io-layer/wapi.h>
 #include <mono/io-layer/wapi-private.h>
-#include <mono/io-layer/misc-private.h>
 #include <mono/io-layer/handles-private.h>
 #include <mono/io-layer/semaphore-private.h>
-
-#include <mono/utils/mono-mutex.h>
+#include <mono/utils/mono-once.h>
 
 #if 0
 #define DEBUG(...) g_message(__VA_ARGS__)
@@ -89,11 +87,9 @@ static mono_once_t sem_ops_once=MONO_ONCE_INIT;
 static void sem_ops_init (void)
 {
        _wapi_handle_register_capabilities (WAPI_HANDLE_SEM,
-                                           WAPI_HANDLE_CAP_WAIT |
-                                           WAPI_HANDLE_CAP_SIGNAL);
+               (WapiHandleCapability)(WAPI_HANDLE_CAP_WAIT | WAPI_HANDLE_CAP_SIGNAL));
        _wapi_handle_register_capabilities (WAPI_HANDLE_NAMEDSEM,
-                                           WAPI_HANDLE_CAP_WAIT |
-                                           WAPI_HANDLE_CAP_SIGNAL);
+               (WapiHandleCapability)(WAPI_HANDLE_CAP_WAIT | WAPI_HANDLE_CAP_SIGNAL));
 }
 
 static void sema_signal(gpointer handle)
@@ -182,8 +178,6 @@ static gpointer sem_create (WapiSecurityAttributes *security G_GNUC_UNUSED,
                return(NULL);
        }
 
-       pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
-                             handle);
        thr_ret = _wapi_handle_lock_handle (handle);
        g_assert (thr_ret == 0);
        
@@ -196,7 +190,6 @@ static gpointer sem_create (WapiSecurityAttributes *security G_GNUC_UNUSED,
 
        thr_ret = _wapi_handle_unlock_handle (handle);
        g_assert (thr_ret == 0);
-       pthread_cleanup_pop (0);
 
        return(handle);
 }
@@ -358,8 +351,6 @@ static gboolean sem_release (gpointer handle, gint32 count, gint32 *prevcount)
                return(FALSE);
        }
 
-       pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
-                             handle);
        thr_ret = _wapi_handle_lock_handle (handle);
        g_assert (thr_ret == 0);
 
@@ -390,7 +381,6 @@ static gboolean sem_release (gpointer handle, gint32 count, gint32 *prevcount)
 end:
        thr_ret = _wapi_handle_unlock_handle (handle);
        g_assert (thr_ret == 0);
-       pthread_cleanup_pop (0);
 
        return(ret);
 }