Sat Apr 20 14:09:40 2024 UTC (20d)
Remove some magic numbers by using genassym.cf


(skrll)
diff -r1.4 -r1.5 src/lib/libc/arch/hppa/genassym.cf
diff -r1.9 -r1.10 src/lib/libc/arch/hppa/gen/__setjmp14.S

cvs diff -r1.4 -r1.5 src/lib/libc/arch/hppa/genassym.cf (expand / switch to unified diff)

--- src/lib/libc/arch/hppa/genassym.cf 2022/06/26 14:37:12 1.4
+++ src/lib/libc/arch/hppa/genassym.cf 2024/04/20 14:09:40 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: genassym.cf,v 1.4 2022/06/26 14:37:12 skrll Exp $ 1# $NetBSD: genassym.cf,v 1.5 2024/04/20 14:09:40 skrll Exp $
2 2
3# 3#
4# Copyright (c) 2014 The NetBSD Foundation, Inc. 4# Copyright (c) 2014 The NetBSD Foundation, Inc.
5# All rights reserved. 5# All rights reserved.
6# 6#
7# This code is derived from software contributed to The NetBSD Foundation 7# This code is derived from software contributed to The NetBSD Foundation
8# by Nick Hudson 8# by Nick Hudson
9# 9#
10# Redistribution and use in source and binary forms, with or without 10# Redistribution and use in source and binary forms, with or without
11# modification, are permitted provided that the following conditions 11# modification, are permitted provided that the following conditions
12# are met: 12# are met:
13# 1. Redistributions of source code must retain the above copyright 13# 1. Redistributions of source code must retain the above copyright
14# notice, this list of conditions and the following disclaimer. 14# notice, this list of conditions and the following disclaimer.
@@ -94,13 +94,26 @@ define _UC_GREGS_R18 offsetof(ucontext_t @@ -94,13 +94,26 @@ define _UC_GREGS_R18 offsetof(ucontext_t
94define _UC_GREGS_R19 offsetof(ucontext_t, uc_mcontext.__gregs[19]) 94define _UC_GREGS_R19 offsetof(ucontext_t, uc_mcontext.__gregs[19])
95define _UC_GREGS_R20 offsetof(ucontext_t, uc_mcontext.__gregs[20]) 95define _UC_GREGS_R20 offsetof(ucontext_t, uc_mcontext.__gregs[20])
96define _UC_GREGS_R21 offsetof(ucontext_t, uc_mcontext.__gregs[21]) 96define _UC_GREGS_R21 offsetof(ucontext_t, uc_mcontext.__gregs[21])
97define _UC_GREGS_R22 offsetof(ucontext_t, uc_mcontext.__gregs[22]) 97define _UC_GREGS_R22 offsetof(ucontext_t, uc_mcontext.__gregs[22])
98define _UC_GREGS_R23 offsetof(ucontext_t, uc_mcontext.__gregs[23]) 98define _UC_GREGS_R23 offsetof(ucontext_t, uc_mcontext.__gregs[23])
99define _UC_GREGS_R24 offsetof(ucontext_t, uc_mcontext.__gregs[24]) 99define _UC_GREGS_R24 offsetof(ucontext_t, uc_mcontext.__gregs[24])
100define _UC_GREGS_R25 offsetof(ucontext_t, uc_mcontext.__gregs[25]) 100define _UC_GREGS_R25 offsetof(ucontext_t, uc_mcontext.__gregs[25])
101define _UC_GREGS_R26 offsetof(ucontext_t, uc_mcontext.__gregs[26]) 101define _UC_GREGS_R26 offsetof(ucontext_t, uc_mcontext.__gregs[26])
102define _UC_GREGS_R27 offsetof(ucontext_t, uc_mcontext.__gregs[27]) 102define _UC_GREGS_R27 offsetof(ucontext_t, uc_mcontext.__gregs[27])
103define _UC_GREGS_R28 offsetof(ucontext_t, uc_mcontext.__gregs[28]) 103define _UC_GREGS_R28 offsetof(ucontext_t, uc_mcontext.__gregs[28])
104define _UC_GREGS_R29 offsetof(ucontext_t, uc_mcontext.__gregs[29]) 104define _UC_GREGS_R29 offsetof(ucontext_t, uc_mcontext.__gregs[29])
105define _UC_GREGS_R30 offsetof(ucontext_t, uc_mcontext.__gregs[30]) 105define _UC_GREGS_R30 offsetof(ucontext_t, uc_mcontext.__gregs[30])
106define _UC_GREGS_R31 offsetof(ucontext_t, uc_mcontext.__gregs[31]) 106define _UC_GREGS_R31 offsetof(ucontext_t, uc_mcontext.__gregs[31])
 107
 108define SIZEOF_SIGCONTEXT sizeof(struct sigcontext)
 109define _SC_ONSTACK offsetof(struct sigcontext, sc_onstack)
 110define _SC_MASK13 offsetof(struct sigcontext, __sc_mask13)
 111define _SC_REGS_SP offsetof(struct sigcontext, sc_sp)
 112define _SC_REGS_FP offsetof(struct sigcontext, sc_fp)
 113define _SC_REGS_AP offsetof(struct sigcontext, sc_ap)
 114define _SC_REGS_PCSQH offsetof(struct sigcontext, sc_pcsqh)
 115define _SC_REGS_PCOQH offsetof(struct sigcontext, sc_pcoqh)
 116define _SC_REGS_PCSQT offsetof(struct sigcontext, sc_pcsqt)
 117define _SC_REGS_PCOQT offsetof(struct sigcontext, sc_pcoqt)
 118define _SC_REGS_PS offsetof(struct sigcontext, sc_ps)
 119define _SC_MASK offsetof(struct sigcontext, sc_mask)

cvs diff -r1.9 -r1.10 src/lib/libc/arch/hppa/gen/__setjmp14.S (expand / switch to unified diff)

--- src/lib/libc/arch/hppa/gen/__setjmp14.S 2020/05/05 06:20:55 1.9
+++ src/lib/libc/arch/hppa/gen/__setjmp14.S 2024/04/20 14:09:40 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: __setjmp14.S,v 1.9 2020/05/05 06:20:55 skrll Exp $ */ 1/* $NetBSD: __setjmp14.S,v 1.10 2024/04/20 14:09:40 skrll Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc. 4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matthew Fredette. 8 * by Matthew Fredette.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -19,66 +19,68 @@ @@ -19,66 +19,68 @@
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
 32#include "assym.h"
 33
32#include <machine/asm.h> 34#include <machine/asm.h>
33#include <machine/frame.h> 35#include <machine/frame.h>
34#include <machine/psl.h> 36#include <machine/psl.h>
35 37
36#if defined(LIBC_SCCS) && !defined(lint) 38#if defined(LIBC_SCCS) && !defined(lint)
37 RCSID("$NetBSD: __setjmp14.S,v 1.9 2020/05/05 06:20:55 skrll Exp $") 39 RCSID("$NetBSD: __setjmp14.S,v 1.10 2024/04/20 14:09:40 skrll Exp $")
38#endif /* LIBC_SCCS and not lint */ 40#endif /* LIBC_SCCS and not lint */
39 41
40/* 42/*
41 * C library -- setjmp, longjmp 43 * C library -- setjmp, longjmp
42 * 44 *
43 * longjmp(a,v) 45 * longjmp(a,v)
44 * will generate a "return(v)" from 46 * will generate a "return(v)" from
45 * the last call to 47 * the last call to
46 * setjmp(a) 48 * setjmp(a)
47 * by restoring registers from the stack, 49 * by restoring registers from the stack,
48 * and a struct sigcontext, see <signal.h> 50 * and a struct sigcontext, see <signal.h>
49 */ 51 */
50 52
51ENTRY(__setjmp14,0) 53ENTRY(__setjmp14,0)
52 /* Finish our stack frame. */ 54 /* Finish our stack frame. */
53 stw %rp, HPPA_FRAME_CRP(%sp) 55 stw %rp, HPPA_FRAME_CRP(%sp)
54 stw %arg0, HPPA_FRAME_ARG(0)(%sp) 56 stw %arg0, HPPA_FRAME_ARG(0)(%sp)
55 57
56 /* A sigcontext is at the beginning of our jmp_buf. */ 58 /* A sigcontext is at the beginning of our jmp_buf. */
57 stw %r0, 4(%arg0) ; unused word (old style signal mask) 59 stw %r0, _SC_MASK13(%arg0) ; unused word (old style signal mask)
58 stw %sp, 8(%arg0) ; sc.sc_sp = %sp 60 stw %sp, _SC_REGS_SP(%arg0) ; sc.sc_sp = %sp
59 stw %r0, 16(%arg0) ; sc.sc_ap = NULL 61 stw %r0, _SC_REGS_AP(%arg0) ; sc.sc_ap = NULL
60 mfsp %sr0, %r1 62 mfsp %sr0, %r1
61 stw %r1, 20(%arg0) ; sc.sc_pcsqh = %sr0 63 stw %r1, _SC_REGS_PCSQH(%arg0) ; sc.sc_pcsqh = %sr0
62 stw %rp, 24(%arg0) ; sc.sc_pcoqh = %rp 64 stw %rp, _SC_REGS_PCOQH(%arg0) ; sc.sc_pcoqh = %rp
63 stw %r1, 28(%arg0) ; sc.sc_pcsqh = %sr0 65 stw %r1, _SC_REGS_PCSQT(%arg0) ; sc.sc_pcsqt = %sr0
64 ldo 4(%rp), %r1 66 ldo 4(%rp), %r1
65 stw %r1, 32(%arg0) ; sc.sc_pcoqt = %rp + 4 67 stw %r1, _SC_REGS_PCOQT(%arg0) ; sc.sc_pcoqt = %rp + 4
66 ldil L%PSW_MBS, %r1 68 ldil L%PSW_MBS, %r1
67 ldo R%PSW_MBS(%r1), %r1 69 ldo R%PSW_MBS(%r1), %r1
68 stw %r1, 36(%arg0) ; set sc.sc_ps 70 stw %r1, _SC_REGS_PS(%arg0) ; set sc.sc_ps
69 71
70 /* We store all callee-saved registers after the sigcontext. */ 72 /* We store all callee-saved registers after the sigcontext. */
71 ldo 56(%arg0), %r1 73 ldo SIZEOF_SIGCONTEXT(%arg0), %r1
72 stwm %r3, 4(%r1) 74 stwm %r3, 4(%r1)
73 stwm %r4, 4(%r1) 75 stwm %r4, 4(%r1)
74 stwm %r5, 4(%r1) 76 stwm %r5, 4(%r1)
75 stwm %r6, 4(%r1) 77 stwm %r6, 4(%r1)
76 stwm %r7, 4(%r1) 78 stwm %r7, 4(%r1)
77 stwm %r8, 4(%r1) 79 stwm %r8, 4(%r1)
78 stwm %r9, 4(%r1) 80 stwm %r9, 4(%r1)
79 stwm %r10, 4(%r1) 81 stwm %r10, 4(%r1)
80 stwm %r11, 4(%r1) 82 stwm %r11, 4(%r1)
81 stwm %r12, 4(%r1) 83 stwm %r12, 4(%r1)
82 stwm %r13, 4(%r1) 84 stwm %r13, 4(%r1)
83 stwm %r14, 4(%r1) 85 stwm %r14, 4(%r1)
84 stwm %r15, 4(%r1) 86 stwm %r15, 4(%r1)
@@ -101,27 +103,27 @@ ENTRY(__setjmp14,0) @@ -101,27 +103,27 @@ ENTRY(__setjmp14,0)
101 /* Get signal stack info. */ 103 /* Get signal stack info. */
102 ldo 4(%r3), %arg1 ; set up oss 104 ldo 4(%r3), %arg1 ; set up oss
103 bl __sigaltstack14, %rp 105 bl __sigaltstack14, %rp
104 copy %r0, %arg0 ; set up ss 106 copy %r0, %arg0 ; set up ss
105 107
106 /* Recover our jmp_buf and extract SS_ONSTACK */ 108 /* Recover our jmp_buf and extract SS_ONSTACK */
107 ldw HPPA_FRAME_ARG(0)(%r3), %arg0 109 ldw HPPA_FRAME_ARG(0)(%r3), %arg0
108 ldw 12(%r3), %r1 ; get ss_flags 110 ldw 12(%r3), %r1 ; get ss_flags
109 ldi 1, %r20 ; SS_ONSTACK 111 ldi 1, %r20 ; SS_ONSTACK
110 and %r1, %r20, %r1 112 and %r1, %r20, %r1
111 stw %r1, 0(%arg0) ; sc.sc_onstack 113 stw %r1, 0(%arg0) ; sc.sc_onstack
112 114
113 /* Get the signal mask. */ 115 /* Get the signal mask. */
114 ldo 40(%arg0), %arg2 ; oset = &sc.sc_mask 116 ldo _SC_MASK(%arg0), %arg2 ; oset = &sc.sc_mask
115 copy %r0, %arg1 ; set = NULL 117 copy %r0, %arg1 ; set = NULL
116 bl __sigprocmask14, %rp 118 bl __sigprocmask14, %rp
117 copy %r0, %arg0 ; action = 0 <ignored> 119 copy %r0, %arg0 ; action = 0 <ignored>
118 120
119 /* Return 0. */ 121 /* Return 0. */
120 ldo HPPA_FRAME_SIZE(%r3),%sp 122 ldo HPPA_FRAME_SIZE(%r3),%sp
121 ldwm -HPPA_FRAME_SIZE(%sp),%r3 123 ldwm -HPPA_FRAME_SIZE(%sp),%r3
122 ldw HPPA_FRAME_CRP(%sp), %rp 124 ldw HPPA_FRAME_CRP(%sp), %rp
123 bv %r0(%rp) 125 bv %r0(%rp)
124 copy %r0, %ret0 126 copy %r0, %ret0
125EXIT(__setjmp14) 127EXIT(__setjmp14)
126 128
127 .end 129 .end