aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEd Schonberg <schonber@gnat.com>2001-10-31 00:07:54 +0000
committerGeert Bosch <bosch@gcc.gnu.org>2001-10-31 01:07:54 +0100
commit84bfdde0540abba02488942bd0617eff6c36fdcd (patch)
tree9028e96337de515589d9449ff638ba6ba68a0a47 /gcc/ada
parentc296e5fc6ce887ba553d64dba39a5df0864db7cf (diff)
downloadgcc-84bfdde0540abba02488942bd0617eff6c36fdcd.zip
gcc-84bfdde0540abba02488942bd0617eff6c36fdcd.tar.gz
gcc-84bfdde0540abba02488942bd0617eff6c36fdcd.tar.bz2
a-reatim.ads: Makes Seconds_Count into a 64-bit integer, to accommodate all its possible values.
* a-reatim.ads: Makes Seconds_Count into a 64-bit integer, to accommodate all its possible values. * a-reatim.adb (Split): Special-case handling of Time_Span_First and of small absolute values of T. From-SVN: r46660
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog8
-rw-r--r--gcc/ada/a-reatim.adb30
-rw-r--r--gcc/ada/a-reatim.ads10
3 files changed, 38 insertions, 10 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 153cc63..4ac4137 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,11 @@
+2001-10-30 Ed Schonberg <schonber@gnat.com>
+
+ * a-reatim.ads: Makes Seconds_Count into a 64-bit integer,
+ to accommodate all its possible values.
+
+ * a-reatim.adb (Split): Special-case handling of Time_Span_First
+ and of small absolute values of T.
+
2001-10-30 Richard Kenner <kenner@gnat.com>
* misc.c (gnat_expand_expr, case NULL_EXPR): Remove call to
diff --git a/gcc/ada/a-reatim.adb b/gcc/ada/a-reatim.adb
index 8854922..4ed7ce7 100644
--- a/gcc/ada/a-reatim.adb
+++ b/gcc/ada/a-reatim.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- $Revision: 1.34 $
+-- $Revision$
-- --
-- Copyright (C) 1991-2001, Florida State University --
-- --
@@ -159,17 +159,33 @@ package body Ada.Real_Time is
-----------
procedure Split (T : Time; SC : out Seconds_Count; TS : out Time_Span) is
+ T_Val : Time;
+
begin
- -- Extract the integer part of T
+ -- Special-case for Time_First, whose absolute value is anomalous,
+ -- courtesy of two's complement.
+
+ if T = Time_First then
+ T_Val := abs (Time_Last);
+ else
+ T_Val := abs (T);
+ end if;
+
+ -- Extract the integer part of T, truncating towards zero.
+
+ if T_Val < 0.5 then
+ SC := 0;
- if T = 0.0 then
- SC := 0;
else
- SC := Seconds_Count (Time_Span'(T - 0.5));
+ SC := Seconds_Count (Time_Span' (T_Val - 0.5));
+ end if;
+
+ if T < 0.0 then
+ SC := -SC;
end if;
- -- Since we loose precision when converting a time value to float,
- -- we need to add this check
+ -- If original time is negative, need to truncate towards negative
+ -- infinity, to make TS non-negative, as per ARM.
if Time (SC) > T then
SC := SC - 1;
diff --git a/gcc/ada/a-reatim.ads b/gcc/ada/a-reatim.ads
index 9fe4762..563565b 100644
--- a/gcc/ada/a-reatim.ads
+++ b/gcc/ada/a-reatim.ads
@@ -6,9 +6,9 @@
-- --
-- S p e c --
-- --
--- $Revision: 1.24 $ --
+-- $Revision$
-- --
--- Copyright (C) 1992-1998 Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
@@ -88,7 +88,11 @@ package Ada.Real_Time is
function Microseconds (US : Integer) return Time_Span;
function Milliseconds (MS : Integer) return Time_Span;
- type Seconds_Count is new Integer range -Integer'Last .. Integer'Last;
+ -- With duration represented as a 64-bit number with a delta of
+ -- 10 ** (-9), the number of seconds in Duration'Last does not fit
+ -- in 32 bits.
+
+ type Seconds_Count is range -2 ** 63 .. 2 ** 63 - 1;
procedure Split (T : Time; SC : out Seconds_Count; TS : out Time_Span);
function Time_Of (SC : Seconds_Count; TS : Time_Span) return Time;