* dwarf2out.c (loc_descriptor_from_tree, case CONSTRUCTOR): New case.
[official-gcc.git] / gcc / ada / s-tposen.ads
blobd5f48785fcdf2783ff6b1bba5ec54796b706e764
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- SYSTEM.TASKING.PROTECTED_OBJECTS.SINGLE_ENTRY --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1991-2001 Florida State University --
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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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. It is --
30 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
31 -- State University (http://www.gnat.com). --
32 -- --
33 ------------------------------------------------------------------------------
35 -- This package provides an optimized version of Protected_Objects.Operations
36 -- and Protected_Objects.Entries making the following assumptions:
38 -- PO have only one entry
39 -- There is only one caller at a time (No_Entry_Queue)
40 -- There is no dynamic priority support (No_Dynamic_Priorities)
41 -- No Abort Statements
42 -- (No_Abort_Statements, Max_Asynchronous_Select_Nesting => 0)
43 -- PO are at library level
44 -- None of the tasks will terminate (no need for finalization)
46 -- This interface is intended to be used in the ravenscar profile, the
47 -- compiler is responsible for ensuring that the conditions mentioned above
48 -- are respected, except for the No_Entry_Queue restriction that is checked
49 -- dynamically in this package, since the check cannot be performed at compile
50 -- time, and is relatively cheap (see body).
52 -- This package is part of the high level tasking interface used by the
53 -- compiler to expand Ada 95 tasking constructs into simpler run time calls
54 -- (aka GNARLI, GNU Ada Run-time Library Interface)
56 -- Note: the compiler generates direct calls to this interface, via Rtsfind.
57 -- Any changes to this interface may require corresponding compiler changes
58 -- in exp_ch9.adb and possibly exp_ch7.adb
60 package System.Tasking.Protected_Objects.Single_Entry is
61 pragma Elaborate_Body;
63 ---------------------------------
64 -- Compiler Interface (GNARLI) --
65 ---------------------------------
67 -- The compiler will expand in the GNAT tree the following construct:
69 -- protected PO is
70 -- entry E;
71 -- procedure P;
72 -- private
73 -- Open : Boolean := False;
74 -- end PO;
76 -- protected body PO is
77 -- entry E when Open is
78 -- ...variable declarations...
79 -- begin
80 -- ...B...
81 -- end E;
83 -- procedure P is
84 -- ...variable declarations...
85 -- begin
86 -- ...C...
87 -- end P;
88 -- end PO;
90 -- as follows:
92 -- protected type poT is
93 -- entry e;
94 -- procedure p;
95 -- private
96 -- open : boolean := false;
97 -- end poT;
98 -- type poTV is limited record
99 -- open : boolean := false;
100 -- _object : aliased protection_entry;
101 -- end record;
102 -- procedure poPT__E1s (O : address; P : address; E :
103 -- protected_entry_index);
104 -- function poPT__B2s (O : address; E : protected_entry_index) return
105 -- boolean;
106 -- procedure poPT__pN (_object : in out poTV);
107 -- procedure poPT__pP (_object : in out poTV);
108 -- poTA : aliased entry_body := (
109 -- barrier => poPT__B2s'unrestricted_access,
110 -- action => poPT__E1s'unrestricted_access);
111 -- freeze poTV [
112 -- procedure _init_proc (_init : in out poTV) is
113 -- begin
114 -- _init.open := false;
115 -- _init_proc (_init._object);
116 -- initialize_protection_entry (_init._object'unchecked_access,
117 -- unspecified_priority, _init'address, poTA'
118 -- unrestricted_access);
119 -- return;
120 -- end _init_proc;
121 -- ]
122 -- po : poT;
123 -- _init_proc (poTV!(po));
125 -- function poPT__B2s (O : address; E : protected_entry_index) return
126 -- boolean is
127 -- type poTVP is access poTV;
128 -- _object : poTVP := poTVP!(O);
129 -- poR : protection_entry renames _object._object;
130 -- openP : boolean renames _object.open;
131 -- begin
132 -- return open;
133 -- end poPT__B2s;
135 -- procedure poPT__E1s (O : address; P : address; E :
136 -- protected_entry_index) is
137 -- type poTVP is access poTV;
138 -- _object : poTVP := poTVP!(O);
139 -- begin
140 -- B1b : declare
141 -- poR : protection_entry renames _object._object;
142 -- openP : boolean renames _object.open;
143 -- ...variable declarations...
144 -- begin
145 -- ...B...
146 -- end B1b;
147 -- complete_single_entry_body (_object._object'unchecked_access);
148 -- return;
149 -- exception
150 -- when all others =>
151 -- exceptional_complete_single_entry_body (_object._object'
152 -- unchecked_access, get_gnat_exception);
153 -- return;
154 -- end poPT__E1s;
156 -- procedure poPT__pN (_object : in out poTV) is
157 -- poR : protection_entry renames _object._object;
158 -- openP : boolean renames _object.open;
159 -- ...variable declarations...
160 -- begin
161 -- ...C...
162 -- return;
163 -- end poPT__pN;
165 -- procedure poPT__pP (_object : in out poTV) is
166 -- procedure _clean is
167 -- begin
168 -- service_entry (_object._object'unchecked_access);
169 -- unlock_entry (_object._object'unchecked_access);
170 -- return;
171 -- end _clean;
172 -- begin
173 -- lock_entry (_object._object'unchecked_access);
174 -- B5b : begin
175 -- poPT__pN (_object);
176 -- at end
177 -- _clean;
178 -- end B5b;
179 -- return;
180 -- end poPT__pP;
182 type Protection_Entry is limited private;
183 -- This type contains the GNARL state of a protected object. The
184 -- application-defined portion of the state (i.e. private objects)
185 -- is maintained by the compiler-generated code.
187 type Protection_Entry_Access is access all Protection_Entry;
189 procedure Initialize_Protection_Entry
190 (Object : Protection_Entry_Access;
191 Ceiling_Priority : Integer;
192 Compiler_Info : System.Address;
193 Entry_Body : Entry_Body_Access);
194 -- Initialize the Object parameter so that it can be used by the run time
195 -- to keep track of the runtime state of a protected object.
197 procedure Lock_Entry (Object : Protection_Entry_Access);
198 -- Lock a protected object for write access. Upon return, the caller
199 -- owns the lock to this object, and no other call to Lock or
200 -- Lock_Read_Only with the same argument will return until the
201 -- corresponding call to Unlock has been made by the caller.
203 procedure Lock_Read_Only_Entry
204 (Object : Protection_Entry_Access);
205 -- Lock a protected object for read access. Upon return, the caller
206 -- owns the lock for read access, and no other calls to Lock
207 -- with the same argument will return until the corresponding call
208 -- to Unlock has been made by the caller. Other cals to Lock_Read_Only
209 -- may (but need not) return before the call to Unlock, and the
210 -- corresponding callers will also own the lock for read access.
212 procedure Unlock_Entry (Object : Protection_Entry_Access);
213 -- Relinquish ownership of the lock for the object represented by
214 -- the Object parameter. If this ownership was for write access, or
215 -- if it was for read access where there are no other read access
216 -- locks outstanding, one (or more, in the case of Lock_Read_Only)
217 -- of the tasks waiting on this lock (if any) will be given the
218 -- lock and allowed to return from the Lock or Lock_Read_Only call.
220 procedure Service_Entry (Object : Protection_Entry_Access);
221 -- Service the entry queue of the specified object, executing the
222 -- corresponding body of any queued entry call that is waiting on True
223 -- barrier. This is used when the state of a protected object may have
224 -- changed, in particular after the execution of the statement sequence of
225 -- a protected procedure.
226 -- This must be called with abortion deferred and with the corresponding
227 -- object locked.
229 procedure Protected_Single_Entry_Call
230 (Object : Protection_Entry_Access;
231 Uninterpreted_Data : System.Address;
232 Mode : Call_Modes);
233 -- Make a protected entry call to the specified object.
234 -- Pend a protected entry call on the protected object represented
235 -- by Object. A pended call is not queued; it may be executed immediately
236 -- or queued, depending on the state of the entry barrier.
238 -- Uninterpreted_Data
239 -- This will be returned by Next_Entry_Call when this call is serviced.
240 -- It can be used by the compiler to pass information between the
241 -- caller and the server, in particular entry parameters.
243 -- Mode
244 -- The kind of call to be pended
246 procedure Timed_Protected_Single_Entry_Call
247 (Object : Protection_Entry_Access;
248 Uninterpreted_Data : System.Address;
249 Timeout : Duration;
250 Mode : Delay_Modes;
251 Entry_Call_Successful : out Boolean);
252 -- Same as the Protected_Entry_Call but with time-out specified.
253 -- This routine is used to implement timed entry calls.
255 procedure Complete_Single_Entry_Body
256 (Object : Protection_Entry_Access);
257 pragma Inline (Complete_Single_Entry_Body);
258 -- Called from within an entry body procedure, indicates that the
259 -- corresponding entry call has been serviced.
261 procedure Exceptional_Complete_Single_Entry_Body
262 (Object : Protection_Entry_Access;
263 Ex : Ada.Exceptions.Exception_Id);
264 -- Perform all of the functions of Complete_Entry_Body. In addition,
265 -- report in Ex the exception whose propagation terminated the entry
266 -- body to the runtime system.
268 function Protected_Count_Entry (Object : Protection_Entry)
269 return Natural;
270 -- Return the number of entry calls on Object (0 or 1).
272 function Protected_Single_Entry_Caller (Object : Protection_Entry)
273 return Task_ID;
274 -- Return value of E'Caller, where E is the protected entry currently
275 -- being handled. This will only work if called from within an
276 -- entry body, as required by the LRM (C.7.1(14)).
278 private
279 type Protection_Entry is record
280 L : aliased Task_Primitives.Lock;
281 Compiler_Info : System.Address;
282 Call_In_Progress : Entry_Call_Link;
283 Ceiling : System.Any_Priority;
284 Entry_Body : Entry_Body_Access;
285 Entry_Queue : Entry_Call_Link;
286 end record;
287 pragma Volatile (Protection_Entry);
288 for Protection_Entry'Alignment use Standard'Maximum_Alignment;
289 -- Use maximum alignement so that one can convert a protection_entry_access
290 -- to a task_id.
292 end System.Tasking.Protected_Objects.Single_Entry;