PATCH [3/n]: Add __snseconds_t and __SNSECONDS_T_TYPE

Paul Eggert eggert@cs.ucla.edu
Thu Mar 15 20:48:00 GMT 2012


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.



More information about the Libc-alpha mailing list