about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/unix/sysv/linux/mips/Makefile39
-rw-r--r--sysdeps/unix/sysv/linux/mips/clone.S1
-rwxr-xr-xsysdeps/unix/sysv/linux/mips/configure0
-rw-r--r--sysdeps/unix/sysv/linux/mips/configure.in75
-rw-r--r--sysdeps/unix/sysv/linux/mips/sys/syscall.h42
5 files changed, 156 insertions, 1 deletions
diff --git a/sysdeps/unix/sysv/linux/mips/Makefile b/sysdeps/unix/sysv/linux/mips/Makefile
index 1f9fc2dd03..799f5ae0d5 100644
--- a/sysdeps/unix/sysv/linux/mips/Makefile
+++ b/sysdeps/unix/sysv/linux/mips/Makefile
@@ -8,4 +8,43 @@ ifeq ($(subdir),misc)
 sysdep_routines += cachectl cacheflush sysmips _test_and_set
 
 sysdep_headers += sys/cachectl.h sys/sysmips.h sys/tas.h
+
+no_syscall_list_h = 1
+
+# 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
+	rm -f $(@:.h=.d)-t
+	{ \
+	 echo '/* Generated at libc build time from kernel syscall list.  */';\
+	 echo ''; \
+	 echo '#ifndef _SYSCALL_H'; \
+	 echo '# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."'; \
+	 echo '#endif'; \
+	 echo ''; \
+	 rm -f $(@:.d=.h).newt; \
+	 SUNPRO_DEPENDENCIES='$(@:.h=.d)-t $@' \
+	 $(CC) -E -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; \
+	} > $(@:.d=.h).new
+	mv -f $(@:.d=.h).new $(@:.d=.h)
+	sed < $(@:.h=.d)-t > $(@:.h=.d)-t2 \
+	    -e 's,$(subst .,\.,$@),$(patsubst $(objpfx)%,$$(objpfx)%,\
+					      $(@:.d=.h) $(@:.h=.d)),'
+	rm -f $(@:.h=.d)-t
+	mv -f $(@:.h=.d)-t2 $(@:.h=.d)
 endif
diff --git a/sysdeps/unix/sysv/linux/mips/clone.S b/sysdeps/unix/sysv/linux/mips/clone.S
index 7af2a1652a..e00351d117 100644
--- a/sysdeps/unix/sysv/linux/mips/clone.S
+++ b/sysdeps/unix/sysv/linux/mips/clone.S
@@ -21,7 +21,6 @@
    and invokes a function in the right context after its all over.  */
 
 #include <sys/asm.h>
-#include <asm/unistd.h>
 #include <sysdep.h>
 #define _ERRNO_H	1
 #include <bits/errno.h>
diff --git a/sysdeps/unix/sysv/linux/mips/configure b/sysdeps/unix/sysv/linux/mips/configure
new file mode 100755
index 0000000000..e69de29bb2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/configure
diff --git a/sysdeps/unix/sysv/linux/mips/configure.in b/sysdeps/unix/sysv/linux/mips/configure.in
new file mode 100644
index 0000000000..3df0c91b30
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/configure.in
@@ -0,0 +1,75 @@
+sinclude(./aclocal.m4)dnl Autoconf lossage
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/sysv/linux/mips.
+
+case $machine in
+mips*64*)
+  rm -f asm-unistd.h
+  asm_unistd_h=$sysheaders/asm/unistd.h
+  if test ! -f $asm_unistd_h; then
+    # Try to find asm/unistd.h in compiler header search path.
+    try_asm_unistd_h=`echo '#include <asm/unistd.h>' | $CPP - |
+			sed -n '/^# 1 "\(\/[^"]*\)".*/{s,,\1,p;q;}'`
+    if test -n "$try_asm_unistd_h" &&
+       test -f "$try_asm_unistd_h"; then
+      asm_unistd_h=$try_asm_unistd_h
+    fi
+  fi
+  if test ! -f "$asm_unistd_h"; then
+    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.
+    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";
+	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;
+}
+/^#define __NR_N32_/ {
+	name = $2;
+	sub (/_N32_/, "_", name);
+	print;
+	print "#if defined _ABIN32 && _MIPS_SIM == _ABIN32";
+	print "# define " name " " $2;
+	print "#endif";
+	next;
+}
+/^#define __NR_N64_/ {
+	name = $2;
+	sub (/_N64_/, "_", name);
+	print;
+	print "#if defined _ABI64 && _MIPS_SIM == _ABI64";
+	print "# define " name " " $2;
+	print "#endif";
+	next;
+}
+{
+	print;
+}'
+  fi ;;
+mips*)
+  rm -f asm-unistd.h
+  echo '#include <asm/unistd.h>' > asm-unistd.h
+  ;;
+esac
diff --git a/sysdeps/unix/sysv/linux/mips/sys/syscall.h b/sysdeps/unix/sysv/linux/mips/sys/syscall.h
new file mode 100644
index 0000000000..f6458cd316
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/sys/syscall.h
@@ -0,0 +1,42 @@
+/* Copyright (C) 1995, 1996, 1997, 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 _SYSCALL_H
+#define _SYSCALL_H	1
+
+/* This file should list the numbers of the system the system knows.
+   But instead of duplicating this we use the information available
+   from the kernel sources.  */
+#ifdef _LIBC
+/* Since the kernel doesn't define macro names in a way usable for
+   glibc, we preprocess this header, and use it during the glibc build
+   process.  */
+# include <asm-unistd.h>
+#else
+# include <asm/unistd.h>
+#endif
+
+#ifndef _LIBC
+/* The Linux kernel header file defines macros `__NR_<name>', but some
+   programs expect the traditional form `SYS_<name>'.  So in building libc
+   we scan the kernel's list and produce <bits/syscall.h> with macros for
+   all the `SYS_' names.  */
+# include <bits/syscall.h>
+#endif
+
+#endif