x86: In ld.so, diagnose missing APX support in APX-only builds
[glibc.git] / sysdeps / x86_64 / tst-audit6.c
blobf2f6a487c4115e0f2e8bb4731508104af102d7c3
1 /* Test case for x86-64 preserved registers in dynamic linker. */
3 #include <stdlib.h>
4 #include <string.h>
5 #include <cpuid.h>
6 #include <emmintrin.h>
8 extern __m128i audit_test (__m128i, __m128i, __m128i, __m128i,
9 __m128i, __m128i, __m128i, __m128i);
12 static int
13 avx_enabled (void)
15 unsigned int eax, ebx, ecx, edx;
17 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx) == 0
18 || (ecx & (bit_AVX | bit_OSXSAVE)) != (bit_AVX | bit_OSXSAVE))
19 return 0;
21 /* Check the OS has AVX and SSE saving enabled. */
22 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
24 return (eax & 6) == 6;
28 static int
29 do_test (void)
31 /* Run AVX test only if AVX is supported. */
32 if (avx_enabled ())
34 __m128i xmm = _mm_setzero_si128 ();
35 __m128i ret = audit_test (xmm, xmm, xmm, xmm, xmm, xmm, xmm, xmm);
37 xmm = _mm_set1_epi32 (0x98abcdef);
38 if (memcmp (&xmm, &ret, sizeof (ret)))
39 abort ();
41 return 0;
44 #define TEST_FUNCTION do_test ()
45 #include "../../test-skeleton.c"