diff options
author | Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr> | 2017-09-06 10:00:42 +0200 |
---|---|---|
committer | Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr> | 2018-04-12 20:51:09 +0200 |
commit | 770d46d8c50d005670a4e2be21cf0fe54340e846 (patch) | |
tree | e799bbe5265c10ee2dffec2aedcd2ee37cb49713 /time | |
parent | cd93d2ea709d1e41108159312a2bd9233f1426f8 (diff) | |
download | glibc-770d46d8c50d005670a4e2be21cf0fe54340e846.tar.gz |
Y2038: add _TIME_BITS supportaaribaud/y2038-2.26-rfc-2-candidate
This makes all previously defined Y2038-proof API types, functions and
implementations the default when _TIME_BITS==64 and __WORDSIZE==32 (so
that 64-bit architectures are unaffected).
Note: it is assumed that the API is consistent, i.e. for each API type
which is enabled here, all API functions which depend on this type are
enabled and mapped to Y2038-proof implementations.
Diffstat (limited to 'time')
-rw-r--r-- | time/bits/types/struct_timespec.h | 17 | ||||
-rw-r--r-- | time/bits/types/struct_timeval.h | 9 | ||||
-rw-r--r-- | time/bits/types/time_t.h | 4 | ||||
-rw-r--r-- | time/sys/time.h | 74 | ||||
-rw-r--r-- | time/time.h | 161 |
5 files changed, 264 insertions, 1 deletions
diff --git a/time/bits/types/struct_timespec.h b/time/bits/types/struct_timespec.h index 644db9fdb6..1ba24cee60 100644 --- a/time/bits/types/struct_timespec.h +++ b/time/bits/types/struct_timespec.h @@ -2,13 +2,30 @@ #define __timespec_defined 1 #include <bits/types.h> +#include <endian.h> /* POSIX.1b structure for a time value. This is like a `struct timeval' but has nanoseconds instead of microseconds. */ +#if __WORDSIZE > 32 || ! defined(__USE_TIME_BITS64) struct timespec { __time_t tv_sec; /* Seconds. */ __syscall_slong_t tv_nsec; /* Nanoseconds. */ }; +# elif BYTE_ORDER == BIG_ENDIAN +struct timespec +{ + __time64_t tv_sec; /* Seconds. */ + int: 32; /* Hidden padding */ + __syscall_slong_t tv_nsec; /* Nanoseconds. */ +}; +# else +struct timespec +{ + __time64_t tv_sec; /* Seconds. */ + __syscall_slong_t tv_nsec; /* Nanoseconds. */ + int: 32; /* Hidden padding */ +}; +# endif #endif diff --git a/time/bits/types/struct_timeval.h b/time/bits/types/struct_timeval.h index 70394ce886..85e0cb5996 100644 --- a/time/bits/types/struct_timeval.h +++ b/time/bits/types/struct_timeval.h @@ -5,9 +5,18 @@ /* A time value that is accurate to the nearest microsecond but also has a range of years. */ +#ifdef __USE_TIME_BITS64 +struct timeval +{ + __time64_t tv_sec; /* Seconds. */ + __uint64_t tv_usec; /* Microseconds. */ +}; +#else struct timeval { __time_t tv_sec; /* Seconds. */ __suseconds_t tv_usec; /* Microseconds. */ }; #endif + +#endif diff --git a/time/bits/types/time_t.h b/time/bits/types/time_t.h index ab8287c6fe..84d67f6ac3 100644 --- a/time/bits/types/time_t.h +++ b/time/bits/types/time_t.h @@ -4,6 +4,10 @@ #include <bits/types.h> /* Returned by `time'. */ +#ifdef __USE_TIME_BITS64 +typedef __time64_t time_t; +#else typedef __time_t time_t; +#endif #endif diff --git a/time/sys/time.h b/time/sys/time.h index 4166a5b10f..32d8766e02 100644 --- a/time/sys/time.h +++ b/time/sys/time.h @@ -65,12 +65,31 @@ typedef void *__restrict __timezone_ptr_t; Returns 0 on success, -1 on errors. NOTE: This form of timezone information is obsolete. Use the functions and variables declared in <time.h> instead. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (gettimeofday, (struct timeval *__restrict __tv, + __timezone_ptr_t __tz), + __gettimeofday64) __THROW __nonnull((1)); +# else +# define gettimeofday __gettimeofday64 +# endif +#endif extern int gettimeofday (struct timeval *__restrict __tv, __timezone_ptr_t __tz) __THROW __nonnull ((1)); #ifdef __USE_MISC /* Set the current time of day and timezone information. This call is restricted to the super-user. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (settimeofday, + (const struct timeval *__tv, + const struct timezone *__tz), + __settimeofday64) __THROW; +# else +# define settimeofday __settimeofday64 +# endif +# endif extern int settimeofday (const struct timeval *__tv, const struct timezone *__tz) __THROW; @@ -79,6 +98,16 @@ extern int settimeofday (const struct timeval *__tv, If OLDDELTA is not NULL, it is filled in with the amount of time adjustment remaining to be done from the last `adjtime' call. This call is restricted to the super-user. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (adjtime, + (const struct timeval *__delta, + struct timeval *__olddelta), + __adjtime64) __THROW; +# else +# define adjtime __adjtime64 +# endif +# endif extern int adjtime (const struct timeval *__delta, struct timeval *__olddelta) __THROW; #endif @@ -119,12 +148,31 @@ typedef int __itimer_which_t; /* Set *VALUE to the current setting of timer WHICH. Return 0 on success, -1 on errors. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (getitimer, (__itimer_which_t __which, + struct itimerval *__value), __getitimer64) + __THROW; +# else +# define getitimer __getitimer64 +# endif +#endif extern int getitimer (__itimer_which_t __which, struct itimerval *__value) __THROW; /* Set the timer WHICH to *NEW. If OLD is not NULL, set *OLD to the old value of timer WHICH. Returns 0 on success, -1 on errors. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (setitimer, (__itimer_which_t __which, + const struct itimerval *__restrict __new, + struct itimerval *__restrict __old), __setitimer64) + __THROW; +# else +# define setitimer __setitimer64 +# endif +#endif extern int setitimer (__itimer_which_t __which, const struct itimerval *__restrict __new, struct itimerval *__restrict __old) __THROW; @@ -132,15 +180,41 @@ extern int setitimer (__itimer_which_t __which, /* Change the access time of FILE to TVP[0] and the modification time of FILE to TVP[1]. If TVP is a null pointer, use the current time instead. Returns 0 on success, -1 on errors. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (utimes, (const char *__file, + const struct timeval __tvp[2]), __utimes64) + __THROW __nonnull ((1)); +# else +# define utimes __utimes64 +# endif +#endif extern int utimes (const char *__file, const struct timeval __tvp[2]) __THROW __nonnull ((1)); #ifdef __USE_MISC /* Same as `utimes', but does not follow symbolic links. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (lutimes, (const char *__file, + const struct timeval __tvp[2]), __lutimes64) + __THROW __nonnull ((1)); +# else +# define lutimes __lutimes64 +# endif +#endif extern int lutimes (const char *__file, const struct timeval __tvp[2]) __THROW __nonnull ((1)); /* Same as `utimes', but takes an open file descriptor instead of a name. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (futimes, (int __fd, const struct timeval __tvp[2]), + __futimes64) __THROW; +# else +# define futimes __futimes64 +# endif +#endif extern int futimes (int __fd, const struct timeval __tvp[2]) __THROW; #endif diff --git a/time/time.h b/time/time.h index 4b55e34402..f80165de8e 100644 --- a/time/time.h +++ b/time/time.h @@ -72,16 +72,38 @@ __BEGIN_DECLS extern clock_t clock (void) __THROW; /* Return the current time and put it in *TIMER if TIMER is not NULL. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern time_t __REDIRECT (time, (time_t * __timer), + __time64) __THROW; +# else +# define time __time64 +# endif +#endif extern time_t time (time_t *__timer) __THROW; /* Return the difference between TIME1 and TIME0. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern double __REDIRECT (difftime, (time_t __time1, time_t __time0), + __difftime64) __THROW; +# else +# define difftime __difftime64 +# endif +#endif extern double difftime (time_t __time1, time_t __time0) __THROW __attribute__ ((__const__)); /* Return the `time_t' representation of TP and normalize TP. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern time_t __REDIRECT (mktime, (struct tm *__tp), __mktime64) __THROW; +# else +# define mktime __mktime64 +# endif +#endif extern time_t mktime (struct tm *__tp) __THROW; - /* Format TP into S according to FORMAT. Write no more than MAXSIZE characters and return the number of characters written, or 0 if it would exceed MAXSIZE. */ @@ -116,20 +138,52 @@ extern char *strptime_l (const char *__restrict __s, /* Return the `struct tm' representation of *TIMER in Universal Coordinated Time (aka Greenwich Mean Time). */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern struct tm * __REDIRECT (gmtime, (const time_t *__timer), + __gmtime64) __THROW; +# else +# define gmtime __gmtime64 +# endif +#endif extern struct tm *gmtime (const time_t *__timer) __THROW; /* Return the `struct tm' representation of *TIMER in the local timezone. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern struct tm * __REDIRECT (localtime, (const time_t *__timer), + __localtime64) __THROW; +# else +# define localtime __localtime64 +# endif +#endif extern struct tm *localtime (const time_t *__timer) __THROW; #ifdef __USE_POSIX /* Return the `struct tm' representation of *TIMER in UTC, using *TP to store the result. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern struct tm * __REDIRECT (gmtime_r, (const time_t *__restrict + __timer, struct tm *__restrict __tp), __gmtime64_r) __THROW; +# else +# define gmtime_r __gmtime64_r +# endif +#endif extern struct tm *gmtime_r (const time_t *__restrict __timer, struct tm *__restrict __tp) __THROW; /* Return the `struct tm' representation of *TIMER in local time, using *TP to store the result. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern struct tm * __REDIRECT (localtime_r, (const time_t *__restrict + __timer, struct tm *__restrict __tp), __localtime64_r) __THROW; +# else +# define localtime_r __localtime64_r +# endif +#endif extern struct tm *localtime_r (const time_t *__restrict __timer, struct tm *__restrict __tp) __THROW; #endif /* POSIX */ @@ -139,6 +193,14 @@ extern struct tm *localtime_r (const time_t *__restrict __timer, extern char *asctime (const struct tm *__tp) __THROW; /* Equivalent to `asctime (localtime (timer))'. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern char * __REDIRECT (ctime, (const time_t *__timer), + __ctime64) __THROW; +# else +# define ctime __ctime64 +# endif +#endif extern char *ctime (const time_t *__timer) __THROW; #ifdef __USE_POSIX @@ -150,6 +212,14 @@ extern char *asctime_r (const struct tm *__restrict __tp, char *__restrict __buf) __THROW; /* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern char * __REDIRECT (ctime_r, (const time_t *__restrict __timer, + char *__restrict __buf), __ctime64_r) __THROW; +# else +# define ctime_r __ctime64_r +# endif +#endif extern char *ctime_r (const time_t *__restrict __timer, char *__restrict __buf) __THROW; #endif /* POSIX */ @@ -178,6 +248,14 @@ extern long int timezone; #ifdef __USE_MISC /* Set the system time to *WHEN. This call is restricted to the superuser. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (stime, (const time_t *__when), __stime64) + __THROW; +# else +# define stime __stime64 +# endif +#endif extern int stime (const time_t *__when) __THROW; #endif @@ -193,9 +271,23 @@ extern int stime (const time_t *__when) __THROW; localtime package. These are included only for compatibility. */ /* Like `mktime', but for TP represents Universal Time, not local time. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern time_t __REDIRECT (timegm, (struct tm *__tp), __timegm64) __THROW; +# else +# define timegm __timegm64 +# endif +#endif extern time_t timegm (struct tm *__tp) __THROW; /* Another name for `mktime'. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern time_t __REDIRECT (timelocal, (struct tm *__tp), __timelocal64) __THROW; +# else +# define timelocal __timelocal64 +# endif +#endif extern time_t timelocal (struct tm *__tp) __THROW; /* Return the number of days in YEAR. */ @@ -208,17 +300,49 @@ extern int dysize (int __year) __THROW __attribute__ ((__const__)); This function is a cancellation point and therefore not marked with __THROW. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (nanosleep, (const struct timespec *__requested_time, + struct timespec *__remaining), __nanosleep64); +# else +# define nanosleep __nanosleep64 +# endif +#endif extern int nanosleep (const struct timespec *__requested_time, struct timespec *__remaining); /* Get resolution of clock CLOCK_ID. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (clock_getres, (clockid_t __clock_id, struct + timespec *__res), __clock_getres64) __THROW; +# else +# define clock_getres __clock_getres64 +# endif +#endif extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __THROW; /* Get current value of clock CLOCK_ID and store it in TP. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (clock_gettime, (clockid_t __clock_id, struct + timespec *__tp), __clock_gettime64) __THROW; +# else +# define clock_gettime __clock_gettime64 +# endif +#endif extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW; /* Set clock CLOCK_ID to value TP. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (clock_settime, (clockid_t __clock_id, const struct + timespec *__tp), __clock_settime64) __THROW; +# else +# define clock_settime __clock_settime64 +# endif +#endif extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp) __THROW; @@ -227,6 +351,15 @@ extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp) This function is a cancellation point and therefore not marked with __THROW. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (clock_nanosleep, (clockid_t __clock_id, int __flags, + const struct timespec *__req, struct timespec *__rem), + __clock_nanosleep64) __THROW; +# else +# define clock_nanosleep __clock_nanosleep64 +# endif +#endif extern int clock_nanosleep (clockid_t __clock_id, int __flags, const struct timespec *__req, struct timespec *__rem); @@ -245,11 +378,29 @@ extern int timer_create (clockid_t __clock_id, extern int timer_delete (timer_t __timerid) __THROW; /* Set timer TIMERID to VALUE, returning old value in OVALUE. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (timer_settime, (timer_t __timerid, int __flags, + const struct itimerspec *__restrict __value, + struct itimerspec *__restrict __ovalue), + __timer_settime64) __THROW; +# else +# define timer_settime __timer_settime64 +# endif +#endif extern int timer_settime (timer_t __timerid, int __flags, const struct itimerspec *__restrict __value, struct itimerspec *__restrict __ovalue) __THROW; /* Get current value of timer TIMERID and store it in VALUE. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (timer_gettime, (timer_t __timerid, struct + itimerspec *__value), __timer_gettime64) __THROW __nonnull ((1)); +# else +# define timer_gettime __timer_gettime64 +# endif +#endif extern int timer_gettime (timer_t __timerid, struct itimerspec *__value) __THROW; @@ -260,6 +411,14 @@ extern int timer_getoverrun (timer_t __timerid) __THROW; #ifdef __USE_ISOC11 /* Set TS to calendar time based in time base BASE. */ +#ifdef __USE_TIME_BITS64 +# if defined(__REDIRECT) +extern int __REDIRECT (timespec_get, (struct timespec *__ts, int __base), + __timespec_get64) __THROW __nonnull ((1)); +# else +# define timespec_get __timespec_get64 +# endif +#endif extern int timespec_get (struct timespec *__ts, int __base) __THROW __nonnull ((1)); #endif |