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