From 084ec5cd0f29c151f3c036065c74985004bda3dc Mon Sep 17 00:00:00 2001 From: natanbc Date: Wed, 20 Mar 2019 06:04:24 -0300 Subject: [PATCH] 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 (https://github.com/asmjit/asmjit/issues/78): ``` cpu_features/src/cpuinfo_x86.c:44:no such instruction: `XGETBV' ``` --- src/cpuinfo_x86.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cpuinfo_x86.c b/src/cpuinfo_x86.c index 2bec7bd..52f178f 100644 --- a/src/cpuinfo_x86.c +++ b/src/cpuinfo_x86.c @@ -41,7 +41,10 @@ Leaf CpuId(uint32_t leaf_id) { uint32_t GetXCR0Eax(void) { uint32_t eax, edx; - __asm("XGETBV" : "=a"(eax), "=d"(edx) : "c"(0)); + /* named form of xgetbv not supported on OSX, so must use byte form, see: + https://github.com/asmjit/asmjit/issues/78 + */ + __asm(".byte 0x0F, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c"(0)); return eax; }