1/* 2 * Copyright (c) 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Computer Consoles Inc. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that this notice is preserved and that due credit is given 10 * to the University of California at Berkeley. The name of the University 11 * may not be used to endorse or promote products derived from this 12 * software without specific prior written permission. This software 13 * is provided ``as is'' without express or implied warranty. 14 */ 15 16#if defined(LIBC_SCCS) && !defined(lint) 17_sccsid:.asciz "@(#)setjmp.s 1.3 (Berkeley) 05/23/88" 18#endif /* LIBC_SCCS and not lint */ 19 20/* 21 * C library -- setjmp, longjmp 22 * 23 * longjmp(a,v) 24 * will generate a "return(v)" from 25 * the last call to 26 * setjmp(a) 27 * by restoring registers from the stack, 28 * previous signal mask, and doing a return. 29 */ 30 31#include "DEFS.h" 32 33ENTRY(setjmp, R6) 34 movl 4(fp),r6 # construct sigcontext 35 movab -8(sp),sp # space for current struct sigstack 36 pushal (sp) # get current values 37 pushl $0 # no new values 38 callf $16,_sigstack # pop args plus signal stack value 39 movl (sp)+,(r6) # save onsigstack status of caller 40 pushl $0 41 callf $8,_sigblock # get signal mask 42 movl r0,4(r6) # save signal mask of caller 43 addl3 $8,fp,8(r6) # save stack pointer of caller 44 movl (fp),12(r6) # save frame pointer of caller 45 movl -8(fp),20(r6) # save pc of caller 46 movpsl 24(r6) # save psl of caller 47 clrl r0 48 ret 49 50ENTRY(longjmp, 0) 51 movl 8(fp),r0 # return(v) 52 movl 4(fp),r1 # fetch buffer 53 tstl 12(r1) 54 beql botch 55loop: 56 cmpl 12(r1),(fp) 57 beql done 58 blssu botch 59 movl $loop,-8(fp) 60 ret # pop another frame 61 62done: 63 cmpb *-8(fp),reiins # returning to an "rei"? 64 bneq 1f 65 movab 3f,-8(fp) # do return w/ psl-pc pop 66 brw 2f 671: 68 movab 4f,-8(fp) # do standard return 692: 70 ret # unwind stack before signals enabled 713: 72 addl2 $8,sp # compensate for PSL-PC push 734: 74 pushl r1 # pointer to sigcontext 75 callf $4,_sigreturn # restore previous context 76 # we should never return 77 78botch: 79 callf $4,_longjmperror 80 halt 81 82 .data 83reiins: rei 84