1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
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 --
8 -- (Dummy body for non-distributed case) --
10 -- Copyright (C) 1995-2020, Free Software Foundation, Inc. --
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 3, or (at your option) any later ver- --
15 -- sion. GNAT 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. --
19 -- As a special exception under Section 7 of GPL version 3, you are granted --
20 -- additional permissions described in the GCC Runtime Library Exception, --
21 -- version 3.1, as published by the Free Software Foundation. --
23 -- You should have received a copy of the GNU General Public License and --
24 -- a copy of the GCC Runtime Library Exception along with this program; --
25 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
26 -- <http://www.gnu.org/licenses/>. --
28 -- GNAT was originally developed by the GNAT team at New York University. --
29 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 ------------------------------------------------------------------------------
33 package body System.Partition_Interface is
35 pragma Warnings (Off); -- suppress warnings for unreferenced formals
39 type String_Access is access String;
41 -- To have a minimal implementation of U'Partition_ID
44 type Pkg_List is access Pkg_Node;
45 type Pkg_Node is record
47 Subp_Info : System.Address;
48 Subp_Info_Len : Integer;
55 function getpid return Integer;
56 pragma Import (C, getpid);
58 PID : constant Integer := getpid;
60 function Lower (S : String) return String;
62 Passive_Prefix : constant String := "SP__";
63 -- String prepended in top of shared passive packages
68 RCI : Boolean := True)
74 -----------------------------
75 -- Get_Active_Partition_ID --
76 -----------------------------
78 function Get_Active_Partition_ID
79 (Name : Unit_Name) return System.RPC.Partition_ID
81 P : Pkg_List := Pkg_Head;
82 N : String := Lower (Name);
86 if P.Name.all = N then
87 return Get_Local_Partition_ID;
94 end Get_Active_Partition_ID;
96 ------------------------
97 -- Get_Active_Version --
98 ------------------------
100 function Get_Active_Version (Name : Unit_Name) return String is
103 end Get_Active_Version;
105 ----------------------------
106 -- Get_Local_Partition_ID --
107 ----------------------------
109 function Get_Local_Partition_ID return System.RPC.Partition_ID is
111 return System.RPC.Partition_ID (PID mod M);
112 end Get_Local_Partition_ID;
114 ------------------------------
115 -- Get_Passive_Partition_ID --
116 ------------------------------
118 function Get_Passive_Partition_ID
119 (Name : Unit_Name) return System.RPC.Partition_ID
122 return Get_Local_Partition_ID;
123 end Get_Passive_Partition_ID;
125 -------------------------
126 -- Get_Passive_Version --
127 -------------------------
129 function Get_Passive_Version (Name : Unit_Name) return String is
132 end Get_Passive_Version;
138 procedure Get_RAS_Info
140 Subp_Id : Subprogram_Id;
141 Proxy_Address : out Interfaces.Unsigned_64)
143 LName : constant String := Lower (Name);
148 if N.Name.all = LName then
150 subtype Subprogram_Array is RCI_Subp_Info_Array
151 (First_RCI_Subprogram_Id ..
152 First_RCI_Subprogram_Id + N.Subp_Info_Len - 1);
153 Subprograms : Subprogram_Array;
154 for Subprograms'Address use N.Subp_Info;
155 pragma Import (Ada, Subprograms);
158 Interfaces.Unsigned_64 (Subprograms (Integer (Subp_Id)).Addr);
167 ------------------------------
168 -- Get_RCI_Package_Receiver --
169 ------------------------------
171 function Get_RCI_Package_Receiver
172 (Name : Unit_Name) return Interfaces.Unsigned_64
176 end Get_RCI_Package_Receiver;
178 -------------------------------
179 -- Get_Unique_Remote_Pointer --
180 -------------------------------
182 procedure Get_Unique_Remote_Pointer
183 (Handler : in out RACW_Stub_Type_Access)
187 end Get_Unique_Remote_Pointer;
193 function Lower (S : String) return String is
197 for J in T'Range loop
198 if T (J) in 'A' .. 'Z' then
199 T (J) := Character'Val (Character'Pos (T (J)) -
200 Character'Pos ('A') +
201 Character'Pos ('a'));
208 -------------------------------------
209 -- Raise_Program_Error_Unknown_Tag --
210 -------------------------------------
212 procedure Raise_Program_Error_Unknown_Tag
213 (E : Ada.Exceptions.Exception_Occurrence)
216 raise Program_Error with Ada.Exceptions.Exception_Message (E);
217 end Raise_Program_Error_Unknown_Tag;
223 package body RCI_Locator is
225 -----------------------------
226 -- Get_Active_Partition_ID --
227 -----------------------------
229 function Get_Active_Partition_ID return System.RPC.Partition_ID is
230 P : Pkg_List := Pkg_Head;
231 N : String := Lower (RCI_Name);
235 if P.Name.all = N then
236 return Get_Local_Partition_ID;
243 end Get_Active_Partition_ID;
245 ------------------------------
246 -- Get_RCI_Package_Receiver --
247 ------------------------------
249 function Get_RCI_Package_Receiver return Interfaces.Unsigned_64 is
252 end Get_RCI_Package_Receiver;
256 ------------------------------
257 -- Register_Passive_Package --
258 ------------------------------
260 procedure Register_Passive_Package
262 Version : String := "")
265 Register_Receiving_Stub
266 (Passive_Prefix & Name, null, Version, System.Null_Address, 0);
267 end Register_Passive_Package;
269 -----------------------------
270 -- Register_Receiving_Stub --
271 -----------------------------
273 procedure Register_Receiving_Stub
275 Receiver : RPC_Receiver;
276 Version : String := "";
277 Subp_Info : System.Address;
278 Subp_Info_Len : Integer)
280 N : constant Pkg_List :=
281 new Pkg_Node'(new String'(Lower (Name)),
282 Subp_Info, Subp_Info_Len,
285 if Pkg_Tail = null then
291 end Register_Receiving_Stub;
298 (Main : Main_Subprogram_Type := null)
310 function Same_Partition
311 (Left : not null access RACW_Stub_Type;
312 Right : not null access RACW_Stub_Type) return Boolean
314 pragma Unreferenced (Left);
315 pragma Unreferenced (Right);
320 end System.Partition_Interface;