Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / metadata / w32semaphore-win32.c
1 /**
2  * \file
3  * Runtime support for managed Semaphore on Win32
4  *
5  * Author:
6  *      Ludovic Henry (luhenry@microsoft.com)
7  *
8  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
9  */
10
11 #include "w32semaphore.h"
12
13 #include <windows.h>
14 #include <winbase.h>
15
16 void
17 mono_w32semaphore_init (void)
18 {
19 }
20
21 #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
22 gpointer
23 ves_icall_System_Threading_Semaphore_CreateSemaphore_internal (gint32 initialCount, gint32 maximumCount, MonoString *name, gint32 *error)
24
25         HANDLE sem;
26
27         sem = CreateSemaphore (NULL, initialCount, maximumCount, name ? mono_string_chars (name) : NULL);
28
29         *error = GetLastError ();
30
31         return sem;
32 }
33 #endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
34
35 MonoBoolean
36 ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal (gpointer handle, gint32 releaseCount, gint32 *prevcount)
37
38         return ReleaseSemaphore (handle, releaseCount, prevcount);
39 }
40
41 gpointer
42 ves_icall_System_Threading_Semaphore_OpenSemaphore_internal (MonoString *name, gint32 rights, gint32 *error)
43 {
44         HANDLE sem;
45
46         sem = OpenSemaphore (rights, FALSE, mono_string_chars (name));
47
48         *error = GetLastError ();
49
50         return sem;
51 }