From a0bdd4b03b87a01a5984aa5c7ad94f66b2a7bc9e Mon Sep 17 00:00:00 2001 From: Doug Rupp Date: Sun, 25 Apr 2021 21:52:09 -0700 Subject: [PATCH] [Ada] The Unix Epochalyse of 2038 - OS_Time 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 | 4 ---- gcc/ada/libgnat/s-os_lib.adb | 8 ++++---- gcc/ada/libgnat/s-os_lib.ads | 3 +-- gcc/ada/osint.adb | 3 +-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h index 6ef61e77e609..b03294f2b18d 100644 --- a/gcc/ada/adaint.h +++ b/gcc/ada/adaint.h @@ -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; diff --git a/gcc/ada/libgnat/s-os_lib.adb b/gcc/ada/libgnat/s-os_lib.adb index 5c02b2d5239a..7591f27903d3 100644 --- a/gcc/ada/libgnat/s-os_lib.adb +++ b/gcc/ada/libgnat/s-os_lib.adb @@ -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 ">="; ----------------- diff --git a/gcc/ada/libgnat/s-os_lib.ads b/gcc/ada/libgnat/s-os_lib.ads index 42ac488c2bf0..1d0af9b73a89 100644 --- a/gcc/ada/libgnat/s-os_lib.ads +++ b/gcc/ada/libgnat/s-os_lib.ads @@ -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. diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb index d47eaa5d649a..3e5db3612d61 100644 --- a/gcc/ada/osint.adb +++ b/gcc/ada/osint.adb @@ -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. -- 2.47.2