Completely replace mono_error_ok with is_ok and make first external_only. (#16217)
[mono-project.git] / mono / metadata / w32semaphore-win32.c
bloba6d3f2be09876fa2eb1d1c6822da1ab5cffdc3e3
1 /**
2 * \file
3 * Runtime support for managed Semaphore on Win32
5 * Author:
6 * Ludovic Henry (luhenry@microsoft.com)
8 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
9 */
11 #include "w32semaphore.h"
13 #include <windows.h>
14 #include <winbase.h>
15 #include "object-internals.h"
16 #include "icall-decl.h"
18 void
19 mono_w32semaphore_init (void)
23 #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
24 gpointer
25 ves_icall_System_Threading_Semaphore_CreateSemaphore_icall (gint32 initialCount, gint32 maximumCount,
26 const gunichar2 *name, gint32 name_length, gint32 *win32error, MonoError *error)
28 HANDLE sem;
29 MONO_ENTER_GC_SAFE;
30 sem = CreateSemaphoreW (NULL, initialCount, maximumCount, name);
31 MONO_EXIT_GC_SAFE;
32 *win32error = GetLastError ();
33 return sem;
35 #endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
37 MonoBoolean
38 ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal (gpointer handle, gint32 releaseCount, gint32 *prevcount, MonoError *error)
40 return ReleaseSemaphore (handle, releaseCount, (PLONG)prevcount);
43 gpointer
44 ves_icall_System_Threading_Semaphore_OpenSemaphore_icall (const gunichar2 *name, gint32 name_length,
45 gint32 rights, gint32 *win32error, MonoError *error)
47 HANDLE sem;
48 MONO_ENTER_GC_SAFE;
49 sem = OpenSemaphoreW (rights, FALSE, name);
50 MONO_EXIT_GC_SAFE;
51 *win32error = GetLastError ();
52 return sem;