Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/compat/arch/arm Use _INVOKE_CERROR() and movs



details:   https://anonhg.NetBSD.org/src/rev/23b3c23b12e7
branches:  trunk
changeset: 789469:23b3c23b12e7
user:      matt <matt%NetBSD.org@localhost>
date:      Mon Aug 19 22:11:50 2013 +0000

description:
Use _INVOKE_CERROR() and movs

diffstat:

 lib/libc/compat/arch/arm/gen/compat_setjmp.S      |  96 ++++++++++++++++------
 lib/libc/compat/arch/arm/gen/compat_sigsetjmp.S   |  46 +++++++++-
 lib/libc/compat/arch/arm/sys/compat_Ovfork.S      |  16 +--
 lib/libc/compat/arch/arm/sys/compat___sigtramp1.S |   5 +-
 lib/libc/compat/arch/arm/sys/compat_sigpending.S  |   7 +-
 lib/libc/compat/arch/arm/sys/compat_sigprocmask.S |  36 ++++++-
 lib/libc/compat/arch/arm/sys/compat_sigsuspend.S  |   7 +-
 7 files changed, 154 insertions(+), 59 deletions(-)

diffs (truncated from 349 to 300 lines):

diff -r 55844af1e63b -r 23b3c23b12e7 lib/libc/compat/arch/arm/gen/compat_setjmp.S
--- a/lib/libc/compat/arch/arm/gen/compat_setjmp.S      Mon Aug 19 22:10:51 2013 +0000
+++ b/lib/libc/compat/arch/arm/gen/compat_setjmp.S      Mon Aug 19 22:11:50 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_setjmp.S,v 1.2 2013/01/11 13:55:26 matt Exp $   */
+/*     $NetBSD: compat_setjmp.S,v 1.3 2013/08/19 22:11:50 matt Exp $   */
 
 /*
  * Copyright (c) 1997 Mark Brinicombe
@@ -47,14 +47,12 @@
 
 ENTRY(setjmp)
        /* Block all signals and retrieve the old signal mask */
-       stmfd   sp!, {r0, r14}
-       mov     r0, #0x00000000
+       push    {r0, lr}
+       movs    r0, #0x00000000
 
        bl      PIC_SYM(_C_LABEL(sigblock), PLT)
        mov     r1, r0
 
-       ldmfd   sp!, {r0, r14}
-
        /* Store signal mask */
        str     r1, [r0, #(_JB_SIGMASK * 4)]
 
@@ -62,52 +60,96 @@
        str     r1, [r0]
 
        /* Store integer registers */
-       add     r0, r0, #(_JB_REG_R4 * 4)
-        stmia  r0, {r4-r14}
-        mov    r0, #0x00000000
-        RET
-
-.Lsetjmp_magic:
-       .word   _JB_MAGIC_SETJMP
-
+       adds    r0, r0, #(_JB_REG_R4 * 4)
+#ifdef __thumb__
+#ifdef _ARM_ARCH_7
+        stmia  r0!, {r4-r12}
+       str     sp, [r0, #0]
+       str     lr, [r0, #4]
+#else
+        stmia  r0!, {r4-r7}
+       mov     r2, r8
+       mov     r3, r9
+       stmia   r0!, {r2-r3}
+       mov     r1, r10
+       mov     r2, r11
+       mov     r3, r12
+       stmia   r0!, {r1-r3}
+       mov     r2, sp
+       mov     r3, lr
+       stmia   r0!, {r2-r3}
+#endif
+#else
+        stmia  r0, {r4-lr}
+#endif
+        movs   r0, #0
+       pop     {r3, pc}
+END(setjmp)
 
 ENTRY(longjmp)
        ldr     r2, .Lsetjmp_magic
        ldr     r3, [r0]
-       teq     r2, r3
+       cmp     r2, r3
        bne     botch
 
        /* Fetch signal mask */
        ldr     r2, [r0, #(_JB_SIGMASK * 4)]
 
        /* Set signal mask */
-       stmfd   sp!, {r0, r1, r14}
-       sub     sp, sp, #4      /* align the stack */
+       push    {r0, r1}        /* don't care about lr */
 
        mov     r0, r2
        bl      PIC_SYM(_C_LABEL(sigsetmask), PLT)
 
-       add     sp, sp, #4      /* unalign the stack */
-       ldmfd   sp!, {r0, r1, r14} 
+       pop     {r0, r1} 
 
        /* Restore integer registers */
-       add     r0, r0, #(_JB_REG_R4 * 4)
-        ldmia  r0, {r4-r14}
+       adds    r0, r0, #(_JB_REG_R4 * 4)
+#if !defined(__thumb__) || defined(_ARM_ARCH_7)
+        ldmia  r0!, {r4-r12}
+#else
+        ldmia  r0!, {r4-r7}
+        ldmia  r0!, {r2-r3}
+       mov     r8, r2
+       mov     r9, r3
+        ldmia  r0!, {r1-r3}
+       mov     r10, r2
+       mov     r11, r3
+        ldmia  r0!, {r2}
+       mov     r12, r2
+#endif
 
-       /* Validate sp and r14 */
-       teq     sp, #0
-       teqne   r14, #0
+       ldmia   r0!, {r2-r3}    /* r2 = sp, r3 = lr */
+
+       /* Validate sp */
+       cmp     r2, #0
        beq     botch
+       mov     sp, r2
+
+       /* Validate lr */
+       cmp     r3, #0
+       beq     botch
+       mov     lr, r3
 
        /* Set return value */
-
        mov     r0, r1
-       teq     r0, #0x00000000
-       moveq   r0, #0x00000001
+       cmp     r0, #0
+#ifdef __thumb__
+       bne     1f
+       movs    r0, #1
+1:
+#else
+       moveq   r0, #1
+#endif
        RET
 
        /* validation failed, die die die. */
 botch:
        bl      PIC_SYM(_C_LABEL(longjmperror), PLT)
        bl      PIC_SYM(_C_LABEL(abort), PLT)
-       b       . - 8           /* Cannot get here */
+2:     b       2b              /* Cannot get here */
+
+       .align  0
+.Lsetjmp_magic:
+       .word   _JB_MAGIC_SETJMP
+END(longjmp)
diff -r 55844af1e63b -r 23b3c23b12e7 lib/libc/compat/arch/arm/gen/compat_sigsetjmp.S
--- a/lib/libc/compat/arch/arm/gen/compat_sigsetjmp.S   Mon Aug 19 22:10:51 2013 +0000
+++ b/lib/libc/compat/arch/arm/gen/compat_sigsetjmp.S   Mon Aug 19 22:11:50 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_sigsetjmp.S,v 1.1 2005/10/16 17:27:50 christos Exp $    */
+/*     $NetBSD: compat_sigsetjmp.S,v 1.2 2013/08/19 22:11:50 matt Exp $        */
 
 /*
  * Copyright (c) 1997 Mark Brinicombe
@@ -46,16 +46,46 @@
  */
 
 ENTRY(sigsetjmp)
-       teq     r1, #0
-       beq     PIC_SYM(_C_LABEL(_setjmp), PLT)
-       b       PIC_SYM(_C_LABEL(setjmp), PLT)
-
-.L_setjmp_magic:
-       .word   _JB_MAGIC__SETJMP
+#if defined(__thumb__) && defined(_ARM_ARCH_T2)
+       cbnz    r1, 1f
+       b       PLT_SYM(_C_LABEL(_setjmp))
+1:     b       PLT_SYM(_C_LABEL(setjmp))
+#elif !defined(__thumb__)
+       cmp     r1, #0
+       beq     PLT_SYM(_C_LABEL(_setjmp))
+       b       PLT_SYM(_C_LABEL(setjmp))
+#else
+       push    {r3, lr}
+       beq     1f
+       bl      PLT_SYM(_C_LABEL(setjmp))
+       pop     {r3, pc}
+1:     bl      PLT_SYM(_C_LABEL(_setjmp))
+       pop     {r3, pc}
+#endif
+END(sigsetjmp)
 
 ENTRY(siglongjmp)
        ldr     r2, .L_setjmp_magic
        ldr     r3, [r0]
-       teq     r2, r3
+       cmp     r2, r3
+#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
+#if defined(__thumb__)
+       it      eq
+#endif
        beq     PIC_SYM(_C_LABEL(_longjmp), PLT)
        b       PIC_SYM(_C_LABEL(longjmp), PLT)
+#else
+       push    {lr}
+       sub     sp, sp, #4
+       beq     1f
+       bl      PIC_SYM(_C_LABEL(longjmp), PLT)
+       b       2f
+1:     bl      PIC_SYM(_C_LABEL(_longjmp), PLT)
+2:     add     sp, sp, #4
+       pop     {pc}
+#endif
+
+       .align  0
+.L_setjmp_magic:
+       .word   _JB_MAGIC__SETJMP
+END(siglongjmp)
diff -r 55844af1e63b -r 23b3c23b12e7 lib/libc/compat/arch/arm/sys/compat_Ovfork.S
--- a/lib/libc/compat/arch/arm/sys/compat_Ovfork.S      Mon Aug 19 22:10:51 2013 +0000
+++ b/lib/libc/compat/arch/arm/sys/compat_Ovfork.S      Mon Aug 19 22:11:50 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_Ovfork.S,v 1.2 2013/08/01 05:54:24 matt Exp $   */
+/*     $NetBSD: compat_Ovfork.S,v 1.3 2013/08/19 22:11:50 matt Exp $   */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -43,14 +43,12 @@
  * r1 == 0 in parent process, r1 == 1 in child process.
  * r0 == pid of child in parent, r0 == pid of parent in child.
  */
-       .text
-       .align  0
-
 ENTRY(vfork)
-       mov     r2, r14
+       mov     r2, lr
        SYSTRAP(vfork)
-       bcs     CERROR
-       mov     r14, r2
-       sub     r1, r1, #1      /* r1 == 0xffffffff if parent, 0 if child */
-       and     r0, r0, r1      /* r0 == 0 if child, else unchanged */
+       _INVOKE_CERROR()
+       mov     lr, r2
+       subs    r1, r1, #1      /* r1 == 0xffffffff if parent, 0 if child */
+       ands    r0, r0, r1      /* r0 == 0 if child, else unchanged */
        RET
+END(vfork)
diff -r 55844af1e63b -r 23b3c23b12e7 lib/libc/compat/arch/arm/sys/compat___sigtramp1.S
--- a/lib/libc/compat/arch/arm/sys/compat___sigtramp1.S Mon Aug 19 22:10:51 2013 +0000
+++ b/lib/libc/compat/arch/arm/sys/compat___sigtramp1.S Mon Aug 19 22:11:50 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat___sigtramp1.S,v 1.2 2008/04/28 20:22:58 martin Exp $    */
+/*     $NetBSD: compat___sigtramp1.S,v 1.3 2013/08/19 22:11:50 matt Exp $      */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -39,9 +39,10 @@
  *
  *     sp->    sigcontext structure
  */
-ENTRY_NP(__sigtramp_sigcontext_1)
+ENTRY(__sigtramp_sigcontext_1)
        mov     r0, sp                  /* get pointer to sigcontext */
        SYSTRAP(compat_16___sigreturn14) /* and call sigreturn */
 
        /* If that failed, exit with the error code. */
        SYSTRAP(exit)
+END(__sigtramp_sigcontext_1)
diff -r 55844af1e63b -r 23b3c23b12e7 lib/libc/compat/arch/arm/sys/compat_sigpending.S
--- a/lib/libc/compat/arch/arm/sys/compat_sigpending.S  Mon Aug 19 22:10:51 2013 +0000
+++ b/lib/libc/compat/arch/arm/sys/compat_sigpending.S  Mon Aug 19 22:11:50 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_sigpending.S,v 1.2 2013/08/01 05:54:24 matt Exp $       */
+/*     $NetBSD: compat_sigpending.S,v 1.3 2013/08/19 22:11:50 matt Exp $       */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -39,7 +39,8 @@
 ENTRY(sigpending)
        mov     r2, r0
        SYSTRAP(compat_13_sigpending13)
-       bcs     CERROR
+       _INVOKE_CERROR()
        str     r0, [r2]
-       mov     r0, #0x00000000
+       movs    r0, #0
        RET
+END(sigpending)
diff -r 55844af1e63b -r 23b3c23b12e7 lib/libc/compat/arch/arm/sys/compat_sigprocmask.S
--- a/lib/libc/compat/arch/arm/sys/compat_sigprocmask.S Mon Aug 19 22:10:51 2013 +0000
+++ b/lib/libc/compat/arch/arm/sys/compat_sigprocmask.S Mon Aug 19 22:11:50 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_sigprocmask.S,v 1.2 2013/08/01 05:54:24 matt Exp $      */
+/*     $NetBSD: compat_sigprocmask.S,v 1.3 2013/08/19 22:11:50 matt Exp $      */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -37,13 +37,35 @@
     "warning: reference to compatibility sigprocmask(); include <signal.h> for correct reference")
 
 ENTRY(sigprocmask)
-       teq     r1, #0x00000000
-       moveq   r0, #0x00000001
-       moveq   r1, #0x00000000
+       cmp     r1, #0
+#if defined(_ARM_ARCH_7) || !defined(__thumb__)
+#ifdef __thumb__
+       itte    eq
+#endif



Home | Main Index | Thread Index | Old Index