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