This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch hjl/pr14955 created. glibc-2.17-40-g2bf154a
- From: hjl at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 3 Jan 2013 17:43:14 -0000
- Subject: GNU C Library master sources branch hjl/pr14955 created. glibc-2.17-40-g2bf154a
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, hjl/pr14955 has been created
at 2bf154ace3fbee75d2391ce62de6eee1fce7d03c (commit)
- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=2bf154ace3fbee75d2391ce62de6eee1fce7d03c
commit 2bf154ace3fbee75d2391ce62de6eee1fce7d03c
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Fri Dec 14 10:28:13 2012 -0800
Make __get_cpu_features hidden
Add init-arch.o/init-arch.os to libm.
diff --git a/ChangeLog.bz14955 b/ChangeLog.bz14955
new file mode 100644
index 0000000..10cc34c
--- /dev/null
+++ b/ChangeLog.bz14955
@@ -0,0 +1,30 @@
+2013-01-03 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #14955]
+ * include/libc-symbols.h (libc_ifunc): Remove INIT_ARCH.
+ (libm_ifunc): Defined to libc_ifunc.
+ * sysdeps/i386/i686/fpu/multiarch/Makefile (libm-sysdep_routines):
+ Add init-arch.
+ * sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines):
+ Likewise.
+ * sysdeps/i386/i686/multiarch/Makefile (CPPFLAGS-init-arch.c): New
+ macro. Defined to -Din_init_arch_c.
+ ($(objpfx)test-multiarch): New dependency.
+ * sysdeps/i386/i686/multiarch/Versions: Removed.
+ * sysdeps/x86_64/multiarch/Versions: Likewise.
+ * sysdeps/wordsize-32/symbol-hacks.h: Skip if in_init_arch_c is
+ defined.
+ * sysdeps/x86/Makefile (tests): Add tst-ifunc-cpu1-main.
+ (modules-names): Add tst-ifunc-cpu1-mod.
+ (tst-ifunc-cpu1-mod.so-no-z-defs): New macro.
+ ($(objpfx)tst-ifunc-cpu1-mod.so): New dependency.
+ ($(objpfx)tst-ifunc-cpu1-main): Likewise.
+ * sysdeps/x86/tst-ifunc-cpu1-main.c: New file.
+ * sysdeps/x86/tst-ifunc-cpu1-mod.c: Likewise.
+ * sysdeps/x86_64/multiarch/Makefile ($(objpfx)test-multiarch): New
+ dependency.
+ * sysdeps/x86_64/multiarch/init-arch.c (__always_inline): Defined
+ to empty.
+ (__get_cpu_features): Removed.
+ * sysdeps/x86_64/multiarch/init-arch.h (INIT_ARCH): Removed.
+ (__get_cpu_features): Defined as an inline function.
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index 0608320..3e4c5ab 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -751,22 +751,12 @@ for linking")
extern void *name##_ifunc (void) __asm__ (#name); \
void *name##_ifunc (void) \
{ \
- INIT_ARCH (); \
__typeof (name) *res = expr; \
return res; \
} \
__asm__ (".type " #name ", %gnu_indirect_function");
-/* The body of the function is supposed to use __get_cpu_features
- which will, if necessary, initialize the data first. */
-#define libm_ifunc(name, expr) \
- extern void *name##_ifunc (void) __asm__ (#name); \
- void *name##_ifunc (void) \
- { \
- __typeof (name) *res = expr; \
- return res; \
- } \
- __asm__ (".type " #name ", %gnu_indirect_function");
+#define libm_ifunc(name, expr) libc_ifunc (name, (expr))
#ifdef HAVE_ASM_SET_DIRECTIVE
# define libc_ifunc_hidden_def1(local, name) \
diff --git a/sysdeps/i386/i686/fpu/multiarch/Makefile b/sysdeps/i386/i686/fpu/multiarch/Makefile
index 7d90892..92ecb04 100644
--- a/sysdeps/i386/i686/fpu/multiarch/Makefile
+++ b/sysdeps/i386/i686/fpu/multiarch/Makefile
@@ -1,4 +1,5 @@
ifeq ($(subdir),math)
+libm-sysdep_routines += init-arch
libm-sysdep_routines += e_expf-sse2 e_expf-ia32 s_sinf-sse2 s_cosf-sse2 \
s_sincosf-sse2
endif
diff --git a/sysdeps/i386/i686/multiarch/Makefile b/sysdeps/i386/i686/multiarch/Makefile
index 8946bfa..7126e23 100644
--- a/sysdeps/i386/i686/multiarch/Makefile
+++ b/sysdeps/i386/i686/multiarch/Makefile
@@ -1,7 +1,10 @@
ifeq ($(subdir),csu)
aux += init-arch
+CPPFLAGS-init-arch.c = -Din_init_arch_c
tests += test-multiarch
gen-as-const-headers += ifunc-defines.sym
+
+$(objpfx)test-multiarch: $(common-objpfx)csu/init-arch.os
endif
ifeq ($(subdir),string)
diff --git a/sysdeps/i386/i686/multiarch/Versions b/sysdeps/i386/i686/multiarch/Versions
deleted file mode 100644
index 59b185a..0000000
--- a/sysdeps/i386/i686/multiarch/Versions
+++ /dev/null
@@ -1,5 +0,0 @@
-libc {
- GLIBC_PRIVATE {
- __get_cpu_features;
- }
-}
diff --git a/sysdeps/wordsize-32/symbol-hacks.h b/sysdeps/wordsize-32/symbol-hacks.h
index 52ac5c1..e2c1e7e 100644
--- a/sysdeps/wordsize-32/symbol-hacks.h
+++ b/sysdeps/wordsize-32/symbol-hacks.h
@@ -21,7 +21,8 @@
therefore we get PLTs. Unnecessarily so. Changing gcc is a big
task which might not be worth it so we play tricks with the
assembler. */
-#if !defined __ASSEMBLER__ && !defined in_divdi3_c && !defined NOT_IN_libc && defined SHARED
+#if !defined __ASSEMBLER__ && !defined in_divdi3_c \
+ && !defined in_init_arch_c && !defined NOT_IN_libc && defined SHARED
asm ("__divdi3 = __divdi3_internal");
asm ("__udivdi3 = __udivdi3_internal");
asm ("__moddi3 = __moddi3_internal");
diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
index 3e87a77..e722a34 100644
--- a/sysdeps/x86/Makefile
+++ b/sysdeps/x86/Makefile
@@ -6,4 +6,14 @@ tests: $(objpfx)tst-xmmymm.out
$(objpfx)tst-xmmymm.out: ../sysdeps/x86/tst-xmmymm.sh $(objpfx)ld.so
@echo "Checking ld.so for SSE register use. This will take a few seconds..."
$(SHELL) $< $(objpfx) '$(NM)' '$(OBJDUMP)' '$(READELF)' > $@
+
+ifeq (yesyes,$(build-shared)$(multi-arch))
+tests += tst-ifunc-cpu1-main
+modules-names += tst-ifunc-cpu1-mod
+
+tst-ifunc-cpu1-mod.so-no-z-defs = yes
+
+$(objpfx)tst-ifunc-cpu1-mod.so: $(common-objpfx)csu/init-arch.os
+$(objpfx)tst-ifunc-cpu1-main: $(objpfx)tst-ifunc-cpu1-mod.so
+endif
endif
diff --git a/sysdeps/x86/tst-ifunc-cpu1-main.c b/sysdeps/x86/tst-ifunc-cpu1-main.c
new file mode 100644
index 0000000..37c16e2
--- /dev/null
+++ b/sysdeps/x86/tst-ifunc-cpu1-main.c
@@ -0,0 +1,10 @@
+/* Test function pointer to local STT_GNU_IFUNC function. */
+
+extern void (*foo_ptr) (void);
+
+int
+main (void)
+{
+ foo_ptr ();
+ return 0;
+}
diff --git a/sysdeps/x86/tst-ifunc-cpu1-mod.c b/sysdeps/x86/tst-ifunc-cpu1-mod.c
new file mode 100644
index 0000000..08ff30f
--- /dev/null
+++ b/sysdeps/x86/tst-ifunc-cpu1-mod.c
@@ -0,0 +1,24 @@
+#include <init-arch.h>
+
+static void
+one (void)
+{
+}
+
+static void
+two (void)
+{
+}
+
+void * foo_ifunc (void) __asm__ ("foo") attribute_hidden;
+__asm__(".type foo, %gnu_indirect_function");
+
+void *
+foo_ifunc (void)
+{
+ const struct cpu_features * cpu = __get_cpu_features ();
+ return cpu->max_cpuid > 1 ? two : one;
+}
+
+extern void foo (void) attribute_hidden;
+void (*foo_ptr) (void) = foo;
diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile
index 12b0526..2cf07bf 100644
--- a/sysdeps/x86_64/fpu/multiarch/Makefile
+++ b/sysdeps/x86_64/fpu/multiarch/Makefile
@@ -1,4 +1,5 @@
ifeq ($(subdir),math)
+libm-sysdep_routines += init-arch
libm-sysdep_routines += s_floor-c s_ceil-c s_floorf-c s_ceilf-c \
s_rint-c s_rintf-c s_nearbyint-c s_nearbyintf-c
diff --git a/sysdeps/x86_64/multiarch/Makefile b/sysdeps/x86_64/multiarch/Makefile
index dd6c27d..948f32f 100644
--- a/sysdeps/x86_64/multiarch/Makefile
+++ b/sysdeps/x86_64/multiarch/Makefile
@@ -2,6 +2,8 @@ ifeq ($(subdir),csu)
aux += init-arch
tests += test-multiarch
gen-as-const-headers += ifunc-defines.sym
+
+$(objpfx)test-multiarch: $(common-objpfx)csu/init-arch.os
endif
ifeq ($(subdir),string)
diff --git a/sysdeps/x86_64/multiarch/Versions b/sysdeps/x86_64/multiarch/Versions
deleted file mode 100644
index 59b185a..0000000
--- a/sysdeps/x86_64/multiarch/Versions
+++ /dev/null
@@ -1,5 +0,0 @@
-libc {
- GLIBC_PRIVATE {
- __get_cpu_features;
- }
-}
diff --git a/sysdeps/x86_64/multiarch/init-arch.c b/sysdeps/x86_64/multiarch/init-arch.c
index 992cbfb..9ee968e 100644
--- a/sysdeps/x86_64/multiarch/init-arch.c
+++ b/sysdeps/x86_64/multiarch/init-arch.c
@@ -19,6 +19,9 @@
#include <atomic.h>
#include <cpuid.h>
+/* Define __get_cpu_features. */
+#undef __always_inline
+#define __always_inline
#include "init-arch.h"
@@ -177,14 +180,3 @@ __init_cpu_features (void)
atomic_write_barrier ();
__cpu_features.kind = kind;
}
-
-#undef __get_cpu_features
-
-const struct cpu_features *
-__get_cpu_features (void)
-{
- if (__cpu_features.kind == arch_kind_unknown)
- __init_cpu_features ();
-
- return &__cpu_features;
-}
diff --git a/sysdeps/x86_64/multiarch/init-arch.h b/sysdeps/x86_64/multiarch/init-arch.h
index 0aece18..cba10cf 100644
--- a/sysdeps/x86_64/multiarch/init-arch.h
+++ b/sysdeps/x86_64/multiarch/init-arch.h
@@ -109,19 +109,18 @@ extern struct cpu_features
extern void __init_cpu_features (void) attribute_hidden;
-# define INIT_ARCH() \
- do \
- if (__cpu_features.kind == arch_kind_unknown) \
- __init_cpu_features (); \
- while (0)
-
-/* Used from outside libc.so to get access to the CPU features structure. */
-extern const struct cpu_features *__get_cpu_features (void)
- __attribute__ ((const));
-
-# ifndef NOT_IN_libc
-# define __get_cpu_features() (&__cpu_features)
-# endif
+
+/* Implicitly call __init_cpu_features before accessing the CPU features
+ structure. */
+
+extern __always_inline attribute_hidden
+const struct cpu_features *
+__get_cpu_features (void)
+{
+ if (__cpu_features.kind == arch_kind_unknown)
+ __init_cpu_features ();
+ return &__cpu_features;
+}
# define HAS_CPU_FEATURE(idx, reg, bit) \
((__get_cpu_features ()->cpuid[idx].reg & (bit)) != 0)
-----------------------------------------------------------------------
hooks/post-receive
--
GNU C Library master sources