linux-mips
[Top] [All Lists]

[PATCH 1/7] signals: reduce {setup,restore}_sigcontext sizes

To: ralf@linux-mips.org
Subject: [PATCH 1/7] signals: reduce {setup,restore}_sigcontext sizes
From: Franck Bui-Huu <vagabon.xyz@gmail.com>
Date: Tue, 23 Jan 2007 15:18:17 +0100
Cc: linux-mips@linux-mips.org, Franck Bui-Huu <fbuihuu@gmail.com>
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:to:cc:subject:date:message-id:x-mailer:in-reply-to:references:from; b=tmgXuNuhnqH+K3Hs2iF+EHeu97VXYCiRc0rm4Ep/VYs9xhdchuBt//vSQKNI2xvF812Nky/uRKldhQgx7YyO077qp03TlRTr1qjRn0QOlB8x/hW3oRnNNsnmop9QE3d43p1BuX64YEEb380vLYQ1D6PWPXN0oWBh21i8KnnYqqg=
In-reply-to: <1169561903878-git-send-email-fbuihuu@gmail.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1169561903878-git-send-email-fbuihuu@gmail.com>
Sender: linux-mips-bounce@linux-mips.org
From: Franck Bui-Huu <fbuihuu@gmail.com>

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>
---
 arch/mips/kernel/signal-common.h |   35 +++++++----------------------------
 1 files changed, 7 insertions(+), 28 deletions(-)

diff --git a/arch/mips/kernel/signal-common.h b/arch/mips/kernel/signal-common.h
index b1f09d5..d56897e 100644
--- a/arch/mips/kernel/signal-common.h
+++ b/arch/mips/kernel/signal-common.h
@@ -13,22 +13,13 @@ static inline int
 setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
 {
        int err = 0;
+       int i;
 
        err |= __put_user(regs->cp0_epc, &sc->sc_pc);
 
-#define save_gp_reg(i) do {                                            \
-       err |= __put_user(regs->regs[i], &sc->sc_regs[i]);              \
-} while(0)
-       __put_user(0, &sc->sc_regs[0]); save_gp_reg(1); save_gp_reg(2);
-       save_gp_reg(3); save_gp_reg(4); save_gp_reg(5); save_gp_reg(6);
-       save_gp_reg(7); save_gp_reg(8); save_gp_reg(9); save_gp_reg(10);
-       save_gp_reg(11); save_gp_reg(12); save_gp_reg(13); save_gp_reg(14);
-       save_gp_reg(15); save_gp_reg(16); save_gp_reg(17); save_gp_reg(18);
-       save_gp_reg(19); save_gp_reg(20); save_gp_reg(21); save_gp_reg(22);
-       save_gp_reg(23); save_gp_reg(24); save_gp_reg(25); save_gp_reg(26);
-       save_gp_reg(27); save_gp_reg(28); save_gp_reg(29); save_gp_reg(30);
-       save_gp_reg(31);
-#undef save_gp_reg
+       err |= __put_user(0, &sc->sc_regs[0]);
+       for (i = 1; i < 32; i++)
+               err |= __put_user(regs->regs[i], &sc->sc_regs[i]);
 
        err |= __put_user(regs->hi, &sc->sc_mdhi);
        err |= __put_user(regs->lo, &sc->sc_mdlo);
@@ -71,6 +62,7 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext 
__user *sc)
        unsigned int used_math;
        unsigned long treg;
        int err = 0;
+       int i;
 
        /* Always make any pending restarted system calls return -EINTR */
        current_thread_info()->restart_block.fn = do_no_restart_syscall;
@@ -88,21 +80,8 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext 
__user *sc)
                err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK);
        }
 
-#define restore_gp_reg(i) do {                                         \
-       err |= __get_user(regs->regs[i], &sc->sc_regs[i]);              \
-} while(0)
-       restore_gp_reg( 1); restore_gp_reg( 2); restore_gp_reg( 3);
-       restore_gp_reg( 4); restore_gp_reg( 5); restore_gp_reg( 6);
-       restore_gp_reg( 7); restore_gp_reg( 8); restore_gp_reg( 9);
-       restore_gp_reg(10); restore_gp_reg(11); restore_gp_reg(12);
-       restore_gp_reg(13); restore_gp_reg(14); restore_gp_reg(15);
-       restore_gp_reg(16); restore_gp_reg(17); restore_gp_reg(18);
-       restore_gp_reg(19); restore_gp_reg(20); restore_gp_reg(21);
-       restore_gp_reg(22); restore_gp_reg(23); restore_gp_reg(24);
-       restore_gp_reg(25); restore_gp_reg(26); restore_gp_reg(27);
-       restore_gp_reg(28); restore_gp_reg(29); restore_gp_reg(30);
-       restore_gp_reg(31);
-#undef restore_gp_reg
+       for (i = 1; i < 32; i++)
+               err |= __get_user(regs->regs[i], &sc->sc_regs[i]);
 
        err |= __get_user(used_math, &sc->sc_used_math);
        conditional_used_math(used_math);
-- 
1.4.4.3.ge6d4


<Prev in Thread] Current Thread [Next in Thread>