@@ -365,6 +365,25 @@
# define __USE_FILE_OFFSET64 1
#endif
+/* We need to know the word size in order to check the time size. */
+#include <bits/wordsize.h>
+
+#if defined _TIME_BITS
+# if _TIME_BITS == 64
+# if ! defined (_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS != 64
+# error _TIME_BITS==64 is allowed only when _FILE_OFFSET_BITS==64
+# elif __WORDSIZE == 32
+# define __USE_TIME_BITS64 1
+# endif
+# elif _TIME_BITS == 32
+# if __WORDSIZE > 32
+# error _TIME_BITS=32 is not compatible with __WORDSIZE > 32
+# endif
+# else
+# error Invalid _TIME_BITS value (can only be 32 or 64)
+# endif
+#endif
+
#if defined _DEFAULT_SOURCE
# define __USE_MISC 1
#endif
@@ -132,7 +132,8 @@ libc_hidden_proto (__timegm64)
#else
extern int __clock_settime64 (clockid_t clock_id,
const struct __timespec64 *tp);
-libc_hidden_proto (__clock_settime64)
+/* For Y2038 safe system the __clock_settime64 needs to be a visible
+ symbol as a replacement for Y2038 unsafe clock_settime. */
#endif
/* Compute the `struct tm' representation of T,
@@ -165,6 +165,34 @@ This macro was introduced as part of the Large File Support extension
(LFS).
@end defvr
+@defvr Macro _TIME_BITS
+This macro determines the bit size of @code{time_t} (and therefore the
+bit size of all @code{time_t} derived types and the prototypes of all
+related functions). If @code{_TIME_BITS} is undefined, the bit size of
+time_t equals the bit size of the architecture.
+
+If @code{_TIME_BITS} is undefined, or if @code{_TIME_BITS} is defined
+to the value @code{32} and @code{__WORDSIZE} is defined to the value
+@code{32}, or or if @code{_TIME_BITS} is defined to the value @code{64}
+and @code{__WORDSIZE} is defined to the value @code{64}, nothing changes.
+
+If @code{_TIME_BITS} is defined to the value @code{64} and if
+@code{__WORDSIZE} is defined to the value @code{32}, then the @w{64 bit}
+time API and implementation are used even though the architecture word
+size is @code{32}. Also, if the kernel provides @w{64 bit} time support,
+it is used; otherwise, the @w{32 bit} kernel time support is used (with
+no provision to address kernel Y2038 shortcomings).
+
+If @code{_TIME_BITS} is defined to the value @code{32} and if
+@code{__WORDSIZE} is defined to the value @code{64}, then a compile-time
+error is emitted.
+
+If @code{_TIME_BITS} is defined to a value different from both @code{32}
+and @code{64}, then a compile-time error is emitted.
+
+This macro was introduced as part of the Y2038 support.
+@end defvr
+
@defvr Macro _ISOC99_SOURCE
@standards{GNU, (none)}
If this macro is defined, features from ISO C99 are included. Since
@@ -1,4 +1,7 @@
libc {
+ GLIBC_PRIVATE {
+ __clock_settime64;
+ }
GLIBC_2.0 {
# global variables
__daylight; __timezone; __tzname;
@@ -3,13 +3,24 @@
#define _STRUCT_TIMESPEC 1
#include <bits/types.h>
+#include <bits/types/time_t.h>
/* POSIX.1b structure for a time value. This is like a `struct timeval' but
has nanoseconds instead of microseconds. */
struct timespec
{
- __time_t tv_sec; /* Seconds. */
- __syscall_slong_t tv_nsec; /* Nanoseconds. */
+ time_t tv_sec; /* Seconds. */
+# ifdef __USE_TIME_BITS64
+# if __BYTE_ORDER == __BIG_ENDIAN
+ int : 32;
+ __syscall_slong_t tv_nsec; /* Nanoseconds. */
+# else
+ __syscall_slong_t tv_nsec; /* Nanoseconds. */
+ int : 32;
+# endif
+# else
+ __syscall_slong_t tv_nsec; /* Nanoseconds. */
+# endif
};
#endif
@@ -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
@@ -222,6 +222,15 @@ extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
__THROW;
+#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
+
# ifdef __USE_XOPEN2K
/* High-resolution sleep with the specified clock.