diff mbox

Please revert the patches in bug #54040 and #59346 and special case x32

Message ID 174636620.hURAyCpPt0@polaris
State New
Headers show

Commit Message

Eric Botcazou April 9, 2014, 11:28 a.m. UTC
> The only changes I've found are: (in the previously attached patch)
> (the other commits refer to
> 2014-01-26: lynxos
> 2014-01-24: android
> 2014-01-20: linux
> 2013-01-29 : vms
> and they are not related to the patches needing a revert.

OK, thanks for the clarification.  Let's try to find a middle ground though so 
that Linux/x32 is not totally broken.

I think that we definitely want to revert the s-osinte-posix.adb change, which 
is a blatant violation of POSIX.  Which means that Linux/x32 cannot use that 
file and we therefore need s-osinte-x32.adb, but the file is relatively small.

In order to avoid creating more x32-specific files, I think that we need to 
move the definition of 'struct timespec' and 'struct timeval' (both specified 
by POSIX) to s-linux.ads.  This requires with'ing Interfaces.C, but I think 
that's OK since s-linux.ads is a spin-off of s-osinte-linux.ads which also 
with'es Interfaces.C.

What do you think, Arno?  I think that the POSIX breakage (and its fallout for 
the other Unices) is ugly and worth the additional complication.


	PR ada/54040
	PR ada/59346
	* s-osinte-x32.adb: New file.
	* s-linux.ads (Time): New section.
	* s-linux-alpha.ads (Time): Likewise.
	* s-linux-android.ads (Time: Likewise.
	* s-linux-hppa.ads (Time): Likewise.
	* s-linux-mipsel.ads (Time): Likewise.
	* s-linux-sparc.ads (Time): Likewise.
	* s-linux-x32.ads (Time): Likewise.
	* s-osinte-linux.ads (Time): Define local subtypes for those defined
	in System.Linux.
	* s-taprop-linux.adb (Monotonic_Clock): Do not define timeval.
	* s-osinte-hpux.ads (timespec): Revert POSIX breakage.
	* s-osinte-kfreebsd-gnu.ads (timespec): Likewise.
	* s-osinte-solaris-posix.ads (timespec): Likewise.
	* s-osinte-posix.adb (To_Timespec): Likewise.
	* gcc-interface/Makefile.in (x32/Linux): Use s-osinte-x32.adb.

Comments

Arnaud Charlet April 9, 2014, 12:41 p.m. UTC | #1
> What do you think, Arno?  I think that the POSIX breakage (and its fallout for
> the other Unices) is ugly and worth the additional complication.

Yes, your patch looks good to me.

Arno
Svante Signell April 9, 2014, 1:58 p.m. UTC | #2
On Wed, 2014-04-09 at 14:41 +0200, Arnaud Charlet wrote:
> > What do you think, Arno?  I think that the POSIX breakage (and its fallout for
> > the other Unices) is ugly and worth the additional complication.
> 
> Yes, your patch looks good to me.

Would it be possible to have s-osinte-posix.adb also for x32 and in
s-osinte-x32.ads use the following construct:
...
   type timespec is private;
...
   type timespec is record
      tv_sec  : time_t;
      tv_nsec : long log;
   end record;
   pragma Convention (C, timespec);

and similiar for timeval if needed?

That's the construct other unices use now when s-osinte-posix.adb
defines tv_nsec as time_t?
Eric Botcazou April 9, 2014, 2:24 p.m. UTC | #3
> Would it be possible to have s-osinte-posix.adb also for x32 and in
> s-osinte-x32.ads use the following construct:
> ...
>    type timespec is private;
> ...
>    type timespec is record
>       tv_sec  : time_t;
>       tv_nsec : long log;
>    end record;
>    pragma Convention (C, timespec);
> 
> and similiar for timeval if needed?
> 
> That's the construct other unices use now when s-osinte-posix.adb
> defines tv_nsec as time_t?

Not sure what the "now" is referring to, but if you want to revert the 
original POSIX breakage in s-osinte-posix.adb, you need to define timespec 
according to the POSIX spec, there is no other way.
Eric Botcazou April 9, 2014, 2:55 p.m. UTC | #4
> Yes, your patch looks good to me.

Thanks, now applied.  I'll make sure everything is resynced with it.
Svante Signell April 9, 2014, 3:18 p.m. UTC | #5
On Wed, 2014-04-09 at 16:24 +0200, Eric Botcazou wrote:
> > Would it be possible to have s-osinte-posix.adb also for x32 and in
> > s-osinte-x32.ads use the following construct:
> > ...
> >    type timespec is private;
> > ...
> >    type timespec is record
> >       tv_sec  : time_t;
> >       tv_nsec : long long;
> >    end record;
> >    pragma Convention (C, timespec);
> > 
> > and similiar for timeval if needed?
> > 
> > That's the construct other unices use now when s-osinte-posix.adb
> > defines tv_nsec as time_t?
> 
> Not sure what the "now" is referring to, but if you want to revert the 
> original POSIX breakage in s-osinte-posix.adb, you need to define timespec 
> according to the POSIX spec, there is no other way.

I thought of creating a new type for x32: 

type nanosec_t is private; 
type nanosec_t is new long long;

  type timespec is record
      tv_sec  : time_t;
      tv_nsec : nanosec_t;
   end record;

Having the correct definition of tv_nsec in s-osinte-posix.adb
   type timespec is record
      tv_sec  : time_t;
      tv_nsec : long;
   end record;
   pragma Convention (C, timespec);
H.J. Lu April 9, 2014, 4:02 p.m. UTC | #6
On Wed, Apr 9, 2014 at 7:55 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> Yes, your patch looks good to me.
>
> Thanks, now applied.  I'll make sure everything is resynced with it.
>

I got

/export/build/gnu/gcc-x32/build-x86_64-linux/./gcc/xgcc
-B/export/build/gnu/gcc-x32/build-x86_64-linux/./gcc/
-B/usr/gcc-4.9.0-x32/x86_64-unknown-linux-gnu/bin/
-B/usr/gcc-4.9.0-x32/x86_64-unknown-linux-gnu/lib/ -isystem
/usr/gcc-4.9.0-x32/x86_64-unknown-linux-gnu/include -isystem
/usr/gcc-4.9.0-x32/x86_64-unknown-linux-gnu/sys-include    -c -g -O2
-mx32 -fpic  -W -Wall -gnatpg -nostdinc -mx32  s-osprim.adb -o
s-osprim.o
s-osprim.adb:121:30: expected type "Standard.Long_Long_Integer"
s-osprim.adb:121:30: found type "System.Os_Primitives.time_t"
make[11]: *** [s-osprim.o] Error 1
Ludovic Brenta April 9, 2014, 7:54 p.m. UTC | #7
Eric Botcazou <ebotcazou@adacore.com> writes:
> In order to avoid creating more x32-specific files, I think that we
> need to move the definition of 'struct timespec' and 'struct timeval'
> (both specified by POSIX) to s-linux.ads.  This requires with'ing
> Interfaces.C, but I think that's OK since s-linux.ads is a spin-off of
> s-osinte-linux.ads which also with'es Interfaces.C.

In my worthless opinion, it is a mistake to declare POSIX data types in
s-linux.ads, they should be in s-posix.ads or similar (don't worry if
that's a new file; and it should not be a "leaf" package).  Think of
GNU/kFreeBSD and GNU/Hurd, which have nothing to do with Linux.
Furthermore there should be only one declaration of type timespec
(i.e. "do not repeat yourself"); that declaration should be in
s-posix.ads and that declaration should "violate" POSIX like so:

with System.OS_Interface;
package System.POSIX is

    type timespec is record
       tv_sec  : time_t;
       tv_nsec : System.OS_Interface.Nanoseconds_T; -- instead of "long"
    end record;
    pragma Convention (C, timespec);

end System.POSIX;

Each platform-specific version of System.OS_Interface should then
declare their own type Nanoseconds_T.  The version for x32 would declare

   type Nanoseconds_T is new Long_Long_Integer;
   -- or perhaps range -2**63 .. 2**63-1 to be more explicit?

thereby really violating POSIX but all others would declare

   type Nanoseconds_T is new Interfaces.C.long;

thereby restoring compliance with POSIX.

I'm really sorry that I don't have the time to propose a proper patch
but if someone does, I'd be happy to review it.
Eric Botcazou April 9, 2014, 9:10 p.m. UTC | #8
> In my worthless opinion, it is a mistake to declare POSIX data types in
> s-linux.ads, they should be in s-posix.ads or similar (don't worry if
> that's a new file; and it should not be a "leaf" package).  Think of
> GNU/kFreeBSD and GNU/Hurd, which have nothing to do with Linux.
> Furthermore there should be only one declaration of type timespec
> (i.e. "do not repeat yourself"); that declaration should be in
> s-posix.ads and that declaration should "violate" POSIX like so:

Right, but you should have posted this message a couple of decades ago when 
this stuff was designed.  We cannot turn everything upside down now, sorry.
diff mbox

Patch

Index: s-osinte-linux.ads
===================================================================
--- s-osinte-linux.ads	(revision 209236)
+++ s-osinte-linux.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                  S p e c                                 --
 --                                                                          --
 --             Copyright (C) 1991-1994, Florida State University            --
---          Copyright (C) 1995-2013, Free Software Foundation, Inc.         --
+--          Copyright (C) 1995-2014, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -217,8 +217,9 @@  package System.OS_Interface is
    -- Time --
    ----------
 
-   type timespec is private;
-   type time_t is private;
+   subtype time_t   is System.Linux.time_t;
+   subtype timespec is System.Linux.timespec;
+   subtype timeval  is System.Linux.timeval;
 
    function To_Duration (TS : timespec) return Duration;
    pragma Inline (To_Duration);
@@ -598,14 +599,6 @@  private
 
    type pid_t is new int;
 
-   type time_t is new System.Linux.time_t;
-
-   type timespec is record
-      tv_sec  : time_t;
-      tv_nsec : time_t;
-   end record;
-   pragma Convention (C, timespec);
-
    type unsigned_long_long_t is mod 2 ** 64;
    --  Local type only used to get the alignment of this type below
 
Index: s-osinte-hpux.ads
===================================================================
--- s-osinte-hpux.ads	(revision 209236)
+++ s-osinte-hpux.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                  S p e c                                 --
 --                                                                          --
 --               Copyright (C) 1991-1994, Florida State University          --
---            Copyright (C) 1995-2013, Free Software Foundation, Inc.       --
+--            Copyright (C) 1995-2014, Free Software Foundation, Inc.       --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -522,7 +522,7 @@  private
 
    type timespec is record
       tv_sec  : time_t;
-      tv_nsec : time_t;
+      tv_nsec : long;
    end record;
    pragma Convention (C, timespec);
 
Index: s-linux-android.ads
===================================================================
--- s-linux-android.ads	(revision 209236)
+++ s-linux-android.ads	(working copy)
@@ -35,14 +35,30 @@ 
 --  PLEASE DO NOT add any with-clauses to this package or remove the pragma
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package
 
+with Interfaces.C;
+
 package System.Linux is
    pragma Preelaborate;
 
-   ------------
-   -- time_t --
-   ------------
+   ----------
+   -- Time --
+   ----------
+
+   subtype long        is Interfaces.C.long;
+   subtype suseconds_t is Interfaces.C.long;
+   subtype time_t      is Interfaces.C.long;
+
+   type timespec is record
+      tv_sec  : time_t;
+      tv_nsec : long;
+   end record;
+   pragma Convention (C, timespec);
 
-   type time_t is new Long_Integer;
+   type timeval is record
+      tv_sec  : time_t;
+      tv_usec : suseconds_t;
+   end record;
+   pragma Convention (C, timeval);
 
    -----------
    -- Errno --
Index: s-osinte-kfreebsd-gnu.ads
===================================================================
--- s-osinte-kfreebsd-gnu.ads	(revision 209236)
+++ s-osinte-kfreebsd-gnu.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                  S p e c                                 --
 --                                                                          --
 --               Copyright (C) 1991-1994, Florida State University          --
---            Copyright (C) 1995-2013, Free Software Foundation, Inc.       --
+--            Copyright (C) 1995-2014, Free Software Foundation, Inc.       --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -492,7 +492,7 @@  private
 
    type timespec is record
       tv_sec  : time_t;
-      tv_nsec : time_t;
+      tv_nsec : long;
    end record;
    pragma Convention (C, timespec);
 
Index: s-linux-hppa.ads
===================================================================
--- s-linux-hppa.ads	(revision 209236)
+++ s-linux-hppa.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                  S p e c                                 --
 --                                                                          --
---          Copyright (C) 2008-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 2008-2014, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -35,14 +35,30 @@ 
 --  PLEASE DO NOT add any with-clauses to this package or remove the pragma
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package.
 
+with Interfaces.C;
+
 package System.Linux is
    pragma Preelaborate;
 
-   ------------
-   -- time_t --
-   ------------
-
-   type time_t is new Long_Integer;
+   ----------
+   -- Time --
+   ----------
+
+   subtype long        is Interfaces.C.long;
+   subtype suseconds_t is Interfaces.C.long;
+   subtype time_t      is Interfaces.C.long;
+
+   type timespec is record
+      tv_sec  : time_t;
+      tv_nsec : long;
+   end record;
+   pragma Convention (C, timespec);
+
+   type timeval is record
+      tv_sec  : time_t;
+      tv_usec : suseconds_t;
+   end record;
+   pragma Convention (C, timeval);
 
    -----------
    -- Errno --
Index: s-osinte-x32.adb
===================================================================
--- s-osinte-x32.adb	(revision 0)
+++ s-osinte-x32.adb	(revision 0)
@@ -0,0 +1,109 @@ 
+------------------------------------------------------------------------------
+--                                                                          --
+--                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
+--                                                                          --
+--                   S Y S T E M . O S _ I N T E R F A C E                  --
+--                                                                          --
+--                                   B o d y                                --
+--                                                                          --
+--             Copyright (C) 1991-1994, Florida State University            --
+--                     Copyright (C) 1995-2014, AdaCore                     --
+--                                                                          --
+-- GNAT is free software;  you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
+--                                                                          --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.               --
+--                                                                          --
+-- You should have received a copy of the GNU General Public License and    --
+-- a copy of the GCC Runtime Library Exception along with this program;     --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
+-- <http://www.gnu.org/licenses/>.                                          --
+--                                                                          --
+-- GNARL was developed by the GNARL team at Florida State University.       --
+-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
+--                                                                          --
+------------------------------------------------------------------------------
+
+--  This version is for Linux/x32
+
+pragma Polling (Off);
+--  Turn off polling, we do not want ATC polling to take place during
+--  tasking operations. It causes infinite loops and other problems.
+
+--  This package encapsulates all direct interfaces to OS services
+--  that are needed by children of System.
+
+with Interfaces.C; use Interfaces.C;
+package body System.OS_Interface is
+
+   --------------------
+   -- Get_Stack_Base --
+   --------------------
+
+   function Get_Stack_Base (thread : pthread_t) return Address is
+      pragma Warnings (Off, thread);
+
+   begin
+      return Null_Address;
+   end Get_Stack_Base;
+
+   ------------------
+   -- pthread_init --
+   ------------------
+
+   procedure pthread_init is
+   begin
+      null;
+   end pthread_init;
+
+   -----------------
+   -- To_Duration --
+   -----------------
+
+   function To_Duration (TS : timespec) return Duration is
+   begin
+      return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
+   end To_Duration;
+
+   ------------------------
+   -- To_Target_Priority --
+   ------------------------
+
+   function To_Target_Priority
+     (Prio : System.Any_Priority) return Interfaces.C.int
+   is
+   begin
+      return Interfaces.C.int (Prio);
+   end To_Target_Priority;
+
+   -----------------
+   -- To_Timespec --
+   -----------------
+
+   function To_Timespec (D : Duration) return timespec 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 timespec'(tv_sec => S,
+                       tv_nsec => Long_Long_Integer (F * 10#1#E9));
+   end To_Timespec;
+
+end System.OS_Interface;
Index: s-taprop-linux.adb
===================================================================
--- s-taprop-linux.adb	(revision 209236)
+++ s-taprop-linux.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                  B o d y                                 --
 --                                                                          --
---         Copyright (C) 1992-2012, Free Software Foundation, Inc.          --
+--         Copyright (C) 1992-2014, Free Software Foundation, Inc.          --
 --                                                                          --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -627,8 +627,6 @@  package body System.Task_Primitives.Oper
    function Monotonic_Clock return Duration is
       use Interfaces;
 
-      type timeval is array (1 .. 2) of System.OS_Interface.time_t;
-
       procedure timeval_to_duration
         (T    : not null access timeval;
          sec  : not null access C.long;
Index: s-osinte-solaris-posix.ads
===================================================================
--- s-osinte-solaris-posix.ads	(revision 209236)
+++ s-osinte-solaris-posix.ads	(working copy)
@@ -7,7 +7,7 @@ 
 --                                  S p e c                                 --
 --                                                                          --
 --             Copyright (C) 1991-1994, Florida State University            --
---          Copyright (C) 1995-2013, Free Software Foundation, Inc.         --
+--          Copyright (C) 1995-2014, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -513,7 +513,7 @@  private
 
    type timespec is record
       tv_sec  : time_t;
-      tv_nsec : time_t;
+      tv_nsec : long;
    end record;
    pragma Convention (C, timespec);
 
Index: s-linux-x32.ads
===================================================================
--- s-linux-x32.ads	(revision 209236)
+++ s-linux-x32.ads	(working copy)
@@ -6,7 +6,8 @@ 
 --                                                                          --
 --                                  S p e c                                 --
 --                                                                          --
---          Copyright (C) 2013, Free Software Foundation, Inc.              --
+--             Copyright (C) 2013-2014, Free Software Foundation, Inc.      --
+--
 --                                                                          --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -38,12 +39,24 @@ 
 package System.Linux is
    pragma Preelaborate;
 
-   ------------
-   -- time_t --
-   ------------
+   ----------
+   -- Time --
+   ----------
 
    type time_t is new Long_Long_Integer;
 
+   type timespec is record
+      tv_sec  : time_t;
+      tv_nsec : Long_Long_Integer;
+   end record;
+   pragma Convention (C, timespec);
+
+   type timeval is record
+      tv_sec  : time_t;
+      tv_usec : Long_Long_Integer;
+   end record;
+   pragma Convention (C, timeval);
+
    -----------
    -- Errno --
    -----------
Index: s-linux.ads
===================================================================
--- s-linux.ads	(revision 209236)
+++ s-linux.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                  S p e c                                 --
 --                                                                          --
---          Copyright (C) 2008-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 2008-2014, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -35,14 +35,30 @@ 
 --  PLEASE DO NOT add any with-clauses to this package or remove the pragma
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package
 
+with Interfaces.C;
+
 package System.Linux is
    pragma Preelaborate;
 
-   ------------
-   -- time_t --
-   ------------
-
-   type time_t is new Long_Integer;
+   ----------
+   -- Time --
+   ----------
+
+   subtype long        is Interfaces.C.long;
+   subtype suseconds_t is Interfaces.C.long;
+   subtype time_t      is Interfaces.C.long;
+
+   type timespec is record
+      tv_sec  : time_t;
+      tv_nsec : long;
+   end record;
+   pragma Convention (C, timespec);
+
+   type timeval is record
+      tv_sec  : time_t;
+      tv_usec : suseconds_t;
+   end record;
+   pragma Convention (C, timeval);
 
    -----------
    -- Errno --
Index: s-osinte-posix.adb
===================================================================
--- s-osinte-posix.adb	(revision 209236)
+++ s-osinte-posix.adb	(working copy)
@@ -7,7 +7,7 @@ 
 --                                   B o d y                                --
 --                                                                          --
 --             Copyright (C) 1991-1994, Florida State University            --
---                     Copyright (C) 1995-2010, AdaCore                     --
+--                     Copyright (C) 1995-2014, AdaCore                     --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -30,8 +30,7 @@ 
 --                                                                          --
 ------------------------------------------------------------------------------
 
---  This is a GNU/LinuxThreads, Solaris pthread and HP-UX pthread version
---  of this package.
+--  This version is for POSIX-like operating systems
 
 pragma Polling (Off);
 --  Turn off polling, we do not want ATC polling to take place during
@@ -104,7 +103,7 @@  package body System.OS_Interface is
       end if;
 
       return timespec'(tv_sec => S,
-                       tv_nsec => time_t (Long_Long_Integer (F * 10#1#E9)));
+                       tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
    end To_Timespec;
 
 end System.OS_Interface;
Index: s-linux-sparc.ads
===================================================================
--- s-linux-sparc.ads	(revision 209236)
+++ s-linux-sparc.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                  S p e c                                 --
 --                                                                          --
---             Copyright (C) 2009-2011, Free Software Foundation, Inc.      --
+--             Copyright (C) 2009-2014, Free Software Foundation, Inc.      --
 --                                                                          --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -35,14 +35,30 @@ 
 --  PLEASE DO NOT add any with-clauses to this package or remove the pragma
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package
 
+with Interfaces.C;
+
 package System.Linux is
    pragma Preelaborate;
 
-   ------------
-   -- time_t --
-   ------------
-
-   type time_t is new Long_Integer;
+   ----------
+   -- Time --
+   ----------
+
+   subtype long        is Interfaces.C.long;
+   subtype suseconds_t is Interfaces.C.long;
+   subtype time_t      is Interfaces.C.long;
+
+   type timespec is record
+      tv_sec  : time_t;
+      tv_nsec : long;
+   end record;
+   pragma Convention (C, timespec);
+
+   type timeval is record
+      tv_sec  : time_t;
+      tv_usec : suseconds_t;
+   end record;
+   pragma Convention (C, timeval);
 
    -----------
    -- Errno --
Index: gcc-interface/Makefile.in
===================================================================
--- gcc-interface/Makefile.in	(revision 209236)
+++ gcc-interface/Makefile.in	(working copy)
@@ -2239,7 +2239,7 @@  ifeq ($(strip $(filter-out %x32 linux%,$
   s-linux.ads<s-linux-x32.ads \
   s-mudido.adb<s-mudido-affinity.adb \
   s-osinte.ads<s-osinte-linux.ads \
-  s-osinte.adb<s-osinte-posix.adb \
+  s-osinte.adb<s-osinte-x32.adb \
   s-osprim.adb<s-osprim-x32.adb \
   s-taprop.adb<s-taprop-linux.adb \
   s-tasinf.ads<s-tasinf-linux.ads \
Index: s-linux-alpha.ads
===================================================================
--- s-linux-alpha.ads	(revision 209236)
+++ s-linux-alpha.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                  S p e c                                 --
 --                                                                          --
---          Copyright (C) 2009-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 2009-2014, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -35,14 +35,30 @@ 
 --  PLEASE DO NOT add any with-clauses to this package or remove the pragma
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package.
 
+with Interfaces.C;
+
 package System.Linux is
    pragma Preelaborate;
 
-   ------------
-   -- time_t --
-   ------------
-
-   type time_t is new Long_Integer;
+   ----------
+   -- Time --
+   ----------
+
+   subtype long        is Interfaces.C.long;
+   subtype suseconds_t is Interfaces.C.long;
+   subtype time_t      is Interfaces.C.long;
+
+   type timespec is record
+      tv_sec  : time_t;
+      tv_nsec : long;
+   end record;
+   pragma Convention (C, timespec);
+
+   type timeval is record
+      tv_sec  : time_t;
+      tv_usec : suseconds_t;
+   end record;
+   pragma Convention (C, timeval);
 
    -----------
    -- Errno --
Index: s-linux-mipsel.ads
===================================================================
--- s-linux-mipsel.ads	(revision 209236)
+++ s-linux-mipsel.ads	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                  S p e c                                 --
 --                                                                          --
---             Copyright (C) 2009-2011, Free Software Foundation, Inc.      --
+--             Copyright (C) 2009-2014, Free Software Foundation, Inc.      --
 --                                                                          --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -34,14 +34,30 @@ 
 --  PLEASE DO NOT add any with-clauses to this package or remove the pragma
 --  Preelaborate. This package is designed to be a bottom-level (leaf) package
 
+with Interfaces.C;
+
 package System.Linux is
    pragma Preelaborate;
 
-   ------------
-   -- time_t --
-   ------------
-
-   type time_t is new Long_Integer;
+   ----------
+   -- Time --
+   ----------
+
+   subtype long        is Interfaces.C.long;
+   subtype suseconds_t is Interfaces.C.long;
+   subtype time_t      is Interfaces.C.long;
+
+   type timespec is record
+      tv_sec  : time_t;
+      tv_nsec : long;
+   end record;
+   pragma Convention (C, timespec);
+
+   type timeval is record
+      tv_sec  : time_t;
+      tv_usec : suseconds_t;
+   end record;
+   pragma Convention (C, timeval);
 
    -----------
    -- Errno --