Changeset 59527 in vbox for trunk/include/iprt
- Timestamp:
- Jan 31, 2016 11:54:20 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 105318
- Location:
- trunk/include/iprt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asm-watcom-x86-16.h
r59480 r59527 150 150 /* ASMAtomicCmpXchgExU64: External assembly implementation, too few registers for parameters. */ 151 151 152 #undef ASMSerializeInstruction 153 #if 1 154 # pragma aux ASMSerializeInstruction = \ 152 #undef ASMSerializeInstructionCpuId 153 #pragma aux ASMSerializeInstructionCpuId = \ 154 ".586" \ 155 "xor eax, eax" \ 156 "cpuid" \ 157 parm [] \ 158 modify exact [ax bx cx dx]; 159 160 #undef ASMSerializeInstructionIRet 161 #pragma aux ASMSerializeInstructionIRet = \ 155 162 "pushf" \ 156 163 "push cs" \ … … 158 165 "jmp done" \ 159 166 "foo:" \ 160 "iret" /* serializing */\167 "iret" \ 161 168 "done:" \ 162 169 parm [] \ 163 modify exact [ax]; 164 #else 165 # pragma aux ASMSerializeInstruction = \ 166 ".586" \ 167 "xor eax, eax" \ 168 "cpuid" \ 170 modify exact []; 171 172 #undef ASMSerializeInstructionRdTscp 173 #pragma aux ASMSerializeInstructionRdTscp = \ 174 0x0f 0x01 0xf9 \ 169 175 parm [] \ 170 modify exact [ax bx cx dx]; 171 #endif 176 modify exact [ax dx cx]; 172 177 173 178 #undef ASMAtomicReadU64 -
trunk/include/iprt/asm-watcom-x86-32.h
r58788 r59527 151 151 modify exact [eax edx]; 152 152 153 #undef ASMSerializeInstruction 154 #pragma aux ASMSerializeInstruction = \153 #undef ASMSerializeInstructionCpuId 154 #pragma aux ASMSerializeInstructionCpuId = \ 155 155 ".586" \ 156 156 "xor eax, eax" \ … … 158 158 parm [] \ 159 159 modify exact [eax ebx ecx edx]; 160 161 #undef ASMSerializeInstructionIRet 162 #pragma aux ASMSerializeInstructionIRet = \ 163 "pushf" \ 164 "push cs" \ 165 "call foo" /* 'push offset done' doesn't work */ \ 166 "jmp done" \ 167 "foo:" \ 168 "iret" \ 169 "done:" \ 170 parm [] \ 171 modify exact []; 172 173 #undef ASMSerializeInstructionRdTscp 174 #pragma aux ASMSerializeInstructionRdTscp = \ 175 0x0f 0x01 0xf9 \ 176 parm [] \ 177 modify exact [eax edx ecx]; 160 178 161 179 #undef ASMAtomicReadU64 -
trunk/include/iprt/asm.h
r59480 r59527 1373 1373 1374 1374 /** 1375 * Serialize Instruction.1375 * Virtualization unfriendly serializing instruction, always exits. 1376 1376 */ 1377 1377 #if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN 1378 DECLASM(void) ASMSerializeInstruction (void);1379 #else 1380 DECLINLINE(void) ASMSerializeInstruction (void)1378 DECLASM(void) ASMSerializeInstructionCpuId(void); 1379 #else 1380 DECLINLINE(void) ASMSerializeInstructionCpuId(void) 1381 1381 { 1382 1382 # if RT_INLINE_ASM_GNU_STYLE 1383 1383 RTCCUINTREG xAX = 0; 1384 1384 # ifdef RT_ARCH_AMD64 1385 __asm__ ("cpuid"1386 : "=a" (xAX)1387 : "0" (xAX)1388 : "rbx", "rcx", "rdx");1385 __asm__ __volatile__ ("cpuid" 1386 : "=a" (xAX) 1387 : "0" (xAX) 1388 : "rbx", "rcx", "rdx"); 1389 1389 # elif (defined(PIC) || defined(__PIC__)) && defined(__i386__) 1390 __asm__ ("push %%ebx\n\t"1391 "cpuid\n\t"1392 "pop %%ebx\n\t"1393 : "=a" (xAX)1394 : "0" (xAX)1395 : "ecx", "edx");1396 # else 1397 __asm__ ("cpuid"1398 : "=a" (xAX)1399 : "0" (xAX)1400 : "ebx", "ecx", "edx");1390 __asm__ __volatile__ ("push %%ebx\n\t" 1391 "cpuid\n\t" 1392 "pop %%ebx\n\t" 1393 : "=a" (xAX) 1394 : "0" (xAX) 1395 : "ecx", "edx"); 1396 # else 1397 __asm__ __volatile__ ("cpuid" 1398 : "=a" (xAX) 1399 : "0" (xAX) 1400 : "ebx", "ecx", "edx"); 1401 1401 # endif 1402 1402 … … 1415 1415 # endif 1416 1416 } 1417 #endif 1418 1419 /** 1420 * Virtualization friendly serializing instruction, though more expensive. 1421 */ 1422 #if RT_INLINE_ASM_EXTERNAL 1423 DECLASM(void) ASMSerializeInstructionIRet(void); 1424 #else 1425 DECLINLINE(void) ASMSerializeInstructionIRet(void) 1426 { 1427 # if RT_INLINE_ASM_GNU_STYLE 1428 # ifdef RT_ARCH_AMD64 1429 __asm__ __volatile__ ("movq %%rsp,%%r10\n\t" 1430 "subq $128, %%rsp\n\t" /*redzone*/ 1431 "mov %%ss, %%eax\n\t" 1432 "pushq %%rax\n\t" 1433 "pushq %%r10\n\t" 1434 "pushfq\n\t" 1435 "movl %%cs, %%eax\n\t" 1436 "pushq %%rax\n\t" 1437 "leaq 1f(%%rip), %%rax\n\t" 1438 "pushq %%rax\n\t" 1439 "iretq\n\t" 1440 "1:\n\t" 1441 ::: "rax", "r10"); 1442 # else 1443 __asm__ __volatile__ ("pushfl\n\t" 1444 "pushl %%cs\n\t" 1445 "pushl $1f\n\t" 1446 "iretl\n\t" 1447 "1:\n\t" 1448 :::); 1449 # endif 1450 1451 # else 1452 __asm 1453 { 1454 pushfd 1455 push cs 1456 push la_ret 1457 retd 1458 la_ret: 1459 } 1460 # endif 1461 } 1462 #endif 1463 1464 /** 1465 * Virtualization friendlier serializing instruction, may still cause exits. 1466 */ 1467 #if RT_INLINE_ASM_EXTERNAL && RT_INLINE_ASM_USES_INTRIN < 15 1468 DECLASM(void) ASMSerializeInstructionRdTscp(void); 1469 #else 1470 DECLINLINE(void) ASMSerializeInstructionRdTscp(void) 1471 { 1472 # if RT_INLINE_ASM_GNU_STYLE 1473 /* rdtscp is not supported by ancient linux build VM of course :-( */ 1474 # ifdef RT_ARCH_AMD64 1475 /*__asm__ __volatile__("rdtscp\n\t" ::: "rax", "rdx, "rcx"); */ 1476 __asm__ __volatile__(".byte 0x0f,0x01,0xf9\n\t" ::: "rax", "rdx", "rcx"); 1477 # else 1478 /*__asm__ __volatile__("rdtscp\n\t" ::: "eax", "edx, "ecx"); */ 1479 __asm__ __volatile__(".byte 0x0f,0x01,0xf9\n\t" ::: "eax", "edx", "ecx"); 1480 # endif 1481 # else 1482 # if RT_INLINE_ASM_USES_INTRIN >= 15 1483 uint32_t uIgnore; 1484 (void)__rdtscp(&uIgnore); 1485 (void)uIgnore; 1486 # else 1487 __asm 1488 { 1489 rdtscp 1490 } 1491 # endif 1492 # endif 1493 } 1494 #endif 1495 1496 1497 /** 1498 * Serialize Instruction. 1499 */ 1500 #if (defined(RT_ARCH_X86) && ARCH_BITS == 16) || defined(IN_GUEST) 1501 # define ASMSerializeInstruction() ASMSerializeInstructionIRet() 1502 #else 1503 # define ASMSerializeInstruction() ASMSerializeInstructionCpuId() 1417 1504 #endif 1418 1505
Note:
See TracChangeset
for help on using the changeset viewer.