use System.OS_Interface;
use type Interfaces.C.int;
- type Signal_List is array (Signal_ID range <>) of Signal_ID;
- Exception_Signals : constant Signal_List (1 .. 4) :=
- (SIGFPE, SIGILL, SIGSEGV, SIGBUS);
-
- Exception_Action : aliased struct_sigaction;
- -- Keep this a variable global so that it is initialized only once
-
- Signal_Mask : aliased sigset_t;
- pragma Import (C, Signal_Mask, "__gnat_signal_mask");
- -- Mask indicating that all exception signals are to be masked
- -- when a signal is propagated.
-
- procedure Notify_Exception
- (signo : Signal;
- siginfo : System.Address;
- sigcontext : System.Address);
- pragma Import (C, Notify_Exception, "__gnat_error_handler");
- -- Map a signal to Ada exception and raise it. Different versions
- -- of VxWorks need different mappings. This is addressed in init.c in
- -- __gnat_map_signal.
-
-----------------------
-- Local Subprograms --
-----------------------
-- 's' Interrupt_State pragma set state to System (use "default"
-- system handler)
- ---------------------------
- -- Initialize_Interrupts --
- ---------------------------
-
- -- Since there is no signal inheritance between VxWorks tasks, we need
- -- to initialize signal handling in each task.
-
- procedure Initialize_Interrupts is
- Result : int;
- old_act : aliased struct_sigaction;
- begin
- for J in Exception_Signals'Range loop
- Result :=
- sigaction
- (Signal (Exception_Signals (J)), Exception_Action'Access,
- old_act'Unchecked_Access);
- pragma Assert (Result = 0);
- end loop;
- end Initialize_Interrupts;
-
----------------
-- Initialize --
----------------
Abort_Task_Interrupt := SIGABRT;
- -- Signal_Mask was initialized in __gnat_install_handler
-
- Exception_Action.sa_handler := Notify_Exception'Address;
- Exception_Action.sa_flags := SA_ONSTACK + SA_SIGINFO;
- Exception_Action.sa_mask := Signal_Mask;
-
-- Initialize hardware interrupt handling
pragma Assert (Reserve = (Interrupt_ID'Range => False));