1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <assert.h>
4 #include "cpuid.h"
5 #include "mpx-os-support.h"
6
7 static int
8 __attribute__ ((noinline))
9 mpx_test (int, const char **);
10
11 #ifdef SHOULDFAIL
12 #define NORUNRES 1
13 #else
14 #define NORUNRES 0
15 #endif
16
17 #define DEBUG
18
19 static int
check_osxsave(void)20 check_osxsave (void)
21 {
22 unsigned int eax, ebx, ecx, edx;
23
24 __cpuid (1, eax, ebx, ecx, edx);
25 return (ecx & bit_OSXSAVE) != 0;
26 }
27
28 int
main(int argc,const char ** argv)29 main (int argc, const char **argv)
30 {
31 unsigned int eax, ebx, ecx, edx;
32
33 if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx))
34 return NORUNRES;
35
36 /* Run MPX test only if host has MPX support. */
37 if (check_osxsave () && (ebx & bit_MPX) && mpx_os_support ())
38 mpx_test (argc, argv);
39 else
40 {
41 #ifdef DEBUG
42 printf ("SKIPPED\n");
43 #endif
44 return NORUNRES;
45 }
46
47 return 0;
48 }
49