-- Special DSA types
- elsif Is_RTE (U_Type, RE_Any_Content_Ptr) then
+ elsif Is_RTE (U_Type, RE_Any_Container_Ptr) then
Lib_RE := RE_FA_A;
-- Other (non-primitive) types
-- Special DSA types
- elsif Is_RTE (U_Type, RE_Any_Content_Ptr) then
+ elsif Is_RTE (U_Type, RE_Any_Container_Ptr) then
Lib_RE := RE_TA_A;
+ U_Type := Typ;
elsif U_Type = Underlying_Type (RTE (RE_TypeCode)) then
-- No corresponding FA_TC ???
-- Special DSA types
- elsif Is_RTE (U_Type, RE_Any_Content_Ptr) then
+ elsif Is_RTE (U_Type, RE_Any_Container_Ptr) then
Lib_RE := RE_TC_A;
-- Other (non-primitive) types
RE_Get_Local_Partition_Id, -- System.DSA_Services
RE_Get_Passive_Partition_Id, -- System.DSA_Services
- RE_Any_Content_Ptr, -- System.DSA_Types
+ RE_Any_Container_Ptr, -- System.DSA_Types
RE_Register_Exception, -- System.Exception_Table
RE_SS_Mark, -- System.Secondary_Stack
RE_SS_Release, -- System.Secondary_Stack
- RE_Shared_Var_Close, -- System.Shared_Storage
RE_Shared_Var_Lock, -- System.Shared_Storage
- RE_Shared_Var_ROpen, -- System.Shared_Storage
RE_Shared_Var_Unlock, -- System.Shared_Storage
- RE_Shared_Var_WOpen, -- System.Shared_Storage
RE_Shared_Var_Procs, -- System.Shared_Storage
RE_Abort_Undefer_Direct, -- System.Standard_Library
RE_Get_Local_Partition_Id => System_DSA_Services,
RE_Get_Passive_Partition_Id => System_DSA_Services,
- RE_Any_Content_Ptr => System_DSA_Types,
+ RE_Any_Container_Ptr => System_DSA_Types,
RE_Register_Exception => System_Exception_Table,
RE_SS_Pool => System_Secondary_Stack,
RE_SS_Release => System_Secondary_Stack,
- RE_Shared_Var_Close => System_Shared_Storage,
RE_Shared_Var_Lock => System_Shared_Storage,
- RE_Shared_Var_ROpen => System_Shared_Storage,
RE_Shared_Var_Unlock => System_Shared_Storage,
- RE_Shared_Var_WOpen => System_Shared_Storage,
RE_Shared_Var_Procs => System_Shared_Storage,
RE_Abort_Undefer_Direct => System_Standard_Library,
with Ada.IO_Exceptions;
with Ada.Streams;
+with Ada.Streams.Stream_IO;
with System.Global_Locks;
with System.Soft_Links;
package SFI renames System.File_IO;
+ package SIO renames Ada.Streams.Stream_IO;
+
type String_Access is access String;
procedure Free is new Ada.Unchecked_Deallocation
(Object => String, Name => String_Access);
-- created entry is returned, after first moving it to the head of
-- the LRU chain. If not, then null is returned.
+ function Shared_Var_ROpen (Var : String) return SIO.Stream_Access;
+ -- As described above, this routine returns null if the
+ -- corresponding shared storage does not exist, and otherwise, if
+ -- the storage does exist, a Stream_Access value that references
+ -- the shared storage, ready to read the current value.
+
+ function Shared_Var_WOpen (Var : String) return SIO.Stream_Access;
+ -- As described above, this routine returns a Stream_Access value
+ -- that references the shared storage, ready to write the new
+ -- value. The storage is created by this call if it does not
+ -- already exist.
+
+ procedure Shared_Var_Close (Var : SIO.Stream_Access);
+ -- This routine signals the end of a read/assign operation. It can
+ -- be useful to embrace a read/write operation between a call to
+ -- open and a call to close which protect the whole operation.
+ -- Otherwise, two simultaneous operations can result in the
+ -- raising of exception Data_Error by setting the access mode of
+ -- the variable in an incorrect mode.
+
---------------
-- Enter_SFE --
---------------
-- For each shared variable, var, an instantiation of the below generic
-- package is created which provides Read and Write supporting procedures.
--- The routine Shared_Var_ROpen in package System.Shared_Storage
--- either returns null if the storage does not exist, or otherwise a
--- Stream_Access value that references the corresponding shared
--- storage, ready to read the current value.
-
--- The routine Shared_Var_WOpen in package System.Shared_Storage
--- returns a Stream_Access value that references the corresponding
--- shared storage, ready to write the new value.
-
--- Note that there is no general synchronization for these storage
--- read and write operations, since it is assumed that a correctly
--- operating programs will provide appropriate synchronization. In
--- particular, variables can be protected using protected types with
--- no entries.
-
--- The routine Shared_Var_Close is called to indicate the end of a
--- read/write operations. This can be useful even in the context of
--- the GNAT implementation. For instance, when a read operation and a
--- write operation occur at the same time on the same partition, as
--- the same stream is used simultaneously, both operations can
--- terminate abruptly by raising exception Mode_Error because the
--- stream has been opened in read mode and then in write mode and at
--- least used by the read operation. To avoid this unexpected
--- behaviour, we introduce a synchronization at the partition level.
+-- The routine Read in package System.Shared_Storage.Shared_Var_Procs
+-- ensures to assign variable V to the last written value among processes
+-- referencing it. A call to this procedure is generated by the expander
+-- before each read access to the shared variable.
+
+-- The routine Write in package System.Shared_Storage.Shared_Var_Proc
+-- set a new value to the shared variable and, according to the used
+-- implementation, propagate this value among processes referencing it.
+-- A call to this procedure is generated by the expander after each
+-- assignement of the shared varible.
-- Note: a special circuit allows the use of stream attributes Read and
-- Write for limited types (using the corresponding attribute for the
-- These calls to the read and assign routines, as well as the lock
-- and unlock routines, are inserted by the expander (see exp_smem.adb).
-with Ada.Streams.Stream_IO;
-
package System.Shared_Storage is
- package SIO renames Ada.Streams.Stream_IO;
-
- function Shared_Var_ROpen (Var : String) return SIO.Stream_Access;
- -- As described above, this routine returns null if the
- -- corresponding shared storage does not exist, and otherwise, if
- -- the storage does exist, a Stream_Access value that references
- -- the shared storage, ready to read the current value.
-
- function Shared_Var_WOpen (Var : String) return SIO.Stream_Access;
- -- As described above, this routine returns a Stream_Access value
- -- that references the shared storage, ready to write the new
- -- value. The storage is created by this call if it does not
- -- already exist.
-
- procedure Shared_Var_Close (Var : SIO.Stream_Access);
- -- This routine signals the end of a read/assign operation. It can
- -- be useful to embrace a read/write operation between a call to
- -- open and a call to close which protect the whole operation.
- -- Otherwise, two simultaneous operations can result in the
- -- raising of exception Data_Error by setting the access mode of
- -- the variable in an incorrect mode.
-
procedure Shared_Var_Lock (Var : String);
-- This procedure claims the shared storage lock. It is used for
-- protected types in shared passive packages. A call to this
procedure Shared_Var_Unlock (Var : String);
-- This procedure releases the shared storage lock obtained by a
- -- prior call to the Shared_Mem_Lock procedure, and is to be
+ -- prior call to the Shared_Var_Lock procedure, and is to be
-- generated as the last operation in the body of a protected
-- subprogram.