summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sysdeps/i386/dl-hwcap.h25
-rw-r--r--sysdeps/i386/dl-procinfo.c16
-rw-r--r--sysdeps/i386/dl-procinfo.h56
-rw-r--r--sysdeps/unix/sysv/linux/i386/dl-procinfo.h2
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/dl-procinfo.h2
-rw-r--r--sysdeps/x86/cpu-features.c9
-rw-r--r--sysdeps/x86/dl-hwcap.h48
-rw-r--r--sysdeps/x86_64/dl-hwcap.h25
-rw-r--r--sysdeps/x86_64/dl-procinfo.c16
-rw-r--r--sysdeps/x86_64/dl-procinfo.h28
10 files changed, 170 insertions, 57 deletions
diff --git a/sysdeps/i386/dl-hwcap.h b/sysdeps/i386/dl-hwcap.h
new file mode 100644
index 0000000000..0e8d95f0cf
--- /dev/null
+++ b/sysdeps/i386/dl-hwcap.h
@@ -0,0 +1,25 @@
+/* i386 version of hardware capability information handling macros.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _DL_HWCAP_H
+#define _DL_HWCAP_H
+#include <sysdeps/x86/dl-hwcap.h>
+
+#define HWCAP_IMPORTANT (HWCAP_X86_SSE2 | HWCAP_X86_AVX2)
+
+#endif /* dl-hwcap.h */
diff --git a/sysdeps/i386/dl-procinfo.c b/sysdeps/i386/dl-procinfo.c
index cec7dccfb8..acb800b342 100644
--- a/sysdeps/i386/dl-procinfo.c
+++ b/sysdeps/i386/dl-procinfo.c
@@ -79,6 +79,22 @@ PROCINFO_CLASS const char _dl_x86_cap_flags[32][8]
#endif
#if !defined PROCINFO_DECL && defined SHARED
+ ._dl_x86_hwcap_flags
+#else
+PROCINFO_CLASS const char _dl_x86_hwcap_flags[2][8]
+#endif
+#ifndef PROCINFO_DECL
+= {
+ "sse2", "avx2"
+ }
+#endif
+#if !defined SHARED || defined PROCINFO_DECL
+;
+#else
+,
+#endif
+
+#if !defined PROCINFO_DECL && defined SHARED
._dl_x86_platforms
#else
PROCINFO_CLASS const char _dl_x86_platforms[4][5]
diff --git a/sysdeps/i386/dl-procinfo.h b/sysdeps/i386/dl-procinfo.h
index 9c38846f0b..5b9bb4c070 100644
--- a/sysdeps/i386/dl-procinfo.h
+++ b/sysdeps/i386/dl-procinfo.h
@@ -20,8 +20,7 @@
#ifndef _DL_PROCINFO_H
#define _DL_PROCINFO_H 1
#include <ldsodefs.h>
-
-#define _DL_HWCAP_COUNT 32
+#include <dl-hwcap.h>
#define _DL_PLATFORMS_COUNT 4
@@ -31,59 +30,6 @@
#define _DL_HWCAP_PLATFORM (((1ULL << _DL_PLATFORMS_COUNT) - 1) \
<< _DL_FIRST_PLATFORM)
-enum
-{
- HWCAP_I386_FPU = 1 << 0,
- HWCAP_I386_VME = 1 << 1,
- HWCAP_I386_DE = 1 << 2,
- HWCAP_I386_PSE = 1 << 3,
- HWCAP_I386_TSC = 1 << 4,
- HWCAP_I386_MSR = 1 << 5,
- HWCAP_I386_PAE = 1 << 6,
- HWCAP_I386_MCE = 1 << 7,
- HWCAP_I386_CX8 = 1 << 8,
- HWCAP_I386_APIC = 1 << 9,
- HWCAP_I386_SEP = 1 << 11,
- HWCAP_I386_MTRR = 1 << 12,
- HWCAP_I386_PGE = 1 << 13,
- HWCAP_I386_MCA = 1 << 14,
- HWCAP_I386_CMOV = 1 << 15,
- HWCAP_I386_FCMOV = 1 << 16,
- HWCAP_I386_MMX = 1 << 23,
- HWCAP_I386_OSFXSR = 1 << 24,
- HWCAP_I386_XMM = 1 << 25,
- HWCAP_I386_XMM2 = 1 << 26,
- HWCAP_I386_AMD3D = 1 << 31,
-
- /* XXX Which others to add here? */
- HWCAP_IMPORTANT = (HWCAP_I386_XMM2)
-
-};
-
-/* We cannot provide a general printing function. */
-#define _dl_procinfo(type, word) -1
-
-static inline const char *
-__attribute__ ((unused))
-_dl_hwcap_string (int idx)
-{
- return GLRO(dl_x86_cap_flags)[idx];
-};
-
-static inline int
-__attribute__ ((unused, always_inline))
-_dl_string_hwcap (const char *str)
-{
- int i;
-
- for (i = 0; i < _DL_HWCAP_COUNT; i++)
- {
- if (strcmp (str, GLRO(dl_x86_cap_flags)[i]) == 0)
- return i;
- }
- return -1;
-};
-
static inline int
__attribute__ ((unused, always_inline))
_dl_string_platform (const char *str)
diff --git a/sysdeps/unix/sysv/linux/i386/dl-procinfo.h b/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
index d49638c2e0..c8196a81dc 100644
--- a/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
+++ b/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
@@ -36,7 +36,7 @@ _dl_procinfo (unsigned int type, unsigned long int word)
_dl_printf ("AT_HWCAP: ");
- for (i = 0; i < _DL_HWCAP_COUNT; ++i)
+ for (i = 0; i < 32; ++i)
if (word & (1 << i))
_dl_printf (" %s", GLRO(dl_x86_cap_flags)[i]);
diff --git a/sysdeps/unix/sysv/linux/x86_64/dl-procinfo.h b/sysdeps/unix/sysv/linux/x86_64/dl-procinfo.h
index 7829e1cd67..dba5cc960f 100644
--- a/sysdeps/unix/sysv/linux/x86_64/dl-procinfo.h
+++ b/sysdeps/unix/sysv/linux/x86_64/dl-procinfo.h
@@ -1,5 +1,5 @@
#if IS_IN (ldconfig)
# include <sysdeps/unix/sysv/linux/i386/dl-procinfo.h>
#else
-# include <sysdeps/generic/dl-procinfo.h>
+# include <sysdeps/x86_64/dl-procinfo.h>
#endif
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index 33788ed323..10fe2f3f85 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -18,6 +18,7 @@
#include <cpuid.h>
#include <cpu-features.h>
+#include <dl-hwcap.h>
static void
get_common_indeces (struct cpu_features *cpu_features,
@@ -302,4 +303,12 @@ no_cpuid:
cpu_features->family = family;
cpu_features->model = model;
cpu_features->kind = kind;
+
+ /* Reuse dl_hwcap and dl_hwcap_mask for x86. */
+ GLRO(dl_hwcap) = 0;
+ if (CPU_FEATURES_CPU_P (cpu_features, SSE2))
+ GLRO(dl_hwcap) |= HWCAP_X86_SSE2;
+ if (CPU_FEATURES_ARCH_P (cpu_features, AVX2_Usable))
+ GLRO(dl_hwcap) |= HWCAP_X86_AVX2;
+ GLRO(dl_hwcap_mask) = HWCAP_IMPORTANT;
}
diff --git a/sysdeps/x86/dl-hwcap.h b/sysdeps/x86/dl-hwcap.h
new file mode 100644
index 0000000000..13ff32a485
--- /dev/null
+++ b/sysdeps/x86/dl-hwcap.h
@@ -0,0 +1,48 @@
+/* x86 version of hardware capability information handling macros.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define _DL_HWCAP_COUNT 2
+
+enum
+{
+ HWCAP_X86_SSE2 = 1 << 0,
+ HWCAP_X86_AVX2 = 1 << 1
+};
+
+static inline const char *
+__attribute__ ((unused))
+_dl_hwcap_string (int idx)
+{
+ return GLRO(dl_x86_hwcap_flags)[idx];
+};
+
+static inline int
+__attribute__ ((unused, always_inline))
+_dl_string_hwcap (const char *str)
+{
+ int i;
+
+ for (i = 0; i < _DL_HWCAP_COUNT; i++)
+ {
+ if (strcmp (str, GLRO(dl_x86_hwcap_flags)[i]) == 0)
+ return i;
+ }
+ return -1;
+};
+
+/* We cannot provide a general printing function. */
+#define _dl_procinfo(type, word) -1
diff --git a/sysdeps/x86_64/dl-hwcap.h b/sysdeps/x86_64/dl-hwcap.h
new file mode 100644
index 0000000000..6e31fa91be
--- /dev/null
+++ b/sysdeps/x86_64/dl-hwcap.h
@@ -0,0 +1,25 @@
+/* x86-64 version of hardware capability information handling macros.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _DL_HWCAP_H
+#define _DL_HWCAP_H
+#include <sysdeps/x86/dl-hwcap.h>
+
+#define HWCAP_IMPORTANT (HWCAP_X86_AVX2)
+
+#endif /* dl-hwcap.h */
diff --git a/sysdeps/x86_64/dl-procinfo.c b/sysdeps/x86_64/dl-procinfo.c
index a76624fb06..5ccdb7fbc3 100644
--- a/sysdeps/x86_64/dl-procinfo.c
+++ b/sysdeps/x86_64/dl-procinfo.c
@@ -53,5 +53,21 @@ PROCINFO_CLASS struct cpu_features _dl_x86_cpu_features
,
#endif
+#if !defined PROCINFO_DECL && defined SHARED
+ ._dl_x86_hwcap_flags
+#else
+PROCINFO_CLASS const char _dl_x86_hwcap_flags[2][8]
+#endif
+#ifndef PROCINFO_DECL
+= {
+ "sse2", "avx2"
+ }
+#endif
+#if !defined SHARED || defined PROCINFO_DECL
+;
+#else
+,
+#endif
+
#undef PROCINFO_DECL
#undef PROCINFO_CLASS
diff --git a/sysdeps/x86_64/dl-procinfo.h b/sysdeps/x86_64/dl-procinfo.h
new file mode 100644
index 0000000000..ddbde2d946
--- /dev/null
+++ b/sysdeps/x86_64/dl-procinfo.h
@@ -0,0 +1,28 @@
+/* x86-64 version of processor capability information handling macros.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _DL_PROCINFO_H
+#define _DL_PROCINFO_H 1
+#include <dl-hwcap.h>
+
+/* There're no platforms to filter out. */
+#define _DL_HWCAP_PLATFORM 0
+
+#define _dl_string_platform(str) (-1)
+
+#endif /* dl-procinfo.h */