From c70220382300ae326ad63fe54c5a32da202d1f13 Mon Sep 17 00:00:00 2001 From: Dmitriy Anisimkov Date: Mon, 19 Aug 2019 08:37:13 +0000 Subject: [PATCH] [Ada] Conversion routines between GNAT.OS_Lib.OS_Time and long integer The new routines convert back and forth between private type OS_Time and a long integer which can be used in package Ada.Calendar.Conversions routines to convert to Ada.Calendar.Time. 2019-08-19 Dmitriy Anisimkov gcc/ada/ * libgnat/s-os_lib.ads, libgnat/s-os_lib.adb (To_Ada, To_C): New routines. From-SVN: r274661 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/libgnat/s-os_lib.adb | 18 ++++++++++++++++++ gcc/ada/libgnat/s-os_lib.ads | 11 +++++++++++ 3 files changed, 34 insertions(+) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 499a4896b90..932ff97f2c1 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-08-19 Dmitriy Anisimkov + + * libgnat/s-os_lib.ads, libgnat/s-os_lib.adb (To_Ada, To_C): New + routines. + 2019-08-19 Bob Duff * exp_attr.adb (Attribute_Valid): Correct the handling of diff --git a/gcc/ada/libgnat/s-os_lib.adb b/gcc/ada/libgnat/s-os_lib.adb index c3c1979ec9e..258cd64d312 100644 --- a/gcc/ada/libgnat/s-os_lib.adb +++ b/gcc/ada/libgnat/s-os_lib.adb @@ -2979,6 +2979,15 @@ package body System.OS_Lib is end loop; end Spawn_Internal; + ------------ + -- To_Ada -- + ------------ + + function To_Ada (Time : time_t) return OS_Time is + begin + return OS_Time (Time); + end To_Ada; + --------------------------- -- To_Path_String_Access -- --------------------------- @@ -3008,6 +3017,15 @@ package body System.OS_Lib is return Return_Val; end To_Path_String_Access; + ---------- + -- To_C -- + ---------- + + function To_C (Time : OS_Time) return time_t is + begin + return time_t (Time); + end To_C; + ------------------ -- Wait_Process -- ------------------ diff --git a/gcc/ada/libgnat/s-os_lib.ads b/gcc/ada/libgnat/s-os_lib.ads index 3e8c21d78b1..99406e9a77d 100644 --- a/gcc/ada/libgnat/s-os_lib.ads +++ b/gcc/ada/libgnat/s-os_lib.ads @@ -164,6 +164,15 @@ 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. + subtype time_t is Long_Integer; + -- C time_t type of the time representation + + function To_C (Time : OS_Time) return time_t; + -- Convert OS_Time to C time_t type + + function To_Ada (Time : time_t) return OS_Time; + -- Convert C time_t type to OS_Time + ---------------- -- File Stuff -- ---------------- @@ -1107,6 +1116,8 @@ private pragma Inline (">"); pragma Inline ("<="); pragma Inline (">="); + pragma Inline (To_C); + pragma Inline (To_Ada); type Process_Id is new Integer; Invalid_Pid : constant Process_Id := -1; -- 2.30.2