Re: PATCH [3/n]: Add __snseconds_t and __SNSECONDS_T_TYPE

From: H.J. Lu
Date: Thu Mar 15 2012 - 18:19:43 EST


On Thu, Mar 15, 2012 at 3:05 PM, Paul Eggert <eggert@xxxxxxxxxxx> wrote:
> On 03/15/2012 01:57 PM, H.J. Lu wrote:
>> What is the real consequence of using long long on tv_nsec,
>> except for not POSIX compliant? Will it lead to wrong code?
>
> It would break applications that do anything like this:
>
>  struct timespec t;
>  long *p = &t->tv_nsec;
>
> Such applications work fine now and conform to POSIX, but would

GCC will complain about "incompatible pointer type".

> either not compile or (worse) might compile and do the
> wrong thing, if tv_nsec were wider than 'long'.

We had a discussion on Linux kernel mailing list:

https://lkml.org/lkml/2012/2/8/408

We thought it was OK to have long long on tv_nsec.

--
H.J.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/