yann@1: See http://sources.redhat.com/bugzilla/show_bug.cgi?id=758 yann@1: yann@1: Submitted By: Jim Gifford (patches at jg555 dot com) yann@1: Date: 2005-02-23 yann@1: Initial Package Version: 2.3.4 yann@1: Origin: Richard Sandiford yann@1: Upstream Status: Unknown yann@1: Description: Fixes Syscall.h generation yann@1: yann@1: diff -Naur glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/Makefile glibc-2.3.4/sysdeps/unix/sysv/linux/mips/Makefile yann@1: --- glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/Makefile 2004-11-24 04:38:15 +0000 yann@1: +++ glibc-2.3.4/sysdeps/unix/sysv/linux/mips/Makefile 2005-02-23 18:21:54 +0000 yann@1: @@ -9,11 +9,73 @@ yann@1: yann@1: no_syscall_list_h = 1 yann@1: yann@1: -# Generate the list of SYS_* macros for the system calls (__NR_* macros). yann@1: -# We generate not only SYS_, pointing at SYS__ if yann@1: -# it exists, but also define SYS__ for all ABIs. yann@1: +# A callable macro that expands to a shell command. Preprocess file $(1) yann@1: +# using ABI option $(2) and see which macros it defines. Print FOO for each yann@1: +# macro of the form __NR$(3)_FOO, filtering out ABI-specific __NR macros yann@1: +# that have a prefix other than $(3). yann@1: +mips_list_syscalls = $(filter-out -m%,$(CC)) -E -x c $(+includes) \ yann@1: + $(sysincludes) -D_LIBC -dM -mabi=$(2) $(1) | \ yann@1: + sed -n 's@^\#define __NR$(3)_\([^ ]*\) .*@\1@p' | \ yann@1: + sed -e '/^[ON]32_/d' -e '/^N64_/d' -e '/^64_/d' | \ yann@1: + LC_ALL=C sort yann@1: + yann@1: +# Generate a list of SYS_* macros from the linux __NR macros. yann@1: +# yann@1: +# Before version 2.6, linux had separate 32-bit and 64-bit MIPS ports, yann@1: +# each with its own set of headers. The ports were merged for 2.6 and yann@1: +# this merged port defines the syscalls in a slightly different way. yann@1: +# There are therefore three sets of headers that we need to consider: yann@1: +# yann@1: +# (1) Headers from the separate 32-bit MIPS port. They just define yann@1: +# a single list of __NR macros. yann@1: +# yann@1: +# (2) Headers from the separate 64-bit MIPS port. They unconditionally yann@1: +# define syscalls for all three ABIs, with o32 syscalls prefixed yann@1: +# by __NR_O32, n32 syscalls prefixed by __NR_N32 and n64 syscalls yann@1: +# prefixed by plain __NR. yann@1: +# yann@1: +# (3) Headers from the combined port. They use the _MIPS_SIM macro to yann@1: +# define the right set of syscalls for the current ABI. The syscalls yann@1: +# themselves have no special ABI prefix, but the headers also define: yann@1: +# yann@1: +# __NR_O32_Linux{,_syscalls} yann@1: +# __NR_N32_Linux{,_syscalls} yann@1: +# __NR_64_Linux{,_syscalls} yann@1: +# yann@1: +# In case (1) we just want a simple list of SYS_* macros. In cases (2) yann@1: +# and (3) we want a file that will work for all three ABIs, regardless yann@1: +# of which ABI we are currently using. We also want the file to work yann@1: +# if the user later moves from (2) to (3). Thus the file we create yann@1: +# for (2) and (3) has the form: yann@1: +# yann@1: +# #if _MIPS_SIM == _MIPS_SIM_NABI32 yann@1: +# # ifdef __NR_N32_open yann@1: +# # define SYS_n32syscall1 __NR_N32_n32syscall1 yann@1: +# # ... yann@1: +# # else yann@1: +# # define SYS_n32syscall1 __NR_n32syscall1 yann@1: +# # ... yann@1: +# # endif yann@1: +# #elif _MIPS_SIM == _MIPS_SIM_ABI64 yann@1: +# # define SYS_n64syscall1 __NR_n64syscall1 yann@1: +# # ... yann@1: +# #else yann@1: +# # ifdef __NR_O32_open yann@1: +# # define SYS_o32syscall1 __NR_O32_o32syscall1 yann@1: +# # ... yann@1: +# # else yann@1: +# # define SYS_o32syscall1 __NR_o32syscall1 yann@1: +# # ... yann@1: +# # endif yann@1: +# #endif yann@1: +# yann@1: +# Here, __NR_N32_open and __NR_O32_open are used to detect case (2) yann@1: +# over case (3). The n64 SYS_* macros can always use the normal yann@1: +# ABI-less names. yann@1: $(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/mips/sys/syscall.h yann@1: $(make-target-directory) yann@1: + $(CC) -E -x c $(+includes) $(sysincludes) -D_LIBC $< -MD -MP \ yann@1: + -MF $(@:.h=.d)-t -MT '$(@:.d=.h) $(@:.h=.d)' > /dev/null yann@1: { \ yann@1: echo '/* Generated at libc build time from kernel syscall list. */';\ yann@1: echo ''; \ yann@1: @@ -22,28 +84,38 @@ yann@1: echo '#endif'; \ yann@1: echo ''; \ yann@1: echo '#include '; \ yann@1: - rm -f $(@:.d=.h).newt; \ yann@1: - $(CC) -E -MD -MP -MF $(@:.h=.d)-t -MT '$(@:.d=.h) $(@:.h=.d)' \ yann@1: - -x c $(+includes) $(sysincludes) $< -D_LIBC -dM | \ yann@1: - sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' \ yann@1: - > $(@:.d=.h).newt; \ yann@1: - if grep SYS_O32_ $(@:.d=.h).newt > /dev/null; then \ yann@1: + rm -f $(@:.d=.h).new32 $(@:.d=.h).newn32 $(@:.d=.h).new64; \ yann@1: + $(call mips_list_syscalls,$<,n32,_N32) > $(@:.d=.h).newn32; \ yann@1: + if test -s $(@:.d=.h).newn32; then \ yann@1: + if grep open $(@:.d=.h).newn32 > /dev/null; then \ yann@1: + $(call mips_list_syscalls,$<,32,_O32) > $(@:.d=.h).new32; \ yann@1: + $(call mips_list_syscalls,$<,64,) > $(@:.d=.h).new64; \ yann@1: + else \ yann@1: + $(call mips_list_syscalls,$<,32,) > $(@:.d=.h).new32; \ yann@1: + $(call mips_list_syscalls,$<,n32,) > $(@:.d=.h).newn32; \ yann@1: + $(call mips_list_syscalls,$<,64,) > $(@:.d=.h).new64; \ yann@1: + fi; \ yann@1: echo '#if _MIPS_SIM == _ABIN32'; \ yann@1: - sed -n 's/^\(#define SYS_\)N32_/\1/p' < $(@:.d=.h).newt | \ yann@1: - LC_ALL=C sort; \ yann@1: + echo '# ifdef __NR_N32_open'; \ yann@1: + sed 's@\(.*\)@# define SYS_\1 __NR_N32_\1@' < $(@:.d=.h).newn32; \ yann@1: + echo '# else'; \ yann@1: + sed 's@\(.*\)@# define SYS_\1 __NR_\1@' < $(@:.d=.h).newn32; \ yann@1: + echo '# endif'; \ yann@1: echo '#elif _MIPS_SIM == _ABI64'; \ yann@1: - sed -n 's/^\(#define SYS_\)N64_/\1/p' < $(@:.d=.h).newt | \ yann@1: - LC_ALL=C sort; \ yann@1: + sed 's@\(.*\)@# define SYS_\1 __NR_\1@' < $(@:.d=.h).new64; \ yann@1: echo '#else'; \ yann@1: - sed -n 's/^\(#define SYS_\)O32_/\1/p' < $(@:.d=.h).newt | \ yann@1: - LC_ALL=C sort; \ yann@1: + echo '# ifdef __NR_O32_open'; \ yann@1: + sed 's@\(.*\)@# define SYS_\1 __NR_O32_\1@' < $(@:.d=.h).new32; \ yann@1: + echo '# else'; \ yann@1: + sed 's@\(.*\)@# define SYS_\1 __NR_\1@' < $(@:.d=.h).new32; \ yann@1: + echo '# endif'; \ yann@1: echo '#endif'; \ yann@1: - sed -n '/^#define SYS_\([ON]32\|N64\)_/p' < $(@:.d=.h).newt | \ yann@1: - LC_ALL=C sort +1.8; \ yann@1: else \ yann@1: - cat $(@:.d=.h).newt; \ yann@1: + $(CC) -E -x c $(+includes) $(sysincludes) -D_LIBC -dM $< | \ yann@1: + sed -n 's@^\#define __NR_\([^ ]*\) .*@\#define SYS_\1 __NR_\1@p' | \ yann@1: + LC_ALL=C sort; \ yann@1: fi; \ yann@1: - rm $(@:.d=.h).newt; \ yann@1: + rm -f $(@:.d=.h).new32 $(@:.d=.h).newn32 $(@:.d=.h).new64; \ yann@1: } > $(@:.d=.h).new yann@1: mv -f $(@:.d=.h).new $(@:.d=.h) yann@1: ifneq (,$(objpfx)) yann@1: diff -Naur glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/configure glibc-2.3.4/sysdeps/unix/sysv/linux/mips/configure yann@1: --- glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/configure 2004-11-24 04:42:45 +0000 yann@1: +++ glibc-2.3.4/sysdeps/unix/sysv/linux/mips/configure 2005-02-23 18:10:11 +0000 yann@1: @@ -18,7 +18,7 @@ yann@1: { echo "$as_me:$LINENO: WARNING: *** asm/unistd.h not found, it will not be pre-processed" >&5 yann@1: echo "$as_me: WARNING: *** asm/unistd.h not found, it will not be pre-processed" >&2;} yann@1: echo '#include ' > asm-unistd.h yann@1: - else yann@1: + elif grep __NR_N32_open "$asm_unistd_h" > /dev/null; then yann@1: # The point of this preprocessing is to turn __NR_ into yann@1: # __NR_N64_, as well as to define __NR_ to yann@1: # __NR__, if __NR__ is defined yann@1: @@ -68,6 +68,8 @@ yann@1: { yann@1: print; yann@1: }' yann@1: + else yann@1: + echo '#include ' > asm-unistd.h yann@1: fi ;; yann@1: mips*) yann@1: rm -f asm-unistd.h yann@1: diff -Naur glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/configure.in glibc-2.3.4/sysdeps/unix/sysv/linux/mips/configure.in yann@1: --- glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/configure.in 2004-11-24 04:38:31 +0000 yann@1: +++ glibc-2.3.4/sysdeps/unix/sysv/linux/mips/configure.in 2005-02-23 18:10:11 +0000 yann@1: @@ -18,7 +18,7 @@ yann@1: if test ! -f "$asm_unistd_h"; then yann@1: AC_MSG_WARN([*** asm/unistd.h not found, it will not be pre-processed]) yann@1: echo '#include ' > asm-unistd.h yann@1: - else yann@1: + elif grep __NR_N32_open "$asm_unistd_h" > /dev/null; then yann@1: # The point of this preprocessing is to turn __NR_ into yann@1: # __NR_N64_, as well as to define __NR_ to yann@1: # __NR__, if __NR__ is defined yann@1: @@ -68,6 +68,8 @@ yann@1: { yann@1: print; yann@1: }' yann@1: + else yann@1: + echo '#include ' > asm-unistd.h yann@1: fi ;; yann@1: mips*) yann@1: rm -f asm-unistd.h yann@1: diff -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 yann@1: --- glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/mips32/kern64/sysdep.h 2003-03-29 08:15:29 +0000 yann@1: +++ glibc-2.3.4/sysdeps/unix/sysv/linux/mips/mips32/kern64/sysdep.h 2005-02-23 18:10:11 +0000 yann@1: @@ -1,36 +0,0 @@ yann@1: -/* Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc. yann@1: - This file is part of the GNU C Library. yann@1: - yann@1: - The GNU C Library is free software; you can redistribute it and/or yann@1: - modify it under the terms of the GNU Lesser General Public yann@1: - License as published by the Free Software Foundation; either yann@1: - version 2.1 of the License, or (at your option) any later version. yann@1: - yann@1: - The GNU C Library is distributed in the hope that it will be useful, yann@1: - but WITHOUT ANY WARRANTY; without even the implied warranty of yann@1: - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yann@1: - Lesser General Public License for more details. yann@1: - yann@1: - You should have received a copy of the GNU Lesser General Public yann@1: - License along with the GNU C Library; if not, write to the Free yann@1: - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA yann@1: - 02111-1307 USA. */ yann@1: - yann@1: -#ifndef _LINUX_MIPS_MIPS32_KERN64_SYSDEP_H yann@1: -#define _LINUX_MIPS_MIPS32_KERN64_SYSDEP_H 1 yann@1: - yann@1: -/* There is some commonality. */ yann@1: -#include yann@1: - yann@1: -/* For Linux we can use the system call table in the header file yann@1: - /usr/include/asm/unistd.h yann@1: - of the kernel. But these symbols do not follow the SYS_* syntax yann@1: - so we have to redefine the `SYS_ify' macro here. */ yann@1: -#undef SYS_ify yann@1: -#ifdef __STDC__ yann@1: -# define SYS_ify(syscall_name) __NR_O32_##syscall_name yann@1: -#else yann@1: -# define SYS_ify(syscall_name) __NR_O32_/**/syscall_name yann@1: -#endif yann@1: - yann@1: -#endif /* linux/mips/mips32/kern64/sysdep.h */ yann@1: diff -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 yann@1: --- glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h 2004-10-18 05:16:07 +0000 yann@1: +++ glibc-2.3.4/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h 2005-02-23 18:10:11 +0000 yann@1: @@ -28,9 +28,9 @@ yann@1: so we have to redefine the `SYS_ify' macro here. */ yann@1: #undef SYS_ify yann@1: #ifdef __STDC__ yann@1: -# define SYS_ify(syscall_name) __NR_N32_##syscall_name yann@1: +# define SYS_ify(syscall_name) __NR_##syscall_name yann@1: #else yann@1: -# define SYS_ify(syscall_name) __NR_N32_/**/syscall_name yann@1: +# define SYS_ify(syscall_name) __NR_/**/syscall_name yann@1: #endif yann@1: yann@1: #ifdef __ASSEMBLER__ yann@1: diff -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 yann@1: --- glibc-2.3.4.orig/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h 2004-10-18 05:16:08 +0000 yann@1: +++ glibc-2.3.4/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h 2005-02-23 18:10:11 +0000 yann@1: @@ -28,9 +28,9 @@ yann@1: so we have to redefine the `SYS_ify' macro here. */ yann@1: #undef SYS_ify yann@1: #ifdef __STDC__ yann@1: -# define SYS_ify(syscall_name) __NR_N64_##syscall_name yann@1: +# define SYS_ify(syscall_name) __NR_##syscall_name yann@1: #else yann@1: -# define SYS_ify(syscall_name) __NR_N64_/**/syscall_name yann@1: +# define SYS_ify(syscall_name) __NR_/**/syscall_name yann@1: #endif yann@1: yann@1: #ifdef __ASSEMBLER__