1/* $OpenBSD: sigsetjmp.S,v 1.4 2022/12/08 02:11:27 guenther Exp $ */ 2/* $NetBSD: sigsetjmp.S,v 1.9 2006/01/05 19:21:37 uwe Exp $ */ 3 4/*- 5 * Copyright (c) 1990 The Regents of the University of California. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * William Jolitz. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. Neither the name of the University nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90 36 */ 37 38#include "SYS.h" 39 40#include <machine/setjmp.h> 41 42ENTRY(sigsetjmp) 43 tst r5, r5 /* if (savemask == 0) */ 44 bt 2f 45 46 /* identical to setjmp */ 47 PIC_PROLOGUE(.L_got_1) 48 sts.l pr, @-sp 49 mov.l r4, @-sp 50 mov.l r5, @-sp 51 52 mov.l .L_sigprocmask_1, r0 53 mov r4, r6 54 mov #1, r4 /* how = SIG_BLOCK */ 55 mov #0, r5 /* new = NULL */ 561: CALL r0 57 add #4, r6 /* old = &sigmask */ 58 59 mov.l @sp+, r5 60 mov.l @sp+, r4 61 lds.l @sp+, pr 62 PIC_EPILOGUE 63 642: /* identical to _setjmp except that first word is in r5 */ 65#if defined(__SH4__) && !defined(__SH4_NOFPU__) 66 add #(_JBLEN * 4), r4 67 sts fpscr, r1 68 xor r0, r0 69 mov.l r1, @-r4 70 lds r0, fpscr 71 sts.l fpul, @-r4 72 fmov.s fr15, @-r4 73 fmov.s fr14, @-r4 74 fmov.s fr13, @-r4 75 fmov.s fr12, @-r4 76 frchg 77 fmov.s fr15, @-r4 78 fmov.s fr14, @-r4 79 fmov.s fr13, @-r4 80 fmov.s fr12, @-r4 81 lds r1, fpscr 82#else 83 add #((_JBLEN - 10) * 4), r4 84#endif 85 sts.l mach, @-r4 86 sts.l macl, @-r4 87 mov.l r15, @-r4 88 mov.l r14, @-r4 89 mov.l r13, @-r4 90 mov.l r12, @-r4 91 mov.l r11, @-r4 92 mov.l r10, @-r4 93 mov.l r9, @-r4 94 mov.l r8, @-r4 95 sts.l pr, @-r4 96 add #-4, r4 /* skip signal mask */ 97 mov.l r5, @-r4 /* has signal mask? */ 98 rts 99 xor r0, r0 100 101 .align 2 102.L_got_1: PIC_GOT_DATUM 103.L_sigprocmask_1: CALL_DATUM(_HIDDEN(sigprocmask), 1b) 104 SET_ENTRY_SIZE(sigsetjmp) 105 106ENTRY(siglongjmp) 107 mov.l @r4+, r0 108 tst r0, r0 109 bt 2f /* if no mask */ 110 111 /* identical to longjmp */ 112 /* we won't return here, so we don't need to save pr and r12 */ 113 PIC_PROLOGUE_NOSAVE(.L_got_2) 114 mov.l r5, @-sp 115 mov.l r4, @-sp 116 117 mov.l .L_sigprocmask_2, r0 118 mov r4, r5 /* new = &sigmask */ 119 mov #3, r4 /* how = SIG_SETMASK */ 1201: CALL r0 121 mov #0, r6 /* old = NULL */ 122 123 mov.l @sp+, r4 124 mov.l @sp+, r5 125 1262: /* identical to _longjmp */ 127 add #4, r4 128 lds.l @r4+, pr 129 mov.l @r4+, r8 130 mov.l @r4+, r9 131 mov.l @r4+, r10 132 mov.l @r4+, r11 133 mov.l @r4+, r12 134 mov.l @r4+, r13 135 mov.l @r4+, r14 136 mov.l @r4+, r15 137 lds.l @r4+, macl 138 lds.l @r4+, mach 139#if defined(__SH4__) && !defined(__SH4_NOFPU__) 140 xor r0, r0 141 lds r0, fpscr 142 frchg 143 fmov.s @r4+, fr12 144 fmov.s @r4+, fr13 145 fmov.s @r4+, fr14 146 fmov.s @r4+, fr15 147 frchg 148 fmov.s @r4+, fr12 149 fmov.s @r4+, fr13 150 fmov.s @r4+, fr14 151 fmov.s @r4+, fr15 152 lds.l @r4+, fpul 153 lds.l @r4+, fpscr 154#endif 155 156 mov r5, r0 157 tst r0, r0 /* make sure return value is non-zero */ 158 bf .L0 159 add #1, r0 160.L0: 161 rts 162 nop 163 164 .align 2 165.L_got_2: PIC_GOT_DATUM 166.L_sigprocmask_2: CALL_DATUM(_HIDDEN(sigprocmask), 1b) 167 SET_ENTRY_SIZE(siglongjmp) 168