121431Sdist/* 221431Sdist * Copyright (c) 1983 Regents of the University of California. 334480Sbostic * All rights reserved. 434480Sbostic * 534480Sbostic * Redistribution and use in source and binary forms are permitted 6*34819Sbostic * provided that the above copyright notice and this paragraph are 7*34819Sbostic * duplicated in all such forms and that any documentation, 8*34819Sbostic * advertising materials, and other materials related to such 9*34819Sbostic * distribution and use acknowledge that the software was developed 10*34819Sbostic * by the University of California, Berkeley. The name of the 11*34819Sbostic * University may not be used to endorse or promote products derived 12*34819Sbostic * from this software without specific prior written permission. 13*34819Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14*34819Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15*34819Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1621431Sdist */ 1713419Sroot 18*34819Sbostic#if defined(LIBC_SCCS) && !defined(lint) 19*34819Sbostic .asciz "@(#)setjmp.s 5.8 (Berkeley) 06/27/88" 20*34819Sbostic#endif /* LIBC_SCCS and not lint */ 2121431Sdist 2213419Sroot/* 2313419Sroot * C library -- setjmp, longjmp 2413419Sroot * 2513419Sroot * longjmp(a,v) 2613419Sroot * will generate a "return(v)" from 2713419Sroot * the last call to 2813419Sroot * setjmp(a) 2913419Sroot * by restoring registers from the stack, 3018292Smckusick * and a struct sigcontext, see <signal.h> 3113419Sroot */ 3213419Sroot 3313419Sroot#include "DEFS.h" 3413419Sroot 3518715SmckusickENTRY(setjmp, R6) 3618715Smckusick movl 4(ap),r6 # construct sigcontext 3718292Smckusick subl2 $8,sp # space for current struct sigstack 3818292Smckusick pushl sp # get current values 3918292Smckusick pushl $0 # no new values 4018292Smckusick calls $3,_sigstack # pop args plus signal stack value 4124300Smckusick movl (sp)+,(r6)+ # save onsigstack status of caller 4213419Sroot pushl $0 4313419Sroot calls $1,_sigblock # get signal mask 4418715Smckusick movl r0,(r6)+ # save signal mask of caller 4518292Smckusick movl (ap),r0 4618715Smckusick moval 4(ap)[r0],(r6)+ # save sp of caller 4718715Smckusick movl 12(fp),(r6)+ # save frame pointer of caller 4818715Smckusick movl 8(fp),(r6)+ # save argument pointer of caller 4918715Smckusick movl 16(fp),(r6)+ # save pc of caller 5018715Smckusick movpsl (r6) # save psl of caller 5118715Smckusick movw 4(fp),(r6) 5213419Sroot clrl r0 5313419Sroot ret 5413419Sroot 5517329SsamENTRY(longjmp, 0) 5613419Sroot movl 8(ap),r0 # return(v) 5713419Sroot movl 4(ap),r1 # fetch buffer 5818292Smckusick tstl 12(r1) 5913419Sroot beql botch 6013419Srootloop: 6118292Smckusick cmpl 12(r1),fp # are we there yet? 6218292Smckusick beql done 6318292Smckusick blssu botch 6418292Smckusick moval 20(fp),r2 6518292Smckusick blbc 6(fp),1f # was r0 saved? 6618292Smckusick movl r0,(r2)+ 6713419Sroot1: 6818292Smckusick bbc $1,6(fp),2f # was r1 saved? 6918292Smckusick movl r1,(r2) 7013419Sroot2: 7113419Sroot movl $loop,16(fp) 7213419Sroot ret # pop another frame 7313419Sroot 7413419Srootdone: 7518292Smckusick pushl r1 # pointer to sigcontext 7618292Smckusick calls $1,_sigreturn # restore previous context 7718292Smckusick # we should never return 7813419Srootbotch: 7925784Smckusick calls $0,_longjmperror 8013419Sroot halt 81