about summary refs log tree commit diff
path: root/sysdeps/mips
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2003-03-17 15:47:13 +0000
committerAlexandre Oliva <aoliva@redhat.com>2003-03-17 15:47:13 +0000
commit4947b4b20f49324647a7cbcd2596b1f5b4639748 (patch)
tree0447ee1cce55994f03a92ba7413268c51be85d11 /sysdeps/mips
parentde4471dd559ab27a8927135fb5a475eaa613c437 (diff)
downloadglibc-4947b4b20f49324647a7cbcd2596b1f5b4639748.tar.gz
glibc-4947b4b20f49324647a7cbcd2596b1f5b4639748.tar.xz
glibc-4947b4b20f49324647a7cbcd2596b1f5b4639748.zip
* sysdeps/mips/bits/wordsize.h: New file, appropriate for all 3 ABIs. * sysdeps/mips/mips64/gmp-mparam.h: New file. Define BITS_PER_LONGINT to __WORDSIZE, to match all 3 ABIs. * sysdeps/mips/setjmp_aux.c (STRINGXP, REGS, PTRS): New macros. (__sigsetjmp_aux): Use them. Adjust for all 3 ABIs. * sysdeps/mips/elf/start.S: Adjust for all 3 ABIs. * sysdeps/unix/mips/brk.S: Likewise. * sysdeps/unix/mips/sysdep.S: Likewise. * sysdeps/unix/sysv/linux/mips/clone.S: Likewise. * sysdeps/mips/bits/setjmp.h (__jmp_buf): Likewise. * sysdeps/mips/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/mips/sys/profcs.h: Likewise. * sysdeps/unix/sysv/linux/mips/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/mips/kernel_stat.h: Likewise. * sysdeps/mips/mips64/bsd-_setjmp.S: Likewise. * sysdeps/mips/mips64/bsd-setjmp.S: Likewise. * sysdeps/mips/mips64/setjmp.S: Likewise. * sysdeps/mips/mips64/bits/setjmp.h: Deleted, obsolete. * sysdeps/mips/mips64/soft-fp/sfp-machine.h: Use long long for 64-bit types.
2003-03-17  Alexandre Oliva  <aoliva@redhat.com>

	* sysdeps/mips/bits/wordsize.h: New file, appropriate for all
	3 ABIs.
	* sysdeps/mips/mips64/gmp-mparam.h: New file.  Define
	BITS_PER_LONGINT to __WORDSIZE, to match all 3 ABIs.
	* sysdeps/mips/setjmp_aux.c (STRINGXP, REGS, PTRS): New macros.
	(__sigsetjmp_aux): Use them.  Adjust for all 3 ABIs.
	* sysdeps/mips/elf/start.S: Adjust for all 3 ABIs.
	* sysdeps/unix/mips/brk.S: Likewise.
	* sysdeps/unix/mips/sysdep.S: Likewise.
	* sysdeps/unix/sysv/linux/mips/clone.S: Likewise.
	* sysdeps/mips/bits/setjmp.h (__jmp_buf): Likewise.
	* sysdeps/mips/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/sys/profcs.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/kernel_stat.h: Likewise.
	* sysdeps/mips/mips64/bsd-_setjmp.S: Likewise.
	* sysdeps/mips/mips64/bsd-setjmp.S: Likewise.
	* sysdeps/mips/mips64/setjmp.S: Likewise.
	* sysdeps/mips/mips64/bits/setjmp.h: Deleted, obsolete.
	* sysdeps/mips/mips64/soft-fp/sfp-machine.h: Use long long for
	64-bit types.
Diffstat (limited to 'sysdeps/mips')
-rw-r--r--sysdeps/mips/bits/setjmp.h19
-rw-r--r--sysdeps/mips/bits/wordsize.h19
-rw-r--r--sysdeps/mips/elf/start.S59
-rw-r--r--sysdeps/mips/mips64/bits/setjmp.h57
-rw-r--r--sysdeps/mips/mips64/bsd-_setjmp.S19
-rw-r--r--sysdeps/mips/mips64/bsd-setjmp.S20
-rw-r--r--sysdeps/mips/mips64/gmp-mparam.h31
-rw-r--r--sysdeps/mips/mips64/setjmp.S12
-rw-r--r--sysdeps/mips/mips64/soft-fp/sfp-machine.h6
-rw-r--r--sysdeps/mips/setjmp_aux.c38
-rw-r--r--sysdeps/mips/sys/ucontext.h20
11 files changed, 179 insertions, 121 deletions
diff --git a/sysdeps/mips/bits/setjmp.h b/sysdeps/mips/bits/setjmp.h
index 8cb53ee291..fa48676445 100644
--- a/sysdeps/mips/bits/setjmp.h
+++ b/sysdeps/mips/bits/setjmp.h
@@ -1,5 +1,6 @@
 /* Define the machine-dependent type `jmp_buf'.  MIPS version.
-   Copyright (C) 1992,93,95,97,2000 Free Software Foundation, Inc.
+   Copyright (C) 1992, 1993, 1995, 1997, 2000, 2002, 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
@@ -24,25 +25,33 @@
 typedef struct
   {
     /* Program counter.  */
-    void * __pc;
+    __ptr_t __pc;
 
     /* Stack pointer.  */
-    void * __sp;
+    __ptr_t __sp;
 
     /* Callee-saved registers s0 through s7.  */
+#if _MIPS_SIM == _MIPS_SIM_ABI32
     int __regs[8];
+#else
+    __extension__ long long __regs[8];
+#endif
 
     /* The frame pointer.  */
-    void * __fp;
+    __ptr_t __fp;
 
     /* The global pointer.  */
-    void * __gp;
+    __ptr_t __gp;
 
     /* Floating point status register.  */
     int __fpc_csr;
 
     /* Callee-saved floating point registers.  */
+#if _MIPS_SIM == _MIPS_SIM_ABI32
     double __fpregs[6];
+#else
+    double __fpregs[8];
+#endif
   } __jmp_buf[1];
 
 #ifdef __USE_MISC
diff --git a/sysdeps/mips/bits/wordsize.h b/sysdeps/mips/bits/wordsize.h
new file mode 100644
index 0000000000..666c7ad07e
--- /dev/null
+++ b/sysdeps/mips/bits/wordsize.h
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002, 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.  */
+
+#define __WORDSIZE	_MIPS_SZPTR
diff --git a/sysdeps/mips/elf/start.S b/sysdeps/mips/elf/start.S
index e85e9f535e..7567423f00 100644
--- a/sysdeps/mips/elf/start.S
+++ b/sysdeps/mips/elf/start.S
@@ -1,5 +1,6 @@
 /* Startup code compliant to the ELF Mips ABI.
-   Copyright (C) 1995, 1997, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1997, 2000, 2001, 2002, 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
@@ -19,6 +20,7 @@
 
 #define __ASSEMBLY__ 1
 #include <entry.h>
+#include <sys/asm.h>
 
 #ifndef ENTRY_POINT
 #error ENTRY_POINT needs to be defined for start.S on MIPS/ELF.
@@ -52,42 +54,41 @@
 		      char **argv, void (*init) (void), void (*fini) (void),
 		      void (*rtld_fini) (void), void *stack_end)
 */
-#ifdef __PIC__
-/* A macro to (re)initialize gp. We can get the run time address of 0f in
-   ra ($31) by blezal instruction. In this early phase, we can't save gp
-   in stack and .cprestore doesn't work properly. So we set gp by using
-   this macro. */
-#define SET_GP \
-	.set noreorder;	\
-	bltzal $0,0f;	\
-	nop;		\
-0:	.cpload $31;	\
-	.set reorder;
-#endif
-
+	
 	.text
 	.globl ENTRY_POINT
 	.type ENTRY_POINT,@function
 ENTRY_POINT:
 #ifdef __PIC__
-	SET_GP
+	SETUP_GPX($0)
+	SETUP_GPX64($25,$0)
 #else
-	la $28, _gp		/* Setup GP correctly if we're non-PIC.  */
-#endif
+	PTR_LA $28, _gp		/* Setup GP correctly if we're non-PIC.  */
 	move $31, $0
+#endif
 
-	la $4, main		/* main */
-	lw $5, 0($29)		/* argc */
-	addu $6, $29, 4		/* argv  */
-	/* Allocate space on the stack for seven arguments and make sure
-	   the stack is aligned to double words (8 bytes).  */
-	and $29, 0xfffffff8
-	subu $29, 32
-	la $7, __libc_csu_init		/* init */
-	la $8, __libc_csu_fini
-	sw $8, 16($29)		/* fini */
-	sw $2, 20($29)		/* rtld_fini */
-	sw $29, 24($29)		/* stack_end */
+	PTR_LA $4, main		/* main */
+	PTR_L $5, 0($29)		/* argc */
+	PTR_ADDIU $6, $29, PTRSIZE	/* argv  */
+	
+	/* Allocate space on the stack for seven arguments (o32 only)
+	   and make sure the stack is aligned to double words (8 bytes) 
+	   on o32 and quad words (16 bytes) on n32 and n64.  */
+	
+	and $29, -2 * SZREG
+#if _MIPS_SIM == _MIPS_SIM_ABI32
+	PTR_SUBIU $29, 32
+#endif
+	PTR_LA $7, __libc_csu_init		/* init */
+	PTR_LA $8, __libc_csu_fini
+#if _MIPS_SIM == _MIPS_SIM_ABI32
+	PTR_S $8, 16($29)		/* fini */
+	PTR_S $2, 20($29)		/* rtld_fini */
+	PTR_S $29, 24($29)		/* stack_end */
+#else
+	move $9, $2		/* rtld_fini */
+	move $10, $29		/* stack_end */
+#endif
 	jal __libc_start_main
 hlt:	b hlt			/* Crash if somehow it does return.  */
 
diff --git a/sysdeps/mips/mips64/bits/setjmp.h b/sysdeps/mips/mips64/bits/setjmp.h
deleted file mode 100644
index e126427dbd..0000000000
--- a/sysdeps/mips/mips64/bits/setjmp.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Define the machine-dependent type `jmp_buf'.  MIPS version.
-   Copyright (C) 1996, 1997 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 _SETJMP_H
-# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
-#endif
-
-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[8];
-  } __jmp_buf[1];
-
-#ifdef __USE_MISC
-/* Offset to the program counter in `jmp_buf'.  */
-# define JB_PC	0
-#endif
-
-
-/* Test if longjmp to JMPBUF would unwind the frame
-   containing a local variable at ADDRESS.  */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
-  ((__ptr_t) (address) < (jmpbuf)[0].__sp)
diff --git a/sysdeps/mips/mips64/bsd-_setjmp.S b/sysdeps/mips/mips64/bsd-_setjmp.S
index c0ff0d7621..9d79ab0a2f 100644
--- a/sysdeps/mips/mips64/bsd-_setjmp.S
+++ b/sysdeps/mips/mips64/bsd-_setjmp.S
@@ -1,5 +1,5 @@
 /* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'.  MIPS64 version.
-   Copyright (C) 1996, 1997, 2000, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 2000, 2002, 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
@@ -28,10 +28,19 @@
 #endif
 ENTRY (_setjmp)
 #ifdef __PIC__
-	.cpload t9
+	SETUP_GP
 #endif
-	dla t9, C_SYMBOL_NAME (__sigsetjmp)
+	SETUP_GP64 (v0, C_SYMBOL_NAME (_setjmp))
+	PTR_LA t9, C_SYMBOL_NAME (__sigsetjmp)
+#if _MIPS_SIM == _MIPS_SIM_ABI32
 	nop
-	jr t9
-	dli a1, 0		/* Pass a second argument of zero.  */
+#endif	
+	RESTORE_GP64
+	move	a1, zero		/* Pass a second argument of zero.  */
+#ifdef __PIC__
+	jr	t9
+#else
+	j	C_SYMBOL_NAME (__sigsetjmp)
+#endif
+	.end	_setjmp
 libc_hidden_def (_setjmp)
diff --git a/sysdeps/mips/mips64/bsd-setjmp.S b/sysdeps/mips/mips64/bsd-setjmp.S
index ee8678728c..f542cb565f 100644
--- a/sysdeps/mips/mips64/bsd-setjmp.S
+++ b/sysdeps/mips/mips64/bsd-setjmp.S
@@ -1,5 +1,5 @@
 /* BSD `setjmp' entry point to `sigsetjmp (..., 1)'.  MIPS64 version.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 2002, 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
@@ -22,15 +22,25 @@
    in setjmp doesn't clobber the state restored by longjmp.  */
 
 #include <sysdep.h>
+#include <sys/asm.h>
 
 #ifdef PIC
 	.option pic2
 #endif
 ENTRY (setjmp)
-#ifdef PIC
-	.cpload t9
+#ifdef __PIC__
+	SETUP_GP
 #endif
-	dla t9, C_SYMBOL_NAME (__sigsetjmp)
+	SETUP_GP64 (v0, C_SYMBOL_NAME (setjmp))
+	PTR_LA t9, C_SYMBOL_NAME (__sigsetjmp)
+#if _MIPS_SIM == _MIPS_SIM_ABI32
 	nop
-	jr t9
+#endif	
+	RESTORE_GP64
 	dli a1, 1		/* Pass a second argument of one.  */
+#ifdef __PIC__
+	jr	t9
+#else
+	j	C_SYMBOL_NAME (__sigsetjmp)
+#endif
+	.end	setjmp
diff --git a/sysdeps/mips/mips64/gmp-mparam.h b/sysdeps/mips/mips64/gmp-mparam.h
new file mode 100644
index 0000000000..7666137a21
--- /dev/null
+++ b/sysdeps/mips/mips64/gmp-mparam.h
@@ -0,0 +1,31 @@
+/* gmp-mparam.h -- Compiler/machine parameter header file.
+
+Copyright (C) 1991, 1993, 1994, 2002, 2003 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 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 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser 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. */
+
+#if defined __GMP_H__ && ! defined _LONG_LONG_LIMB
+#error "Included too late for _LONG_LONG_LIMB to take effect"
+#endif
+
+#define _LONG_LONG_LIMB
+#define BITS_PER_MP_LIMB 64
+#define BYTES_PER_MP_LIMB 8
+#define BITS_PER_LONGINT __WORDSIZE
+#define BITS_PER_INT 32
+#define BITS_PER_SHORTINT 16
+#define BITS_PER_CHAR 8
diff --git a/sysdeps/mips/mips64/setjmp.S b/sysdeps/mips/mips64/setjmp.S
index 5e18897d88..3d2bf20e7c 100644
--- a/sysdeps/mips/mips64/setjmp.S
+++ b/sysdeps/mips/mips64/setjmp.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2000, 2002, 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
@@ -17,6 +17,7 @@
    02111-1307 USA.  */
 
 #include <sysdep.h>
+#include <sys/asm.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
@@ -26,10 +27,15 @@
 #endif
 ENTRY (__sigsetjmp)
 #ifdef __PIC__
-	.cpload t9
+	SETUP_GP
 #endif
+	SETUP_GP64 (v0, C_SYMBOL_NAME (__sigsetjmp))
 	move a2, sp
 	move a3, fp
-	dla t9, __sigsetjmp_aux
+	PTR_LA t9, __sigsetjmp_aux
+#if _MIPS_SIM == _MIPS_SIM_ABI32
 	nop
+#endif	
+	RESTORE_GP64
 	jr t9
+	.end __sigsetjmp
diff --git a/sysdeps/mips/mips64/soft-fp/sfp-machine.h b/sysdeps/mips/mips64/soft-fp/sfp-machine.h
index 730deae872..309a14a5f8 100644
--- a/sysdeps/mips/mips64/soft-fp/sfp-machine.h
+++ b/sysdeps/mips/mips64/soft-fp/sfp-machine.h
@@ -1,7 +1,7 @@
 #define _FP_W_TYPE_SIZE		64
-#define _FP_W_TYPE		unsigned long
-#define _FP_WS_TYPE		signed long
-#define _FP_I_TYPE		long
+#define _FP_W_TYPE		unsigned long long
+#define _FP_WS_TYPE		signed long long
+#define _FP_I_TYPE		long long
 
 #define _FP_MUL_MEAT_S(R,X,Y)					\
   _FP_MUL_MEAT_1_imm(_FP_WFRACBITS_S,R,X,Y)
diff --git a/sysdeps/mips/setjmp_aux.c b/sysdeps/mips/setjmp_aux.c
index 1cd2b2155e..9e6766f949 100644
--- a/sysdeps/mips/setjmp_aux.c
+++ b/sysdeps/mips/setjmp_aux.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2000, 2002, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Brendan Kehoe (brendan@zen.org).
 
@@ -18,6 +18,11 @@
    02111-1307 USA.  */
 
 #include <setjmp.h>
+#include <sys/asm.h>
+
+#define STRINGXP(X) __STRING(X)
+#define REGS STRINGXP(REG_S)
+#define PTRS STRINGXP(PTR_S)
 
 /* This function is only called via the assembly language routine
    __sigsetjmp, which arranges to pass in the stack pointer and the frame
@@ -28,15 +33,26 @@ int
 __sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp)
 {
   /* Store the floating point callee-saved registers...  */
+#if _MIPS_SIM == _MIPS_SIM_ABI32
   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]));
+#else
+  asm volatile ("s.d $f24, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[0]));
+  asm volatile ("s.d $f25, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[1]));
+  asm volatile ("s.d $f26, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[2]));
+  asm volatile ("s.d $f27, %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 $f29, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[5]));
+  asm volatile ("s.d $f30, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[6]));
+  asm volatile ("s.d $f31, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[7]));
+#endif  
 
   /* .. and the PC;  */
-  asm volatile ("sw $31, %0" : : "m" (env[0].__jmpbuf[0].__pc));
+  asm volatile (PTRS " $31, %0" : : "m" (env[0].__jmpbuf[0].__pc));
 
   /* .. and the stack pointer;  */
   env[0].__jmpbuf[0].__sp = (void *) sp;
@@ -45,17 +61,17 @@ __sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp)
   env[0].__jmpbuf[0].__fp = (void *) fp;
 
   /* .. and the GP; */
-  asm volatile ("sw $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp));
+  asm volatile (PTRS " $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]));
+  asm volatile (REGS " $16, %0" : : "m" (env[0].__jmpbuf[0].__regs[0]));
+  asm volatile (REGS " $17, %0" : : "m" (env[0].__jmpbuf[0].__regs[1]));
+  asm volatile (REGS " $18, %0" : : "m" (env[0].__jmpbuf[0].__regs[2]));
+  asm volatile (REGS " $19, %0" : : "m" (env[0].__jmpbuf[0].__regs[3]));
+  asm volatile (REGS " $20, %0" : : "m" (env[0].__jmpbuf[0].__regs[4]));
+  asm volatile (REGS " $21, %0" : : "m" (env[0].__jmpbuf[0].__regs[5]));
+  asm volatile (REGS " $22, %0" : : "m" (env[0].__jmpbuf[0].__regs[6]));
+  asm volatile (REGS " $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));
diff --git a/sysdeps/mips/sys/ucontext.h b/sysdeps/mips/sys/ucontext.h
index 90c992dae6..90aa09a80f 100644
--- a/sysdeps/mips/sys/ucontext.h
+++ b/sysdeps/mips/sys/ucontext.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 1999, 2002, 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
@@ -25,7 +25,11 @@
 #include <signal.h>
 
 /* Type for general register.  */
-typedef unsigned int greg_t;
+#if _MIPS_SIM == _MIPS_SIM_ABI32
+typedef __uint32_t greg_t;
+#else
+typedef __uint64_t greg_t;
+#endif
 
 /* Number of general registers.  */
 #define NGREG	36
@@ -115,9 +119,15 @@ typedef struct fpregset
 {
   union
   {
+#if _MIPS_SIM == _MIPS_SIM_ABI32
     double fp_dregs[16];
     float fp_fregs[32];
     unsigned int fp_regs[32];
+#else
+    double fp_dregs[32];
+    /* float fp_fregs[32]; */
+    __uint64_t fp_regs[32];
+#endif
   } fp_r;
   unsigned int fp_csr;
   unsigned int fp_pad;
@@ -133,12 +143,16 @@ typedef struct
 /* Userlevel context.  */
 typedef struct ucontext
 {
+#if _MIPS_SIM == _MIPS_SIM_ABI32
   unsigned long int uc_flags;
+#else
+  __uint64_t uc_flags;
+#endif
   struct ucontext *uc_link;
   __sigset_t uc_sigmask;
   stack_t uc_stack;
   mcontext_t uc_mcontext;
-  long int uc_filler[48];
+  int uc_filler[48];
 } ucontext_t;
 
 #endif /* sys/ucontext.h */