11.11Suwe/* $NetBSD: sigsetjmp.S,v 1.11 2024/07/17 07:11:57 uwe Exp $ */ 21.1Smsaitoh 31.1Smsaitoh/*- 41.1Smsaitoh * Copyright (c) 1990 The Regents of the University of California. 51.1Smsaitoh * All rights reserved. 61.1Smsaitoh * 71.1Smsaitoh * This code is derived from software contributed to Berkeley by 81.1Smsaitoh * William Jolitz. 91.1Smsaitoh * 101.1Smsaitoh * Redistribution and use in source and binary forms, with or without 111.1Smsaitoh * modification, are permitted provided that the following conditions 121.1Smsaitoh * are met: 131.1Smsaitoh * 1. Redistributions of source code must retain the above copyright 141.1Smsaitoh * notice, this list of conditions and the following disclaimer. 151.1Smsaitoh * 2. Redistributions in binary form must reproduce the above copyright 161.1Smsaitoh * notice, this list of conditions and the following disclaimer in the 171.1Smsaitoh * documentation and/or other materials provided with the distribution. 181.6Sagc * 3. Neither the name of the University nor the names of its contributors 191.1Smsaitoh * may be used to endorse or promote products derived from this software 201.1Smsaitoh * without specific prior written permission. 211.1Smsaitoh * 221.1Smsaitoh * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 231.1Smsaitoh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 241.1Smsaitoh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 251.1Smsaitoh * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 261.1Smsaitoh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 271.1Smsaitoh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 281.1Smsaitoh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 291.1Smsaitoh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 301.1Smsaitoh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 311.1Smsaitoh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 321.1Smsaitoh * SUCH DAMAGE. 331.1Smsaitoh * 341.7Suwe * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90 351.1Smsaitoh */ 361.1Smsaitoh 371.1Smsaitoh#include <machine/asm.h> 381.8Suwe#include <machine/setjmp.h> 391.8Suwe 401.1Smsaitoh#if defined(LIBC_SCCS) 411.11Suwe RCSID("$NetBSD: sigsetjmp.S,v 1.11 2024/07/17 07:11:57 uwe Exp $") 421.1Smsaitoh#endif 431.1Smsaitoh 441.7SuweENTRY(__sigsetjmp14) 451.1Smsaitoh tst r5, r5 461.8Suwe bt 2f /* if (savemask == 0) */ 471.8Suwe 481.8Suwe /* identical to longjmp except that _JB_HAS_MASK is in the argument */ 491.8Suwe PIC_PROLOGUE(.L_got_1) 501.8Suwe sts.l pr, @-sp 511.8Suwe mov.l r4, @-sp 521.8Suwe mov.l r5, @-sp 531.4Smsaitoh 541.8Suwe mov.l .L___sigprocmask14_1, r0 551.7Suwe mov r4, r6 561.10Sskrll mov #0, r4 /* how is ignored */ 571.10Sskrll mov #0, r5 /* set = NULL */ 581.8Suwe1: CALL r0 591.10Sskrll add #(_JB_SIGMASK * 4), r6 /* oset = &sigmask */ 601.8Suwe 611.8Suwe mov.l @sp+, r5 621.8Suwe mov.l @sp+, r4 631.8Suwe lds.l @sp+, pr 641.8Suwe PIC_EPILOGUE 651.8Suwe 661.8Suwe2: /* identical to _setjmp except that _JB_HAS_MASK is in the argument */ 671.8Suwe add #((_JB_HAS_MASK + 1) * 4), r4 681.8Suwe mov.l r5, @-r4 /* has signal mask? */ 691.1Smsaitoh mov.l r15, @-r4 701.1Smsaitoh mov.l r14, @-r4 711.1Smsaitoh mov.l r13, @-r4 721.1Smsaitoh mov.l r12, @-r4 731.1Smsaitoh mov.l r11, @-r4 741.1Smsaitoh mov.l r10, @-r4 751.1Smsaitoh mov.l r9, @-r4 761.1Smsaitoh mov.l r8, @-r4 771.1Smsaitoh sts.l pr, @-r4 781.1Smsaitoh rts 791.8Suwe xor r0, r0 801.8Suwe 811.8Suwe .align 2 821.8Suwe.L_got_1: PIC_GOT_DATUM 831.8Suwe.L___sigprocmask14_1: CALL_DATUM(_C_LABEL(__sigprocmask14), 1b) 841.8Suwe SET_ENTRY_SIZE(__sigsetjmp14) 851.8Suwe 861.1Smsaitoh 871.7SuweENTRY(__siglongjmp14) 881.11Suwe // return value can't be zero, adjust to 1 if it is 891.11Suwe tst r5, r5 901.11Suwe bf/s 0f 911.11Suwe mov.l @(_JB_REG_PR * 4, r4), r0 921.11Suwe mov #1, r5 931.11Suwe0: 941.11Suwe // restore context first (callee-saved regs) 951.11Suwe mov.l @(_JB_REG_R8 * 4, r4), r8 961.11Suwe mov.l @(_JB_REG_R9 * 4, r4), r9 971.11Suwe mov.l @(_JB_REG_R10 * 4, r4), r10 981.11Suwe mov.l @(_JB_REG_R11 * 4, r4), r11 991.11Suwe mov.l @(_JB_REG_R12 * 4, r4), r12 1001.11Suwe mov.l @(_JB_REG_R13 * 4, r4), r13 1011.11Suwe mov.l @(_JB_REG_R14 * 4, r4), r14 1021.11Suwe mov.l @(_JB_REG_R15 * 4, r4), r15 1031.11Suwe 1041.11Suwe // do we need to restore signal mask? 1051.11Suwe mov.l @(_JB_HAS_MASK * 4, r4), r7 1061.11Suwe tst r7, r7 1071.11Suwe bf/s 0f 1081.11Suwe mov #0, r6 // sigprocmask: oset = NULL 1091.11Suwe // ... no, just the registers 1101.11Suwe lds r0, pr 1111.11Suwe rts 1121.11Suwe mov r5, r0 1131.11Suwe0: 1141.11Suwe // create a frame 1151.11Suwe mov.l r5, @-sp // future return value (pre-adjusted) 1161.11Suwe mov.l r0, @-sp // caller's PR from the jumpbuf 1171.11Suwe PIC_PROLOGUE(.L_got_2) 1181.1Smsaitoh 1191.11Suwe // restore signal mask from &a[_JB_SIGMASK] 1201.11Suwe mov r4, r5 1211.8Suwe mov.l .L___sigprocmask14_2, r0 1221.11Suwe add #(_JB_SIGMASK * 4), r5 // set = &a[_JB_SIGMASK] 1231.8Suwe1: CALL r0 1241.11Suwe mov #3, r4 // how = SIG_SETMASK 1251.8Suwe 1261.11Suwe // return "from" setjmp 1271.11Suwe PIC_EPILOGUE 1281.11Suwe lds.l @sp+, pr 1291.1Smsaitoh rts 1301.11Suwe mov.l @sp+, r0 1311.1Smsaitoh 1321.4Smsaitoh .align 2 1331.8Suwe.L_got_2: PIC_GOT_DATUM 1341.8Suwe.L___sigprocmask14_2: CALL_DATUM(_C_LABEL(__sigprocmask14), 1b) 1351.8Suwe SET_ENTRY_SIZE(__siglongjmp14) 136