fixing pr42337
[official-gcc.git] / gcc / ada / s-intman-irix.adb
blobccd91bfa7c8f16bff36e73edcc82cd8578bdd7a2
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- S Y S T E M . I N T E R R U P T _ M A N A G E M E N T --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1995-2007, AdaCore --
10 -- --
11 -- GNARL is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNARL; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNARL was developed by the GNARL team at Florida State University. --
30 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 -- This is a SGI Pthread version of this package
36 -- Make a careful study of all signals available under the OS, to see which
37 -- need to be reserved, kept always unmasked, or kept always unmasked. Be on
38 -- the lookout for special signals that may be used by the thread library.
40 package body System.Interrupt_Management is
42 use System.OS_Interface;
44 type Interrupt_List is array (Interrupt_ID range <>) of Interrupt_ID;
45 Exception_Interrupts : constant Interrupt_List :=
46 (SIGTSTP, SIGILL, SIGTRAP, SIGEMT, SIGFPE, SIGBUS, SIGSTOP, SIGKILL,
47 SIGSEGV, SIGSYS, SIGXCPU, SIGXFSZ, SIGPROF, SIGPTINTR, SIGPTRESCHED,
48 SIGABRT, SIGPIPE);
50 Unreserve_All_Interrupts : Interfaces.C.int;
51 pragma Import
52 (C, Unreserve_All_Interrupts, "__gl_unreserve_all_interrupts");
54 function State (Int : Interrupt_ID) return Character;
55 pragma Import (C, State, "__gnat_get_interrupt_state");
57 -- Get interrupt state. Defined in a-init.c
58 -- The input argument is the interrupt number,
59 -- and the result is one of the following:
61 User : constant Character := 'u';
62 Runtime : constant Character := 'r';
63 Default : constant Character := 's';
64 -- 'n' this interrupt not set by any Interrupt_State pragma
65 -- 'u' Interrupt_State pragma set state to User
66 -- 'r' Interrupt_State pragma set state to Runtime
67 -- 's' Interrupt_State pragma set state to System (use "default"
68 -- system handler)
70 ----------------
71 -- Initialize --
72 ----------------
74 Initialized : Boolean := False;
76 procedure Initialize is
77 use type Interfaces.C.int;
78 begin
79 if Initialized then
80 return;
81 end if;
83 Initialized := True;
84 Abort_Task_Interrupt := SIGABRT;
86 -- Change this if you want to use another signal for task abort.
87 -- SIGTERM might be a good one.
89 pragma Assert (Keep_Unmasked = (Interrupt_ID'Range => False));
90 pragma Assert (Reserve = (Interrupt_ID'Range => False));
92 -- Process state of exception signals
94 for J in Exception_Interrupts'Range loop
95 if State (Exception_Interrupts (J)) /= User then
96 Keep_Unmasked (Exception_Interrupts (J)) := True;
97 Reserve (Exception_Interrupts (J)) := True;
98 end if;
99 end loop;
101 if State (Abort_Task_Interrupt) /= User then
102 Keep_Unmasked (Abort_Task_Interrupt) := True;
103 Reserve (Abort_Task_Interrupt) := True;
104 end if;
106 -- Set SIGINT to unmasked state as long as it's
107 -- not in "User" state. Check for Unreserve_All_Interrupts last
109 if State (SIGINT) /= User then
110 Keep_Unmasked (SIGINT) := True;
111 end if;
113 -- Check all signals for state that requires keeping them
114 -- unmasked and reserved
116 for J in Interrupt_ID'Range loop
117 if State (J) = Default or else State (J) = Runtime then
118 Keep_Unmasked (J) := True;
119 Reserve (J) := True;
120 end if;
121 end loop;
123 -- Process pragma Unreserve_All_Interrupts. This overrides any
124 -- settings due to pragma Interrupt_State:
126 if Unreserve_All_Interrupts /= 0 then
127 Keep_Unmasked (SIGINT) := False;
128 Reserve (SIGINT) := False;
129 end if;
131 -- We do not have Signal 0 in reality. We just use this value
132 -- to identify not existing signals (see s-intnam.ads). Therefore,
133 -- Signal 0 should not be used in all signal related operations hence
134 -- mark it as reserved.
136 Reserve (0) := True;
137 end Initialize;
139 end System.Interrupt_Management;