This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR ada/54040: [x32] Incorrect timeval and timespec
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Arnaud Charlet <charlet at adacore dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Eric Botcazou <ebotcazou at adacore dot com>
- Date: Mon, 18 Nov 2013 05:52:07 -0800
- Subject: Re: [PATCH] PR ada/54040: [x32] Incorrect timeval and timespec
- Authentication-results: sourceware.org; auth=none
- References: <CAMe9rOobDA0tByri=q0tF7sw5OBPu_McmF8Tc9RcC=waqh_2nQ at mail dot gmail dot com> <20131115105054 dot GC15490 at adacore dot com> <CAMe9rOq=0jJRC9Ps6aHjKihfXd3XKHmGX7TY0HVTpESd7m0H6Q at mail dot gmail dot com> <20131115111843 dot GA31367 at adacore dot com> <CAMe9rOrZpt5LCP_1dDiOYDi2phbfEQMBYtKaUZhzireTt9vGHg at mail dot gmail dot com> <20131115113815 dot GB7411 at adacore dot com> <CAMe9rOpAs6Gu07nhf-tM1ir97jF-LztL8JY86DuVQ8hb9q80ag at mail dot gmail dot com> <20131115115615 dot GD27059 at adacore dot com> <CAMe9rOpTqtdy_e-Yz6gUAGFWpZNr582-R16WOPEdbikCPg2VjA at mail dot gmail dot com> <20131118085832 dot GA13792 at adacore dot com> <20131118090233 dot GB6341 at adacore dot com>
On Mon, Nov 18, 2013 at 1:02 AM, Arnaud Charlet <charlet@adacore.com> wrote:
>> Actually there are two issues with your change:
>>
>> Using time_t for tv_nsec looks actually wrong, the definition on (my)
>> linux is:
>>
>> struct timespec {
>> __kernel_time_t tv_sec; /* seconds */
>> long tv_nsec; /* nanoseconds */
>> };
This is wrong for x32 where tv_nsec is long long, not
long. There are a couple places where long should be
long long for x32. Glibc gets them right properly:
/* A time value that is accurate to the nearest
microsecond but also has a range of years. */
struct timeval
{
__time_t tv_sec; /* Seconds. */
__suseconds_t tv_usec; /* Microseconds. */
};
>> As you can see, the types for tv_sec and tv_nsec are different.
>>
>> So the change to timespec looks wrong to me.
>
> In addition concerning s-taprop-linux.adb, the definition of struct
> timeval on linux is:
>
> /* A time value that is accurate to the nearest
> microsecond but also has a range of years. */
> struct timeval
> {
> __time_t tv_sec; /* Seconds. */
> __suseconds_t tv_usec; /* Microseconds. */
> };
>
> So again, we have another type (__suseconds_t), and NOT time_t or __time_t
> so it's really wrong for tv_nsec to use time_t.
>
All for Linux architectures, __suseconds_t and
__suseconds_t are the same as time_t, including
x32. If not, we can't use array for timeval.
--
H.J.