[PATCH] PR ada/54040: [x32] Incorrect timeval and timespec
H.J. Lu
hjl.tools@gmail.com
Thu Nov 14 22:17:00 GMT 2013
On Thu, Nov 14, 2013 at 6:16 AM, Arnaud Charlet <charlet@adacore.com> wrote:
>> I also changed s-osinte-posix.adb and s-osprim-posix.adb
>> for x32. They aren't Linux specific. What should I do with
>> them?
>
> I would use the time_t type defined in s-osinte* (all POSIX implementations
> of s-osinte* have such definition, or if they don't, it's easy to add), and
> in the s-osinte-linux version we can have a renaming:
>
> subtype time_t is System.Linux.time_t
>
> and in System.Linux have either:
>
> type time_t is new Long_Integer;
>
> or
>
> type time_t is new Long_Long_Integer;
>
> depending on the variant.
>
> Arno
Please bear with me. I know next to nothing about Ada.
I tried:
diff --git a/gcc/ada/s-linux.ads b/gcc/ada/s-linux.ads
index c8a7ad1..6244ca7 100644
--- a/gcc/ada/s-linux.ads
+++ b/gcc/ada/s-linux.ads
@@ -38,6 +38,24 @@
package System.Linux is
pragma Preelaborate;
+ ------------
+ -- time_t --
+ ------------
+
+ type time_t is new Long_Integer;
+
+ ---------------
+ -- tv_nsec_t --
+ ---------------
+
+ type tv_nsec_t is new Long_Integer;
+
+ -----------------------
+ -- timeval_element_t --
+ -----------------------
+
+ type timeval_element_t is new Long_Integer;
+
-----------
-- Errno --
-----------
diff --git a/gcc/ada/s-osinte-linux.ads b/gcc/ada/s-osinte-linux.ads
index a99c4e5..6fbe13a 100644
--- a/gcc/ada/s-osinte-linux.ads
+++ b/gcc/ada/s-osinte-linux.ads
@@ -596,11 +596,12 @@ private
type pid_t is new int;
- type time_t is new long;
+ subtype time_t is System.Linux.time_t;
+ subtype tv_nsec_t is System.Linux.tv_nsec_t;
type timespec is record
tv_sec : time_t;
- tv_nsec : long;
+ tv_nsec : tv_nsec_t;
end record;
pragma Convention (C, timespec);
and got
s-osinte.adb:102:17: operator for type "System.Linux.time_t" is not
directly visible
s-osinte.adb:102:17: use clause would make operation legal
s-osinte.adb:107:35: expected type "System.Linux.tv_nsec_t"
s-osinte.adb:107:35: found type "Interfaces.C.long"
make[7]: *** [s-osinte.o] Error 1
How do I resolve this?
Thanks.
--
H.J.
More information about the Gcc-patches
mailing list