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 [4/n]: Support 64bit time_t and 32bit long


On 03/15/2012 01:16 PM, H.J. Lu wrote:

>    verify (C99_integer_division, -1 / 2 == 0);
>    verify (long_int_year_and_yday_are_wide_enough,
> -	  INT_MAX <= LONG_MAX / 2 || TIME_T_MAX <= UINT_MAX);
> +	  INT_MAX <= TIME_T_MAX / 2 || TIME_T_MAX <= UINT_MAX);

This patch cannot be right.  The rest of mktime.c is written
assuming that 'long int' is wide enough, and the above code
checks that this assumption is in fact true on the current platform.
Evidently this code caused a compile-time failure on x32,
but that's a good thing: it's warning you that mktime.c won't work
as-is.  The proper way to fix this is to alter mktime.c so that
it works even if time_t is wider than 'long int', and *then*
to change the 'verify' to match the code's altered assumptions.

Instead of trying to fix this yourself, I suggest that you simply
sync from the upstream version of mktime.c, which is in gnulib.
gnulib mktime.c was changed some time ago so that it does not
assume that 'long int' is wide enough for the calculations in question.

Here's how to get gnulib mktime.c:

git clone git://git.savannah.gnu.org/gnulib.git

As far as I know, all you should need to do is to use gnulib's
lib/mktime.c, substituting an LGPL copyright notice for its
GPL copyright notice.


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