[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.
This commit is contained in:
Doug Rupp 2021-04-28 07:46:12 -07:00 committed by Pierre-Marie de Rodat
parent 2644eaa0b9
commit cee731748f
2 changed files with 36 additions and 28 deletions

View File

@ -1347,13 +1347,13 @@ package body System.OS_Lib is
Second : out Second_Type) Second : out Second_Type)
is is
procedure To_GM_Time procedure To_GM_Time
(P_Time_T : Address; (P_OS_Time : Address;
P_Year : Address; P_Year : Address;
P_Month : Address; P_Month : Address;
P_Day : Address; P_Day : Address;
P_Hours : Address; P_Hours : Address;
P_Mins : Address; P_Mins : Address;
P_Secs : Address); P_Secs : Address);
pragma Import (C, To_GM_Time, "__gnat_to_gm_time"); pragma Import (C, To_GM_Time, "__gnat_to_gm_time");
T : OS_Time := Date; T : OS_Time := Date;
@ -1385,13 +1385,13 @@ package body System.OS_Lib is
Locked_Processing : begin Locked_Processing : begin
SSL.Lock_Task.all; SSL.Lock_Task.all;
To_GM_Time To_GM_Time
(P_Time_T => T'Address, (P_OS_Time => T'Address,
P_Year => Y'Address, P_Year => Y'Address,
P_Month => Mo'Address, P_Month => Mo'Address,
P_Day => D'Address, P_Day => D'Address,
P_Hours => H'Address, P_Hours => H'Address,
P_Mins => Mn'Address, P_Mins => Mn'Address,
P_Secs => S'Address); P_Secs => S'Address);
SSL.Unlock_Task.all; SSL.Unlock_Task.all;
exception exception
@ -1429,26 +1429,26 @@ package body System.OS_Lib is
Second : Second_Type) return OS_Time Second : Second_Type) return OS_Time
is is
procedure To_OS_Time procedure To_OS_Time
(P_Time_T : Address; (P_OS_Time : Address;
P_Year : Integer; P_Year : Integer;
P_Month : Integer; P_Month : Integer;
P_Day : Integer; P_Day : Integer;
P_Hours : Integer; P_Hours : Integer;
P_Mins : Integer; P_Mins : Integer;
P_Secs : Integer); P_Secs : Integer);
pragma Import (C, To_OS_Time, "__gnat_to_os_time"); pragma Import (C, To_OS_Time, "__gnat_to_os_time");
Result : OS_Time; Result : OS_Time;
begin begin
To_OS_Time To_OS_Time
(P_Time_T => Result'Address, (P_OS_Time => Result'Address,
P_Year => Year - 1900, P_Year => Year - 1900,
P_Month => Month - 1, P_Month => Month - 1,
P_Day => Day, P_Day => Day,
P_Hours => Hour, P_Hours => Hour,
P_Mins => Minute, P_Mins => Minute,
P_Secs => Second); P_Secs => Second);
return Result; return Result;
end GM_Time_Of; end GM_Time_Of;

View File

@ -164,6 +164,14 @@ package System.OS_Lib is
-- component parts to be interpreted in the local time zone, and returns -- component parts to be interpreted in the local time zone, and returns
-- an OS_Time. Returns Invalid_Time if the creation fails. -- 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; subtype time_t is Long_Integer;
-- C time_t type of the time representation -- C time_t type of the time representation