OSDN Git Service

2001-12-11 David O'Brien <obrien@FreeBSD.org>
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-interr.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                GNU ADA 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 --                             $Revision: 1.12 $                            --
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 with System.Interrupts;
38 --  used for Interrupt_ID
39 --           Parameterless_Handler
40 --           Is_Reserved
41 --           Is_Handler_Attached
42 --           Current_Handler
43 --           Attach_Handler
44 --           Exchange_Handler
45 --           Detach_Handler
46 --           Reference
47
48 with Unchecked_Conversion;
49
50 package body Ada.Interrupts is
51
52    package SI renames System.Interrupts;
53
54    function To_System is new Unchecked_Conversion
55      (Parameterless_Handler, SI.Parameterless_Handler);
56
57    function To_Ada is new Unchecked_Conversion
58      (SI.Parameterless_Handler, Parameterless_Handler);
59
60    --------------------
61    -- Attach_Handler --
62    --------------------
63
64    procedure Attach_Handler
65      (New_Handler : Parameterless_Handler;
66       Interrupt   : Interrupt_ID)
67    is
68    begin
69       SI.Attach_Handler
70         (To_System (New_Handler), SI.Interrupt_ID (Interrupt), False);
71    end Attach_Handler;
72
73    ---------------------
74    -- Current_Handler --
75    ---------------------
76
77    function Current_Handler
78      (Interrupt : Interrupt_ID)
79       return      Parameterless_Handler
80    is
81    begin
82       return To_Ada (SI.Current_Handler (SI.Interrupt_ID (Interrupt)));
83    end Current_Handler;
84
85    --------------------
86    -- Detach_Handler --
87    --------------------
88
89    procedure Detach_Handler (Interrupt : in Interrupt_ID) is
90    begin
91       SI.Detach_Handler (SI.Interrupt_ID (Interrupt), False);
92    end Detach_Handler;
93
94    ----------------------
95    -- Exchange_Handler --
96    ----------------------
97
98    procedure Exchange_Handler
99      (Old_Handler : out Parameterless_Handler;
100       New_Handler : Parameterless_Handler;
101       Interrupt   : Interrupt_ID)
102    is
103       H : SI.Parameterless_Handler;
104
105    begin
106       SI.Exchange_Handler
107         (H, To_System (New_Handler),
108          SI.Interrupt_ID (Interrupt), False);
109       Old_Handler := To_Ada (H);
110    end Exchange_Handler;
111
112    -----------------
113    -- Is_Attached --
114    -----------------
115
116    function Is_Attached (Interrupt : Interrupt_ID) return Boolean is
117    begin
118       return SI.Is_Handler_Attached (SI.Interrupt_ID (Interrupt));
119    end Is_Attached;
120
121    -----------------
122    -- Is_Reserved --
123    -----------------
124
125    function Is_Reserved (Interrupt : Interrupt_ID) return Boolean is
126    begin
127       return SI.Is_Reserved (SI.Interrupt_ID (Interrupt));
128    end Is_Reserved;
129
130    ---------------
131    -- Reference --
132    ---------------
133
134    function Reference (Interrupt : Interrupt_ID) return System.Address is
135    begin
136       return SI.Reference (SI.Interrupt_ID (Interrupt));
137    end Reference;
138
139 end Ada.Interrupts;