Moving BSTR conv to native code in SecureStringToBSTR.
[mono.git] / mono / io-layer / shared.c
1 /*
2  * shared.c:  Shared memory handling, and daemon launching
3  *
4  * Author:
5  *      Dick Porter (dick@ximian.com)
6  *
7  * (C) 2002-2006 Novell, Inc.
8  */
9
10 #include <config.h>
11 #include <glib.h>
12
13 #include <mono/io-layer/wapi-private.h>
14 #include <mono/io-layer/shared.h>
15 #include <mono/utils/mono-os-mutex.h>
16
17 #define DEBUGLOG(...)
18 //#define DEBUGLOG(...) g_message(__VA_ARGS__);
19
20 static mono_mutex_t noshm_sems[_WAPI_SHARED_SEM_COUNT];
21
22 void
23 _wapi_shm_semaphores_init (void)
24 {
25         int i;
26         for (i = 0; i < _WAPI_SHARED_SEM_COUNT; i++) 
27                 mono_os_mutex_init (&noshm_sems [i]);
28 }
29
30 void
31 _wapi_shm_semaphores_remove (void)
32 {
33         /* Nothing */
34 }
35
36 int
37 _wapi_shm_sem_lock (int sem)
38 {
39         DEBUGLOG ("%s: locking nosem %d", __func__, sem);
40         return mono_os_mutex_lock (&noshm_sems[sem]);
41 }
42
43 int
44 _wapi_shm_sem_trylock (int sem)
45 {
46         DEBUGLOG ("%s: trying to lock nosem %d", __func__, sem);
47         return mono_os_mutex_trylock (&noshm_sems[sem]);
48 }
49
50 int
51 _wapi_shm_sem_unlock (int sem)
52 {
53         DEBUGLOG ("%s: unlocking nosem %d", __func__, sem);
54         return mono_os_mutex_unlock (&noshm_sems[sem]);
55 }