This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

mips64 sigaction changes


This patch ports sigaction to all 3 mips64 ABIs.  __restore and
__NR_restore are probably not really necessary, since n32 and n64
always use the rt variants and o32 doesn't need a sa_restorer, but I
thought it wouldn't hurt to put it in, just in case...  Ok?

Index: ChangeLog
2003-03-14  Alexandre Oliva  <aoliva at redhat dot com>

	* sysdeps/unix/sysv/linux/mips/kernel_sigaction.h
	(_KERNEL_NSIG_BPW): Define in terms of _MIPS_SZLONG.
	* sysdeps/unix/sysv/linux/mips/sigaction.c: Define restore and
	restore_rt functions.  Use them.

Index: sysdeps/unix/sysv/linux/mips/kernel_sigaction.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/mips/kernel_sigaction.h,v
retrieving revision 1.4
diff -u -p -r1.4 kernel_sigaction.h
--- sysdeps/unix/sysv/linux/mips/kernel_sigaction.h 11 Dec 2000 19:27:03 -0000 1.4
+++ sysdeps/unix/sysv/linux/mips/kernel_sigaction.h 15 Jan 2003 15:30:24 -0000
@@ -23,7 +23,7 @@ struct old_kernel_sigaction {
 
 
 #define _KERNEL_NSIG	       128
-#define _KERNEL_NSIG_BPW       32
+#define _KERNEL_NSIG_BPW       _MIPS_SZLONG
 #define _KERNEL_NSIG_WORDS     (_KERNEL_NSIG / _KERNEL_NSIG_BPW)
 
 typedef struct {
Index: sysdeps/unix/sysv/linux/mips/sigaction.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/mips/sigaction.c,v
retrieving revision 1.5
diff -u -p -r1.5 sigaction.c
--- sysdeps/unix/sysv/linux/mips/sigaction.c 3 Jan 2003 00:42:10 -0000 1.5
+++ sysdeps/unix/sysv/linux/mips/sigaction.c 15 Jan 2003 15:30:26 -0000
@@ -41,6 +41,15 @@ extern int __syscall_sigaction (int, con
 extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *__unbounded,
 				   struct kernel_sigaction *__unbounded, size_t);
 
+#if _MIPS_SIM != _MIPS_SIM_ABI32
+
+# ifdef __NR_rt_sigreturn
+static void restore_rt (void) asm ("__restore_rt");
+# endif
+# ifdef __NR_sigreturn
+static void restore (void) asm ("__restore");
+# endif
+#endif
 
 /* If ACT is not NULL, change the action for SIG to *ACT.
    If OACT is not NULL, put the old action for SIG in *OACT.  */
@@ -74,7 +83,11 @@ __libc_sigaction (sig, act, oact)
 	  memcpy (&kact.sa_mask, &act->sa_mask, sizeof (kernel_sigset_t));
 	  kact.sa_flags = act->sa_flags;
 # ifdef HAVE_SA_RESTORER
+#  if _MIPS_SIM == _MIPS_SIM_ABI32
 	  kact.sa_restorer = act->sa_restorer;
+#  else
+	  kact.sa_restorer = &restore_rt;
+#  endif
 # endif
 	}
 
@@ -128,7 +141,11 @@ __libc_sigaction (sig, act, oact)
       oact->sa_mask.__val[0] = k_osigact.sa_mask;
       oact->sa_flags = k_osigact.sa_flags;
 # ifdef HAVE_SA_RESTORER
+#  if _MIPS_SIM == _MIPS_SIM_ABI32
       oact->sa_restorer = k_osigact.sa_restorer;
+#  else
+      oact->sa_restorer = &restore;
+#  endif
 # endif
     }
   return result;
@@ -140,4 +157,32 @@ libc_hidden_def (__libc_sigaction)
 weak_alias (__libc_sigaction, __sigaction)
 libc_hidden_weak (__sigaction)
 weak_alias (__libc_sigaction, sigaction)
+#endif
+
+/* NOTE: Please think twice before making any changes to the bits of
+   code below.  GDB needs some intimate knowledge about it to
+   recognize them as signal trampolines, and make backtraces through
+   signal handlers work right.  Important are both the names
+   (__restore_rt) and the exact instruction sequence.
+   If you ever feel the need to make any changes, please notify the
+   appropriate GDB maintainer.  */
+
+#define RESTORE(name, syscall) RESTORE2 (name, syscall)
+#define RESTORE2(name, syscall) \
+asm						\
+  (						\
+   ".align 4\n"					\
+   "__" #name ":\n"				\
+   "	li $2, " #syscall "\n"			\
+   "	syscall\n"				\
+   );
+
+/* The return code for realtime-signals.  */
+#if _MIPS_SIM != _MIPS_SIM_ABI32
+# ifdef __NR_rt_sigreturn
+RESTORE (restore_rt, __NR_rt_sigreturn)
+# endif
+# ifdef __NR_sigreturn
+RESTORE (restore, __NR_sigreturn)
+# endif
 #endif
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva at {redhat dot com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva at {lsd dot ic dot unicamp dot br, gnu.org}
Free Software Evangelist                Professional serial bug killer

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]