Commit 0999b547 by Kevin Pouget Committed by Arnaud Charlet

s-shasto.ads, [...]: Move Shared_Var_ROpen...

2008-08-22  Kevin Pouget  <pouget@adacore.com>

	* s-shasto.ads, s-shasto.adb: Move Shared_Var_ROpen, Shared_Var_WOpen and
	Shared_Var_Close procedure specifications from package spec to package body.

	* rtsfind.ads: Remove RE_Shared_Var_Close, RE_Shared_Var_ROpen,
	RE_Shared_Var_WOpen entries.

	* exp_dist.adb: Update RE_Any_Content_Ptr to RE_Any_Container_Ptr in
	Build_To_Any_Call, Build_TypeCode_Call and Build_From_Any_Call procedures.

From-SVN: r139445
parent 44b90160
......@@ -8452,7 +8452,7 @@ package body Exp_Dist is
-- 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
......@@ -9317,8 +9317,9 @@ package body Exp_Dist is
-- 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 ???
......@@ -10086,7 +10087,7 @@ package body Exp_Dist is
-- 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
......
......@@ -697,7 +697,7 @@ package Rtsfind is
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
......@@ -1261,11 +1261,8 @@ package Rtsfind is
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
......@@ -1854,7 +1851,7 @@ package Rtsfind is
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,
......@@ -2418,11 +2415,8 @@ package Rtsfind is
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,
......
......@@ -33,6 +33,7 @@
with Ada.IO_Exceptions;
with Ada.Streams;
with Ada.Streams.Stream_IO;
with System.Global_Locks;
with System.Soft_Links;
......@@ -55,6 +56,8 @@ package body System.Shared_Storage is
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);
......@@ -168,6 +171,26 @@ package body System.Shared_Storage is
-- 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 --
---------------
......
......@@ -82,30 +82,16 @@
-- 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
......@@ -150,32 +136,8 @@
-- 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
......@@ -185,7 +147,7 @@ package System.Shared_Storage is
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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment