@@ -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_BIT==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
@@ -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
@@ -4,6 +4,9 @@
#include <bits/types.h>
+/* Use the original definition for 64-bit arches
+ or when 64-bit-time by default has *not* been requested */
+#if __WORDSIZE > 32 || ! defined(__USE_TIME_BITS64)
/* POSIX.1b structure for a time value. This is like a `struct timeval' but
has nanoseconds instead of microseconds. */
struct timespec
@@ -11,5 +14,10 @@ struct timespec
__time_t tv_sec; /* Seconds. */
__syscall_slong_t tv_nsec; /* Nanoseconds. */
};
+#else
+# include <bits/types/struct___timespec64.h>
+/* Use the 64-bit-time timespec by default */
+#define timespec __timespec64
+# 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