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 sparctrans
31
*/
32
 
33
Common __sparc_stack_limit : pointer (locals_alignment) = 
34
                            make_null_ptr(locals_alignment);
35
 
36
Common __sparc_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
Tokdec posix.signal.SIGUSR1 : [] EXP;
43
Tokdec posix.signal.SIG_SETMASK : [] EXP;
44
Tokdec posix.signal.sigaction : [EXP, EXP, EXP] EXP;
45
Tokdec posix.signal.sigemptyset : [EXP] EXP;
46
Tokdec posix.signal.sigset_t : [] SHAPE;
47
Tokdec posix.signal.struct_sigaction : [] SHAPE;
48
Tokdec posix.signal.sigaction.sa_handler : [] EXP;
49
Tokdec posix.signal.sigaction.sa_mask : [] EXP;
50
Tokdec posix.signal.sigaction.sa_flags : [] EXP;
51
Tokdec posix.signal.sigprocmask : [EXP, EXP, EXP] EXP;
52
 
53
/*
54
    Sync handler delays subsequent processing until any pending
55
    exceptions have been raised
56
*/
57
Tokdec ~Sync_handler : [] EXP;
58
 
59
Var allsigs : posix.signal.sigset_t;
60
 
61
/*
62
  Called before any use of error treatment
63
 
64
  Sets up each of the signal handlers
65
*/
66
Tokdef ~Set_signal_handler = [] EXP 
67
 
68
Let ovhandler = Proc bottom (sig : Int)
69
  {
70
    posix.signal.sigprocmask [posix.signal.SIG_SETMASK, allsigs,
71
                make_null_ptr (alignment (posix.signal.sigset_t)) ];
72
    (* __sparc_errhandler) [bottom] (+ error_val(overflow)(Int));
73
  }
74
 
75
 
76
Let nil_access_handler = Proc bottom (sig : Int){
77
      posix.signal.sigprocmask [posix.signal.SIG_SETMASK, allsigs,
78
                make_null_ptr (alignment (posix.signal.sigset_t)) ];
79
      (* __sparc_errhandler) [bottom] (+ error_val(nil_access)(Int));
80
}
81
 
82
 
83
 
84
Let errhandler = Proc bottom (err : Int)
85
{	/* called from numerical exception interrupt or from translated code */
86
  ?{	? (* err == + error_val(overflow)(Int));
87
	~Throw[error_val(overflow)];
88
	ansi.stdlib.abort ;
89
  | ?{	? (* err == + error_val(stack_overflow)(Int));
90
	~Throw[error_val(stack_overflow)];
91
	ansi.stdlib.abort ;
92
    |	~Throw[error_val(nil_access)];
93
	ansi.stdlib.abort ;
94
  } }
95
}
96
 
97
 
98
Var sigact : posix.signal.struct_sigaction
99
{
100
  __sparc_errhandler = errhandler;
101
  posix.signal.sigemptyset [allsigs];
102
  (sigact *+. posix.signal.sigaction.sa_handler) = ovhandler;
103
  posix.signal.sigemptyset [sigact *+. posix.signal.sigaction.sa_mask];
104
  (sigact *+. posix.signal.sigaction.sa_flags) = 0(Int);
105
  posix.signal.sigaction [ ansi.signal.SIGFPE, sigact, 
106
		make_null_ptr (alignment (posix.signal.struct_sigaction)) ];
107
  (sigact *+. posix.signal.sigaction.sa_handler) = nil_access_handler;
108
  posix.signal.sigaction [ansi.signal.SIGSEGV,sigact,
109
		 make_null_ptr(alignment(posix.signal.struct_sigaction)) ];
110
  env_size (errhandler)
111
};
112
 
113
 
114
Keep (~Set_signal_handler, ~Sync_handler, __sparc_errhandler, 
115
      __sparc_stack_limit)