This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][Ada] Fix tasking on sparc64-linux (122 ACATS FAIL => 1 FAIL)


On Fri, 2009-11-20 at 09:36 +0100, Eric Botcazou wrote:
> > Ok for SOSC for 4.5 then, what is the patch scheme you have in mind?
> > There are 21 files depending on tv_usec (outside socket stuff):
> 
> Yes, that's somewhat intrusive.  What about trying to eliminate struct_timeval 
> from System.OS_Interface when possible first?  It seems to be unused, except 
> for Linux, and the interface isn't correct.  Then we'll decide what to do for 
> Linux.

I tested successfully the patch below on x86_64-linux (-m32/64) and
sparc64-linux, it is reusing the cal.c scheme for timeval_to_duration
and so doesn't change any dependancy or Makefile.

Let me know if this is the approach you had in mind.

Sincerely,

Laurent

Index: s-osinte-linux.ads
===================================================================
--- s-osinte-linux.ads	(revision 154361)
+++ s-osinte-linux.ads	(working copy)
@@ -228,19 +228,6 @@
    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: s-osinte-posix.adb
===================================================================
--- s-osinte-posix.adb	(revision 154361)
+++ s-osinte-posix.adb	(working copy)
@@ -74,11 +74,6 @@
       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 @@
                        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: s-osprim-posix.adb
===================================================================
--- s-osprim-posix.adb	(revision 154361)
+++ s-osprim-posix.adb	(working copy)
@@ -38,26 +38,8 @@
    --  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 @@
    -----------
 
    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 @@
       --  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: s-taprop-linux.adb
===================================================================
--- s-taprop-linux.adb	(revision 154361)
+++ s-taprop-linux.adb	(working copy)
@@ -589,12 +589,32 @@
    ---------------------
 
    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;
 
    -------------------




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]