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] PR ada/54040: [x32] Incorrect timeval and timespec


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.


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