Reduce hwloc & cpuid test requirements
[gromacs.git] / cmake / TestInlineASM_gcc_x86.cpp
blobf5b184b7822e654dc225fce32145b06ada3b4f60
1 int
2 main()
4 unsigned int _eax,_ebx,_ecx,_edx;
5 unsigned int level = 0;
7 /* Test gcc inline asm for x86. Note that we CANNOT plainly use __x86_64__
8 * to correspond to a 64-bit environment without also checking that __ILP32__
9 * is NOT set, since x32 uses __x86_64__.
11 #if (defined(__x86_64__) && !defined(__ILP32__))
12 __asm__("push %%rbx \n\t"
13 "cpuid \n\t"
14 "movl %%ebx, %1 \n\t"
15 "pop %%rbx \n\t"
16 : "=a"(_eax), "=r"(_ebx), "=c"(_ecx), "=d"(_edx) : "0"(level));
17 #elif (defined(__x86_64__) && defined(__ILP32__)) || defined(__i386__)
18 __asm__("push %%ebx \n\t"
19 "cpuid \n\t"
20 "movl %%ebx, %1 \n\t"
21 "pop %%ebx \n\t"
22 : "=a"(_eax), "=r"(_ebx), "=c"(_ecx), "=d"(_edx) : "0"(level));
23 #else
24 # error Cannot detect whether this is a 32-bit or 64-bit x86 build.
25 #endif
27 return 0;