Commit | Line | Data |
---|---|---|
586c39b1 DF |
1 | /* |
2 | * Copyright (c) 1983 Regents of the University of California. | |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
5 | */ | |
6 | ||
2ce81398 | 7 | #ifdef LIBC_SCCS |
95f51977 | 8 | .asciz "@(#)setjmp.s 5.5 (Berkeley) 3/9/86" |
2ce81398 | 9 | #endif LIBC_SCCS |
8ccdc4c5 BJ |
10 | |
11 | /* | |
12 | * C library -- setjmp, longjmp | |
13 | * | |
14 | * longjmp(a,v) | |
15 | * will generate a "return(v)" from | |
16 | * the last call to | |
17 | * setjmp(a) | |
18 | * by restoring registers from the stack, | |
99e8a407 | 19 | * and a struct sigcontext, see <signal.h> |
8ccdc4c5 BJ |
20 | */ |
21 | ||
22 | #include "DEFS.h" | |
23 | ||
84458aaa KM |
24 | ENTRY(setjmp, R6) |
25 | movl 4(ap),r6 # construct sigcontext | |
99e8a407 KM |
26 | subl2 $8,sp # space for current struct sigstack |
27 | pushl sp # get current values | |
28 | pushl $0 # no new values | |
29 | calls $3,_sigstack # pop args plus signal stack value | |
a4b62a22 | 30 | movl (sp)+,(r6)+ # save onsigstack status of caller |
8ccdc4c5 BJ |
31 | pushl $0 |
32 | calls $1,_sigblock # get signal mask | |
84458aaa | 33 | movl r0,(r6)+ # save signal mask of caller |
99e8a407 | 34 | movl (ap),r0 |
84458aaa KM |
35 | moval 4(ap)[r0],(r6)+ # save sp of caller |
36 | movl 12(fp),(r6)+ # save frame pointer of caller | |
37 | movl 8(fp),(r6)+ # save argument pointer of caller | |
38 | movl 16(fp),(r6)+ # save pc of caller | |
39 | movpsl (r6) # save psl of caller | |
40 | movw 4(fp),(r6) | |
8ccdc4c5 BJ |
41 | clrl r0 |
42 | ret | |
43 | ||
dadab5a2 | 44 | ENTRY(longjmp, 0) |
8ccdc4c5 BJ |
45 | movl 8(ap),r0 # return(v) |
46 | movl 4(ap),r1 # fetch buffer | |
99e8a407 | 47 | tstl 12(r1) |
8ccdc4c5 BJ |
48 | beql botch |
49 | loop: | |
99e8a407 | 50 | cmpl 12(r1),fp # are we there yet? |
8ccdc4c5 BJ |
51 | beql done |
52 | blssu botch | |
99e8a407 KM |
53 | moval 20(fp),r2 |
54 | blbc 6(fp),1f # was r0 saved? | |
55 | movl r0,(r2)+ | |
56 | 1: | |
57 | bbc $1,6(fp),2f # was r1 saved? | |
58 | movl r1,(r2) | |
59 | 2: | |
8ccdc4c5 BJ |
60 | movl $loop,16(fp) |
61 | ret # pop another frame | |
62 | ||
63 | done: | |
99e8a407 KM |
64 | |
65 | #ifndef NOCOMPAT | |
66 | /* | |
67 | * This code checks to see if it can use the new sigreturn. | |
68 | * If it finds that sigtramp is using the new system call, | |
69 | * it will also use it. Otherwise it uses the old system call | |
70 | * to preserve compatibility. | |
71 | */ | |
72 | #include <vax/machparam.h> | |
73 | #define U (0x80000000-UPAGES*NBPG) | |
74 | #define PCB_SIGC 0x6c | |
75 | #define CHMKINS 7 | |
76 | cmpl 3f,U+PCB_SIGC+CHMKINS # check to see how sigtramp returns | |
77 | beql 4f # sigtramp uses the new system call | |
78 | pushl r1 # must use the old signal return | |
79 | chmk $139 # restore previous context | |
80 | jmp *20(r1) # done, return | |
8ccdc4c5 | 81 | 3: |
99e8a407 | 82 | chmk $103 # the new system call for sigreturn |
8ccdc4c5 | 83 | 4: |
99e8a407 | 84 | #endif NOCOMPAT |
8ccdc4c5 | 85 | |
99e8a407 KM |
86 | pushl r1 # pointer to sigcontext |
87 | calls $1,_sigreturn # restore previous context | |
88 | # we should never return | |
8ccdc4c5 | 89 | botch: |
f6a3ad26 | 90 | calls $0,_longjmperror |
8ccdc4c5 | 91 | halt |