]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/x86_64/multiarch/test-multiarch.c
1 /* Test CPU feature data.
2 This file is part of the GNU C Library.
3 Copyright (C) 2012-2018 Free Software Foundation, Inc.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <cpu-features.h>
24 static char *cpu_flags
;
26 /* Search for flags in /proc/cpuinfo and store line
36 f
= fopen ("/proc/cpuinfo", "r");
39 printf ("cannot open /proc/cpuinfo\n");
43 while ((read
= getline (&line
, &len
, f
)) != -1)
45 if (strncmp (line
, "flags", 5) == 0)
47 cpu_flags
= strdup (line
);
56 check_proc (const char *proc_name
, int flag
, const char *name
)
60 printf ("Checking %s:\n", name
);
61 printf (" init-arch %d\n", flag
);
62 if (strstr (cpu_flags
, proc_name
) != NULL
)
64 printf (" cpuinfo (%s) %d\n", proc_name
, found
);
67 printf (" *** failure ***\n");
69 return (found
!= flag
);
73 do_test (int argc
, char **argv
)
78 fails
= check_proc ("avx", HAS_ARCH_FEATURE (AVX_Usable
),
79 "HAS_ARCH_FEATURE (AVX_Usable)");
80 fails
+= check_proc ("fma4", HAS_ARCH_FEATURE (FMA4_Usable
),
81 "HAS_ARCH_FEATURE (FMA4_Usable)");
82 fails
+= check_proc ("sse4_2", HAS_CPU_FEATURE (SSE4_2
),
83 "HAS_CPU_FEATURE (SSE4_2)");
84 fails
+= check_proc ("sse4_1", HAS_CPU_FEATURE (SSE4_1
)
85 , "HAS_CPU_FEATURE (SSE4_1)");
86 fails
+= check_proc ("ssse3", HAS_CPU_FEATURE (SSSE3
),
87 "HAS_CPU_FEATURE (SSSE3)");
88 fails
+= check_proc ("popcnt", HAS_CPU_FEATURE (POPCNT
),
89 "HAS_CPU_FEATURE (POPCNT)");
91 printf ("%d differences between /proc/cpuinfo and glibc code.\n", fails
);
96 #include "../../../test-skeleton.c"