]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
s-osinte-linux.ads (struct_timeval, [...]): Delete.
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 21 Nov 2009 12:01:11 +0000 (12:01 +0000)
committerLaurent Guerby <guerby@gcc.gnu.org>
Sat, 21 Nov 2009 12:01:11 +0000 (12:01 +0000)
2009-11-21  Eric Botcazou  <ebotcazou@adacore.com>
            Laurent GUERBY  <laurent@guerby.net>

        * s-osinte-linux.ads (struct_timeval, To_Duration, To_Timeval,
        gettimeofday): Delete.
        * s-osinte-posix.adb (To_Duration, To_Timeval): Delete.
        * s-osprim-posix.adb (struct_timezone, struct_timeval,
        gettimeofday): Delete.
        (Clock): Use cal.c timeval_to_duration.
        * s-taprop-linux.adb (Monotonic_Clock): Likewise.

Co-Authored-By: Laurent GUERBY <laurent@guerby.net>
From-SVN: r154407

gcc/ada/ChangeLog
gcc/ada/s-osinte-linux.ads
gcc/ada/s-osinte-posix.adb
gcc/ada/s-osprim-posix.adb
gcc/ada/s-taprop-linux.adb

index 02f4d8cd0a06bf610040041743cbc9ee0081fd3b..86f2bcc3c22b0f155f98cd31072713007113529b 100644 (file)
@@ -1,3 +1,14 @@
+2009-11-21  Eric Botcazou  <ebotcazou@adacore.com>
+            Laurent GUERBY  <laurent@guerby.net>
+
+        * s-osinte-linux.ads (struct_timeval, To_Duration, To_Timeval,
+        gettimeofday): Delete.
+        * s-osinte-posix.adb (To_Duration, To_Timeval): Delete.
+        * s-osprim-posix.adb (struct_timezone, struct_timeval, 
+        gettimeofday): Delete.
+        (Clock): Use cal.c timeval_to_duration.
+        * s-taprop-linux.adb (Monotonic_Clock): Likewise.
+
 2009-11-12  Eric Botcazou  <ebotcazou@adacore.com>
             Laurent GUERBY  <laurent@guerby.net>
 
index 5d2fdccb69f7690c08e654633e89fa1d85b7bf6a..2a620c5504a045427dc4b0cf41b4cc427f3a5f6d 100644 (file)
@@ -228,19 +228,6 @@ package System.OS_Interface is
    function To_Timespec (D : Duration) return timespec;
    pragma Inline (To_Timespec);
 
-   type struct_timeval is private;
-
-   function To_Duration (TV : struct_timeval) return Duration;
-   pragma Inline (To_Duration);
-
-   function To_Timeval (D : Duration) return struct_timeval;
-   pragma Inline (To_Timeval);
-
-   function gettimeofday
-     (tv : access struct_timeval;
-      tz : System.Address := System.Null_Address) return int;
-   pragma Import (C, gettimeofday, "gettimeofday");
-
    function sysconf (name : int) return long;
    pragma Import (C, sysconf);
 
index c6460c2d241efce1480fe3f6a468d962f523cf49..310454ad15c9869812de5e921da26b2c05c9d42b 100644 (file)
@@ -74,11 +74,6 @@ package body System.OS_Interface is
       return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
    end To_Duration;
 
-   function To_Duration (TV : struct_timeval) return Duration is
-   begin
-      return Duration (TV.tv_sec) + Duration (TV.tv_usec) / 10#1#E6;
-   end To_Duration;
-
    ------------------------
    -- To_Target_Priority --
    ------------------------
@@ -114,30 +109,4 @@ package body System.OS_Interface is
                        tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
    end To_Timespec;
 
-   ----------------
-   -- To_Timeval --
-   ----------------
-
-   function To_Timeval (D : Duration) return struct_timeval is
-      S : time_t;
-      F : Duration;
-
-   begin
-      S := time_t (Long_Long_Integer (D));
-      F := D - Duration (S);
-
-      --  If F has negative value due to a round-up, adjust for positive F
-      --  value.
-
-      if F < 0.0 then
-         S := S - 1;
-         F := F + 1.0;
-      end if;
-
-      return
-        struct_timeval'
-          (tv_sec  => S,
-           tv_usec => time_t (Long_Long_Integer (F * 10#1#E6)));
-   end To_Timeval;
-
 end System.OS_Interface;
index c02ad98380c988ef776c12ffba47f2f0a7ab2fed..e03a132c8a3b0083ae07ae961c979e50dd84b01f 100644 (file)
@@ -38,26 +38,8 @@ package body System.OS_Primitives is
    --  these declarations in System.OS_Interface and move these ones in
    --  the spec.
 
-   type struct_timezone is record
-      tz_minuteswest  : Integer;
-      tz_dsttime   : Integer;
-   end record;
-   pragma Convention (C, struct_timezone);
-   type struct_timezone_ptr is access all struct_timezone;
-
    type time_t is new Long_Integer;
 
-   type struct_timeval is record
-      tv_sec       : time_t;
-      tv_usec      : Long_Integer;
-   end record;
-   pragma Convention (C, struct_timeval);
-
-   function gettimeofday
-     (tv : not null access struct_timeval;
-      tz : struct_timezone_ptr) return Integer;
-   pragma Import (C, gettimeofday, "gettimeofday");
-
    type timespec is record
       tv_sec  : time_t;
       tv_nsec : Long_Integer;
@@ -72,11 +54,26 @@ package body System.OS_Primitives is
    -----------
 
    function Clock return Duration is
-      TV     : aliased struct_timeval;
-
+      type timeval is array (1 .. 2) of Long_Integer;
+
+      procedure timeval_to_duration
+        (T    : not null access timeval;
+         sec  : not null access Long_Integer;
+         usec : not null access Long_Integer);
+      pragma Import (C, timeval_to_duration, "__gnat_timeval_to_duration");
+
+      Micro  : constant := 10**6;
+      sec    : aliased Long_Integer;
+      usec   : aliased Long_Integer;
+      TV     : aliased timeval;
       Result : Integer;
       pragma Unreferenced (Result);
 
+      function gettimeofday
+        (Tv : access timeval;
+         Tz : System.Address := System.Null_Address) return Integer;
+      pragma Import (C, gettimeofday, "gettimeofday");
+
    begin
       --  The return codes for gettimeofday are as follows (from man pages):
       --    EPERM  settimeofday is called by someone other than the superuser
@@ -86,8 +83,9 @@ package body System.OS_Primitives is
       --  None of these codes signal a potential clock skew, hence the return
       --  value is never checked.
 
-      Result := gettimeofday (TV'Access, null);
-      return Duration (TV.tv_sec) + Duration (TV.tv_usec) / 10#1#E6;
+      Result := gettimeofday (TV'Access, System.Null_Address);
+      timeval_to_duration (TV'Access, sec'Access, usec'Access);
+      return Duration (sec) + Duration (usec) / Micro;
    end Clock;
 
    ---------------------
index 46b10a3f1f508e321809b5620cdac7e0ead8da4a..0f0773cec5eb5e4666ddde8ec83b98683337d30c 100644 (file)
@@ -589,12 +589,32 @@ package body System.Task_Primitives.Operations is
    ---------------------
 
    function Monotonic_Clock return Duration is
-      TV     : aliased struct_timeval;
-      Result : Interfaces.C.int;
+      use Interfaces;
+
+      type timeval is array (1 .. 2) of C.long;
+
+      procedure timeval_to_duration
+        (T    : not null access timeval;
+         sec  : not null access C.long;
+         usec : not null access C.long);
+      pragma Import (C, timeval_to_duration, "__gnat_timeval_to_duration");
+
+      Micro  : constant := 10**6;
+      sec    : aliased C.long;
+      usec   : aliased C.long;
+      TV     : aliased timeval;
+      Result : int;
+
+      function gettimeofday
+        (Tv : access timeval;
+         Tz : System.Address := System.Null_Address) return int;
+      pragma Import (C, gettimeofday, "gettimeofday");
+
    begin
       Result := gettimeofday (TV'Access, System.Null_Address);
       pragma Assert (Result = 0);
-      return To_Duration (TV);
+      timeval_to_duration (TV'Access, sec'Access, usec'Access);
+      return Duration (sec) + Duration (usec) / Micro;
    end Monotonic_Clock;
 
    -------------------