summaryrefslogtreecommitdiff
path: root/gcc/ada/a-reatim.adb
diff options
context:
space:
mode:
authorbosch <bosch@138bc75d-0d04-0410-961f-82ee72b054a4>2001-10-31 00:07:54 +0000
committerbosch <bosch@138bc75d-0d04-0410-961f-82ee72b054a4>2001-10-31 00:07:54 +0000
commit784b5d91dba7b668588fa608f5670a561fc3d553 (patch)
tree9028e96337de515589d9449ff638ba6ba68a0a47 /gcc/ada/a-reatim.adb
parent7ae0fe4438059aa4269cdaa14cf0e5d8b3600280 (diff)
downloadgcc-784b5d91dba7b668588fa608f5670a561fc3d553.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46660 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-reatim.adb')
-rw-r--r--gcc/ada/a-reatim.adb30
1 files changed, 23 insertions, 7 deletions
diff --git a/gcc/ada/a-reatim.adb b/gcc/ada/a-reatim.adb
index 8854922d200..4ed7ce7791b 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;