OSDN Git Service

2005-03-29 Robert Dewar <dewar@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-parint.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUN-TIME COMPONENTS                         --
4 --                                                                          --
5 --            S Y S T E M . P A R T I T I O N _ I N T E R F A C E           --
6 --                                                                          --
7 --                                  B o d y                                 --
8 --                   (Dummy body for non-distributed case)                  --
9 --                                                                          --
10 --          Copyright (C) 1995-2004 Free Software Foundation, Inc.          --
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,  59 Temple Place - Suite 330,  Boston, --
21 -- MA 02111-1307, 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 -- GNAT was originally developed  by the GNAT team at  New York University. --
31 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
32 --                                                                          --
33 ------------------------------------------------------------------------------
34
35 package body System.Partition_Interface is
36
37    pragma Warnings (Off); -- supress warnings for unreferenced formals
38
39    M : constant := 7;
40
41    type String_Access is access String;
42
43    --  To have a minimal implementation of U'Partition_ID.
44
45    type Pkg_Node;
46    type Pkg_List is access Pkg_Node;
47    type Pkg_Node is record
48       Name          : String_Access;
49       Subp_Info     : System.Address;
50       Subp_Info_Len : Integer;
51       Next          : Pkg_List;
52    end record;
53
54    Pkg_Head : Pkg_List;
55    Pkg_Tail : Pkg_List;
56
57    function getpid return Integer;
58    pragma Import (C, getpid);
59
60    PID : constant Integer := getpid;
61
62    function Lower (S : String) return String;
63
64    Passive_Prefix : constant String := "SP__";
65    --  String prepended in top of shared passive packages
66
67    procedure Check
68      (Name    : Unit_Name;
69       Version : String;
70       RCI     : Boolean := True)
71    is
72    begin
73       null;
74    end Check;
75
76    -----------------------------
77    -- Get_Active_Partition_Id --
78    -----------------------------
79
80    function Get_Active_Partition_ID
81      (Name : Unit_Name) return System.RPC.Partition_ID
82    is
83       P : Pkg_List := Pkg_Head;
84       N : String   := Lower (Name);
85
86    begin
87       while P /= null loop
88          if P.Name.all = N then
89             return Get_Local_Partition_ID;
90          end if;
91
92          P := P.Next;
93       end loop;
94
95       return M;
96    end Get_Active_Partition_ID;
97
98    ------------------------
99    -- Get_Active_Version --
100    ------------------------
101
102    function Get_Active_Version (Name : Unit_Name) return String is
103    begin
104       return "";
105    end Get_Active_Version;
106
107    ----------------------------
108    -- Get_Local_Partition_Id --
109    ----------------------------
110
111    function Get_Local_Partition_ID return System.RPC.Partition_ID is
112    begin
113       return System.RPC.Partition_ID (PID mod M);
114    end Get_Local_Partition_ID;
115
116    ------------------------------
117    -- Get_Passive_Partition_ID --
118    ------------------------------
119
120    function Get_Passive_Partition_ID
121      (Name : Unit_Name) return System.RPC.Partition_ID
122    is
123    begin
124       return Get_Local_Partition_ID;
125    end Get_Passive_Partition_ID;
126
127    -------------------------
128    -- Get_Passive_Version --
129    -------------------------
130
131    function Get_Passive_Version (Name : Unit_Name) return String is
132    begin
133       return "";
134    end Get_Passive_Version;
135
136    ------------------
137    -- Get_RAS_Info --
138    ------------------
139
140    procedure Get_RAS_Info
141      (Name          :  Unit_Name;
142       Subp_Id       :  Subprogram_Id;
143       Proxy_Address : out Interfaces.Unsigned_64)
144    is
145       LName : constant String := Lower (Name);
146       N : Pkg_List;
147    begin
148       N := Pkg_Head;
149       while N /= null loop
150          if N.Name.all = LName then
151             declare
152                subtype Subprogram_Array is RCI_Subp_Info_Array
153                  (First_RCI_Subprogram_Id ..
154                   First_RCI_Subprogram_Id + N.Subp_Info_Len - 1);
155                Subprograms : Subprogram_Array;
156                for Subprograms'Address use N.Subp_Info;
157                pragma Import (Ada, Subprograms);
158             begin
159                Proxy_Address :=
160                  Interfaces.Unsigned_64 (Subprograms (Integer (Subp_Id)).Addr);
161                return;
162             end;
163          end if;
164          N := N.Next;
165       end loop;
166       Proxy_Address := 0;
167    end Get_RAS_Info;
168
169    ------------------------------
170    -- Get_RCI_Package_Receiver --
171    ------------------------------
172
173    function Get_RCI_Package_Receiver
174      (Name : Unit_Name) return Interfaces.Unsigned_64
175    is
176    begin
177       return 0;
178    end Get_RCI_Package_Receiver;
179
180    -------------------------------
181    -- Get_Unique_Remote_Pointer --
182    -------------------------------
183
184    procedure Get_Unique_Remote_Pointer
185      (Handler : in out RACW_Stub_Type_Access)
186    is
187    begin
188       null;
189    end Get_Unique_Remote_Pointer;
190
191    -----------
192    -- Lower --
193    -----------
194
195    function Lower (S : String) return String is
196       T : String := S;
197
198    begin
199       for J in T'Range loop
200          if T (J) in 'A' .. 'Z' then
201             T (J) := Character'Val (Character'Pos (T (J)) -
202                                     Character'Pos ('A') +
203                                     Character'Pos ('a'));
204          end if;
205       end loop;
206
207       return T;
208    end Lower;
209
210    -------------------------------------
211    -- Raise_Program_Error_Unknown_Tag --
212    -------------------------------------
213
214    procedure Raise_Program_Error_Unknown_Tag
215      (E : Ada.Exceptions.Exception_Occurrence)
216    is
217    begin
218       Ada.Exceptions.Raise_Exception
219         (Program_Error'Identity, Ada.Exceptions.Exception_Message (E));
220    end Raise_Program_Error_Unknown_Tag;
221
222    -----------------
223    -- RCI_Locator --
224    -----------------
225
226    package body RCI_Locator is
227
228       -----------------------------
229       -- Get_Active_Partition_ID --
230       -----------------------------
231
232       function Get_Active_Partition_ID return System.RPC.Partition_ID is
233          P : Pkg_List := Pkg_Head;
234          N : String   := Lower (RCI_Name);
235
236       begin
237          while P /= null loop
238             if P.Name.all = N then
239                return Get_Local_Partition_ID;
240             end if;
241
242             P := P.Next;
243          end loop;
244
245          return M;
246       end Get_Active_Partition_ID;
247
248       ------------------------------
249       -- Get_RCI_Package_Receiver --
250       ------------------------------
251
252       function Get_RCI_Package_Receiver return Interfaces.Unsigned_64 is
253       begin
254          return 0;
255       end Get_RCI_Package_Receiver;
256
257    end RCI_Locator;
258
259    ------------------------------
260    -- Register_Passive_Package --
261    ------------------------------
262
263    procedure Register_Passive_Package
264      (Name    : Unit_Name;
265       Version : String := "")
266    is
267    begin
268       Register_Receiving_Stub
269         (Passive_Prefix & Name, null, Version, System.Null_Address, 0);
270    end Register_Passive_Package;
271
272    -----------------------------
273    -- Register_Receiving_Stub --
274    -----------------------------
275
276    procedure Register_Receiving_Stub
277      (Name          : Unit_Name;
278       Receiver      : RPC_Receiver;
279       Version       : String := "";
280       Subp_Info     : System.Address;
281       Subp_Info_Len : Integer)
282    is
283       N : constant Pkg_List :=
284             new Pkg_Node'(new String'(Lower (Name)),
285                           Subp_Info, Subp_Info_Len,
286                           Next => null);
287    begin
288       if Pkg_Tail = null then
289          Pkg_Head := N;
290       else
291          Pkg_Tail.Next := N;
292       end if;
293       Pkg_Tail := N;
294    end Register_Receiving_Stub;
295
296    ---------
297    -- Run --
298    ---------
299
300    procedure Run
301      (Main : Main_Subprogram_Type := null)
302    is
303    begin
304       if Main /= null then
305          Main.all;
306       end if;
307    end Run;
308
309    --------------------
310    -- Same_Partition --
311    --------------------
312
313    function Same_Partition
314       (Left  : access RACW_Stub_Type;
315        Right : access RACW_Stub_Type) return Boolean
316    is
317       pragma Unreferenced (Left);
318       pragma Unreferenced (Right);
319    begin
320       return True;
321    end Same_Partition;
322
323 end System.Partition_Interface;