#include <mono/io-layer/wapi.h>
#include <mono/io-layer/wapi-private.h>
#include <mono/io-layer/handles-private.h>
-#include <mono/io-layer/misc-private.h>
-
-#include <mono/io-layer/mono-mutex.h>
-
#include <mono/io-layer/event-private.h>
+#include <mono/utils/mono-once.h>
-#undef DEBUG
+#if 0
+#define DEBUG(...) g_message(__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
static void event_signal(gpointer handle);
static gboolean event_own (gpointer handle);
static void event_ops_init (void)
{
_wapi_handle_register_capabilities (WAPI_HANDLE_EVENT,
- WAPI_HANDLE_CAP_WAIT |
- WAPI_HANDLE_CAP_SIGNAL);
+ (WapiHandleCapability)(WAPI_HANDLE_CAP_WAIT | WAPI_HANDLE_CAP_SIGNAL));
_wapi_handle_register_capabilities (WAPI_HANDLE_NAMEDEVENT,
- WAPI_HANDLE_CAP_WAIT |
- WAPI_HANDLE_CAP_SIGNAL);
+ (WapiHandleCapability)(WAPI_HANDLE_CAP_WAIT | WAPI_HANDLE_CAP_SIGNAL));
}
static void event_signal(gpointer handle)
{
- ResetEvent(handle);
+ SetEvent(handle);
}
static gboolean event_own (gpointer handle)
return (FALSE);
}
-#ifdef DEBUG
- g_message("%s: owning event handle %p", __func__, handle);
-#endif
+ DEBUG("%s: owning event handle %p", __func__, handle);
if(event_handle->manual==FALSE) {
g_assert (event_handle->set_count > 0);
static void namedevent_signal (gpointer handle)
{
- ResetEvent (handle);
+ SetEvent (handle);
}
/* NB, always called with the shared handle lock held */
struct _WapiHandle_namedevent *namedevent_handle;
gboolean ok;
-#ifdef DEBUG
- g_message ("%s: owning named event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: owning named event handle %p", __func__, handle);
ok = _wapi_lookup_handle (handle, WAPI_HANDLE_NAMEDEVENT,
(gpointer *)&namedevent_handle);
*/
SetLastError (ERROR_SUCCESS);
-#ifdef DEBUG
- g_message ("%s: Creating unnamed event", __func__);
-#endif
+ DEBUG ("%s: Creating unnamed event", __func__);
event_handle.manual = manual;
event_handle.set_count = 0;
return(NULL);
}
- pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
- handle);
thr_ret = _wapi_handle_lock_handle (handle);
g_assert (thr_ret == 0);
_wapi_handle_set_signal_state (handle, TRUE, FALSE);
}
-#ifdef DEBUG
- g_message("%s: created new event handle %p", __func__, handle);
-#endif
+ DEBUG("%s: created new event handle %p", __func__, handle);
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
- pthread_cleanup_pop (0);
return(handle);
}
utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
-#ifdef DEBUG
- g_message ("%s: Creating named event [%s]", __func__, utf8_name);
-#endif
+ DEBUG ("%s: Creating named event [%s]", __func__, utf8_name);
offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDEVENT,
utf8_name);
_wapi_handle_unlock_shared_handles ();
}
-#ifdef DEBUG
- g_message ("%s: returning event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: returning event handle %p", __func__, handle);
cleanup:
g_free (utf8_name);
return(FALSE);
}
- pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
- handle);
thr_ret = _wapi_handle_lock_handle (handle);
g_assert (thr_ret == 0);
-#ifdef DEBUG
- g_message ("%s: Pulsing event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: Pulsing event handle %p", __func__, handle);
if (event_handle->manual == TRUE) {
_wapi_handle_set_signal_state (handle, TRUE, TRUE);
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
- pthread_cleanup_pop (0);
-
if (event_handle->manual == TRUE) {
/* For a manual-reset event, we're about to try and
* get the handle lock again, so give other threads a
* have proceeded. Currently we rely on broadcasting
* a condition.
*/
-#ifdef DEBUG
- g_message ("%s: Obtained write lock on event handle %p",
+ DEBUG ("%s: Obtained write lock on event handle %p",
__func__, handle);
-#endif
- pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle, handle);
thr_ret = _wapi_handle_lock_handle (handle);
g_assert (thr_ret == 0);
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
- pthread_cleanup_pop (0);
}
return(TRUE);
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
-#ifdef DEBUG
- g_message ("%s: Pulsing named event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: Pulsing named event handle %p", __func__, handle);
if (namedevent_handle->manual == TRUE) {
_wapi_shared_handle_set_signal_state (handle, TRUE);
* have proceeded. Currently we rely on waiting for
* twice the shared handle poll interval.
*/
-#ifdef DEBUG
- g_message ("%s: Obtained write lock on event handle %p",
+ DEBUG ("%s: Obtained write lock on event handle %p",
__func__, handle);
-#endif
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
return(FALSE);
}
-#ifdef DEBUG
- g_message ("%s: Resetting event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: Resetting event handle %p", __func__, handle);
- pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
- handle);
thr_ret = _wapi_handle_lock_handle (handle);
g_assert (thr_ret == 0);
if (_wapi_handle_issignalled (handle) == FALSE) {
-#ifdef DEBUG
- g_message ("%s: No need to reset event handle %p", __func__,
+ DEBUG ("%s: No need to reset event handle %p", __func__,
handle);
-#endif
} else {
-#ifdef DEBUG
- g_message ("%s: Obtained write lock on event handle %p",
+ DEBUG ("%s: Obtained write lock on event handle %p",
__func__, handle);
-#endif
_wapi_handle_set_signal_state (handle, FALSE, FALSE);
}
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
- pthread_cleanup_pop (0);
-
return(TRUE);
}
return(FALSE);
}
-#ifdef DEBUG
- g_message ("%s: Resetting named event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: Resetting named event handle %p", __func__, handle);
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
if (_wapi_handle_issignalled (handle) == FALSE) {
-#ifdef DEBUG
- g_message ("%s: No need to reset named event handle %p",
+ DEBUG ("%s: No need to reset named event handle %p",
__func__, handle);
-#endif
} else {
-#ifdef DEBUG
- g_message ("%s: Obtained write lock on named event handle %p",
+ DEBUG ("%s: Obtained write lock on named event handle %p",
__func__, handle);
-#endif
_wapi_shared_handle_set_signal_state (handle, FALSE);
}
return(FALSE);
}
- pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
- handle);
thr_ret = _wapi_handle_lock_handle (handle);
g_assert (thr_ret == 0);
-#ifdef DEBUG
- g_message ("%s: Setting event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: Setting event handle %p", __func__, handle);
if (event_handle->manual == TRUE) {
_wapi_handle_set_signal_state (handle, TRUE, TRUE);
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
- pthread_cleanup_pop (0);
-
return(TRUE);
}
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
-#ifdef DEBUG
- g_message ("%s: Setting named event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: Setting named event handle %p", __func__, handle);
if (namedevent_handle->manual == TRUE) {
_wapi_shared_handle_set_signal_state (handle, TRUE);
utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
-#ifdef DEBUG
- g_message ("%s: Opening named event [%s]", __func__, utf8_name);
-#endif
+ DEBUG ("%s: Opening named event [%s]", __func__, utf8_name);
offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDEVENT,
utf8_name);
}
ret = handle;
-#ifdef DEBUG
- g_message ("%s: returning named event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: returning named event handle %p", __func__, handle);
cleanup:
g_free (utf8_name);