This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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 [3/n]: Add __snseconds_t and __SNSECONDS_T_TYPE


On 03/15/2012 01:26 PM, H.J. Lu wrote:
>  struct timespec
>    {
>      __time_t tv_sec;		/* Seconds.  */
> -    long int tv_nsec;		/* Nanoseconds.  */
> +    __snseconds_t tv_nsec;	/* Nanoseconds.  */
>    };

This patch does not look right.  POSIX says that tv_nsec must
be of type 'long'; it cannot be of type 'long long'.  See
<http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html>.

Instead, I suggest redoing the patch so that there is a 4-byte
filler in the data structure on x32.  There should be no need
to introduce __snseconds_t or __SNSECONDS_T_TYPE; just use
'long'.  When passing the data structure to the kernel, you can
sign-extend tv_nsec into the filler.  You can ignore the filler
when getting the data structure back from the kernel, since it
should always be appropriately sign-extended.


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