]> gcc.gnu.org Git - gcc.git/commitdiff
s-os_lib.ads, [...] (GM_Time_Of): New routine to create an OS_Time from time parts.
authorPascal Obry <obry@adacore.com>
Fri, 18 Jul 2014 09:31:36 +0000 (09:31 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 18 Jul 2014 09:31:36 +0000 (11:31 +0200)
2014-07-18  Pascal Obry  <obry@adacore.com>

* s-os_lib.ads, s-os_lib.adb (GM_Time_Of): New routine to create an
OS_Time from time parts.
* adaint.h, adaint.c (__gnat_to_os_time): New routine.

From-SVN: r212788

gcc/ada/ChangeLog
gcc/ada/adaint.c
gcc/ada/adaint.h
gcc/ada/s-os_lib.adb
gcc/ada/s-os_lib.ads

index 7321d41992ec022d88ea7a68bcd7e39db73c4b2a..897853b0bf183614f894edeb88b25e702ad1785e 100644 (file)
@@ -1,3 +1,9 @@
+2014-07-18  Pascal Obry  <obry@adacore.com>
+
+       * s-os_lib.ads, s-os_lib.adb (GM_Time_Of): New routine to create an
+       OS_Time from time parts.
+       * adaint.h, adaint.c (__gnat_to_os_time): New routine.
+
 2014-07-18  Ed Schonberg  <schonberg@adacore.com>
 
        * sem_ch4.adb (Try_Container_Indexing): Refine previous patch for
index 607ba8257295a06fc1f1f8ef26529d108e450563..6e0e4a3db0ef23cb237ed405ddc6fcb8eb2c84a9 100644 (file)
@@ -503,6 +503,25 @@ __gnat_to_gm_time (OS_Time *p_time, int *p_year, int *p_month, int *p_day,
     *p_year = *p_month = *p_day = *p_hours = *p_mins = *p_secs = 0;
 }
 
+void
+__gnat_to_os_time (OS_Time *p_time, int year, int month, int day,
+                  int hours, int mins, int secs)
+{
+  struct tm v;
+
+  v.tm_year  = year;
+  v.tm_mon   = month;
+  v.tm_mday  = day;
+  v.tm_hour  = hours;
+  v.tm_min   = mins;
+  v.tm_sec   = secs;
+  v.tm_isdst = 0;
+
+  /* returns -1 of failing, this is s-os_lib Invalid_Time */
+
+  *p_time = (OS_Time) mktime (&v);
+}
+
 /* Place the contents of the symbolic link named PATH in the buffer BUF,
    which has size BUFSIZ.  If PATH is a symbolic link, then return the number
    of characters of its content in BUF.  Otherwise, return -1.
index 3c3e4760c70fb89fdf798c929c89dd4fa84c2010..f6b6f69fb66bfa2d25ee6415bbd12e4d515fc9af 100644 (file)
@@ -107,6 +107,8 @@ extern void   __gnat_current_time_string           (char *);
 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,
+                                                    int, int, int);
 extern int    __gnat_get_maximum_file_name_length  (void);
 extern int    __gnat_get_switches_case_sensitive   (void);
 extern int    __gnat_get_file_names_case_sensitive (void);
index 17ac32e3bdb9f3c6c31485eca8e87ac6b87e4240..796fe08f5e320b7e9934cacdc3f1cdb673ee9669 100644 (file)
@@ -1308,6 +1308,28 @@ package body System.OS_Lib is
       Second := S;
    end GM_Split;
 
+   ----------------
+   -- GM_Time_Of --
+   ----------------
+
+   function GM_Time_Of
+     (Year   : Year_Type;
+      Month  : Month_Type;
+      Day    : Day_Type;
+      Hour   : Hour_Type;
+      Minute : Minute_Type;
+      Second : Second_Type) return OS_Time
+   is
+      procedure To_OS_Time
+        (P_Time_T : Address; Year, Month, Day, Hours, Mins, Secs : Integer);
+      pragma Import (C, To_OS_Time, "__gnat_to_os_time");
+      Result : OS_Time;
+   begin
+      To_OS_Time
+        (Result'Address, Year - 1900, Month - 1, Day, Hour, Minute, Second);
+      return Result;
+   end GM_Time_Of;
+
    -------------
    -- GM_Year --
    -------------
index 9552d8626fd5421785557537653358cbd0ae7ee4..810d7d4414a187c47298862c75b5e292c1a6f94c 100644 (file)
@@ -152,6 +152,17 @@ package System.OS_Lib is
    --  provides a representation of it as a set of component parts, to be
    --  interpreted as a date point in UTC.
 
+   function GM_Time_Of
+     (Year   : Year_Type;
+      Month  : Month_Type;
+      Day    : Day_Type;
+      Hour   : Hour_Type;
+      Minute : Minute_Type;
+      Second : Second_Type) return OS_Time;
+   --  Analogous to the Time_Of routine in Ada.Calendar, takes a set of
+   --  time component parts and returns an OS_Time. Returns Invalid_Time
+   --  if the creation fails.
+
    ----------------
    -- File Stuff --
    ----------------
This page took 0.071154 seconds and 5 git commands to generate.