|
23 | 23 | */ |
24 | 24 |
|
25 | 25 | // TODO: compare exchange, test/set/clear, thread fences and barriers. |
| 26 | +// TODO: relaxed barrier functions. |
26 | 27 |
|
27 | 28 | #pragma once |
28 | 29 |
|
|
135 | 136 |
|
136 | 137 | /*********************************************************************************************************************** |
137 | 138 | * @brief Atomically performs AND operation to the variable that memory points to. |
138 | | - * @return The resulting value of the AND operation. |
| 139 | + * @return The current value of the variable that memory points to. |
139 | 140 | * |
140 | 141 | * @param[in,out] memory pointer of a variable to which the AND operation is to be performed |
141 | 142 | * @param value variable whose value is to be used for an AND operation |
142 | 143 | */ |
143 | | -#define atomicAndFetch8(memory, value) __atomic_and_fetch(memory, value, __ATOMIC_SEQ_CST) |
| 144 | +#define atomicFetchAnd8(memory, value) __atomic_fetch_and(memory, value, __ATOMIC_SEQ_CST) |
144 | 145 | /** |
145 | 146 | * @brief Atomically performs AND operation to the variable that memory points to. |
146 | | - * @return The resulting value of the AND operation. |
| 147 | + * @return The current value of the variable that memory points to. |
147 | 148 | * |
148 | 149 | * @param[in,out] memory pointer of a variable to which the AND operation is to be performed |
149 | 150 | * @param value variable whose value is to be used for an AND operation |
150 | 151 | */ |
151 | | -#define atomicAndFetch16(memory, value) __atomic_and_fetch(memory, value, __ATOMIC_SEQ_CST) |
| 152 | +#define atomicFetchAnd16(memory, value) __atomic_fetch_and(memory, value, __ATOMIC_SEQ_CST) |
152 | 153 | /** |
153 | 154 | * @brief Atomically performs AND operation to the variable that memory points to. |
154 | | - * @return The resulting value of the AND operation. |
| 155 | + * @return The current value of the variable that memory points to. |
155 | 156 | * |
156 | 157 | * @param[in,out] memory pointer of a variable to which the AND operation is to be performed |
157 | 158 | * @param value variable whose value is to be used for an AND operation |
158 | 159 | */ |
159 | | -#define atomicAndFetch32(memory, value) __atomic_and_fetch(memory, value, __ATOMIC_SEQ_CST) |
| 160 | +#define atomicFetchAnd32(memory, value) __atomic_fetch_and(memory, value, __ATOMIC_SEQ_CST) |
160 | 161 | /** |
161 | 162 | * @brief Atomically performs AND operation to the variable that memory points to. |
162 | | - * @return The resulting value of the AND operation. |
| 163 | + * @return The current value of the variable that memory points to. |
163 | 164 | * |
164 | 165 | * @param[in,out] memory pointer of a variable to which the AND operation is to be performed |
165 | 166 | * @param value variable whose value is to be used for an AND operation |
166 | 167 | */ |
167 | | -#define atomicAndFetch64(memory, value) __atomic_and_fetch(memory, value, __ATOMIC_SEQ_CST) |
| 168 | +#define atomicFetchAnd64(memory, value) __atomic_fetch_and(memory, value, __ATOMIC_SEQ_CST) |
168 | 169 |
|
169 | 170 | /*********************************************************************************************************************** |
170 | 171 | * @brief Atomically performs OR operation to the variable that memory points to. |
171 | | - * @return The resulting value of the OR operation. |
| 172 | + * @return The current value of the variable that memory points to. |
172 | 173 | * |
173 | 174 | * @param[in,out] memory pointer of a variable to which the OR operation is to be performed |
174 | 175 | * @param value variable whose value is to be used for an OR operation |
175 | 176 | */ |
176 | | -#define atomicOrFetch8(memory, value) __atomic_or_fetch(memory, value, __ATOMIC_SEQ_CST) |
| 177 | +#define atomicFetchOr8(memory, value) __atomic_fetch_or(memory, value, __ATOMIC_SEQ_CST) |
177 | 178 | /** |
178 | 179 | * @brief Atomically performs OR operation to the variable that memory points to. |
179 | | - * @return The resulting value of the OR operation. |
| 180 | + * @return The current value of the variable that memory points to. |
180 | 181 | * |
181 | 182 | * @param[in,out] memory pointer of a variable to which the OR operation is to be performed |
182 | 183 | * @param value variable whose value is to be used for an OR operation |
183 | 184 | */ |
184 | | -#define atomicOrFetch16(memory, value) __atomic_or_fetch(memory, value, __ATOMIC_SEQ_CST) |
| 185 | +#define atomicFetchOr16(memory, value) __atomic_fetch_or(memory, value, __ATOMIC_SEQ_CST) |
185 | 186 | /** |
186 | 187 | * @brief Atomically performs OR operation to the variable that memory points to. |
187 | | - * @return The resulting value of the OR operation. |
| 188 | + * @return The current value of the variable that memory points to. |
188 | 189 | * |
189 | 190 | * @param[in,out] memory pointer of a variable to which the OR operation is to be performed |
190 | 191 | * @param value variable whose value is to be used for an OR operation |
191 | 192 | */ |
192 | | -#define atomicOrFetch32(memory, value) __atomic_or_fetch(memory, value, __ATOMIC_SEQ_CST) |
| 193 | +#define atomicFetchOr32(memory, value) __atomic_fetch_or(memory, value, __ATOMIC_SEQ_CST) |
193 | 194 | /** |
194 | 195 | * @brief Atomically performs OR operation to the variable that memory points to. |
195 | | - * @return The resulting value of the OR operation. |
| 196 | + * @return The current value of the variable that memory points to. |
196 | 197 | * |
197 | 198 | * @param[in,out] memory pointer of a variable to which the OR operation is to be performed |
198 | 199 | * @param value variable whose value is to be used for an OR operation |
199 | 200 | */ |
200 | | -#define atomicOrFetch64(memory, value) __atomic_or_fetch(memory, value, __ATOMIC_SEQ_CST) |
| 201 | +#define atomicFetchOr64(memory, value) __atomic_fetch_or(memory, value, __ATOMIC_SEQ_CST) |
201 | 202 |
|
202 | 203 | /*********************************************************************************************************************** |
203 | 204 | * @brief Atomically performs XOR operation to the variable that memory points to. |
204 | | - * @return The resulting value of the XOR operation. |
| 205 | + * @return The current value of the variable that memory points to. |
205 | 206 | * |
206 | 207 | * @param[in,out] memory pointer of a variable to which the XOR operation is to be performed |
207 | 208 | * @param value variable whose value is to be used for an XOR operation |
208 | 209 | */ |
209 | | -#define atomicXorFetch8(memory, value) __atomic_xor_fetch(memory, value, __ATOMIC_SEQ_CST) |
| 210 | +#define atomicFetchXor8(memory, value) __atomic_fetch_xor(memory, value, __ATOMIC_SEQ_CST) |
210 | 211 | /** |
211 | 212 | * @brief Atomically performs XOR operation to the variable that memory points to. |
212 | | - * @return The resulting value of the XOR operation. |
| 213 | + * @return The current value of the variable that memory points to. |
213 | 214 | * |
214 | 215 | * @param[in,out] memory pointer of a variable to which the XOR operation is to be performed |
215 | 216 | * @param value variable whose value is to be used for an XOR operation |
216 | 217 | */ |
217 | | -#define atomicXorFetch16(memory, value) __atomic_xor_fetch(memory, value, __ATOMIC_SEQ_CST) |
| 218 | +#define atomicFetchXor16(memory, value) __atomic_fetch_xor(memory, value, __ATOMIC_SEQ_CST) |
218 | 219 | /** |
219 | 220 | * @brief Atomically performs XOR operation to the variable that memory points to. |
220 | | - * @return The resulting value of the XOR operation. |
| 221 | + * @return The current value of the variable that memory points to. |
221 | 222 | * |
222 | 223 | * @param[in,out] memory pointer of a variable to which the XOR operation is to be performed |
223 | 224 | * @param value variable whose value is to be used for an XOR operation |
224 | 225 | */ |
225 | | -#define atomicXorFetch32(memory, value) __atomic_xor_fetch(memory, value, __ATOMIC_SEQ_CST) |
| 226 | +#define atomicFetchXor32(memory, value) __atomic_fetch_xor(memory, value, __ATOMIC_SEQ_CST) |
226 | 227 | /** |
227 | 228 | * @brief Atomically performs XOR operation to the variable that memory points to. |
228 | | - * @return The resulting value of the XOR operation. |
| 229 | + * @return The current value of the variable that memory points to. |
229 | 230 | * |
230 | 231 | * @param[in,out] memory pointer of a variable to which the XOR operation is to be performed |
231 | 232 | * @param value variable whose value is to be used for an XOR operation |
232 | 233 | */ |
233 | | -#define atomicXorFetch64(memory, value) __atomic_xor_fetch(memory, value, __ATOMIC_SEQ_CST) |
| 234 | +#define atomicFetchXor64(memory, value) __atomic_fetch_xor(memory, value, __ATOMIC_SEQ_CST) |
234 | 235 |
|
235 | 236 | /*********************************************************************************************************************** |
236 | 237 | * @brief Atomically adds the value to the variable that memory points to. |
@@ -411,102 +412,102 @@ static inline void atomicStore64(atomic_int64* memory, atomic_int64 value) |
411 | 412 |
|
412 | 413 | /*********************************************************************************************************************** |
413 | 414 | * @brief Atomically performs AND operation to the variable that memory points to. |
414 | | - * @return The resulting value of the AND operation. |
| 415 | + * @return The current value of the variable that memory points to. |
415 | 416 | * |
416 | 417 | * @param[in,out] memory pointer of a variable to which the AND operation is to be performed |
417 | 418 | * @param value variable whose value is to be used for an AND operation |
418 | 419 | */ |
419 | | -#define atomicAndFetch8(memory, value) _InterlockedAnd8(memory, value) |
| 420 | +#define atomicFetchAnd8(memory, value) _InterlockedAnd8(memory, value) |
420 | 421 | /** |
421 | 422 | * @brief Atomically performs AND operation to the variable that memory points to. |
422 | | - * @return The resulting value of the AND operation. |
| 423 | + * @return The current value of the variable that memory points to. |
423 | 424 | * |
424 | 425 | * @param[in,out] memory pointer of a variable to which the AND operation is to be performed |
425 | 426 | * @param value variable whose value is to be used for an AND operation |
426 | 427 | */ |
427 | | -#define atomicAndFetch16(memory, value) _InterlockedAnd16(memory, value) |
| 428 | +#define atomicFetchAnd16(memory, value) _InterlockedAnd16(memory, value) |
428 | 429 | /** |
429 | 430 | * @brief Atomically performs AND operation to the variable that memory points to. |
430 | | - * @return The resulting value of the AND operation. |
| 431 | + * @return The current value of the variable that memory points to. |
431 | 432 | * |
432 | 433 | * @param[in,out] memory pointer of a variable to which the AND operation is to be performed |
433 | 434 | * @param value variable whose value is to be used for an AND operation |
434 | 435 | */ |
435 | | -#define atomicAndFetch32(memory, value) _InterlockedAnd(memory, value) |
| 436 | +#define atomicFetchAnd32(memory, value) _InterlockedAnd(memory, value) |
436 | 437 | /** |
437 | 438 | * @brief Atomically performs AND operation to the variable that memory points to. |
438 | | - * @return The resulting value of the AND operation. |
| 439 | + * @return The current value of the variable that memory points to. |
439 | 440 | * |
440 | 441 | * @param[in,out] memory pointer of a variable to which the AND operation is to be performed |
441 | 442 | * @param value variable whose value is to be used for an AND operation |
442 | 443 | */ |
443 | | -#define atomicAndFetch64(memory, value) _InterlockedAnd64(memory, value) |
| 444 | +#define atomicFetchAnd64(memory, value) _InterlockedAnd64(memory, value) |
444 | 445 |
|
445 | 446 | /*********************************************************************************************************************** |
446 | 447 | * @brief Atomically performs OR operation to the variable that memory points to. |
447 | | - * @return The resulting value of the OR operation. |
| 448 | + * @return The current value of the variable that memory points to. |
448 | 449 | * |
449 | 450 | * @param[in,out] memory pointer of a variable to which the OR operation is to be performed |
450 | 451 | * @param value variable whose value is to be used for an OR operation |
451 | 452 | */ |
452 | | -#define atomicOrFetch8(memory, value) _InterlockedOr8(memory, value) |
| 453 | +#define atomicFetchOr8(memory, value) _InterlockedOr8(memory, value) |
453 | 454 | /** |
454 | 455 | * @brief Atomically performs OR operation to the variable that memory points to. |
455 | | - * @return The resulting value of the OR operation. |
| 456 | + * @return The current value of the variable that memory points to. |
456 | 457 | * |
457 | 458 | * @param[in,out] memory pointer of a variable to which the OR operation is to be performed |
458 | 459 | * @param value variable whose value is to be used for an OR operation |
459 | 460 | */ |
460 | | -#define atomicOrFetch16(memory, value) _InterlockedOr16(memory, value) |
| 461 | +#define atomicFetchOr16(memory, value) _InterlockedOr16(memory, value) |
461 | 462 | /** |
462 | 463 | * @brief Atomically performs OR operation to the variable that memory points to. |
463 | | - * @return The resulting value of the OR operation. |
| 464 | + * @return The current value of the variable that memory points to. |
464 | 465 | * |
465 | 466 | * @param[in,out] memory pointer of a variable to which the OR operation is to be performed |
466 | 467 | * @param value variable whose value is to be used for an OR operation |
467 | 468 | */ |
468 | | -#define atomicOrFetch32(memory, value) _InterlockedOr(memory, value) |
| 469 | +#define atomicFetchOr32(memory, value) _InterlockedOr(memory, value) |
469 | 470 | /** |
470 | 471 | * @brief Atomically performs OR operation to the variable that memory points to. |
471 | | - * @return The resulting value of the OR operation. |
| 472 | + * @return The current value of the variable that memory points to. |
472 | 473 | * |
473 | 474 | * @param[in,out] memory pointer of a variable to which the OR operation is to be performed |
474 | 475 | * @param value variable whose value is to be used for an OR operation |
475 | 476 | */ |
476 | | -#define atomicOrFetch64(memory, value) _InterlockedOr64(memory, value) |
| 477 | +#define atomicFetchOr64(memory, value) _InterlockedOr64(memory, value) |
477 | 478 |
|
478 | 479 | /*********************************************************************************************************************** |
479 | 480 | * @brief Atomically performs XOR operation to the variable that memory points to. |
480 | | - * @return The resulting value of the XOR operation. |
| 481 | + * @return The current value of the variable that memory points to. |
481 | 482 | * |
482 | 483 | * @param[in,out] memory pointer of a variable to which the XOR operation is to be performed |
483 | 484 | * @param value variable whose value is to be used for an XOR operation |
484 | 485 | */ |
485 | | -#define atomicXorFetch8(memory, value) _InterlockedXor8(memory, value) |
| 486 | +#define atomicFetchXor8(memory, value) _InterlockedXor8(memory, value) |
486 | 487 | /** |
487 | 488 | * @brief Atomically performs XOR operation to the variable that memory points to. |
488 | | - * @return The resulting value of the XOR operation. |
| 489 | + * @return The current value of the variable that memory points to. |
489 | 490 | * |
490 | 491 | * @param[in,out] memory pointer of a variable to which the XOR operation is to be performed |
491 | 492 | * @param value variable whose value is to be used for an XOR operation |
492 | 493 | */ |
493 | | -#define atomicXorFetch16(memory, value) _InterlockedXor16(memory, value) |
| 494 | +#define atomicFetchXor16(memory, value) _InterlockedXor16(memory, value) |
494 | 495 | /** |
495 | 496 | * @brief Atomically performs XOR operation to the variable that memory points to. |
496 | | - * @return The resulting value of the XOR operation. |
| 497 | + * @return The current value of the variable that memory points to. |
497 | 498 | * |
498 | 499 | * @param[in,out] memory pointer of a variable to which the XOR operation is to be performed |
499 | 500 | * @param value variable whose value is to be used for an XOR operation |
500 | 501 | */ |
501 | | -#define atomicXorFetch32(memory, value) _InterlockedXor(memory, value) |
| 502 | +#define atomicFetchXor32(memory, value) _InterlockedXor(memory, value) |
502 | 503 | /** |
503 | 504 | * @brief Atomically performs XOR operation to the variable that memory points to. |
504 | | - * @return The resulting value of the XOR operation. |
| 505 | + * @return The current value of the variable that memory points to. |
505 | 506 | * |
506 | 507 | * @param[in,out] memory pointer of a variable to which the XOR operation is to be performed |
507 | 508 | * @param value variable whose value is to be used for an XOR operation |
508 | 509 | */ |
509 | | -#define atomicXorFetch64(memory, value) _InterlockedXor64(memory, value) |
| 510 | +#define atomicFetchXor64(memory, value) _InterlockedXor64(memory, value) |
510 | 511 |
|
511 | 512 | /*********************************************************************************************************************** |
512 | 513 | * @brief Atomically adds the value to the variable that memory points to. |
|
0 commit comments