summaryrefslogtreecommitdiff
path: root/recipes/glibc/glibc-2.3.2/glibc-i686-timing.patch
blob: acac110944eaef89ee20d9261ebde64a7118a0d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
--- glibc-2.3.2/sysdeps/generic/ldsodefs.h.orig	2003-10-03 11:47:45.000000000 -0400
+++ glibc-2.3.2/sysdeps/generic/ldsodefs.h	2003-10-03 11:48:10.000000000 -0400
@@ -292,7 +292,7 @@ struct rtld_global
   /* The object to be initialized first.  */
   EXTERN struct link_map *_dl_initfirst;
 
-#if HP_TIMING_AVAIL || HP_SMALL_TIMING_AVAIL
+#if HP_TIMING_AVAIL || HP_SMALL_TIMING_AVAIL || HP_TIMING_PAD
   /* Start time on CPU clock.  */
   EXTERN hp_timing_t _dl_cpuclock_offset;
 
--- /dev/null	1969-12-31 19:00:00.000000000 -0500
+++ glibc-2.3.2/sysdeps/i386/hp-timing.h	2003-10-03 11:50:30.000000000 -0400
@@ -0,0 +1,34 @@
+/* High precision, low overhead timing functions.  i386 version.
+   Copyright (C) 2003 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _i386_HP_TIMING_H
+#define _i386_HP_TIMING_H	1
+
+#define hp_timing_t hp_timing_t__
+#include <sysdeps/generic/hp-timing.h>
+#undef hp_timing_t
+
+/* We don't use high-precision timers, but we might load an i686 libpthread
+   which does.  */
+#define HP_TIMING_PAD 1
+
+/* i686 uses 64bit values for the times.  */
+typedef unsigned long long int hp_timing_t;
+
+#endif	/* hp-timing.h */
--- glibc-2.3.2/elf/Makefile.orig	2003-10-12 13:15:46.000000000 -0400
+++ glibc-2.3.2/elf/Makefile	2003-10-12 13:17:38.000000000 -0400
@@ -23,7 +23,7 @@ subdir		:= elf
 headers		= elf.h bits/elfclass.h link.h
 routines	= $(dl-routines) dl-open dl-close dl-support dl-iteratephdr \
 		  dl-iteratephdr-static dl-addr enbl-secure dl-profstub \
-		  dl-origin dl-libc dl-sym dl-tsd
+		  dl-origin dl-libc dl-sym dl-tsd dl-altinit
 
 # The core dynamic linking functions are in libc for the static and
 # profiled libraries.
@@ -40,6 +40,10 @@ elide-routines.os = $(all-dl-routines) d
 rtld-routines	:= rtld $(dl-routines) dl-sysdep dl-environ dl-minimal
 all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines)
 
+# We only need to re-run initializers if ld.so and libc.so might be built
+# for different machines, so only shared libraries need dl-altinit.
+shared-only-routines = dl-altinit
+
 distribute	:= rtld-Rules \
 		   $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
 		   dl-cache.h dl-hash.h soinit.c sofini.c ldd.bash.in \
@@ -91,7 +95,7 @@ include ../Makeconfig
 
 ifeq ($(unwind-find-fde),yes)
 routines += unwind-dw2-fde-glibc
-shared-only-routines = unwind-dw2-fde-glibc
+shared-only-routines += unwind-dw2-fde-glibc
 endif
 
 before-compile  = $(objpfx)trusted-dirs.h
--- /dev/null	1969-12-31 19:00:00.000000000 -0500
+++ glibc-2.3.2/elf/dl-altinit.c	2003-10-12 13:23:15.000000000 -0400
@@ -0,0 +1,43 @@
+/* Extra initializers for shared libc.
+   Copyright (C) 2003 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <ldsodefs.h>
+#include <hp-timing.h>
+
+/* This file is used from the shared libc, to initialize anything which
+   ld.so should have initialized but didn't - for instance, if ld.so
+   is built for a machine without HP_TIMING but libc.so is built for
+   a machine with HP_TIMING, clock_gettime will expect dl_cpuclock_offset
+   to be initialized.  */
+
+static void
+dlinit_hptiming (void)
+{
+#if HP_TIMING_AVAIL || HP_SMALL_TIMING_AVAIL
+  if (GL(dl_cpuclock_offset) == 0)
+    HP_TIMING_NOW (GL(dl_cpuclock_offset));
+#endif
+}
+
+static void dlinit_alt (void) __attribute__((constructor));
+static void
+dlinit_alt (void)
+{
+  dlinit_hptiming ();
+}