]> gcc.gnu.org Git - gcc.git/commitdiff
[Ada] Conversion routines between GNAT.OS_Lib.OS_Time and long integer
authorDmitriy Anisimkov <anisimko@adacore.com>
Mon, 19 Aug 2019 08:37:13 +0000 (08:37 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Mon, 19 Aug 2019 08:37:13 +0000 (08:37 +0000)
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  <anisimko@adacore.com>

gcc/ada/

* libgnat/s-os_lib.ads, libgnat/s-os_lib.adb (To_Ada, To_C): New
routines.

From-SVN: r274661

gcc/ada/ChangeLog
gcc/ada/libgnat/s-os_lib.adb
gcc/ada/libgnat/s-os_lib.ads

index 499a4896b90313dca9370b81f8c28cadc6265fce..932ff97f2c1fee5e26ab3097f8187fcf31aba2d8 100644 (file)
@@ -1,3 +1,8 @@
+2019-08-19  Dmitriy Anisimkov  <anisimko@adacore.com>
+
+       * libgnat/s-os_lib.ads, libgnat/s-os_lib.adb (To_Ada, To_C): New
+       routines.
+
 2019-08-19  Bob Duff  <duff@adacore.com>
 
        * exp_attr.adb (Attribute_Valid): Correct the handling of
index c3c1979ec9e6835351d7211d0cca168388447321..258cd64d312ca6a043f0903ba1bb1cb46dcd66db 100644 (file)
@@ -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 --
    ------------------
index 3e8c21d78b1e193bbdf546abcfea61d7dd0ab88f..99406e9a77dd86660ffcb567c7a08b508c49aaff 100644 (file)
@@ -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;
This page took 0.074461 seconds and 5 git commands to generate.