Changeset 21535 in vbox for trunk/include
- Timestamp:
- Jul 13, 2009 2:44:54 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 50008
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asm.h
r21451 r21535 1501 1501 1502 1502 /** 1503 * Are interrupts enabled? 1504 * 1505 * @returns true / false. 1506 */ 1507 #if RT_INLINE_ASM_EXTERNAL 1508 DECLASM(RTCCUINTREG) ASMIntAreEnabled(void); 1509 #else 1510 DECLINLINE(RTCCUINTREG) ASMIntAreEnabled(void) 1511 { 1512 RTCCUINTREG uFlags = ASMGetFlags(); 1513 return uFlags & 0x200 /* X86_EFL_IF */ ? true : false; 1514 } 1515 #endif 1516 1517 1518 /** 1503 1519 * Halts the CPU until interrupted. 1504 1520 */ … … 1513 1529 __asm { 1514 1530 hlt 1531 } 1532 # endif 1533 } 1534 #endif 1535 1536 1537 /** 1538 * The PAUSE variant of NOP for helping hyperthreaded CPUs detecing spin locks. 1539 */ 1540 #if RT_INLINE_ASM_EXTERNAL 1541 DECLASM(void) ASMNopPause(void); 1542 #else 1543 DECLINLINE(void) ASMNopPause(void) 1544 { 1545 # if RT_INLINE_ASM_GNU_STYLE 1546 __asm__ __volatile__(".byte 0xf3,0x90\n\t"); 1547 # else 1548 __asm { 1549 _emit 0f3h 1550 _emit 090h 1515 1551 } 1516 1552 # endif … … 2914 2950 # define ASMAtomicXchgHandle(ph, hNew, phRes) \ 2915 2951 do { \ 2916 *(uint32_t *)(phRes) = ASMAtomicXchgU32((uint32_t volatile *)(ph), (const uint32_t)(hNew)); \2917 2952 AssertCompile(sizeof(*(ph)) == sizeof(uint32_t)); \ 2918 2953 AssertCompile(sizeof(*(phRes)) == sizeof(uint32_t)); \ 2954 *(uint32_t *)(phRes) = ASMAtomicXchgU32((uint32_t volatile *)(ph), (const uint32_t)(hNew)); \ 2919 2955 } while (0) 2920 2956 #elif HC_ARCH_BITS == 64 2921 2957 # define ASMAtomicXchgHandle(ph, hNew, phRes) \ 2922 2958 do { \ 2923 *(uint64_t *)(phRes) = ASMAtomicXchgU64((uint64_t volatile *)(ph), (const uint64_t)(hNew)); \2924 2959 AssertCompile(sizeof(*(ph)) == sizeof(uint64_t)); \ 2925 2960 AssertCompile(sizeof(*(phRes)) == sizeof(uint64_t)); \ 2961 *(uint64_t *)(phRes) = ASMAtomicXchgU64((uint64_t volatile *)(ph), (const uint64_t)(hNew)); \ 2926 2962 } while (0) 2927 2963 #else … … 3191 3227 # define ASMAtomicCmpXchgHandle(ph, hNew, hOld, fRc) \ 3192 3228 do { \ 3229 AssertCompile(sizeof(*(ph)) == sizeof(uint32_t)); \ 3193 3230 (fRc) = ASMAtomicCmpXchgU32((uint32_t volatile *)(ph), (const uint32_t)(hNew), (const uint32_t)(hOld)); \ 3194 AssertCompile(sizeof(*(ph)) == sizeof(uint32_t)); \3195 3231 } while (0) 3196 3232 #elif HC_ARCH_BITS == 64 3197 3233 # define ASMAtomicCmpXchgHandle(ph, hNew, hOld, fRc) \ 3198 3234 do { \ 3235 AssertCompile(sizeof(*(ph)) == sizeof(uint64_t)); \ 3199 3236 (fRc) = ASMAtomicCmpXchgU64((uint64_t volatile *)(ph), (const uint64_t)(hNew), (const uint64_t)(hOld)); \ 3200 AssertCompile(sizeof(*(ph)) == sizeof(uint64_t)); \3201 3237 } while (0) 3202 3238 #else … … 3439 3475 # define ASMAtomicCmpXchgExHandle(ph, hNew, hOld, fRc, phOldVal) \ 3440 3476 do { \ 3441 (fRc) = ASMAtomicCmpXchgExU32((volatile uint32_t *)(pu), (uint32_t)(uNew), (uint32_t)(uOld), (uint32_t *)(puOldVal)); \3442 3477 AssertCompile(sizeof(*ph) == sizeof(uint32_t)); \ 3443 3478 AssertCompile(sizeof(*phOldVal) == sizeof(uint32_t)); \ 3479 (fRc) = ASMAtomicCmpXchgExU32((volatile uint32_t *)(pu), (uint32_t)(uNew), (uint32_t)(uOld), (uint32_t *)(puOldVal)); \ 3444 3480 } while (0) 3445 3481 #elif HC_ARCH_BITS == 64 3446 3482 # define ASMAtomicCmpXchgExHandle(ph, hNew, hOld, fRc, phOldVal) \ 3447 3483 do { \ 3448 (fRc) = ASMAtomicCmpXchgExU64((volatile uint64_t *)(pu), (uint64_t)(uNew), (uint64_t)(uOld), (uint64_t *)(puOldVal)); \3449 3484 AssertCompile(sizeof(*(ph)) == sizeof(uint64_t)); \ 3450 3485 AssertCompile(sizeof(*(phOldVal)) == sizeof(uint64_t)); \ 3486 (fRc) = ASMAtomicCmpXchgExU64((volatile uint64_t *)(pu), (uint64_t)(uNew), (uint64_t)(uOld), (uint64_t *)(puOldVal)); \ 3451 3487 } while (0) 3452 3488 #else … … 4348 4384 # define ASMAtomicReadHandle(ph, phRes) \ 4349 4385 do { \ 4350 *(uint32_t *)(phRes) = ASMAtomicReadU32((uint32_t volatile *)(ph)); \4351 4386 AssertCompile(sizeof(*(ph)) == sizeof(uint32_t)); \ 4352 4387 AssertCompile(sizeof(*(phRes)) == sizeof(uint32_t)); \ 4388 *(uint32_t *)(phRes) = ASMAtomicReadU32((uint32_t volatile *)(ph)); \ 4353 4389 } while (0) 4354 4390 #elif HC_ARCH_BITS == 64 4355 4391 # define ASMAtomicReadHandle(ph, phRes) \ 4356 4392 do { \ 4357 *(uint64_t *)(phRes) = ASMAtomicReadU64((uint64_t volatile *)(ph)); \4358 4393 AssertCompile(sizeof(*(ph)) == sizeof(uint64_t)); \ 4359 4394 AssertCompile(sizeof(*(phRes)) == sizeof(uint64_t)); \ 4395 *(uint64_t *)(phRes) = ASMAtomicReadU64((uint64_t volatile *)(ph)); \ 4360 4396 } while (0) 4361 4397 #else … … 4375 4411 # define ASMAtomicUoReadHandle(ph, phRes) \ 4376 4412 do { \ 4377 *(uint32_t *)(phRes) = ASMAtomicUoReadU32((uint32_t volatile *)(ph)); \4378 4413 AssertCompile(sizeof(*(ph)) == sizeof(uint32_t)); \ 4379 4414 AssertCompile(sizeof(*(phRes)) == sizeof(uint32_t)); \ 4415 *(uint32_t *)(phRes) = ASMAtomicUoReadU32((uint32_t volatile *)(ph)); \ 4380 4416 } while (0) 4381 4417 #elif HC_ARCH_BITS == 64 4382 4418 # define ASMAtomicUoReadHandle(ph, phRes) \ 4383 4419 do { \ 4384 *(uint64_t *)(phRes) = ASMAtomicUoReadU64((uint64_t volatile *)(ph)); \4385 4420 AssertCompile(sizeof(*(ph)) == sizeof(uint64_t)); \ 4386 4421 AssertCompile(sizeof(*(phRes)) == sizeof(uint64_t)); \ 4422 *(uint64_t *)(phRes) = ASMAtomicUoReadU64((uint64_t volatile *)(ph)); \ 4387 4423 } while (0) 4388 4424 #else … … 4708 4744 # define ASMAtomicWriteHandle(ph, hNew) \ 4709 4745 do { \ 4746 AssertCompile(sizeof(*(ph)) == sizeof(uint32_t)); \ 4710 4747 ASMAtomicWriteU32((uint32_t volatile *)(ph), (const uint32_t)(hNew)); \ 4711 AssertCompile(sizeof(*(ph)) == sizeof(uint32_t)); \4712 4748 } while (0) 4713 4749 #elif HC_ARCH_BITS == 64 4714 4750 # define ASMAtomicWriteHandle(ph, hNew) \ 4715 4751 do { \ 4752 AssertCompile(sizeof(*(ph)) == sizeof(uint64_t)); \ 4716 4753 ASMAtomicWriteU64((uint64_t volatile *)(ph), (const uint64_t)(hNew)); \ 4717 AssertCompile(sizeof(*(ph)) == sizeof(uint64_t)); \4718 4754 } while (0) 4719 4755 #else … … 4733 4769 # define ASMAtomicUoWriteHandle(ph, hNew) \ 4734 4770 do { \ 4771 AssertCompile(sizeof(*(ph)) == sizeof(uint32_t)); \ 4735 4772 ASMAtomicUoWriteU32((uint32_t volatile *)(ph), (const uint32_t)hNew); \ 4736 AssertCompile(sizeof(*(ph)) == sizeof(uint32_t)); \4737 4773 } while (0) 4738 4774 #elif HC_ARCH_BITS == 64 4739 4775 # define ASMAtomicUoWriteHandle(ph, hNew) \ 4740 4776 do { \ 4777 AssertCompile(sizeof(*(ph)) == sizeof(uint64_t)); \ 4741 4778 ASMAtomicUoWriteU64((uint64_t volatile *)(ph), (const uint64_t)hNew); \ 4742 AssertCompile(sizeof(*(ph)) == sizeof(uint64_t)); \4743 4779 } while (0) 4744 4780 #else
Note:
See TracChangeset
for help on using the changeset viewer.