OSDN Git Service

2007-04-20 Robert Dewar <dewar@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-interr.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
4 --                                                                          --
5 --                         A D A . I N T E R R U P T S                      --
6 --                                                                          --
7 --                                  B o d y                                 --
8 --                                                                          --
9 --             Copyright (C) 1991-1994, Florida State University            --
10 --                     Copyright (C) 1995-2007, AdaCore                     --
11 --                                                                          --
12 -- GNARL is free software; you can  redistribute it  and/or modify it under --
13 -- terms of the  GNU General Public License as published  by the Free Soft- --
14 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
15 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
18 -- for  more details.  You should have  received  a copy of the GNU General --
19 -- Public License  distributed with GNARL; see file COPYING.  If not, write --
20 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
21 -- Boston, MA 02110-1301, USA.                                              --
22 --                                                                          --
23 -- As a special exception,  if other files  instantiate  generics from this --
24 -- unit, or you link  this unit with other files  to produce an executable, --
25 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
26 -- covered  by the  GNU  General  Public  License.  This exception does not --
27 -- however invalidate  any other reasons why  the executable file  might be --
28 -- covered by the  GNU Public License.                                      --
29 --                                                                          --
30 -- GNARL was developed by the GNARL team at Florida State University.       --
31 -- Extensive contributions were provided by Ada Core Technologies, Inc.     --
32 --                                                                          --
33 ------------------------------------------------------------------------------
34
35 with Ada.Unchecked_Conversion;
36
37 package body Ada.Interrupts is
38
39    package SI renames System.Interrupts;
40
41    function To_System is new Ada.Unchecked_Conversion
42      (Parameterless_Handler, SI.Parameterless_Handler);
43
44    function To_Ada is new Ada.Unchecked_Conversion
45      (SI.Parameterless_Handler, Parameterless_Handler);
46
47    --------------------
48    -- Attach_Handler --
49    --------------------
50
51    procedure Attach_Handler
52      (New_Handler : Parameterless_Handler;
53       Interrupt   : Interrupt_ID)
54    is
55    begin
56       SI.Attach_Handler
57         (To_System (New_Handler), SI.Interrupt_ID (Interrupt), False);
58    end Attach_Handler;
59
60    ---------------------
61    -- Current_Handler --
62    ---------------------
63
64    function Current_Handler
65      (Interrupt : Interrupt_ID) return Parameterless_Handler
66    is
67    begin
68       return To_Ada (SI.Current_Handler (SI.Interrupt_ID (Interrupt)));
69    end Current_Handler;
70
71    --------------------
72    -- Detach_Handler --
73    --------------------
74
75    procedure Detach_Handler (Interrupt : Interrupt_ID) is
76    begin
77       SI.Detach_Handler (SI.Interrupt_ID (Interrupt), False);
78    end Detach_Handler;
79
80    ----------------------
81    -- Exchange_Handler --
82    ----------------------
83
84    procedure Exchange_Handler
85      (Old_Handler : out Parameterless_Handler;
86       New_Handler : Parameterless_Handler;
87       Interrupt   : Interrupt_ID)
88    is
89       H : SI.Parameterless_Handler;
90
91    begin
92       SI.Exchange_Handler
93         (H, To_System (New_Handler),
94          SI.Interrupt_ID (Interrupt), False);
95       Old_Handler := To_Ada (H);
96    end Exchange_Handler;
97
98    -----------------
99    -- Is_Attached --
100    -----------------
101
102    function Is_Attached (Interrupt : Interrupt_ID) return Boolean is
103    begin
104       return SI.Is_Handler_Attached (SI.Interrupt_ID (Interrupt));
105    end Is_Attached;
106
107    -----------------
108    -- Is_Reserved --
109    -----------------
110
111    function Is_Reserved (Interrupt : Interrupt_ID) return Boolean is
112    begin
113       return SI.Is_Reserved (SI.Interrupt_ID (Interrupt));
114    end Is_Reserved;
115
116    ---------------
117    -- Reference --
118    ---------------
119
120    function Reference (Interrupt : Interrupt_ID) return System.Address is
121    begin
122       return SI.Reference (SI.Interrupt_ID (Interrupt));
123    end Reference;
124
125 end Ada.Interrupts;