1*a92c0621Suwe/* $NetBSD: compat_setjmp.S,v 1.3 2006/01/05 19:21:37 uwe Exp $ */ 24890707aSuwe 34890707aSuwe/*- 44890707aSuwe * Copyright (c) 1990 The Regents of the University of California. 54890707aSuwe * All rights reserved. 64890707aSuwe * 74890707aSuwe * This code is derived from software contributed to Berkeley by 84890707aSuwe * William Jolitz. 94890707aSuwe * 104890707aSuwe * Redistribution and use in source and binary forms, with or without 114890707aSuwe * modification, are permitted provided that the following conditions 124890707aSuwe * are met: 134890707aSuwe * 1. Redistributions of source code must retain the above copyright 144890707aSuwe * notice, this list of conditions and the following disclaimer. 154890707aSuwe * 2. Redistributions in binary form must reproduce the above copyright 164890707aSuwe * notice, this list of conditions and the following disclaimer in the 174890707aSuwe * documentation and/or other materials provided with the distribution. 184890707aSuwe * 3. Neither the name of the University nor the names of its contributors 194890707aSuwe * may be used to endorse or promote products derived from this software 204890707aSuwe * without specific prior written permission. 214890707aSuwe * 224890707aSuwe * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 234890707aSuwe * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 244890707aSuwe * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 254890707aSuwe * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 264890707aSuwe * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 274890707aSuwe * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 284890707aSuwe * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 294890707aSuwe * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 304890707aSuwe * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 314890707aSuwe * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 324890707aSuwe * SUCH DAMAGE. 334890707aSuwe * 344890707aSuwe * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90 354890707aSuwe */ 364890707aSuwe 374890707aSuwe#include <machine/asm.h> 38f859e17aSuwe#include <machine/setjmp.h> 39f859e17aSuwe 404890707aSuwe#if defined(LIBC_SCCS) 41*a92c0621Suwe RCSID("$NetBSD: compat_setjmp.S,v 1.3 2006/01/05 19:21:37 uwe Exp $") 424890707aSuwe#endif 434890707aSuwe 444890707aSuwe/* 45f859e17aSuwe * C library -- setjmp, longjmp 464890707aSuwe * 474890707aSuwe * longjmp(a,v) 484890707aSuwe * will generate a "return(v)" from the last call to 494890707aSuwe * setjmp(a) 504890707aSuwe * by restoring registers from the stack. 514890707aSuwe * The previous signal state is restored. 524890707aSuwe */ 534890707aSuwe 544890707aSuweENTRY(setjmp) 55f859e17aSuwe PIC_PROLOGUE(.L_got_1) 56f859e17aSuwe sts.l pr, @-sp 57f859e17aSuwe mov.l r4, @-sp 584890707aSuwe 59f859e17aSuwe mov.l .L_sigblock, r0 60f859e17aSuwe1: CALL r0 /* int mask = sigblock(0); */ 61f859e17aSuwe mov #0, r4 62f859e17aSuwe 63f859e17aSuwe mov.l @sp+, r4 64f859e17aSuwe lds.l @sp+, pr 65f859e17aSuwe PIC_EPILOGUE 66f859e17aSuwe 67f859e17aSuwe /* identical to _setjmp except that mask is present */ 68f859e17aSuwe add #((_JB_SIGMASK + 1) * 4), r4 69f859e17aSuwe mov.l r0, @-r4 /* current mask returned by sigblock */ 704890707aSuwe mov #1, r0 71f859e17aSuwe mov.l r0, @-r4 /* has signal mask */ 724890707aSuwe mov.l r15, @-r4 734890707aSuwe mov.l r14, @-r4 744890707aSuwe mov.l r13, @-r4 754890707aSuwe mov.l r12, @-r4 764890707aSuwe mov.l r11, @-r4 774890707aSuwe mov.l r10, @-r4 784890707aSuwe mov.l r9, @-r4 794890707aSuwe mov.l r8, @-r4 804890707aSuwe sts.l pr, @-r4 814890707aSuwe rts 824890707aSuwe xor r0, r0 834890707aSuwe 844890707aSuwe .align 2 85f859e17aSuwe.L_got_1: PIC_GOT_DATUM 86f859e17aSuwe.L_sigblock: CALL_DATUM(_C_LABEL(sigblock), 1b) 87f859e17aSuwe SET_ENTRY_SIZE(setjmp) 88f859e17aSuwe 894890707aSuwe 904890707aSuweENTRY(longjmp) 91*a92c0621Suwe /* we won't return here, so we don't need to save pr and r12 */ 92*a92c0621Suwe PIC_PROLOGUE_NOSAVE(.L_got_2) 93f859e17aSuwe mov.l r5, @-sp 94*a92c0621Suwe mov.l r4, @-sp 954890707aSuwe 96f859e17aSuwe mov.l .L_sigsetmask, r0 97f859e17aSuwe1: CALL r0 /* sigsetmask(saved mask) */ 98f859e17aSuwe mov.l @(_JB_SIGMASK * 4, r4), r4 99f859e17aSuwe 100f859e17aSuwe mov.l @sp+, r4 101*a92c0621Suwe mov.l @sp+, r5 102f859e17aSuwe 103f859e17aSuwe /* identical to _longjmp */ 1044890707aSuwe lds.l @r4+, pr 1054890707aSuwe mov.l @r4+, r8 1064890707aSuwe mov.l @r4+, r9 1074890707aSuwe mov.l @r4+, r10 1084890707aSuwe mov.l @r4+, r11 1094890707aSuwe mov.l @r4+, r12 1104890707aSuwe mov.l @r4+, r13 1114890707aSuwe mov.l @r4+, r14 1124890707aSuwe mov.l @r4+, r15 113f859e17aSuwe 1144890707aSuwe mov r5, r0 115f859e17aSuwe tst r0, r0 /* make sure return value is non-zero */ 1164890707aSuwe bf .L0 1174890707aSuwe add #1, r0 1184890707aSuwe.L0: 1194890707aSuwe rts 1204890707aSuwe nop 1214890707aSuwe 1224890707aSuwe .align 2 123f859e17aSuwe.L_got_2: PIC_GOT_DATUM 124f859e17aSuwe.L_sigsetmask: CALL_DATUM(_C_LABEL(sigsetmask), 1b) 125f859e17aSuwe SET_ENTRY_SIZE(longjmp) 126