1*0ee2ce67Sguenther/* $OpenBSD: sigsetjmp.S,v 1.4 2022/12/08 02:11:27 guenther Exp $ */ 2cf252584Smiod/* $NetBSD: sigsetjmp.S,v 1.9 2006/01/05 19:21:37 uwe Exp $ */ 3cf252584Smiod 4cf252584Smiod/*- 5cf252584Smiod * Copyright (c) 1990 The Regents of the University of California. 6cf252584Smiod * All rights reserved. 7cf252584Smiod * 8cf252584Smiod * This code is derived from software contributed to Berkeley by 9cf252584Smiod * William Jolitz. 10cf252584Smiod * 11cf252584Smiod * Redistribution and use in source and binary forms, with or without 12cf252584Smiod * modification, are permitted provided that the following conditions 13cf252584Smiod * are met: 14cf252584Smiod * 1. Redistributions of source code must retain the above copyright 15cf252584Smiod * notice, this list of conditions and the following disclaimer. 16cf252584Smiod * 2. Redistributions in binary form must reproduce the above copyright 17cf252584Smiod * notice, this list of conditions and the following disclaimer in the 18cf252584Smiod * documentation and/or other materials provided with the distribution. 19cf252584Smiod * 3. Neither the name of the University nor the names of its contributors 20cf252584Smiod * may be used to endorse or promote products derived from this software 21cf252584Smiod * without specific prior written permission. 22cf252584Smiod * 23cf252584Smiod * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24cf252584Smiod * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25cf252584Smiod * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26cf252584Smiod * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27cf252584Smiod * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28cf252584Smiod * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29cf252584Smiod * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30cf252584Smiod * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31cf252584Smiod * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32cf252584Smiod * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33cf252584Smiod * SUCH DAMAGE. 34cf252584Smiod * 35cf252584Smiod * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90 36cf252584Smiod */ 37cf252584Smiod 3895146ac7Smiod#include "SYS.h" 3995146ac7Smiod 40cf252584Smiod#include <machine/setjmp.h> 41cf252584Smiod 42cf252584SmiodENTRY(sigsetjmp) 43243b5df4Smiod tst r5, r5 /* if (savemask == 0) */ 44243b5df4Smiod bt 2f 45cf252584Smiod 46243b5df4Smiod /* identical to setjmp */ 47cf252584Smiod PIC_PROLOGUE(.L_got_1) 48cf252584Smiod sts.l pr, @-sp 49cf252584Smiod mov.l r4, @-sp 50cf252584Smiod mov.l r5, @-sp 51cf252584Smiod 52cf252584Smiod mov.l .L_sigprocmask_1, r0 53cf252584Smiod mov r4, r6 54cf252584Smiod mov #1, r4 /* how = SIG_BLOCK */ 55cf252584Smiod mov #0, r5 /* new = NULL */ 56cf252584Smiod1: CALL r0 57243b5df4Smiod add #4, r6 /* old = &sigmask */ 58cf252584Smiod 59cf252584Smiod mov.l @sp+, r5 60cf252584Smiod mov.l @sp+, r4 61cf252584Smiod lds.l @sp+, pr 62cf252584Smiod PIC_EPILOGUE 63cf252584Smiod 64243b5df4Smiod2: /* identical to _setjmp except that first word is in r5 */ 65243b5df4Smiod#if defined(__SH4__) && !defined(__SH4_NOFPU__) 66243b5df4Smiod add #(_JBLEN * 4), r4 67243b5df4Smiod sts fpscr, r1 68243b5df4Smiod xor r0, r0 69243b5df4Smiod mov.l r1, @-r4 70243b5df4Smiod lds r0, fpscr 71243b5df4Smiod sts.l fpul, @-r4 72243b5df4Smiod fmov.s fr15, @-r4 73243b5df4Smiod fmov.s fr14, @-r4 74243b5df4Smiod fmov.s fr13, @-r4 75243b5df4Smiod fmov.s fr12, @-r4 76243b5df4Smiod frchg 77243b5df4Smiod fmov.s fr15, @-r4 78243b5df4Smiod fmov.s fr14, @-r4 79243b5df4Smiod fmov.s fr13, @-r4 80243b5df4Smiod fmov.s fr12, @-r4 81243b5df4Smiod lds r1, fpscr 82243b5df4Smiod#else 83243b5df4Smiod add #((_JBLEN - 10) * 4), r4 84243b5df4Smiod#endif 85243b5df4Smiod sts.l mach, @-r4 86243b5df4Smiod sts.l macl, @-r4 87cf252584Smiod mov.l r15, @-r4 88cf252584Smiod mov.l r14, @-r4 89cf252584Smiod mov.l r13, @-r4 90cf252584Smiod mov.l r12, @-r4 91cf252584Smiod mov.l r11, @-r4 92cf252584Smiod mov.l r10, @-r4 93cf252584Smiod mov.l r9, @-r4 94cf252584Smiod mov.l r8, @-r4 95cf252584Smiod sts.l pr, @-r4 96243b5df4Smiod add #-4, r4 /* skip signal mask */ 97243b5df4Smiod mov.l r5, @-r4 /* has signal mask? */ 98cf252584Smiod rts 99cf252584Smiod xor r0, r0 100cf252584Smiod 101cf252584Smiod .align 2 102cf252584Smiod.L_got_1: PIC_GOT_DATUM 103*0ee2ce67Sguenther.L_sigprocmask_1: CALL_DATUM(_HIDDEN(sigprocmask), 1b) 104cf252584Smiod SET_ENTRY_SIZE(sigsetjmp) 105cf252584Smiod 106cf252584SmiodENTRY(siglongjmp) 107243b5df4Smiod mov.l @r4+, r0 108cf252584Smiod tst r0, r0 109cf252584Smiod bt 2f /* if no mask */ 110cf252584Smiod 111cf252584Smiod /* identical to longjmp */ 112cf252584Smiod /* we won't return here, so we don't need to save pr and r12 */ 113cf252584Smiod PIC_PROLOGUE_NOSAVE(.L_got_2) 114cf252584Smiod mov.l r5, @-sp 115cf252584Smiod mov.l r4, @-sp 116cf252584Smiod 117cf252584Smiod mov.l .L_sigprocmask_2, r0 118243b5df4Smiod mov r4, r5 /* new = &sigmask */ 119cf252584Smiod mov #3, r4 /* how = SIG_SETMASK */ 120cf252584Smiod1: CALL r0 121cf252584Smiod mov #0, r6 /* old = NULL */ 122cf252584Smiod 123cf252584Smiod mov.l @sp+, r4 124cf252584Smiod mov.l @sp+, r5 125cf252584Smiod 126cf252584Smiod2: /* identical to _longjmp */ 127243b5df4Smiod add #4, r4 128cf252584Smiod lds.l @r4+, pr 129cf252584Smiod mov.l @r4+, r8 130cf252584Smiod mov.l @r4+, r9 131cf252584Smiod mov.l @r4+, r10 132cf252584Smiod mov.l @r4+, r11 133cf252584Smiod mov.l @r4+, r12 134cf252584Smiod mov.l @r4+, r13 135cf252584Smiod mov.l @r4+, r14 136cf252584Smiod mov.l @r4+, r15 137243b5df4Smiod lds.l @r4+, macl 138243b5df4Smiod lds.l @r4+, mach 139243b5df4Smiod#if defined(__SH4__) && !defined(__SH4_NOFPU__) 140243b5df4Smiod xor r0, r0 141243b5df4Smiod lds r0, fpscr 142243b5df4Smiod frchg 143243b5df4Smiod fmov.s @r4+, fr12 144243b5df4Smiod fmov.s @r4+, fr13 145243b5df4Smiod fmov.s @r4+, fr14 146243b5df4Smiod fmov.s @r4+, fr15 147243b5df4Smiod frchg 148243b5df4Smiod fmov.s @r4+, fr12 149243b5df4Smiod fmov.s @r4+, fr13 150243b5df4Smiod fmov.s @r4+, fr14 151243b5df4Smiod fmov.s @r4+, fr15 152243b5df4Smiod lds.l @r4+, fpul 153243b5df4Smiod lds.l @r4+, fpscr 154243b5df4Smiod#endif 155cf252584Smiod 156cf252584Smiod mov r5, r0 157cf252584Smiod tst r0, r0 /* make sure return value is non-zero */ 158cf252584Smiod bf .L0 159cf252584Smiod add #1, r0 160cf252584Smiod.L0: 161cf252584Smiod rts 162cf252584Smiod nop 163cf252584Smiod 164cf252584Smiod .align 2 165cf252584Smiod.L_got_2: PIC_GOT_DATUM 166*0ee2ce67Sguenther.L_sigprocmask_2: CALL_DATUM(_HIDDEN(sigprocmask), 1b) 167cf252584Smiod SET_ENTRY_SIZE(siglongjmp) 168