about summary refs log tree commit diff
path: root/sysdeps/x86/cpu-features.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-08-18 07:59:49 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-08-18 08:00:00 -0700
commit1814df5b02b9c359052c2048a1d2d617b406a17a (patch)
tree30f5786d3e53d6043ecaab75bdb71cddf6567368 /sysdeps/x86/cpu-features.h
parent441c3b59d1e2fca4ad40cf53d03d6196c978e85f (diff)
downloadglibc-1814df5b02b9c359052c2048a1d2d617b406a17a.tar.gz
glibc-1814df5b02b9c359052c2048a1d2d617b406a17a.tar.xz
glibc-1814df5b02b9c359052c2048a1d2d617b406a17a.zip
Define HAS_CPUID/HAS_I586/HAS_I686 from -march=
cpuid, i586 and i686 instructions are available if the processor
specified by -march= supports them.  We can use this information
to determine whether those instructions can be used safely.

	* sysdeps/x86/cpu-features.c (init_cpu_features): Check
	whether cpuid is available only if HAS_CPUID is 0.
	* sysdeps/x86/cpu-features.h (HAS_CPUID): New.
	(HAS_I586): Likewise.
	(HAS_I686): Likewise.
Diffstat (limited to 'sysdeps/x86/cpu-features.h')
-rw-r--r--sysdeps/x86/cpu-features.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/sysdeps/x86/cpu-features.h b/sysdeps/x86/cpu-features.h
index 22e5abb919..6b8299f125 100644
--- a/sysdeps/x86/cpu-features.h
+++ b/sysdeps/x86/cpu-features.h
@@ -237,4 +237,31 @@ extern const struct cpu_features *__get_cpu_features (void)
 
 #endif	/* !__ASSEMBLER__ */
 
+#ifdef __x86_64__
+# define HAS_CPUID 1
+#elif defined __pentium__
+# define HAS_CPUID 1
+# define HAS_I586 1
+# define HAS_I686 0
+#elif (defined __pentiumpro__ || defined __pentium4__		\
+       || defined __nocona__ || defined __atom__		\
+       || defined __core2__ || defined __corei7__		\
+       || defined __corei7_avx__ || defined __core_avx2__	\
+       || defined __nehalem__ || defined __sandybridge__	\
+       || defined __haswell__  || defined __knl__		\
+       || defined __bonnell__ || defined __silvermont__ 	\
+       || defined __k6__ || defined __k8__			\
+       || defined __athlon__ || defined __amdfam10__		\
+       || defined __bdver1__ || defined __bdver2__		\
+       || defined __bdver3__ || defined __bdver4__		\
+       || defined __btver1__ || defined __btver2__)
+# define HAS_CPUID 1
+# define HAS_I586 1
+# define HAS_I686 1
+#else
+# define HAS_CPUID 0
+# define HAS_I586 0
+# define HAS_I686 0
+#endif
+
 #endif  /* cpu_features_h */