diff options
author | Matti Picus <matti.picus@gmail.com> | 2020-02-07 11:00:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-07 11:00:15 +0200 |
commit | 615b6a5ef4040e5602a21aa2ff528c90d3ec6dd4 (patch) | |
tree | 9ca85360ccd925d5bbac2ac5a81ea58d290925a6 | |
parent | dae4f67c797176c66281101be8f3b4d6c424735c (diff) | |
parent | b4adb831936b10a5c12d65e5c1ee206100988ee2 (diff) | |
download | numpy-615b6a5ef4040e5602a21aa2ff528c90d3ec6dd4.tar.gz |
Merge pull request #15526 from seiko2plus/issue15525
BUG: Fix inline assembly that detects cpu features on x86(32bit)
-rw-r--r-- | numpy/core/src/common/npy_cpu_features.c.src | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/numpy/core/src/common/npy_cpu_features.c.src b/numpy/core/src/common/npy_cpu_features.c.src index cbd99827b..4f193a471 100644 --- a/numpy/core/src/common/npy_cpu_features.c.src +++ b/numpy/core/src/common/npy_cpu_features.c.src @@ -94,15 +94,21 @@ npy__cpu_cpuid(int reg[4], int func_id) __cpuid(reg, func_id); #elif defined(__GNUC__) || defined(__clang__) #if defined(NPY_CPU_X86) && defined(__PIC__) - // %ebx may be the PIC register - #define NPY__CPUID_ASM \ - "xchg{l}\t{%%}ebx, %1\n\t" \ - "cpuid\n\t" \ - "xchg{l}\t{%%}ebx, %1\n\t" + // %ebx may be the PIC register + __asm__("xchg{l}\t{%%}ebx, %1\n\t" + "cpuid\n\t" + "xchg{l}\t{%%}ebx, %1\n\t" + : "=a" (reg[0]), "=r" (reg[1]), "=c" (reg[2]), + "=d" (reg[3]) + : "a" (func_id), "c" (0) + ); #else - #define NPY__CPUID_ASM "cpuid" + __asm__("cpuid\n\t" + : "=a" (reg[0]), "=b" (reg[1]), "=c" (reg[2]), + "=d" (reg[3]) + : "a" (func_id), "c" (0) + ); #endif - __asm__(NPY__CPUID_ASM : "=a" (reg[0]), "=b" (reg[1]), "=c" (reg[2]), "=d" (reg[3]) : "a" (func_id), "c" (0) : ); #else // TODO: handle other x86 compilers reg[0] = 0; |