summaryrefslogtreecommitdiff
path: root/gcc/ada/s-taprop-posix.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2013-10-10 12:27:37 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2013-10-10 12:27:37 +0000
commit9856f6976e873d4368c0a7f2f914a4c6e2fc019c (patch)
tree19eca81a6b738b0f0635049d99cccf6e686ce8e1 /gcc/ada/s-taprop-posix.adb
parent056dc9877a5b20e3f9954d49425d5abc98adb21a (diff)
downloadgcc-9856f6976e873d4368c0a7f2f914a4c6e2fc019c.tar.gz
2013-10-10 Pascal Obry <obry@adacore.com>
* prj-conf.adb: Minor typo fixes in comment. 2013-10-10 Thomas Quinot <quinot@adacore.com> * s-taprop-posix.adb (Compute_Deadline): New local subprogram, factors common code between Timed_Sleep and Timed_Delay. 2013-10-10 Robert Dewar <dewar@adacore.com> * freeze.adb (Freeze_Record_Type): Don't replace others if expander inactive. This avoids clobbering the ASIS tree in -gnatct mode. 2013-10-10 Robert Dewar <dewar@adacore.com> * sem_res.adb (Resolve_Op_Expon): Avoid crash testing for fixed-point case in preanalysis mode (error will be caught during full analysis). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203362 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/s-taprop-posix.adb')
-rw-r--r--gcc/ada/s-taprop-posix.adb97
1 files changed, 63 insertions, 34 deletions
diff --git a/gcc/ada/s-taprop-posix.adb b/gcc/ada/s-taprop-posix.adb
index 667603b73b7..275828d049c 100644
--- a/gcc/ada/s-taprop-posix.adb
+++ b/gcc/ada/s-taprop-posix.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2013, 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- --
@@ -178,6 +178,18 @@ package body System.Task_Primitives.Operations is
pragma Import (C,
GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup");
+ procedure Compute_Deadline
+ (Time : Duration;
+ Mode : ST.Delay_Modes;
+ Check_Time : out Duration;
+ Abs_Time : out Duration;
+ Rel_time : out Duration);
+ -- Helper for Timed_Sleep and Timed_Delay: given a deadline specified by
+ -- Time and Mode, compute the current clock reading (Check_Time), and the
+ -- target absolute and relative clock readings (Abs_Time, Rel_Time). The
+ -- epoch for Time depends on Mode; the epoch for Check_Time and Abs_Time
+ -- is always that of CLOCK_RT_Ada.
+
-------------------
-- Abort_Handler --
-------------------
@@ -236,6 +248,36 @@ package body System.Task_Primitives.Operations is
end if;
end Abort_Handler;
+ ----------------------
+ -- Compute_Deadline --
+ ----------------------
+
+ procedure Compute_Deadline
+ (Time : Duration;
+ Mode : ST.Delay_Modes;
+ Check_Time : out Duration;
+ Abs_Time : out Duration;
+ Rel_time : out Duration)
+ is
+ begin
+ Check_Time := Monotonic_Clock;
+
+ if Mode = Relative then
+ Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time;
+
+ if Relative_Timed_Wait then
+ Rel_Time := Duration'Min (Max_Sensible_Delay, Time);
+ end if;
+
+ else
+ Abs_Time := Duration'Min (Check_Time + Max_Sensible_Delay, Time);
+
+ if Relative_Timed_Wait then
+ Rel_Time := Duration'Min (Max_Sensible_Delay, Time - Check_Time);
+ end if;
+ end if;
+ end Compute_Deadline;
+
-----------------
-- Stack_Guard --
-----------------
@@ -528,10 +570,11 @@ package body System.Task_Primitives.Operations is
is
pragma Unreferenced (Reason);
- Base_Time : constant Duration := Monotonic_Clock;
- Check_Time : Duration := Base_Time;
- Rel_Time : Duration;
+ Base_Time : Duration;
+ Check_Time : Duration;
Abs_Time : Duration;
+ Rel_Time : Duration;
+
Request : aliased timespec;
Result : Interfaces.C.int;
@@ -539,20 +582,13 @@ package body System.Task_Primitives.Operations is
Timedout := True;
Yielded := False;
- if Mode = Relative then
- Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time;
-
- if Relative_Timed_Wait then
- Rel_Time := Duration'Min (Max_Sensible_Delay, Time);
- end if;
-
- else
- Abs_Time := Duration'Min (Check_Time + Max_Sensible_Delay, Time);
-
- if Relative_Timed_Wait then
- Rel_Time := Duration'Min (Max_Sensible_Delay, Time - Check_Time);
- end if;
- end if;
+ Compute_Deadline
+ (Time => Time,
+ Mode => Mode,
+ Check_Time => Check_Time,
+ Abs_Time => Abs_Time,
+ Rel_Time => Rel_Time);
+ Base_Time := Check_Time;
if Abs_Time > Check_Time then
Request :=
@@ -597,8 +633,8 @@ package body System.Task_Primitives.Operations is
Time : Duration;
Mode : ST.Delay_Modes)
is
- Base_Time : constant Duration := Monotonic_Clock;
- Check_Time : Duration := Base_Time;
+ Base_Time : Duration;
+ Check_Time : Duration;
Abs_Time : Duration;
Rel_Time : Duration;
Request : aliased timespec;
@@ -613,20 +649,13 @@ package body System.Task_Primitives.Operations is
Write_Lock (Self_ID);
- if Mode = Relative then
- Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time;
-
- if Relative_Timed_Wait then
- Rel_Time := Duration'Min (Max_Sensible_Delay, Time);
- end if;
-
- else
- Abs_Time := Duration'Min (Check_Time + Max_Sensible_Delay, Time);
-
- if Relative_Timed_Wait then
- Rel_Time := Duration'Min (Max_Sensible_Delay, Time - Check_Time);
- end if;
- end if;
+ Compute_Deadline
+ (Time => Time,
+ Mode => Mode,
+ Check_Time => Check_Time,
+ Abs_Time => Abs_Time,
+ Rel_Time => Rel_Time);
+ Base_Time := Check_Time;
if Abs_Time > Check_Time then
Request :=