Changeset 8277 in vbox for trunk/include
- Timestamp:
- Apr 22, 2008 11:56:47 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asm.h
r8275 r8277 38 38 * Defined as 1 if we're using a _MSC_VER 1400. 39 39 * Otherwise defined as 0. 40 */41 42 /** @note43 *44 * Some remarks about __volatile__: Without this keyword gcc is allowed to reorder45 * or even optimize assembler instructions away. For instance, in the following code46 * the second rdmsr instruction is optimized away because gcc treats that instruction47 * as deterministic:48 *49 * @code50 * static inline uint64_t rdmsr_low(idx)51 * {52 * uint32_t low;53 * __asm__ ("rdmsr" : "=a"(low) : "c"(idx) : "edx");54 * }55 * ...56 * uint32_t msr1 = rdmsr(1);57 * foo(msr1);58 * msr1 = rdmsr(1);59 * bar(msr1);60 * @endcode61 *62 * The input parameter of rdmsr_low is the same for both calls and therefore gcc will63 * use the result of the first call as input parameter for bar() as well. For rdmsr this64 * is not acceptable as this instruction is _not_ deterministic. This applies to reading65 * machine status information in general.66 40 */ 67 41 … … 141 115 * are unordered (note the Uo). 142 116 * 117 * @remarks Some remarks about __volatile__: Without this keyword gcc is allowed to reorder 118 * or even optimize assembler instructions away. For instance, in the following code 119 * the second rdmsr instruction is optimized away because gcc treats that instruction 120 * as deterministic: 121 * 122 * @code 123 * static inline uint64_t rdmsr_low(int idx) 124 * { 125 * uint32_t low; 126 * __asm__ ("rdmsr" : "=a"(low) : "c"(idx) : "edx"); 127 * } 128 * ... 129 * uint32_t msr1 = rdmsr_low(1); 130 * foo(msr1); 131 * msr1 = rdmsr_low(1); 132 * bar(msr1); 133 * @endcode 134 * 135 * The input parameter of rdmsr_low is the same for both calls and therefore gcc will 136 * use the result of the first call as input parameter for bar() as well. For rdmsr this 137 * is not acceptable as this instruction is _not_ deterministic. This applies to reading 138 * machine status information in general. 139 * 143 140 * @{ 144 141 */ … … 1388 1385 RTUINT64U u; 1389 1386 # if RT_INLINE_ASM_GNU_STYLE 1390 __asm__ __volatile__ 1391 : "=a" (u.s.Lo),1392 "=d" (u.s.Hi)1393 : "c" (uRegister));1387 __asm__ __volatile__("rdmsr\n\t" 1388 : "=a" (u.s.Lo), 1389 "=d" (u.s.Hi) 1390 : "c" (uRegister)); 1394 1391 1395 1392 # elif RT_INLINE_ASM_USES_INTRIN … … 1462 1459 # if RT_INLINE_ASM_GNU_STYLE 1463 1460 __asm__ __volatile__("rdmsr\n\t" 1464 : "=a" (u32)1465 : "c" (uRegister)1466 : "edx");1461 : "=a" (u32) 1462 : "c" (uRegister) 1463 : "edx"); 1467 1464 1468 1465 # elif RT_INLINE_ASM_USES_INTRIN … … 1497 1494 # if RT_INLINE_ASM_GNU_STYLE 1498 1495 __asm__ __volatile__("rdmsr\n\t" 1499 : "=d" (u32)1500 : "c" (uRegister)1501 : "eax");1496 : "=d" (u32) 1497 : "c" (uRegister) 1498 : "eax"); 1502 1499 1503 1500 # elif RT_INLINE_ASM_USES_INTRIN
Note:
See TracChangeset
for help on using the changeset viewer.