source: scripts/patches/glibc-2.3.4-mips_syscall-2.patch@ 7702d6f

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 7702d6f was 7f65c0e, checked in by Jim Gifford <clfs@…>, 19 years ago

r625@server (orig r623): jim | 2005-10-31 12:43:24 -0800
Final Move

  • Property mode set to 100644
File size: 10.8 KB
RevLine 
[617118d]1Submitted By: Jim Gifford (patches at jg555 dot com)
2Date: 2005-02-23
3Initial Package Version: 2.3.4
4Origin: Richard Sandiford
5Upstream Status: Unknown
6Description: Fixes Syscall.h generation
7
8diff -Naur glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/Makefile glibc-2.3.4/sysdeps/unix/sysv/linux/mips/Makefile
9--- glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/Makefile 2004-11-24 04:38:15 +0000
10+++ glibc-2.3.4/sysdeps/unix/sysv/linux/mips/Makefile 2005-02-23 18:21:54 +0000
11@@ -9,11 +9,73 @@
12
13 no_syscall_list_h = 1
14
15-# Generate the list of SYS_* macros for the system calls (__NR_* macros).
16-# We generate not only SYS_<syscall>, pointing at SYS_<abi>_<syscall> if
17-# it exists, but also define SYS_<abi>_<syscall> for all ABIs.
18+# A callable macro that expands to a shell command. Preprocess file $(1)
19+# using ABI option $(2) and see which macros it defines. Print FOO for each
20+# macro of the form __NR$(3)_FOO, filtering out ABI-specific __NR macros
21+# that have a prefix other than $(3).
22+mips_list_syscalls = $(filter-out -m%,$(CC)) -E -x c $(+includes) \
23+ $(sysincludes) -D_LIBC -dM -mabi=$(2) $(1) | \
24+ sed -n 's@^\#define __NR$(3)_\([^ ]*\) .*@\1@p' | \
25+ sed -e '/^[ON]32_/d' -e '/^N64_/d' -e '/^64_/d' | \
26+ LC_ALL=C sort
27+
28+# Generate a list of SYS_* macros from the linux __NR macros.
29+#
30+# Before version 2.6, linux had separate 32-bit and 64-bit MIPS ports,
31+# each with its own set of headers. The ports were merged for 2.6 and
32+# this merged port defines the syscalls in a slightly different way.
33+# There are therefore three sets of headers that we need to consider:
34+#
35+# (1) Headers from the separate 32-bit MIPS port. They just define
36+# a single list of __NR macros.
37+#
38+# (2) Headers from the separate 64-bit MIPS port. They unconditionally
39+# define syscalls for all three ABIs, with o32 syscalls prefixed
40+# by __NR_O32, n32 syscalls prefixed by __NR_N32 and n64 syscalls
41+# prefixed by plain __NR.
42+#
43+# (3) Headers from the combined port. They use the _MIPS_SIM macro to
44+# define the right set of syscalls for the current ABI. The syscalls
45+# themselves have no special ABI prefix, but the headers also define:
46+#
47+# __NR_O32_Linux{,_syscalls}
48+# __NR_N32_Linux{,_syscalls}
49+# __NR_64_Linux{,_syscalls}
50+#
51+# In case (1) we just want a simple list of SYS_* macros. In cases (2)
52+# and (3) we want a file that will work for all three ABIs, regardless
53+# of which ABI we are currently using. We also want the file to work
54+# if the user later moves from (2) to (3). Thus the file we create
55+# for (2) and (3) has the form:
56+#
57+# #if _MIPS_SIM == _MIPS_SIM_NABI32
58+# # ifdef __NR_N32_open
59+# # define SYS_n32syscall1 __NR_N32_n32syscall1
60+# # ...
61+# # else
62+# # define SYS_n32syscall1 __NR_n32syscall1
63+# # ...
64+# # endif
65+# #elif _MIPS_SIM == _MIPS_SIM_ABI64
66+# # define SYS_n64syscall1 __NR_n64syscall1
67+# # ...
68+# #else
69+# # ifdef __NR_O32_open
70+# # define SYS_o32syscall1 __NR_O32_o32syscall1
71+# # ...
72+# # else
73+# # define SYS_o32syscall1 __NR_o32syscall1
74+# # ...
75+# # endif
76+# #endif
77+#
78+# Here, __NR_N32_open and __NR_O32_open are used to detect case (2)
79+# over case (3). The n64 SYS_* macros can always use the normal
80+# ABI-less names.
81 $(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/mips/sys/syscall.h
82 $(make-target-directory)
83+ $(CC) -E -x c $(+includes) $(sysincludes) -D_LIBC $< -MD -MP \
84+ -MF $(@:.h=.d)-t -MT '$(@:.d=.h) $(@:.h=.d)' > /dev/null
85 { \
86 echo '/* Generated at libc build time from kernel syscall list. */';\
87 echo ''; \
88@@ -22,28 +84,38 @@
89 echo '#endif'; \
90 echo ''; \
91 echo '#include <sgidefs.h>'; \
92- rm -f $(@:.d=.h).newt; \
93- $(CC) -E -MD -MP -MF $(@:.h=.d)-t -MT '$(@:.d=.h) $(@:.h=.d)' \
94- -x c $(+includes) $(sysincludes) $< -D_LIBC -dM | \
95- sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' \
96- > $(@:.d=.h).newt; \
97- if grep SYS_O32_ $(@:.d=.h).newt > /dev/null; then \
98+ rm -f $(@:.d=.h).new32 $(@:.d=.h).newn32 $(@:.d=.h).new64; \
99+ $(call mips_list_syscalls,$<,n32,_N32) > $(@:.d=.h).newn32; \
100+ if test -s $(@:.d=.h).newn32; then \
101+ if grep open $(@:.d=.h).newn32 > /dev/null; then \
102+ $(call mips_list_syscalls,$<,32,_O32) > $(@:.d=.h).new32; \
103+ $(call mips_list_syscalls,$<,64,) > $(@:.d=.h).new64; \
104+ else \
105+ $(call mips_list_syscalls,$<,32,) > $(@:.d=.h).new32; \
106+ $(call mips_list_syscalls,$<,n32,) > $(@:.d=.h).newn32; \
107+ $(call mips_list_syscalls,$<,64,) > $(@:.d=.h).new64; \
108+ fi; \
109 echo '#if _MIPS_SIM == _ABIN32'; \
110- sed -n 's/^\(#define SYS_\)N32_/\1/p' < $(@:.d=.h).newt | \
111- LC_ALL=C sort; \
112+ echo '# ifdef __NR_N32_open'; \
113+ sed 's@\(.*\)@# define SYS_\1 __NR_N32_\1@' < $(@:.d=.h).newn32; \
114+ echo '# else'; \
115+ sed 's@\(.*\)@# define SYS_\1 __NR_\1@' < $(@:.d=.h).newn32; \
116+ echo '# endif'; \
117 echo '#elif _MIPS_SIM == _ABI64'; \
118- sed -n 's/^\(#define SYS_\)N64_/\1/p' < $(@:.d=.h).newt | \
119- LC_ALL=C sort; \
120+ sed 's@\(.*\)@# define SYS_\1 __NR_\1@' < $(@:.d=.h).new64; \
121 echo '#else'; \
122- sed -n 's/^\(#define SYS_\)O32_/\1/p' < $(@:.d=.h).newt | \
123- LC_ALL=C sort; \
124+ echo '# ifdef __NR_O32_open'; \
125+ sed 's@\(.*\)@# define SYS_\1 __NR_O32_\1@' < $(@:.d=.h).new32; \
126+ echo '# else'; \
127+ sed 's@\(.*\)@# define SYS_\1 __NR_\1@' < $(@:.d=.h).new32; \
128+ echo '# endif'; \
129 echo '#endif'; \
130- sed -n '/^#define SYS_\([ON]32\|N64\)_/p' < $(@:.d=.h).newt | \
131- LC_ALL=C sort +1.8; \
132 else \
133- cat $(@:.d=.h).newt; \
134+ $(CC) -E -x c $(+includes) $(sysincludes) -D_LIBC -dM $< | \
135+ sed -n 's@^\#define __NR_\([^ ]*\) .*@\#define SYS_\1 __NR_\1@p' | \
136+ LC_ALL=C sort; \
137 fi; \
138- rm $(@:.d=.h).newt; \
139+ rm -f $(@:.d=.h).new32 $(@:.d=.h).newn32 $(@:.d=.h).new64; \
140 } > $(@:.d=.h).new
141 mv -f $(@:.d=.h).new $(@:.d=.h)
142 ifneq (,$(objpfx))
143diff -Naur glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/configure glibc-2.3.4/sysdeps/unix/sysv/linux/mips/configure
144--- glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/configure 2004-11-24 04:42:45 +0000
145+++ glibc-2.3.4/sysdeps/unix/sysv/linux/mips/configure 2005-02-23 18:10:11 +0000
146@@ -18,7 +18,7 @@
147 { echo "$as_me:$LINENO: WARNING: *** asm/unistd.h not found, it will not be pre-processed" >&5
148 echo "$as_me: WARNING: *** asm/unistd.h not found, it will not be pre-processed" >&2;}
149 echo '#include <asm/unistd.h>' > asm-unistd.h
150- else
151+ elif grep __NR_N32_open "$asm_unistd_h" > /dev/null; then
152 # The point of this preprocessing is to turn __NR_<syscall> into
153 # __NR_N64_<syscall>, as well as to define __NR_<syscall> to
154 # __NR_<abi>_<syscall>, if __NR_<abi>_<syscall> is defined
155@@ -68,6 +68,8 @@
156 {
157 print;
158 }'
159+ else
160+ echo '#include <asm/unistd.h>' > asm-unistd.h
161 fi ;;
162 mips*)
163 rm -f asm-unistd.h
164diff -Naur glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/configure.in glibc-2.3.4/sysdeps/unix/sysv/linux/mips/configure.in
165--- glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/configure.in 2004-11-24 04:38:31 +0000
166+++ glibc-2.3.4/sysdeps/unix/sysv/linux/mips/configure.in 2005-02-23 18:10:11 +0000
167@@ -18,7 +18,7 @@
168 if test ! -f "$asm_unistd_h"; then
169 AC_MSG_WARN([*** asm/unistd.h not found, it will not be pre-processed])
170 echo '#include <asm/unistd.h>' > asm-unistd.h
171- else
172+ elif grep __NR_N32_open "$asm_unistd_h" > /dev/null; then
173 # The point of this preprocessing is to turn __NR_<syscall> into
174 # __NR_N64_<syscall>, as well as to define __NR_<syscall> to
175 # __NR_<abi>_<syscall>, if __NR_<abi>_<syscall> is defined
176@@ -68,6 +68,8 @@
177 {
178 print;
179 }'
180+ else
181+ echo '#include <asm/unistd.h>' > asm-unistd.h
182 fi ;;
183 mips*)
184 rm -f asm-unistd.h
185diff -Naur glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/mips32/kern64/sysdep.h glibc-2.3.4/sysdeps/unix/sysv/linux/mips/mips32/kern64/sysdep.h
186--- glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/mips32/kern64/sysdep.h 2003-03-29 08:15:29 +0000
187+++ glibc-2.3.4/sysdeps/unix/sysv/linux/mips/mips32/kern64/sysdep.h 2005-02-23 18:10:11 +0000
188@@ -1,36 +0,0 @@
189-/* Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
190- This file is part of the GNU C Library.
191-
192- The GNU C Library is free software; you can redistribute it and/or
193- modify it under the terms of the GNU Lesser General Public
194- License as published by the Free Software Foundation; either
195- version 2.1 of the License, or (at your option) any later version.
196-
197- The GNU C Library is distributed in the hope that it will be useful,
198- but WITHOUT ANY WARRANTY; without even the implied warranty of
199- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
200- Lesser General Public License for more details.
201-
202- You should have received a copy of the GNU Lesser General Public
203- License along with the GNU C Library; if not, write to the Free
204- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
205- 02111-1307 USA. */
206-
207-#ifndef _LINUX_MIPS_MIPS32_KERN64_SYSDEP_H
208-#define _LINUX_MIPS_MIPS32_KERN64_SYSDEP_H 1
209-
210-/* There is some commonality. */
211-#include <sysdeps/unix/sysv/linux/mips/mips32/sysdep.h>
212-
213-/* For Linux we can use the system call table in the header file
214- /usr/include/asm/unistd.h
215- of the kernel. But these symbols do not follow the SYS_* syntax
216- so we have to redefine the `SYS_ify' macro here. */
217-#undef SYS_ify
218-#ifdef __STDC__
219-# define SYS_ify(syscall_name) __NR_O32_##syscall_name
220-#else
221-# define SYS_ify(syscall_name) __NR_O32_/**/syscall_name
222-#endif
223-
224-#endif /* linux/mips/mips32/kern64/sysdep.h */
225diff -Naur glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h glibc-2.3.4/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
226--- glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h 2004-10-18 05:16:07 +0000
227+++ glibc-2.3.4/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h 2005-02-23 18:10:11 +0000
228@@ -28,9 +28,9 @@
229 so we have to redefine the `SYS_ify' macro here. */
230 #undef SYS_ify
231 #ifdef __STDC__
232-# define SYS_ify(syscall_name) __NR_N32_##syscall_name
233+# define SYS_ify(syscall_name) __NR_##syscall_name
234 #else
235-# define SYS_ify(syscall_name) __NR_N32_/**/syscall_name
236+# define SYS_ify(syscall_name) __NR_/**/syscall_name
237 #endif
238
239 #ifdef __ASSEMBLER__
240diff -Naur glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h glibc-2.3.4/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
241--- glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h 2004-10-18 05:16:08 +0000
242+++ glibc-2.3.4/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h 2005-02-23 18:10:11 +0000
243@@ -28,9 +28,9 @@
244 so we have to redefine the `SYS_ify' macro here. */
245 #undef SYS_ify
246 #ifdef __STDC__
247-# define SYS_ify(syscall_name) __NR_N64_##syscall_name
248+# define SYS_ify(syscall_name) __NR_##syscall_name
249 #else
250-# define SYS_ify(syscall_name) __NR_N64_/**/syscall_name
251+# define SYS_ify(syscall_name) __NR_/**/syscall_name
252 #endif
253
254 #ifdef __ASSEMBLER__
Note: See TracBrowser for help on using the repository browser.