Changeset 10995 in vbox for trunk/include
- Timestamp:
- Jul 30, 2008 3:49:16 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asm.h
r10943 r10995 5540 5540 } 5541 5541 5542 /** 5543 * Reverse the byte order of the given 16-bit integer. 5544 * 5545 * @returns Revert 5546 * @param u16 16-bit integer value. 5547 */ 5548 DECLINLINE(uint16_t) ASMByteSwapU16(uint16_t u16) 5549 { 5550 #if RT_INLINE_ASM_USES_INTRIN 5551 u16 = _byteswap_ushort(u16); 5552 #elif RT_INLINE_ASM_GNU_STYLE 5553 __asm__ ("rorw $8, %0" : "=r" (u16) : "0" (u16)); 5554 #else 5555 _asm 5556 { 5557 mov ax, [u16] 5558 ror ax, 8 5559 mov [u16], ax 5560 } 5561 #endif 5562 return u16; 5563 } 5542 5564 5543 5565 /** 5544 5566 * Reverse the byte order of the given 32-bit integer. 5545 * @param u32 Integer 5567 * 5568 * @returns Revert 5569 * @param u32 32-bit integer value. 5546 5570 */ 5547 5571 DECLINLINE(uint32_t) ASMByteSwapU32(uint32_t u32) … … 5562 5586 } 5563 5587 5588 5589 /** 5590 * Reverse the byte order of the given 64-bit integer. 5591 * 5592 * @returns Revert 5593 * @param u64 64-bit integer value. 5594 */ 5595 DECLINLINE(uint64_t) ASMByteSwapU64(uint64_t u64) 5596 { 5597 #if defined(RT_ARCH_AMD64) && RT_INLINE_ASM_USES_INTRIN 5598 u64 = _byteswap_uint64(u64); 5599 #else /* !RT_ARCH_AMD64 (assume x86) */ 5600 u64 = (uint64_t)ASMByteSwapU32((uint32_t)u64) << 32 5601 | (uint64_t)ASMByteSwapU32(u64 >> 32); 5602 #endif 5603 return u64; 5604 } 5605 5606 5564 5607 /** @} */ 5565 5608
Note:
See TracChangeset
for help on using the changeset viewer.