exp_ch4.adb (Expand_N_Allocator): Generate meaningful names for a dynamic task if...
[platform/upstream/gcc.git] / gcc / ada / 5fintman.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                GNU ADA 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 --                             $Revision: 1.5 $
10 --                                                                          --
11 --            Copyright (C) 1991-2001, Florida State University             --
12 --                                                                          --
13 -- GNARL is free software; you can  redistribute it  and/or modify it under --
14 -- terms of the  GNU General Public License as published  by the Free Soft- --
15 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
16 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
19 -- for  more details.  You should have  received  a copy of the GNU General --
20 -- Public License  distributed with GNARL; see file COPYING.  If not, write --
21 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
22 -- MA 02111-1307, USA.                                                      --
23 --                                                                          --
24 -- As a special exception,  if other files  instantiate  generics from this --
25 -- unit, or you link  this unit with other files  to produce an executable, --
26 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
27 -- covered  by the  GNU  General  Public  License.  This exception does not --
28 -- however invalidate  any other reasons why  the executable file  might be --
29 -- covered by the  GNU Public License.                                      --
30 --                                                                          --
31 -- GNARL was developed by the GNARL team at Florida State University. It is --
32 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
33 -- State University (http://www.gnat.com).                                  --
34 --                                                                          --
35 ------------------------------------------------------------------------------
36
37 --  This is a SGI Pthread version of this package.
38
39 --  PLEASE DO NOT add any dependences on other packages.
40 --  This package is designed to work with or without tasking support.
41
42 --  Make a careful study of all signals available under the OS,
43 --  to see which need to be reserved, kept always unmasked,
44 --  or kept always unmasked.
45 --  Be on the lookout for special signals that
46 --  may be used by the thread library.
47
48 with Interfaces.C;
49 --  used for int
50
51 with System.OS_Interface;
52 --  used for various Constants, Signal and types
53
54 package body System.Interrupt_Management is
55
56    use System.OS_Interface;
57
58    type Interrupt_List is array (Interrupt_ID range <>) of Interrupt_ID;
59    Exception_Interrupts : constant Interrupt_List :=
60      (SIGTSTP, SIGILL, SIGTRAP, SIGEMT, SIGFPE, SIGBUS, SIGSTOP, SIGKILL,
61       SIGSEGV, SIGSYS, SIGXCPU, SIGXFSZ, SIGPROF, SIGPTINTR, SIGPTRESCHED,
62       SIGABRT, SIGPIPE);
63
64    ---------------------------
65    -- Initialize_Interrupts --
66    ---------------------------
67
68    --  Nothing needs to be done on this platform.
69
70    procedure Initialize_Interrupts is
71    begin
72       null;
73    end Initialize_Interrupts;
74
75    Unreserve_All_Interrupts : Interfaces.C.int;
76    pragma Import
77      (C, Unreserve_All_Interrupts, "__gl_unreserve_all_interrupts");
78
79    use type Interfaces.C.int;
80
81 begin
82    Abort_Task_Interrupt := SIGABRT;
83    --  Change this if you want to use another signal for task abort.
84    --  SIGTERM might be a good one.
85
86    for I in Exception_Interrupts'Range loop
87       Keep_Unmasked (Exception_Interrupts (I)) := True;
88    end loop;
89
90    --  By keeping SIGINT unmasked, allow the user to do a Ctrl-C, but in the
91    --  same time, disable the ability of handling this signal via
92    --  Ada.Interrupts.
93    --  The pragma Unreserve_All_Interrupts let the user the ability to
94    --  change this behavior.
95
96    if Unreserve_All_Interrupts = 0 then
97       Keep_Unmasked (SIGINT) := True;
98    end if;
99
100    Keep_Unmasked (Abort_Task_Interrupt) := True;
101
102    Reserve := Keep_Unmasked or Keep_Masked;
103    Reserve (0) := True;
104 end System.Interrupt_Management;