diff options
Diffstat (limited to 'libraries/eina/src/include/eina_inline_lock_wince.x')
-rw-r--r-- | libraries/eina/src/include/eina_inline_lock_wince.x | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/libraries/eina/src/include/eina_inline_lock_wince.x b/libraries/eina/src/include/eina_inline_lock_wince.x new file mode 100644 index 0000000..965d475 --- /dev/null +++ b/libraries/eina/src/include/eina_inline_lock_wince.x | |||
@@ -0,0 +1,178 @@ | |||
1 | /* EINA - EFL data type library | ||
2 | * Copyright (C) 2011 Vincent Torri | ||
3 | * | ||
4 | * This library is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) any later version. | ||
8 | * | ||
9 | * This library is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * Lesser General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public | ||
15 | * License along with this library; | ||
16 | * if not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifndef EINA_INLINE_LOCK_WIN32_X_ | ||
20 | #define EINA_INLINE_LOCK_WIN32_X_ | ||
21 | |||
22 | #include <windows.h> | ||
23 | |||
24 | EAPI extern Eina_Bool _threads_activated; | ||
25 | |||
26 | typedef HANDLE Eina_Lock; | ||
27 | typedef Eina_Lock Eina_RWLock; | ||
28 | typedef DWORD Eina_TLS; | ||
29 | |||
30 | static inline Eina_Bool | ||
31 | eina_lock_new(Eina_Lock *mutex) | ||
32 | { | ||
33 | Eina_Lock m; | ||
34 | |||
35 | m = CreateMutex(NULL, FALSE, NULL); | ||
36 | if (m) *mutex = m; | ||
37 | return (m != NULL); | ||
38 | } | ||
39 | |||
40 | static inline void | ||
41 | eina_lock_free(Eina_Lock *mutex) | ||
42 | { | ||
43 | CloseHandle(*mutex); | ||
44 | } | ||
45 | |||
46 | static inline Eina_Lock_Result | ||
47 | eina_lock_take(Eina_Lock *mutex) | ||
48 | { | ||
49 | DWORD res; | ||
50 | |||
51 | #ifdef EINA_HAVE_ON_OFF_THREADS | ||
52 | if (!_eina_threads_activated) return EINA_LOCK_FAIL; | ||
53 | #endif | ||
54 | |||
55 | res = WaitForSingleObject(*mutex, INFINITE); | ||
56 | if ((res == WAIT_ABANDONED) || (res == WAIT_FAILED)) | ||
57 | return EINA_LOCK_FAIL; | ||
58 | |||
59 | return EINA_LOCK_SUCCEED; | ||
60 | } | ||
61 | |||
62 | static inline Eina_Lock_Result | ||
63 | eina_lock_take_try(Eina_Lock *mutex) | ||
64 | { | ||
65 | return eina_lock_take(*mutex); | ||
66 | } | ||
67 | |||
68 | static inline Eina_Lock_Result | ||
69 | eina_lock_release(Eina_Lock *mutex) | ||
70 | { | ||
71 | #ifdef EINA_HAVE_ON_OFF_THREADS | ||
72 | if (!_eina_threads_activated) return ; | ||
73 | #endif | ||
74 | |||
75 | return ReleaseMutex(*mutex) ? EINA_LOCK_SUCCEED : EINA_LOCK_FAIL; | ||
76 | } | ||
77 | |||
78 | static inline void | ||
79 | eina_lock_debug(const Eina_Lock *mutex) | ||
80 | { | ||
81 | } | ||
82 | |||
83 | static inline Eina_Bool | ||
84 | eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex) | ||
85 | { | ||
86 | return EINA_FALSE; | ||
87 | } | ||
88 | |||
89 | static inline void | ||
90 | eina_condition_free(Eina_Condition *cond) | ||
91 | { | ||
92 | } | ||
93 | |||
94 | static inline Eina_Bool | ||
95 | eina_condition_wait(Eina_Condition *cond) | ||
96 | { | ||
97 | return EINA_FALSE; | ||
98 | } | ||
99 | |||
100 | static inline Eina_Bool | ||
101 | eina_condition_timedwait(Eina_Condition *cond, double t) | ||
102 | { | ||
103 | return EINA_FALSE; | ||
104 | } | ||
105 | |||
106 | static inline Eina_Bool | ||
107 | eina_condition_broadcast(Eina_Condition *cond) | ||
108 | { | ||
109 | return EINA_FALSE; | ||
110 | } | ||
111 | |||
112 | static inline Eina_Bool | ||
113 | eina_condition_signal(Eina_Condition *cond) | ||
114 | { | ||
115 | return EINA_FALSE; | ||
116 | } | ||
117 | |||
118 | static inline Eina_Bool | ||
119 | eina_rwlock_new(Eina_RWLock *mutex) | ||
120 | { | ||
121 | return eina_lock_new(mutex); | ||
122 | } | ||
123 | |||
124 | static inline void | ||
125 | eina_rwlock_free(Eina_RWLock *mutex) | ||
126 | { | ||
127 | return eina_lock_free(mutex); | ||
128 | } | ||
129 | |||
130 | static inline Eina_Lock_Result | ||
131 | eina_rwlock_take_read(Eina_RWLock *mutex) | ||
132 | { | ||
133 | return eina_lock_take(mutex); | ||
134 | } | ||
135 | |||
136 | static inline Eina_Lock_Result | ||
137 | eina_rwlock_take_write(Eina_RWLock *mutex) | ||
138 | { | ||
139 | return eina_lock_take(mutex); | ||
140 | } | ||
141 | |||
142 | static inline Eina_Lock_Result | ||
143 | eina_rwlock_release(Eina_RWLock *mutex) | ||
144 | { | ||
145 | return eina_lock_release(mutex); | ||
146 | } | ||
147 | |||
148 | static inline Eina_Bool | ||
149 | eina_tls_new(Eina_TLS *key) | ||
150 | { | ||
151 | if (TlsAlloc() == TLS_OUT_OF_INDEXES) | ||
152 | return EINA_FALSE; | ||
153 | return EINA_TRUE; | ||
154 | } | ||
155 | |||
156 | static inline void | ||
157 | eina_tls_free(Eina_TLS key) | ||
158 | { | ||
159 | TlsFree(key); | ||
160 | } | ||
161 | |||
162 | static inline void * | ||
163 | eina_tls_get(Eina_TLS key) | ||
164 | { | ||
165 | return (void*)TlsGetValue(key); | ||
166 | } | ||
167 | |||
168 | static inline Eina_Bool | ||
169 | eina_tls_set(Eina_TLS key, const void *data) | ||
170 | { | ||
171 | if (TlsSetValue(key, (LPVOID)data) == 0) | ||
172 | return EINA_FALSE; | ||
173 | return EINA_TRUE; | ||
174 | } | ||
175 | |||
176 | |||
177 | |||
178 | #endif | ||