Changeset 33284 in vbox for trunk/include
- Timestamp:
- Oct 21, 2010 9:36:40 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asm.h
r33199 r33284 2526 2526 2527 2527 /** 2528 * Atomically exchanges and adds a value which size might differ between 2529 * platforms or compilers, ordered. 2530 * 2531 * @param pu Pointer to the variable to update. 2532 * @param uNew The value to add to *pu. 2533 * @param puOld Where to store the old value. 2534 */ 2535 #define ASMAtomicAddSize(pu, uNew, puOld) \ 2536 do { \ 2537 switch (sizeof(*(pu))) { \ 2538 case 4: *(uint32_t *)(puOld) = ASMAtomicAddU32((volatile uint32_t *)(void *)(pu), (uint32_t)(uNew)); break; \ 2539 case 8: *(uint64_t *)(puOld) = ASMAtomicAddU64((volatile uint64_t *)(void *)(pu), (uint64_t)(uNew)); break; \ 2540 default: AssertMsgFailed(("ASMAtomicAddSize: size %d is not supported\n", sizeof(*(pu)))); \ 2541 } \ 2542 } while (0) 2543 2544 2545 /** 2528 2546 * Atomically exchanges and subtracts to an unsigned 32-bit value, ordered. 2529 2547 * … … 2575 2593 return (int64_t)ASMAtomicAddU64((uint64_t volatile *)pi64, (uint64_t)-i64); 2576 2594 } 2595 2596 /** 2597 * Atomically exchanges and subtracts a value which size might differ between 2598 * platforms or compilers, ordered. 2599 * 2600 * @param pu Pointer to the variable to update. 2601 * @param uNew The value to subtract to *pu. 2602 * @param puOld Where to store the old value. 2603 */ 2604 #define ASMAtomicSubSize(pu, uNew, puOld) \ 2605 do { \ 2606 switch (sizeof(*(pu))) { \ 2607 case 4: *(uint32_t *)(puOld) = ASMAtomicSubU32((volatile uint32_t *)(void *)(pu), (uint32_t)(uNew)); break; \ 2608 case 8: *(uint64_t *)(puOld) = ASMAtomicSubU64((volatile uint64_t *)(void *)(pu), (uint64_t)(uNew)); break; \ 2609 default: AssertMsgFailed(("ASMAtomicSubSize: size %d is not supported\n", sizeof(*(pu)))); \ 2610 } \ 2611 } while (0) 2577 2612 2578 2613
Note:
See TracChangeset
for help on using the changeset viewer.