Sophie

Sophie

distrib > Mageia > 6 > armv5tl > by-pkgid > 741d673bcb95c5664e7c2a84750d540a > files > 122

glibc-2.22-26.mga6.src.rpm

2011-2014 Thomas Backlund <tmb@mageia.org>

        * Rebased / adapted for new glibc

2006-05-17  Gwenole Beauchesne  <gbeauchesne@mandriva.com>

        * Update and simplify for glibc 2.4.90.

2002-12-07  Gwenole Beauchesne  <gbeauchesne@mandrakesoft.com>

        Let an i586 rtld load i686 libraries (especially libpthread)

        * elf/rtld.c (HP_TIMING_AVAIL): Redefine to HP_TIMING_HWCAP_AVAIL
        since early statistics require high-precision timers.
        * sysdeps/generic/ldsodefs.h (rtld_global): Declare
        _dl_cpuclock_offset if HP_TIMING_HWCAP_AVAIL is defined too.

        * sysdeps/unix/sysv/linux/i386/i586/Makefile: New file.
        * sysdeps/unix/sysv/linux/i386/i586/hp-timing.c: New file.
        * sysdeps/unix/sysv/linux/i386/i586/hp-timing.h: New file.
---
 elf/rtld.c                    |   12 ++++++++++-
 sysdeps/generic/ldsodefs.h    |    2 -
 sysdeps/i386/i586/Makefile    |    4 +++
 sysdeps/i386/i586/hp-timing.c |    2 +
 sysdeps/i386/i586/hp-timing.h |   43 ++++++++++++++++++++++++++++++++++++++++++

diff -Nurp glibc-2.20.orig/elf/rtld.c glibc-2.20/elf/rtld.c
--- glibc-2.20.orig/elf/rtld.c	2014-09-07 11:09:09.000000000 +0300
+++ glibc-2.20/elf/rtld.c	2014-09-08 18:12:17.640928030 +0300
@@ -16,6 +16,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+/* Early statistics require high-precision timing.  */
+#define NEED_HP_TIMING_HWCAP_AVAIL 1
+
 #include <errno.h>
 #include <dlfcn.h>
 #include <fcntl.h>
@@ -195,6 +198,12 @@ static void dl_main (const ElfW(Phdr) *p
 static struct libname_list _dl_rtld_libname;
 static struct libname_list _dl_rtld_libname2;
 
+/* Run-time detect availability of high-precision timer?  */
+#ifdef HP_TIMING_HWCAP_AVAIL
+# undef HP_SMALL_TIMING_AVAIL
+# define HP_SMALL_TIMING_AVAIL HP_TIMING_HWCAP_AVAIL
+#endif
+
 /* Variable for statistics.  */
 #ifndef HP_TIMING_NONAVAIL
 static hp_timing_t relocate_time;
@@ -296,7 +305,8 @@ _dl_start_final (void *arg, struct dl_st
 # endif
 #endif
 
-  HP_TIMING_NOW (GL(dl_cpuclock_offset));
+  if (HP_SMALL_TIMING_AVAIL)
+    HP_TIMING_NOW (GL(dl_cpuclock_offset));
 
   /* Initialize the stack end variable.  */
   __libc_stack_end = __builtin_frame_address (0);
diff -Nurp glibc-2.20.orig/sysdeps/generic/ldsodefs.h glibc-2.20/sysdeps/generic/ldsodefs.h
--- glibc-2.20.orig/sysdeps/generic/ldsodefs.h	2014-09-07 11:09:09.000000000 +0300
+++ glibc-2.20/sysdeps/generic/ldsodefs.h	2014-09-08 18:17:19.655631175 +0300
@@ -319,7 +319,7 @@ struct rtld_global
   /* The object to be initialized first.  */
   EXTERN struct link_map *_dl_initfirst;
 
-#if HP_SMALL_TIMING_AVAIL
+#if HP_SMALL_TIMING_AVAIL || defined HP_TIMING_HWCAP_AVAIL
   /* Start time on CPU clock.  */
   EXTERN hp_timing_t _dl_cpuclock_offset;
 #endif
diff -Nurp glibc-2.20.orig/sysdeps/i386/i586/hp-timing.h glibc-2.20/sysdeps/i386/i586/hp-timing.h
--- glibc-2.20.orig/sysdeps/i386/i586/hp-timing.h	1970-01-01 02:00:00.000000000 +0200
+++ glibc-2.20/sysdeps/i386/i586/hp-timing.h	2014-09-08 18:07:38.466353624 +0300
@@ -0,0 +1,43 @@
+#ifndef _HP_HWCAP_TIMING_H
+#define _HP_HWCAP_TIMING_H 1
+
+/* We can use the i686 implementation with slight changes.  */
+#include <sysdeps/i386/i686/hp-timing.h>
+
+/* We need the definition of HWCAP_I386_TSC.  */
+#include <sysdeps/i386/dl-hwcapinfo.h>
+
+/* We need to perform a runtime check for the timestamp register.  */
+#undef  HP_SMALL_TIMING_AVAIL
+#define HP_SMALL_TIMING_AVAIL (0)
+
+/* HP_TIMING_HWCAP_AVAIL: this macro performs a run-time check for the
+   capability.  */
+#define HP_TIMING_HWCAP_AVAIL (_dl_hp_timing_avail())
+
+/* Perform the TSC check.  */
+#ifdef NEED_HP_TIMING_HWCAP_AVAIL
+static inline
+unsigned int
+_dl_cpuid_edx (unsigned int op)
+{
+  unsigned int edx;
+  __asm__ __volatile__("push %%ebx ; cpuid ; pop %%ebx"
+		       : "=d" (edx) : "a" (op) : "ecx");
+  return edx;
+}
+
+static int
+internal_function
+_dl_hp_timing_avail (void)
+{
+  static int has_tsc = -1;
+
+  if (__builtin_expect (has_tsc == -1, 0))
+    has_tsc = (_dl_cpuid_edx(1) & HWCAP_I386_TSC) == HWCAP_I386_TSC;
+
+  return has_tsc;
+}
+#endif
+
+#endif /* hp-timing.h */