This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[Ada] Fix Ada.Real_Time.Time_First


Applied for Ed. Tested on GNU Linux/x86.

  -Geert

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.

*** a-reatim.ads	1998/08/22 14:28:09	1.24
--- a-reatim.ads	2001/10/17 03:23:43	1.25
***************
*** 6,14 ****
  --                                                                          --
  --                                  S p e c                                 --
  --                                                                          --
! --                             $Revision$                            --
  --                                                                          --
! --          Copyright (C) 1992-1998 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 --
--- 6,14 ----
  --                                                                          --
  --                                  S p e c                                 --
  --                                                                          --
! --                             $Revision$
  --                                                                          --
! --          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,94 ****
     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;
  
     procedure Split (T : Time; SC : out Seconds_Count; TS : out Time_Span);
     function Time_Of (SC : Seconds_Count; TS : Time_Span) return Time;
--- 88,98 ----
     function Microseconds (US : Integer) return Time_Span;
     function Milliseconds (MS : Integer) return Time_Span;
  
!    --  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;

*** a-reatim.adb	2001/03/30 19:15:06	1.34
--- a-reatim.adb	2001/10/17 03:23:44	1.35
***************
*** 159,175 ****
     -----------
  
     procedure Split (T : Time; SC : out Seconds_Count; TS : out Time_Span) is
     begin
!       --  Extract the integer part of T
  
!       if T = 0.0 then
!          SC := 0;
        else
!          SC := Seconds_Count (Time_Span'(T - 0.5));
        end if;
  
!       --  Since we loose precision when converting a time value to float,
!       --  we need to add this check
  
        if Time (SC) > T then
           SC := SC - 1;
--- 159,191 ----
     -----------
  
     procedure Split (T : Time; SC : out Seconds_Count; TS : out Time_Span) is
+       T_Val : Time;
+ 
     begin
!       --  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;
! 
        else
!          SC := Seconds_Count (Time_Span' (T_Val - 0.5));
!       end if;
! 
!       if T < 0.0 then
!          SC := -SC;
        end if;
  
!       --  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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]