[io-layer] Remove wait.h
[mono.git] / mono / metadata / monitor.c
index 1d9ff1b8acc251ee6fd5524232aa1edf35204b71..02a5ef6825d946b701c84d929b7041a44315898b 100644 (file)
@@ -868,7 +868,7 @@ retry_contended:
                }
        }
 
-       if (ms != INFINITE) {
+       if (ms != MONO_INFINITE_WAIT) {
                then = mono_msec_ticks ();
        }
        waitms = ms;
@@ -919,7 +919,7 @@ done_waiting:
                 * allow_interruption is FALSE to avoid hangs at shutdown.
                 */
                if (!mono_thread_test_state (mono_thread_internal_current (), (MonoThreadState)(ThreadState_StopRequested | ThreadState_SuspendRequested | ThreadState_AbortRequested))) {
-                       if (ms != INFINITE) {
+                       if (ms != MONO_INFINITE_WAIT) {
                                now = mono_msec_ticks ();
 
                                /* it should not overflow before ~30k years */
@@ -1032,7 +1032,7 @@ mono_monitor_enter (MonoObject *obj)
         * it will return NULL meaning we can't be aborted right now. Once that happens we switch to non-alertable.
         */
        do {
-               res = mono_monitor_try_enter_internal (obj, INFINITE, allow_interruption);
+               res = mono_monitor_try_enter_internal (obj, MONO_INFINITE_WAIT, allow_interruption);
                /*This means we got interrupted during the wait and didn't got the monitor.*/
                if (res == -1) {
                        MonoException *exc = mono_thread_interruption_checkpoint ();
@@ -1160,7 +1160,7 @@ mono_monitor_enter_v4 (MonoObject *obj, char *lock_taken)
                return;
        }
 
-       ves_icall_System_Threading_Monitor_Monitor_try_enter_with_atomic_var (obj, INFINITE, lock_taken);
+       ves_icall_System_Threading_Monitor_Monitor_try_enter_with_atomic_var (obj, MONO_INFINITE_WAIT, lock_taken);
 }
 
 /*
@@ -1294,7 +1294,7 @@ ves_icall_System_Threading_Monitor_Monitor_wait (MonoObject *obj, guint32 ms)
        MonoThreadsSync *mon;
        HANDLE event;
        guint32 nest;
-       guint32 ret;
+       MonoW32HandleWaitRet ret;
        gboolean success = FALSE;
        gint32 regain;
        MonoInternalThread *thread = mono_thread_internal_current ();
@@ -1350,7 +1350,11 @@ ves_icall_System_Threading_Monitor_Monitor_wait (MonoObject *obj, guint32 ms)
         * signalled before we wait, we still succeed.
         */
        MONO_ENTER_GC_SAFE;
-       ret = WaitForSingleObjectEx (event, ms, TRUE);
+#ifdef HOST_WIN32
+       ret = mono_w32handle_convert_wait_ret (WaitForSingleObjectEx (event, ms, TRUE), 1);
+#else
+       ret = mono_w32handle_wait_one (event, ms, TRUE);
+#endif /* HOST_WIN32 */
        MONO_EXIT_GC_SAFE;
 
        /* Reset the thread state fairly early, so we don't have to worry
@@ -1360,7 +1364,7 @@ ves_icall_System_Threading_Monitor_Monitor_wait (MonoObject *obj, guint32 ms)
 
        /* Regain the lock with the previous nest count */
        do {
-               regain = mono_monitor_try_enter_inflated (obj, INFINITE, TRUE, id);
+               regain = mono_monitor_try_enter_inflated (obj, MONO_INFINITE_WAIT, TRUE, id);
                /* We must regain the lock before handling interruption requests */
        } while (regain == -1);
 
@@ -1370,12 +1374,16 @@ ves_icall_System_Threading_Monitor_Monitor_wait (MonoObject *obj, guint32 ms)
 
        LOCK_DEBUG (g_message ("%s: (%d) Regained %p lock %p", __func__, mono_thread_info_get_small_id (), obj, mon));
 
-       if (ret == WAIT_TIMEOUT) {
+       if (ret == MONO_W32HANDLE_WAIT_RET_TIMEOUT) {
                /* Poll the event again, just in case it was signalled
                 * while we were trying to regain the monitor lock
                 */
                MONO_ENTER_GC_SAFE;
-               ret = WaitForSingleObjectEx (event, 0, FALSE);
+#ifdef HOST_WIN32
+               ret = mono_w32handle_convert_wait_ret (WaitForSingleObjectEx (event, 0, FALSE), 1);
+#else
+               ret = mono_w32handle_wait_one (event, 0, FALSE);
+#endif /* HOST_WIN32 */
                MONO_EXIT_GC_SAFE;
        }
 
@@ -1389,7 +1397,7 @@ ves_icall_System_Threading_Monitor_Monitor_wait (MonoObject *obj, guint32 ms)
         * thread.
         */
        
-       if (ret == WAIT_OBJECT_0) {
+       if (ret == MONO_W32HANDLE_WAIT_RET_SUCCESS_0) {
                LOCK_DEBUG (g_message ("%s: (%d) Success", __func__, mono_thread_info_get_small_id ()));
                success = TRUE;
        } else {