[w32file] Remove dead code
[mono.git] / mono / utils / mono-coop-semaphore.h
1 /**
2  * \file
3  */
4
5 #ifndef __MONO_COOP_SEMAPHORE_H__
6 #define __MONO_COOP_SEMAPHORE_H__
7
8 #include <config.h>
9 #include <glib.h>
10
11 #include "mono-os-semaphore.h"
12 #include "mono-threads-api.h"
13
14 G_BEGIN_DECLS
15
16 /* We put the OS sync primitives in struct, so the compiler will warn us if
17  * we use mono_os_(mutex|cond|sem)_... on MonoCoop(Mutex|Cond|Sem) structures */
18
19 typedef struct _MonoCoopSem MonoCoopSem;
20 struct _MonoCoopSem {
21         MonoSemType s;
22 };
23
24 static inline void
25 mono_coop_sem_init (MonoCoopSem *sem, int value)
26 {
27         mono_os_sem_init (&sem->s, value);
28 }
29
30 static inline void
31 mono_coop_sem_destroy (MonoCoopSem *sem)
32 {
33         mono_os_sem_destroy (&sem->s);
34 }
35
36 static inline gint
37 mono_coop_sem_wait (MonoCoopSem *sem, MonoSemFlags flags)
38 {
39         gint res;
40
41         MONO_ENTER_GC_SAFE;
42
43         res = mono_os_sem_wait (&sem->s, flags);
44
45         MONO_EXIT_GC_SAFE;
46
47         return res;
48 }
49
50 static inline MonoSemTimedwaitRet
51 mono_coop_sem_timedwait (MonoCoopSem *sem, guint timeout_ms, MonoSemFlags flags)
52 {
53         MonoSemTimedwaitRet res;
54
55         MONO_ENTER_GC_SAFE;
56
57         res = mono_os_sem_timedwait (&sem->s, timeout_ms, flags);
58
59         MONO_EXIT_GC_SAFE;
60
61         return res;
62 }
63
64 static inline void
65 mono_coop_sem_post (MonoCoopSem *sem)
66 {
67         mono_os_sem_post (&sem->s);
68 }
69
70 G_END_DECLS
71
72 #endif /* __MONO_COOP_SEMAPHORE_H__ */