1 /* Check if the OS supports executing AVX instructions.  */
2 
3 #define XCR_XFEATURE_ENABLED_MASK	0x0
4 
5 #define XSTATE_FP	0x1
6 #define XSTATE_SSE	0x2
7 #define XSTATE_YMM	0x4
8 
9 static int
avx_os_support(void)10 avx_os_support (void)
11 {
12   unsigned int eax, edx;
13   unsigned int ecx = XCR_XFEATURE_ENABLED_MASK;
14 
15   __asm__ ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (ecx));
16 
17   return (eax & (XSTATE_SSE | XSTATE_YMM)) == (XSTATE_SSE | XSTATE_YMM);
18 }
19