Subversion Repositories tendra.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
  Exception tokens for alphatrans
31
*/
32
 
33
Common __alpha_stack_limit : pointer (locals_alignment) = 
34
                            make_null_ptr(locals_alignment);
35
 
36
Common __alpha_errhandler : proc; /* initialised by ~Set_signal_handler */
37
 
38
Tokdec ~Throw: [NAT] EXP;
39
Tokdec ansi.stdlib.abort : [] EXP;
40
Tokdec ansi.signal.SIGFPE : [] EXP;
41
Tokdec ansi.signal.SIGSEGV : [] EXP;
42
/*
43
Tokdec svid3.signal.SIGTRAP : [] EXP;
44
*/
45
Tokdec posix.signal.SIG_SETMASK : [] EXP;
46
Tokdec posix.signal.sigaction : [EXP, EXP, EXP] EXP;
47
Tokdec posix.signal.sigemptyset : [EXP] EXP;
48
Tokdec posix.signal.sigset_t : [] SHAPE;
49
Tokdec posix.signal.struct_sigaction : [] SHAPE;
50
Tokdec posix.signal.sigaction.sa_handler : [] EXP;
51
Tokdec posix.signal.sigaction.sa_mask : [] EXP;
52
Tokdec posix.signal.sigaction.sa_flags : [] EXP;
53
Tokdec posix.signal.sigprocmask : [EXP, EXP, EXP] EXP;
54
 
55
/*
56
  Sync handler delays subsequent processing until any pending
57
  exceptions have been raised
58
*/
59
Tokdec ~Sync_handler : [] EXP;
60
 
61
Var allsigs : posix.signal.sigset_t;
62
 
63
/*
64
  Called before any use of error treatment
65
 
66
  Sets up each of the signal handlers
67
*/
68
Tokdef ~Set_signal_handler = [] EXP 
69
 
70
Let ovhandler = Proc bottom (sig : Int)
71
  {
72
    posix.signal.sigprocmask [posix.signal.SIG_SETMASK, allsigs,
73
                make_null_ptr (alignment (posix.signal.sigset_t)) ];
74
    (* __alpha_errhandler) [bottom] (+ error_val(overflow)(Int));
75
  }
76
 
77
Let stack_handler = Proc bottom (sig : Int){
78
      posix.signal.sigprocmask [posix.signal.SIG_SETMASK, allsigs,
79
                make_null_ptr (alignment (posix.signal.sigset_t)) ];
80
      (* __alpha_errhandler) [bottom] (+ error_val(stack_overflow)(Int));
81
}
82
 
83
Let nil_access_handler = Proc bottom (sig : Int){
84
      posix.signal.sigprocmask [posix.signal.SIG_SETMASK, allsigs,
85
                make_null_ptr (alignment (posix.signal.sigset_t)) ];
86
      (* __alpha_errhandler) [bottom] (+ error_val(nil_access)(Int));
87
}
88
 
89
 
90
Let errhandler = Proc bottom (err : Int)
91
{	/* called from numerical exception interrupt or from translated code */
92
  ?{	? (* err == + error_val(overflow)(Int));
93
	~Throw[error_val(overflow)];
94
	ansi.stdlib.abort ;
95
  | ?{	? (* err == + error_val(stack_overflow)(Int));
96
	~Throw[error_val(stack_overflow)];
97
	ansi.stdlib.abort ;
98
    |	~Throw[error_val(nil_access)];
99
	ansi.stdlib.abort ;
100
  } }
101
}
102
 
103
 
104
Var sigact : posix.signal.struct_sigaction
105
{
106
  __alpha_errhandler = errhandler;
107
  posix.signal.sigemptyset [allsigs];
108
  (sigact *+. posix.signal.sigaction.sa_handler) = ovhandler;
109
  posix.signal.sigemptyset [sigact *+. posix.signal.sigaction.sa_mask];
110
  (sigact *+. posix.signal.sigaction.sa_flags) = 0(Int);
111
  posix.signal.sigaction [ ansi.signal.SIGFPE, sigact, 
112
		make_null_ptr (alignment (posix.signal.struct_sigaction)) ];
113
  /* assembler functions (divx, remx, etc) produce SIGTRAP internally,
114
     so treat it as overflow */
115
/*
116
  posix.signal.sigaction [svid3.signal.SIGTRAP,sigact,
117
		 make_null_ptr(alignment(posix.signal.struct_sigaction)) ];
118
*/
119
  (sigact *+. posix.signal.sigaction.sa_handler) = nil_access_handler;
120
  posix.signal.sigaction [ansi.signal.SIGSEGV,sigact,
121
		 make_null_ptr(alignment(posix.signal.struct_sigaction)) ];
122
 
123
  env_size (errhandler)
124
};
125
 
126
 
127
Keep (~Set_signal_handler, ~Sync_handler, __alpha_errhandler, 
128
      __alpha_stack_limit)