Commit 3b91d88e by Arnaud Charlet

a-calend-mingw.adb: Add call to OS_Primitives.Initialize;

	* a-calend-mingw.adb: Add call to OS_Primitives.Initialize;

	* s-taprop-mingw.adb, s-taprop-vms.adb, s-taprop-solaris.adb,
	s-taprop-os2.adb, s-taprop-irix-athread.adb, s-taprop-linux.adb,
	s-taprop-hpux-dce.adb, s-taprop-irix.adb, s-taprop-tru64.adb,
	s-taprop-lynxos.adb: Move with clauses outside Warnings Off now that
	dependent units are Preelaborate.
	(Initialize): Call Interrupt_Managemeent.Initialize and
	OS_Primitives.Initialize to ensure proper initialization of this unit.
	Remove use of System.Soft_Links
	Make this unit Preelaborate.

	* s-stache.ads, s-taspri-vxworks.ads, s-taspri-mingw.ads,
	s-taspri-vms.ads, s-tasinf-solaris.ads, s-taspri-os2.ads,
	s-taspri-lynxos.ads, s-taspri-hpux-dce.ads, s-taspri-tru64.ads,
	s-tasinf-tru64.ads, s-tasinf-irix.ads, s-tasinf-irix-athread.ads,
	s-proinf-irix-athread.adb, s-proinf-irix-athread.ads,
	s-tratas.ads, s-tasinf.ads: Minor reformatting.
	Add pragma Preelaborate, since these packages are suitable for this
	categorization.
	Update comments.

	* s-traent-vms.ads, s-intman-dummy.adb,
	s-taprop-dummy.adb: Make this unit Preelaborate.

	* s-osprim-vxworks.adb, s-osprim-vms.adb, s-osprim-vms.ads,
	s-osprim-mingw.adb, s-intman-vxworks.ads, s-intman-vxworks.adb,
	s-intman-vms.adb, s-intman-mingw.adb, s-intman-vms.ads,
	s-osprim-unix.adb, s-osprim-os2.adb, s-osprim-solaris.adb,
	s-intman-solaris.adb, s-intman-irix-athread.adb,
	s-intman-irix.adb: Mark this unit Preelaborate.
	(Initialize): New procedure.
	Update comments.

	* s-taspri-linux.ads: Removed.

	* s-tpopsp-solaris.adb (Initialize): Create the key in this procedure,
	as done by other implementations (e.g. posix).

	* s-taprop.ads (Timed_Delay): Update spec since the caller now is
	responsible for deferring abort.
	Mark this unit Preelaborate.

	* s-taprob.adb, s-tarest.adb: Call System.Tasking.Initialize to ensure
	proper initialization of the tasking run-time.

	* s-tasdeb.ads: Mark this unit Preelaborate.
	(Known_Tasks): Add explicit default value to avoid elaboration code.

	* s-inmaop-vms.adb (Elaboration code): Add call to
	Interrupt_Management.Initialize since the elaboration code depends on
	proper initialization of this package.

	* s-intman.ads, s-inmaop-posix.adb, s-intman-posix.adb,
	s-osprim.ads, s-taprop-posix.adb, s-taspri-posix.ads,
	s-osprim-posix.adb: Make this unit Preelaborate.

	* a-calend.adb: Add call to OS_Primitives.Initialize

	* a-elchha.adb: Update use of Except.Id.Full_Name.
	Minor reformatting.
	Remove use of Ada.Exceptions.Traceback when possible, cleaner.

	* a-dynpri.adb, a-sytaco.adb, a-sytaco.ads:
	Move with clauses outside Warnings Off now that dependent units are
	Preelaborate.
	Use raise xxx with "..."; Ada 2005 form.

	* a-taside.ads, a-taside.adb:
	Remove some dependencies, to make it easier to make this unit truly
	Preelaborate.
	Rewrite some code to be conformant with Preelaborate rules.

	* g-os_lib.adb: Remove non-preelaborate code so that this unit can be
	marked Preelaborate in the future.

	* s-proinf.ads, g-string.ads, s-auxdec.ads, s-auxdec-vms_64.ads: Make
	these units Preelaborate.

	* s-exctab.adb: Update use of Except.Id.Full_Name.

	* s-soflin.ads, s-soflin.adb: Mark this unit Preelaborate_05.
	(Set_Exc_Stack_Addr_Soft, Get_Exc_Stack_Addr_NT, Set_Exc_Stack_Addr_NT,
	Set_Exc_Stack_Addr): Removed, no longer used.
	Remove reference to *Machine_State_Addr*, no longer needed.

	* s-stalib.ads: Mark this unit as Preelaborate[_05].
	(Exception_Data): Full_Name is now a System.Address so that this unit
	can be made Preelaborate.
	Clean up/simplify code thanks to Full_Name being a System.Address.
	Remove obsolete pragma Suppress (All_Checks), no longer needed.

	* s-taskin.ads, s-taskin.adb:
	Move with clauses outside Warnings Off now that dependent units are
	Preelaborate.
	Make this unit Preelaborate.
	(Initialize): New proceduure, replace elaboration code and makes the
	set up of the tasking run-time cleaner.
	(Detect_Blocking): Now a function instead of a deferred boolean, to
	obey Preelaborate rules.

	* s-tassta.adb (Finalize_Global_Tasks): Remove Get/Set_Exc_Stack_Addr
	soft links, no longer used.

	* s-traces.ads, s-traent.ads: Add pragma Preelaborate, since these
	packages are suitable for this categorization.

	* s-solita.adb: Replace use of Ada.Exception by raise xxx with "..."
	since we compile run-time sources in Ada 2005 mode.
	(Timed_Delay_T): Call Abort_Defer/Undefer around Timed_Delay, to
	avoid having s-taprop*.adb depend on s-soflin and to avoid code
	duplication.
	Remove reference to *Machine_State_Addr*, no longer needed.

From-SVN: r103847
parent ca887693
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1997-2002 Free Software Foundation, Inc. -- -- Copyright (C) 1997-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- This is the Windows NT/95 version. -- This is the Windows NT/95 version
with System.OS_Primitives; with System.OS_Primitives;
-- used for Clock -- used for Clock
...@@ -262,7 +262,7 @@ package body Ada.Calendar is ...@@ -262,7 +262,7 @@ package body Ada.Calendar is
end if; end if;
-- Date_Int is the number of seconds from Epoch. -- Date_Int is the number of seconds from Epoch
Date_Int := Long_Long_Integer Date_Int := Long_Long_Integer
(Int_Date * Sec_Unit / system_time_ns) + epoch_1970; (Int_Date * Sec_Unit / system_time_ns) + epoch_1970;
...@@ -391,4 +391,6 @@ package body Ada.Calendar is ...@@ -391,4 +391,6 @@ package body Ada.Calendar is
return DY; return DY;
end Year; end Year;
begin
System.OS_Primitives.Initialize;
end Ada.Calendar; end Ada.Calendar;
...@@ -476,4 +476,6 @@ package body Ada.Calendar is ...@@ -476,4 +476,6 @@ package body Ada.Calendar is
return DY; return DY;
end Year; end Year;
begin
System.OS_Primitives.Initialize;
end Ada.Calendar; end Ada.Calendar;
...@@ -31,11 +31,6 @@ ...@@ -31,11 +31,6 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
pragma Warnings (Off);
-- Allow withing of non-Preelaborated units in Ada 2005 mode where this
-- package will be categorized as Preelaborate. See AI-362 for details.
-- It is safe in the context of the run-time to violate the rules!
with Ada.Task_Identification; with Ada.Task_Identification;
-- used for Task_Id -- used for Task_Id
-- Current_Task -- Current_Task
...@@ -52,26 +47,22 @@ with System.Task_Primitives.Operations; ...@@ -52,26 +47,22 @@ with System.Task_Primitives.Operations;
with System.Tasking; with System.Tasking;
-- used for Task_Id -- used for Task_Id
with Ada.Exceptions;
-- used for Raise_Exception
with System.Tasking.Initialization;
-- used for Defer/Undefer_Abort
with System.Parameters; with System.Parameters;
-- used for Single_Lock -- used for Single_Lock
with Unchecked_Conversion; with System.Soft_Links;
-- use for Abort_Defer
-- Abort_Undefer
pragma Warnings (On); with Unchecked_Conversion;
package body Ada.Dynamic_Priorities is package body Ada.Dynamic_Priorities is
package STPO renames System.Task_Primitives.Operations; package STPO renames System.Task_Primitives.Operations;
package SSL renames System.Soft_Links;
use System.Parameters; use System.Parameters;
use System.Tasking; use System.Tasking;
use Ada.Exceptions;
function Convert_Ids is new function Convert_Ids is new
Unchecked_Conversion Unchecked_Conversion
...@@ -92,13 +83,11 @@ package body Ada.Dynamic_Priorities is ...@@ -92,13 +83,11 @@ package body Ada.Dynamic_Priorities is
begin begin
if Target = Convert_Ids (Ada.Task_Identification.Null_Task_Id) then if Target = Convert_Ids (Ada.Task_Identification.Null_Task_Id) then
Raise_Exception (Program_Error'Identity, raise Program_Error with Error_Message & "null task";
Error_Message & "null task");
end if; end if;
if Task_Identification.Is_Terminated (T) then if Task_Identification.Is_Terminated (T) then
Raise_Exception (Tasking_Error'Identity, raise Tasking_Error with Error_Message & "null task";
Error_Message & "null task");
end if; end if;
return Target.Common.Base_Priority; return Target.Common.Base_Priority;
...@@ -121,16 +110,14 @@ package body Ada.Dynamic_Priorities is ...@@ -121,16 +110,14 @@ package body Ada.Dynamic_Priorities is
begin begin
if Target = Convert_Ids (Ada.Task_Identification.Null_Task_Id) then if Target = Convert_Ids (Ada.Task_Identification.Null_Task_Id) then
Raise_Exception (Program_Error'Identity, raise Program_Error with Error_Message & "null task";
Error_Message & "null task");
end if; end if;
if Task_Identification.Is_Terminated (T) then if Task_Identification.Is_Terminated (T) then
Raise_Exception (Tasking_Error'Identity, raise Tasking_Error with Error_Message & "terminated task";
Error_Message & "terminated task");
end if; end if;
Initialization.Defer_Abort (Self_ID); SSL.Abort_Defer.all;
if Single_Lock then if Single_Lock then
STPO.Lock_RTS; STPO.Lock_RTS;
...@@ -148,7 +135,7 @@ package body Ada.Dynamic_Priorities is ...@@ -148,7 +135,7 @@ package body Ada.Dynamic_Priorities is
STPO.Unlock_RTS; STPO.Unlock_RTS;
end if; end if;
-- Yield is needed to enforce FIFO task dispatching. -- Yield is needed to enforce FIFO task dispatching
-- LL Set_Priority is made while holding the RTS lock so that it -- LL Set_Priority is made while holding the RTS lock so that it
-- is inheriting high priority until it release all the RTS locks. -- is inheriting high priority until it release all the RTS locks.
...@@ -175,7 +162,7 @@ package body Ada.Dynamic_Priorities is ...@@ -175,7 +162,7 @@ package body Ada.Dynamic_Priorities is
end if; end if;
end if; end if;
Initialization.Undefer_Abort (Self_ID); SSL.Abort_Undefer.all;
end Set_Priority; end Set_Priority;
end Ada.Dynamic_Priorities; end Ada.Dynamic_Priorities;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2003-2004 Free Software Foundation, Inc. -- -- Copyright (C) 2003-2005 Free Software Foundation, Inc. --
-- -- -- --
-- This specification is derived from the Ada Reference Manual for use with -- -- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow -- -- GNAT. The copyright notice above, and the license provisions that follow --
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
-- Default version for most targets -- Default version for most targets
with System.Standard_Library; use System.Standard_Library;
procedure Ada.Exceptions.Last_Chance_Handler procedure Ada.Exceptions.Last_Chance_Handler
(Except : Exception_Occurrence) (Except : Exception_Occurrence)
is is
...@@ -88,7 +90,7 @@ begin ...@@ -88,7 +90,7 @@ begin
-- really an exception at all. We recognize this by the fact that -- really an exception at all. We recognize this by the fact that
-- it is the only exception whose name starts with underscore. -- it is the only exception whose name starts with underscore.
if Except.Id.Full_Name.all (1) = '_' then if To_Ptr (Except.Id.Full_Name) (1) = '_' then
To_Stderr (Nline); To_Stderr (Nline);
To_Stderr ("Execution terminated by abort of environment task"); To_Stderr ("Execution terminated by abort of environment task");
To_Stderr (Nline); To_Stderr (Nline);
...@@ -100,7 +102,8 @@ begin ...@@ -100,7 +102,8 @@ begin
elsif Except.Num_Tracebacks = 0 then elsif Except.Num_Tracebacks = 0 then
To_Stderr (Nline); To_Stderr (Nline);
To_Stderr ("raised "); To_Stderr ("raised ");
To_Stderr (Except.Id.Full_Name.all (1 .. Except.Id.Name_Length - 1)); To_Stderr
(To_Ptr (Except.Id.Full_Name) (1 .. Except.Id.Name_Length - 1));
if Exception_Message_Length (Except) /= 0 then if Exception_Message_Length (Except) /= 0 then
To_Stderr (" : "); To_Stderr (" : ");
......
...@@ -31,11 +31,6 @@ ...@@ -31,11 +31,6 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
pragma Warnings (Off);
-- Allow withing of non-Preelaborated units in Ada 2005 mode where this
-- package will be categorized as Preelaborate. See AI-362 for details.
-- It is safe in the context of the run-time to violate the rules!
with System.Tasking; with System.Tasking;
-- Used for Detect_Blocking -- Used for Detect_Blocking
-- Self -- Self
...@@ -51,8 +46,6 @@ with System.Task_Primitives.Operations; ...@@ -51,8 +46,6 @@ with System.Task_Primitives.Operations;
-- Set_True -- Set_True
-- Suspend_Until_True -- Suspend_Until_True
pragma Warnings (On);
package body Ada.Synchronous_Task_Control is package body Ada.Synchronous_Task_Control is
---------------- ----------------
......
...@@ -35,22 +35,15 @@ ...@@ -35,22 +35,15 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
pragma Warnings (Off);
-- Allow withing of non-Preelaborated units in Ada 2005 mode where this
-- package will be implicitly categorized as Preelaborate. See AI-362 for
-- details. It is safe in the context of the run-time to violate the rules!
with System.Task_Primitives; with System.Task_Primitives;
-- Used for Suspension_Object -- Used for Suspension_Object
with Ada.Finalization; with Ada.Finalization;
-- Used for Limited_Controlled -- Used for Limited_Controlled
pragma Warnings (On);
package Ada.Synchronous_Task_Control is package Ada.Synchronous_Task_Control is
pragma Preelaborate_05 (Synchronous_Task_Control); pragma Preelaborate_05;
-- In accordance with Ada 2005 AI-362 -- In accordance with Ada 2005 AI-362
type Suspension_Object is limited private; type Suspension_Object is limited private;
...@@ -71,12 +64,13 @@ private ...@@ -71,12 +64,13 @@ private
-- Finalization for Suspension_Object -- Finalization for Suspension_Object
type Suspension_Object is type Suspension_Object is
new Ada.Finalization.Limited_Controlled with record new Ada.Finalization.Limited_Controlled with
record
SO : System.Task_Primitives.Suspension_Object; SO : System.Task_Primitives.Suspension_Object;
-- Use low-level suspension objects so that the synchronization -- Use low-level suspension objects so that the synchronization
-- functionality provided by this object can be achieved using -- functionality provided by this object can be achieved using
-- efficient operating system primitives. -- efficient operating system primitives.
end record; end record;
pragma Inline (Set_True); pragma Inline (Set_True);
pragma Inline (Set_False); pragma Inline (Set_False);
......
...@@ -31,32 +31,28 @@ ...@@ -31,32 +31,28 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with System.Address_Image;
with System.Parameters;
with System.Soft_Links;
with System.Task_Primitives.Operations;
with System.Tasking;
with Unchecked_Conversion;
pragma Warnings (Off); pragma Warnings (Off);
-- Allow withing of non-Preelaborated units in Ada 2005 mode where this -- Allow withing of non-Preelaborated units in Ada 2005 mode where this
-- package will be categorized as Preelaborate. See AI-362 for details. -- package will be categorized as Preelaborate. See AI-362 for details.
-- It is safe in the context of the run-time to violate the rules! -- It is safe in the context of the run-time to violate the rules!
with System.Address_Image;
-- used for the function itself
with System.Tasking;
-- used for Task_List
with System.Tasking.Stages; with System.Tasking.Stages;
-- used for Terminated
-- Abort_Tasks
with System.Tasking.Rendezvous; pragma Warnings (On);
-- used for Callable
with System.Task_Primitives.Operations; package body Ada.Task_Identification is
-- used for Self
with Unchecked_Conversion;
pragma Warnings (Off); use System.Parameters;
package body Ada.Task_Identification is package STPO renames System.Task_Primitives.Operations;
----------------------- -----------------------
-- Local Subprograms -- -- Local Subprograms --
...@@ -71,7 +67,7 @@ package body Ada.Task_Identification is ...@@ -71,7 +67,7 @@ package body Ada.Task_Identification is
-- "=" -- -- "=" --
--------- ---------
function "=" (Left, Right : Task_Id) return Boolean is function "=" (Left, Right : Task_Id) return Boolean is
begin begin
return System.Tasking."=" (Convert_Ids (Left), Convert_Ids (Right)); return System.Tasking."=" (Convert_Ids (Left), Convert_Ids (Right));
end "="; end "=";
...@@ -139,11 +135,28 @@ package body Ada.Task_Identification is ...@@ -139,11 +135,28 @@ package body Ada.Task_Identification is
----------------- -----------------
function Is_Callable (T : Task_Id) return Boolean is function Is_Callable (T : Task_Id) return Boolean is
Result : Boolean;
Id : constant System.Tasking.Task_Id := Convert_Ids (T);
begin begin
if T = Null_Task_Id then if T = Null_Task_Id then
raise Program_Error; raise Program_Error;
else else
return System.Tasking.Rendezvous.Callable (Convert_Ids (T)); System.Soft_Links.Abort_Defer.all;
if Single_Lock then
STPO.Lock_RTS;
end if;
STPO.Write_Lock (Id);
Result := Id.Callable;
STPO.Unlock (Id);
if Single_Lock then
STPO.Unlock_RTS;
end if;
System.Soft_Links.Abort_Undefer.all;
return Result;
end if; end if;
end Is_Callable; end Is_Callable;
...@@ -152,11 +165,31 @@ package body Ada.Task_Identification is ...@@ -152,11 +165,31 @@ package body Ada.Task_Identification is
------------------- -------------------
function Is_Terminated (T : Task_Id) return Boolean is function Is_Terminated (T : Task_Id) return Boolean is
Result : Boolean;
Id : constant System.Tasking.Task_Id := Convert_Ids (T);
use System.Tasking;
begin begin
if T = Null_Task_Id then if T = Null_Task_Id then
raise Program_Error; raise Program_Error;
else else
return System.Tasking.Stages.Terminated (Convert_Ids (T)); System.Soft_Links.Abort_Defer.all;
if Single_Lock then
STPO.Lock_RTS;
end if;
STPO.Write_Lock (Id);
Result := Id.Common.State = Terminated;
STPO.Unlock (Id);
if Single_Lock then
STPO.Unlock_RTS;
end if;
System.Soft_Links.Abort_Undefer.all;
return Result;
end if; end if;
end Is_Terminated; end Is_Terminated;
......
...@@ -35,25 +35,18 @@ ...@@ -35,25 +35,18 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
pragma Warnings (Off);
-- Allow withing of non-Preelaborated units in Ada 2005 mode where this
-- package will be categorized as Preelaborate. See AI-362 for details.
-- It is safe in the context of the run-time to violate the rules!
with System; with System;
with System.Tasking; with System.Tasking;
pragma Warnings (On);
package Ada.Task_Identification is package Ada.Task_Identification is
pragma Preelaborate_05 (Task_Identification); pragma Preelaborate_05;
-- In accordance with Ada 2005 AI-362 -- In accordance with Ada 2005 AI-362
type Task_Id is private; type Task_Id is private;
Null_Task_Id : constant Task_Id; Null_Task_Id : constant Task_Id;
function "=" (Left, Right : Task_Id) return Boolean; function "=" (Left, Right : Task_Id) return Boolean;
pragma Inline ("="); pragma Inline ("=");
function Image (T : Task_Id) return String; function Image (T : Task_Id) return String;
...@@ -63,7 +56,7 @@ pragma Preelaborate_05 (Task_Identification); ...@@ -63,7 +56,7 @@ pragma Preelaborate_05 (Task_Identification);
procedure Abort_Task (T : Task_Id); procedure Abort_Task (T : Task_Id);
pragma Inline (Abort_Task); pragma Inline (Abort_Task);
-- Note: parameter is mode IN, not IN OUT, per AI-00101. -- Note: parameter is mode IN, not IN OUT, per AI-00101
function Is_Terminated (T : Task_Id) return Boolean; function Is_Terminated (T : Task_Id) return Boolean;
pragma Inline (Is_Terminated); pragma Inline (Is_Terminated);
...@@ -75,13 +68,6 @@ private ...@@ -75,13 +68,6 @@ private
type Task_Id is new System.Tasking.Task_Id; type Task_Id is new System.Tasking.Task_Id;
pragma Warnings (Off); Null_Task_Id : constant Task_Id := null;
-- Allow non-static constant in Ada 2005 mode where this package will be
-- categorized as Preelaborate. See AI-362 for details. It is safe in the
-- context of the run-time to violate the rules!
Null_Task_Id : constant Task_Id := Task_Id (System.Tasking.Null_Task);
pragma Warnings (On);
end Ada.Task_Identification; end Ada.Task_Identification;
...@@ -65,11 +65,14 @@ package body GNAT.OS_Lib is ...@@ -65,11 +65,14 @@ package body GNAT.OS_Lib is
-- The following are used by Create_Temp_File -- The following are used by Create_Temp_File
Current_Temp_File_Name : String := "GNAT-TEMP-000000.TMP"; First_Temp_File_Name : constant String := "GNAT-TEMP-000000.TMP";
-- Used to initialize Current_Temp_File_Name and Temp_File_Name_Last_Digit
Current_Temp_File_Name : String := First_Temp_File_Name;
-- Name of the temp file last created -- Name of the temp file last created
Temp_File_Name_Last_Digit : constant Positive := Temp_File_Name_Last_Digit : constant Positive :=
Current_Temp_File_Name'Last - 4; First_Temp_File_Name'Last - 4;
-- Position of the last digit in Current_Temp_File_Name -- Position of the last digit in Current_Temp_File_Name
Max_Attempts : constant := 100; Max_Attempts : constant := 100;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1995-2002 Free Software Foundation, Inc. -- -- Copyright (C) 1995-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
with Unchecked_Deallocation; with Unchecked_Deallocation;
package GNAT.Strings is package GNAT.Strings is
pragma Preelaborate;
type String_Access is access all String; type String_Access is access all String;
-- General purpose string access type. Note that the caller is -- General purpose string access type. Note that the caller is
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1996-2004 Free Software Foundation, Inc. -- -- Copyright (C) 1996-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
with Unchecked_Conversion; with Unchecked_Conversion;
package System.Aux_DEC is package System.Aux_DEC is
pragma Elaborate_Body (Aux_DEC); pragma Preelaborate;
subtype Short_Address is Address subtype Short_Address is Address
range -2 ** (32 - 1) .. +2 ** (32 - 1) - 1; range -2 ** (32 - 1) .. +2 ** (32 - 1) - 1;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1996-2004 Free Software Foundation, Inc. -- -- Copyright (C) 1996-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
with Unchecked_Conversion; with Unchecked_Conversion;
package System.Aux_DEC is package System.Aux_DEC is
pragma Elaborate_Body (Aux_DEC); pragma Preelaborate;
subtype Short_Address is Address; subtype Short_Address is Address;
-- In some versions of System.Aux_DEC, notably that for VMS on the -- In some versions of System.Aux_DEC, notably that for VMS on the
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1996-2003 Free Software Foundation, Inc. -- -- Copyright (C) 1996-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -43,9 +43,9 @@ package body System.Exception_Table is ...@@ -43,9 +43,9 @@ package body System.Exception_Table is
procedure Set_HT_Link (T : Exception_Data_Ptr; Next : Exception_Data_Ptr); procedure Set_HT_Link (T : Exception_Data_Ptr; Next : Exception_Data_Ptr);
function Get_HT_Link (T : Exception_Data_Ptr) return Exception_Data_Ptr; function Get_HT_Link (T : Exception_Data_Ptr) return Exception_Data_Ptr;
function Hash (F : Big_String_Ptr) return HTable_Headers; function Hash (F : System.Address) return HTable_Headers;
function Equal (A, B : Big_String_Ptr) return Boolean; function Equal (A, B : System.Address) return Boolean;
function Get_Key (T : Exception_Data_Ptr) return Big_String_Ptr; function Get_Key (T : Exception_Data_Ptr) return System.Address;
package Exception_HTable is new System.HTable.Static_HTable ( package Exception_HTable is new System.HTable.Static_HTable (
Header_Num => HTable_Headers, Header_Num => HTable_Headers,
...@@ -54,7 +54,7 @@ package body System.Exception_Table is ...@@ -54,7 +54,7 @@ package body System.Exception_Table is
Null_Ptr => null, Null_Ptr => null,
Set_Next => Set_HT_Link, Set_Next => Set_HT_Link,
Next => Get_HT_Link, Next => Get_HT_Link,
Key => Big_String_Ptr, Key => System.Address,
Get_Key => Get_Key, Get_Key => Get_Key,
Hash => Hash, Hash => Hash,
Equal => Equal); Equal => Equal);
...@@ -63,15 +63,17 @@ package body System.Exception_Table is ...@@ -63,15 +63,17 @@ package body System.Exception_Table is
-- Equal -- -- Equal --
----------- -----------
function Equal (A, B : Big_String_Ptr) return Boolean is function Equal (A, B : System.Address) return Boolean is
J : Integer := 1; S1 : constant Big_String_Ptr := To_Ptr (A);
S2 : constant Big_String_Ptr := To_Ptr (B);
J : Integer := 1;
begin begin
loop loop
if A (J) /= B (J) then if S1 (J) /= S2 (J) then
return False; return False;
elsif A (J) = ASCII.NUL then elsif S1 (J) = ASCII.NUL then
return True; return True;
else else
...@@ -93,7 +95,7 @@ package body System.Exception_Table is ...@@ -93,7 +95,7 @@ package body System.Exception_Table is
-- Get_Key -- -- Get_Key --
------------- -------------
function Get_Key (T : Exception_Data_Ptr) return Big_String_Ptr is function Get_Key (T : Exception_Data_Ptr) return System.Address is
begin begin
return T.Full_Name; return T.Full_Name;
end Get_Key; end Get_Key;
...@@ -125,9 +127,10 @@ package body System.Exception_Table is ...@@ -125,9 +127,10 @@ package body System.Exception_Table is
-- Hash -- -- Hash --
---------- ----------
function Hash (F : Big_String_Ptr) return HTable_Headers is function Hash (F : System.Address) return HTable_Headers is
type S is mod 2**8; type S is mod 2**8;
Str : constant Big_String_Ptr := To_Ptr (F);
Size : constant S := S (HTable_Headers'Last - HTable_Headers'First + 1); Size : constant S := S (HTable_Headers'Last - HTable_Headers'First + 1);
Tmp : S := 0; Tmp : S := 0;
J : Positive; J : Positive;
...@@ -135,10 +138,10 @@ package body System.Exception_Table is ...@@ -135,10 +138,10 @@ package body System.Exception_Table is
begin begin
J := 1; J := 1;
loop loop
if F (J) = ASCII.NUL then if Str (J) = ASCII.NUL then
return HTable_Headers'First + HTable_Headers'Base (Tmp mod Size); return HTable_Headers'First + HTable_Headers'Base (Tmp mod Size);
else else
Tmp := Tmp xor S (Character'Pos (F (J))); Tmp := Tmp xor S (Character'Pos (Str (J)));
end if; end if;
J := J + 1; J := J + 1;
end loop; end loop;
...@@ -161,7 +164,7 @@ package body System.Exception_Table is ...@@ -161,7 +164,7 @@ package body System.Exception_Table is
begin begin
Copy (X'Range) := X; Copy (X'Range) := X;
Copy (Copy'Last) := ASCII.NUL; Copy (Copy'Last) := ASCII.NUL;
Res := Exception_HTable.Get (To_Ptr (Copy'Address)); Res := Exception_HTable.Get (Copy'Address);
-- If unknown exception, create it on the heap. This is a legitimate -- If unknown exception, create it on the heap. This is a legitimate
-- situation in the distributed case when an exception is defined only -- situation in the distributed case when an exception is defined only
...@@ -175,7 +178,7 @@ package body System.Exception_Table is ...@@ -175,7 +178,7 @@ package body System.Exception_Table is
(Not_Handled_By_Others => False, (Not_Handled_By_Others => False,
Lang => 'A', Lang => 'A',
Name_Length => Copy'Length, Name_Length => Copy'Length,
Full_Name => To_Ptr (Dyn_Copy.all'Address), Full_Name => Dyn_Copy.all'Address,
HTable_Ptr => null, HTable_Ptr => null,
Import_Code => 0, Import_Code => 0,
Raise_Hook => null); Raise_Hook => null);
......
...@@ -286,13 +286,14 @@ package body System.Interrupt_Management.Operations is ...@@ -286,13 +286,14 @@ package body System.Interrupt_Management.Operations is
end Setup_Interrupt_Mask; end Setup_Interrupt_Mask;
begin begin
declare declare
mask : aliased sigset_t; mask : aliased sigset_t;
allmask : aliased sigset_t; allmask : aliased sigset_t;
Result : Interfaces.C.int; Result : Interfaces.C.int;
begin begin
Interrupt_Management.Initialize;
for Sig in 1 .. Signal'Last loop for Sig in 1 .. Signal'Last loop
Result := sigaction Result := sigaction
(Sig, null, Initial_Action (Sig)'Unchecked_Access); (Sig, null, Initial_Action (Sig)'Unchecked_Access);
......
...@@ -295,6 +295,7 @@ package body System.Interrupt_Management.Operations is ...@@ -295,6 +295,7 @@ package body System.Interrupt_Management.Operations is
end Setup_Interrupt_Mask; end Setup_Interrupt_Mask;
begin begin
Interrupt_Management.Initialize;
Environment_Mask := (others => False); Environment_Mask := (others => False);
All_Tasks_Mask := (others => True); All_Tasks_Mask := (others => True);
......
...@@ -35,4 +35,13 @@ ...@@ -35,4 +35,13 @@
package body System.Interrupt_Management is package body System.Interrupt_Management is
----------------
-- Initialize --
----------------
procedure Initialize is
begin
null;
end Initialize;
end System.Interrupt_Management; end System.Interrupt_Management;
...@@ -34,9 +34,6 @@ ...@@ -34,9 +34,6 @@
-- This is an Irix (old pthread library) version of this package. -- This is an Irix (old pthread library) version of this package.
-- PLEASE DO NOT add any dependences on other packages.
-- This package is designed to work with or without tasking support.
-- Make a careful study of all signals available under the OS, -- Make a careful study of all signals available under the OS,
-- to see which need to be reserved, kept always unmasked, -- to see which need to be reserved, kept always unmasked,
-- or kept always unmasked. -- or kept always unmasked.
...@@ -49,6 +46,7 @@ with System.OS_Interface; ...@@ -49,6 +46,7 @@ with System.OS_Interface;
with Interfaces.C; with Interfaces.C;
-- used for "int" -- used for "int"
package body System.Interrupt_Management is package body System.Interrupt_Management is
use System.OS_Interface; use System.OS_Interface;
...@@ -82,25 +80,27 @@ package body System.Interrupt_Management is ...@@ -82,25 +80,27 @@ package body System.Interrupt_Management is
pragma Import pragma Import
(C, Unreserve_All_Interrupts, "__gl_unreserve_all_interrupts"); (C, Unreserve_All_Interrupts, "__gl_unreserve_all_interrupts");
begin function State (Int : Interrupt_ID) return Character;
declare pragma Import (C, State, "__gnat_get_interrupt_state");
function State (Int : Interrupt_ID) return Character; -- Get interrupt state. Defined in a-init.c
pragma Import (C, State, "__gnat_get_interrupt_state"); -- The input argument is the interrupt number,
-- Get interrupt state. Defined in a-init.c -- and the result is one of the following:
-- The input argument is the interrupt number,
-- and the result is one of the following: User : constant Character := 'u';
Runtime : constant Character := 'r';
User : constant Character := 'u'; Default : constant Character := 's';
Runtime : constant Character := 'r'; -- 'n' this interrupt not set by any Interrupt_State pragma
Default : constant Character := 's'; -- 'u' Interrupt_State pragma set state to User
-- 'n' this interrupt not set by any Interrupt_State pragma -- 'r' Interrupt_State pragma set state to Runtime
-- 'u' Interrupt_State pragma set state to User -- 's' Interrupt_State pragma set state to System (use "default"
-- 'r' Interrupt_State pragma set state to Runtime -- system handler)
-- 's' Interrupt_State pragma set state to System (use "default"
-- system handler) ----------------
-- Initialize --
----------------
procedure Initialize is
use Interfaces.C; use Interfaces.C;
begin begin
Abort_Task_Interrupt := Abort_Signal; Abort_Task_Interrupt := Abort_Signal;
...@@ -158,5 +158,6 @@ begin ...@@ -158,5 +158,6 @@ begin
-- mark it as reserved. -- mark it as reserved.
Reserve (0) := True; Reserve (0) := True;
end; end Initialize;
end System.Interrupt_Management; end System.Interrupt_Management;
...@@ -34,9 +34,6 @@ ...@@ -34,9 +34,6 @@
-- This is a SGI Pthread version of this package. -- This is a SGI Pthread version of this package.
-- PLEASE DO NOT add any dependences on other packages.
-- This package is designed to work with or without tasking support.
-- Make a careful study of all signals available under the OS, -- Make a careful study of all signals available under the OS,
-- to see which need to be reserved, kept always unmasked, -- to see which need to be reserved, kept always unmasked,
-- or kept always unmasked. -- or kept always unmasked.
...@@ -63,27 +60,36 @@ package body System.Interrupt_Management is ...@@ -63,27 +60,36 @@ package body System.Interrupt_Management is
pragma Import pragma Import
(C, Unreserve_All_Interrupts, "__gl_unreserve_all_interrupts"); (C, Unreserve_All_Interrupts, "__gl_unreserve_all_interrupts");
use type Interfaces.C.int; function State (Int : Interrupt_ID) return Character;
pragma Import (C, State, "__gnat_get_interrupt_state");
-- Get interrupt state. Defined in a-init.c
-- The input argument is the interrupt number,
-- and the result is one of the following:
begin User : constant Character := 'u';
declare Runtime : constant Character := 'r';
function State (Int : Interrupt_ID) return Character; Default : constant Character := 's';
pragma Import (C, State, "__gnat_get_interrupt_state"); -- 'n' this interrupt not set by any Interrupt_State pragma
-- 'u' Interrupt_State pragma set state to User
-- 'r' Interrupt_State pragma set state to Runtime
-- 's' Interrupt_State pragma set state to System (use "default"
-- system handler)
-- Get interrupt state. Defined in a-init.c ----------------
-- The input argument is the interrupt number, -- Initialize --
-- and the result is one of the following: ----------------
User : constant Character := 'u'; Initialized : Boolean := False;
Runtime : constant Character := 'r';
Default : constant Character := 's';
-- 'n' this interrupt not set by any Interrupt_State pragma
-- 'u' Interrupt_State pragma set state to User
-- 'r' Interrupt_State pragma set state to Runtime
-- 's' Interrupt_State pragma set state to System (use "default"
-- system handler)
procedure Initialize is
use type Interfaces.C.int;
begin begin
if Initialized then
return;
end if;
Initialized := True;
Abort_Task_Interrupt := SIGABRT; Abort_Task_Interrupt := SIGABRT;
-- Change this if you want to use another signal for task abort. -- Change this if you want to use another signal for task abort.
...@@ -137,5 +143,6 @@ begin ...@@ -137,5 +143,6 @@ begin
-- mark it as reserved. -- mark it as reserved.
Reserve (0) := True; Reserve (0) := True;
end; end Initialize;
end System.Interrupt_Management; end System.Interrupt_Management;
...@@ -33,34 +33,29 @@ ...@@ -33,34 +33,29 @@
-- This is the NT version of this package -- This is the NT version of this package
-- This file performs the system-dependent translation between machine with System.OS_Interface; use System.OS_Interface;
-- exceptions and the Ada exceptions, if any, that should be raised when they
-- occur.
-- PLEASE DO NOT add any dependences on other packages. package body System.Interrupt_Management is
-- This package is designed to work with or without tasking support.
-- See the other warnings in the package specification before making any ----------------
-- modifications to this file. -- Initialize --
----------------
-- Make a careful study of all signals available under the OS, to see which procedure Initialize is
-- need to be reserved, kept always unmasked, or kept always unmasked. Be on begin
-- the lookout for special signals that may be used by the thread library. -- "Reserve" all the interrupts, except those that are explicitely
-- defined.
with System.OS_Interface; use System.OS_Interface; for J in Interrupt_ID'Range loop
Reserve (J) := True;
package body System.Interrupt_Management is end loop;
begin
-- "Reserve" all the interrupts, except those that are explicitely defined
for J in Interrupt_ID'Range loop Reserve (SIGINT) := False;
Reserve (J) := True; Reserve (SIGILL) := False;
end loop; Reserve (SIGABRT) := False;
Reserve (SIGFPE) := False;
Reserve (SIGSEGV) := False;
Reserve (SIGTERM) := False;
end Initialize;
Reserve (SIGINT) := False;
Reserve (SIGILL) := False;
Reserve (SIGABRT) := False;
Reserve (SIGFPE) := False;
Reserve (SIGSEGV) := False;
Reserve (SIGTERM) := False;
end System.Interrupt_Management; end System.Interrupt_Management;
...@@ -33,12 +33,6 @@ ...@@ -33,12 +33,6 @@
-- This is the POSIX threads version of this package -- This is the POSIX threads version of this package
-- PLEASE DO NOT add any dependences on other packages. ??? why not ???
-- This package is designed to work with or without tasking support.
-- See the other warnings in the package specification before making
-- any modifications to this file.
-- Make a careful study of all signals available under the OS, to see which -- Make a careful study of all signals available under the OS, to see which
-- need to be reserved, kept always unmasked, or kept always unmasked. Be on -- need to be reserved, kept always unmasked, or kept always unmasked. Be on
-- the lookout for special signals that may be used by the thread library. -- the lookout for special signals that may be used by the thread library.
...@@ -88,6 +82,21 @@ package body System.Interrupt_Management is ...@@ -88,6 +82,21 @@ package body System.Interrupt_Management is
-- Local Subprograms -- -- Local Subprograms --
----------------------- -----------------------
function State (Int : Interrupt_ID) return Character;
pragma Import (C, State, "__gnat_get_interrupt_state");
-- Get interrupt state. Defined in init.c
-- The input argument is the interrupt number,
-- and the result is one of the following:
User : constant Character := 'u';
Runtime : constant Character := 'r';
Default : constant Character := 's';
-- 'n' this interrupt not set by any Interrupt_State pragma
-- 'u' Interrupt_State pragma set state to User
-- 'r' Interrupt_State pragma set state to Runtime
-- 's' Interrupt_State pragma set state to System (use "default"
-- system handler)
procedure Notify_Exception procedure Notify_Exception
(signo : Signal; (signo : Signal;
siginfo : System.Address; siginfo : System.Address;
...@@ -154,32 +163,24 @@ package body System.Interrupt_Management is ...@@ -154,32 +163,24 @@ package body System.Interrupt_Management is
end case; end case;
end Notify_Exception; end Notify_Exception;
------------------------- ----------------
-- Package Elaboration -- -- Initialize --
------------------------- ----------------
begin Initialized : Boolean := False;
declare
procedure Initialize is
act : aliased struct_sigaction; act : aliased struct_sigaction;
old_act : aliased struct_sigaction; old_act : aliased struct_sigaction;
Result : System.OS_Interface.int; Result : System.OS_Interface.int;
function State (Int : Interrupt_ID) return Character;
pragma Import (C, State, "__gnat_get_interrupt_state");
-- Get interrupt state. Defined in a-init.c
-- The input argument is the interrupt number,
-- and the result is one of the following:
User : constant Character := 'u';
Runtime : constant Character := 'r';
Default : constant Character := 's';
-- 'n' this interrupt not set by any Interrupt_State pragma
-- 'u' Interrupt_State pragma set state to User
-- 'r' Interrupt_State pragma set state to Runtime
-- 's' Interrupt_State pragma set state to System (use "default"
-- system handler)
begin begin
if Initialized then
return;
end if;
Initialized := True;
-- Need to call pthread_init very early because it is doing signal -- Need to call pthread_init very early because it is doing signal
-- initializations. -- initializations.
...@@ -295,5 +296,6 @@ begin ...@@ -295,5 +296,6 @@ begin
-- mark it as reserved. -- mark it as reserved.
Reserve (0) := True; Reserve (0) := True;
end; end Initialize;
end System.Interrupt_Management; end System.Interrupt_Management;
...@@ -33,9 +33,6 @@ ...@@ -33,9 +33,6 @@
-- This is a Solaris version of this package. -- This is a Solaris version of this package.
-- PLEASE DO NOT add any dependences on other packages.
-- This package is designed to work with or without tasking support.
-- Make a careful study of all signals available under the OS, -- Make a careful study of all signals available under the OS,
-- to see which need to be reserved, kept always unmasked, -- to see which need to be reserved, kept always unmasked,
-- or kept always unmasked. -- or kept always unmasked.
...@@ -63,6 +60,21 @@ package body System.Interrupt_Management is ...@@ -63,6 +60,21 @@ package body System.Interrupt_Management is
pragma Import pragma Import
(C, Unreserve_All_Interrupts, "__gl_unreserve_all_interrupts"); (C, Unreserve_All_Interrupts, "__gl_unreserve_all_interrupts");
function State (Int : Interrupt_ID) return Character;
pragma Import (C, State, "__gnat_get_interrupt_state");
-- Get interrupt state. Defined in init.c
-- The input argument is the interrupt number,
-- and the result is one of the following:
User : constant Character := 'u';
Runtime : constant Character := 'r';
Default : constant Character := 's';
-- 'n' this interrupt not set by any Interrupt_State pragma
-- 'u' Interrupt_State pragma set state to User
-- 'r' Interrupt_State pragma set state to Runtime
-- 's' Interrupt_State pragma set state to System (use "default"
-- system handler)
---------------------- ----------------------
-- Notify_Exception -- -- Notify_Exception --
---------------------- ----------------------
...@@ -86,8 +98,7 @@ package body System.Interrupt_Management is ...@@ -86,8 +98,7 @@ package body System.Interrupt_Management is
info : access siginfo_t; info : access siginfo_t;
context : access ucontext_t) context : access ucontext_t)
is is
pragma Warnings (Off, context); pragma Unreferenced (context);
begin begin
-- Check that treatment of exception propagation here -- Check that treatment of exception propagation here
-- is consistent with treatment of the abort signal in -- is consistent with treatment of the abort signal in
...@@ -121,33 +132,25 @@ package body System.Interrupt_Management is ...@@ -121,33 +132,25 @@ package body System.Interrupt_Management is
end case; end case;
end Notify_Exception; end Notify_Exception;
---------------------------- ----------------
-- Package Initialization -- -- Initialize --
---------------------------- ----------------
begin Initialized : Boolean := False;
declare
procedure Initialize is
act : aliased struct_sigaction; act : aliased struct_sigaction;
old_act : aliased struct_sigaction; old_act : aliased struct_sigaction;
mask : aliased sigset_t; mask : aliased sigset_t;
Result : Interfaces.C.int; Result : Interfaces.C.int;
function State (Int : Interrupt_ID) return Character;
pragma Import (C, State, "__gnat_get_interrupt_state");
-- Get interrupt state. Defined in a-init.c
-- The input argument is the interrupt number,
-- and the result is one of the following:
--
User : constant Character := 'u';
Runtime : constant Character := 'r';
Default : constant Character := 's';
-- 'n' this interrupt not set by any Interrupt_State pragma
-- 'u' Interrupt_State pragma set state to User
-- 'r' Interrupt_State pragma set state to Runtime
-- 's' Interrupt_State pragma set state to System (use "default"
-- system handler)
begin begin
if Initialized then
return;
end if;
Initialized := True;
-- Need to call pthread_init very early because it is doing signal -- Need to call pthread_init very early because it is doing signal
-- initializations. -- initializations.
...@@ -248,5 +251,6 @@ begin ...@@ -248,5 +251,6 @@ begin
-- mark it as reserved. -- mark it as reserved.
Reserve (0) := True; Reserve (0) := True;
end; end Initialize;
end System.Interrupt_Management; end System.Interrupt_Management;
...@@ -38,20 +38,29 @@ with System.OS_Interface; ...@@ -38,20 +38,29 @@ with System.OS_Interface;
package body System.Interrupt_Management is package body System.Interrupt_Management is
use System.OS_Interface; ----------------
use type unsigned_long; -- Initialize --
----------------
begin Initialized : Boolean := False;
Abort_Task_Interrupt := Interrupt_ID_0;
-- Unused
Reserve := Reserve or Keep_Unmasked or Keep_Masked; procedure Initialize is
use System.OS_Interface;
Reserve (Interrupt_ID_0) := True; use type unsigned_long;
declare
Status : Cond_Value_Type; Status : Cond_Value_Type;
begin begin
if Initialized then
return;
end if;
Initialized := True;
Abort_Task_Interrupt := Interrupt_ID_0;
-- Unused
Reserve := Reserve or Keep_Unmasked or Keep_Masked;
Reserve (Interrupt_ID_0) := True;
Sys_Crembx Sys_Crembx
(Status => Status, (Status => Status,
Prmflg => False, Prmflg => False,
...@@ -60,7 +69,6 @@ begin ...@@ -60,7 +69,6 @@ begin
Bufquo => Interrupt_Bufquo, Bufquo => Interrupt_Bufquo,
Lognam => "GNAT_Interrupt_Mailbox", Lognam => "GNAT_Interrupt_Mailbox",
Flags => CMB_M_READONLY); Flags => CMB_M_READONLY);
pragma Assert ((Status and 1) = 1); pragma Assert ((Status and 1) = 1);
Sys_Assign Sys_Assign
...@@ -68,7 +76,7 @@ begin ...@@ -68,7 +76,7 @@ begin
Devnam => "GNAT_Interrupt_Mailbox", Devnam => "GNAT_Interrupt_Mailbox",
Chan => Snd_Interrupt_Chan, Chan => Snd_Interrupt_Chan,
Flags => AGN_M_WRITEONLY); Flags => AGN_M_WRITEONLY);
pragma Assert ((Status and 1) = 1); pragma Assert ((Status and 1) = 1);
end; end Initialize;
end System.Interrupt_Management; end System.Interrupt_Management;
...@@ -39,16 +39,6 @@ ...@@ -39,16 +39,6 @@
-- PLEASE DO NOT add any with-clauses to this package -- PLEASE DO NOT add any with-clauses to this package
-- This is designed to work for both tasking and non-tasking systems, without
-- pulling in any of the tasking support.
-- PLEASE DO NOT remove the Elaborate_Body pragma from this package.
-- Elaboration of this package should happen early, as most other
-- Forcing immediate elaboration of the body also helps to enforce the design
-- assumption that this is a second-level package, just one level above
-- System.OS_Interface, with no cross-dependences.
-- PLEASE DO NOT put any subprogram declarations with arguments of type -- PLEASE DO NOT put any subprogram declarations with arguments of type
-- Interrupt_ID into the visible part of this package. -- Interrupt_ID into the visible part of this package.
...@@ -62,8 +52,7 @@ with System.OS_Interface; ...@@ -62,8 +52,7 @@ with System.OS_Interface;
-- sigset_t -- sigset_t
package System.Interrupt_Management is package System.Interrupt_Management is
pragma Preelaborate;
pragma Elaborate_Body;
type Interrupt_Mask is limited private; type Interrupt_Mask is limited private;
...@@ -110,6 +99,11 @@ package System.Interrupt_Management is ...@@ -110,6 +99,11 @@ package System.Interrupt_Management is
-- example, if interrupts are OS signals and signal masking is per-task, -- example, if interrupts are OS signals and signal masking is per-task,
-- use of the sigwait operation requires the signal be masked in all tasks. -- use of the sigwait operation requires the signal be masked in all tasks.
procedure Initialize;
-- Initialize the various variables defined in this package.
-- This procedure must be called before accessing any object from this
-- package and can be called multiple times.
private private
use type System.OS_Interface.unsigned_long; use type System.OS_Interface.unsigned_long;
......
...@@ -33,15 +33,6 @@ ...@@ -33,15 +33,6 @@
-- This is the VxWorks version of this package. -- This is the VxWorks version of this package.
-- It is likely to need tailoring to fit each operating system
-- and machine architecture.
-- PLEASE DO NOT add any dependences on other packages.
-- This package is designed to work with or without tasking support.
-- See the other warnings in the package specification before making
-- any modifications to this file.
-- Make a careful study of all signals available under the OS, -- Make a careful study of all signals available under the OS,
-- to see which need to be reserved, kept always unmasked, -- to see which need to be reserved, kept always unmasked,
-- or kept always unmasked. -- or kept always unmasked.
...@@ -74,6 +65,20 @@ package body System.Interrupt_Management is ...@@ -74,6 +65,20 @@ package body System.Interrupt_Management is
-- Local Subprograms -- -- Local Subprograms --
----------------------- -----------------------
function State (Int : Interrupt_ID) return Character;
pragma Import (C, State, "__gnat_get_interrupt_state");
-- Get interrupt state. Defined in init.c
-- The input argument is the interrupt number,
-- and the result is one of the following:
Runtime : constant Character := 'r';
Default : constant Character := 's';
-- 'n' this interrupt not set by any Interrupt_State pragma
-- 'u' Interrupt_State pragma set state to User
-- 'r' Interrupt_State pragma set state to Runtime
-- 's' Interrupt_State pragma set state to System (use "default"
-- system handler)
procedure Notify_Exception (signo : Signal); procedure Notify_Exception (signo : Signal);
-- Identify the Ada exception to be raised using -- Identify the Ada exception to be raised using
-- the information when the system received a synchronous signal. -- the information when the system received a synchronous signal.
...@@ -116,27 +121,21 @@ package body System.Interrupt_Management is ...@@ -116,27 +121,21 @@ package body System.Interrupt_Management is
end loop; end loop;
end Initialize_Interrupts; end Initialize_Interrupts;
begin ----------------
declare -- Initialize --
mask : aliased sigset_t; ----------------
Result : int;
function State (Int : Interrupt_ID) return Character;
pragma Import (C, State, "__gnat_get_interrupt_state");
-- Get interrupt state. Defined in a-init.c
-- The input argument is the interrupt number,
-- and the result is one of the following:
Runtime : constant Character := 'r'; Initialized : Boolean := False;
Default : constant Character := 's';
-- 'n' this interrupt not set by any Interrupt_State pragma
-- 'u' Interrupt_State pragma set state to User
-- 'r' Interrupt_State pragma set state to Runtime
-- 's' Interrupt_State pragma set state to System (use "default"
-- system handler)
procedure Initialize is
mask : aliased sigset_t;
Result : int;
begin begin
-- Initialize signal handling if Initialized then
return;
end if;
Initialized := True;
-- Change this if you want to use another signal for task abort. -- Change this if you want to use another signal for task abort.
-- SIGTERM might be a good one. -- SIGTERM might be a good one.
...@@ -176,5 +175,6 @@ begin ...@@ -176,5 +175,6 @@ begin
-- The abort signal must also be unmasked -- The abort signal must also be unmasked
Keep_Unmasked (Abort_Task_Signal) := True; Keep_Unmasked (Abort_Task_Signal) := True;
end; end Initialize;
end System.Interrupt_Management; end System.Interrupt_Management;
...@@ -40,13 +40,6 @@ ...@@ -40,13 +40,6 @@
-- Unlike the original design, System.Interrupt_Management can only -- Unlike the original design, System.Interrupt_Management can only
-- be used for tasking systems. -- be used for tasking systems.
-- PLEASE DO NOT remove the Elaborate_Body pragma from this package.
-- Elaboration of this package should happen early, as most other
-- initializations depend on it. Forcing immediate elaboration of
-- the body also helps to enforce the design assumption that this
-- is a second-level package, just one level above System.OS_Interface
-- with no cross-dependencies.
-- PLEASE DO NOT put any subprogram declarations with arguments of -- PLEASE DO NOT put any subprogram declarations with arguments of
-- type Interrupt_ID into the visible part of this package. The type -- type Interrupt_ID into the visible part of this package. The type
-- Interrupt_ID is used to derive the type in Ada.Interrupts, and -- Interrupt_ID is used to derive the type in Ada.Interrupts, and
...@@ -61,8 +54,7 @@ with Interfaces.C; ...@@ -61,8 +54,7 @@ with Interfaces.C;
-- used for int -- used for int
package System.Interrupt_Management is package System.Interrupt_Management is
pragma Preelaborate;
pragma Elaborate_Body;
type Interrupt_Mask is limited private; type Interrupt_Mask is limited private;
...@@ -114,6 +106,11 @@ package System.Interrupt_Management is ...@@ -114,6 +106,11 @@ package System.Interrupt_Management is
-- This procedure is used to initialize signal-to-exception mapping in -- This procedure is used to initialize signal-to-exception mapping in
-- each task. -- each task.
procedure Initialize;
-- Initialize the various variables defined in this package.
-- This procedure must be called before accessing any object from this
-- package and can be called multiple times.
private private
type Interrupt_Mask is new System.OS_Interface.sigset_t; type Interrupt_Mask is new System.OS_Interface.sigset_t;
-- In some implementation Interrupt_Mask can be represented as a linked -- In some implementation Interrupt_Mask can be represented as a linked
......
...@@ -38,13 +38,6 @@ ...@@ -38,13 +38,6 @@
-- Unlike the original design, System.Interrupt_Management can only be used -- Unlike the original design, System.Interrupt_Management can only be used
-- for tasking systems. -- for tasking systems.
-- PLEASE DO NOT remove the Elaborate_Body pragma from this package.
-- Elaboration of this package should happen early, as most other
-- initializations depend on it. Forcing immediate elaboration of the body
-- also helps to enforce the design assumption that this is a second-level
-- package, just one level above System.OS_Interface with no
-- cross-dependencies.
-- PLEASE DO NOT put any subprogram declarations with arguments of type -- PLEASE DO NOT put any subprogram declarations with arguments of type
-- Interrupt_ID into the visible part of this package. The type Interrupt_ID -- Interrupt_ID into the visible part of this package. The type Interrupt_ID
-- is used to derive the type in Ada.Interrupts, and adding more operations -- is used to derive the type in Ada.Interrupts, and adding more operations
...@@ -59,8 +52,7 @@ with Interfaces.C; ...@@ -59,8 +52,7 @@ with Interfaces.C;
-- used for int -- used for int
package System.Interrupt_Management is package System.Interrupt_Management is
pragma Preelaborate;
pragma Elaborate_Body;
type Interrupt_Mask is limited private; type Interrupt_Mask is limited private;
...@@ -103,6 +95,11 @@ package System.Interrupt_Management is ...@@ -103,6 +95,11 @@ package System.Interrupt_Management is
-- example, it may be mapped to an exception used to implement task abort, -- example, it may be mapped to an exception used to implement task abort,
-- or used to implement time delays. -- or used to implement time delays.
procedure Initialize;
-- Initialize the various variables defined in this package.
-- This procedure must be called before accessing any object from this
-- package, and can be called multiple times.
private private
type Interrupt_Mask is new System.OS_Interface.sigset_t; type Interrupt_Mask is new System.OS_Interface.sigset_t;
-- In some implementations Interrupt_Mask can be represented as a linked -- In some implementations Interrupt_Mask can be represented as a linked
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
-- This is the NT version of this package -- This is the NT version of this package
with Ada.Exceptions;
with Interfaces.C; with Interfaces.C;
package body System.OS_Primitives is package body System.OS_Primitives is
...@@ -267,20 +266,35 @@ package body System.OS_Primitives is ...@@ -267,20 +266,35 @@ package body System.OS_Primitives is
end if; end if;
end Timed_Delay; end Timed_Delay;
-- Package elaboration, get starting time as base ----------------
-- Initialize --
----------------
begin Initialized : Boolean := False;
if not QueryPerformanceFrequency (Tick_Frequency'Access) then
Ada.Exceptions.Raise_Exception
(Program_Error'Identity,
"cannot get high performance counter frequency");
end if;
Get_Base_Time; procedure Initialize is
begin
if Initialized then
return;
end if;
Initialized := True;
-- Get starting time as base
if not QueryPerformanceFrequency (Tick_Frequency'Access) then
raise Program_Error
with "cannot get high performance counter frequency";
end if;
Get_Base_Time;
-- Keep base clock and ticks for the monotonic clock. These values
-- should never be changed to ensure proper behavior of the monotonic
-- clock.
-- Keep base clock and ticks for the monotonic clock. These values should Base_Monotonic_Clock := Base_Clock;
-- never be changed to ensure proper behavior of the monotonic clock. Base_Monotonic_Ticks := Base_Ticks;
end Initialize;
Base_Monotonic_Clock := Base_Clock;
Base_Monotonic_Ticks := Base_Ticks;
end System.OS_Primitives; end System.OS_Primitives;
...@@ -167,6 +167,18 @@ package body System.OS_Primitives is ...@@ -167,6 +167,18 @@ package body System.OS_Primitives is
end if; end if;
end Timed_Delay; end Timed_Delay;
begin ----------------
Set_Epoch_Offset; -- Initialize --
----------------
Initialized : Boolean := False;
procedure Initialize is
begin
if not Initialized then
Initialized := True;
Set_Epoch_Offset;
end if;
end Initialize;
end System.OS_Primitives; end System.OS_Primitives;
...@@ -156,4 +156,13 @@ package body System.OS_Primitives is ...@@ -156,4 +156,13 @@ package body System.OS_Primitives is
end if; end if;
end Timed_Delay; end Timed_Delay;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
null;
end Initialize;
end System.OS_Primitives; end System.OS_Primitives;
...@@ -121,4 +121,13 @@ package body System.OS_Primitives is ...@@ -121,4 +121,13 @@ package body System.OS_Primitives is
end if; end if;
end Timed_Delay; end Timed_Delay;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
null;
end Initialize;
end System.OS_Primitives; end System.OS_Primitives;
...@@ -121,4 +121,13 @@ package body System.OS_Primitives is ...@@ -121,4 +121,13 @@ package body System.OS_Primitives is
end if; end if;
end Timed_Delay; end Timed_Delay;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
null;
end Initialize;
end System.OS_Primitives; end System.OS_Primitives;
...@@ -45,14 +45,22 @@ package body System.OS_Primitives is ...@@ -45,14 +45,22 @@ package body System.OS_Primitives is
pragma Import (C, Get_GMToff, "get_gmtoff"); pragma Import (C, Get_GMToff, "get_gmtoff");
-- Get the offset from GMT for this timezone -- Get the offset from GMT for this timezone
VMS_Epoch_Offset : constant Long_Integer := function VMS_Epoch_Offset return Long_Integer;
10_000_000 * pragma Inline (VMS_Epoch_Offset);
(3_506_716_800 + Long_Integer (Get_GMToff));
-- The offset between the Unix Epoch and the VMS Epoch -- The offset between the Unix Epoch and the VMS Epoch
subtype Cond_Value_Type is System.Aux_DEC.Unsigned_Longword; subtype Cond_Value_Type is System.Aux_DEC.Unsigned_Longword;
-- Condition Value return type -- Condition Value return type
----------------------
-- VMS_Epoch_Offset --
----------------------
function VMS_Epoch_Offset return Long_Integer is
begin
return 10_000_000 * (3_506_716_800 + Long_Integer (Get_GMToff));
end VMS_Epoch_Offset;
---------------- ----------------
-- Sys_Schdwk -- -- Sys_Schdwk --
---------------- ----------------
......
...@@ -35,11 +35,12 @@ ...@@ -35,11 +35,12 @@
-- delays in non tasking applications on Alpha/VMS -- delays in non tasking applications on Alpha/VMS
-- The choice of the real clock/delay implementation (depending on whether -- The choice of the real clock/delay implementation (depending on whether
-- tasking is involved or not) is done via soft links (see s-tasoli.ads) -- tasking is involved or not) is done via soft links (see s-soflin.ads)
-- NEVER add any dependency to tasking packages here -- NEVER add any dependency to tasking packages here
package System.OS_Primitives is package System.OS_Primitives is
pragma Preelaborate;
subtype OS_Time is Long_Integer; subtype OS_Time is Long_Integer;
-- System time on VMS is used for performance reasons. -- System time on VMS is used for performance reasons.
......
...@@ -158,4 +158,13 @@ package body System.OS_Primitives is ...@@ -158,4 +158,13 @@ package body System.OS_Primitives is
end if; end if;
end Timed_Delay; end Timed_Delay;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
null;
end Initialize;
end System.OS_Primitives; end System.OS_Primitives;
...@@ -35,11 +35,12 @@ ...@@ -35,11 +35,12 @@
-- delays in non tasking applications. -- delays in non tasking applications.
-- The choice of the real clock/delay implementation (depending on whether -- The choice of the real clock/delay implementation (depending on whether
-- tasking is involved or not) is done via soft links (see s-tasoli.ads) -- tasking is involved or not) is done via soft links (see s-soflin.ads)
-- NEVER add any dependency to tasking packages here -- NEVER add any dependency to tasking packages here
package System.OS_Primitives is package System.OS_Primitives is
pragma Preelaborate;
Max_Sensible_Delay : constant Duration := Max_Sensible_Delay : constant Duration :=
Duration'Min (183 * 24 * 60 * 60.0, Duration'Min (183 * 24 * 60 * 60.0,
...@@ -53,6 +54,11 @@ package System.OS_Primitives is ...@@ -53,6 +54,11 @@ package System.OS_Primitives is
-- occurs in high integrity mode with 32-bit words, and possibly on -- occurs in high integrity mode with 32-bit words, and possibly on
-- some specific ports of GNAT), Duration'Last is used instead. -- some specific ports of GNAT), Duration'Last is used instead.
procedure Initialize;
-- Initialize global settings related to this package.
-- This procedure should be called before any other subprograms in
-- this package. Note that this procedure can be called several times.
function Clock return Duration; function Clock return Duration;
pragma Inline (Clock); pragma Inline (Clock);
-- Returns "absolute" time, represented as an offset -- Returns "absolute" time, represented as an offset
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1997-1999 Free Software Foundation, Inc. -- -- Copyright (C) 1997-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -46,7 +46,9 @@ ...@@ -46,7 +46,9 @@
-- then relink your application as usual. -- then relink your application as usual.
-- --
pragma Warnings (Off);
with GNAT.OS_Lib; with GNAT.OS_Lib;
pragma Warnings (On);
package body System.Program_Info is package body System.Program_Info is
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1997-2003 Free Software Foundation, Inc. -- -- Copyright (C) 1997-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -35,62 +35,45 @@ ...@@ -35,62 +35,45 @@
-- to the run-time system at program startup for the SGI implementation. -- to the run-time system at program startup for the SGI implementation.
package System.Program_Info is package System.Program_Info is
pragma Preelaborate;
function Initial_Sproc_Count return Integer; function Initial_Sproc_Count return Integer;
--
-- The number of sproc created at program startup for scheduling -- The number of sproc created at program startup for scheduling
-- threads. -- threads.
--
function Max_Sproc_Count return Integer; function Max_Sproc_Count return Integer;
--
-- The maximum number of sprocs that can be created by the program -- The maximum number of sprocs that can be created by the program
-- for servicing threads. This limit includes both the pre-created -- for servicing threads. This limit includes both the pre-created
-- sprocs and those explicitly created under program control. -- sprocs and those explicitly created under program control.
--
function Sproc_Stack_Size return Integer; function Sproc_Stack_Size return Integer;
--
-- The size, in bytes, of the sproc's initial stack. -- The size, in bytes, of the sproc's initial stack.
--
function Default_Time_Slice return Duration; function Default_Time_Slice return Duration;
--
-- The default time quanta for round-robin scheduling of threads of -- The default time quanta for round-robin scheduling of threads of
-- equal priority. This default value can be overridden on a per-task -- equal priority. This default value can be overridden on a per-task
-- basis by specifying an alternate value via the implementation-defined -- basis by specifying an alternate value via the implementation-defined
-- Task_Info pragma. See s-tasinf.ads for more information. -- Task_Info pragma. See s-tasinf.ads for more information.
--
function Default_Task_Stack return Integer; function Default_Task_Stack return Integer;
--
-- The default stack size for each created thread. This default value -- The default stack size for each created thread. This default value
-- can be overriden on a per-task basis by the language-defined -- can be overriden on a per-task basis by the language-defined
-- Storage_Size pragma. -- Storage_Size pragma.
--
function Stack_Guard_Pages return Integer; function Stack_Guard_Pages return Integer;
--
-- The number of non-writable, guard pages to append to the bottom of -- The number of non-writable, guard pages to append to the bottom of
-- each thread's stack. -- each thread's stack.
--
function Pthread_Sched_Signal return Integer; function Pthread_Sched_Signal return Integer;
--
-- The signal used by the Pthreads library to affect scheduling actions -- The signal used by the Pthreads library to affect scheduling actions
-- in remote sprocs. -- in remote sprocs.
--
function Pthread_Arena_Size return Integer; function Pthread_Arena_Size return Integer;
--
-- The size of the shared arena from which pthread locks are allocated. -- The size of the shared arena from which pthread locks are allocated.
-- See the usinit(3p) man page for more information on shared arenas. -- See the usinit(3p) man page for more information on shared arenas.
--
function Os_Default_Priority return Integer; function Os_Default_Priority return Integer;
--
-- The default Irix Non-Degrading priority for each sproc created to -- The default Irix Non-Degrading priority for each sproc created to
-- service threads. -- service threads.
--
end System.Program_Info; end System.Program_Info;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1996-2003 Free Software Foundation, Inc. -- -- Copyright (C) 1996-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
-- to the run-time system at program startup. -- to the run-time system at program startup.
package System.Program_Info is package System.Program_Info is
pragma Preelaborate;
function Default_Task_Stack return Integer; function Default_Task_Stack return Integer;
-- The default stack size for each created thread. This default value -- The default stack size for each created thread. This default value
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- Copyright (C) 1992-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -35,26 +35,26 @@ pragma Polling (Off); ...@@ -35,26 +35,26 @@ pragma Polling (Off);
-- We must turn polling off for this unit, because otherwise we get -- We must turn polling off for this unit, because otherwise we get
-- an infinite loop from the code within the Poll routine itself. -- an infinite loop from the code within the Poll routine itself.
with System.Machine_State_Operations; use System.Machine_State_Operations;
-- Used for Create_TSD, Destroy_TSD
with System.Parameters; with System.Parameters;
-- Used for Sec_Stack_Ratio -- Used for Sec_Stack_Ratio
pragma Warnings (Off);
-- Disable warnings since System.Secondary_Stack is currently not
-- Preelaborate
with System.Secondary_Stack; with System.Secondary_Stack;
pragma Warnings (On);
package body System.Soft_Links is package body System.Soft_Links is
package SST renames System.Secondary_Stack; package SST renames System.Secondary_Stack;
-- Allocate an exception stack for the main program to use.
-- We make sure that the stack has maximum alignment. Some systems require
-- this (e.g. Sun), and in any case it is a good idea for efficiency.
NT_Exc_Stack : array (0 .. 8192) of aliased Character; NT_Exc_Stack : array (0 .. 8192) of aliased Character;
for NT_Exc_Stack'Alignment use Standard'Maximum_Alignment; for NT_Exc_Stack'Alignment use Standard'Maximum_Alignment;
-- Allocate an exception stack for the main program to use.
-- This is currently only used under VMS.
NT_TSD : TSD; NT_TSD : TSD;
-- Note: we rely on the default initialization of NT_TSD.
-------------------- --------------------
-- Abort_Defer_NT -- -- Abort_Defer_NT --
...@@ -116,10 +116,6 @@ package body System.Soft_Links is ...@@ -116,10 +116,6 @@ package body System.Soft_Links is
SST.SS_Init SST.SS_Init
(New_TSD.Sec_Stack_Addr, SST.Default_Secondary_Stack_Size); (New_TSD.Sec_Stack_Addr, SST.Default_Secondary_Stack_Size);
end if; end if;
New_TSD.Machine_State_Addr :=
System.Address
(System.Machine_State_Operations.Allocate_Machine_State);
end Create_TSD; end Create_TSD;
----------------------- -----------------------
...@@ -138,8 +134,6 @@ package body System.Soft_Links is ...@@ -138,8 +134,6 @@ package body System.Soft_Links is
procedure Destroy_TSD (Old_TSD : in out TSD) is procedure Destroy_TSD (Old_TSD : in out TSD) is
begin begin
SST.SS_Free (Old_TSD.Sec_Stack_Addr); SST.SS_Free (Old_TSD.Sec_Stack_Addr);
System.Machine_State_Operations.Free_Machine_State
(Machine_State (Old_TSD.Machine_State_Addr));
end Destroy_TSD; end Destroy_TSD;
--------------------- ---------------------
...@@ -166,14 +160,14 @@ package body System.Soft_Links is ...@@ -166,14 +160,14 @@ package body System.Soft_Links is
function Get_Exc_Stack_Addr_NT return Address is function Get_Exc_Stack_Addr_NT return Address is
begin begin
return NT_TSD.Exc_Stack_Addr; return NT_Exc_Stack (NT_Exc_Stack'Last)'Address;
end Get_Exc_Stack_Addr_NT; end Get_Exc_Stack_Addr_NT;
----------------------------- -----------------------------
-- Get_Exc_Stack_Addr_Soft -- -- Get_Exc_Stack_Addr_Soft --
----------------------------- -----------------------------
function Get_Exc_Stack_Addr_Soft return Address is function Get_Exc_Stack_Addr_Soft return Address is
begin begin
return Get_Exc_Stack_Addr.all; return Get_Exc_Stack_Addr.all;
end Get_Exc_Stack_Addr_Soft; end Get_Exc_Stack_Addr_Soft;
...@@ -205,24 +199,6 @@ package body System.Soft_Links is ...@@ -205,24 +199,6 @@ package body System.Soft_Links is
return Get_Jmpbuf_Address.all; return Get_Jmpbuf_Address.all;
end Get_Jmpbuf_Address_Soft; end Get_Jmpbuf_Address_Soft;
-------------------------------
-- Get_Machine_State_Addr_NT --
-------------------------------
function Get_Machine_State_Addr_NT return Address is
begin
return NT_TSD.Machine_State_Addr;
end Get_Machine_State_Addr_NT;
---------------------------------
-- Get_Machine_State_Addr_Soft --
---------------------------------
function Get_Machine_State_Addr_Soft return Address is
begin
return Get_Machine_State_Addr.all;
end Get_Machine_State_Addr_Soft;
--------------------------- ---------------------------
-- Get_Sec_Stack_Addr_NT -- -- Get_Sec_Stack_Addr_NT --
--------------------------- ---------------------------
...@@ -260,26 +236,6 @@ package body System.Soft_Links is ...@@ -260,26 +236,6 @@ package body System.Soft_Links is
end Null_Adafinal; end Null_Adafinal;
--------------------------- ---------------------------
-- Set_Exc_Stack_Addr_NT --
---------------------------
procedure Set_Exc_Stack_Addr_NT (Self_ID : Address; Addr : Address) is
pragma Warnings (Off, Self_ID);
begin
NT_TSD.Exc_Stack_Addr := Addr;
end Set_Exc_Stack_Addr_NT;
-----------------------------
-- Set_Exc_Stack_Addr_Soft --
-----------------------------
procedure Set_Exc_Stack_Addr_Soft (Self_ID : Address; Addr : Address) is
begin
Set_Exc_Stack_Addr (Self_ID, Addr);
end Set_Exc_Stack_Addr_Soft;
---------------------------
-- Set_Jmpbuf_Address_NT -- -- Set_Jmpbuf_Address_NT --
--------------------------- ---------------------------
...@@ -293,24 +249,6 @@ package body System.Soft_Links is ...@@ -293,24 +249,6 @@ package body System.Soft_Links is
Set_Jmpbuf_Address (Addr); Set_Jmpbuf_Address (Addr);
end Set_Jmpbuf_Address_Soft; end Set_Jmpbuf_Address_Soft;
-------------------------------
-- Set_Machine_State_Addr_NT --
-------------------------------
procedure Set_Machine_State_Addr_NT (Addr : Address) is
begin
NT_TSD.Machine_State_Addr := Addr;
end Set_Machine_State_Addr_NT;
---------------------------------
-- Set_Machine_State_Addr_Soft --
---------------------------------
procedure Set_Machine_State_Addr_Soft (Addr : Address) is
begin
Set_Machine_State_Addr (Addr);
end Set_Machine_State_Addr_Soft;
--------------------------- ---------------------------
-- Set_Sec_Stack_Addr_NT -- -- Set_Sec_Stack_Addr_NT --
--------------------------- ---------------------------
...@@ -365,13 +303,4 @@ package body System.Soft_Links is ...@@ -365,13 +303,4 @@ package body System.Soft_Links is
return "main_task"; return "main_task";
end Task_Name_NT; end Task_Name_NT;
-------------------------
-- Package Elaboration --
-------------------------
begin
NT_TSD.Exc_Stack_Addr := NT_Exc_Stack (8192)'Address;
Ada.Exceptions.Save_Occurrence
(NT_TSD.Current_Excep, Ada.Exceptions.Null_Occurrence);
end System.Soft_Links; end System.Soft_Links;
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- This package contains a set of subprogram access variables that access -- This package contains a set of subprogram access variables that access
-- some low-level primitives that are called different depending wether -- some low-level primitives that are called different depending whether
-- tasking is involved or not (e.g. the Get/Set_Jmpbuf_Address that needs -- tasking is involved or not (e.g. the Get/Set_Jmpbuf_Address that needs
-- to provide a different value for each task). To avoid dragging in the -- to provide a different value for each task). To avoid dragging in the
-- tasking all the time, we use a system of soft links where the links are -- tasking all the time, we use a system of soft links where the links are
...@@ -43,7 +43,9 @@ with Ada.Exceptions; ...@@ -43,7 +43,9 @@ with Ada.Exceptions;
with System.Stack_Checking; with System.Stack_Checking;
package System.Soft_Links is package System.Soft_Links is
pragma Elaborate_Body; pragma Warnings (Off);
pragma Preelaborate_05;
pragma Warnings (On);
subtype EOA is Ada.Exceptions.Exception_Occurrence_Access; subtype EOA is Ada.Exceptions.Exception_Occurrence_Access;
subtype EO is Ada.Exceptions.Exception_Occurrence; subtype EO is Ada.Exceptions.Exception_Occurrence;
...@@ -210,21 +212,8 @@ package System.Soft_Links is ...@@ -210,21 +212,8 @@ package System.Soft_Links is
Get_Sec_Stack_Addr : Get_Address_Call := Get_Sec_Stack_Addr_NT'Access; Get_Sec_Stack_Addr : Get_Address_Call := Get_Sec_Stack_Addr_NT'Access;
Set_Sec_Stack_Addr : Set_Address_Call := Set_Sec_Stack_Addr_NT'Access; Set_Sec_Stack_Addr : Set_Address_Call := Set_Sec_Stack_Addr_NT'Access;
function Get_Machine_State_Addr_NT return Address; function Get_Exc_Stack_Addr_NT return Address;
procedure Set_Machine_State_Addr_NT (Addr : Address);
Get_Machine_State_Addr : Get_Address_Call
:= Get_Machine_State_Addr_NT'Access;
Set_Machine_State_Addr : Set_Address_Call
:= Set_Machine_State_Addr_NT'Access;
function Get_Exc_Stack_Addr_NT return Address;
procedure Set_Exc_Stack_Addr_NT (Self_ID : Address; Addr : Address);
-- Self_ID is a Task_Id, but in the non-tasking case there is no
-- Task_Id type available, so make do with Address.
Get_Exc_Stack_Addr : Get_Address_Call := Get_Exc_Stack_Addr_NT'Access; Get_Exc_Stack_Addr : Get_Address_Call := Get_Exc_Stack_Addr_NT'Access;
Set_Exc_Stack_Addr : Set_Address_Call2 := Set_Exc_Stack_Addr_NT'Access;
function Get_Current_Excep_NT return EOA; function Get_Current_Excep_NT return EOA;
...@@ -302,24 +291,18 @@ package System.Soft_Links is ...@@ -302,24 +291,18 @@ package System.Soft_Links is
-- to the tasks requested stack size before the task can do -- to the tasks requested stack size before the task can do
-- its first stack check. -- its first stack check.
Jmpbuf_Address : Address := Null_Address; pragma Warnings (Off);
Jmpbuf_Address : System.Address := System.Null_Address;
-- Address of jump buffer used to store the address of the -- Address of jump buffer used to store the address of the
-- current longjmp/setjmp buffer for exception management. -- current longjmp/setjmp buffer for exception management.
-- These buffers are threaded into a stack, and the address -- These buffers are threaded into a stack, and the address
-- here is the top of the stack. A null address means that -- here is the top of the stack. A null address means that
-- no exception handler is currently active. -- no exception handler is currently active.
Sec_Stack_Addr : Address := Null_Address; Sec_Stack_Addr : System.Address := System.Null_Address;
pragma Warnings (On);
-- Address of currently allocated secondary stack -- Address of currently allocated secondary stack
Exc_Stack_Addr : Address := Null_Address;
-- Address of a task-specific stack used for the propagation of
-- exceptions in response to synchronous faults. This alternate
-- stack is necessary when propagating Storage_Error resulting
-- from a stack overflow, as the task's primary stack is full.
-- This is currently only used on the SGI, and this value stays
-- null on other platforms.
Current_Excep : aliased EO; Current_Excep : aliased EO;
-- Exception occurrence that contains the information for the -- Exception occurrence that contains the information for the
-- current exception. Note that any exception in the same task -- current exception. Note that any exception in the same task
...@@ -328,9 +311,6 @@ package System.Soft_Links is ...@@ -328,9 +311,6 @@ package System.Soft_Links is
-- --
-- Also act as a list of the active exceptions in the case of the GCC -- Also act as a list of the active exceptions in the case of the GCC
-- exception mechanism, organized as a stack with the most recent first. -- exception mechanism, organized as a stack with the most recent first.
Machine_State_Addr : Address := Null_Address;
-- Machine state address. Used by front-end zero cost exception
end record; end record;
procedure Create_TSD (New_TSD : in out TSD); procedure Create_TSD (New_TSD : in out TSD);
...@@ -340,7 +320,7 @@ package System.Soft_Links is ...@@ -340,7 +320,7 @@ package System.Soft_Links is
procedure Destroy_TSD (Old_TSD : in out TSD); procedure Destroy_TSD (Old_TSD : in out TSD);
pragma Inline (Destroy_TSD); pragma Inline (Destroy_TSD);
-- Called from s-tassta just before a thread is destroyed to perform -- Called from s-tassta just before a thread is destroyed to perform
-- any required finalization. -- any required finalization.
function Get_GNAT_Exception return Ada.Exceptions.Exception_Id; function Get_GNAT_Exception return Ada.Exceptions.Exception_Id;
...@@ -364,14 +344,6 @@ package System.Soft_Links is ...@@ -364,14 +344,6 @@ package System.Soft_Links is
pragma Inline (Get_Sec_Stack_Addr_Soft); pragma Inline (Get_Sec_Stack_Addr_Soft);
pragma Inline (Set_Sec_Stack_Addr_Soft); pragma Inline (Set_Sec_Stack_Addr_Soft);
function Get_Exc_Stack_Addr_Soft return Address; function Get_Exc_Stack_Addr_Soft return Address;
procedure Set_Exc_Stack_Addr_Soft (Self_ID : Address; Addr : Address);
pragma Inline (Get_Exc_Stack_Addr_Soft);
pragma Inline (Set_Exc_Stack_Addr_Soft);
function Get_Machine_State_Addr_Soft return Address;
procedure Set_Machine_State_Addr_Soft (Addr : Address);
pragma Inline (Get_Machine_State_Addr_Soft);
pragma Inline (Set_Machine_State_Addr_Soft);
end System.Soft_Links; end System.Soft_Links;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2004, Free Software Foundation, Inc. -- -- Copyright (C) 2004-2005, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -47,9 +47,6 @@ with System.Task_Primitives.Operations; ...@@ -47,9 +47,6 @@ with System.Task_Primitives.Operations;
with System.Tasking; with System.Tasking;
-- Used for Task_Id -- Used for Task_Id
with Ada.Exceptions;
-- Used for Raise_Exception
package body System.Soft_Links.Tasking is package body System.Soft_Links.Tasking is
package STPO renames System.Task_Primitives.Operations; package STPO renames System.Task_Primitives.Operations;
...@@ -75,10 +72,6 @@ package body System.Soft_Links.Tasking is ...@@ -75,10 +72,6 @@ package body System.Soft_Links.Tasking is
procedure Set_Sec_Stack_Addr (Addr : Address); procedure Set_Sec_Stack_Addr (Addr : Address);
-- Get/Set location of current task's secondary stack -- Get/Set location of current task's secondary stack
function Get_Machine_State_Addr return Address;
procedure Set_Machine_State_Addr (Addr : Address);
-- Get/Set the address for storing the current task's machine state
function Get_Current_Excep return SSL.EOA; function Get_Current_Excep return SSL.EOA;
-- Task-safe version of SSL.Get_Current_Excep -- Task-safe version of SSL.Get_Current_Excep
...@@ -99,11 +92,6 @@ package body System.Soft_Links.Tasking is ...@@ -99,11 +92,6 @@ package body System.Soft_Links.Tasking is
return STPO.Self.Common.Compiler_Data.Jmpbuf_Address; return STPO.Self.Common.Compiler_Data.Jmpbuf_Address;
end Get_Jmpbuf_Address; end Get_Jmpbuf_Address;
function Get_Machine_State_Addr return Address is
begin
return STPO.Self.Common.Compiler_Data.Machine_State_Addr;
end Get_Machine_State_Addr;
function Get_Sec_Stack_Addr return Address is function Get_Sec_Stack_Addr return Address is
begin begin
return STPO.Self.Common.Compiler_Data.Sec_Stack_Addr; return STPO.Self.Common.Compiler_Data.Sec_Stack_Addr;
...@@ -118,11 +106,6 @@ package body System.Soft_Links.Tasking is ...@@ -118,11 +106,6 @@ package body System.Soft_Links.Tasking is
STPO.Self.Common.Compiler_Data.Jmpbuf_Address := Addr; STPO.Self.Common.Compiler_Data.Jmpbuf_Address := Addr;
end Set_Jmpbuf_Address; end Set_Jmpbuf_Address;
procedure Set_Machine_State_Addr (Addr : Address) is
begin
STPO.Self.Common.Compiler_Data.Machine_State_Addr := Addr;
end Set_Machine_State_Addr;
procedure Set_Sec_Stack_Addr (Addr : Address) is procedure Set_Sec_Stack_Addr (Addr : Address) is
begin begin
STPO.Self.Common.Compiler_Data.Sec_Stack_Addr := Addr; STPO.Self.Common.Compiler_Data.Sec_Stack_Addr := Addr;
...@@ -143,12 +126,12 @@ package body System.Soft_Links.Tasking is ...@@ -143,12 +126,12 @@ package body System.Soft_Links.Tasking is
if System.Tasking.Detect_Blocking if System.Tasking.Detect_Blocking
and then Self_Id.Common.Protected_Action_Nesting > 0 and then Self_Id.Common.Protected_Action_Nesting > 0
then then
Ada.Exceptions.Raise_Exception raise Program_Error with "potentially blocking operation";
(Program_Error'Identity, "potentially blocking operation");
else else
Abort_Defer.all;
STPO.Timed_Delay (Self_Id, Time, Mode); STPO.Timed_Delay (Self_Id, Time, Mode);
Abort_Undefer.all;
end if; end if;
end Timed_Delay_T; end Timed_Delay_T;
----------------------------- -----------------------------
...@@ -172,8 +155,6 @@ package body System.Soft_Links.Tasking is ...@@ -172,8 +155,6 @@ package body System.Soft_Links.Tasking is
SSL.Set_Jmpbuf_Address := Set_Jmpbuf_Address'Access; SSL.Set_Jmpbuf_Address := Set_Jmpbuf_Address'Access;
SSL.Get_Sec_Stack_Addr := Get_Sec_Stack_Addr'Access; SSL.Get_Sec_Stack_Addr := Get_Sec_Stack_Addr'Access;
SSL.Set_Sec_Stack_Addr := Set_Sec_Stack_Addr'Access; SSL.Set_Sec_Stack_Addr := Set_Sec_Stack_Addr'Access;
SSL.Get_Machine_State_Addr := Get_Machine_State_Addr'Access;
SSL.Set_Machine_State_Addr := Set_Machine_State_Addr'Access;
SSL.Get_Current_Excep := Get_Current_Excep'Access; SSL.Get_Current_Excep := Get_Current_Excep'Access;
SSL.Timed_Delay := Timed_Delay_T'Access; SSL.Timed_Delay := Timed_Delay_T'Access;
...@@ -182,7 +163,6 @@ package body System.Soft_Links.Tasking is ...@@ -182,7 +163,6 @@ package body System.Soft_Links.Tasking is
SSL.Set_Sec_Stack_Addr (SSL.Get_Sec_Stack_Addr_NT); SSL.Set_Sec_Stack_Addr (SSL.Get_Sec_Stack_Addr_NT);
SSL.Set_Jmpbuf_Address (SSL.Get_Jmpbuf_Address_NT); SSL.Set_Jmpbuf_Address (SSL.Get_Jmpbuf_Address_NT);
SSL.Set_Machine_State_Addr (SSL.Get_Machine_State_Addr_NT);
end if; end if;
end Init_Tasking_Soft_Links; end Init_Tasking_Soft_Links;
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
with System.Storage_Elements; with System.Storage_Elements;
package System.Stack_Checking is package System.Stack_Checking is
pragma Preelaborate;
pragma Elaborate_Body; pragma Elaborate_Body;
-- This unit has a junk null body. The reason is that historically we -- This unit has a junk null body. The reason is that historically we
-- used to have a real body, and it causes bootstrapping path problems -- used to have a real body, and it causes bootstrapping path problems
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2004 Free Software Foundation, Inc. -- -- Copyright (C) 1992-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -54,11 +54,9 @@ with System; ...@@ -54,11 +54,9 @@ with System;
with Unchecked_Conversion; with Unchecked_Conversion;
package System.Standard_Library is package System.Standard_Library is
pragma Warnings (Off);
pragma Suppress (All_Checks); pragma Preelaborate_05;
-- Suppress explicitely all the checks to work around the Solaris linker pragma Warnings (On);
-- bug when using gnatmake -f -a (but without -gnatp). This is not needed
-- with Solaris 2.6, so eventually can be removed ???
type Big_String_Ptr is access all String (Positive); type Big_String_Ptr is access all String (Positive);
-- A non-fat pointer type for null terminated strings -- A non-fat pointer type for null terminated strings
...@@ -137,8 +135,9 @@ package System.Standard_Library is ...@@ -137,8 +135,9 @@ package System.Standard_Library is
Name_Length : Natural; Name_Length : Natural;
-- Length of fully expanded name of exception -- Length of fully expanded name of exception
Full_Name : Big_String_Ptr; Full_Name : System.Address;
-- Fully expanded name of exception, null terminated -- Fully expanded name of exception, null terminated
-- You can use To_Ptr to convert this to a string.
HTable_Ptr : Exception_Data_Ptr; HTable_Ptr : Exception_Data_Ptr;
-- Hash table pointer used to link entries together in the hash table -- Hash table pointer used to link entries together in the hash table
...@@ -157,7 +156,6 @@ package System.Standard_Library is ...@@ -157,7 +156,6 @@ package System.Standard_Library is
-- whenever the exception is raised. This call occurs immediately, -- whenever the exception is raised. This call occurs immediately,
-- before any other actions taken by the raise (and in particular -- before any other actions taken by the raise (and in particular
-- before any unwinding of the stack occurs). -- before any unwinding of the stack occurs).
end record; end record;
-- Definitions for standard predefined exceptions defined in Standard, -- Definitions for standard predefined exceptions defined in Standard,
...@@ -179,7 +177,7 @@ package System.Standard_Library is ...@@ -179,7 +177,7 @@ package System.Standard_Library is
(Not_Handled_By_Others => False, (Not_Handled_By_Others => False,
Lang => 'A', Lang => 'A',
Name_Length => Constraint_Error_Name'Length, Name_Length => Constraint_Error_Name'Length,
Full_Name => To_Ptr (Constraint_Error_Name'Address), Full_Name => Constraint_Error_Name'Address,
HTable_Ptr => null, HTable_Ptr => null,
Import_Code => 0, Import_Code => 0,
Raise_Hook => null); Raise_Hook => null);
...@@ -188,7 +186,7 @@ package System.Standard_Library is ...@@ -188,7 +186,7 @@ package System.Standard_Library is
(Not_Handled_By_Others => False, (Not_Handled_By_Others => False,
Lang => 'A', Lang => 'A',
Name_Length => Numeric_Error_Name'Length, Name_Length => Numeric_Error_Name'Length,
Full_Name => To_Ptr (Numeric_Error_Name'Address), Full_Name => Numeric_Error_Name'Address,
HTable_Ptr => null, HTable_Ptr => null,
Import_Code => 0, Import_Code => 0,
Raise_Hook => null); Raise_Hook => null);
...@@ -197,7 +195,7 @@ package System.Standard_Library is ...@@ -197,7 +195,7 @@ package System.Standard_Library is
(Not_Handled_By_Others => False, (Not_Handled_By_Others => False,
Lang => 'A', Lang => 'A',
Name_Length => Program_Error_Name'Length, Name_Length => Program_Error_Name'Length,
Full_Name => To_Ptr (Program_Error_Name'Address), Full_Name => Program_Error_Name'Address,
HTable_Ptr => null, HTable_Ptr => null,
Import_Code => 0, Import_Code => 0,
Raise_Hook => null); Raise_Hook => null);
...@@ -206,7 +204,7 @@ package System.Standard_Library is ...@@ -206,7 +204,7 @@ package System.Standard_Library is
(Not_Handled_By_Others => False, (Not_Handled_By_Others => False,
Lang => 'A', Lang => 'A',
Name_Length => Storage_Error_Name'Length, Name_Length => Storage_Error_Name'Length,
Full_Name => To_Ptr (Storage_Error_Name'Address), Full_Name => Storage_Error_Name'Address,
HTable_Ptr => null, HTable_Ptr => null,
Import_Code => 0, Import_Code => 0,
Raise_Hook => null); Raise_Hook => null);
...@@ -215,7 +213,7 @@ package System.Standard_Library is ...@@ -215,7 +213,7 @@ package System.Standard_Library is
(Not_Handled_By_Others => False, (Not_Handled_By_Others => False,
Lang => 'A', Lang => 'A',
Name_Length => Tasking_Error_Name'Length, Name_Length => Tasking_Error_Name'Length,
Full_Name => To_Ptr (Tasking_Error_Name'Address), Full_Name => Tasking_Error_Name'Address,
HTable_Ptr => null, HTable_Ptr => null,
Import_Code => 0, Import_Code => 0,
Raise_Hook => null); Raise_Hook => null);
...@@ -224,7 +222,7 @@ package System.Standard_Library is ...@@ -224,7 +222,7 @@ package System.Standard_Library is
(Not_Handled_By_Others => True, (Not_Handled_By_Others => True,
Lang => 'A', Lang => 'A',
Name_Length => Abort_Signal_Name'Length, Name_Length => Abort_Signal_Name'Length,
Full_Name => To_Ptr (Abort_Signal_Name'Address), Full_Name => Abort_Signal_Name'Address,
HTable_Ptr => null, HTable_Ptr => null,
Import_Code => 0, Import_Code => 0,
Raise_Hook => null); Raise_Hook => null);
......
...@@ -241,7 +241,9 @@ package body System.Tasking.Protected_Objects is ...@@ -241,7 +241,9 @@ package body System.Tasking.Protected_Objects is
end Unlock; end Unlock;
begin begin
-- Ensure that tasking soft links are set when using protected objects -- Ensure that tasking is initialized, as well as tasking soft links
-- when using protected objects.
Tasking.Initialize;
System.Soft_Links.Tasking.Init_Tasking_Soft_Links; System.Soft_Links.Tasking.Init_Tasking_Soft_Links;
end System.Tasking.Protected_Objects; end System.Tasking.Protected_Objects;
...@@ -40,10 +40,6 @@ pragma Polling (Off); ...@@ -40,10 +40,6 @@ pragma Polling (Off);
-- Turn off polling, we do not want ATC polling to take place during -- Turn off polling, we do not want ATC polling to take place during
-- tasking operations. It causes infinite loops and other problems. -- tasking operations. It causes infinite loops and other problems.
with System.Tasking;
-- used for Ada_Task_Control_Block
-- Task_Id
with System.Error_Reporting; with System.Error_Reporting;
-- used for Shutdown -- used for Shutdown
...@@ -55,9 +51,6 @@ package body System.Task_Primitives.Operations is ...@@ -55,9 +51,6 @@ package body System.Task_Primitives.Operations is
pragma Warnings (Off); pragma Warnings (Off);
-- Turn off warnings since so many unreferenced parameters -- Turn off warnings since so many unreferenced parameters
No_Tasking : Boolean;
-- Comment required here ???
---------------- ----------------
-- Abort_Task -- -- Abort_Task --
---------------- ----------------
...@@ -193,8 +186,11 @@ package body System.Task_Primitives.Operations is ...@@ -193,8 +186,11 @@ package body System.Task_Primitives.Operations is
---------------- ----------------
procedure Initialize (Environment_Task : Task_Id) is procedure Initialize (Environment_Task : Task_Id) is
No_Tasking : Boolean;
begin begin
null; No_Tasking :=
System.Error_Reporting.Shutdown
("Tasking not implemented on this configuration");
end Initialize; end Initialize;
procedure Initialize (S : in out Suspension_Object) is procedure Initialize (S : in out Suspension_Object) is
...@@ -479,11 +475,4 @@ package body System.Task_Primitives.Operations is ...@@ -479,11 +475,4 @@ package body System.Task_Primitives.Operations is
null; null;
end Yield; end Yield;
begin
-- Can't raise an exception because target independent packages try to
-- do an Abort_Defer, which gets a memory fault.
No_Tasking :=
System.Error_Reporting.Shutdown
("Tasking not implemented on this configuration");
end System.Task_Primitives.Operations; end System.Task_Primitives.Operations;
...@@ -43,41 +43,32 @@ pragma Polling (Off); ...@@ -43,41 +43,32 @@ pragma Polling (Off);
with System.Tasking.Debug; with System.Tasking.Debug;
-- used for Known_Tasks -- used for Known_Tasks
with Interfaces.C;
-- used for int
-- size_t
with System.Interrupt_Management; with System.Interrupt_Management;
-- used for Keep_Unmasked -- used for Keep_Unmasked
-- Abort_Task_Interrupt -- Abort_Task_Interrupt
-- Interrupt_ID -- Interrupt_ID
pragma Warnings (Off);
with System.Interrupt_Management.Operations; with System.Interrupt_Management.Operations;
-- used for Set_Interrupt_Mask -- used for Set_Interrupt_Mask
-- All_Tasks_Mask -- All_Tasks_Mask
pragma Elaborate_All (System.Interrupt_Management.Operations); pragma Elaborate_All (System.Interrupt_Management.Operations);
pragma Warnings (On);
with System.OS_Primitives;
-- used for Delay_Modes
with Interfaces.C;
-- used for int
-- size_t
with System.Parameters; with System.Parameters;
-- used for Size_Type -- used for Size_Type
with System.Task_Primitives.Interrupt_Operations; with System.Task_Primitives.Interrupt_Operations;
-- used for Get_Interrupt_ID -- used for Get_Interrupt_ID
with System.Tasking;
-- used for Ada_Task_Control_Block
-- Task_Id
with System.Soft_Links;
-- used for Defer/Undefer_Abort
-- Note that we do not use System.Tasking.Initialization directly since
-- this is a higher level package that we shouldn't depend on. For example
-- when using the restricted run time, it is replaced by
-- System.Tasking.Restricted.Stages.
with System.OS_Primitives;
-- used for Delay_Modes
with Unchecked_Conversion; with Unchecked_Conversion;
with Unchecked_Deallocation; with Unchecked_Deallocation;
...@@ -91,7 +82,6 @@ package body System.Task_Primitives.Operations is ...@@ -91,7 +82,6 @@ package body System.Task_Primitives.Operations is
use System.OS_Primitives; use System.OS_Primitives;
package PIO renames System.Task_Primitives.Interrupt_Operations; package PIO renames System.Task_Primitives.Interrupt_Operations;
package SSL renames System.Soft_Links;
---------------- ----------------
-- Local Data -- -- Local Data --
...@@ -124,9 +114,6 @@ package body System.Task_Primitives.Operations is ...@@ -124,9 +114,6 @@ package body System.Task_Primitives.Operations is
-- is not implemented for DCE threads. The HPUX 10 port is at this -- is not implemented for DCE threads. The HPUX 10 port is at this
-- stage considered dead, and no further work is planned on it. -- stage considered dead, and no further work is planned on it.
FIFO_Within_Priorities : constant Boolean := Dispatching_Policy = 'F';
-- Indicates whether FIFO_Within_Priorities is set
Foreign_Task_Elaborated : aliased Boolean := True; Foreign_Task_Elaborated : aliased Boolean := True;
-- Used to identified fake tasks (i.e., non-Ada Threads) -- Used to identified fake tasks (i.e., non-Ada Threads)
...@@ -495,11 +482,6 @@ package body System.Task_Primitives.Operations is ...@@ -495,11 +482,6 @@ package body System.Task_Primitives.Operations is
Result : Interfaces.C.int; Result : Interfaces.C.int;
begin begin
-- The little window between deferring abort and locking Self_ID is the
-- only reason to check for pending abort and priority change below!
SSL.Abort_Defer.all;
if Single_Lock then if Single_Lock then
Lock_RTS; Lock_RTS;
end if; end if;
...@@ -550,7 +532,6 @@ package body System.Task_Primitives.Operations is ...@@ -550,7 +532,6 @@ package body System.Task_Primitives.Operations is
end if; end if;
Result := sched_yield; Result := sched_yield;
SSL.Abort_Undefer.all;
end Timed_Delay; end Timed_Delay;
--------------------- ---------------------
...@@ -632,7 +613,7 @@ package body System.Task_Primitives.Operations is ...@@ -632,7 +613,7 @@ package body System.Task_Primitives.Operations is
Result := pthread_setschedparam Result := pthread_setschedparam
(T.Common.LL.Thread, SCHED_RR, Param'Access); (T.Common.LL.Thread, SCHED_RR, Param'Access);
elsif FIFO_Within_Priorities or else Time_Slice_Val = 0 then elsif Dispatching_Policy = 'F' or else Time_Slice_Val = 0 then
Result := pthread_setschedparam Result := pthread_setschedparam
(T.Common.LL.Thread, SCHED_FIFO, Param'Access); (T.Common.LL.Thread, SCHED_FIFO, Param'Access);
...@@ -643,7 +624,7 @@ package body System.Task_Primitives.Operations is ...@@ -643,7 +624,7 @@ package body System.Task_Primitives.Operations is
pragma Assert (Result = 0); pragma Assert (Result = 0);
if FIFO_Within_Priorities then if Dispatching_Policy = 'F' then
-- Annex D requirement [RM D.2.2 par. 9]: -- Annex D requirement [RM D.2.2 par. 9]:
-- If the task drops its priority due to the loss of inherited -- If the task drops its priority due to the loss of inherited
...@@ -1162,6 +1143,8 @@ package body System.Task_Primitives.Operations is ...@@ -1162,6 +1143,8 @@ package body System.Task_Primitives.Operations is
begin begin
Environment_Task_Id := Environment_Task; Environment_Task_Id := Environment_Task;
Interrupt_Management.Initialize;
-- Initialize the lock used to synchronize chain of all ATCBs -- Initialize the lock used to synchronize chain of all ATCBs
Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
......
...@@ -47,20 +47,19 @@ with Interfaces.C; ...@@ -47,20 +47,19 @@ with Interfaces.C;
with System.Tasking.Debug; with System.Tasking.Debug;
-- used for Known_Tasks -- used for Known_Tasks
with System.Task_Info;
with System.Interrupt_Management; with System.Interrupt_Management;
-- used for Keep_Unmasked -- used for Keep_Unmasked
-- Abort_Task_Interrupt -- Abort_Task_Interrupt
-- Interrupt_ID -- Interrupt_ID
with System.OS_Primitives;
-- used for Delay_Modes
with System.Task_Info;
with System.Parameters; with System.Parameters;
-- used for Size_Type -- used for Size_Type
with System.Tasking;
-- used for Ada_Task_Control_Block
-- Task_Id
with System.Program_Info; with System.Program_Info;
-- used for Default_Task_Stack -- used for Default_Task_Stack
-- Default_Time_Slice -- Default_Time_Slice
...@@ -68,17 +67,6 @@ with System.Program_Info; ...@@ -68,17 +67,6 @@ with System.Program_Info;
-- Pthread_Sched_Signal -- Pthread_Sched_Signal
-- Pthread_Arena_Size -- Pthread_Arena_Size
with System.Soft_Links;
-- used for Defer/Undefer_Abort
-- Note that we do not use System.Tasking.Initialization directly since
-- this is a higher level package that we shouldn't depend on. For example
-- when using the restricted run time, it is replaced by
-- System.Tasking.Restricted.Stages.
with System.OS_Primitives;
-- used for Delay_Modes
with System.Storage_Elements; with System.Storage_Elements;
-- used for To_Address -- used for To_Address
...@@ -94,8 +82,6 @@ package body System.Task_Primitives.Operations is ...@@ -94,8 +82,6 @@ package body System.Task_Primitives.Operations is
use System.Parameters; use System.Parameters;
use System.OS_Primitives; use System.OS_Primitives;
package SSL renames System.Soft_Links;
----------------- -----------------
-- Local Data -- -- Local Data --
----------------- -----------------
...@@ -433,12 +419,6 @@ package body System.Task_Primitives.Operations is ...@@ -433,12 +419,6 @@ package body System.Task_Primitives.Operations is
Result : Interfaces.C.int; Result : Interfaces.C.int;
begin begin
-- Only the little window between deferring abort and
-- locking Self_ID is the reason we need to
-- check for pending abort and priority change below!
SSL.Abort_Defer.all;
if Single_Lock then if Single_Lock then
Lock_RTS; Lock_RTS;
end if; end if;
...@@ -490,7 +470,6 @@ package body System.Task_Primitives.Operations is ...@@ -490,7 +470,6 @@ package body System.Task_Primitives.Operations is
end if; end if;
pthread_yield; pthread_yield;
SSL.Abort_Undefer.all;
end Timed_Delay; end Timed_Delay;
--------------------- ---------------------
...@@ -819,7 +798,7 @@ package body System.Task_Primitives.Operations is ...@@ -819,7 +798,7 @@ package body System.Task_Primitives.Operations is
pragma Assert (Result = 0); pragma Assert (Result = 0);
end Abort_Task; end Abort_Task;
---------------- ----------------
-- Initialize -- -- Initialize --
---------------- ----------------
...@@ -1087,7 +1066,9 @@ package body System.Task_Primitives.Operations is ...@@ -1087,7 +1066,9 @@ package body System.Task_Primitives.Operations is
procedure Initialize (Environment_Task : Task_Id) is procedure Initialize (Environment_Task : Task_Id) is
begin begin
Initialize_Athread_Library;
Environment_Task_Id := Environment_Task; Environment_Task_Id := Environment_Task;
Interrupt_Management.Initialize;
Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
-- Initialize the lock used to synchronize chain of all ATCBs. -- Initialize the lock used to synchronize chain of all ATCBs.
...@@ -1126,8 +1107,4 @@ package body System.Task_Primitives.Operations is ...@@ -1126,8 +1107,4 @@ package body System.Task_Primitives.Operations is
end if; end if;
end Initialize_Athread_Library; end Initialize_Athread_Library;
-- Package initialization
begin
Initialize_Athread_Library;
end System.Task_Primitives.Operations; end System.Task_Primitives.Operations;
...@@ -49,28 +49,19 @@ with System.Task_Info; ...@@ -49,28 +49,19 @@ with System.Task_Info;
with System.Tasking.Debug; with System.Tasking.Debug;
-- used for Known_Tasks -- used for Known_Tasks
with System.IO;
-- used for Put_Line
with System.Interrupt_Management; with System.Interrupt_Management;
-- used for Keep_Unmasked -- used for Keep_Unmasked
-- Abort_Task_Interrupt -- Abort_Task_Interrupt
-- Interrupt_ID -- Interrupt_ID
with System.Parameters; with System.OS_Primitives;
-- used for Size_Type -- used for Delay_Modes
with System.Tasking;
-- used for Ada_Task_Control_Block
-- Task_Id
with System.Soft_Links; with System.IO;
-- used for Defer/Undefer_Abort -- used for Put_Line
-- Note that we do not use System.Tasking.Initialization directly since with System.Parameters;
-- this is a higher level package that we shouldn't depend on. For example -- used for Size_Type
-- when using the restricted run time, it is replaced by
-- System.Tasking.Restricted.Stages.
with System.Program_Info; with System.Program_Info;
-- used for Default_Task_Stack -- used for Default_Task_Stack
...@@ -82,9 +73,6 @@ with System.Program_Info; ...@@ -82,9 +73,6 @@ with System.Program_Info;
with System.OS_Interface; with System.OS_Interface;
-- used for various type, constant, and operations -- used for various type, constant, and operations
with System.OS_Primitives;
-- used for Delay_Modes
with Unchecked_Conversion; with Unchecked_Conversion;
with Unchecked_Deallocation; with Unchecked_Deallocation;
...@@ -97,8 +85,6 @@ package body System.Task_Primitives.Operations is ...@@ -97,8 +85,6 @@ package body System.Task_Primitives.Operations is
use System.OS_Primitives; use System.OS_Primitives;
use System.Parameters; use System.Parameters;
package SSL renames System.Soft_Links;
---------------- ----------------
-- Local Data -- -- Local Data --
---------------- ----------------
...@@ -515,12 +501,6 @@ package body System.Task_Primitives.Operations is ...@@ -515,12 +501,6 @@ package body System.Task_Primitives.Operations is
Result : Interfaces.C.int; Result : Interfaces.C.int;
begin begin
-- The little window between deferring abort and locking Self_ID is
-- the only reason we need to check for pending abort and priority
-- change below!
SSL.Abort_Defer.all;
if Single_Lock then if Single_Lock then
Lock_RTS; Lock_RTS;
end if; end if;
...@@ -565,7 +545,6 @@ package body System.Task_Primitives.Operations is ...@@ -565,7 +545,6 @@ package body System.Task_Primitives.Operations is
end if; end if;
Yield; Yield;
SSL.Abort_Undefer.all;
end Timed_Delay; end Timed_Delay;
--------------------- ---------------------
...@@ -1243,6 +1222,8 @@ package body System.Task_Primitives.Operations is ...@@ -1243,6 +1222,8 @@ package body System.Task_Primitives.Operations is
begin begin
Environment_Task_Id := Environment_Task; Environment_Task_Id := Environment_Task;
Interrupt_Management.Initialize;
-- Initialize the lock used to synchronize chain of all ATCBs. -- Initialize the lock used to synchronize chain of all ATCBs.
Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
...@@ -1251,6 +1232,18 @@ package body System.Task_Primitives.Operations is ...@@ -1251,6 +1232,18 @@ package body System.Task_Primitives.Operations is
Enter_Task (Environment_Task); Enter_Task (Environment_Task);
-- Prepare the set of signals that should unblocked in all tasks
Result := sigemptyset (Unblocked_Signal_Mask'Access);
pragma Assert (Result = 0);
for J in Interrupt_Management.Interrupt_ID loop
if System.Interrupt_Management.Keep_Unmasked (J) then
Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J));
pragma Assert (Result = 0);
end if;
end loop;
-- Install the abort-signal handler -- Install the abort-signal handler
if State (System.Interrupt_Management.Abort_Task_Interrupt) if State (System.Interrupt_Management.Abort_Task_Interrupt)
...@@ -1272,30 +1265,4 @@ package body System.Task_Primitives.Operations is ...@@ -1272,30 +1265,4 @@ package body System.Task_Primitives.Operations is
end if; end if;
end Initialize; end Initialize;
begin
declare
Result : Interfaces.C.int;
begin
-- Prepare the set of signals that should unblocked in all tasks
Result := sigemptyset (Unblocked_Signal_Mask'Access);
pragma Assert (Result = 0);
for J in Interrupt_Management.Interrupt_ID loop
if System.Interrupt_Management.Keep_Unmasked (J) then
Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J));
pragma Assert (Result = 0);
end if;
end loop;
-- Pick the highest resolution Clock for Clock_Realtime
-- ??? This code currently doesn't work (see c94007[ab] for example)
-- if syssgi (SGI_CYCLECNTR_SIZE) = 64 then
-- Real_Time_Clock_Id := CLOCK_SGI_CYCLE;
-- else
-- Real_Time_Clock_Id := CLOCK_REALTIME;
-- end if;
end;
end System.Task_Primitives.Operations; end System.Task_Primitives.Operations;
...@@ -40,44 +40,32 @@ pragma Polling (Off); ...@@ -40,44 +40,32 @@ pragma Polling (Off);
-- Turn off polling, we do not want ATC polling to take place during -- Turn off polling, we do not want ATC polling to take place during
-- tasking operations. It causes infinite loops and other problems. -- tasking operations. It causes infinite loops and other problems.
with System.Tasking.Debug;
-- used for Known_Tasks
with Interfaces.C; with Interfaces.C;
-- used for int -- used for int
-- size_t -- size_t
with System.Parameters;
-- used for Size_Type
with System.Tasking.Debug;
-- used for Known_Tasks
with System.Interrupt_Management; with System.Interrupt_Management;
-- used for Keep_Unmasked -- used for Keep_Unmasked
-- Abort_Task_Interrupt -- Abort_Task_Interrupt
-- Interrupt_ID -- Interrupt_ID
with System.Parameters; with System.OS_Primitives;
-- used for Size_Type -- used for Delay_Modes
with System.Tasking; with System.Soft_Links;
-- used for Ada_Task_Control_Block -- used for Abort_Defer/Undefer
-- Task_Id
with Ada.Exceptions; with Ada.Exceptions;
-- used for Raise_Exception -- used for Raise_Exception
-- Raise_From_Signal_Handler -- Raise_From_Signal_Handler
-- Exception_Id -- Exception_Id
with System.Soft_Links;
-- used for Defer/Undefer_Abort
-- Note that we do not use System.Tasking.Initialization directly since
-- this is a higher level package that we shouldn't depend on. For example
-- when using the restricted run time, it is replaced by
-- System.Tasking.Restricted.Stages.
with System.OS_Primitives;
-- used for Delay_Modes
with System.Soft_Links;
-- used for Abort_Defer/Undefer
with Unchecked_Conversion; with Unchecked_Conversion;
with Unchecked_Deallocation; with Unchecked_Deallocation;
...@@ -90,8 +78,6 @@ package body System.Task_Primitives.Operations is ...@@ -90,8 +78,6 @@ package body System.Task_Primitives.Operations is
use System.Parameters; use System.Parameters;
use System.OS_Primitives; use System.OS_Primitives;
package SSL renames System.Soft_Links;
---------------- ----------------
-- Local Data -- -- Local Data --
---------------- ----------------
...@@ -111,12 +97,10 @@ package body System.Task_Primitives.Operations is ...@@ -111,12 +97,10 @@ package body System.Task_Primitives.Operations is
-- A variable to hold Task_Id for the environment task -- A variable to hold Task_Id for the environment task
Unblocked_Signal_Mask : aliased sigset_t; Unblocked_Signal_Mask : aliased sigset_t;
-- The set of signals that should unblocked in all tasks -- The set of signals that should be unblocked in all tasks
-- The followings are internal configuration constants needed -- The followings are internal configuration constants needed
Priority_Ceiling_Emulation : constant Boolean := True;
Next_Serial_Number : Task_Serial_Number := 100; Next_Serial_Number : Task_Serial_Number := 100;
-- We start at 100, to reserve some special values for -- We start at 100, to reserve some special values for
-- using in error checking. -- using in error checking.
...@@ -127,9 +111,6 @@ package body System.Task_Primitives.Operations is ...@@ -127,9 +111,6 @@ package body System.Task_Primitives.Operations is
Dispatching_Policy : Character; Dispatching_Policy : Character;
pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy"); pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy");
FIFO_Within_Priorities : constant Boolean := Dispatching_Policy = 'F';
-- Indicates whether FIFO_Within_Priorities is set
-- The following are effectively constants, but they need to -- The following are effectively constants, but they need to
-- be initialized by calling a pthread_ function. -- be initialized by calling a pthread_ function.
...@@ -280,14 +261,11 @@ package body System.Task_Primitives.Operations is ...@@ -280,14 +261,11 @@ package body System.Task_Primitives.Operations is
(Prio : System.Any_Priority; (Prio : System.Any_Priority;
L : access Lock) L : access Lock)
is is
Result : Interfaces.C.int; pragma Unreferenced (Prio);
Result : Interfaces.C.int;
begin begin
if Priority_Ceiling_Emulation then Result := pthread_mutex_init (L, Mutex_Attr'Access);
L.Ceiling := Prio;
end if;
Result := pthread_mutex_init (L.L'Access, Mutex_Attr'Access);
pragma Assert (Result = 0 or else Result = ENOMEM); pragma Assert (Result = 0 or else Result = ENOMEM);
...@@ -319,7 +297,7 @@ package body System.Task_Primitives.Operations is ...@@ -319,7 +297,7 @@ package body System.Task_Primitives.Operations is
procedure Finalize_Lock (L : access Lock) is procedure Finalize_Lock (L : access Lock) is
Result : Interfaces.C.int; Result : Interfaces.C.int;
begin begin
Result := pthread_mutex_destroy (L.L'Access); Result := pthread_mutex_destroy (L);
pragma Assert (Result = 0); pragma Assert (Result = 0);
end Finalize_Lock; end Finalize_Lock;
...@@ -336,37 +314,13 @@ package body System.Task_Primitives.Operations is ...@@ -336,37 +314,13 @@ package body System.Task_Primitives.Operations is
procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is
Result : Interfaces.C.int; Result : Interfaces.C.int;
begin begin
if Priority_Ceiling_Emulation then Result := pthread_mutex_lock (L);
declare Ceiling_Violation := Result = EINVAL;
Self_ID : constant Task_Id := Self;
begin
if Self_ID.Common.LL.Active_Priority > L.Ceiling then
Ceiling_Violation := True;
return;
end if;
L.Saved_Priority := Self_ID.Common.LL.Active_Priority;
if Self_ID.Common.LL.Active_Priority < L.Ceiling then -- Assume the cause of EINVAL is a priority ceiling violation
Self_ID.Common.LL.Active_Priority := L.Ceiling;
end if;
Result := pthread_mutex_lock (L.L'Access);
pragma Assert (Result = 0);
Ceiling_Violation := False;
end;
else
Result := pthread_mutex_lock (L.L'Access);
Ceiling_Violation := Result = EINVAL;
-- Assume the cause of EINVAL is a priority ceiling violation
pragma Assert (Result = 0 or else Result = EINVAL); pragma Assert (Result = 0 or else Result = EINVAL);
end if;
end Write_Lock; end Write_Lock;
procedure Write_Lock procedure Write_Lock
...@@ -405,25 +359,9 @@ package body System.Task_Primitives.Operations is ...@@ -405,25 +359,9 @@ package body System.Task_Primitives.Operations is
procedure Unlock (L : access Lock) is procedure Unlock (L : access Lock) is
Result : Interfaces.C.int; Result : Interfaces.C.int;
begin begin
if Priority_Ceiling_Emulation then Result := pthread_mutex_unlock (L);
declare pragma Assert (Result = 0);
Self_ID : constant Task_Id := Self;
begin
Result := pthread_mutex_unlock (L.L'Access);
pragma Assert (Result = 0);
if Self_ID.Common.LL.Active_Priority > L.Saved_Priority then
Self_ID.Common.LL.Active_Priority := L.Saved_Priority;
end if;
end;
else
Result := pthread_mutex_unlock (L.L'Access);
pragma Assert (Result = 0);
end if;
end Unlock; end Unlock;
procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is
...@@ -553,14 +491,8 @@ package body System.Task_Primitives.Operations is ...@@ -553,14 +491,8 @@ package body System.Task_Primitives.Operations is
Abs_Time : Duration; Abs_Time : Duration;
Request : aliased timespec; Request : aliased timespec;
Result : Interfaces.C.int; Result : Interfaces.C.int;
begin
-- Only the little window between deferring abort and
-- locking Self_ID is the reason we need to
-- check for pending abort and priority change below! :(
SSL.Abort_Defer.all;
begin
if Single_Lock then if Single_Lock then
Lock_RTS; Lock_RTS;
end if; end if;
...@@ -611,7 +543,6 @@ package body System.Task_Primitives.Operations is ...@@ -611,7 +543,6 @@ package body System.Task_Primitives.Operations is
end if; end if;
Result := sched_yield; Result := sched_yield;
SSL.Abort_Undefer.all;
end Timed_Delay; end Timed_Delay;
--------------------- ---------------------
...@@ -678,12 +609,6 @@ package body System.Task_Primitives.Operations is ...@@ -678,12 +609,6 @@ package body System.Task_Primitives.Operations is
begin begin
T.Common.Current_Priority := Prio; T.Common.Current_Priority := Prio;
if Priority_Ceiling_Emulation then
if T.Common.LL.Active_Priority < Prio then
T.Common.LL.Active_Priority := Prio;
end if;
end if;
-- Priorities are in range 1 .. 99 on GNU/Linux, so we map -- Priorities are in range 1 .. 99 on GNU/Linux, so we map
-- map 0 .. 31 to 1 .. 32 -- map 0 .. 31 to 1 .. 32
...@@ -693,7 +618,7 @@ package body System.Task_Primitives.Operations is ...@@ -693,7 +618,7 @@ package body System.Task_Primitives.Operations is
Result := pthread_setschedparam Result := pthread_setschedparam
(T.Common.LL.Thread, SCHED_RR, Param'Access); (T.Common.LL.Thread, SCHED_RR, Param'Access);
elsif FIFO_Within_Priorities or else Time_Slice_Val = 0 then elsif Dispatching_Policy = 'F' or else Time_Slice_Val = 0 then
Result := pthread_setschedparam Result := pthread_setschedparam
(T.Common.LL.Thread, SCHED_FIFO, Param'Access); (T.Common.LL.Thread, SCHED_FIFO, Param'Access);
...@@ -1167,6 +1092,26 @@ package body System.Task_Primitives.Operations is ...@@ -1167,6 +1092,26 @@ package body System.Task_Primitives.Operations is
begin begin
Environment_Task_Id := Environment_Task; Environment_Task_Id := Environment_Task;
Interrupt_Management.Initialize;
-- Prepare the set of signals that should be unblocked in all tasks
Result := sigemptyset (Unblocked_Signal_Mask'Access);
pragma Assert (Result = 0);
for J in Interrupt_Management.Interrupt_ID loop
if System.Interrupt_Management.Keep_Unmasked (J) then
Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J));
pragma Assert (Result = 0);
end if;
end loop;
Result := pthread_mutexattr_init (Mutex_Attr'Access);
pragma Assert (Result = 0);
Result := pthread_condattr_init (Cond_Attr'Access);
pragma Assert (Result = 0);
Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
-- Initialize the global RTS lock -- Initialize the global RTS lock
...@@ -1196,26 +1141,4 @@ package body System.Task_Primitives.Operations is ...@@ -1196,26 +1141,4 @@ package body System.Task_Primitives.Operations is
end if; end if;
end Initialize; end Initialize;
begin
declare
Result : Interfaces.C.int;
begin
-- Prepare the set of signals that should unblocked in all tasks
Result := sigemptyset (Unblocked_Signal_Mask'Access);
pragma Assert (Result = 0);
for J in Interrupt_Management.Interrupt_ID loop
if System.Interrupt_Management.Keep_Unmasked (J) then
Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J));
pragma Assert (Result = 0);
end if;
end loop;
Result := pthread_mutexattr_init (Mutex_Attr'Access);
pragma Assert (Result = 0);
Result := pthread_condattr_init (Cond_Attr'Access);
pragma Assert (Result = 0);
end;
end System.Task_Primitives.Operations; end System.Task_Primitives.Operations;
...@@ -44,6 +44,14 @@ pragma Polling (Off); ...@@ -44,6 +44,14 @@ pragma Polling (Off);
with System.Tasking.Debug; with System.Tasking.Debug;
-- used for Known_Tasks -- used for Known_Tasks
with System.Interrupt_Management;
-- used for Keep_Unmasked
-- Abort_Task_Interrupt
-- Interrupt_ID
with System.OS_Primitives;
-- used for Delay_Modes
with System.Task_Info; with System.Task_Info;
-- used for Task_Info_Type -- used for Task_Info_Type
...@@ -51,29 +59,9 @@ with Interfaces.C; ...@@ -51,29 +59,9 @@ with Interfaces.C;
-- used for int -- used for int
-- size_t -- size_t
with System.Interrupt_Management;
-- used for Keep_Unmasked
-- Abort_Task_Interrupt
-- Interrupt_ID
with System.Parameters; with System.Parameters;
-- used for Size_Type -- used for Size_Type
with System.Tasking;
-- used for Ada_Task_Control_Block
-- Task_Id
with System.Soft_Links;
-- used for Defer/Undefer_Abort
-- Note that we do not use System.Tasking.Initialization directly since
-- this is a higher level package that we shouldn't depend on. For example
-- when using the restricted run time, it is replaced by
-- System.Tasking.Restricted.Stages.
with System.OS_Primitives;
-- used for Delay_Modes
with Unchecked_Deallocation; with Unchecked_Deallocation;
package body System.Task_Primitives.Operations is package body System.Task_Primitives.Operations is
...@@ -85,8 +73,6 @@ package body System.Task_Primitives.Operations is ...@@ -85,8 +73,6 @@ package body System.Task_Primitives.Operations is
use System.Parameters; use System.Parameters;
use System.OS_Primitives; use System.OS_Primitives;
package SSL renames System.Soft_Links;
---------------- ----------------
-- Local Data -- -- Local Data --
---------------- ----------------
...@@ -127,9 +113,6 @@ package body System.Task_Primitives.Operations is ...@@ -127,9 +113,6 @@ package body System.Task_Primitives.Operations is
Dispatching_Policy : Character; Dispatching_Policy : Character;
pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy"); pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy");
FIFO_Within_Priorities : constant Boolean := Dispatching_Policy = 'F';
-- Indicates whether FIFO_Within_Priorities is set
Foreign_Task_Elaborated : aliased Boolean := True; Foreign_Task_Elaborated : aliased Boolean := True;
-- Used to identified fake tasks (i.e., non-Ada Threads) -- Used to identified fake tasks (i.e., non-Ada Threads)
...@@ -560,12 +543,6 @@ package body System.Task_Primitives.Operations is ...@@ -560,12 +543,6 @@ package body System.Task_Primitives.Operations is
Result : Interfaces.C.int; Result : Interfaces.C.int;
begin begin
-- Only the little window between deferring abort and
-- locking Self_ID is the reason we need to
-- check for pending abort and priority change below!
SSL.Abort_Defer.all;
if Single_Lock then if Single_Lock then
Lock_RTS; Lock_RTS;
end if; end if;
...@@ -632,7 +609,6 @@ package body System.Task_Primitives.Operations is ...@@ -632,7 +609,6 @@ package body System.Task_Primitives.Operations is
end if; end if;
Result := sched_yield; Result := sched_yield;
SSL.Abort_Undefer.all;
end Timed_Delay; end Timed_Delay;
--------------------- ---------------------
...@@ -703,7 +679,7 @@ package body System.Task_Primitives.Operations is ...@@ -703,7 +679,7 @@ package body System.Task_Primitives.Operations is
Result := pthread_setschedparam Result := pthread_setschedparam
(T.Common.LL.Thread, SCHED_RR, Param'Access); (T.Common.LL.Thread, SCHED_RR, Param'Access);
elsif FIFO_Within_Priorities or else Time_Slice_Val = 0 then elsif Dispatching_Policy = 'F' or else Time_Slice_Val = 0 then
Result := pthread_setschedparam Result := pthread_setschedparam
(T.Common.LL.Thread, SCHED_FIFO, Param'Access); (T.Common.LL.Thread, SCHED_FIFO, Param'Access);
...@@ -1302,6 +1278,20 @@ package body System.Task_Primitives.Operations is ...@@ -1302,6 +1278,20 @@ package body System.Task_Primitives.Operations is
begin begin
Environment_Task_Id := Environment_Task; Environment_Task_Id := Environment_Task;
Interrupt_Management.Initialize;
-- Prepare the set of signals that should unblocked in all tasks
Result := sigemptyset (Unblocked_Signal_Mask'Access);
pragma Assert (Result = 0);
for J in Interrupt_Management.Interrupt_ID loop
if System.Interrupt_Management.Keep_Unmasked (J) then
Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J));
pragma Assert (Result = 0);
end if;
end loop;
-- Initialize the lock used to synchronize chain of all ATCBs -- Initialize the lock used to synchronize chain of all ATCBs
Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
...@@ -1332,20 +1322,4 @@ package body System.Task_Primitives.Operations is ...@@ -1332,20 +1322,4 @@ package body System.Task_Primitives.Operations is
end if; end if;
end Initialize; end Initialize;
begin
declare
Result : Interfaces.C.int;
begin
-- Prepare the set of signals that should unblocked in all tasks
Result := sigemptyset (Unblocked_Signal_Mask'Access);
pragma Assert (Result = 0);
for J in Interrupt_Management.Interrupt_ID loop
if System.Interrupt_Management.Keep_Unmasked (J) then
Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J));
pragma Assert (Result = 0);
end if;
end loop;
end;
end System.Task_Primitives.Operations; end System.Task_Primitives.Operations;
...@@ -43,6 +43,9 @@ pragma Polling (Off); ...@@ -43,6 +43,9 @@ pragma Polling (Off);
with System.Tasking.Debug; with System.Tasking.Debug;
-- used for Known_Tasks -- used for Known_Tasks
with System.OS_Primitives;
-- used for Delay_Modes
with Interfaces.C; with Interfaces.C;
-- used for int -- used for int
-- size_t -- size_t
...@@ -56,22 +59,6 @@ with System.OS_Interface; ...@@ -56,22 +59,6 @@ with System.OS_Interface;
with System.Parameters; with System.Parameters;
-- used for Size_Type -- used for Size_Type
with System.Tasking;
-- used for Ada_Task_Control_Block
-- Task_Id
with System.Soft_Links;
-- used for Defer/Undefer_Abort
-- to initialize TSD for a C thread, in function Self
-- Note that we do not use System.Tasking.Initialization directly since
-- this is a higher level package that we shouldn't depend on. For example
-- when using the restricted run time, it is replaced by
-- System.Tasking.Restricted.Stages.
with System.OS_Primitives;
-- used for Delay_Modes
with System.Task_Info; with System.Task_Info;
-- used for Unspecified_Task_Info -- used for Unspecified_Task_Info
...@@ -92,8 +79,6 @@ package body System.Task_Primitives.Operations is ...@@ -92,8 +79,6 @@ package body System.Task_Primitives.Operations is
-- permit to have more than 30 tasks running at the same time. Note that -- permit to have more than 30 tasks running at the same time. Note that
-- we set the stack size for non tasking programs on System unit. -- we set the stack size for non tasking programs on System unit.
package SSL renames System.Soft_Links;
---------------- ----------------
-- Local Data -- -- Local Data --
---------------- ----------------
...@@ -112,9 +97,6 @@ package body System.Task_Primitives.Operations is ...@@ -112,9 +97,6 @@ package body System.Task_Primitives.Operations is
Dispatching_Policy : Character; Dispatching_Policy : Character;
pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy"); pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy");
FIFO_Within_Priorities : constant Boolean := Dispatching_Policy = 'F';
-- Indicates whether FIFO_Within_Priorities is set
Foreign_Task_Elaborated : aliased Boolean := True; Foreign_Task_Elaborated : aliased Boolean := True;
-- Used to identified fake tasks (i.e., non-Ada Threads) -- Used to identified fake tasks (i.e., non-Ada Threads)
...@@ -595,12 +577,6 @@ package body System.Task_Primitives.Operations is ...@@ -595,12 +577,6 @@ package body System.Task_Primitives.Operations is
Timedout : Boolean; Timedout : Boolean;
begin begin
-- Only the little window between deferring abort and
-- locking Self_ID is the reason we need to
-- check for pending abort and priority change below!
SSL.Abort_Defer.all;
if Single_Lock then if Single_Lock then
Lock_RTS; Lock_RTS;
end if; end if;
...@@ -651,7 +627,6 @@ package body System.Task_Primitives.Operations is ...@@ -651,7 +627,6 @@ package body System.Task_Primitives.Operations is
end if; end if;
Yield; Yield;
SSL.Abort_Undefer.all;
end Timed_Delay; end Timed_Delay;
------------ ------------
...@@ -702,7 +677,7 @@ package body System.Task_Primitives.Operations is ...@@ -702,7 +677,7 @@ package body System.Task_Primitives.Operations is
(T.Common.LL.Thread, Interfaces.C.int (Underlying_Priorities (Prio))); (T.Common.LL.Thread, Interfaces.C.int (Underlying_Priorities (Prio)));
pragma Assert (Res = True); pragma Assert (Res = True);
if FIFO_Within_Priorities then if Dispatching_Policy = 'F' then
-- Annex D requirement [RM D.2.2 par. 9]: -- Annex D requirement [RM D.2.2 par. 9]:
-- If the task drops its priority due to the loss of inherited -- If the task drops its priority due to the loss of inherited
...@@ -883,7 +858,7 @@ package body System.Task_Primitives.Operations is ...@@ -883,7 +858,7 @@ package body System.Task_Primitives.Operations is
Set_Priority (T, Priority); Set_Priority (T, Priority);
if Time_Slice_Val = 0 or else FIFO_Within_Priorities then if Time_Slice_Val = 0 or else Dispatching_Policy = 'F' then
-- Here we need Annex E semantics so we disable the NT priority -- Here we need Annex E semantics so we disable the NT priority
-- boost. A priority boost is temporarily given by the system to a -- boost. A priority boost is temporarily given by the system to a
-- thread when it is taken out of a wait state. -- thread when it is taken out of a wait state.
...@@ -997,10 +972,11 @@ package body System.Task_Primitives.Operations is ...@@ -997,10 +972,11 @@ package body System.Task_Primitives.Operations is
begin begin
Environment_Task_Id := Environment_Task; Environment_Task_Id := Environment_Task;
OS_Primitives.Initialize;
if Time_Slice_Val = 0 or else FIFO_Within_Priorities then if Time_Slice_Val = 0 or else Dispatching_Policy = 'F' then
-- Here we need Annex E semantics, switch the current process to the -- Here we need Annex D semantics, switch the current process to the
-- High_Priority_Class. -- High_Priority_Class.
Discard := Discard :=
......
...@@ -43,37 +43,23 @@ pragma Polling (Off); ...@@ -43,37 +43,23 @@ pragma Polling (Off);
with System.Tasking.Debug; with System.Tasking.Debug;
-- used for Known_Tasks -- used for Known_Tasks
with Interfaces.C; with System.OS_Primitives;
-- used for size_t -- used for Delay_Modes
-- Clock
with Interfaces.C.Strings;
-- used for Null_Ptr
with Interfaces.OS2Lib.Errors; with Interfaces.OS2Lib.Errors;
with Interfaces.OS2Lib.Threads; with Interfaces.OS2Lib.Threads;
with Interfaces.OS2Lib.Synchronization; with Interfaces.OS2Lib.Synchronization;
with System.Parameters; with Interfaces.C;
-- used for Size_Type -- used for size_t
with System.Tasking; with Interfaces.C.Strings;
-- used for Task_Id -- used for Null_Ptr
with System.Parameters; with System.Parameters;
-- used for Size_Type -- used for Size_Type
with System.Soft_Links;
-- used for Defer/Undefer_Abort
-- Note that we do not use System.Tasking.Initialization directly since
-- this is a higher level package that we shouldn't depend on. For example
-- when using the restricted run time, it is replaced by
-- System.Tasking.Restricted.Stages.
with System.OS_Primitives;
-- used for Delay_Modes
-- Clock
with Unchecked_Conversion; with Unchecked_Conversion;
with Unchecked_Deallocation; with Unchecked_Deallocation;
...@@ -82,7 +68,6 @@ package body System.Task_Primitives.Operations is ...@@ -82,7 +68,6 @@ package body System.Task_Primitives.Operations is
package IC renames Interfaces.C; package IC renames Interfaces.C;
package ICS renames Interfaces.C.Strings; package ICS renames Interfaces.C.Strings;
package OSP renames System.OS_Primitives; package OSP renames System.OS_Primitives;
package SSL renames System.Soft_Links;
use Interfaces.OS2Lib; use Interfaces.OS2Lib;
use Interfaces.OS2Lib.Errors; use Interfaces.OS2Lib.Errors;
...@@ -599,12 +584,6 @@ package body System.Task_Primitives.Operations is ...@@ -599,12 +584,6 @@ package body System.Task_Primitives.Operations is
Count : aliased ULONG; -- Used to store dummy result Count : aliased ULONG; -- Used to store dummy result
begin begin
-- Only the little window between deferring abort and
-- locking Self_ID is the reason we need to
-- check for pending abort and priority change below! :(
SSL.Abort_Defer.all;
if Single_Lock then if Single_Lock then
Lock_RTS; Lock_RTS;
else else
...@@ -672,7 +651,6 @@ package body System.Task_Primitives.Operations is ...@@ -672,7 +651,6 @@ package body System.Task_Primitives.Operations is
end if; end if;
System.OS_Interface.Yield; System.OS_Interface.Yield;
SSL.Abort_Undefer.all;
end Timed_Delay; end Timed_Delay;
------------ ------------
...@@ -1244,6 +1222,20 @@ package body System.Task_Primitives.Operations is ...@@ -1244,6 +1222,20 @@ package body System.Task_Primitives.Operations is
begin begin
Environment_Task_Id := Environment_Task; Environment_Task_Id := Environment_Task;
OS_Primitives.Initialize;
-- Initialize pointer to task local data.
-- This is done once, for all tasks.
Must_Not_Fail (DosAllocThreadLocalMemory
((Thread_Local_Data'Size + 31) / 32, -- nr of 32-bit words
To_PPVOID (Thread_Local_Data_Ptr'Access)));
-- Initialize thread local data for main thread
Thread_Local_Data_Ptr.Self_ID := null;
Thread_Local_Data_Ptr.Lock_Prio_Level := 0;
Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
-- Initialize the lock used to synchronize chain of all ATCBs -- Initialize the lock used to synchronize chain of all ATCBs
...@@ -1279,16 +1271,4 @@ package body System.Task_Primitives.Operations is ...@@ -1279,16 +1271,4 @@ package body System.Task_Primitives.Operations is
-- initialization needed for the environment task. -- initialization needed for the environment task.
end Initialize; end Initialize;
begin
-- Initialize pointer to task local data.
-- This is done once, for all tasks.
Must_Not_Fail (DosAllocThreadLocalMemory
((Thread_Local_Data'Size + 31) / 32, -- nr of 32-bit words
To_PPVOID (Thread_Local_Data_Ptr'Access)));
-- Initialize thread local data for main thread
Thread_Local_Data_Ptr.Self_ID := null;
Thread_Local_Data_Ptr.Lock_Prio_Level := 0;
end System.Task_Primitives.Operations; end System.Task_Primitives.Operations;
...@@ -49,6 +49,14 @@ pragma Polling (Off); ...@@ -49,6 +49,14 @@ pragma Polling (Off);
with System.Tasking.Debug; with System.Tasking.Debug;
-- used for Known_Tasks -- used for Known_Tasks
with System.Interrupt_Management;
-- used for Keep_Unmasked
-- Abort_Task_Interrupt
-- Interrupt_ID
with System.OS_Primitives;
-- used for Delay_Modes
with System.Task_Info; with System.Task_Info;
-- used for Task_Info_Type -- used for Task_Info_Type
...@@ -56,29 +64,9 @@ with Interfaces.C; ...@@ -56,29 +64,9 @@ with Interfaces.C;
-- used for int -- used for int
-- size_t -- size_t
with System.Interrupt_Management;
-- used for Keep_Unmasked
-- Abort_Task_Interrupt
-- Interrupt_ID
with System.Parameters; with System.Parameters;
-- used for Size_Type -- used for Size_Type
with System.Tasking;
-- used for Ada_Task_Control_Block
-- Task_Id
with System.Soft_Links;
-- used for Defer/Undefer_Abort
-- Note that we do not use System.Tasking.Initialization directly since
-- this is a higher level package that we shouldn't depend on. For example
-- when using the restricted run time, it is replaced by
-- System.Tasking.Restricted.Stages.
with System.OS_Primitives;
-- used for Delay_Modes
with Unchecked_Conversion; with Unchecked_Conversion;
with Unchecked_Deallocation; with Unchecked_Deallocation;
...@@ -91,8 +79,6 @@ package body System.Task_Primitives.Operations is ...@@ -91,8 +79,6 @@ package body System.Task_Primitives.Operations is
use System.Parameters; use System.Parameters;
use System.OS_Primitives; use System.OS_Primitives;
package SSL renames System.Soft_Links;
---------------- ----------------
-- Local Data -- -- Local Data --
---------------- ----------------
...@@ -133,9 +119,6 @@ package body System.Task_Primitives.Operations is ...@@ -133,9 +119,6 @@ package body System.Task_Primitives.Operations is
Dispatching_Policy : Character; Dispatching_Policy : Character;
pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy"); pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy");
FIFO_Within_Priorities : constant Boolean := Dispatching_Policy = 'F';
-- Indicates whether FIFO_Within_Priorities is set.
Foreign_Task_Elaborated : aliased Boolean := True; Foreign_Task_Elaborated : aliased Boolean := True;
-- Used to identified fake tasks (i.e., non-Ada Threads). -- Used to identified fake tasks (i.e., non-Ada Threads).
...@@ -603,12 +586,6 @@ package body System.Task_Primitives.Operations is ...@@ -603,12 +586,6 @@ package body System.Task_Primitives.Operations is
Result : Interfaces.C.int; Result : Interfaces.C.int;
begin begin
-- Only the little window between deferring abort and
-- locking Self_ID is the reason we need to
-- check for pending abort and priority change below! :(
SSL.Abort_Defer.all;
if Single_Lock then if Single_Lock then
Lock_RTS; Lock_RTS;
end if; end if;
...@@ -673,7 +650,6 @@ package body System.Task_Primitives.Operations is ...@@ -673,7 +650,6 @@ package body System.Task_Primitives.Operations is
end if; end if;
Result := sched_yield; Result := sched_yield;
SSL.Abort_Undefer.all;
end Timed_Delay; end Timed_Delay;
--------------------- ---------------------
...@@ -746,7 +722,7 @@ package body System.Task_Primitives.Operations is ...@@ -746,7 +722,7 @@ package body System.Task_Primitives.Operations is
Result := pthread_setschedparam Result := pthread_setschedparam
(T.Common.LL.Thread, SCHED_RR, Param'Access); (T.Common.LL.Thread, SCHED_RR, Param'Access);
elsif FIFO_Within_Priorities or else Time_Slice_Val = 0 then elsif Dispatching_Policy = 'F' or else Time_Slice_Val = 0 then
Result := pthread_setschedparam Result := pthread_setschedparam
(T.Common.LL.Thread, SCHED_FIFO, Param'Access); (T.Common.LL.Thread, SCHED_FIFO, Param'Access);
...@@ -1038,7 +1014,7 @@ package body System.Task_Primitives.Operations is ...@@ -1038,7 +1014,7 @@ package body System.Task_Primitives.Operations is
pragma Assert (Result = 0); pragma Assert (Result = 0);
end Abort_Task; end Abort_Task;
---------------- ----------------
-- Initialize -- -- Initialize --
---------------- ----------------
...@@ -1323,6 +1299,20 @@ package body System.Task_Primitives.Operations is ...@@ -1323,6 +1299,20 @@ package body System.Task_Primitives.Operations is
begin begin
Environment_Task_Id := Environment_Task; Environment_Task_Id := Environment_Task;
Interrupt_Management.Initialize;
-- Prepare the set of signals that should unblocked in all tasks
Result := sigemptyset (Unblocked_Signal_Mask'Access);
pragma Assert (Result = 0);
for J in Interrupt_Management.Interrupt_ID loop
if System.Interrupt_Management.Keep_Unmasked (J) then
Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J));
pragma Assert (Result = 0);
end if;
end loop;
-- Initialize the lock used to synchronize chain of all ATCBs. -- Initialize the lock used to synchronize chain of all ATCBs.
Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
...@@ -1352,20 +1342,4 @@ package body System.Task_Primitives.Operations is ...@@ -1352,20 +1342,4 @@ package body System.Task_Primitives.Operations is
end if; end if;
end Initialize; end Initialize;
begin
declare
Result : Interfaces.C.int;
begin
-- Prepare the set of signals that should unblocked in all tasks
Result := sigemptyset (Unblocked_Signal_Mask'Access);
pragma Assert (Result = 0);
for J in Interrupt_Management.Interrupt_ID loop
if System.Interrupt_Management.Keep_Unmasked (J) then
Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J));
pragma Assert (Result = 0);
end if;
end loop;
end;
end System.Task_Primitives.Operations; end System.Task_Primitives.Operations;
...@@ -43,44 +43,30 @@ pragma Polling (Off); ...@@ -43,44 +43,30 @@ pragma Polling (Off);
with System.Tasking.Debug; with System.Tasking.Debug;
-- used for Known_Tasks -- used for Known_Tasks
with Ada.Exceptions; with System.Interrupt_Management;
-- used for Raise_Exception -- used for Keep_Unmasked
-- Abort_Task_Interrupt
-- Interrupt_ID
with System.OS_Primitives;
-- used for Delay_Modes
pragma Warnings (Off);
with GNAT.OS_Lib; with GNAT.OS_Lib;
-- used for String_Access, Getenv -- used for String_Access, Getenv
pragma Warnings (On);
with Interfaces.C; with Interfaces.C;
-- used for int -- used for int
-- size_t -- size_t
with System.Interrupt_Management;
-- used for Keep_Unmasked
-- Abort_Task_Interrupt
-- Interrupt_ID
with System.Parameters; with System.Parameters;
-- used for Size_Type -- used for Size_Type
with System.Tasking;
-- used for Ada_Task_Control_Block
-- Task_Id
-- ATCB components and types
with System.Task_Info; with System.Task_Info;
-- to initialize Task_Info for a C thread, in function Self -- to initialize Task_Info for a C thread, in function Self
with System.Soft_Links;
-- used for Defer/Undefer_Abort
-- to initialize TSD for a C thread, in function Self
-- Note that we do not use System.Tasking.Initialization directly since
-- this is a higher level package that we shouldn't depend on. For example
-- when using the restricted run time, it is replaced by
-- System.Tasking.Restricted.Stages.
with System.OS_Primitives;
-- used for Delay_Modes
with Unchecked_Deallocation; with Unchecked_Deallocation;
package body System.Task_Primitives.Operations is package body System.Task_Primitives.Operations is
...@@ -90,11 +76,8 @@ package body System.Task_Primitives.Operations is ...@@ -90,11 +76,8 @@ package body System.Task_Primitives.Operations is
use Interfaces.C; use Interfaces.C;
use System.OS_Interface; use System.OS_Interface;
use System.Parameters; use System.Parameters;
use Ada.Exceptions;
use System.OS_Primitives; use System.OS_Primitives;
package SSL renames System.Soft_Links;
---------------- ----------------
-- Local Data -- -- Local Data --
---------------- ----------------
...@@ -280,7 +263,6 @@ package body System.Task_Primitives.Operations is ...@@ -280,7 +263,6 @@ package body System.Task_Primitives.Operations is
Old_Set : aliased sigset_t; Old_Set : aliased sigset_t;
Result : Interfaces.C.int; Result : Interfaces.C.int;
pragma Unreferenced (Result);
begin begin
-- It is not safe to raise an exception when using ZCX and the GCC -- It is not safe to raise an exception when using ZCX and the GCC
...@@ -425,11 +407,73 @@ package body System.Task_Primitives.Operations is ...@@ -425,11 +407,73 @@ package body System.Task_Primitives.Operations is
begin begin
Environment_Task_Id := Environment_Task; Environment_Task_Id := Environment_Task;
-- This is done in Enter_Task, but this is too late for the Interrupt_Management.Initialize;
-- Prepare the set of signals that should unblocked in all tasks
Result := sigemptyset (Unblocked_Signal_Mask'Access);
pragma Assert (Result = 0);
for J in Interrupt_Management.Interrupt_ID loop
if System.Interrupt_Management.Keep_Unmasked (J) then
Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J));
pragma Assert (Result = 0);
end if;
end loop;
if Dispatching_Policy = 'F' then
declare
Result : Interfaces.C.long;
Class_Info : aliased struct_pcinfo;
Secs, Nsecs : Interfaces.C.long;
begin
-- If a pragma Time_Slice is specified, takes the value in account
if Time_Slice_Val > 0 then
-- Convert Time_Slice_Val (microseconds) into seconds and
-- nanoseconds
Secs := Time_Slice_Val / 1_000_000;
Nsecs := (Time_Slice_Val rem 1_000_000) * 1_000;
-- Otherwise, default to no time slicing (i.e run until blocked)
else
Secs := RT_TQINF;
Nsecs := RT_TQINF;
end if;
-- Get the real time class id.
Class_Info.pc_clname (1) := 'R';
Class_Info.pc_clname (2) := 'T';
Class_Info.pc_clname (3) := ASCII.NUL;
Result := priocntl (PC_VERSION, P_LWPID, P_MYID, PC_GETCID,
Class_Info'Address);
-- Request the real time class
Prio_Param.pc_cid := Class_Info.pc_cid;
Prio_Param.rt_pri := pri_t (Class_Info.rt_maxpri);
Prio_Param.rt_tqsecs := Secs;
Prio_Param.rt_tqnsecs := Nsecs;
Result := priocntl (PC_VERSION, P_LWPID, P_MYID, PC_SETPARMS,
Prio_Param'Address);
Using_Real_Time_Class := Result /= -1;
end;
end if;
Specific.Initialize (Environment_Task);
-- The following is done in Enter_Task, but this is too late for the
-- Environment Task, since we need to call Self in Check_Locks when -- Environment Task, since we need to call Self in Check_Locks when
-- the run time is compiled with assertions on. -- the run time is compiled with assertions on.
Specific.Initialize (Environment_Task); Specific.Set (Environment_Task);
-- Initialize the lock used to synchronize chain of all ATCBs. -- Initialize the lock used to synchronize chain of all ATCBs.
...@@ -496,7 +540,7 @@ package body System.Task_Primitives.Operations is ...@@ -496,7 +540,7 @@ package body System.Task_Primitives.Operations is
pragma Assert (Result = 0 or else Result = ENOMEM); pragma Assert (Result = 0 or else Result = ENOMEM);
if Result = ENOMEM then if Result = ENOMEM then
Raise_Exception (Storage_Error'Identity, "Failed to allocate a lock"); raise Storage_Error with "Failed to allocate a lock";
end if; end if;
end Initialize_Lock; end Initialize_Lock;
...@@ -513,7 +557,7 @@ package body System.Task_Primitives.Operations is ...@@ -513,7 +557,7 @@ package body System.Task_Primitives.Operations is
pragma Assert (Result = 0 or else Result = ENOMEM); pragma Assert (Result = 0 or else Result = ENOMEM);
if Result = ENOMEM then if Result = ENOMEM then
Raise_Exception (Storage_Error'Identity, "Failed to allocate a lock"); raise Storage_Error with "Failed to allocate a lock";
end if; end if;
end Initialize_Lock; end Initialize_Lock;
...@@ -1244,12 +1288,6 @@ package body System.Task_Primitives.Operations is ...@@ -1244,12 +1288,6 @@ package body System.Task_Primitives.Operations is
Yielded : Boolean := False; Yielded : Boolean := False;
begin begin
-- Only the little window between deferring abort and
-- locking Self_ID is the reason we need to
-- check for pending abort and priority change below!
SSL.Abort_Defer.all;
if Single_Lock then if Single_Lock then
Lock_RTS; Lock_RTS;
end if; end if;
...@@ -1310,8 +1348,6 @@ package body System.Task_Primitives.Operations is ...@@ -1310,8 +1348,6 @@ package body System.Task_Primitives.Operations is
if not Yielded then if not Yielded then
thr_yield; thr_yield;
end if; end if;
SSL.Abort_Undefer.all;
end Timed_Delay; end Timed_Delay;
------------ ------------
...@@ -1643,7 +1679,7 @@ package body System.Task_Primitives.Operations is ...@@ -1643,7 +1679,7 @@ package body System.Task_Primitives.Operations is
pragma Assert (Result = 0 or else Result = ENOMEM); pragma Assert (Result = 0 or else Result = ENOMEM);
if Result = ENOMEM then if Result = ENOMEM then
Raise_Exception (Storage_Error'Identity, "Failed to allocate a lock"); raise Storage_Error with "Failed to allocate a lock";
end if; end if;
-- Initialize internal condition variable -- Initialize internal condition variable
...@@ -1872,75 +1908,4 @@ package body System.Task_Primitives.Operations is ...@@ -1872,75 +1908,4 @@ package body System.Task_Primitives.Operations is
end if; end if;
end Resume_Task; end Resume_Task;
-- Package elaboration
begin
declare
Result : Interfaces.C.int;
begin
-- Prepare the set of signals that should unblocked in all tasks
Result := sigemptyset (Unblocked_Signal_Mask'Access);
pragma Assert (Result = 0);
for J in Interrupt_Management.Interrupt_ID loop
if System.Interrupt_Management.Keep_Unmasked (J) then
Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J));
pragma Assert (Result = 0);
end if;
end loop;
-- We need the following code to support automatic creation of fake
-- ATCB's for C threads that call the Ada run-time system, even if
-- we use a faster way of getting Self for real Ada tasks.
Result := thr_keycreate (ATCB_Key'Access, System.Null_Address);
pragma Assert (Result = 0);
end;
if Dispatching_Policy = 'F' then
declare
Result : Interfaces.C.long;
Class_Info : aliased struct_pcinfo;
Secs, Nsecs : Interfaces.C.long;
begin
-- If a pragma Time_Slice is specified, takes the value in account.
if Time_Slice_Val > 0 then
-- Convert Time_Slice_Val (microseconds) into seconds and
-- nanoseconds
Secs := Time_Slice_Val / 1_000_000;
Nsecs := (Time_Slice_Val rem 1_000_000) * 1_000;
-- Otherwise, default to no time slicing (i.e run until blocked)
else
Secs := RT_TQINF;
Nsecs := RT_TQINF;
end if;
-- Get the real time class id.
Class_Info.pc_clname (1) := 'R';
Class_Info.pc_clname (2) := 'T';
Class_Info.pc_clname (3) := ASCII.NUL;
Result := priocntl (PC_VERSION, P_LWPID, P_MYID, PC_GETCID,
Class_Info'Address);
-- Request the real time class
Prio_Param.pc_cid := Class_Info.pc_cid;
Prio_Param.rt_pri := pri_t (Class_Info.rt_maxpri);
Prio_Param.rt_tqsecs := Secs;
Prio_Param.rt_tqnsecs := Nsecs;
Result := priocntl (PC_VERSION, P_LWPID, P_MYID, PC_SETPARMS,
Prio_Param'Address);
Using_Real_Time_Class := Result /= -1;
end;
end if;
end System.Task_Primitives.Operations; end System.Task_Primitives.Operations;
...@@ -43,6 +43,14 @@ pragma Polling (Off); ...@@ -43,6 +43,14 @@ pragma Polling (Off);
with System.Tasking.Debug; with System.Tasking.Debug;
-- used for Known_Tasks -- used for Known_Tasks
with System.Interrupt_Management;
-- used for Keep_Unmasked
-- Abort_Task_Interrupt
-- Interrupt_ID
with System.OS_Primitives;
-- used for Delay_Modes
with System.Task_Info; with System.Task_Info;
-- used for Task_Info_Type -- used for Task_Info_Type
...@@ -53,30 +61,9 @@ with Interfaces.C; ...@@ -53,30 +61,9 @@ with Interfaces.C;
-- used for int -- used for int
-- size_t -- size_t
with System.Interrupt_Management;
-- used for Keep_Unmasked
-- Abort_Task_Interrupt
-- Interrupt_ID
with System.Parameters; with System.Parameters;
-- used for Size_Type -- used for Size_Type
with System.Tasking;
-- used for Ada_Task_Control_Block
-- Task_Id
-- ATCB components and types
with System.Soft_Links;
-- used for Defer/Undefer_Abort
-- Note that we do not use System.Tasking.Initialization directly since
-- this is a higher level package that we shouldn't depend on. For example
-- when using the restricted run time, it is replaced by
-- System.Tasking.Restricted.Stages.
with System.OS_Primitives;
-- used for Delay_Modes
with Unchecked_Deallocation; with Unchecked_Deallocation;
package body System.Task_Primitives.Operations is package body System.Task_Primitives.Operations is
...@@ -88,8 +75,6 @@ package body System.Task_Primitives.Operations is ...@@ -88,8 +75,6 @@ package body System.Task_Primitives.Operations is
use System.Parameters; use System.Parameters;
use System.OS_Primitives; use System.OS_Primitives;
package SSL renames System.Soft_Links;
---------------- ----------------
-- Local Data -- -- Local Data --
---------------- ----------------
...@@ -120,9 +105,6 @@ package body System.Task_Primitives.Operations is ...@@ -120,9 +105,6 @@ package body System.Task_Primitives.Operations is
Dispatching_Policy : Character; Dispatching_Policy : Character;
pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy"); pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy");
FIFO_Within_Priorities : constant Boolean := Dispatching_Policy = 'F';
-- Indicates whether FIFO_Within_Priorities is set
Curpid : pid_t; Curpid : pid_t;
Foreign_Task_Elaborated : aliased Boolean := True; Foreign_Task_Elaborated : aliased Boolean := True;
...@@ -527,12 +509,6 @@ package body System.Task_Primitives.Operations is ...@@ -527,12 +509,6 @@ package body System.Task_Primitives.Operations is
Result : Interfaces.C.int; Result : Interfaces.C.int;
begin begin
-- Only the little window between deferring abort and
-- locking Self_ID is the reason we need to
-- check for pending abort and priority change below! :(
SSL.Abort_Defer.all;
if Single_Lock then if Single_Lock then
Lock_RTS; Lock_RTS;
end if; end if;
...@@ -585,7 +561,6 @@ package body System.Task_Primitives.Operations is ...@@ -585,7 +561,6 @@ package body System.Task_Primitives.Operations is
end if; end if;
Yield; Yield;
SSL.Abort_Undefer.all;
end Timed_Delay; end Timed_Delay;
--------------------- ---------------------
...@@ -661,7 +636,7 @@ package body System.Task_Primitives.Operations is ...@@ -661,7 +636,7 @@ package body System.Task_Primitives.Operations is
Result := pthread_setschedparam Result := pthread_setschedparam
(T.Common.LL.Thread, SCHED_RR, Param'Access); (T.Common.LL.Thread, SCHED_RR, Param'Access);
elsif FIFO_Within_Priorities or else Time_Slice_Val = 0 then elsif Dispatching_Policy = 'F' or else Time_Slice_Val = 0 then
Result := pthread_setschedparam Result := pthread_setschedparam
(T.Common.LL.Thread, SCHED_FIFO, Param'Access); (T.Common.LL.Thread, SCHED_FIFO, Param'Access);
...@@ -846,7 +821,7 @@ package body System.Task_Primitives.Operations is ...@@ -846,7 +821,7 @@ package body System.Task_Primitives.Operations is
Result := pthread_attr_setschedpolicy Result := pthread_attr_setschedpolicy
(Attributes'Access, System.OS_Interface.SCHED_RR); (Attributes'Access, System.OS_Interface.SCHED_RR);
elsif FIFO_Within_Priorities or else Time_Slice_Val = 0 then elsif Dispatching_Policy = 'F' or else Time_Slice_Val = 0 then
Result := pthread_attr_setschedpolicy Result := pthread_attr_setschedpolicy
(Attributes'Access, System.OS_Interface.SCHED_FIFO); (Attributes'Access, System.OS_Interface.SCHED_FIFO);
...@@ -1240,6 +1215,22 @@ package body System.Task_Primitives.Operations is ...@@ -1240,6 +1215,22 @@ package body System.Task_Primitives.Operations is
begin begin
Environment_Task_Id := Environment_Task; Environment_Task_Id := Environment_Task;
Interrupt_Management.Initialize;
-- Prepare the set of signals that should unblocked in all tasks
Result := sigemptyset (Unblocked_Signal_Mask'Access);
pragma Assert (Result = 0);
for J in Interrupt_Management.Interrupt_ID loop
if System.Interrupt_Management.Keep_Unmasked (J) then
Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J));
pragma Assert (Result = 0);
end if;
end loop;
Curpid := getpid;
-- Initialize the lock used to synchronize chain of all ATCBs -- Initialize the lock used to synchronize chain of all ATCBs
Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
...@@ -1269,22 +1260,4 @@ package body System.Task_Primitives.Operations is ...@@ -1269,22 +1260,4 @@ package body System.Task_Primitives.Operations is
end if; end if;
end Initialize; end Initialize;
begin
declare
Result : Interfaces.C.int;
begin
-- Prepare the set of signals that should unblocked in all tasks
Result := sigemptyset (Unblocked_Signal_Mask'Access);
pragma Assert (Result = 0);
for J in Interrupt_Management.Interrupt_ID loop
if System.Interrupt_Management.Keep_Unmasked (J) then
Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J));
pragma Assert (Result = 0);
end if;
end loop;
end;
Curpid := getpid;
end System.Task_Primitives.Operations; end System.Task_Primitives.Operations;
...@@ -43,6 +43,9 @@ pragma Polling (Off); ...@@ -43,6 +43,9 @@ pragma Polling (Off);
with System.Tasking.Debug; with System.Tasking.Debug;
-- used for Known_Tasks -- used for Known_Tasks
with System.OS_Primitives;
-- used for Delay_Modes
with Interfaces.C; with Interfaces.C;
-- used for int -- used for int
-- size_t -- size_t
...@@ -50,21 +53,8 @@ with Interfaces.C; ...@@ -50,21 +53,8 @@ with Interfaces.C;
with System.Parameters; with System.Parameters;
-- used for Size_Type -- used for Size_Type
with System.Tasking;
-- used for Ada_Task_Control_Block
-- Task_Id
with System.Soft_Links; with System.Soft_Links;
-- used for Defer/Undefer_Abort -- used for Get_Exc_Stack_Addr
-- Set_Exc_Stack_Addr
-- Note that we do not use System.Tasking.Initialization directly since
-- this is a higher level package that we shouldn't depend on. For example
-- when using the restricted run time, it is replaced by
-- System.Tasking.Restricted.Stages.
with System.OS_Primitives;
-- used for Delay_Modes
with Unchecked_Conversion; with Unchecked_Conversion;
with Unchecked_Deallocation; with Unchecked_Deallocation;
...@@ -105,9 +95,6 @@ package body System.Task_Primitives.Operations is ...@@ -105,9 +95,6 @@ package body System.Task_Primitives.Operations is
Dispatching_Policy : Character; Dispatching_Policy : Character;
pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy"); pragma Import (C, Dispatching_Policy, "__gl_task_dispatching_policy");
FIFO_Within_Priorities : constant Boolean := Dispatching_Policy = 'F';
-- Indicates whether FIFO_Within_Priorities is set.
Foreign_Task_Elaborated : aliased Boolean := True; Foreign_Task_Elaborated : aliased Boolean := True;
-- Used to identified fake tasks (i.e., non-Ada Threads). -- Used to identified fake tasks (i.e., non-Ada Threads).
...@@ -156,6 +143,9 @@ package body System.Task_Primitives.Operations is ...@@ -156,6 +143,9 @@ package body System.Task_Primitives.Operations is
function To_Address is new Unchecked_Conversion (Task_Id, System.Address); function To_Address is new Unchecked_Conversion (Task_Id, System.Address);
function Get_Exc_Stack_Addr return Address;
-- Replace System.Soft_Links.Get_Exc_Stack_Addr_NT
procedure Timer_Sleep_AST (ID : Address); procedure Timer_Sleep_AST (ID : Address);
-- Signal the condition variable when AST fires. -- Signal the condition variable when AST fires.
...@@ -492,17 +482,12 @@ package body System.Task_Primitives.Operations is ...@@ -492,17 +482,12 @@ package body System.Task_Primitives.Operations is
Yielded : Boolean := False; Yielded : Boolean := False;
begin begin
-- Only the little window between deferring abort and
-- locking Self_ID is the reason we need to
-- check for pending abort and priority change below!
if Single_Lock then if Single_Lock then
Lock_RTS; Lock_RTS;
end if; end if;
-- More comments required in body below ??? -- More comments required in body below ???
SSL.Abort_Defer.all;
Write_Lock (Self_ID); Write_Lock (Self_ID);
if Time /= 0.0 or else Mode /= Relative then if Time /= 0.0 or else Mode /= Relative then
...@@ -562,8 +547,6 @@ package body System.Task_Primitives.Operations is ...@@ -562,8 +547,6 @@ package body System.Task_Primitives.Operations is
Result := sched_yield; Result := sched_yield;
pragma Assert (Result = 0); pragma Assert (Result = 0);
end if; end if;
SSL.Abort_Undefer.all;
end Timed_Delay; end Timed_Delay;
--------------------- ---------------------
...@@ -629,7 +612,7 @@ package body System.Task_Primitives.Operations is ...@@ -629,7 +612,7 @@ package body System.Task_Primitives.Operations is
Result := pthread_setschedparam Result := pthread_setschedparam
(T.Common.LL.Thread, SCHED_RR, Param'Access); (T.Common.LL.Thread, SCHED_RR, Param'Access);
elsif FIFO_Within_Priorities or else Time_Slice_Val = 0 then elsif Dispatching_Policy = 'F' or else Time_Slice_Val = 0 then
Result := pthread_setschedparam Result := pthread_setschedparam
(T.Common.LL.Thread, SCHED_FIFO, Param'Access); (T.Common.LL.Thread, SCHED_FIFO, Param'Access);
...@@ -749,9 +732,6 @@ package body System.Task_Primitives.Operations is ...@@ -749,9 +732,6 @@ package body System.Task_Primitives.Operations is
if Result = 0 then if Result = 0 then
Succeeded := True; Succeeded := True;
Self_ID.Common.LL.Exc_Stack_Ptr := new Exc_Stack_T; Self_ID.Common.LL.Exc_Stack_Ptr := new Exc_Stack_T;
SSL.Set_Exc_Stack_Addr
(To_Address (Self_ID),
Self_ID.Common.LL.Exc_Stack_Ptr (Exc_Stack_T'Last)'Address);
else else
if not Single_Lock then if not Single_Lock then
...@@ -766,6 +746,15 @@ package body System.Task_Primitives.Operations is ...@@ -766,6 +746,15 @@ package body System.Task_Primitives.Operations is
pragma Assert (Result = 0); pragma Assert (Result = 0);
end Initialize_TCB; end Initialize_TCB;
------------------------
-- Get_Exc_Stack_Addr --
------------------------
function Get_Exc_Stack_Addr return Address is
begin
return Self.Common.LL.Exc_Stack_Ptr (Exc_Stack_T'Last)'Address;
end Get_Exc_Stack_Addr;
----------------- -----------------
-- Create_Task -- -- Create_Task --
----------------- -----------------
...@@ -1169,6 +1158,8 @@ package body System.Task_Primitives.Operations is ...@@ -1169,6 +1158,8 @@ package body System.Task_Primitives.Operations is
begin begin
Environment_Task_Id := Environment_Task; Environment_Task_Id := Environment_Task;
SSL.Get_Exc_Stack_Addr := Get_Exc_Stack_Addr'Access;
-- Initialize the lock used to synchronize chain of all ATCBs -- Initialize the lock used to synchronize chain of all ATCBs
Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level);
......
...@@ -44,8 +44,8 @@ with System.OS_Interface; ...@@ -44,8 +44,8 @@ with System.OS_Interface;
-- used for Thread_Id -- used for Thread_Id
package System.Task_Primitives.Operations is package System.Task_Primitives.Operations is
pragma Preelaborate;
pragma Elaborate_Body;
package ST renames System.Tasking; package ST renames System.Tasking;
package OSI renames System.OS_Interface; package OSI renames System.OS_Interface;
...@@ -356,8 +356,8 @@ package System.Task_Primitives.Operations is ...@@ -356,8 +356,8 @@ package System.Task_Primitives.Operations is
(Self_ID : ST.Task_Id; (Self_ID : ST.Task_Id;
Time : Duration; Time : Duration;
Mode : ST.Delay_Modes); Mode : ST.Delay_Modes);
-- Implement the semantics of the delay statement. It is assumed that -- Implement the semantics of the delay statement.
-- the caller is not abort-deferred and does not hold any locks. -- The caller should be abort-deferred and should not hold any locks.
procedure Wakeup procedure Wakeup
(T : ST.Task_Id; (T : ST.Task_Id;
......
...@@ -505,6 +505,8 @@ package body System.Tasking.Restricted.Stages is ...@@ -505,6 +505,8 @@ package body System.Tasking.Restricted.Stages is
procedure Init_RTS is procedure Init_RTS is
begin begin
Tasking.Initialize;
-- Initialize lock used to implement mutual exclusion between all tasks -- Initialize lock used to implement mutual exclusion between all tasks
STPO.Initialize_Lock (Global_Task_Lock'Access, STPO.Global_Task_Level); STPO.Initialize_Lock (Global_Task_Lock'Access, STPO.Global_Task_Level);
......
...@@ -38,6 +38,7 @@ with System.Tasking; ...@@ -38,6 +38,7 @@ with System.Tasking;
with System.OS_Interface; with System.OS_Interface;
package System.Tasking.Debug is package System.Tasking.Debug is
pragma Preelaborate;
------------------------------------------ ------------------------------------------
-- Application-level debugging routines -- -- Application-level debugging routines --
...@@ -66,7 +67,7 @@ package System.Tasking.Debug is ...@@ -66,7 +67,7 @@ package System.Tasking.Debug is
-- General GDB support -- -- General GDB support --
------------------------- -------------------------
Known_Tasks : array (0 .. 999) of Task_Id; Known_Tasks : array (0 .. 999) of Task_Id := (others => null);
-- Global array of tasks read by gdb, and updated by -- Global array of tasks read by gdb, and updated by
-- Create_Task and Finalize_TCB -- Create_Task and Finalize_TCB
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2004 Free Software Foundation, Inc. -- -- Copyright (C) 1992-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -41,11 +41,12 @@ ...@@ -41,11 +41,12 @@
-- This unit may be used directly from an application program by providing -- This unit may be used directly from an application program by providing
-- an appropriate WITH, and the interface can be expected to remain stable. -- an appropriate WITH, and the interface can be expected to remain stable.
-- This is the SGI (libathread) specific version of this module. -- This is the SGI (libathread) specific version of this module
with System.OS_Interface; with System.OS_Interface;
package System.Task_Info is package System.Task_Info is
pragma Preelaborate;
pragma Elaborate_Body; pragma Elaborate_Body;
-- To ensure that a body is allowed -- To ensure that a body is allowed
...@@ -147,7 +148,7 @@ package System.Task_Info is ...@@ -147,7 +148,7 @@ package System.Task_Info is
ANY_CPU : constant CPU_Number := CPU_Number'First; ANY_CPU : constant CPU_Number := CPU_Number'First;
type Non_Degrading_Priority is range 0 .. 255; type Non_Degrading_Priority is range 0 .. 255;
-- Specification of IRIX Non Degrading Priorities. -- Specification of IRIX Non Degrading Priorities
-- --
-- WARNING: IRIX priorities have the reverse meaning of Ada priorities. -- WARNING: IRIX priorities have the reverse meaning of Ada priorities.
-- The lower the priority value, the greater the greater the -- The lower the priority value, the greater the greater the
...@@ -203,8 +204,7 @@ package System.Task_Info is ...@@ -203,8 +204,7 @@ package System.Task_Info is
CPU : CPU_Number := ANY_CPU; CPU : CPU_Number := ANY_CPU;
Resident : Page_Locking := NOLOCK; Resident : Page_Locking := NOLOCK;
NDPRI : Non_Degrading_Priority := NDP_NONE) return sproc_t; NDPRI : Non_Degrading_Priority := NDP_NONE) return sproc_t;
-- Allocates a sproc_t control structure and creates the -- Allocates a sproc_t control structure and creates corresponding sproc
-- corresponding sproc.
Invalid_CPU_Number : exception; Invalid_CPU_Number : exception;
Permission_Error : exception; Permission_Error : exception;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2003 Free Software Foundation, Inc. -- -- Copyright (C) 1992-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -44,14 +44,12 @@ ...@@ -44,14 +44,12 @@
-- This is the IRIX (kernel threads) version of this package -- This is the IRIX (kernel threads) version of this package
with Interfaces.C; with Interfaces.C;
with System.OS_Interface;
package System.Task_Info is package System.Task_Info is
pragma Preelaborate;
pragma Elaborate_Body; pragma Elaborate_Body;
-- To ensure that a body is allowed -- To ensure that a body is allowed
package OSI renames System.OS_Interface;
----------------------------------------- -----------------------------------------
-- Implementation of Task_Info Feature -- -- Implementation of Task_Info Feature --
----------------------------------------- -----------------------------------------
...@@ -91,27 +89,13 @@ package System.Task_Info is ...@@ -91,27 +89,13 @@ package System.Task_Info is
subtype Thread_Scheduling_Priority is Integer range subtype Thread_Scheduling_Priority is Integer range
No_Specified_Priority .. 255; No_Specified_Priority .. 255;
function Min (Policy : Interfaces.C.int) return Interfaces.C.int subtype FIFO_Priority is Thread_Scheduling_Priority range 0 .. 255;
renames OSI.sched_get_priority_min;
function Max (Policy : Interfaces.C.int) return Interfaces.C.int
renames OSI.sched_get_priority_max;
subtype FIFO_Priority is Thread_Scheduling_Priority range
Thread_Scheduling_Priority (Min (OSI.SCHED_FIFO)) ..
Thread_Scheduling_Priority (Max (OSI.SCHED_FIFO));
subtype RR_Priority is Thread_Scheduling_Priority range subtype RR_Priority is Thread_Scheduling_Priority range 0 .. 255;
Thread_Scheduling_Priority (Min (OSI.SCHED_RR)) ..
Thread_Scheduling_Priority (Max (OSI.SCHED_RR));
subtype TS_Priority is Thread_Scheduling_Priority range subtype TS_Priority is Thread_Scheduling_Priority range 1 .. 40;
Thread_Scheduling_Priority (Min (OSI.SCHED_TS)) ..
Thread_Scheduling_Priority (Max (OSI.SCHED_TS));
subtype OTHER_Priority is Thread_Scheduling_Priority range subtype OTHER_Priority is Thread_Scheduling_Priority range 1 .. 40;
Thread_Scheduling_Priority (Min (OSI.SCHED_OTHER)) ..
Thread_Scheduling_Priority (Max (OSI.SCHED_OTHER));
subtype CPU_Number is Integer range -1 .. Integer'Last; subtype CPU_Number is Integer range -1 .. Integer'Last;
ANY_CPU : constant CPU_Number := CPU_Number'First; ANY_CPU : constant CPU_Number := CPU_Number'First;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2003 Free Software Foundation, Inc. -- -- Copyright (C) 1992-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
with System.OS_Interface; with System.OS_Interface;
package System.Task_Info is package System.Task_Info is
pragma Preelaborate;
pragma Elaborate_Body; pragma Elaborate_Body;
-- To ensure that a body is allowed -- To ensure that a body is allowed
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
-- S p e c -- -- S p e c --
-- (Compiler Interface) -- -- (Compiler Interface) --
-- -- -- --
-- Copyright (C) 1998-2003 Free Software Foundation, Inc. -- -- Copyright (C) 1998-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
-- This is a DEC Unix 4.0d version of this package. -- This is a DEC Unix 4.0d version of this package.
package System.Task_Info is package System.Task_Info is
pragma Preelaborate;
pragma Elaborate_Body; pragma Elaborate_Body;
-- To ensure that a body is allowed -- To ensure that a body is allowed
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2003 Free Software Foundation, Inc. -- -- Copyright (C) 1992-2005 Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
-- an appropriate WITH, and the interface can be expected to remain stable. -- an appropriate WITH, and the interface can be expected to remain stable.
package System.Task_Info is package System.Task_Info is
pragma Preelaborate;
pragma Elaborate_Body; pragma Elaborate_Body;
-- To ensure that a body is allowed -- To ensure that a body is allowed
......
...@@ -48,6 +48,21 @@ package body System.Tasking is ...@@ -48,6 +48,21 @@ package body System.Tasking is
package STPO renames System.Task_Primitives.Operations; package STPO renames System.Task_Primitives.Operations;
---------------------
-- Detect_Blocking --
---------------------
function Detect_Blocking return Boolean is
GL_Detect_Blocking : Integer;
pragma Import (C, GL_Detect_Blocking, "__gl_detect_blocking");
-- Global variable exported by the binder generated file.
-- A value equal to 1 indicates that pragma Detect_Blocking is active,
-- while 0 is used for the pragma not being present.
begin
return GL_Detect_Blocking = 1;
end Detect_Blocking;
---------- ----------
-- Self -- -- Self --
---------- ----------
...@@ -116,8 +131,12 @@ package body System.Tasking is ...@@ -116,8 +131,12 @@ package body System.Tasking is
All_Tasks_List := T; All_Tasks_List := T;
end Initialize_ATCB; end Initialize_ATCB;
----------------
-- Initialize --
----------------
Main_Task_Image : constant String := "main_task"; Main_Task_Image : constant String := "main_task";
-- Image of environment task. -- Image of environment task
Main_Priority : Integer; Main_Priority : Integer;
pragma Import (C, Main_Priority, "__gl_main_priority"); pragma Import (C, Main_Priority, "__gl_main_priority");
...@@ -125,26 +144,21 @@ package body System.Tasking is ...@@ -125,26 +144,21 @@ package body System.Tasking is
-- Priority, because we use the value -1 to indicate the default -- Priority, because we use the value -1 to indicate the default
-- main priority, and that is of course not in Priority'range. -- main priority, and that is of course not in Priority'range.
---------------------------- Initialized : Boolean := False;
-- Tasking Initialization -- -- Used to prevent multiple calls to Initialize
----------------------------
procedure Initialize is
-- This block constitutes the first part of the initialization of the
-- GNARL. This includes creating data structures to make the initial thread
-- into the environment task. The last part of the initialization is done
-- in System.Tasking.Initialization or System.Tasking.Restricted.Stages.
-- All the initializations used to be in Tasking.Initialization, but this
-- is no longer possible with the run time simplification (including
-- optimized PO and the restricted run time) since one cannot rely on
-- System.Tasking.Initialization being present, as was done before.
begin
declare
T : Task_Id; T : Task_Id;
Success : Boolean; Success : Boolean;
Base_Priority : Any_Priority; Base_Priority : Any_Priority;
begin begin
if Initialized then
return;
end if;
Initialized := True;
-- Initialize Environment Task -- Initialize Environment Task
if Main_Priority = Unspecified_Priority then if Main_Priority = Unspecified_Priority then
...@@ -170,5 +184,6 @@ begin ...@@ -170,5 +184,6 @@ begin
-- in ravenscar mode. Rest of the initialization is done in Init_RTS. -- in ravenscar mode. Rest of the initialization is done in Init_RTS.
T.Entry_Calls (1).Self := T; T.Entry_Calls (1).Self := T;
end; end Initialize;
end System.Tasking; end System.Tasking;
...@@ -54,6 +54,7 @@ with System.Task_Primitives; ...@@ -54,6 +54,7 @@ with System.Task_Primitives;
with Unchecked_Conversion; with Unchecked_Conversion;
package System.Tasking is package System.Tasking is
pragma Preelaborate;
------------------- -------------------
-- Locking Rules -- -- Locking Rules --
...@@ -342,8 +343,9 @@ package System.Tasking is ...@@ -342,8 +343,9 @@ package System.Tasking is
type Access_Boolean is access all Boolean; type Access_Boolean is access all Boolean;
Detect_Blocking : constant Boolean; function Detect_Blocking return Boolean;
-- Boolean constant set True iff Detect_Blocking is active pragma Inline (Detect_Blocking);
-- Return whether the Detect_Blocking pragma is enabled.
---------------------------------------------- ----------------------------------------------
-- Ada_Task_Control_Block (ATCB) definition -- -- Ada_Task_Control_Block (ATCB) definition --
...@@ -977,9 +979,19 @@ package System.Tasking is ...@@ -977,9 +979,19 @@ package System.Tasking is
-- has exclusive access to this field. -- has exclusive access to this field.
end record; end record;
--------------------- --------------------
-- Initialize_ATCB -- -- Initialization --
--------------------- --------------------
procedure Initialize;
-- This procedure constitutes the first part of the initialization of the
-- GNARL. This includes creating data structures to make the initial thread
-- into the environment task. The last part of the initialization is done
-- in System.Tasking.Initialization or System.Tasking.Restricted.Stages.
-- All the initializations used to be in Tasking.Initialization, but this
-- is no longer possible with the run time simplification (including
-- optimized PO and the restricted run time) since one cannot rely on
-- System.Tasking.Initialization being present, as was done before.
procedure Initialize_ATCB procedure Initialize_ATCB
(Self_ID : Task_Id; (Self_ID : Task_Id;
...@@ -999,14 +1011,6 @@ package System.Tasking is ...@@ -999,14 +1011,6 @@ package System.Tasking is
private private
Null_Task : constant Task_Id := null; Null_Task : constant Task_Id := null;
GL_Detect_Blocking : Integer;
pragma Import (C, GL_Detect_Blocking, "__gl_detect_blocking");
-- Global variable exported by the binder generated file. A value equal to
-- 1 indicates that pragma Detect_Blocking is active, while 0 is used for
-- the pragma not being present.
Detect_Blocking : constant Boolean := GL_Detect_Blocking = 1;
type Activation_Chain is record type Activation_Chain is record
T_ID : Task_Id; T_ID : Task_Id;
end record; end record;
......
...@@ -45,6 +45,7 @@ with System.OS_Interface; ...@@ -45,6 +45,7 @@ with System.OS_Interface;
-- pthread_t -- pthread_t
package System.Task_Primitives is package System.Task_Primitives is
pragma Preelaborate;
type Lock is limited private; type Lock is limited private;
-- Should be used for implementation of protected objects -- Should be used for implementation of protected objects
......
------------------------------------------------------------------------------
-- --
-- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K _ P R I M I T I V E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1991-2005 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, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, 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 is the GNU/Linux (GNU/LinuxThreads) version of this package
-- This package provides low-level support for most tasking features
pragma Polling (Off);
-- Turn off polling, we do not want ATC polling to take place during
-- tasking operations. It causes infinite loops and other problems.
with System.OS_Interface;
-- used for pthread_mutex_t
-- pthread_cond_t
-- pthread_t
package System.Task_Primitives is
type Lock is limited private;
-- Should be used for implementation of protected objects
type RTS_Lock is limited private;
-- Should be used inside the runtime system. The difference between Lock
-- and the RTS_Lock is that the later one serves only as a semaphore so
-- that do not check for ceiling violations.
type Suspension_Object is limited private;
-- Should be used for the implementation of Ada.Synchronous_Task_Control
type Task_Body_Access is access procedure;
-- Pointer to the task body's entry point (or possibly a wrapper
-- declared local to the GNARL).
type Private_Data is limited private;
-- Any information that the GNULLI needs maintained on a per-task basis.
-- A component of this type is guaranteed to be included in the
-- Ada_Task_Control_Block.
private
type Prio_Array_Type is array (System.Any_Priority) of Integer;
type Lock is record
L : aliased System.OS_Interface.pthread_mutex_t;
Ceiling : System.Any_Priority := System.Any_Priority'First;
Saved_Priority : System.Any_Priority := System.Any_Priority'First;
end record;
type RTS_Lock is new System.OS_Interface.pthread_mutex_t;
type Suspension_Object is record
State : Boolean;
pragma Atomic (State);
-- Boolean that indicates whether the object is open. This field is
-- marked Atomic to ensure that we can read its value without locking
-- the access to the Suspension_Object.
Waiting : Boolean;
-- Flag showing if there is a task already suspended on this object
L : aliased System.OS_Interface.pthread_mutex_t;
-- Protection for ensuring mutual exclusion on the Suspension_Object
CV : aliased System.OS_Interface.pthread_cond_t;
-- Condition variable used to queue threads until the condition is
-- signaled.
end record;
type Private_Data is record
Thread : aliased System.OS_Interface.pthread_t;
pragma Atomic (Thread);
-- Thread field may be updated by two different threads of control.
-- (See, Enter_Task and Create_Task in s-taprop.adb).
-- They put the same value (thr_self value). We do not want to
-- use lock on those operations and the only thing we have to
-- make sure is that they are updated in atomic fashion.
CV : aliased System.OS_Interface.pthread_cond_t;
L : aliased RTS_Lock;
-- Protection for all components is lock L
Active_Priority : System.Any_Priority := System.Any_Priority'First;
-- Simulated active priority, used only if Priority_Ceiling_Support
-- is True.
end record;
end System.Task_Primitives;
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- This is a LynxOS version of this package, derived from 7staspri.ads -- This is a LynxOS version of this package, derived from s-taspri-posix.ads
pragma Polling (Off); pragma Polling (Off);
-- Turn off polling, we do not want ATC polling to take place during -- Turn off polling, we do not want ATC polling to take place during
...@@ -44,6 +44,7 @@ with System.OS_Interface; ...@@ -44,6 +44,7 @@ with System.OS_Interface;
-- pthread_t -- pthread_t
package System.Task_Primitives is package System.Task_Primitives is
pragma Preelaborate;
type Lock is limited private; type Lock is limited private;
-- Should be used for implementation of protected objects -- Should be used for implementation of protected objects
......
...@@ -43,6 +43,7 @@ with System.OS_Interface; ...@@ -43,6 +43,7 @@ with System.OS_Interface;
-- pthread_t -- pthread_t
package System.Task_Primitives is package System.Task_Primitives is
pragma Preelaborate;
type Lock is limited private; type Lock is limited private;
-- Should be used for implementation of protected objects -- Should be used for implementation of protected objects
......
...@@ -44,15 +44,12 @@ with Interfaces.OS2Lib.Threads; ...@@ -44,15 +44,12 @@ with Interfaces.OS2Lib.Threads;
with Interfaces.OS2Lib.Synchronization; with Interfaces.OS2Lib.Synchronization;
package System.Task_Primitives is package System.Task_Primitives is
pragma Preelaborate; pragma Preelaborate;
-- Why are these commented out ??? type Lock is limited private;
-- type Lock is limited private;
-- Should be used for implementation of protected objects. -- Should be used for implementation of protected objects.
-- type RTS_Lock is limited private; type RTS_Lock is limited private;
-- Should be used inside the runtime system. -- Should be used inside the runtime system.
-- The difference between Lock and the RTS_Lock is that the later -- The difference between Lock and the RTS_Lock is that the later
-- one serves only as a semaphore so that do not check for -- one serves only as a semaphore so that do not check for
...@@ -62,12 +59,12 @@ package System.Task_Primitives is ...@@ -62,12 +59,12 @@ package System.Task_Primitives is
-- Pointer to the task body's entry point (or possibly a wrapper -- Pointer to the task body's entry point (or possibly a wrapper
-- declared local to the GNARL). -- declared local to the GNARL).
-- type Private_Data is limited private; type Private_Data is limited private;
-- Any information that the GNULLI needs maintained on a per-task -- Any information that the GNULLI needs maintained on a per-task
-- basis. A component of this type is guaranteed to be included -- basis. A component of this type is guaranteed to be included
-- in the Ada_Task_Control_Block. -- in the Ada_Task_Control_Block.
-- private (why commented out???) private
type Lock is record type Lock is record
Mutex : aliased Interfaces.OS2Lib.Synchronization.HMTX; Mutex : aliased Interfaces.OS2Lib.Synchronization.HMTX;
......
...@@ -46,6 +46,7 @@ with System.OS_Interface; ...@@ -46,6 +46,7 @@ with System.OS_Interface;
-- pthread_t -- pthread_t
package System.Task_Primitives is package System.Task_Primitives is
pragma Preelaborate;
type Lock is limited private; type Lock is limited private;
-- Should be used for implementation of protected objects -- Should be used for implementation of protected objects
......
...@@ -49,6 +49,7 @@ with System.OS_Interface; ...@@ -49,6 +49,7 @@ with System.OS_Interface;
-- pthread_t -- pthread_t
package System.Task_Primitives is package System.Task_Primitives is
pragma Preelaborate;
type Lock is limited private; type Lock is limited private;
-- Should be used for implementation of protected objects -- Should be used for implementation of protected objects
......
...@@ -49,6 +49,7 @@ with System.OS_Interface; ...@@ -49,6 +49,7 @@ with System.OS_Interface;
-- pthread_t -- pthread_t
package System.Task_Primitives is package System.Task_Primitives is
pragma Preelaborate;
type Lock is limited private; type Lock is limited private;
-- Should be used for implementation of protected objects -- Should be used for implementation of protected objects
......
...@@ -40,6 +40,7 @@ pragma Polling (Off); ...@@ -40,6 +40,7 @@ pragma Polling (Off);
with System.OS_Interface; with System.OS_Interface;
package System.Task_Primitives is package System.Task_Primitives is
pragma Preelaborate;
type Lock is limited private; type Lock is limited private;
-- Should be used for implementation of protected objects -- Should be used for implementation of protected objects
......
...@@ -846,8 +846,6 @@ package body System.Tasking.Stages is ...@@ -846,8 +846,6 @@ package body System.Tasking.Stages is
SSL.Set_Jmpbuf_Address := SSL.Set_Jmpbuf_Address_NT'Access; SSL.Set_Jmpbuf_Address := SSL.Set_Jmpbuf_Address_NT'Access;
SSL.Get_Sec_Stack_Addr := SSL.Get_Sec_Stack_Addr_NT'Access; SSL.Get_Sec_Stack_Addr := SSL.Get_Sec_Stack_Addr_NT'Access;
SSL.Set_Sec_Stack_Addr := SSL.Set_Sec_Stack_Addr_NT'Access; SSL.Set_Sec_Stack_Addr := SSL.Set_Sec_Stack_Addr_NT'Access;
SSL.Get_Exc_Stack_Addr := SSL.Get_Exc_Stack_Addr_NT'Access;
SSL.Set_Exc_Stack_Addr := SSL.Set_Exc_Stack_Addr_NT'Access;
SSL.Check_Abort_Status := SSL.Check_Abort_Status_NT'Access; SSL.Check_Abort_Status := SSL.Check_Abort_Status_NT'Access;
SSL.Get_Stack_Info := SSL.Get_Stack_Info_NT'Access; SSL.Get_Stack_Info := SSL.Get_Stack_Info_NT'Access;
...@@ -1135,7 +1133,6 @@ package body System.Tasking.Stages is ...@@ -1135,7 +1133,6 @@ package body System.Tasking.Stages is
procedure To_Stderr (S : String); procedure To_Stderr (S : String);
pragma Import (Ada, To_Stderr, "__gnat_to_stderr"); pragma Import (Ada, To_Stderr, "__gnat_to_stderr");
use System.Task_Info;
use System.Soft_Links; use System.Soft_Links;
use System.Standard_Library; use System.Standard_Library;
......
...@@ -42,9 +42,10 @@ package body Specific is ...@@ -42,9 +42,10 @@ package body Specific is
---------------- ----------------
procedure Initialize (Environment_Task : Task_Id) is procedure Initialize (Environment_Task : Task_Id) is
pragma Unreferenced (Environment_Task);
Result : Interfaces.C.int; Result : Interfaces.C.int;
begin begin
Result := thr_setspecific (ATCB_Key, To_Address (Environment_Task)); Result := thr_keycreate (ATCB_Key'Access, System.Null_Address);
pragma Assert (Result = 0); pragma Assert (Result = 0);
end Initialize; end Initialize;
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
-- To add a new target, just adapt System.Traces.Send to your own purpose. -- To add a new target, just adapt System.Traces.Send to your own purpose.
package System.Traces is package System.Traces is
pragma Preelaborate;
type Trace_T is type Trace_T is
( (
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
-- This is the Alpha/OpenVMS version of this package -- This is the Alpha/OpenVMS version of this package
package System.Traceback_Entries is package System.Traceback_Entries is
pragma Preelaborate;
type Traceback_Entry is record type Traceback_Entry is record
PC : System.Address; PC : System.Address;
......
...@@ -41,12 +41,13 @@ ...@@ -41,12 +41,13 @@
-- address of a call instruction part of the call-chain. -- address of a call instruction part of the call-chain.
package System.Traceback_Entries is package System.Traceback_Entries is
pragma Preelaborate;
subtype Traceback_Entry is System.Address; subtype Traceback_Entry is System.Address;
-- This subtype defines what each traceback array entry contains. -- This subtype defines what each traceback array entry contains
Null_TB_Entry : constant Traceback_Entry := System.Null_Address; Null_TB_Entry : constant Traceback_Entry := System.Null_Address;
-- This is the value to be used when initializing an entry. -- This is the value to be used when initializing an entry
function PC_For (TB_Entry : Traceback_Entry) return System.Address; function PC_For (TB_Entry : Traceback_Entry) return System.Address;
pragma Inline (PC_For); pragma Inline (PC_For);
...@@ -55,6 +56,6 @@ package System.Traceback_Entries is ...@@ -55,6 +56,6 @@ package System.Traceback_Entries is
function TB_Entry_For (PC : System.Address) return Traceback_Entry; function TB_Entry_For (PC : System.Address) return Traceback_Entry;
pragma Inline (TB_Entry_For); pragma Inline (TB_Entry_For);
-- Returns an entry representing a frame for a call instruction at PC. -- Returns an entry representing a frame for a call instruction at PC
end System.Traceback_Entries; end System.Traceback_Entries;
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
with System.Tasking; with System.Tasking;
package System.Traces.Tasking is package System.Traces.Tasking is
pragma Preelaborate;
package ST renames System.Tasking; package ST renames System.Tasking;
......
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