https://gcc.gnu.org/g:0b8864e64121122b45a3fead333254f38467b816
commit r17-1196-g0b8864e64121122b45a3fead333254f38467b816 Author: Piotr Trojanek <[email protected]> Date: Tue Apr 14 00:14:54 2026 +0200 ada: Simplify interfacing with gmtime wrapper Interface from Ada to C for calling gmtime was over-complicated. Now we just rely on the Ada RM and what it guarantees when interfacing for parameters of elementary types depending on their IN/OUT mode. gcc/ada/ChangeLog: * adaint.c, adaint.h (__gnat_to_gm_time): Adapt C side, while keeping the explicit conversion to time_t, if this ever needs to be debugged. * libgnat/s-os_lib.adb (To_GM_Time): Adapt Ada side. Diff: --- gcc/ada/adaint.c | 4 ++-- gcc/ada/adaint.h | 2 +- gcc/ada/libgnat/s-os_lib.adb | 29 ++++++++++++++--------------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index 95351a5f4ef7..5fb255717746 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -444,11 +444,11 @@ __gnat_current_time_string (char *result) } void -__gnat_to_gm_time (OS_Time *p_time, int *p_year, int *p_month, int *p_day, +__gnat_to_gm_time (OS_Time date, int *p_year, int *p_month, int *p_day, int *p_hours, int *p_mins, int *p_secs) { struct tm *res; - time_t time = (time_t) *p_time; + time_t time = (time_t) date; res = gmtime (&time); if (res) diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h index ca92e08f8585..c8973c16cdef 100644 --- a/gcc/ada/adaint.h +++ b/gcc/ada/adaint.h @@ -146,7 +146,7 @@ extern int __gnat_in_child_after_fork; extern OS_Time __gnat_current_time (void); extern void __gnat_current_time_string (char *); -extern void __gnat_to_gm_time (OS_Time *, int *, int *, +extern void __gnat_to_gm_time (OS_Time, int *, int *, int *, int *, int *, int *); extern void __gnat_to_os_time (OS_Time *, int, int, int, diff --git a/gcc/ada/libgnat/s-os_lib.adb b/gcc/ada/libgnat/s-os_lib.adb index df11e75afc92..ae8ef2b1a08b 100644 --- a/gcc/ada/libgnat/s-os_lib.adb +++ b/gcc/ada/libgnat/s-os_lib.adb @@ -1304,16 +1304,15 @@ package body System.OS_Lib is Second : out Second_Type) is procedure To_GM_Time - (P_OS_Time : Address; - P_Year : Address; - P_Month : Address; - P_Day : Address; - P_Hours : Address; - P_Mins : Address; - P_Secs : Address); + (Date : OS_Time; + P_Year : out Integer; + P_Month : out Integer; + P_Day : out Integer; + P_Hours : out Integer; + P_Mins : out Integer; + P_Secs : out Integer); pragma Import (C, To_GM_Time, "__gnat_to_gm_time"); - T : OS_Time := Date; Y : Integer; Mo : Integer; D : Integer; @@ -1342,13 +1341,13 @@ package body System.OS_Lib is Locked_Processing : begin SSL.Lock_Task.all; To_GM_Time - (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); + (Date => Date, + P_Year => Y, + P_Month => Mo, + P_Day => D, + P_Hours => H, + P_Mins => Mn, + P_Secs => S); SSL.Unlock_Task.all; exception
