8sa1-gcc/gcc/ada/s-tpoben.adb
Arnaud Charlet c885d7a17a [multiple changes]
2004-09-09  Vincent Celier  <celier@gnat.com>

	* a-direct.ads: Add pragma Ada_05
	(Directory_Entry_Type): Give default value to component Kind to avoid
	not initialized warnings.

	* a-direct.adb (Current_Directory): Remove directory separator at the
	end.
	(Delete_Directory, Delete_Tree): Raise Name_Error if Directory is not
	an existing directory.
	(Fetch_Next_Entry): Give default value to variable Kind to avoid warning
	(Size (String)): Function C_Size returns Long_Integer, not File_Size.
	Convert the result to File_Size.

	* prj.ads: (Project_Error): New exception

	* prj-attr.adb: Except in procedure Initialize, Fail comes from
	Prj.Com, not from Osint.
	(Attrs, Package_Attributes): Tables moved to private part of spec
	(Add_Attribute, Add_Unknown_Package): Moved to new child package
	Prj.Attr.PM.
	(Register_New_Package (Name, Attributes), Register_New_Attribute): Raise
	Prj.Project_Error after call to Fail.
	(Register_New_Package (Name, Id)): Set Id to Empty_Package after calling
	Fail. Check that package name is not already in use.

	* prj-attr.ads: Comment updates to indicate that all subprograms may be
	used by tools, not only by the project manager, and to indicate that
	exception Prj.Prj_Error may be raised in case of problem.
	(Add_Unknown_Package, Add_Attribute): Moved to new child package
	Prj.Attr.PM.
	(Attrs, Package_Attributes): Table instantiations moved from the body to
	the private part to be accessible from Prj.Attr.PM body.

	* prj-dect.adb (Parse_Package_Declaration): Call Add_Unknown_Package
	from new package Prj.Attr.PM.
	(Parse_Attribute_Declaration): Call Add_Attribute from new package
	Prj.Attr.PM.

	* Makefile.in: Add prj-attr-pm.o to gnatmake object list

	* gnatbind.adb (Gnatbind): Correct warning message (Elaboration_Check
	instead of Elaboration_Checks).

	* a-calend.adb: Minor reformatting

2004-09-09  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* gigi.h (maybe_pad_type): New declaration.
	(create_subprog_type): New arg RETURNS_BY_TARGET_PTR.

	* ada-tree.h: (TYPE_RETURNS_BY_TARGET_PTR_P): New macro.

	* cuintp.c: Convert to use buildN.

	* decl.c (maybe_pad_type): No longer static.
	(gnat_to_gnu_entity, case E_Function): Handle case of returning by
	target pointer.
	Convert to use buildN.

	* trans.c (call_to_gnu): Add arg GNU_TARGET; support
	TYPE_RETURNS_BY_TARGET_PTR_P.  All callers changed.
	(gnat_to_gnu, case N_Assignment_Statement): Call call_to_gnu if call on
	RHS.
	(gnat_to_gnu, case N_Return): Handle TYPE_RETURN_BY_TARGET_PTR_P.
	(gnat_gimplify_expr, case ADDR_EXPR): New case.
	Convert to use buildN.

	* utils2.c (gnat_build_constructor): Also set TREE_INVARIANT and
	TREE_READONLY for const.
	Convert to use buildN.

	* utils.c (create_subprog_type): New operand RETURNS_BY_TARGET_PTR.
	(create_var_decl): Refine when TREE_STATIC is set.
	Convert to use buildN.

2004-09-09  Gary Dismukes  <dismukes@gnat.com>

	* gnat_ugn.texi: Delete text relating to checking of ali and object
	consistency.

	* a-except.adb (Rcheck_*): Add pragmas No_Return for each of these
	routines.

2004-09-09  Jose Ruiz  <ruiz@act-europe.fr>

	* gnat_ugn.texi: Add Detect_Blocking to the list of configuration
	pragmas recognized by GNAT.

	* gnat_rm.texi: Document pragma Detect_Blocking.

	* s-solita.adb (Timed_Delay_T): When pragma Detect_Blocking is active,
	raise Program_Error if called from a protected operation.

	* s-taprob.adb (Lock): When pragma Detect_Blocking is active increase
	the protected action nesting level.
	(Lock_Read_Only): When pragma Detect_Blocking is active increase the
	protected action nesting level.
	(Unlock): When pragma Detect_Blocking is active decrease the protected
	action nesting level.

	* s-taskin.adb (Initialize_ATCB): Initialize to 0 the
	Protected_Action_Nesting.

	* s-taskin.ads: Adding the field Protected_Action_Nesting to the
	Common_ATCB record. It contains the dynamic level of protected action
	nesting for each task. It is needed for checking whether potentially
	blocking operations are called from protected operations.
	(Detect_Blocking): Adding a Boolean constant reflecting whether pragma
	Detect_Blocking is active or not in the partition.

	* s-tasren.adb (Call_Simple): When pragma Detect_Blocking is active,
	raise Program_Error if called from a protected operation.
	(Task_Entry_Call): When pragma Detect_Blocking is active, raise
	Program_Error if called from a protected operation.
	(Timed_Task_Entry_Call): When pragma Detect_Blocking is active, raise
	Program_Error if called from a protected operation.

	* s-tassta.adb (Abort_Tasks): When pragma Detect_Blocking is active,
	raise Program_Error if called from a protected operation.

	* s-tpoben.adb (Lock_Entries): When pragma Detect_Blocking is active,
	raise Program_Error if called from a protected operation, and increase
	the protected action nesting level.
	(Lock_Read_Only_Entries): When pragma Detect_Blocking is active, raise
	Program_Error if called from a protected operation, and increase the
	protected action nesting level.
	(Unlock_Entries): When pragma Detect_Blocking is active decrease the
	protected action nesting level.

	* s-tposen.adb (Lock_Entry): When pragma Detect_Blocking is active,
	raise Program_Error if called from a protected operation, and increase
	the protected action nesting level.
	(Lock_Read_Only_Entry): When pragma Detect_Blocking is active, raise
	Program_Error if called from a protected operation, and increase the
	protected action nesting level.
	(Protected_Single_Entry_Call): When pragma Detect_Blocking is active,
	raise Program_Error if called from a protected operation.
	(Timed_Protected_Single_Entry_Call): When pragma Detect_Blocking is
	active, raise Program_Error if called from a protected operation.
	(Unlock_Entry): When pragma Detect_Blocking is active decrease the
	protected action nesting level.

	* sem_util.adb (Check_Potentially_Blocking_Operation): Remove the
	insertion of the statement raising Program_Error. The run time
	contains the required machinery for handling that.

	* sem_util.ads: Change comment associated to procedure
	Check_Potentially_Blocking_Operation.
	This procedure does not insert a call for raising the exception because
	that is currently done by the run time.

	* raise.h (__gnat_set_globals): Pass the detect_blocking parameter.

	* init.c: Add the global variable __gl_detect_blocking that indicates
	whether pragma Detect_Blocking is active (1) or not (0). Needed for
	making the pragma available at run time.
	(__gnat_set_globals): Pass and update the detect_blocking parameter.

	* lib-writ.adb (Write_ALI): Set the DB flag in the ali file if
	pragma Detect_Blocking is active.

	* lib-writ.ads: Document the Detect_Blocking flag (DB) in ali files.

	* ali.adb (Scan_ALI): Set the Detect_Blocking value to true if the flag
	DB is found in the ali file. Any unit compiled with pragma
	Detect_Blocking active forces its effect in the whole partition.

	* a-retide.adb (Delay_Until): Raise Program_Error if pragma
	Detect_Blocking is active and delay is called from a protected
	operation.

	* bindgen.adb (Gen_Adainit_Ada): When generating the call to
	__gnat_set_globals, pass 1 as Detect_Blocking parameter if pragma
	Detect_Blocking is active (0 otherwise).
	(Gen_Adainit_C): When generating the call to __gnat_set_globals, pass 1
	as Detect_Blocking parameter if pragma Detect_Blocking is active (0
	otherwise).

2004-09-09  Thomas Quinot  <quinot@act-europe.fr>

	* gnat_rm.texi: Rename GNAT.Perfect_Hash.Generators to
	GNAT.Perfect_Hash_Generators, and remove the empty GNAT.Perfect_Hash
	package.

	* s-parint.ads, s-parint.adb (Get_RAS_Info): New subprogram.
	(Register_Receiving_Stub): Add Subp_Info formal parameter.
	Update API in placeholder implemetation of s-parint to reflect changes
	in distribution runtime library.

	* sem_ch3.adb (Expand_Derived_Record): Rename to
	Expand_Record_Extension.

	* sem_disp.adb (Check_Controlling_Formals): Improve error message for
	primitive operations of potentially distributed object types that have
	non-controlling anonymous access formals.

	* sem_dist.ads, sem_dist.adb (Build_RAS_Primitive_Specification): New
	subprogram.
	New implementation of expansion for remote access-to-subprogram types,
	based on the RACW infrastructure.
	This version of sem_dist is compatible with PolyORB/DSA as well as
	GLADE.

	* sem_prag.adb (Analyze_Pragma, case Pragma_Asynchronous): For a pragma
	Asynchrronous that applies to a remote access-to-subprogram type, mark
	the underlying RACW type as asynchronous.

	* link.c: FreeBSD uses GNU ld: set __gnat_objlist_file_supported and
	 __gnat_using_gnu_linker to 1.

	* Makefile.rtl, impunit.adb, g-perhas.ads, g-pehage.ads,
	g-pehage.adb: Rename GNAT.Perfect_Hash.Generators to
	GNAT.Perfect_Hash_Generators, and remove the empty
	GNAT.Perfect_Hash package.

	* atree.adb: Minor reformatting

	* exp_ch3.adb (Expand_Derived_Record): Rename to
	Expand_Record_Extension.
	(Build_Record_Init_Proc.Build_Assignment): The default expression in
	a component declaration must remain attached at that point in the
	tree so New_Copy_Tree copies it if the enclosing record type is derived.
	It is therefore necessary to take a copy of the expression when building
	the corresponding assignment statement in the init proc.
	As a side effect, in the case of a derived record type, we now see the
	original expression, without any rewriting that could have occurred
	during expansion of the ancestor type's init proc, and we do not need
	to go back to Original_Node.

	* exp_ch3.ads (Expand_Derived_Record): Rename to
	Expand_Record_Extension.

	* exp_dist.ads, exp_dist.adb (Underlying_RACW_Type): New subprogram.
	Returns the RACW type used to implement a remote access-to-subprogram
	type.
	(Add_RAS_Proxy_And_Analyze, Build_Remote_Subprogram_Proxy_Type):
	New subprograms. Used to create a proxy tagged object for a remote
	subprogram. The proxy object is used as the designated object
	for RAS values on the same partition (unless All_Calls_Remote applies).
	(Build_Get_Unique_RP_Call): New subprogram. Build a call to
	System.Partition_Interface.Get_Unique_Remote_Pointer.
	(Add_RAS_Access_TSS, Add_RAS_Dereference_TSS):
	Renamed from Add_RAS_*_Attribute.
	(Add_Receiving_Stubs_To_Declarations): Generate a table of local
	subprograms.
	New implementation of expansion for remote access-to-subprogram types,
	based on the RACW infrastructure.

	* exp_dist.ads (Copy_Specification): Update comment to note that this
	function can copy the specification from either a subprogram
	specification or an access-to-subprogram type definition.

2004-09-09  Ed Schonberg  <schonberg@gnat.com>

	* sem_type.adb (Disambiguate): Handle properly an accidental ambiguity
	in an instance, between an explicit subprogram an one inherited from a
	type derived from an actual.

	* exp_ch6.adb (Expand_N_Subprogram_Body): If polling is enabled, do not
	add a polling call if the subprogram is to be inlined by the back-end,
	to avoid repeated calls with multiple inlinings.

	* checks.adb (Apply_Alignment_Check): If the expression in the address
	clause is a call whose name is not a static entity (e.g. a dispatching
	call), treat as dynamic.

2004-09-09  Robert Dewar  <dewar@gnat.com>

	* g-trasym.ads: Minor reformatting

	* exp_ch3.adb (Component_Needs_Simple_Initialization): Don't except
	packed arrays, since unused bits are expected to be zero for a
	comparison.

2004-09-09  Eric Botcazou  <ebotcazou@act-europe.fr>

	* exp_pakd.ads: Fix an inacurracy and a couple of typos in the head
	comment.

2004-09-09  Pascal Obry  <obry@gnat.com>

	* mdll.ads, mdll.adb (Build_Dynamic_Library): New parameter Map_File to
	enable map file generation. Add the right option to generate the map
	file if Map_File is set to True.

	* gnatdll.adb (Gen_Map_File): New variable.
	(Syntax): Add info about new -m (Map_File) option.
	(Parse_Command_Line): Add support for -m option.
	(gnatdll): Pass Gen_Map_File to Build_Dynamic_Library calls.
	Minor reformatting.

2004-09-09  Laurent Pautet  <pautet@act-europe.fr>

	* gnatls.adb: Add a very verbose mode -V. Such mode is required by the
	new gnatdist implementation.
	Define a subpackage isolating the output routines specific to this
	verbose mode.

2004-09-09  Joel Brobecker  <brobecker@gnat.com>

	* Makefile.rtl: (GNATRTL_NONTASKING_OBJS): Add g-dynhta.

	* gnat_ugn.texi (Main Subprograms): Fix typo. Deduced, not deducted.

2004-09-09  Cyrille Comar  <comar@act-europe.fr>

	* opt.adb (Set_Opt_Config_Switches): Use Ada_Version_Runtime to compile
	internal unit.

	* opt.ads: Add Ada_Version_Runtime constant used to decide which
	version of the language is used to compile the run time.

2004-09-09  Arnaud Charlet  <charlet@act-europe.fr>

	* sem_util.adb (Requires_Transient_Scope): Re-enable handling
	of variable length temporaries for function return now that the
	back-end and gigi support it.

From-SVN: r87435
2004-09-13 12:18:42 +02:00

349 lines
12 KiB
Ada

------------------------------------------------------------------------------
-- --
-- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- SYSTEM.TASKING.PROTECTED_OBJECTS.ENTRIES --
-- --
-- B o d y --
-- --
-- Copyright (C) 1998-2004, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains all the simple primitives related to
-- Protected_Objects with entries (i.e init, lock, unlock).
-- The handling of protected objects with no entries is done in
-- System.Tasking.Protected_Objects, the complex routines for protected
-- objects with entries in System.Tasking.Protected_Objects.Operations.
-- The split between Entries and Operations is needed to break circular
-- dependencies inside the run time.
-- Note: the compiler generates direct calls to this interface, via Rtsfind.
with Ada.Exceptions;
-- used for Exception_Occurrence_Access
-- Raise_Exception
with System.Task_Primitives.Operations;
-- used for Initialize_Lock
-- Write_Lock
-- Unlock
-- Get_Priority
-- Wakeup
with System.Tasking.Initialization;
-- used for Defer_Abort,
-- Undefer_Abort,
-- Change_Base_Priority
pragma Elaborate_All (System.Tasking.Initialization);
-- this insures that tasking is initialized if any protected objects are
-- created.
with System.Parameters;
-- used for Single_Lock
package body System.Tasking.Protected_Objects.Entries is
package STPO renames System.Task_Primitives.Operations;
use Parameters;
use Task_Primitives.Operations;
use Ada.Exceptions;
----------------
-- Local Data --
----------------
Locking_Policy : Character;
pragma Import (C, Locking_Policy, "__gl_locking_policy");
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Protection_Entries) is
Entry_Call : Entry_Call_Link;
Caller : Task_Id;
Ceiling_Violation : Boolean;
Self_ID : constant Task_Id := STPO.Self;
Old_Base_Priority : System.Any_Priority;
begin
if Object.Finalized then
return;
end if;
STPO.Write_Lock (Object.L'Unrestricted_Access, Ceiling_Violation);
if Single_Lock then
Lock_RTS;
end if;
if Ceiling_Violation then
-- Dip our own priority down to ceiling of lock.
-- See similar code in Tasking.Entry_Calls.Lock_Server.
STPO.Write_Lock (Self_ID);
Old_Base_Priority := Self_ID.Common.Base_Priority;
Self_ID.New_Base_Priority := Object.Ceiling;
Initialization.Change_Base_Priority (Self_ID);
STPO.Unlock (Self_ID);
if Single_Lock then
Unlock_RTS;
end if;
STPO.Write_Lock (Object.L'Unrestricted_Access, Ceiling_Violation);
if Ceiling_Violation then
Raise_Exception (Program_Error'Identity, "Ceiling Violation");
end if;
if Single_Lock then
Lock_RTS;
end if;
Object.Old_Base_Priority := Old_Base_Priority;
Object.Pending_Action := True;
end if;
-- Send program_error to all tasks still queued on this object.
for E in Object.Entry_Queues'Range loop
Entry_Call := Object.Entry_Queues (E).Head;
while Entry_Call /= null loop
Caller := Entry_Call.Self;
Entry_Call.Exception_To_Raise := Program_Error'Identity;
STPO.Write_Lock (Caller);
Initialization.Wakeup_Entry_Caller (Self_ID, Entry_Call, Done);
STPO.Unlock (Caller);
exit when Entry_Call = Object.Entry_Queues (E).Tail;
Entry_Call := Entry_Call.Next;
end loop;
end loop;
Object.Finalized := True;
if Single_Lock then
Unlock_RTS;
end if;
STPO.Unlock (Object.L'Unrestricted_Access);
STPO.Finalize_Lock (Object.L'Unrestricted_Access);
end Finalize;
-------------------------------------
-- Has_Interrupt_Or_Attach_Handler --
-------------------------------------
function Has_Interrupt_Or_Attach_Handler
(Object : Protection_Entries_Access)
return Boolean
is
pragma Warnings (Off, Object);
begin
return False;
end Has_Interrupt_Or_Attach_Handler;
-----------------------------------
-- Initialize_Protection_Entries --
-----------------------------------
procedure Initialize_Protection_Entries
(Object : Protection_Entries_Access;
Ceiling_Priority : Integer;
Compiler_Info : System.Address;
Entry_Bodies : Protected_Entry_Body_Access;
Find_Body_Index : Find_Body_Index_Access)
is
Init_Priority : Integer := Ceiling_Priority;
Self_ID : constant Task_Id := STPO.Self;
begin
if Init_Priority = Unspecified_Priority then
Init_Priority := System.Priority'Last;
end if;
if Locking_Policy = 'C'
and then Has_Interrupt_Or_Attach_Handler (Object)
and then Init_Priority not in System.Interrupt_Priority
then
-- Required by C.3.1(11)
raise Program_Error;
end if;
Initialization.Defer_Abort (Self_ID);
Initialize_Lock (Init_Priority, Object.L'Access);
Initialization.Undefer_Abort (Self_ID);
Object.Ceiling := System.Any_Priority (Init_Priority);
Object.Compiler_Info := Compiler_Info;
Object.Pending_Action := False;
Object.Call_In_Progress := null;
Object.Entry_Bodies := Entry_Bodies;
Object.Find_Body_Index := Find_Body_Index;
for E in Object.Entry_Queues'Range loop
Object.Entry_Queues (E).Head := null;
Object.Entry_Queues (E).Tail := null;
end loop;
end Initialize_Protection_Entries;
------------------
-- Lock_Entries --
------------------
procedure Lock_Entries
(Object : Protection_Entries_Access; Ceiling_Violation : out Boolean)
is
begin
if Object.Finalized then
Raise_Exception
(Program_Error'Identity, "Protected Object is finalized");
end if;
-- If pragma Detect_Blocking is active then Program_Error must
-- be raised if this potentially blocking operation is called from
-- a protected action, and the protected object nesting level
-- must be increased.
if Detect_Blocking then
declare
Self_Id : constant Task_Id := STPO.Self;
begin
if Self_Id.Common.Protected_Action_Nesting > 0 then
Ada.Exceptions.Raise_Exception
(Program_Error'Identity, "potentially blocking operation");
else
-- We are entering in a protected action, so that we
-- increase the protected object nesting level.
Self_Id.Common.Protected_Action_Nesting :=
Self_Id.Common.Protected_Action_Nesting + 1;
end if;
end;
end if;
-- The lock is made without defering abortion.
-- Therefore the abortion has to be deferred before calling this
-- routine. This means that the compiler has to generate a Defer_Abort
-- call before the call to Lock.
-- The caller is responsible for undeferring abortion, and compiler
-- generated calls must be protected with cleanup handlers to ensure
-- that abortion is undeferred in all cases.
pragma Assert (STPO.Self.Deferral_Level > 0);
Write_Lock (Object.L'Access, Ceiling_Violation);
end Lock_Entries;
procedure Lock_Entries (Object : Protection_Entries_Access) is
Ceiling_Violation : Boolean;
begin
Lock_Entries (Object, Ceiling_Violation);
if Ceiling_Violation then
Raise_Exception (Program_Error'Identity, "Ceiling Violation");
end if;
end Lock_Entries;
----------------------------
-- Lock_Read_Only_Entries --
----------------------------
procedure Lock_Read_Only_Entries (Object : Protection_Entries_Access) is
Ceiling_Violation : Boolean;
begin
if Object.Finalized then
Raise_Exception
(Program_Error'Identity, "Protected Object is finalized");
end if;
-- If pragma Detect_Blocking is active then Program_Error must be
-- raised if this potentially blocking operation is called from a
-- protected action, and the protected object nesting level must
-- be increased.
if Detect_Blocking then
declare
Self_Id : constant Task_Id := STPO.Self;
begin
if Self_Id.Common.Protected_Action_Nesting > 0 then
Ada.Exceptions.Raise_Exception
(Program_Error'Identity, "potentially blocking operation");
else
-- We are entering in a protected action, so that we
-- increase the protected object nesting level.
Self_Id.Common.Protected_Action_Nesting :=
Self_Id.Common.Protected_Action_Nesting + 1;
end if;
end;
end if;
Read_Lock (Object.L'Access, Ceiling_Violation);
if Ceiling_Violation then
Raise_Exception (Program_Error'Identity, "Ceiling Violation");
end if;
end Lock_Read_Only_Entries;
--------------------
-- Unlock_Entries --
--------------------
procedure Unlock_Entries (Object : Protection_Entries_Access) is
begin
-- We are exiting from a protected action, so that we decrease the
-- protected object nesting level (if pragma Detect_Blocking is
-- active).
if Detect_Blocking then
declare
Self_Id : constant Task_Id := Self;
begin
-- Cannot call this procedure without being within a protected
-- action.
pragma Assert (Self_Id.Common.Protected_Action_Nesting > 0);
Self_Id.Common.Protected_Action_Nesting :=
Self_Id.Common.Protected_Action_Nesting - 1;
end;
end if;
Unlock (Object.L'Access);
end Unlock_Entries;
end System.Tasking.Protected_Objects.Entries;