2007-08-26  Daniel Jacobowitz  <dan@codesourcery.com>

	* defs.h [MIPS]: Include <sgidefs.h>.
	(MAX_QUALS): Update for MIPS.
	(LINUX_MIPSO32, LINUX_MIPSN32, LINUX_MIPSN64, LINUX_MIPS64): Define.
	(struct tcb): Add ext_arg for MIPS N32.
	(TCB_WAITEXECVE): Define for MIPS.
	(ALIGN64): Use LINUX_MIPSO32.
	* file.c (sys_lseek): Use ext_arg for MIPS N32.
	(sys_readahead, sys_fadvise64_64): Likewise.
	* io.c (sys_pread64, sys_pwrite64): Likewise.
	* mem.c (print_mmap): Take OFFSET argument.
	(sys_old_mmap): Update call to print_mmap.
	(sys_mmap): Use ext_arg for MIPS N32.
	* process.c (struct_user_offsets): Add MIPS registers.
	* signal.c (sys_sigreturn): Handle MIPS N32 and MIPS N64.  Correct
	MIPS O32 call to sprintsigmask.
	* syscall.c (internal_syscall): Handle MIPS N32.  Check for
	TCB_WAITEXECVE on MIPS.
	(force_result): Add a comment about MIPS N32.
	(syscall_enter): Handle MIPS N32 and MIPS N64.
	* linux/syscall.h (sys_pread64, sys_pwrite64): Declare.
	* linux/mips/syscallent.h: Include "dummy.h".  Handle alternate
	MIPS ABIs.
diff --git a/signal.c b/signal.c
index d0c4ae7..90e38b7 100644
--- a/signal.c
+++ b/signal.c
@@ -1429,6 +1429,33 @@
 	}
 	return 0;
 #else
+#if defined (LINUX_MIPSN32) || defined (LINUX_MIPSN64)
+	/* This decodes rt_sigreturn.  The 64-bit ABIs do not have
+	   sigreturn.  */
+	long sp;
+	struct ucontext uc;
+
+	if(entering(tcp)) {
+	  	tcp->u_arg[0] = 0;
+		if (upeek(tcp->pid, REG_SP, &sp) < 0)
+		  	return 0;
+		/* There are six words followed by a 128-byte siginfo.  */
+		sp = sp + 6 * 4 + 128;
+		if (umove(tcp, sp, &uc) < 0)
+		  	return 0;
+		tcp->u_arg[0] = 1;
+		tcp->u_arg[1] = *(long *) &uc.uc_sigmask;
+	} else {
+		sigset_t sigm;
+		long_to_sigset(tcp->u_arg[1], &sigm);
+	  	tcp->u_rval = tcp->u_error = 0;
+		if(tcp->u_arg[0] == 0)
+		  	return 0;
+		tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
+		return RVAL_NONE | RVAL_STR;
+	}
+	return 0;
+#else
 #ifdef MIPS
 	long sp;
 	struct pt_regs regs;
@@ -1459,6 +1486,7 @@
 #warning         (no problem, just a reminder :-)
 	return 0;
 #endif /* MIPS */
+#endif /* LINUX_MIPSN32 || LINUX_MIPSN64 */
 #endif /* SPARC || SPARC64 */
 #endif /* ALPHA */
 #endif /* !M68K */