3 * Runtime support for managed Mutex on Win32
6 * Ludovic Henry (luhenry@microsoft.com)
8 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
15 #include <mono/metadata/handle.h>
16 #include <mono/utils/mono-error-internals.h>
17 #include "icall-decl.h"
20 mono_w32mutex_init (void)
25 ves_icall_System_Threading_Mutex_CreateMutex_icall (MonoBoolean owned
, const gunichar2
*name
,
26 gint32 name_length
, MonoBoolean
*created
, MonoError
*error
)
32 /* Need to blow away any old errors here, because code tests
33 * for ERROR_ALREADY_EXISTS on success (!) to see if a mutex
34 * was freshly created */
35 SetLastError (ERROR_SUCCESS
);
38 mutex
= CreateMutexW (NULL
, owned
, name
);
39 if (name
&& GetLastError () == ERROR_ALREADY_EXISTS
)
47 ves_icall_System_Threading_Mutex_ReleaseMutex_internal (gpointer handle
)
49 return ReleaseMutex (handle
);
53 ves_icall_System_Threading_Mutex_OpenMutex_icall (const gunichar2
*name
, gint32 name_length
,
54 gint32 rights
, gint32
*win32error
, MonoError
*error
)
58 *win32error
= ERROR_SUCCESS
;
61 ret
= OpenMutexW (rights
, FALSE
, name
);
63 *win32error
= GetLastError ();