[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

MIPS syscall.h



For whoever works on this bug.  I dragged this patch out of an internal
tree; it's against a different version of glibc, and I haven't gotten round
to submitting it to glibc yet, and it only works with the new-style unistd.h
so it might break MIPS with older kernel-headers.  But here you go anyway.

It's much more complicated than Debian needs it to be because it supports
mips64 also.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

Source: MontaVista Software, Inc.
Description:
  Handle new-style mips64 unistd.h.

--- glibc-2.3.2/sysdeps/unix/sysv/linux/mips/configure.in	2003-12-04 13:10:59.000000000 -0500
+++ glibc-2.3.2.foo/sysdeps/unix/sysv/linux/mips/configure.in	2003-12-04 13:07:40.000000000 -0500
@@ -19,49 +19,61 @@
     AC_MSG_WARN([*** asm/unistd.h not found, it will not be pre-processed])
     echo '#include <asm/unistd.h>' > asm-unistd.h
   else
-    # The point of this preprocessing is to turn __NR_<syscall> into
-    # __NR_N64_<syscall>, as well as to define __NR_<syscall> to
-    # __NR_<abi>_<syscall>, if __NR_<abi>_<syscall> is defined
-    # and <abi> is the compiler-enabled ABI.
+    # There are two versions of this header.  The older form defined
+    # __NR_foo, __NR_N32_foo, and __NR_O32_foo.  The new form defines
+    # only __NR_foo, but does it based on the current ABI.
+    # We want to have __NR_O32_foo, __NR_N64_foo, and __NR_N32_foo defined
+    # always, and __NR_foo defined conditionally.  Only the newer form is
+    # supported.
     cat "$asm_unistd_h" |
-    sed -e 's,__NR_,__NR_N64_,g' \
-        -e 's,__NR_N64_##,__NR_##,g' \
-	-e 's,__NR_N64_O32_,__NR_O32_,g' \
-	-e 's,__NR_N64_N32_,__NR_N32_,g' \
-	-e 's,__NR_N64_N64_,__NR_N64_,g' \
-    | awk > asm-unistd.h '
-/^#define __NR.*unused/ { print; next; }
-/^#define __NR_N64__exit __NR_N64_exit/ {
-	print "#define __NR__exit __NR_exit";
-	print "#define __NR_O32__exit __NR_O32_exit";
-	print "#define __NR_N32__exit __NR_N32_exit";
+    awk > asm-unistd.h '
+/^#if _MIPS_SIM == _MIPS_SIM_ABI32/,/^#endif.*_MIPS_SIM_ABI32/ {
+  if (/^#define __NR_Linux/) { print; next; }
+  if (/^#define __NR_/) {
+	line = $0;
+	gsub (/_NR_/, "_NR_O32_", line);
+	print "#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */";
+	print "";
+	print line;
+	print "";
+	print "#if _MIPS_SIM == _MIPS_SIM_ABI32";
 	print; next;
+  }
+  print; next;
 }
-/^#define __NR_O32_/ {
-	name = $2;
-	sub (/_O32_/, "_", name);
-	print;
-	print "#if _MIPS_SIM == _MIPS_SIM_ABI32";
-	print "# define " name " " $2;
-	print "#endif";
-	next;
+/^#if _MIPS_SIM == _MIPS_SIM_NABI32/,/^#endif.*_MIPS_SIM_NABI32/ {
+  if (/^#define __NR_Linux/) { print; next; }
+  if (/^#define __NR_/) {
+	line = $0;
+	gsub (/_NR_/, "_NR_N32_", line);
+	print "#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */";
+	print "";
+	print line;
+	print "";
+	print "#if _MIPS_SIM == _MIPS_SIM_NABI32";
+	print; next;
+  }
+  print; next;
 }
-/^#define __NR_N32_/ {
-	name = $2;
-	sub (/_N32_/, "_", name);
-	print;
-	print "#if defined _ABIN32 && _MIPS_SIM == _ABIN32";
-	print "# define " name " " $2;
-	print "#endif";
-	next;
+/^#if _MIPS_SIM == _MIPS_SIM_ABI64/,/^#endif.*_MIPS_SIM_ABI64/ {
+  if (/^#define __NR_Linux/) { print; next; }
+  if (/^#define __NR_/) {
+	line = $0;
+	gsub (/_NR_/, "_NR_N64_", line);
+	print "#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */";
+	print "";
+	print line;
+	print "";
+	print "#if _MIPS_SIM == _MIPS_SIM_ABI64";
+	print; next;
+  }
+  print; next;
 }
-/^#define __NR_N64_/ {
-	name = $2;
-	sub (/_N64_/, "_", name);
+/^#define __NR_64_/ {
+	line = $0;
+	gsub (/_NR_64_/, "_NR_N64_", line);
 	print;
-	print "#if defined _ABI64 && _MIPS_SIM == _ABI64";
-	print "# define " name " " $2;
-	print "#endif";
+	print line;
 	next;
 }
 {
--- glibc-2.3.2/sysdeps/unix/sysv/linux/mips/configure	2003-12-04 13:10:59.000000000 -0500
+++ glibc-2.3.2.foo/sysdeps/unix/sysv/linux/mips/configure	2003-12-04 13:09:47.000000000 -0500
@@ -19,49 +19,61 @@
 echo "$as_me: WARNING: *** asm/unistd.h not found, it will not be pre-processed" >&2;}
     echo '#include <asm/unistd.h>' > asm-unistd.h
   else
-    # The point of this preprocessing is to turn __NR_<syscall> into
-    # __NR_N64_<syscall>, as well as to define __NR_<syscall> to
-    # __NR_<abi>_<syscall>, if __NR_<abi>_<syscall> is defined
-    # and <abi> is the compiler-enabled ABI.
+    # There are two versions of this header.  The older form defined
+    # __NR_foo, __NR_N32_foo, and __NR_O32_foo.  The new form defines
+    # only __NR_foo, but does it based on the current ABI.
+    # We want to have __NR_O32_foo, __NR_N64_foo, and __NR_N32_foo defined
+    # always, and __NR_foo defined conditionally.  Only the newer form is
+    # supported.
     cat "$asm_unistd_h" |
-    sed -e 's,__NR_,__NR_N64_,g' \
-        -e 's,__NR_N64_##,__NR_##,g' \
-	-e 's,__NR_N64_O32_,__NR_O32_,g' \
-	-e 's,__NR_N64_N32_,__NR_N32_,g' \
-	-e 's,__NR_N64_N64_,__NR_N64_,g' \
-    | awk > asm-unistd.h '
-/^#define __NR.*unused/ { print; next; }
-/^#define __NR_N64__exit __NR_N64_exit/ {
-	print "#define __NR__exit __NR_exit";
-	print "#define __NR_O32__exit __NR_O32_exit";
-	print "#define __NR_N32__exit __NR_N32_exit";
+    awk > asm-unistd.h '
+/^#if _MIPS_SIM == _MIPS_SIM_ABI32/,/^#endif.*_MIPS_SIM_ABI32/ {
+  if (/^#define __NR_Linux/) { print; next; }
+  if (/^#define __NR_/) {
+	line = $0;
+	gsub (/_NR_/, "_NR_O32_", line);
+	print "#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */";
+	print "";
+	print line;
+	print "";
+	print "#if _MIPS_SIM == _MIPS_SIM_ABI32";
 	print; next;
+  }
+  print; next;
 }
-/^#define __NR_O32_/ {
-	name = $2;
-	sub (/_O32_/, "_", name);
-	print;
-	print "#if _MIPS_SIM == _MIPS_SIM_ABI32";
-	print "# define " name " " $2;
-	print "#endif";
-	next;
+/^#if _MIPS_SIM == _MIPS_SIM_NABI32/,/^#endif.*_MIPS_SIM_NABI32/ {
+  if (/^#define __NR_Linux/) { print; next; }
+  if (/^#define __NR_/) {
+	line = $0;
+	gsub (/_NR_/, "_NR_N32_", line);
+	print "#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */";
+	print "";
+	print line;
+	print "";
+	print "#if _MIPS_SIM == _MIPS_SIM_NABI32";
+	print; next;
+  }
+  print; next;
 }
-/^#define __NR_N32_/ {
-	name = $2;
-	sub (/_N32_/, "_", name);
-	print;
-	print "#if defined _ABIN32 && _MIPS_SIM == _ABIN32";
-	print "# define " name " " $2;
-	print "#endif";
-	next;
+/^#if _MIPS_SIM == _MIPS_SIM_ABI64/,/^#endif.*_MIPS_SIM_ABI64/ {
+  if (/^#define __NR_Linux/) { print; next; }
+  if (/^#define __NR_/) {
+	line = $0;
+	gsub (/_NR_/, "_NR_N64_", line);
+	print "#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */";
+	print "";
+	print line;
+	print "";
+	print "#if _MIPS_SIM == _MIPS_SIM_ABI64";
+	print; next;
+  }
+  print; next;
 }
-/^#define __NR_N64_/ {
-	name = $2;
-	sub (/_N64_/, "_", name);
+/^#define __NR_64_/ {
+	line = $0;
+	gsub (/_NR_64_/, "_NR_N64_", line);
 	print;
-	print "#if defined _ABI64 && _MIPS_SIM == _ABI64";
-	print "# define " name " " $2;
-	print "#endif";
+	print line;
 	next;
 }
 {
--- glibc-2.3.2/sysdeps/unix/sysv/linux/mips/Makefile.orig	2003-12-11 16:04:24.000000000 -0500
+++ glibc-2.3.2/sysdeps/unix/sysv/linux/mips/Makefile	2003-12-11 16:18:55.000000000 -0500
@@ -12,7 +12,7 @@
 # Generate the list of SYS_* macros for the system calls (__NR_* macros).
 # We generate not only SYS_<syscall>, pointing at SYS_<abi>_<syscall> if
 # it exists, but also define SYS_<abi>_<syscall> for all ABIs.
-$(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/mips/sys/syscall.h
+$(objpfx)syscall-list.h $(objpfx)syscall-list.d: $(common-objpfx)asm-unistd.h
 	$(make-target-directory)
 	{ \
 	 echo '/* Generated at libc build time from kernel syscall list.  */';\
@@ -21,31 +21,9 @@
 	 echo '# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."'; \
 	 echo '#endif'; \
 	 echo ''; \
-	 rm -f $(@:.d=.h).newt; \
-	 $(CC) -E -MD -MP -MF $(@:.h=.d)-t -MT '$(@:.d=.h) $(@:.h=.d)' \
-	       -x c -I $(common-objdir) $(sysincludes) $< -D_LIBC -dM | \
-	 sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' \
-	     > $(@:.d=.h).newt; \
-	 if grep SYS_O32_ $(@:.d=.h).newt > /dev/null; then \
-	   echo '#if defined _ABI64 && _MIPS_SIM == _ABI64'; \
-	   sed -n 's/^\(#define SYS_\)N64_/\1/p' < $(@:.d=.h).newt; \
-	   echo '#elif defined _ABIN32 && _MIPS_SIM == _ABIN32'; \
-	   sed -n 's/^\(#define SYS_\)N32_/\1/p' < $(@:.d=.h).newt; \
-	   echo '#else'; \
-	   sed -n 's/^\(#define SYS_\)O32_/\1/p' < $(@:.d=.h).newt; \
-	   echo '#endif'; \
-	   sed -n '/^#define SYS_\([ON]32\|N64\)_/p' < $(@:.d=.h).newt; \
-	 else \
-	   cat $(@:.d=.h).newt; \
-	 fi; \
-	 rm $(@:.d=.h).newt; \
+	 grep -E '^#.*(MIPS_SIM|__NR)' $(common-objpfx)asm-unistd.h \
+	  | sed 's/__NR_/SYS_/g' ; \
 	} > $(@:.d=.h).new
 	mv -f $(@:.d=.h).new $(@:.d=.h)
-ifneq (,$(objpfx))
-	sed $(sed-remove-objpfx) $(@:.h=.d)-t > $(@:.h=.d)-t2
-	rm -f $(@:.h=.d)-t
-	mv -f $(@:.h=.d)-t2 $(@:.h=.d)
-else
-	mv -f $(@:.h=.d)-t $(@:.h=.d)
-endif
+	echo > $(@:.h=.d)
 endif



Reply to: