Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/arch/alpha - Consistently use _REG_* defines from a...



details:   https://anonhg.NetBSD.org/src/rev/6b84535d2523
branches:  trunk
changeset: 956089:6b84535d2523
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Oct 21 01:24:04 2020 +0000

description:
- Consistently use _REG_* defines from assym.h to mean register numbers,
  not offsets (i.e. *8 to get the offset).
- Define and use SIZEOF_SIGINFO and UC_GREGS constants, rather than
  hard-code magic numbers.

NFC -- same object code is generated.

diffstat:

 lib/libc/arch/alpha/gen/__setjmp14.S  |  28 ++++++------
 lib/libc/arch/alpha/gen/swapcontext.S |   9 ++-
 lib/libc/arch/alpha/genassym.cf       |  76 ++++++++++++++++++----------------
 lib/libc/arch/alpha/sys/__sigtramp2.S |   5 +-
 lib/libc/arch/alpha/sys/getcontext.S  |   7 +-
 5 files changed, 66 insertions(+), 59 deletions(-)

diffs (236 lines):

diff -r 7d670b37f244 -r 6b84535d2523 lib/libc/arch/alpha/gen/__setjmp14.S
--- a/lib/libc/arch/alpha/gen/__setjmp14.S      Tue Oct 20 23:27:57 2020 +0000
+++ b/lib/libc/arch/alpha/gen/__setjmp14.S      Wed Oct 21 01:24:04 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: __setjmp14.S,v 1.7 2014/01/23 03:08:50 christos Exp $ */
+/* $NetBSD: __setjmp14.S,v 1.8 2020/10/21 01:24:05 thorpej Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
@@ -46,16 +46,16 @@
 LEAF(__setjmp14, 1)
        LDGP(pv)
        stq     ra, SC_PC(a0)                   /* sc_pc = return address */
-       stq     s0, (SC_REGS+_REG_S0)(a0)       /* saved bits of sc_regs */
-       stq     s1, (SC_REGS+_REG_S1)(a0)
-       stq     s2, (SC_REGS+_REG_S2)(a0)
-       stq     s3, (SC_REGS+_REG_S3)(a0)
-       stq     s4, (SC_REGS+_REG_S4)(a0)
-       stq     s5, (SC_REGS+_REG_S5)(a0)
-       stq     s6, (SC_REGS+_REG_S6)(a0)
-       stq     ra, (SC_REGS+_REG_RA)(a0)
-       stq     sp, (SC_REGS+_REG_SP)(a0)
-       stq     gp, (SC_REGS+_REG_GP)(a0)
+       stq     s0, (SC_REGS+_REG_S0*8)(a0)     /* saved bits of sc_regs */
+       stq     s1, (SC_REGS+_REG_S1*8)(a0)
+       stq     s2, (SC_REGS+_REG_S2*8)(a0)
+       stq     s3, (SC_REGS+_REG_S3*8)(a0)
+       stq     s4, (SC_REGS+_REG_S4*8)(a0)
+       stq     s5, (SC_REGS+_REG_S5*8)(a0)
+       stq     s6, (SC_REGS+_REG_S6*8)(a0)
+       stq     ra, (SC_REGS+_REG_RA*8)(a0)
+       stq     sp, (SC_REGS+_REG_SP*8)(a0)
+       stq     gp, (SC_REGS+_REG_GP*8)(a0)
 
        /*
         * get signal information
@@ -74,7 +74,7 @@
        CALL(__sigaltstack14)
        ldl     t0, 16(sp)                      /* offset of ss_flags */
        lda     sp, 24(sp)                      /* sizeof struct sigaltstack */
-       ldq     ra, (SC_REGS+_REG_RA)(s0)       /* restore return address */
+       ldq     ra, (SC_REGS+_REG_RA*8)(s0)     /* restore return address */
        blt     v0, botch                       /* check for error */
        and     t0, 0x1, t0                     /* get SA_ONSTACK flag */
        stq     t0, SC_ONSTACK(s0)              /* and save it in sc_onstack */
@@ -82,10 +82,10 @@
         * Restore old s0 and a0, and continue saving registers
         */
        mov     s0, a0
-       ldq     s0, (SC_REGS+_REG_S0)(a0)
+       ldq     s0, (SC_REGS+_REG_S0*8)(a0)
 
        ldq     t0, magic                       /* sigcontext magic number */
-       stq     t0, (SC_REGS+_REG_UNIQUE)(a0)   /* magic in sc_regs[31] */
+       stq     t0, (SC_REGS+_REG_UNIQUE*8)(a0) /* magic in sc_regs[31] */
        /* Too bad we can't check if we actually used FP */
        ldiq    t0, 1
        stq     t0, SC_OWNEDFP(a0)              /* say we've used FP.  */
diff -r 7d670b37f244 -r 6b84535d2523 lib/libc/arch/alpha/gen/swapcontext.S
--- a/lib/libc/arch/alpha/gen/swapcontext.S     Tue Oct 20 23:27:57 2020 +0000
+++ b/lib/libc/arch/alpha/gen/swapcontext.S     Wed Oct 21 01:24:04 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: swapcontext.S,v 1.3 2008/04/28 20:22:55 martin Exp $   */
+/*     $NetBSD: swapcontext.S,v 1.4 2020/10/21 01:24:05 thorpej Exp $  */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,6 +30,7 @@
  */
 
 #include "SYS.h"
+#include "assym.h"
 
 NESTED(swapcontext, 2, 24, ra, IM_RA|IM_A0|IM_A1, 0)
        LDGP(pv)
@@ -41,10 +42,10 @@
        ldq     t0, (24-16)(sp)
        bne     v0, Lerr
        ldq     t1, (24- 8)(sp)
-       stq     t1, (56 + 26 * 8)(t0)   /* Adjust saved RA */
-       stq     t1, (56 + 32 * 8)(t0)   /* Adjust saved PC */
+       stq     t1, (UC_GREGS + _REG_RA*8)(t0)  /* Adjust saved RA */
+       stq     t1, (UC_GREGS + _REG_PC*8)(t0)  /* Adjust saved PC */
        lda     t1, 24(sp)
-       stq     t1, (56 + 30 * 8)(t0)   /* Adjust saved SP */
+       stq     t1, (UC_GREGS + _REG_SP*8)(t0)  /* Adjust saved SP */
 
        ldq     a0, (24-24)(sp)
        CALL(setcontext)                /* setcontext(ucp) */
diff -r 7d670b37f244 -r 6b84535d2523 lib/libc/arch/alpha/genassym.cf
--- a/lib/libc/arch/alpha/genassym.cf   Tue Oct 20 23:27:57 2020 +0000
+++ b/lib/libc/arch/alpha/genassym.cf   Wed Oct 21 01:24:04 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: genassym.cf,v 1.2 2008/04/28 20:22:55 martin Exp $
+#      $NetBSD: genassym.cf,v 1.3 2020/10/21 01:24:04 thorpej Exp $
 
 #
 # Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -34,41 +34,41 @@
 include <ucontext.h>
 include <signal.h>
 
-define _REG_V0         8*_REG_V0       /* 0 */
-define _REG_T0         8*_REG_T0       /* 1 */
-define _REG_T1         8*_REG_T1       /* 2 */
-define _REG_T2         8*_REG_T2       /* 3 */
-define _REG_T3         8*_REG_T3       /* 4 */
-define _REG_T4         8*_REG_T4       /* 5 */
-define _REG_T5         8*_REG_T5       /* 6 */
-define _REG_T6         8*_REG_T6       /* 7 */
-define _REG_T7         8*_REG_T7       /* 8 */
-define _REG_S0         8*_REG_S0       /* 9 */
-define _REG_S1         8*_REG_S1       /* 10 */
-define _REG_S2         8*_REG_S2       /* 11 */
-define _REG_S3         8*_REG_S3       /* 12 */
-define _REG_S4         8*_REG_S4       /* 13 */
-define _REG_S5         8*_REG_S5       /* 14 */
-define _REG_S6         8*_REG_S6       /* 15 */
-define _REG_A0         8*_REG_A0       /* 16 */
-define _REG_A1         8*_REG_A1       /* 17 */
-define _REG_A2         8*_REG_A2       /* 18 */
-define _REG_A3         8*_REG_A3       /* 19 */
-define _REG_A4         8*_REG_A4       /* 20 */
-define _REG_A5         8*_REG_A5       /* 21 */
-define _REG_T8         8*_REG_T8       /* 22 */
-define _REG_T9         8*_REG_T9       /* 23 */
-define _REG_T10                8*_REG_T10      /* 24 */
-define _REG_T11                8*_REG_T11      /* 25 */
-define _REG_RA         8*_REG_RA       /* 26 */
-define _REG_T12                8*_REG_T12      /* 27 */
-define _REG_PV         8*_REG_PV       /* 27 */
-define _REG_AT         8*_REG_AT       /* 28 */
-define _REG_GP         8*_REG_GP       /* 29 */
-define _REG_SP         8*_REG_SP       /* 30 */
-define _REG_UNIQUE     8*_REG_UNIQUE   /* 31 */
-define _REG_PC         8*_REG_PC       /* 32 */
-define _REG_PS         8*_REG_PS       /* 33 */
+define _REG_V0         _REG_V0         /* 0 */
+define _REG_T0         _REG_T0         /* 1 */
+define _REG_T1         _REG_T1         /* 2 */
+define _REG_T2         _REG_T2         /* 3 */
+define _REG_T3         _REG_T3         /* 4 */
+define _REG_T4         _REG_T4         /* 5 */
+define _REG_T5         _REG_T5         /* 6 */
+define _REG_T6         _REG_T6         /* 7 */
+define _REG_T7         _REG_T7         /* 8 */
+define _REG_S0         _REG_S0         /* 9 */
+define _REG_S1         _REG_S1         /* 10 */
+define _REG_S2         _REG_S2         /* 11 */
+define _REG_S3         _REG_S3         /* 12 */
+define _REG_S4         _REG_S4         /* 13 */
+define _REG_S5         _REG_S5         /* 14 */
+define _REG_S6         _REG_S6         /* 15 */
+define _REG_A0         _REG_A0         /* 16 */
+define _REG_A1         _REG_A1         /* 17 */
+define _REG_A2         _REG_A2         /* 18 */
+define _REG_A3         _REG_A3         /* 19 */
+define _REG_A4         _REG_A4         /* 20 */
+define _REG_A5         _REG_A5         /* 21 */
+define _REG_T8         _REG_T8         /* 22 */
+define _REG_T9         _REG_T9         /* 23 */
+define _REG_T10                _REG_T10        /* 24 */
+define _REG_T11                _REG_T11        /* 25 */
+define _REG_RA         _REG_RA         /* 26 */
+define _REG_T12                _REG_T12        /* 27 */
+define _REG_PV         _REG_PV         /* 27 */
+define _REG_AT         _REG_AT         /* 28 */
+define _REG_GP         _REG_GP         /* 29 */
+define _REG_SP         _REG_SP         /* 30 */
+define _REG_UNIQUE     _REG_UNIQUE     /* 31 */
+define _REG_PC         _REG_PC         /* 32 */
+define _REG_PS         _REG_PS         /* 33 */
 
 define SC_ONSTACK      offsetof(struct sigcontext, sc_onstack)
 define SC_SP           offsetof(struct sigcontext, sc_sp)
@@ -82,3 +82,7 @@
 define SC_MASK         offsetof(struct sigcontext, sc_mask)
 define SC_RESERVED     offsetof(struct sigcontext, sc_reserved)
 define SC_XXX          offsetof(struct sigcontext, sc_xxx)
+
+define SIZEOF_SIGINFO  sizeof(siginfo_t)
+
+define UC_GREGS        offsetof(ucontext_t, uc_mcontext.__gregs)
diff -r 7d670b37f244 -r 6b84535d2523 lib/libc/arch/alpha/sys/__sigtramp2.S
--- a/lib/libc/arch/alpha/sys/__sigtramp2.S     Tue Oct 20 23:27:57 2020 +0000
+++ b/lib/libc/arch/alpha/sys/__sigtramp2.S     Wed Oct 21 01:24:04 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: __sigtramp2.S,v 1.2 2006/11/08 21:16:40 drochner Exp $ */
+/*     $NetBSD: __sigtramp2.S,v 1.3 2020/10/21 01:24:05 thorpej Exp $  */
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -28,6 +28,7 @@
  */
 
 #include "SYS.h"
+#include "assym.h"
 
 /*
  * The Alpha signal trampoline is invoked only to return from
@@ -40,7 +41,7 @@
  */
 NESTED_NOPROFILE(__sigtramp_siginfo_2,0,0,ra,0,0)
        ldgp    gp,0(ra)
-       lda     a0,(128)(sp)            /* get pointer to ucontext */
+       lda     a0,(SIZEOF_SIGINFO)(sp) /* get pointer to ucontext */
        CALLSYS_NOERROR(setcontext)     /* and call setcontext() with it */
        ldiq    a0,-1                   /* if that failed, set an exit code */
        CALLSYS_NOERROR(exit)           /* and call exit() */
diff -r 7d670b37f244 -r 6b84535d2523 lib/libc/arch/alpha/sys/getcontext.S
--- a/lib/libc/arch/alpha/sys/getcontext.S      Tue Oct 20 23:27:57 2020 +0000
+++ b/lib/libc/arch/alpha/sys/getcontext.S      Wed Oct 21 01:24:04 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getcontext.S,v 1.3 2008/04/28 20:22:55 martin Exp $    */
+/*     $NetBSD: getcontext.S,v 1.4 2020/10/21 01:24:05 thorpej Exp $   */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,6 +30,7 @@
  */
 
 #include "SYS.h"
+#include "assym.h"
 
 #ifdef WEAK_ALIAS
 WEAK_ALIAS(getcontext, _getcontext)
@@ -37,7 +38,7 @@
 
 LEAF(_getcontext, 1)
        CALLSYS_ERROR(getcontext)
-       stq     ra, (56 + 32 * 8)(a0)   /* Adjust saved PC */
-       stq     zero, (56 + 0 * 8)(a0)  /* Arrange for a return value of 0 */
+       stq     ra, (UC_GREGS + _REG_PC*8)(a0)  /* Adjust saved PC */
+       stq     zero, (UC_GREGS + _REG_V0*8)(a0)/* Arrange for a rv of 0 */
        RET
 END(_getcontext)



Home | Main Index | Thread Index | Old Index