aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorFranck Bui-Huu <fbuihuu@gmail.com>2007-02-05 09:24:19 -0500
committerRalf Baechle <ralf@linux-mips.org>2007-02-10 17:38:44 -0500
commita007b1f1c764c08896bc574fbd33e19ce898a188 (patch)
tree3af4bf0466234ffdbb916b085b72f4034e7a0340 /arch/mips
parent4ed3a77f38c023658784804cb39a7ce18063dc88 (diff)
[MIPS] signals: reduce {setup,restore}_sigcontext sizes
This trivial change reduces considerably code size of these 2 functions callers. For instance, here is the figures for arch/kernel/signal.o objects: text data bss dec hex filename 11972 0 0 11972 2ec4 arch/mips/kernel/signal.o~old 5380 0 0 5380 1504 arch/mips/kernel/signal.o~new Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/kernel/signal-common.h66
1 files changed, 21 insertions, 45 deletions
diff --git a/arch/mips/kernel/signal-common.h b/arch/mips/kernel/signal-common.h
index b1f09d54ebe6..bb3c631b808e 100644
--- a/arch/mips/kernel/signal-common.h
+++ b/arch/mips/kernel/signal-common.h
@@ -13,22 +13,13 @@ static inline int
13setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) 13setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
14{ 14{
15 int err = 0; 15 int err = 0;
16 int i;
16 17
17 err |= __put_user(regs->cp0_epc, &sc->sc_pc); 18 err |= __put_user(regs->cp0_epc, &sc->sc_pc);
18 19
19#define save_gp_reg(i) do { \ 20 err |= __put_user(0, &sc->sc_regs[0]);
20 err |= __put_user(regs->regs[i], &sc->sc_regs[i]); \ 21 for (i = 1; i < 32; i++)
21} while(0) 22 err |= __put_user(regs->regs[i], &sc->sc_regs[i]);
22 __put_user(0, &sc->sc_regs[0]); save_gp_reg(1); save_gp_reg(2);
23 save_gp_reg(3); save_gp_reg(4); save_gp_reg(5); save_gp_reg(6);
24 save_gp_reg(7); save_gp_reg(8); save_gp_reg(9); save_gp_reg(10);
25 save_gp_reg(11); save_gp_reg(12); save_gp_reg(13); save_gp_reg(14);
26 save_gp_reg(15); save_gp_reg(16); save_gp_reg(17); save_gp_reg(18);
27 save_gp_reg(19); save_gp_reg(20); save_gp_reg(21); save_gp_reg(22);
28 save_gp_reg(23); save_gp_reg(24); save_gp_reg(25); save_gp_reg(26);
29 save_gp_reg(27); save_gp_reg(28); save_gp_reg(29); save_gp_reg(30);
30 save_gp_reg(31);
31#undef save_gp_reg
32 23
33 err |= __put_user(regs->hi, &sc->sc_mdhi); 24 err |= __put_user(regs->hi, &sc->sc_mdhi);
34 err |= __put_user(regs->lo, &sc->sc_mdlo); 25 err |= __put_user(regs->lo, &sc->sc_mdlo);
@@ -44,24 +35,21 @@ setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
44 35
45 err |= __put_user(!!used_math(), &sc->sc_used_math); 36 err |= __put_user(!!used_math(), &sc->sc_used_math);
46 37
47 if (!used_math()) 38 if (used_math()) {
48 goto out; 39 /*
49 40 * Save FPU state to signal context. Signal handler
50 /* 41 * will "inherit" current FPU state.
51 * Save FPU state to signal context. Signal handler will "inherit" 42 */
52 * current FPU state. 43 preempt_disable();
53 */ 44
54 preempt_disable(); 45 if (!is_fpu_owner()) {
55 46 own_fpu();
56 if (!is_fpu_owner()) { 47 restore_fp(current);
57 own_fpu(); 48 }
58 restore_fp(current); 49 err |= save_fp_context(sc);
50
51 preempt_enable();
59 } 52 }
60 err |= save_fp_context(sc);
61
62 preempt_enable();
63
64out:
65 return err; 53 return err;
66} 54}
67 55
@@ -71,6 +59,7 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
71 unsigned int used_math; 59 unsigned int used_math;
72 unsigned long treg; 60 unsigned long treg;
73 int err = 0; 61 int err = 0;
62 int i;
74 63
75 /* Always make any pending restarted system calls return -EINTR */ 64 /* Always make any pending restarted system calls return -EINTR */
76 current_thread_info()->restart_block.fn = do_no_restart_syscall; 65 current_thread_info()->restart_block.fn = do_no_restart_syscall;
@@ -88,21 +77,8 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
88 err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK); 77 err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK);
89 } 78 }
90 79
91#define restore_gp_reg(i) do { \ 80 for (i = 1; i < 32; i++)
92 err |= __get_user(regs->regs[i], &sc->sc_regs[i]); \ 81 err |= __get_user(regs->regs[i], &sc->sc_regs[i]);
93} while(0)
94 restore_gp_reg( 1); restore_gp_reg( 2); restore_gp_reg( 3);
95 restore_gp_reg( 4); restore_gp_reg( 5); restore_gp_reg( 6);
96 restore_gp_reg( 7); restore_gp_reg( 8); restore_gp_reg( 9);
97 restore_gp_reg(10); restore_gp_reg(11); restore_gp_reg(12);
98 restore_gp_reg(13); restore_gp_reg(14); restore_gp_reg(15);
99 restore_gp_reg(16); restore_gp_reg(17); restore_gp_reg(18);
100 restore_gp_reg(19); restore_gp_reg(20); restore_gp_reg(21);
101 restore_gp_reg(22); restore_gp_reg(23); restore_gp_reg(24);
102 restore_gp_reg(25); restore_gp_reg(26); restore_gp_reg(27);
103 restore_gp_reg(28); restore_gp_reg(29); restore_gp_reg(30);
104 restore_gp_reg(31);
105#undef restore_gp_reg
106 82
107 err |= __get_user(used_math, &sc->sc_used_math); 83 err |= __get_user(used_math, &sc->sc_used_math);
108 conditional_used_math(used_math); 84 conditional_used_math(used_math);