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