diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-03-18 14:14:15 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-04-30 09:02:17 -0700 |
commit | 20aa5819586ac7ad11f711bab64feda307965191 (patch) | |
tree | 81a1ab6c9d471bf99609784cbd3a446c67ef2471 /posix | |
parent | 87c266d758d29e52bfb717f90025ef1fe2663d38 (diff) | |
download | glibc-20aa5819586ac7ad11f711bab64feda307965191.tar glibc-20aa5819586ac7ad11f711bab64feda307965191.tar.gz glibc-20aa5819586ac7ad11f711bab64feda307965191.tar.bz2 glibc-20aa5819586ac7ad11f711bab64feda307965191.zip |
Make mktime etc. compatible with __time64_t
Keep these functions compatible with Gnulib while adding
__time64_t support. The basic idea is to move private API
declarations from include/time.h to time/mktime-internal.h, since
the former file cannot easily be shared with Gnulib whereas the
latter can.
Also, do some other minor cleanup while in the neighborhood.
* include/time.h: Include stdbool.h, time/mktime-internal.h.
(__mktime_internal): Move this prototype to time/mktime-internal.h,
since Gnulib needs it.
(__localtime64_r, __gmtime64_r) [__TIMESIZE == 64]:
Move these macros to time/mktime-internal.h, since Gnulib needs them.
(__mktime64, __timegm64) [__TIMESIZE != 64]: New prototypes.
(in_time_t_range): New static function.
* posix/bits/types.h (__time64_t) [__TIMESIZE == 64 && !defined __LIBC]:
Do not define as a macro in this case, so that portable code is
less tempted to use __time64_t.
* time/mktime-internal.h: Rewrite so that it does both glibc
and Gnulib work. Include time.h if not _LIBC.
(mktime_offset_t) [!_LIBC]: Define for gnulib.
(__time64_t, __gmtime64_r, __localtime64_r, __mktime64, __timegm64)
[!_LIBC || __TIMESIZE == 64]: New macros, mostly moved here
from include/time.h.
(__gmtime_r, __localtime_r, __mktime_internal) [!_LIBC]:
New macros, taken from GNulib.
(__mktime_internal): New prototype, moved here from include/time.h.
* time/mktime.c (mktime_min, mktime_max, convert_time)
(ranged_convert, __mktime_internal, __mktime64):
* time/timegm.c (__timegm64):
Use __time64_t, not time_t.
* time/mktime.c: Stop worrying about whether time_t is floating-point.
(__mktime64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from mktime.
(mktime) [_LIBC && __TIMESIZE != 64]: New function.
* time/timegm.c [!_LIBC]: Include libc-config.h, not config.h,
for libc_hidden_def.
Include errno.h.
(__timegm64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from timegm.
(timegm) [_LIBC && __TIMESIZE != 64]: New function.
First cut at publicizing __time64_t
Diffstat (limited to 'posix')
-rw-r--r-- | posix/bits/types.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/posix/bits/types.h b/posix/bits/types.h index 0de6c59bb4..cb737caff0 100644 --- a/posix/bits/types.h +++ b/posix/bits/types.h @@ -213,10 +213,13 @@ __STD_TYPE __U32_TYPE __socklen_t; It is not currently necessary for this to be machine-specific. */ typedef int __sig_atomic_t; -#if __TIMESIZE == 64 +/* Seconds since the Epoch, visible to user code when time_t is too + narrow only for consistency with the old way of widening too-narrow + types. User code should never use __time64_t. */ +#if __TIMESIZE == 64 && defined __LIBC # define __time64_t __time_t -#else -__STD_TYPE __TIME64_T_TYPE __time64_t; /* Seconds since the Epoch. */ +#elif __TIMESIZE != 64 +__STD_TYPE __TIME64_T_TYPE __time64_t; #endif #undef __STD_TYPE |