/[packages]/cauldron/glibc/current/SOURCES/glibc-2.20-i586-hptiming.patch
ViewVC logotype

Contents of /cauldron/glibc/current/SOURCES/glibc-2.20-i586-hptiming.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 673678 - (show annotations) (download)
Mon Sep 8 17:19:48 2014 UTC (9 years, 7 months ago) by tmb
File size: 4171 byte(s)
hp-timing.c is dropped upstream
1 2011-2014 Thomas Backlund <tmb@mageia.org>
2
3 * Rebased / adapted for new glibc
4
5 2006-05-17 Gwenole Beauchesne <gbeauchesne@mandriva.com>
6
7 * Update and simplify for glibc 2.4.90.
8
9 2002-12-07 Gwenole Beauchesne <gbeauchesne@mandrakesoft.com>
10
11 Let an i586 rtld load i686 libraries (especially libpthread)
12
13 * elf/rtld.c (HP_TIMING_AVAIL): Redefine to HP_TIMING_HWCAP_AVAIL
14 since early statistics require high-precision timers.
15 * sysdeps/generic/ldsodefs.h (rtld_global): Declare
16 _dl_cpuclock_offset if HP_TIMING_HWCAP_AVAIL is defined too.
17
18 * sysdeps/unix/sysv/linux/i386/i586/Makefile: New file.
19 * sysdeps/unix/sysv/linux/i386/i586/hp-timing.c: New file.
20 * sysdeps/unix/sysv/linux/i386/i586/hp-timing.h: New file.
21 ---
22 elf/rtld.c | 12 ++++++++++-
23 sysdeps/generic/ldsodefs.h | 2 -
24 sysdeps/i386/i586/Makefile | 4 +++
25 sysdeps/i386/i586/hp-timing.c | 2 +
26 sysdeps/i386/i586/hp-timing.h | 43 ++++++++++++++++++++++++++++++++++++++++++
27
28 diff -Nurp glibc-2.20.orig/elf/rtld.c glibc-2.20/elf/rtld.c
29 --- glibc-2.20.orig/elf/rtld.c 2014-09-07 11:09:09.000000000 +0300
30 +++ glibc-2.20/elf/rtld.c 2014-09-08 18:12:17.640928030 +0300
31 @@ -16,6 +16,9 @@
32 License along with the GNU C Library; if not, see
33 <http://www.gnu.org/licenses/>. */
34
35 +/* Early statistics require high-precision timing. */
36 +#define NEED_HP_TIMING_HWCAP_AVAIL 1
37 +
38 #include <errno.h>
39 #include <dlfcn.h>
40 #include <fcntl.h>
41 @@ -195,6 +198,12 @@ static void dl_main (const ElfW(Phdr) *p
42 static struct libname_list _dl_rtld_libname;
43 static struct libname_list _dl_rtld_libname2;
44
45 +/* Run-time detect availability of high-precision timer? */
46 +#ifdef HP_TIMING_HWCAP_AVAIL
47 +# undef HP_SMALL_TIMING_AVAIL
48 +# define HP_SMALL_TIMING_AVAIL HP_TIMING_HWCAP_AVAIL
49 +#endif
50 +
51 /* Variable for statistics. */
52 #ifndef HP_TIMING_NONAVAIL
53 static hp_timing_t relocate_time;
54 @@ -296,7 +305,8 @@ _dl_start_final (void *arg, struct dl_st
55 # endif
56 #endif
57
58 - HP_TIMING_NOW (GL(dl_cpuclock_offset));
59 + if (HP_SMALL_TIMING_AVAIL)
60 + HP_TIMING_NOW (GL(dl_cpuclock_offset));
61
62 /* Initialize the stack end variable. */
63 __libc_stack_end = __builtin_frame_address (0);
64 diff -Nurp glibc-2.20.orig/sysdeps/generic/ldsodefs.h glibc-2.20/sysdeps/generic/ldsodefs.h
65 --- glibc-2.20.orig/sysdeps/generic/ldsodefs.h 2014-09-07 11:09:09.000000000 +0300
66 +++ glibc-2.20/sysdeps/generic/ldsodefs.h 2014-09-08 18:17:19.655631175 +0300
67 @@ -319,7 +319,7 @@ struct rtld_global
68 /* The object to be initialized first. */
69 EXTERN struct link_map *_dl_initfirst;
70
71 -#if HP_SMALL_TIMING_AVAIL
72 +#if HP_SMALL_TIMING_AVAIL || defined HP_TIMING_HWCAP_AVAIL
73 /* Start time on CPU clock. */
74 EXTERN hp_timing_t _dl_cpuclock_offset;
75 #endif
76 diff -Nurp glibc-2.20.orig/sysdeps/i386/i586/hp-timing.h glibc-2.20/sysdeps/i386/i586/hp-timing.h
77 --- glibc-2.20.orig/sysdeps/i386/i586/hp-timing.h 1970-01-01 02:00:00.000000000 +0200
78 +++ glibc-2.20/sysdeps/i386/i586/hp-timing.h 2014-09-08 18:07:38.466353624 +0300
79 @@ -0,0 +1,43 @@
80 +#ifndef _HP_HWCAP_TIMING_H
81 +#define _HP_HWCAP_TIMING_H 1
82 +
83 +/* We can use the i686 implementation with slight changes. */
84 +#include <sysdeps/i386/i686/hp-timing.h>
85 +
86 +/* We need the definition of HWCAP_I386_TSC. */
87 +#include <sysdeps/i386/dl-hwcapinfo.h>
88 +
89 +/* We need to perform a runtime check for the timestamp register. */
90 +#undef HP_SMALL_TIMING_AVAIL
91 +#define HP_SMALL_TIMING_AVAIL (0)
92 +
93 +/* HP_TIMING_HWCAP_AVAIL: this macro performs a run-time check for the
94 + capability. */
95 +#define HP_TIMING_HWCAP_AVAIL (_dl_hp_timing_avail())
96 +
97 +/* Perform the TSC check. */
98 +#ifdef NEED_HP_TIMING_HWCAP_AVAIL
99 +static inline
100 +unsigned int
101 +_dl_cpuid_edx (unsigned int op)
102 +{
103 + unsigned int edx;
104 + __asm__ __volatile__("push %%ebx ; cpuid ; pop %%ebx"
105 + : "=d" (edx) : "a" (op) : "ecx");
106 + return edx;
107 +}
108 +
109 +static int
110 +internal_function
111 +_dl_hp_timing_avail (void)
112 +{
113 + static int has_tsc = -1;
114 +
115 + if (__builtin_expect (has_tsc == -1, 0))
116 + has_tsc = (_dl_cpuid_edx(1) & HWCAP_I386_TSC) == HWCAP_I386_TSC;
117 +
118 + return has_tsc;
119 +}
120 +#endif
121 +
122 +#endif /* hp-timing.h */

  ViewVC Help
Powered by ViewVC 1.1.30