1 | /* |
---|
2 | * Licensed under the GNU Lesser General Public License Version 3 |
---|
3 | * |
---|
4 | * This library is free software: you can redistribute it and/or modify |
---|
5 | * it under the terms of the GNU Lesser General Public License as published by |
---|
6 | * the Free Software Foundation, either version 3 of the license, or |
---|
7 | * (at your option) any later version. |
---|
8 | * |
---|
9 | * This software 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 |
---|
12 | * GNU Lesser General Public License for more details. |
---|
13 | * |
---|
14 | * You should have received a copy of the GNU Lesser General Public License |
---|
15 | * along with this library. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | */ |
---|
17 | |
---|
18 | // generated automatically - do not change |
---|
19 | |
---|
20 | |
---|
21 | module glib.Atomic; |
---|
22 | |
---|
23 | private import gi.glib; |
---|
24 | public import gi.glibtypes; |
---|
25 | |
---|
26 | |
---|
27 | /** */ |
---|
28 | public struct Atomic |
---|
29 | { |
---|
30 | |
---|
31 | /** |
---|
32 | * Atomically adds @val to the value of @atomic. |
---|
33 | * |
---|
34 | * Think of this operation as an atomic version of |
---|
35 | * `{ tmp = *atomic; *atomic += val; return tmp; }`. |
---|
36 | * |
---|
37 | * This call acts as a full compiler and hardware memory barrier. |
---|
38 | * |
---|
39 | * Before version 2.30, this function did not return a value |
---|
40 | * (but g_atomic_int_exchange_and_add() did, and had the same meaning). |
---|
41 | * |
---|
42 | * Params: |
---|
43 | * atomic = a pointer to a #gint or #guint |
---|
44 | * val = the value to add |
---|
45 | * |
---|
46 | * Returns: the value of @atomic before the add, signed |
---|
47 | * |
---|
48 | * Since: 2.4 |
---|
49 | */ |
---|
50 | public static int intAdd(int* atomic, int val) |
---|
51 | { |
---|
52 | return g_atomic_int_add(atomic, val); |
---|
53 | } |
---|
54 | |
---|
55 | /** |
---|
56 | * Performs an atomic bitwise 'and' of the value of @atomic and @val, |
---|
57 | * storing the result back in @atomic. |
---|
58 | * |
---|
59 | * This call acts as a full compiler and hardware memory barrier. |
---|
60 | * |
---|
61 | * Think of this operation as an atomic version of |
---|
62 | * `{ tmp = *atomic; *atomic &= val; return tmp; }`. |
---|
63 | * |
---|
64 | * Params: |
---|
65 | * atomic = a pointer to a #gint or #guint |
---|
66 | * val = the value to 'and' |
---|
67 | * |
---|
68 | * Returns: the value of @atomic before the operation, unsigned |
---|
69 | * |
---|
70 | * Since: 2.30 |
---|
71 | */ |
---|
72 | public static uint intAnd(uint* atomic, uint val) |
---|
73 | { |
---|
74 | return g_atomic_int_and(atomic, val); |
---|
75 | } |
---|
76 | |
---|
77 | /** |
---|
78 | * Compares @atomic to @oldval and, if equal, sets it to @newval. |
---|
79 | * If @atomic was not equal to @oldval then no change occurs. |
---|
80 | * |
---|
81 | * This compare and exchange is done atomically. |
---|
82 | * |
---|
83 | * Think of this operation as an atomic version of |
---|
84 | * `{ if (*atomic == oldval) { *atomic = newval; return TRUE; } else return FALSE; }`. |
---|
85 | * |
---|
86 | * This call acts as a full compiler and hardware memory barrier. |
---|
87 | * |
---|
88 | * Params: |
---|
89 | * atomic = a pointer to a #gint or #guint |
---|
90 | * oldval = the value to compare with |
---|
91 | * newval = the value to conditionally replace with |
---|
92 | * |
---|
93 | * Returns: %TRUE if the exchange took place |
---|
94 | * |
---|
95 | * Since: 2.4 |
---|
96 | */ |
---|
97 | public static bool intCompareAndExchange(int* atomic, int oldval, int newval) |
---|
98 | { |
---|
99 | return g_atomic_int_compare_and_exchange(atomic, oldval, newval) != 0; |
---|
100 | } |
---|
101 | |
---|
102 | /** |
---|
103 | * Decrements the value of @atomic by 1. |
---|
104 | * |
---|
105 | * Think of this operation as an atomic version of |
---|
106 | * `{ *atomic -= 1; return (*atomic == 0); }`. |
---|
107 | * |
---|
108 | * This call acts as a full compiler and hardware memory barrier. |
---|
109 | * |
---|
110 | * Params: |
---|
111 | * atomic = a pointer to a #gint or #guint |
---|
112 | * |
---|
113 | * Returns: %TRUE if the resultant value is zero |
---|
114 | * |
---|
115 | * Since: 2.4 |
---|
116 | */ |
---|
117 | public static bool intDecAndTest(int* atomic) |
---|
118 | { |
---|
119 | return g_atomic_int_dec_and_test(atomic) != 0; |
---|
120 | } |
---|
121 | |
---|
122 | /** |
---|
123 | * This function existed before g_atomic_int_add() returned the prior |
---|
124 | * value of the integer (which it now does). It is retained only for |
---|
125 | * compatibility reasons. Don't use this function in new code. |
---|
126 | * |
---|
127 | * Deprecated: Use g_atomic_int_add() instead. |
---|
128 | * |
---|
129 | * Params: |
---|
130 | * atomic = a pointer to a #gint |
---|
131 | * val = the value to add |
---|
132 | * |
---|
133 | * Returns: the value of @atomic before the add, signed |
---|
134 | * |
---|
135 | * Since: 2.4 |
---|
136 | */ |
---|
137 | public static int intExchangeAndAdd(int* atomic, int val) |
---|
138 | { |
---|
139 | return g_atomic_int_exchange_and_add(atomic, val); |
---|
140 | } |
---|
141 | |
---|
142 | /** |
---|
143 | * Gets the current value of @atomic. |
---|
144 | * |
---|
145 | * This call acts as a full compiler and hardware |
---|
146 | * memory barrier (before the get). |
---|
147 | * |
---|
148 | * Params: |
---|
149 | * atomic = a pointer to a #gint or #guint |
---|
150 | * |
---|
151 | * Returns: the value of the integer |
---|
152 | * |
---|
153 | * Since: 2.4 |
---|
154 | */ |
---|
155 | public static int intGet(int* atomic) |
---|
156 | { |
---|
157 | return g_atomic_int_get(atomic); |
---|
158 | } |
---|
159 | |
---|
160 | /** |
---|
161 | * Increments the value of @atomic by 1. |
---|
162 | * |
---|
163 | * Think of this operation as an atomic version of `{ *atomic += 1; }`. |
---|
164 | * |
---|
165 | * This call acts as a full compiler and hardware memory barrier. |
---|
166 | * |
---|
167 | * Params: |
---|
168 | * atomic = a pointer to a #gint or #guint |
---|
169 | * |
---|
170 | * Since: 2.4 |
---|
171 | */ |
---|
172 | public static void intInc(int* atomic) |
---|
173 | { |
---|
174 | g_atomic_int_inc(atomic); |
---|
175 | } |
---|
176 | |
---|
177 | /** |
---|
178 | * Performs an atomic bitwise 'or' of the value of @atomic and @val, |
---|
179 | * storing the result back in @atomic. |
---|
180 | * |
---|
181 | * Think of this operation as an atomic version of |
---|
182 | * `{ tmp = *atomic; *atomic |= val; return tmp; }`. |
---|
183 | * |
---|
184 | * This call acts as a full compiler and hardware memory barrier. |
---|
185 | * |
---|
186 | * Params: |
---|
187 | * atomic = a pointer to a #gint or #guint |
---|
188 | * val = the value to 'or' |
---|
189 | * |
---|
190 | * Returns: the value of @atomic before the operation, unsigned |
---|
191 | * |
---|
192 | * Since: 2.30 |
---|
193 | */ |
---|
194 | public static uint intOr(uint* atomic, uint val) |
---|
195 | { |
---|
196 | return g_atomic_int_or(atomic, val); |
---|
197 | } |
---|
198 | |
---|
199 | /** |
---|
200 | * Sets the value of @atomic to @newval. |
---|
201 | * |
---|
202 | * This call acts as a full compiler and hardware |
---|
203 | * memory barrier (after the set). |
---|
204 | * |
---|
205 | * Params: |
---|
206 | * atomic = a pointer to a #gint or #guint |
---|
207 | * newval = a new value to store |
---|
208 | * |
---|
209 | * Since: 2.4 |
---|
210 | */ |
---|
211 | public static void intSet(int* atomic, int newval) |
---|
212 | { |
---|
213 | g_atomic_int_set(atomic, newval); |
---|
214 | } |
---|
215 | |
---|
216 | /** |
---|
217 | * Performs an atomic bitwise 'xor' of the value of @atomic and @val, |
---|
218 | * storing the result back in @atomic. |
---|
219 | * |
---|
220 | * Think of this operation as an atomic version of |
---|
221 | * `{ tmp = *atomic; *atomic ^= val; return tmp; }`. |
---|
222 | * |
---|
223 | * This call acts as a full compiler and hardware memory barrier. |
---|
224 | * |
---|
225 | * Params: |
---|
226 | * atomic = a pointer to a #gint or #guint |
---|
227 | * val = the value to 'xor' |
---|
228 | * |
---|
229 | * Returns: the value of @atomic before the operation, unsigned |
---|
230 | * |
---|
231 | * Since: 2.30 |
---|
232 | */ |
---|
233 | public static uint intXor(uint* atomic, uint val) |
---|
234 | { |
---|
235 | return g_atomic_int_xor(atomic, val); |
---|
236 | } |
---|
237 | |
---|
238 | /** |
---|
239 | * Atomically adds @val to the value of @atomic. |
---|
240 | * |
---|
241 | * Think of this operation as an atomic version of |
---|
242 | * `{ tmp = *atomic; *atomic += val; return tmp; }`. |
---|
243 | * |
---|
244 | * This call acts as a full compiler and hardware memory barrier. |
---|
245 | * |
---|
246 | * Params: |
---|
247 | * atomic = a pointer to a #gpointer-sized value |
---|
248 | * val = the value to add |
---|
249 | * |
---|
250 | * Returns: the value of @atomic before the add, signed |
---|
251 | * |
---|
252 | * Since: 2.30 |
---|
253 | */ |
---|
254 | public static ptrdiff_t pointerAdd(void* atomic, ptrdiff_t val) |
---|
255 | { |
---|
256 | return g_atomic_pointer_add(atomic, val); |
---|
257 | } |
---|
258 | |
---|
259 | /** |
---|
260 | * Performs an atomic bitwise 'and' of the value of @atomic and @val, |
---|
261 | * storing the result back in @atomic. |
---|
262 | * |
---|
263 | * Think of this operation as an atomic version of |
---|
264 | * `{ tmp = *atomic; *atomic &= val; return tmp; }`. |
---|
265 | * |
---|
266 | * This call acts as a full compiler and hardware memory barrier. |
---|
267 | * |
---|
268 | * Params: |
---|
269 | * atomic = a pointer to a #gpointer-sized value |
---|
270 | * val = the value to 'and' |
---|
271 | * |
---|
272 | * Returns: the value of @atomic before the operation, unsigned |
---|
273 | * |
---|
274 | * Since: 2.30 |
---|
275 | */ |
---|
276 | public static size_t pointerAnd(void* atomic, size_t val) |
---|
277 | { |
---|
278 | return g_atomic_pointer_and(atomic, val); |
---|
279 | } |
---|
280 | |
---|
281 | /** |
---|
282 | * Compares @atomic to @oldval and, if equal, sets it to @newval. |
---|
283 | * If @atomic was not equal to @oldval then no change occurs. |
---|
284 | * |
---|
285 | * This compare and exchange is done atomically. |
---|
286 | * |
---|
287 | * Think of this operation as an atomic version of |
---|
288 | * `{ if (*atomic == oldval) { *atomic = newval; return TRUE; } else return FALSE; }`. |
---|
289 | * |
---|
290 | * This call acts as a full compiler and hardware memory barrier. |
---|
291 | * |
---|
292 | * Params: |
---|
293 | * atomic = a pointer to a #gpointer-sized value |
---|
294 | * oldval = the value to compare with |
---|
295 | * newval = the value to conditionally replace with |
---|
296 | * |
---|
297 | * Returns: %TRUE if the exchange took place |
---|
298 | * |
---|
299 | * Since: 2.4 |
---|
300 | */ |
---|
301 | public static bool pointerCompareAndExchange(void* atomic, void* oldval, void* newval) |
---|
302 | { |
---|
303 | return g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) != 0; |
---|
304 | } |
---|
305 | |
---|
306 | /** |
---|
307 | * Gets the current value of @atomic. |
---|
308 | * |
---|
309 | * This call acts as a full compiler and hardware |
---|
310 | * memory barrier (before the get). |
---|
311 | * |
---|
312 | * Params: |
---|
313 | * atomic = a pointer to a #gpointer-sized value |
---|
314 | * |
---|
315 | * Returns: the value of the pointer |
---|
316 | * |
---|
317 | * Since: 2.4 |
---|
318 | */ |
---|
319 | public static void* pointerGet(void* atomic) |
---|
320 | { |
---|
321 | return g_atomic_pointer_get(atomic); |
---|
322 | } |
---|
323 | |
---|
324 | /** |
---|
325 | * Performs an atomic bitwise 'or' of the value of @atomic and @val, |
---|
326 | * storing the result back in @atomic. |
---|
327 | * |
---|
328 | * Think of this operation as an atomic version of |
---|
329 | * `{ tmp = *atomic; *atomic |= val; return tmp; }`. |
---|
330 | * |
---|
331 | * This call acts as a full compiler and hardware memory barrier. |
---|
332 | * |
---|
333 | * Params: |
---|
334 | * atomic = a pointer to a #gpointer-sized value |
---|
335 | * val = the value to 'or' |
---|
336 | * |
---|
337 | * Returns: the value of @atomic before the operation, unsigned |
---|
338 | * |
---|
339 | * Since: 2.30 |
---|
340 | */ |
---|
341 | public static size_t pointerOr(void* atomic, size_t val) |
---|
342 | { |
---|
343 | return g_atomic_pointer_or(atomic, val); |
---|
344 | } |
---|
345 | |
---|
346 | /** |
---|
347 | * Sets the value of @atomic to @newval. |
---|
348 | * |
---|
349 | * This call acts as a full compiler and hardware |
---|
350 | * memory barrier (after the set). |
---|
351 | * |
---|
352 | * Params: |
---|
353 | * atomic = a pointer to a #gpointer-sized value |
---|
354 | * newval = a new value to store |
---|
355 | * |
---|
356 | * Since: 2.4 |
---|
357 | */ |
---|
358 | public static void pointerSet(void* atomic, void* newval) |
---|
359 | { |
---|
360 | g_atomic_pointer_set(atomic, newval); |
---|
361 | } |
---|
362 | |
---|
363 | /** |
---|
364 | * Performs an atomic bitwise 'xor' of the value of @atomic and @val, |
---|
365 | * storing the result back in @atomic. |
---|
366 | * |
---|
367 | * Think of this operation as an atomic version of |
---|
368 | * `{ tmp = *atomic; *atomic ^= val; return tmp; }`. |
---|
369 | * |
---|
370 | * This call acts as a full compiler and hardware memory barrier. |
---|
371 | * |
---|
372 | * Params: |
---|
373 | * atomic = a pointer to a #gpointer-sized value |
---|
374 | * val = the value to 'xor' |
---|
375 | * |
---|
376 | * Returns: the value of @atomic before the operation, unsigned |
---|
377 | * |
---|
378 | * Since: 2.30 |
---|
379 | */ |
---|
380 | public static size_t pointerXor(void* atomic, size_t val) |
---|
381 | { |
---|
382 | return g_atomic_pointer_xor(atomic, val); |
---|
383 | } |
---|
384 | } |
---|