1*18715Smckusick/* setjmp.s 4.8 85/04/24 */ 213419Sroot 313419Sroot/* 413419Sroot * C library -- setjmp, longjmp 513419Sroot * 613419Sroot * longjmp(a,v) 713419Sroot * will generate a "return(v)" from 813419Sroot * the last call to 913419Sroot * setjmp(a) 1013419Sroot * by restoring registers from the stack, 1118292Smckusick * and a struct sigcontext, see <signal.h> 1213419Sroot */ 1313419Sroot 1413419Sroot#include "DEFS.h" 1513419Sroot 16*18715SmckusickENTRY(setjmp, R6) 17*18715Smckusick movl 4(ap),r6 # construct sigcontext 1818292Smckusick subl2 $8,sp # space for current struct sigstack 1918292Smckusick pushl sp # get current values 2018292Smckusick pushl $0 # no new values 2118292Smckusick calls $3,_sigstack # pop args plus signal stack value 22*18715Smckusick movl *(sp)+,(r6)+ # save onsigstack status of caller 2313419Sroot pushl $0 2413419Sroot calls $1,_sigblock # get signal mask 25*18715Smckusick movl r0,(r6)+ # save signal mask of caller 2618292Smckusick movl (ap),r0 27*18715Smckusick moval 4(ap)[r0],(r6)+ # save sp of caller 28*18715Smckusick movl 12(fp),(r6)+ # save frame pointer of caller 29*18715Smckusick movl 8(fp),(r6)+ # save argument pointer of caller 30*18715Smckusick movl 16(fp),(r6)+ # save pc of caller 31*18715Smckusick movpsl (r6) # save psl of caller 32*18715Smckusick movw 4(fp),(r6) 3313419Sroot clrl r0 3413419Sroot ret 3513419Sroot 3617329SsamENTRY(longjmp, 0) 3713419Sroot movl 8(ap),r0 # return(v) 3813419Sroot movl 4(ap),r1 # fetch buffer 3918292Smckusick tstl 12(r1) 4013419Sroot beql botch 4113419Srootloop: 4218292Smckusick cmpl 12(r1),fp # are we there yet? 4318292Smckusick beql done 4418292Smckusick blssu botch 4518292Smckusick moval 20(fp),r2 4618292Smckusick blbc 6(fp),1f # was r0 saved? 4718292Smckusick movl r0,(r2)+ 4813419Sroot1: 4918292Smckusick bbc $1,6(fp),2f # was r1 saved? 5018292Smckusick movl r1,(r2) 5113419Sroot2: 5213419Sroot movl $loop,16(fp) 5313419Sroot ret # pop another frame 5413419Sroot 5513419Srootdone: 5618292Smckusick 5718292Smckusick#ifndef NOCOMPAT 5818292Smckusick/* 5918292Smckusick * This code checks to see if it can use the new sigreturn. 6018292Smckusick * If it finds that sigtramp is using the new system call, 6118292Smckusick * it will also use it. Otherwise it uses the old system call 6218292Smckusick * to preserve compatibility. 6318292Smckusick */ 6418292Smckusick#include <vax/machparam.h> 6518292Smckusick#define U (0x80000000-UPAGES*NBPG) 6618292Smckusick#define PCB_SIGC 0x6c 6718292Smckusick#define CHMKINS 7 6818292Smckusick cmpl 3f,U+PCB_SIGC+CHMKINS # check to see how sigtramp returns 6918292Smckusick beql 4f # sigtramp uses the new system call 7018292Smckusick pushl r1 # must use the old signal return 7118292Smckusick chmk $139 # restore previous context 7218292Smckusick jmp *20(r1) # done, return 7313419Sroot3: 7418292Smckusick chmk $103 # the new system call for sigreturn 7513419Sroot4: 7618292Smckusick#endif NOCOMPAT 7713419Sroot 7818292Smckusick pushl r1 # pointer to sigcontext 7918292Smckusick calls $1,_sigreturn # restore previous context 8018292Smckusick # we should never return 8113419Srootbotch: 8213500Ssam pushl $msgend-msg 8313419Sroot pushl $msg 8413419Sroot pushl $2 8513419Sroot calls $3,_write 8613419Sroot halt 8713419Sroot 8813625Ssam .data 8913500Ssammsg: .ascii "longjmp botch\n" 9013500Ssammsgend: 91