]> git.ozlabs.org Git - ccan/blob - ccan/cpuid/issupprted.S
cpuid: only compile source file if x86 cpu
[ccan] / ccan / cpuid / issupprted.S
1 /*
2   Test if the CPUID instruction is available.
3   returns 1 if so, 0 otherwise.  */
4
5 /* Only compile this file if we're on a x86 machine.  */
6 #if defined(__i386__) || defined(__i386) || defined(__x86_64) \
7         || defined(_M_AMD64) || defined(__M_X64)
8
9 .section .text
10 .global cpuid_is_supported
11 .type cpuid_is_supported, @function
12 cpuid_is_supported:
13         nop
14
15         pushfl
16         popl %eax
17         movl %eax, %ecx
18         xorl $0x200000, %eax
19         pushl %eax
20         popfl
21
22         pushfl
23         popl %eax
24         xorl %ecx, %eax
25         shrl $21, %eax
26         andl $1, %eax
27         pushl %ecx
28         popfl
29
30         ret
31
32         .size cpuid_is_supported, .-cpuid_is_supported
33 #endif
34