Please revert the patches in bug #54040 and #59346 and special case x32
Svante Signell
svante.signell@gmail.com
Mon Mar 24 13:48:00 GMT 2014
In reply to the thread ending with:
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg02069.html
and bugs:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54040
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59346
Changing s-osinte-posix.adb
- tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
+ tv_nsec => time_t (Long_Long_Integer (F * 10#1#E9)));
breaks the build for kFreeBSD and Hurd too (in addition to hpux and solaris).
Note that POSIX specified tv_nsec to be long (i.e. 64 bit), see:
http://pubs.opengroup.org/onlinepubs/009695299/basedefs/time.h.html
The <time.h> header shall declare the structure timespec, which has at
least the following members:
time_t tv_sec Seconds.
long tv_nsec Nanoseconds.
Additionally Linux/kFreeBSD/Hurd all defines struct timespec in time.h as follows:
/* POSIX.1b structure for a time value. This is like a `struct timeval'
but
has nanoseconds instead of microseconds. */
struct timespec
{
__time_t tv_sec; /* Seconds. */
__syscall_slong_t tv_nsec; /* Nanoseconds. */
};
So defining tv_nsec to be time_t is completely wrong. The problem seems
to be present only for the x32 architecture, so why not make a special-case
solution for that arch. Obviously x32 is non-POSIX compliant since long
is 32 bits, resulting in tv_nsec being 32 bits where it needs to be 64
bits. Isn't it possible to handle the differences for x32 with a
s-osinte-linux-x32.ads file, even with s-osinte-posix.adb stays intact?
Then ther changes would be limited to:
* s-linux-x32.ads: New file.
* s-osprim-x32.adb: Likewise.
* gcc-interface/Makefile.in (LIBGNAT_TARGET_PAIRS): Replace
s-linux.ads with s-linux-x32.ads, s-osprim-posix.adb with
s-osprim-x32.adb for x32.
and the rest would be obsolete:
* s-linux.ads (time_t): New type.
* s-linux-alpha.ads (time_t): Likewise.
* s-linux-hppa.ads (time_t): Likewise.
* s-linux-mipsel.ads (time_t): Likewise.
* s-linux-sparc.ads (time_t): Likewise.
* s-osinte-linux.ads (time_t): Mark it private. Replace long
with System.Linux.time_t.
(timespec): Replace long with time_t.
* s-osinte-posix.adb (To_Timespec): Likewise.
* s-taprop-linux.adb (timeval): Replace C.long with
System.OS_Interface.time_t.
and
* s-osinte-hpux.ads (timespec): Change type of tv_nsec field to time_t.
* s-osinte-kfreebsd-gnu.ads (timespec): Likewise.
* s-osinte-solaris-posix.ads (timespec): Likewise.
Possible content in s-osinte-linux-x32.ads would be:
type tv_nsec_t is private;
type tv_nsec_t is new Long_Long_Integer;
type timespec is record
tv_sec : time_t;
tv_nsec : tv_nsec_t;
end record;
pragma Convention (C, timespec);
More information about the Gcc-patches
mailing list