Merge pull request #3749 from BrzVlad/fix-mips-fix
[mono.git] / mono / metadata / w32semaphore-unix.c
index 54abc039e9547285708c6a1cccad944fe2a01e4a..21e7921127aae4b0c69731225cecaeef9d58e4f8 100644 (file)
@@ -24,10 +24,12 @@ struct MonoW32HandleNamedSemaphore {
        MonoW32HandleNamespace sharedns;
 };
 
-static gboolean sem_handle_own (gpointer handle, MonoW32HandleType type)
+static gboolean sem_handle_own (gpointer handle, MonoW32HandleType type, guint32 *statuscode)
 {
        MonoW32HandleSemaphore *sem_handle;
 
+       *statuscode = WAIT_OBJECT_0;
+
        if (!mono_w32handle_lookup (handle, type, (gpointer *)&sem_handle)) {
                g_warning ("%s: error looking up %s handle %p",
                        __func__, mono_w32handle_ops_typename (type), handle);
@@ -50,9 +52,9 @@ static void sema_signal(gpointer handle)
        ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal(handle, 1, NULL);
 }
 
-static gboolean sema_own (gpointer handle)
+static gboolean sema_own (gpointer handle, guint32 *statuscode)
 {
-       return sem_handle_own (handle, MONO_W32HANDLE_SEM);
+       return sem_handle_own (handle, MONO_W32HANDLE_SEM, statuscode);
 }
 
 static void namedsema_signal (gpointer handle)
@@ -61,9 +63,9 @@ static void namedsema_signal (gpointer handle)
 }
 
 /* NB, always called with the shared handle lock held */
-static gboolean namedsema_own (gpointer handle)
+static gboolean namedsema_own (gpointer handle, guint32 *statuscode)
 {
-       return sem_handle_own (handle, MONO_W32HANDLE_NAMEDSEM);
+       return sem_handle_own (handle, MONO_W32HANDLE_NAMEDSEM, statuscode);
 }
 
 static void sema_details (gpointer data)
@@ -182,7 +184,7 @@ namedsem_create (gint32 initial, gint32 max, const gunichar2 *name)
        gchar *utf8_name;
 
        mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating %s handle, initial %d max %d name \"%s\"",
-               __func__, mono_w32handle_ops_typename (MONO_W32HANDLE_NAMEDSEM), initial, max, name);
+                   __func__, mono_w32handle_ops_typename (MONO_W32HANDLE_NAMEDSEM), initial, max, (const char*)name);
 
        /* w32 seems to guarantee that opening named objects can't race each other */
        mono_w32handle_namespace_lock ();