Skip to content

Commit 084ec5c

Browse files
natanbcgchatelet
authored andcommitted
Convert XGETBV to equivalent byte form in GetXCR0Eax (#69)
osxcross (https://github.com/tpoechtrager/osxcross) gives the following error, which also happens with regular gcc on OS X (asmjit/asmjit#78): ``` cpu_features/src/cpuinfo_x86.c:44:no such instruction: `XGETBV' ```
1 parent 7806502 commit 084ec5c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/cpuinfo_x86.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ Leaf CpuId(uint32_t leaf_id) {
4141

4242
uint32_t GetXCR0Eax(void) {
4343
uint32_t eax, edx;
44-
__asm("XGETBV" : "=a"(eax), "=d"(edx) : "c"(0));
44+
/* named form of xgetbv not supported on OSX, so must use byte form, see:
45+
https://github.com/asmjit/asmjit/issues/78
46+
*/
47+
__asm(".byte 0x0F, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c"(0));
4548
return eax;
4649
}
4750

0 commit comments

Comments
 (0)