2 |
7u83 |
1 |
/*
|
|
|
2 |
Crown Copyright (c) 1997
|
|
|
3 |
|
|
|
4 |
This TenDRA(r) Computer Program is subject to Copyright
|
|
|
5 |
owned by the United Kingdom Secretary of State for Defence
|
|
|
6 |
acting through the Defence Evaluation and Research Agency
|
|
|
7 |
(DERA). It is made available to Recipients with a
|
|
|
8 |
royalty-free licence for its use, reproduction, transfer
|
|
|
9 |
to other parties and amendment for any purpose not excluding
|
|
|
10 |
product development provided that any such use et cetera
|
|
|
11 |
shall be deemed to be acceptance of the following conditions:-
|
|
|
12 |
|
|
|
13 |
(1) Its Recipients shall ensure that this Notice is
|
|
|
14 |
reproduced upon any copies or amended versions of it;
|
|
|
15 |
|
|
|
16 |
(2) Any amended version of it shall be clearly marked to
|
|
|
17 |
show both the nature of and the organisation responsible
|
|
|
18 |
for the relevant amendment or amendments;
|
|
|
19 |
|
|
|
20 |
(3) Its onward transfer from a recipient to another
|
|
|
21 |
party shall be deemed to be that party's acceptance of
|
|
|
22 |
these conditions;
|
|
|
23 |
|
|
|
24 |
(4) DERA gives no warranty or assurance as to its
|
|
|
25 |
quality or suitability for any purpose and DERA accepts
|
|
|
26 |
no liability whatsoever in relation to any use to which
|
|
|
27 |
it may be put.
|
|
|
28 |
*/
|
|
|
29 |
/* **************************************************** */
|
|
|
30 |
/* */
|
|
|
31 |
/* Spec Token Definitions for HP PA-RISC */
|
|
|
32 |
/* Needs to be linked with posix library */
|
|
|
33 |
/* specific to each platform. */
|
|
|
34 |
/* */
|
|
|
35 |
/* **************************************************** */
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
Tokdec ~Throw : [NAT] EXP;
|
|
|
39 |
|
|
|
40 |
Tokdec ansi.stdlib.abort : [] EXP;
|
|
|
41 |
Tokdec ansi.signal.SIGFPE : [] EXP;
|
|
|
42 |
Tokdec posix.signal.SIG_SETMASK : [] EXP;
|
|
|
43 |
Tokdec posix.signal.sigaction : [EXP, EXP, EXP] EXP;
|
|
|
44 |
Tokdec posix.signal.sigemptyset : [EXP] EXP;
|
|
|
45 |
Tokdec posix.signal.sigset_t : [] SHAPE;
|
|
|
46 |
Tokdec posix.signal.struct_sigaction : [] SHAPE;
|
|
|
47 |
Tokdec posix.signal.sigaction.sa_handler : [] EXP;
|
|
|
48 |
Tokdec posix.signal.sigaction.sa_mask : [] EXP;
|
|
|
49 |
Tokdec posix.signal.sigaction.sa_flags : [] EXP;
|
|
|
50 |
Tokdec posix.signal.sigprocmask : [EXP, EXP, EXP] EXP;
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
Common __TDFstacklim : pointer (locals_alignment)
|
|
|
54 |
= make_null_ptr (locals_alignment);
|
|
|
55 |
|
|
|
56 |
Common __hppahandler : proc;
|
|
|
57 |
/* Initialised by ~Set_signal_handler */
|
|
|
58 |
/* called from numerical exception interrupt or from translated code */
|
|
|
59 |
|
|
|
60 |
Tokdef SIGFPE = []SIGNED_NAT 8;
|
|
|
61 |
Tokdef SIGBUS = []SIGNED_NAT 10;
|
|
|
62 |
Tokdef SIGSEGV = []SIGNED_NAT 11;
|
|
|
63 |
Tokdef SIGUSR1 = []SIGNED_NAT 16;
|
|
|
64 |
/* signal numbers - SIGUSR1 is used for stack overflow
|
|
|
65 |
*/
|
|
|
66 |
|
|
|
67 |
Var allsigs : posix.signal.sigset_t;
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
Tokdef ~Set_signal_handler = [] EXP
|
|
|
72 |
/* must be called before any possible exceptions */
|
|
|
73 |
|
|
|
74 |
Let ovhandler = Proc bottom (sig : Int)
|
|
|
75 |
{
|
|
|
76 |
posix.signal.sigprocmask [posix.signal.SIG_SETMASK, allsigs,
|
|
|
77 |
make_null_ptr (alignment (posix.signal.sigset_t)) ];
|
|
|
78 |
(* __hppahandler) [bottom] (SIGFPE(Int));
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
Let nil_access_handler = Proc bottom (sig : Int)
|
|
|
82 |
{
|
|
|
83 |
posix.signal.sigprocmask [posix.signal.SIG_SETMASK, allsigs,
|
|
|
84 |
make_null_ptr (alignment (posix.signal.sigset_t)) ];
|
|
|
85 |
(* __hppahandler) [bottom] (SIGSEGV(Int));
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
Let __TDFhandler = Proc bottom (err : Int)
|
|
|
89 |
{
|
|
|
90 |
Labelled {
|
|
|
91 |
Case * err (SIGFPE -> overf,
|
|
|
92 |
SIGBUS -> nilref1,
|
|
|
93 |
SIGSEGV -> nilref2,
|
|
|
94 |
SIGUSR1 -> stackov)
|
|
|
95 |
| :overf:
|
|
|
96 |
~Throw[error_val(overflow)] ;
|
|
|
97 |
ansi.stdlib.abort;
|
|
|
98 |
| :nilref1:
|
|
|
99 |
~Throw[error_val(nil_access)] ;
|
|
|
100 |
ansi.stdlib.abort;
|
|
|
101 |
| :nilref2:
|
|
|
102 |
~Throw[error_val(nil_access)] ;
|
|
|
103 |
ansi.stdlib.abort;
|
|
|
104 |
| :stackov:
|
|
|
105 |
~Throw[error_val(stack_overflow)] ;
|
|
|
106 |
ansi.stdlib.abort;
|
|
|
107 |
/* other C signals can be treated similarly */
|
|
|
108 |
};
|
|
|
109 |
return(make_top);
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
Var sigact : posix.signal.struct_sigaction
|
|
|
116 |
|
|
|
117 |
{
|
|
|
118 |
__hppahandler = __TDFhandler;
|
|
|
119 |
|
|
|
120 |
posix.signal.sigemptyset [allsigs];
|
|
|
121 |
posix.signal.sigemptyset [sigact *+. posix.signal.sigaction.sa_mask];
|
|
|
122 |
(sigact *+. posix.signal.sigaction.sa_flags) = 0(Int);
|
|
|
123 |
|
|
|
124 |
(sigact *+. posix.signal.sigaction.sa_handler) = ovhandler;
|
|
|
125 |
posix.signal.sigaction [ SIGFPE(Int), sigact,
|
|
|
126 |
make_null_ptr (alignment (posix.signal.struct_sigaction)) ];
|
|
|
127 |
|
|
|
128 |
(sigact *+. posix.signal.sigaction.sa_handler) = nil_access_handler;
|
|
|
129 |
posix.signal.sigaction [SIGSEGV(Int),sigact,
|
|
|
130 |
make_null_ptr(alignment(posix.signal.struct_sigaction)) ];
|
|
|
131 |
|
|
|
132 |
posix.signal.sigaction [SIGBUS(Int),sigact,
|
|
|
133 |
make_null_ptr(alignment(posix.signal.struct_sigaction)) ];
|
|
|
134 |
|
|
|
135 |
env_size (__TDFhandler)
|
|
|
136 |
};
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
Tokdef ~Sync_handler = [] EXP make_top;
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
Keep (~Set_signal_handler, ~Sync_handler,
|
|
|
143 |
__hppahandler, __TDFstacklim)
|
|
|
144 |
|