6 |
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 |
Iddec printf:proc;
|
|
|
32 |
Tokdec TRY :[EXP, NAT, EXP]EXP;
|
|
|
33 |
Tokdec SET_SIGNAL_HANDLER: []EXP;
|
|
|
34 |
Tokdec MAKE_STACK_LIMIT:[EXP]EXP;
|
|
|
35 |
|
|
|
36 |
String sof = "OVERFLOW \n";
|
|
|
37 |
String sna = "NIL ACCESS\n";
|
|
|
38 |
String sso = "STACK OVERFLOW\n";
|
|
|
39 |
String send = "END\n";
|
|
|
40 |
String sx = "Current env = %d - %d\n";
|
|
|
41 |
|
|
|
42 |
Iddec f:proc;
|
|
|
43 |
|
|
|
44 |
Proc f = General top(;) Check_stack {
|
|
|
45 |
f[top]();
|
|
|
46 |
return(make_top)
|
|
|
47 |
};
|
|
|
48 |
|
|
|
49 |
Iddec main:proc;
|
|
|
50 |
|
|
|
51 |
Proc main = top()
|
|
|
52 |
Var i:Int
|
|
|
53 |
Let p = make_null_ptr(alignment(Int))
|
|
|
54 |
Let msize = env_size(main)
|
|
|
55 |
Let tosize = msize .+.
|
|
|
56 |
(offset_pad(alignment(Int),shape_offset(Int)) .* 100(Int))
|
|
|
57 |
Let stl = MAKE_STACK_LIMIT[tosize]
|
|
|
58 |
|
|
|
59 |
{
|
|
|
60 |
set_stack_limit(stl);
|
|
|
61 |
printf[top](sx, current_env,stl);
|
|
|
62 |
SET_SIGNAL_HANDLER;
|
|
|
63 |
TRY[ i = * (Int) p, error_val(nil_access), printf[top](sna)];
|
|
|
64 |
|
|
|
65 |
printf[top](sx, current_env,
|
|
|
66 |
make_stack_limit(current_env, tosize, offset_zero(alignment(Int))));
|
|
|
67 |
|
|
|
68 |
TRY[plus([overflow], 16r7fffffff(Int), 16r1(Int)),
|
|
|
69 |
error_val(overflow),
|
|
|
70 |
printf[top](sof)
|
|
|
71 |
];
|
|
|
72 |
|
|
|
73 |
printf[top](sx, current_env,
|
|
|
74 |
make_stack_limit(current_env, tosize, offset_zero(alignment(Int))));
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
TRY[ f[top][;], error_val(stack_overflow), printf[top](sso)];
|
|
|
78 |
|
|
|
79 |
printf[top](send,i,p);
|
|
|
80 |
return(make_top)
|
|
|
81 |
|
|
|
82 |
};
|
|
|
83 |
|
|
|
84 |
|
|
|
85 |
Keep (main)
|