1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
|
*** ada/a-init.c.orig Wed Jul 19 15:09:57 2000
--- ada/a-init.c Fri Oct 13 11:25:52 2000
***************
*** 1441,1446 ****
--- 1441,1528 ----
}
+ /*************************************************/
+ /* __gnat_initialize (FreeBSD version) */
+ /*************************************************/
+
+ #elif defined (__FreeBSD__)
+
+ #include <signal.h>
+ #include <unistd.h>
+
+ static void
+ __gnat_error_handler (sig, code, sc)
+ int sig;
+ int code;
+ struct sigcontext *sc;
+ {
+ struct Exception_Data *exception;
+ char *msg;
+
+ switch (sig)
+ {
+ case SIGFPE:
+ exception = &constraint_error;
+ msg = "SIGFPE";
+ break;
+
+ case SIGILL:
+ exception = &constraint_error;
+ msg = "SIGILL";
+ break;
+
+ case SIGSEGV:
+ exception = &storage_error;
+ msg = "stack overflow or erroneous memory access";
+ break;
+
+ case SIGBUS:
+ exception = &constraint_error;
+ msg = "SIGBUS";
+ break;
+
+ default:
+ exception = &program_error;
+ msg = "unhandled signal";
+ }
+
+ Raise_From_Signal_Handler (exception, msg);
+ }
+
+ static void
+ __gnat_install_handler ()
+ {
+ struct sigaction act;
+
+ /* Set up signal handler to map synchronous signals to appropriate
+ exceptions. Make sure that the handler isn't interrupted by another
+ signal that might cause a scheduling event! */
+
+ act.sa_handler = __gnat_error_handler;
+ act.sa_flags = SA_NODEFER | SA_RESTART;
+ (void) sigemptyset (&act.sa_mask);
+
+ (void) sigaction (SIGILL, &act, NULL);
+ (void) sigaction (SIGFPE, &act, NULL);
+ (void) sigaction (SIGSEGV, &act, NULL);
+ (void) sigaction (SIGBUS, &act, NULL);
+ }
+
+ void __gnat_init_float ();
+
+ void
+ __gnat_initialize ()
+ {
+ __gnat_install_handler ();
+
+ /* XXX - Initialize floating-point coprocessor. This call is
+ needed because FreeBSD defaults to 64-bit precision instead
+ of 80-bit precision? We require the full precision for
+ proper operation, given that we have set Max_Digits etc
+ with this in mind */
+ __gnat_init_float ();
+ }
+
/***************************************/
/* __gnat_initialize (default version) */
/***************************************/
***************
*** 1466,1472 ****
WIN32 and could be used under OS/2 */
#if defined (_WIN32) || defined (__INTERIX) || defined (__EMX__) \
! || defined (__Lynx__)
#define HAVE_GNAT_INIT_FLOAT
--- 1548,1554 ----
WIN32 and could be used under OS/2 */
#if defined (_WIN32) || defined (__INTERIX) || defined (__EMX__) \
! || defined (__Lynx__) || defined (__FreeBSD__)
#define HAVE_GNAT_INIT_FLOAT
|