Repository navigation
Expand file tree
/
Copy pathsetjmp.e
More file actions
executable file
·112 lines (108 loc) · 2.35 KB
/
Copy pathsetjmp.e
File metadata and controls
executable file
·112 lines (108 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
8000
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#
mes 2,_EM_WSIZE,_EM_PSIZE
;
; layout of a setjmp buffer:
;
; -----------------
; | flag | (!0 when blocked signals saved (POSIX))
; -----------------
; | signal mask/set | (for Berkeley 4.[2-] / POSIX)
; -----------------
; | |
; | GTO descriptor |
; | (SP, LB, PC) |
; | |
; -----------------
;
; setjmp saves the signalmask, PC, SP, and LB of caller, and creates a
; GTO descriptor from this.
; The big problem here is how to get the return address, i.e. the PC of
; the caller; This problem is solved by the front-end, which must pass
; it as an extra parameter to setjmp.
; a GTO descriptor must be in the global data area
gtobuf
bss 3*_EM_PSIZE,0,0
inp $fill_ret_area
exp $__setjmp
pro $__setjmp,0
#if defined(_POSIX_SOURCE)
; save mask of currently blocked signals.
; longjmp must restore this mask
lol _EM_PSIZE ; the flag integer at offset _EM_PSIZE
lal 0
loi _EM_PSIZE
stf 3*_EM_PSIZE+_EM_LSIZE
lol _EM_PSIZE ; the flag integer at offset _EM_PSIZE
zeq *1
lal 0
loi _EM_PSIZE
adp 3*_EM_PSIZE
cal $__newsigset
asp _EM_PSIZE
1
#elif defined(__BSD4_2)
loc 0
cal $sigblock
asp _EM_WSIZE
lfr _EM_WSIZE
lal 0
loi _EM_PSIZE
stf 3*_EM_PSIZE
#endif
; create GTO descriptor for longjmp
lxl 0
dch ; Local Base of caller
lxa 0 ; Stackpointer of caller
lal _EM_PSIZE+_EM_WSIZE
loi _EM_PSIZE ; Return address of caller
lal 0
loi _EM_PSIZE ; address of jmpbuf
sti 3*_EM_PSIZE ; LB, SP, and PC stored in jmpbuf
loc 0
ret _EM_WSIZE ; setjmp must return 0
end 0
pro $fill_ret_area,0
; put argument in function result area
lol 0
ret _EM_WSIZE
end 0
exp $longjmp
pro $longjmp,?
#if defined(_POSIX_SOURCE)
; restore blocked mask
lal 0
loi _EM_PSIZE
lof 3*_EM_PSIZE+_EM_LSIZE
zeq *2
lal 0
loi _EM_PSIZE
adp 3*_EM_PSIZE
cal $__oldsigset
asp _EM_PSIZE
2
#elif defined(__BSD4_2)
; restore signal mask
lal 0
loi _EM_PSIZE
lof 3*_EM_PSIZE
cal $_sigsetmask
asp _EM_WSIZE
lfr _EM_WSIZE
asp _EM_WSIZE
#endif
lal 0
l
3B83
oi _EM_PSIZE ; address of jmpbuf
lae gtobuf
blm 3*_EM_PSIZE ; fill GTO descriptor from jmpbuf
lol _EM_PSIZE ; second parameter of longjmp: the return value
dup _EM_WSIZE
zne *3
; of course, longjmp may not return 0!
inc
3
; put return value in function result area
cal $fill_ret_area
asp _EM_WSIZE
gto gtobuf ; there we go ...
; ASP and GTO do not damage function result area
end 0