Add hppa-openbsd target
[official-gcc.git] / gcc / ada / s-tpobop.ads
blob8b260c946484ec43b4149a16c20021edb70cf714
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- S Y S T E M . T A S K I N G . P R O T E C T E D _ O B J E C T S . --
6 -- O P E R A T I O N S --
7 -- --
8 -- S p e c --
9 -- --
10 -- --
11 -- Copyright (C) 1992-2001, Free Software Foundation, Inc. --
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 ------------------------------------------------------------------------------
37 -- This package contains all the extended primitives related to
38 -- Protected_Objects with entries.
39 -- The handling of protected objects with no entries is done in
40 -- System.Tasking.Protected_Objects, the simple routines for protected
41 -- objects with entries in System.Tasking.Protected_Objects.Entries.
42 -- The split between Entries and Operations is needed to break circular
43 -- dependencies inside the run time.
45 -- Note: the compiler generates direct calls to this interface, via Rtsfind.
46 -- Any changes to this interface may require corresponding compiler changes.
48 with Ada.Exceptions;
49 -- used for Exception_Id
51 with System.Tasking.Protected_Objects.Entries;
53 package System.Tasking.Protected_Objects.Operations is
54 pragma Elaborate_Body;
56 type Communication_Block is private;
57 -- Objects of this type are passed between GNARL calls to allow RTS
58 -- information to be preserved.
60 procedure Protected_Entry_Call
61 (Object : Entries.Protection_Entries_Access;
62 E : Protected_Entry_Index;
63 Uninterpreted_Data : System.Address;
64 Mode : Call_Modes;
65 Block : out Communication_Block);
66 -- Make a protected entry call to the specified object.
67 -- Pend a protected entry call on the protected object represented
68 -- by Object. A pended call is not queued; it may be executed immediately
69 -- or queued, depending on the state of the entry barrier.
71 -- E
72 -- The index representing the entry to be called.
74 -- Uninterpreted_Data
75 -- This will be returned by Next_Entry_Call when this call is serviced.
76 -- It can be used by the compiler to pass information between the
77 -- caller and the server, in particular entry parameters.
79 -- Mode
80 -- The kind of call to be pended
82 -- Block
83 -- Information passed between runtime calls by the compiler
85 procedure Timed_Protected_Entry_Call
86 (Object : Entries.Protection_Entries_Access;
87 E : Protected_Entry_Index;
88 Uninterpreted_Data : System.Address;
89 Timeout : Duration;
90 Mode : Delay_Modes;
91 Entry_Call_Successful : out Boolean);
92 -- Same as the Protected_Entry_Call but with time-out specified.
93 -- This routines is used when we do not use ATC mechanism to implement
94 -- timed entry calls.
96 procedure Service_Entries (Object : Entries.Protection_Entries_Access);
97 pragma Inline (Service_Entries);
99 procedure PO_Service_Entries
100 (Self_ID : Task_ID;
101 Object : Entries.Protection_Entries_Access);
102 -- Service all entry queues of the specified object, executing the
103 -- corresponding bodies of any queued entry calls that are waiting
104 -- on True barriers. This is used when the state of a protected
105 -- object may have changed, in particular after the execution of
106 -- the statement sequence of a protected procedure.
107 -- Note that servicing an entry may change the value of one or more
108 -- barriers, so this routine keeps checking barriers until all of
109 -- them are closed.
111 -- This must be called with abortion deferred and with the corresponding
112 -- object locked.
114 procedure Complete_Entry_Body (Object : Entries.Protection_Entries_Access);
115 -- Called from within an entry body procedure, indicates that the
116 -- corresponding entry call has been serviced.
118 procedure Exceptional_Complete_Entry_Body
119 (Object : Entries.Protection_Entries_Access;
120 Ex : Ada.Exceptions.Exception_Id);
121 -- Perform all of the functions of Complete_Entry_Body. In addition,
122 -- report in Ex the exception whose propagation terminated the entry
123 -- body to the runtime system.
125 procedure Cancel_Protected_Entry_Call (Block : in out Communication_Block);
126 -- Attempt to cancel the most recent protected entry call. If the call is
127 -- not queued abortably, wait until it is or until it has completed.
128 -- If the call is actually cancelled, the called object will be
129 -- locked on return from this call. Get_Cancelled (Block) can be
130 -- used to determine if the cancellation took place; there
131 -- may be entries needing service in this case.
133 -- Block passes information between this and other runtime calls.
135 function Enqueued (Block : Communication_Block) return Boolean;
136 -- Returns True if the Protected_Entry_Call which returned the
137 -- specified Block object was queued; False otherwise.
139 function Cancelled (Block : Communication_Block) return Boolean;
140 -- Returns True if the Protected_Entry_Call which returned the
141 -- specified Block object was cancelled, False otherwise.
143 procedure Requeue_Protected_Entry
144 (Object : Entries.Protection_Entries_Access;
145 New_Object : Entries.Protection_Entries_Access;
146 E : Protected_Entry_Index;
147 With_Abort : Boolean);
148 -- If Object = New_Object, queue the protected entry call on Object
149 -- currently being serviced on the queue corresponding to the entry
150 -- represented by E.
152 -- If Object /= New_Object, transfer the call to New_Object.E,
153 -- executing or queuing it as appropriate.
155 -- With_Abort---True if the call is to be queued abortably, false
156 -- otherwise.
158 procedure Requeue_Task_To_Protected_Entry
159 (New_Object : Entries.Protection_Entries_Access;
160 E : Protected_Entry_Index;
161 With_Abort : Boolean);
162 -- Transfer task entry call currently being serviced to entry E
163 -- on New_Object.
165 -- With_Abort---True if the call is to be queued abortably, false
166 -- otherwise.
168 function Protected_Count
169 (Object : Entries.Protection_Entries'Class;
170 E : Protected_Entry_Index)
171 return Natural;
172 -- Return the number of entry calls to E on Object.
174 function Protected_Entry_Caller
175 (Object : Entries.Protection_Entries'Class) return Task_ID;
176 -- Return value of E'Caller, where E is the protected entry currently
177 -- being handled. This will only work if called from within an entry
178 -- body, as required by the LRM (C.7.1(14)).
180 -- For internal use only:
182 procedure PO_Do_Or_Queue
183 (Self_ID : Task_ID;
184 Object : Entries.Protection_Entries_Access;
185 Entry_Call : Entry_Call_Link;
186 With_Abort : Boolean);
187 -- This procedure either executes or queues an entry call, depending
188 -- on the status of the corresponding barrier. It assumes that abortion
189 -- is deferred and that the specified object is locked.
191 private
192 type Communication_Block is record
193 Self : Task_ID;
194 Enqueued : Boolean := True;
195 Cancelled : Boolean := False;
196 end record;
197 pragma Volatile (Communication_Block);
199 -- ?????
200 -- The Communication_Block seems to be a relic.
201 -- At the moment, the compiler seems to be generating
202 -- unnecessary conditional code based on this block.
203 -- See the code generated for async. select with task entry
204 -- call for another way of solving this.
206 end System.Tasking.Protected_Objects.Operations;