[Ada] Fix handling of delay until with no tasking

Arnaud Charlet charlet@adacore.com
Fri Apr 6 15:59:00 GMT 2007


Tested on i686-linux, committed on trunk

Ada.Real_Time.Delays operations depend on tasking, and proper tasking
initialization must always be performed. The patch adds the required
elaboration code to ensure that the tasking run time is always initialized
when using delay operations. The initialization routine has the required
machinery to prevent multiple calls to Initialize.
The following test case should compile and execute quietly:
--
with Ada.Real_Time;

procedure Test_Delay is
begin
   delay until Ada.Real_Time.Clock;
end Test_Delay;

(added to testsuite/gnat.dg)

2007-04-06  Jose Ruiz  <ruiz@adacore.com>

	* a-retide.adb: Add elaboration code to ensure that the tasking run
	time is initialized when using delay operations even when no task is
	created.

-------------- next part --------------
Index: a-retide.adb
===================================================================
--- a-retide.adb	(revision 123291)
+++ a-retide.adb	(working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                  B o d y                                 --
 --                                                                          --
---         Copyright (C) 1992-2005, Free Software Foundation, Inc.          --
+--         Copyright (C) 1992-2006, 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- --
@@ -36,6 +36,7 @@ with Ada.Exceptions;
 
 with System.Tasking;
 --  Used for Task_Id
+--           Initialize
 
 with System.Task_Primitives.Operations;
 --  Used for Timed_Delay
@@ -82,4 +83,10 @@ package body Ada.Real_Time.Delays is
       return To_Duration (Time_Span (T));
    end To_Duration;
 
+begin
+   --  Ensure that the tasking run time is initialized when using delay
+   --  operations. The initialization routine has the required machinery to
+   --  prevent multiple calls to Initialize.
+
+   System.Tasking.Initialize;
 end Ada.Real_Time.Delays;


More information about the Gcc-patches mailing list