about summary refs log tree commit diff
path: root/sysdeps/mips
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-02-18 01:27:10 +0000
committerRoland McGrath <roland@gnu.org>1995-02-18 01:27:10 +0000
commit28f540f45bbacd939bfd07f213bcad2bf730b1bf (patch)
tree15f07c4c43d635959c6afee96bde71fb1b3614ee /sysdeps/mips
downloadglibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.tar.gz
glibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.tar.xz
glibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.zip
initial import
Diffstat (limited to 'sysdeps/mips')
-rw-r--r--sysdeps/mips/.cvsignore4
-rw-r--r--sysdeps/mips/Dist1
-rw-r--r--sysdeps/mips/Implies2
-rw-r--r--sysdeps/mips/Makefile3
-rw-r--r--sysdeps/mips/__longjmp.c81
-rw-r--r--sysdeps/mips/bsd-_setjmp.S28
-rw-r--r--sysdeps/mips/bsd-setjmp.S28
-rw-r--r--sysdeps/mips/dec/bytesex.h4
-rw-r--r--sysdeps/mips/jmp_buf.h47
-rw-r--r--sysdeps/mips/mips64/gmp-mparam.h26
-rw-r--r--sysdeps/mips/mipsel/bytesex.h4
-rw-r--r--sysdeps/mips/p40/bytesex.h4
-rw-r--r--sysdeps/mips/setjmp.S31
-rw-r--r--sysdeps/mips/setjmp_aux.c64
14 files changed, 327 insertions, 0 deletions
diff --git a/sysdeps/mips/.cvsignore b/sysdeps/mips/.cvsignore
new file mode 100644
index 0000000000..1f69fd919a
--- /dev/null
+++ b/sysdeps/mips/.cvsignore
@@ -0,0 +1,4 @@
+*.gz *.Z *.tar *.tgz
+=*
+TODO COPYING* AUTHORS copyr-* copying.*
+glibc-*
diff --git a/sysdeps/mips/Dist b/sysdeps/mips/Dist
new file mode 100644
index 0000000000..ad6ea0313a
--- /dev/null
+++ b/sysdeps/mips/Dist
@@ -0,0 +1 @@
+setjmp_aux.c
diff --git a/sysdeps/mips/Implies b/sysdeps/mips/Implies
new file mode 100644
index 0000000000..60732cef94
--- /dev/null
+++ b/sysdeps/mips/Implies
@@ -0,0 +1,2 @@
+# MIPS uses IEEE 754 floating point.
+ieee754
diff --git a/sysdeps/mips/Makefile b/sysdeps/mips/Makefile
new file mode 100644
index 0000000000..736414197a
--- /dev/null
+++ b/sysdeps/mips/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),setjmp)
+sysdep_routines := $(sysdep_routines) setjmp_aux
+endif
diff --git a/sysdeps/mips/__longjmp.c b/sysdeps/mips/__longjmp.c
new file mode 100644
index 0000000000..7ea3df2827
--- /dev/null
+++ b/sysdeps/mips/__longjmp.c
@@ -0,0 +1,81 @@
+/* Copyright (C) 1992, 1995 Free Software Foundation, Inc.
+   Contributed by Brendan Kehoe (brendan@zen.org).
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#include <ansidecl.h>
+#include <setjmp.h>
+#include <stdlib.h>
+
+#undef __longjmp
+
+#ifndef	__GNUC__
+  #error This file uses GNU C extensions; you must compile with GCC.
+#endif
+
+void
+DEFUN(__longjmp, (env, val_arg), CONST __jmp_buf env AND int val_arg)
+{
+  /* gcc 1.39.19 miscompiled the longjmp routine (as it did setjmp before
+     the hack around it); force it to use $a1 for the longjmp value.
+     Without this it saves $a1 in a register which gets clobbered
+     along the way.  */
+  register int val asm ("a1");
+
+  /* Pull back the floating point callee-saved registers.  */
+  asm volatile ("l.d $f20, %0" : : "m" (env[0].__fpregs[0]));
+  asm volatile ("l.d $f22, %0" : : "m" (env[0].__fpregs[1]));
+  asm volatile ("l.d $f24, %0" : : "m" (env[0].__fpregs[2]));
+  asm volatile ("l.d $f26, %0" : : "m" (env[0].__fpregs[3]));
+  asm volatile ("l.d $f28, %0" : : "m" (env[0].__fpregs[4]));
+  asm volatile ("l.d $f30, %0" : : "m" (env[0].__fpregs[5]));
+  
+  /* Restore the stack pointer.  */
+  asm volatile ("lw $29, %0" : : "m" (env[0].__sp));
+
+  /* Get and reconstruct the floating point csr.  */
+  asm volatile ("lw $2, %0" : : "m" (env[0].__fpc_csr));
+  asm volatile ("ctc1 $2, $31");
+
+  /* Get the FP.  */
+  asm volatile ("lw $30, %0" : : "m" (env[0].__fp));
+
+  /* Get the GP. */
+  asm volatile ("lw $gp, %0" : : "m" (env[0].__gp));
+
+  /* Get the callee-saved registers.  */
+  asm volatile ("lw $16, %0" : : "m" (env[0].__regs[0]));
+  asm volatile ("lw $17, %0" : : "m" (env[0].__regs[1]));
+  asm volatile ("lw $18, %0" : : "m" (env[0].__regs[2]));
+  asm volatile ("lw $19, %0" : : "m" (env[0].__regs[3]));
+  asm volatile ("lw $20, %0" : : "m" (env[0].__regs[4]));
+  asm volatile ("lw $21, %0" : : "m" (env[0].__regs[5]));
+  asm volatile ("lw $22, %0" : : "m" (env[0].__regs[6]));
+  asm volatile ("lw $23, %0" : : "m" (env[0].__regs[7]));
+
+  /* Get the PC.  */
+  asm volatile ("lw $31, %0" : : "m" (env[0].__pc));
+  
+  /* Give setjmp 1 if given a 0, or what they gave us if non-zero.  */
+  if (val == 0)
+    asm volatile ("li $2, 1");
+  else
+    asm volatile ("move $2, %0" : : "r" (val));
+
+  asm volatile ("j $31");
+
+  abort ();
+}
diff --git a/sysdeps/mips/bsd-_setjmp.S b/sysdeps/mips/bsd-_setjmp.S
new file mode 100644
index 0000000000..6e6844cc52
--- /dev/null
+++ b/sysdeps/mips/bsd-_setjmp.S
@@ -0,0 +1,28 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'.  MIPS version.
+Copyright (C) 1994, 1995 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 Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 0)'.
+   We cannot do it in C because it must be a tail-call, so frame-unwinding
+   in setjmp doesn't clobber the state restored by longjmp.  */
+
+#include <sysdep.h>
+
+ENTRY (setjmp)
+	j C_SYMBOL_NAME (__sigsetjmp)
+	li a1, zero		/* Pass a second argument of zero.  */
diff --git a/sysdeps/mips/bsd-setjmp.S b/sysdeps/mips/bsd-setjmp.S
new file mode 100644
index 0000000000..5cd090a31c
--- /dev/null
+++ b/sysdeps/mips/bsd-setjmp.S
@@ -0,0 +1,28 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'.  MIPS version.
+Copyright (C) 1994, 1995 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 Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
+   We cannot do it in C because it must be a tail-call, so frame-unwinding
+   in setjmp doesn't clobber the state restored by longjmp.  */
+
+#include <sysdep.h>
+
+ENTRY (setjmp)
+	j C_SYMBOL_NAME (__sigsetjmp)
+	li a1, 1		/* Pass a second argument of one.  */
diff --git a/sysdeps/mips/dec/bytesex.h b/sysdeps/mips/dec/bytesex.h
new file mode 100644
index 0000000000..157bc44d06
--- /dev/null
+++ b/sysdeps/mips/dec/bytesex.h
@@ -0,0 +1,4 @@
+/* The MIPS architecture has selectable endianness.
+   The DECstation uses little-endian mode.  */
+
+#define __BYTE_ORDER __LITTLE_ENDIAN
diff --git a/sysdeps/mips/jmp_buf.h b/sysdeps/mips/jmp_buf.h
new file mode 100644
index 0000000000..eed47dce7f
--- /dev/null
+++ b/sysdeps/mips/jmp_buf.h
@@ -0,0 +1,47 @@
+/* Define the machine-dependent type `jmp_buf'.  Mips version.
+   Copyright (C) 1992, 1993 Free Software Foundation, Inc.
+   Contributed by Brendan Kehoe (brendan@zen.org).
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+typedef struct
+  {
+    /* Program counter.  */
+    __ptr_t __pc;
+    
+    /* Stack pointer.  */
+    __ptr_t __sp;
+    
+    /* Callee-saved registers s0 through s7.  */
+    int __regs[8];
+    
+    /* The frame pointer.  */
+    __ptr_t __fp;
+    
+    /* The global pointer.  */
+    __ptr_t __gp;
+    
+    /* Floating point status register.  */
+    int __fpc_csr;
+    
+    /* Callee-saved floating point registers.  */
+    double __fpregs[6];
+  } __jmp_buf[1];
+
+#ifdef __USE_MISC
+/* Offset to the program counter in `jmp_buf'.  */
+#define JB_PC	0
+#endif
diff --git a/sysdeps/mips/mips64/gmp-mparam.h b/sysdeps/mips/mips64/gmp-mparam.h
new file mode 100644
index 0000000000..a801b35d7a
--- /dev/null
+++ b/sysdeps/mips/mips64/gmp-mparam.h
@@ -0,0 +1,26 @@
+/* gmp-mparam.h -- Compiler/machine parameter header file.
+
+Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Library General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at your
+option) any later version.
+
+The GNU MP 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 Library General Public
+License for more details.
+
+You should have received a copy of the GNU Library General Public License
+along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
+the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#define BITS_PER_MP_LIMB 64
+#define BYTES_PER_MP_LIMB 8
+#define BITS_PER_LONGINT 32
+#define BITS_PER_INT 32
+#define BITS_PER_SHORTINT 16
+#define BITS_PER_CHAR 8
diff --git a/sysdeps/mips/mipsel/bytesex.h b/sysdeps/mips/mipsel/bytesex.h
new file mode 100644
index 0000000000..5da5965cb2
--- /dev/null
+++ b/sysdeps/mips/mipsel/bytesex.h
@@ -0,0 +1,4 @@
+/* The MIPS architecture has selectable endianness.
+   This file is for a machine using little-endian mode.  */
+
+#define __BYTE_ORDER __LITTLE_ENDIAN
diff --git a/sysdeps/mips/p40/bytesex.h b/sysdeps/mips/p40/bytesex.h
new file mode 100644
index 0000000000..e4b0119433
--- /dev/null
+++ b/sysdeps/mips/p40/bytesex.h
@@ -0,0 +1,4 @@
+/* The MIPS has selectable endianness.
+   The Japanese homebrew P40 architecture uses big-endian mode.  */
+
+#define __BYTE_ORDER __BIG_ENDIAN
diff --git a/sysdeps/mips/setjmp.S b/sysdeps/mips/setjmp.S
new file mode 100644
index 0000000000..b3c0247468
--- /dev/null
+++ b/sysdeps/mips/setjmp.S
@@ -0,0 +1,31 @@
+/* Copyright (C) 1992, 1994 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 Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#include <sysdep.h>
+
+/* The function __sigsetjmp_aux saves all the registers, but it can't
+   reliably access the stack or frame pointers, so we pass them in as
+   extra arguments.  */
+ENTRY (__sigsetjmp)
+	move a2, sp
+#ifdef __sgi__
+	move a3, fp
+#else
+	move a3, $fp
+#endif
+	j __sigsetjmp_aux
diff --git a/sysdeps/mips/setjmp_aux.c b/sysdeps/mips/setjmp_aux.c
new file mode 100644
index 0000000000..d478e3fdc9
--- /dev/null
+++ b/sysdeps/mips/setjmp_aux.c
@@ -0,0 +1,64 @@
+/* Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
+   Contributed by Brendan Kehoe (brendan@zen.org).
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#include <setjmp.h>
+
+/* This function is only called via the assembly language routine
+   __sigsetjmp, which arranges to pass in the stack pointer and the frame
+   pointer.  We do things this way because it's difficult to reliably
+   access them in C.  */
+
+int
+__sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp)
+{
+  /* Store the floating point callee-saved registers...  */
+  asm volatile ("s.d $f20, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[0]));
+  asm volatile ("s.d $f22, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[1]));
+  asm volatile ("s.d $f24, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[2]));
+  asm volatile ("s.d $f26, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[3]));
+  asm volatile ("s.d $f28, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[4]));
+  asm volatile ("s.d $f30, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[5]));
+
+  /* .. and the PC;  */
+  asm volatile ("sw $31, %0" : : "m" (env[0].__jmpbuf[0].__pc));
+
+  /* .. and the stack pointer;  */
+  env[0].__jmpbuf[0].__sp = sp;
+
+  /* .. and the FP; it'll be in s8. */
+  env[0].__jmpbuf[0].__fp = fp;
+
+  /* .. and the GP; */
+  asm volatile ("sw $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp));
+
+  /* .. and the callee-saved registers; */
+  asm volatile ("sw $16, %0" : : "m" (env[0].__jmpbuf[0].__regs[0]));
+  asm volatile ("sw $17, %0" : : "m" (env[0].__jmpbuf[0].__regs[1]));
+  asm volatile ("sw $18, %0" : : "m" (env[0].__jmpbuf[0].__regs[2]));
+  asm volatile ("sw $19, %0" : : "m" (env[0].__jmpbuf[0].__regs[3]));
+  asm volatile ("sw $20, %0" : : "m" (env[0].__jmpbuf[0].__regs[4]));
+  asm volatile ("sw $21, %0" : : "m" (env[0].__jmpbuf[0].__regs[5]));
+  asm volatile ("sw $22, %0" : : "m" (env[0].__jmpbuf[0].__regs[6]));
+  asm volatile ("sw $23, %0" : : "m" (env[0].__jmpbuf[0].__regs[7]));
+
+  /* .. and finally get and reconstruct the floating point csr.  */
+  asm ("cfc1 %0, $31" : "=r" (env[0].__jmpbuf[0].__fpc_csr));
+
+  /* Save the signal mask if requested.  */
+  return __sigjmp_save (env, savemask);
+}