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