Skip to contentSkip to conversation

Struct sigaction cleanup

PATCH Ralf Baechle 1 participant 1 message Mar 8, 2003 MIPS

lore
Share & tools
lore
#0 lore raw

I'm working on overhauling the signal code. Part 1 is just some cleanup. As historic garbage we've got two unused fields in struct sigaction:

struct sigaction {
        unsigned int    sa_flags;
        __sighandler_t  sa_handler;
        sigset_t        sa_mask;
        void            (*sa_restorer)(void);
        int             sa_resv[1];     /* reserved */
};

Actually the size of sa_mask is supposed to be variable and therefore sa_mask has to be the last member of struct sigaction. Further no known libc implementation making use of sa_restorer. So here's a patch to remove the two fields. This little change btw. delivers 3% speedup of signal delivery.

Note there is no binary compatibility issue. Glibc's contains it's own definitions of struct sigaction and the kernel's struct sigaction. That means existing glibc binaries will simply pass a too large kernel struct sigaction to the kernel which will just ignore the extra fields.

Comments?

Ralf

Index: arch/mips/kernel/irixsig.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/kernel/irixsig.c,v retrieving revision 1.20.2.1

mips/kernel/irixsig.c +3 -2
diff -u -r1.20.2.1 irixsig.c
@@ -116,7 +116,8 @@
 	regs->regs[5] = 0; /* XXX sigcode XXX */
 	regs->regs[6] = regs->regs[29] = sp;
 	regs->regs[7] = (unsigned long) ka->sa.sa_handler;
-	regs->regs[25] = regs->cp0_epc = (unsigned long) ka->sa.sa_restorer;
+	regs->regs[25] = regs->cp0_epc = (unsigned long) ka->sa_restorer;
+
 	return;
 
 segv_and_exit:
@@ -407,7 +408,7 @@
 		 * value for all invocations of sigaction.  Will have to
 		 * investigate.  POSIX POSIX, die die die...
 		 */
-		new_ka.sa.sa_restorer = trampoline;
+		new_ka.sa_restorer = trampoline;
 	}
 
 /* XXX Implement SIG_SETMASK32 for IRIX compatibility */

Index: arch/mips/kernel/signal.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/kernel/signal.c,v retrieving revision 1.39.2.10

mips/kernel/signal.c +18 -36

78 lines not on this page · raw message

Index: arch/mips64/kernel/signal32.c
===================================================================
RCS file: /home/cvs/linux/arch/mips64/kernel/signal32.c,v retrieving revision 1.20.2.11

mips64/kernel/signal32.c +21 -42

116 lines not on this page · raw message

Index: include/asm-mips/signal.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips/signal.h,v retrieving revision 1.9.2.1

asm-mips/signal.h +4 -2
diff -u -r1.9.2.1 signal.h
@@ -9,6 +9,7 @@
 #ifndef _ASM_SIGNAL_H
 #define _ASM_SIGNAL_H
 
+#include <linux/config.h>
 #include <linux/types.h>
 
 #define _NSIG		128
@@ -130,12 +131,13 @@
 	unsigned int	sa_flags;
 	__sighandler_t	sa_handler;
 	sigset_t	sa_mask;
-	void		(*sa_restorer)(void);
-	int		sa_resv[1];	/* reserved */
 };
 
 struct k_sigaction {
 	struct sigaction sa;
+#ifdef CONFIG_BINFMT_IRIX
+	void		(*sa_restorer)(void);
+#endif
 };
 
 /* IRIX compatible stack_t  */

Index: include/asm-mips64/signal.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips64/signal.h,v retrieving revision 1.4.2.4

asm-mips64/signal.h +0 -2
diff -u -r1.4.2.4 signal.h
@@ -139,8 +139,6 @@
 	unsigned int	sa_flags;
 	__sighandler_t	sa_handler;
 	sigset_t	sa_mask;
-	void		(*sa_restorer)(void);
-	int		sa_resv[1];	/* reserved */
 };
 
 struct k_sigaction {