From cee731748f23f6cbdcd7baf8102ac4dc87ca5c52 Mon Sep 17 00:00:00 2001 From: Doug Rupp Date: Wed, 28 Apr 2021 07:46:12 -0700 Subject: [PATCH] [Ada] The Unix Epochalypse of 2038 (Warn about time_t in the compiler) gcc/ada/ * libgnat/s-os_lib.ads: Add some comments about time_t. * libgnat/s-os_lib.adb (GM_Split/To_GM_Time): Rename formal to P_OS_Time. (GM_Time_Of/To_OS_Time): Likewise. --- gcc/ada/libgnat/s-os_lib.adb | 56 ++++++++++++++++++------------------ gcc/ada/libgnat/s-os_lib.ads | 8 ++++++ 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/gcc/ada/libgnat/s-os_lib.adb b/gcc/ada/libgnat/s-os_lib.adb index 7591f27903d..d338450dce6 100644 --- a/gcc/ada/libgnat/s-os_lib.adb +++ b/gcc/ada/libgnat/s-os_lib.adb @@ -1347,13 +1347,13 @@ package body System.OS_Lib is Second : out Second_Type) is procedure To_GM_Time - (P_Time_T : Address; - P_Year : Address; - P_Month : Address; - P_Day : Address; - P_Hours : Address; - P_Mins : Address; - P_Secs : Address); + (P_OS_Time : Address; + P_Year : Address; + P_Month : Address; + P_Day : Address; + P_Hours : Address; + P_Mins : Address; + P_Secs : Address); pragma Import (C, To_GM_Time, "__gnat_to_gm_time"); T : OS_Time := Date; @@ -1385,13 +1385,13 @@ package body System.OS_Lib is Locked_Processing : begin SSL.Lock_Task.all; To_GM_Time - (P_Time_T => T'Address, - P_Year => Y'Address, - P_Month => Mo'Address, - P_Day => D'Address, - P_Hours => H'Address, - P_Mins => Mn'Address, - P_Secs => S'Address); + (P_OS_Time => T'Address, + P_Year => Y'Address, + P_Month => Mo'Address, + P_Day => D'Address, + P_Hours => H'Address, + P_Mins => Mn'Address, + P_Secs => S'Address); SSL.Unlock_Task.all; exception @@ -1429,26 +1429,26 @@ package body System.OS_Lib is Second : Second_Type) return OS_Time is procedure To_OS_Time - (P_Time_T : Address; - P_Year : Integer; - P_Month : Integer; - P_Day : Integer; - P_Hours : Integer; - P_Mins : Integer; - P_Secs : Integer); + (P_OS_Time : Address; + P_Year : Integer; + P_Month : Integer; + P_Day : Integer; + P_Hours : Integer; + P_Mins : Integer; + P_Secs : Integer); pragma Import (C, To_OS_Time, "__gnat_to_os_time"); Result : OS_Time; begin To_OS_Time - (P_Time_T => Result'Address, - P_Year => Year - 1900, - P_Month => Month - 1, - P_Day => Day, - P_Hours => Hour, - P_Mins => Minute, - P_Secs => Second); + (P_OS_Time => Result'Address, + P_Year => Year - 1900, + P_Month => Month - 1, + P_Day => Day, + P_Hours => Hour, + P_Mins => Minute, + P_Secs => Second); return Result; end GM_Time_Of; diff --git a/gcc/ada/libgnat/s-os_lib.ads b/gcc/ada/libgnat/s-os_lib.ads index 1d0af9b73a8..8770d94e4da 100644 --- a/gcc/ada/libgnat/s-os_lib.ads +++ b/gcc/ada/libgnat/s-os_lib.ads @@ -164,6 +164,14 @@ package System.OS_Lib is -- component parts to be interpreted in the local time zone, and returns -- an OS_Time. Returns Invalid_Time if the creation fails. + ------------------ + -- Time_t Stuff -- + ------------------ + + -- Note: Do not use time_t in the compiler and host based tools, + -- instead use OS_Time. These 3 declarations are indended for use only + -- by consumers of the GNAT.OS_Lib renaming of this package. + subtype time_t is Long_Integer; -- C time_t type of the time representation