134438Sbostic/* 2*61183Sbostic * Copyright (c) 1988, 1993 3*61183Sbostic * The Regents of the University of California. All rights reserved. 434438Sbostic * 534438Sbostic * This code is derived from software contributed to Berkeley by 634438Sbostic * Computer Consoles Inc. 746166Sbostic * 846166Sbostic * %sccs.include.redist.c% 934438Sbostic */ 1029698Ssam 1134438Sbostic#if defined(LIBC_SCCS) && !defined(lint) 12*61183Sbostic .asciz "@(#)setjmp.s 8.1 (Berkeley) 06/04/93" 1334438Sbostic#endif /* LIBC_SCCS and not lint */ 1434438Sbostic 1529698Ssam/* 1629698Ssam * C library -- setjmp, longjmp 1729698Ssam * 1829698Ssam * longjmp(a,v) 1929698Ssam * will generate a "return(v)" from 2029698Ssam * the last call to 2129698Ssam * setjmp(a) 2229698Ssam * by restoring registers from the stack, 2329698Ssam * previous signal mask, and doing a return. 2429698Ssam */ 2529698Ssam 2629698Ssam#include "DEFS.h" 2729698Ssam 2829797SsamENTRY(setjmp, R6) 2929797Ssam movl 4(fp),r6 # construct sigcontext 3029797Ssam movab -8(sp),sp # space for current struct sigstack 3129797Ssam pushal (sp) # get current values 3229797Ssam pushl $0 # no new values 3329797Ssam callf $16,_sigstack # pop args plus signal stack value 3429797Ssam movl (sp)+,(r6) # save onsigstack status of caller 3529698Ssam pushl $0 3629698Ssam callf $8,_sigblock # get signal mask 3729797Ssam movl r0,4(r6) # save signal mask of caller 3829797Ssam addl3 $8,fp,8(r6) # save stack pointer of caller 3929797Ssam movl (fp),12(r6) # save frame pointer of caller 4029797Ssam movl -8(fp),20(r6) # save pc of caller 4129797Ssam movpsl 24(r6) # save psl of caller 4229698Ssam clrl r0 4329698Ssam ret 4429698Ssam 4529698SsamENTRY(longjmp, 0) 4629698Ssam movl 8(fp),r0 # return(v) 4729698Ssam movl 4(fp),r1 # fetch buffer 4829797Ssam tstl 12(r1) 4929698Ssam beql botch 5029698Ssamloop: 5129797Ssam cmpl 12(r1),(fp) 5229698Ssam beql done 5329698Ssam blssu botch 5429698Ssam movl $loop,-8(fp) 5529698Ssam ret # pop another frame 5629698Ssam 5729698Ssamdone: 5829698Ssam cmpb *-8(fp),reiins # returning to an "rei"? 5929698Ssam bneq 1f 6029698Ssam movab 3f,-8(fp) # do return w/ psl-pc pop 6129698Ssam brw 2f 6229698Ssam1: 6329698Ssam movab 4f,-8(fp) # do standard return 6429698Ssam2: 6529698Ssam ret # unwind stack before signals enabled 6629698Ssam3: 6729698Ssam addl2 $8,sp # compensate for PSL-PC push 6829698Ssam4: 6929797Ssam pushl r1 # pointer to sigcontext 7029797Ssam callf $4,_sigreturn # restore previous context 7129797Ssam # we should never return 7229698Ssam 7329698Ssambotch: 7429698Ssam callf $4,_longjmperror 7529698Ssam halt 7629698Ssam 7729698Ssam .data 7829698Ssamreiins: rei 79