OSDN Git Service

2009-02-27 Tobias Burnus <burnus@net-b.de>
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-intman.ads
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 --                                  S p e c                                 --
8 --                                                                          --
9 --          Copyright (C) 1992-2008, Free Software Foundation, Inc.         --
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 ------------------------------------------------------------------------------
33
34 --  This package encapsulates and centralizes information about all uses of
35 --  interrupts (or signals), including the target-dependent mapping of
36 --  interrupts (or signals) to exceptions.
37
38 --  Unlike the original design, System.Interrupt_Management can only be used
39 --  for tasking systems.
40
41 --  PLEASE DO NOT put any subprogram declarations with arguments of type
42 --  Interrupt_ID into the visible part of this package. The type Interrupt_ID
43 --  is used to derive the type in Ada.Interrupts, and adding more operations
44 --  to that type would be illegal according to the Ada Reference Manual. This
45 --  is the reason why the signals sets are implemented using visible arrays
46 --  rather than functions.
47
48 with System.OS_Interface;
49
50 with Interfaces.C;
51
52 package System.Interrupt_Management is
53    pragma Preelaborate;
54
55    type Interrupt_Mask is limited private;
56
57    type Interrupt_ID is new Interfaces.C.int
58      range 0 .. System.OS_Interface.Max_Interrupt;
59
60    type Interrupt_Set is array (Interrupt_ID) of Boolean;
61
62    --  The following objects serve as constants, but are initialized in the
63    --  body to aid portability. This permits us to use more portable names for
64    --  interrupts, where distinct names may map to the same interrupt ID
65    --  value.
66
67    --  For example, suppose SIGRARE is a signal that is not defined on all
68    --  systems, but is always reserved when it is defined. If we have the
69    --  convention that ID zero is not used for any "real" signals, and SIGRARE
70    --  = 0 when SIGRARE is not one of the locally supported signals, we can
71    --  write:
72    --     Reserved (SIGRARE) := True;
73    --  and the initialization code will be portable.
74
75    Abort_Task_Interrupt : Interrupt_ID;
76    --  The interrupt that is used to implement task abort if an interrupt is
77    --  used for that purpose. This is one of the reserved interrupts.
78
79    Keep_Unmasked : Interrupt_Set := (others => False);
80    --  Keep_Unmasked (I) is true iff the interrupt I is one that must that
81    --  must be kept unmasked at all times, except (perhaps) for short critical
82    --  sections. This includes interrupts that are mapped to exceptions (see
83    --  System.Interrupt_Exceptions.Is_Exception), but may also include
84    --  interrupts (e.g. timer) that need to be kept unmasked for other
85    --  reasons. Where interrupts are implemented as OS signals, and signal
86    --  masking is per-task, the interrupt should be unmasked in ALL TASKS.
87
88    Reserve : Interrupt_Set := (others => False);
89    --  Reserve (I) is true iff the interrupt I is one that cannot be permitted
90    --  to be attached to a user handler. The possible reasons are many. For
91    --  example, it may be mapped to an exception used to implement task abort,
92    --  or used to implement time delays.
93
94    procedure Initialize;
95    --  Initialize the various variables defined in this package. This procedure
96    --  must be called before accessing any object from this package, and can be
97    --  called multiple times.
98
99 private
100    type Interrupt_Mask is new System.OS_Interface.sigset_t;
101    --  In some implementations Interrupt_Mask is represented as a linked list
102
103    procedure Adjust_Context_For_Raise
104      (Signo    : System.OS_Interface.Signal;
105       Ucontext : System.Address);
106    pragma Import
107      (C, Adjust_Context_For_Raise, "__gnat_adjust_context_for_raise");
108    --  Target specific hook performing adjustments to the signal's machine
109    --  context, to be called before an exception may be raised from a signal
110    --  handler. This service is provided by init.c, together with the
111    --  non-tasking signal handler.
112
113 end System.Interrupt_Management;