On 03/08/2017 02:28 AM, Albert ARIBAUD wrote:
the only problem I see is if some weird code implicitly depends on tv_nsec's size being 'long'.
Although I have not found "weird code" like that in GNU applications I help maintain, I did find one instance of "weird code" back in 2012 when I was first looking into the problem: an example program in Kerrisk's book "The Linux Programming Interface" http://man7.org/tlpi/code/online/dist/timers/t_clock_nanosleep.c.html, which contains this:
printf("... Remaining: %ld.%09ld", (long) remain.tv_sec, remain.tv_nsec);
This fails on ABIs where tv_nsec is 'long long' and where 'long long' is passed differently from 'long'. (The code also fails on these ABIs if remain.tv_sec exceeds LONG_MAX, of course.)
So, although I'm mildly inclined to think it's OK to change tv_nsec to be wider than long, I suspect this change will break a few lower-quality applications in minor ways, and this is not a cost that we can entirely sweep under the rug.