[Ada] The Unix Epochalyse of 2038 - OS_Time
authorDoug Rupp <rupp@adacore.com>
Mon, 26 Apr 2021 04:52:09 +0000 (21:52 -0700)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 5 Jul 2021 13:09:12 +0000 (13:09 +0000)
gcc/ada/

* adaint.h (OS_Time): typedef as long long.
* osint.adb (Underlying_OS_Time): Declare as 64-bit signed type.
* libgnat/s-os_lib.adb ("<"): Compare OS_Time as
Long_Long_Integer.
("<="): Likewise.
(">"): Likewise.
(">="): Likewise.
* libgnat/s-os_lib.ads (OS_Time): Declare as 64-bit signed type.

gcc/ada/adaint.h
gcc/ada/libgnat/s-os_lib.adb
gcc/ada/libgnat/s-os_lib.ads
gcc/ada/osint.adb

index 6ef61e7..b03294f 100644 (file)
@@ -101,11 +101,7 @@ extern "C" {
 #endif
 
 /* Type corresponding to GNAT.OS_Lib.OS_Time */
-#if defined (_WIN64)
 typedef long long OS_Time;
-#else
-typedef long OS_Time;
-#endif
 
 #define __int64 long long
 GNAT_STRUCT_STAT;
index 5c02b2d..7591f27 100644 (file)
@@ -139,7 +139,7 @@ package body System.OS_Lib is
 
    function "<"  (X, Y : OS_Time) return Boolean is
    begin
-      return Long_Integer (X) < Long_Integer (Y);
+      return Long_Long_Integer (X) < Long_Long_Integer (Y);
    end "<";
 
    ----------
@@ -148,7 +148,7 @@ package body System.OS_Lib is
 
    function "<="  (X, Y : OS_Time) return Boolean is
    begin
-      return Long_Integer (X) <= Long_Integer (Y);
+      return Long_Long_Integer (X) <= Long_Long_Integer (Y);
    end "<=";
 
    ---------
@@ -157,7 +157,7 @@ package body System.OS_Lib is
 
    function ">"  (X, Y : OS_Time) return Boolean is
    begin
-      return Long_Integer (X) > Long_Integer (Y);
+      return Long_Long_Integer (X) > Long_Long_Integer (Y);
    end ">";
 
    ----------
@@ -166,7 +166,7 @@ package body System.OS_Lib is
 
    function ">="  (X, Y : OS_Time) return Boolean is
    begin
-      return Long_Integer (X) >= Long_Integer (Y);
+      return Long_Long_Integer (X) >= Long_Long_Integer (Y);
    end ">=";
 
    -----------------
index 42ac488..1d0af9b 100644 (file)
@@ -1098,8 +1098,7 @@ private
    pragma Import (C, Current_Process_Id, "__gnat_current_process_id");
 
    type OS_Time is
-     range -(2 ** (Standard'Address_Size - Integer'(1))) ..
-           +(2 ** (Standard'Address_Size - Integer'(1)) - 1);
+     range -(2 ** 63) ..  +(2 ** 63 - 1);
    --  Type used for timestamps in the compiler. This type is used to hold
    --  time stamps, but may have a different representation than C's time_t.
    --  This type needs to match the declaration of OS_Time in adaint.h.
index d47eaa5..3e5db36 100644 (file)
@@ -2191,8 +2191,7 @@ package body Osint is
       GNAT_Time : Time_Stamp_Type;
 
       type Underlying_OS_Time is
-        range -(2 ** (Standard'Address_Size - Integer'(1))) ..
-              +(2 ** (Standard'Address_Size - Integer'(1)) - 1);
+        range -(2 ** 63) ..  +(2 ** 63 - 1);
       --  Underlying_OS_Time is a redeclaration of OS_Time to allow integer
       --  manipulation. Remove this in favor of To_Ada/To_C once newer
       --  GNAT releases are available with these functions.