[PATCH v2 1/2] Y2038: make __mktime_internal compatible with __time64_t
Paul Eggert
eggert@cs.ucla.edu
Mon Mar 18 21:23:00 GMT 2019
On 3/11/19 11:58 PM, Lukasz Majewski wrote:
> The question is if there is a more suitable place than include/time.h
> header to have fits_in_time() reused by both Glibc and Gnulib?
Hmm, well, on further thought, fits_in_time_t can live in include/time.h
since only glibc will need it. Gnulib won't support two kinds of time_t
types, so it should't need the function. (The attached patch renames it
to "in_time_t_range" to avoid *_t pollution.)
That being said, we will have to make a place for private .h code shared
between glibc and Gnulib, because include/time.h can't easily be shared
with Gnulib. I suggest using time/mktime-internal.h for this
Some other comments on that patch that I noticed while looking into this.
The patch added duplicate "#include <errno.h>" lines to time/timegm.c.
I still don't get why we need __timelocal64. Glibc code can use
__mktime64. User code shouldn't see that symbol.
Come to think of it, user code shouldn't see __time64_t either. Yes, the
name begins with two underscores so user code should avoid it, but
putting __time64_t in /usr/include will just tempt users. It's easy to
keep __time64_t out of /usr/include so let's do that.
The body of __mktime64 can be simplified; there's no need for locals of
type __time64_t, time_t, and struct tm. And it should use
in_time_t_range instead of doing it by hand.
The bodies of mktime and timegm [__TIMESIZE != 64] should not pass tp to
__mktime64/__timegm64 directly, since *tp should not be updated if the
result is in __time64_t range but out of time_t range. And timegm should
use in_time_t_range instead of doing it by hand.
The "#ifdef weak_alias" etc. lines can be removed now, since Gnulib does
this stuff OK now.
timegm.c should include libc-config.h, not config.h, as this is the
current Gnulib style for code shared with Gnulib.
Revised proposed patch attached.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Make-mktime-etc.-compatible-with-__time64_t.patch
Type: text/x-patch
Size: 17765 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20190318/4aa3c814/attachment.bin>
More information about the Libc-alpha
mailing list