summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2017-09-06 10:00:42 +0200
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-02-01 12:16:04 +0100
commit9bb849f25802604148e67170674bbd0a7ad8f921 (patch)
treec5011ce6facad0e21dd8804eaf4f618794c4fb52
parent943f74e4ef0a6a7465bdceea68d3d64b42e0469e (diff)
downloadglibc-aaribaud/y2038-temp.tar.gz
Y2038: add _TIME_BITS supportaaribaud/y2038-temp
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.
-rw-r--r--include/features.h14
-rw-r--r--io/sys/stat.h75
-rw-r--r--io/utime.h15
-rw-r--r--manual/creature.texi28
-rw-r--r--misc/sys/select.h25
-rw-r--r--posix/sched.h9
-rw-r--r--resource/sys/resource.h9
-rw-r--r--rt/mqueue.h22
-rw-r--r--signal/signal.h10
-rw-r--r--sysdeps/nptl/pthread.h41
-rw-r--r--sysdeps/pthread/semaphore.h10
-rw-r--r--sysdeps/unix/sysv/linux/bits/stat.h6
-rw-r--r--sysdeps/unix/sysv/linux/sys/timerfd.h19
-rw-r--r--sysdeps/unix/sysv/linux/sys/timex.h32
-rw-r--r--sysvipc/sys/msg.h9
-rw-r--r--time/bits/types/struct_timespec.h17
-rw-r--r--time/bits/types/struct_timeval.h9
-rw-r--r--time/bits/types/time_t.h4
-rw-r--r--time/sys/time.h74
-rw-r--r--time/time.h161
20 files changed, 574 insertions, 15 deletions
diff --git a/include/features.h b/include/features.h
index 0e96de030f..4d83c0deae 100644
--- a/include/features.h
+++ b/include/features.h
@@ -364,6 +364,20 @@
# define __USE_FILE_OFFSET64 1
#endif
+#if defined _TIME_BITS
+# if _TIME_BITS == 64
+# if __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
diff --git a/io/sys/stat.h b/io/sys/stat.h
index 90c403cfd6..c28ba3e583 100644
--- a/io/sys/stat.h
+++ b/io/sys/stat.h
@@ -210,14 +210,27 @@ extern int stat (const char *__restrict __file,
extern int fstat (int __fd, struct stat *__buf) __THROW __nonnull ((2));
#else
# ifdef __REDIRECT_NTH
+# ifdef __USE_TIME_BITS64
+extern int __REDIRECT_NTH (stat, (const char *__restrict __file,
+ struct stat *__restrict __buf), __stat64_t64)
+ __nonnull ((1, 2));
+extern int __REDIRECT_NTH (fstat, (int __fd, struct stat *__buf), __fstat64_t64)
+ __nonnull ((2));
+# else
extern int __REDIRECT_NTH (stat, (const char *__restrict __file,
struct stat *__restrict __buf), stat64)
__nonnull ((1, 2));
extern int __REDIRECT_NTH (fstat, (int __fd, struct stat *__buf), fstat64)
__nonnull ((2));
+# endif
# else
-# define stat stat64
-# define fstat fstat64
+# ifdef __USE_TIME_BITS64
+# define stat stat64_t64
+# define fstat fstat64_t64
+# else
+# define stat stat64
+# define fstat fstat64
+# endif
# endif
#endif
#ifdef __USE_LARGEFILE64
@@ -260,12 +273,23 @@ extern int lstat (const char *__restrict __file,
struct stat *__restrict __buf) __THROW __nonnull ((1, 2));
# else
# ifdef __REDIRECT_NTH
+# ifdef __USE_TIME_BITS64
+extern int __REDIRECT_NTH (lstat,
+ (const char *__restrict __file,
+ struct stat *__restrict __buf), __lstat64_t64)
+ __nonnull ((1, 2));
+# else
extern int __REDIRECT_NTH (lstat,
(const char *__restrict __file,
struct stat *__restrict __buf), lstat64)
__nonnull ((1, 2));
+# endif
# else
-# define lstat lstat64
+# ifdef __USE_TIME_BITS64
+# define lstat __lstat64_t64
+# else
+# define lstat lstat64
+# endif
# endif
# endif
# ifdef __USE_LARGEFILE64
@@ -357,6 +381,15 @@ extern int mkfifoat (int __fd, const char *__path, __mode_t __mode)
#ifdef __USE_ATFILE
/* Set file access and modification times relative to directory file
descriptor. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern int __REDIRECT (utimensat, (int __fd, const char *__path,
+ const struct timespec __times[2], int __flags),
+ __utimensat64) __THROW __nonnull((2));
+# else
+# define utimensat __utimensat64
+# endif
+#endif
extern int utimensat (int __fd, const char *__path,
const struct timespec __times[2],
int __flags)
@@ -365,6 +398,14 @@ extern int utimensat (int __fd, const char *__path,
#ifdef __USE_XOPEN2K8
/* Set file access and modification times of the file associated with FD. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern int __REDIRECT (futimens, (int __fd, const struct timespec __times[2]),
+ __futimens64) __THROW;
+# else
+# define futimens __futimens64
+# endif
+#endif
extern int futimens (int __fd, const struct timespec __times[2]) __THROW;
#endif
@@ -403,6 +444,21 @@ extern int __fxstatat (int __ver, int __fildes, const char *__filename,
__THROW __nonnull ((3, 4));
#else
# ifdef __REDIRECT_NTH
+# ifdef __USE_TIME_BITS64
+extern int __REDIRECT_NTH (__fxstat, (int __ver, int __fildes,
+ struct stat *__stat_buf), __fxstat64_t64)
+ __nonnull ((3));
+extern int __REDIRECT_NTH (__xstat, (int __ver, const char *__filename,
+ struct stat *__stat_buf), __xstat64_t64)
+ __nonnull ((2, 3));
+extern int __REDIRECT_NTH (__lxstat, (int __ver, const char *__filename,
+ struct stat *__stat_buf), __lxstat64_t64)
+ __nonnull ((2, 3));
+extern int __REDIRECT_NTH (__fxstatat, (int __ver, int __fildes,
+ const char *__filename,
+ struct stat *__stat_buf, int __flag),
+ __fxstatat64_t64) __nonnull ((3, 4));
+# else
extern int __REDIRECT_NTH (__fxstat, (int __ver, int __fildes,
struct stat *__stat_buf), __fxstat64)
__nonnull ((3));
@@ -416,11 +472,18 @@ extern int __REDIRECT_NTH (__fxstatat, (int __ver, int __fildes,
const char *__filename,
struct stat *__stat_buf, int __flag),
__fxstatat64) __nonnull ((3, 4));
+# endif
# else
-# define __fxstat __fxstat64
-# define __xstat __xstat64
-# define __lxstat __lxstat64
+# ifdef __USE_TIME_BITS64
+# define __fxstat __fxstat64_t64
+# define __xstat __xstat64_t64
+# define __lxstat __lxstat64_t64
+# else
+# define __fxstat __fxstat64
+# define __xstat __xstat64
+# define __lxstat __lxstat64
+# endif
# endif
#endif
diff --git a/io/utime.h b/io/utime.h
index 8409ba4ddc..4f07935764 100644
--- a/io/utime.h
+++ b/io/utime.h
@@ -32,15 +32,24 @@ __BEGIN_DECLS
# include <bits/types/time_t.h>
#endif
-/* Structure describing file times. */
+/* Structure describing file times, 32- or 64-bit time. */
struct utimbuf
{
- __time_t actime; /* Access time. */
- __time_t modtime; /* Modification time. */
+ time_t actime; /* Access time. */
+ time_t modtime; /* Modification time. */
};
/* Set the access and modification times of FILE to those given in
*FILE_TIMES. If FILE_TIMES is NULL, set them to the current time. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern int __REDIRECT (utime, (const char *__file,
+ const struct utimbuf *__file_times),
+ __utime_t64) __THROW __nonnull ((1));
+# else
+# define utime __utime_t64
+# endif
+#endif
extern int utime (const char *__file,
const struct utimbuf *__file_times)
__THROW __nonnull ((1));
diff --git a/manual/creature.texi b/manual/creature.texi
index 96f8ee0a0c..713a5fa5dd 100644
--- a/manual/creature.texi
+++ b/manual/creature.texi
@@ -148,6 +148,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)}
Until the revised @w{ISO C} standard is widely adopted the new features
diff --git a/misc/sys/select.h b/misc/sys/select.h
index 6dd0c83227..aa311940b2 100644
--- a/misc/sys/select.h
+++ b/misc/sys/select.h
@@ -98,6 +98,18 @@ __BEGIN_DECLS
This function is a cancellation point and therefore not marked with
__THROW. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern int __REDIRECT (select, (int __nfds,
+ fd_set *__restrict __readfds,
+ fd_set *__restrict __writefds,
+ fd_set *__restrict __exceptfds,
+ struct timeval *__restrict __timeout),
+ __select_t64);
+# else
+# define select __select_t64
+# endif
+#endif
extern int select (int __nfds, fd_set *__restrict __readfds,
fd_set *__restrict __writefds,
fd_set *__restrict __exceptfds,
@@ -110,6 +122,19 @@ extern int select (int __nfds, fd_set *__restrict __readfds,
This function is a cancellation point and therefore not marked with
__THROW. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern int __REDIRECT (pselect, (int __nfds,
+ fd_set *__restrict __readfds,
+ fd_set *__restrict __writefds,
+ fd_set *__restrict __exceptfds,
+ const struct timespec *__restrict __timeout,
+ const __sigset_t *__restrict __sigmask),
+ __pselect_t64);
+# else
+# define pselect __pselect_t64
+# endif
+#endif
extern int pselect (int __nfds, fd_set *__restrict __readfds,
fd_set *__restrict __writefds,
fd_set *__restrict __exceptfds,
diff --git a/posix/sched.h b/posix/sched.h
index 619b3b3a81..7c46401f94 100644
--- a/posix/sched.h
+++ b/posix/sched.h
@@ -74,6 +74,15 @@ extern int sched_get_priority_max (int __algorithm) __THROW;
extern int sched_get_priority_min (int __algorithm) __THROW;
/* Get the SCHED_RR interval for the named process. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern int __REDIRECT (sched_rr_get_interval,
+ (__pid_t __pid, struct timespec *__t),
+ __sched_rr_get_interval_t64) __THROW;
+# else
+# define sched_rr_get_interval __sched_rr_get_interval_t64
+# endif
+#endif
extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
diff --git a/resource/sys/resource.h b/resource/sys/resource.h
index 881db3970c..a5c8f3525a 100644
--- a/resource/sys/resource.h
+++ b/resource/sys/resource.h
@@ -84,6 +84,15 @@ extern int setrlimit64 (__rlimit_resource_t __resource,
/* Return resource usage information on process indicated by WHO
and put it in *USAGE. Returns 0 for success, -1 for failure. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern double __REDIRECT (getrusage, (__rusage_who_t __who,
+ struct rusage *__usage),
+ __getrusage_t64) __THROW;
+# else
+# define getrusage __getrusage_t64
+# endif
+#endif
extern int getrusage (__rusage_who_t __who, struct rusage *__usage) __THROW;
/* Return the highest priority of any process specified by WHICH and WHO
diff --git a/rt/mqueue.h b/rt/mqueue.h
index 5f354b4d76..cd9a8cc9ea 100644
--- a/rt/mqueue.h
+++ b/rt/mqueue.h
@@ -73,6 +73,17 @@ extern int mq_send (mqd_t __mqdes, const char *__msg_ptr, size_t __msg_len,
#ifdef __USE_XOPEN2K
/* Receive the oldest from highest priority messages in message queue
MQDES, stop waiting if ABS_TIMEOUT expires. */
+# ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern ssize_t __REDIRECT (mq_timedreceive, (mqd_t __mqdes,
+ char *__restrict __msg_ptr, size_t __msg_len,
+ unsigned int *__restrict __msg_prio,
+ const struct timespec *__restrict __abs_timeout),
+ __mq_timedreceive_t64) __nonnull((2, 5));
+# else
+# define mq_timedreceive __mq_timedreceive_t64
+# endif
+# endif
extern ssize_t mq_timedreceive (mqd_t __mqdes, char *__restrict __msg_ptr,
size_t __msg_len,
unsigned int *__restrict __msg_prio,
@@ -81,6 +92,17 @@ extern ssize_t mq_timedreceive (mqd_t __mqdes, char *__restrict __msg_ptr,
/* Add message pointed by MSG_PTR to message queue MQDES, stop blocking
on full message queue if ABS_TIMEOUT expires. */
+# ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern int __REDIRECT (mq_timedsend, (mqd_t __mqdes,
+ const char *__msg_ptr, size_t __msg_len,
+ unsigned int __msg_prio,
+ const struct timespec *__abs_timeout),
+ __mq_timedsend_t64) __nonnull((2, 5));
+# else
+# define mq_timedsend __mq_timedsend_t64
+# endif
+# endif
extern int mq_timedsend (mqd_t __mqdes, const char *__msg_ptr,
size_t __msg_len, unsigned int __msg_prio,
const struct timespec *__abs_timeout)
diff --git a/signal/signal.h b/signal/signal.h
index 87dc82a998..3f8c6e14db 100644
--- a/signal/signal.h
+++ b/signal/signal.h
@@ -266,6 +266,16 @@ extern int sigwaitinfo (const sigset_t *__restrict __set,
This function is a cancellation point and therefore not marked with
__THROW. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern int __REDIRECT (sigtimedwait, (const sigset_t *__restrict __set,
+ siginfo_t *__restrict __info,
+ const struct timespec *__restrict __timeout),
+ __sigtimedwait64) __nonnull ((1));
+# else
+# define sigtimedwait __sigtimedwait64
+# endif
+#endif
extern int sigtimedwait (const sigset_t *__restrict __set,
siginfo_t *__restrict __info,
const struct timespec *__restrict __timeout)
diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h
index df049abf74..6583b1f419 100644
--- a/sysdeps/nptl/pthread.h
+++ b/sysdeps/nptl/pthread.h
@@ -765,6 +765,16 @@ extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
#ifdef __USE_XOPEN2K
/* Wait until lock becomes available, or specified time passes. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern struct tm * __REDIRECT (pthread_mutex_timedlock,
+ (pthread_mutex_t *__restrict __mutex,
+ const struct timespec *__restrict __abstime),
+ __pthread_mutex_timedlock_t64) __THROWNL __nonnull ((1, 2));
+# else
+# define pthread_mutex_timedlock __pthread_mutex_timedlock_t64
+# endif
+#endif
extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
const struct timespec *__restrict
__abstime) __THROWNL __nonnull ((1, 2));
@@ -904,6 +914,16 @@ extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
# ifdef __USE_XOPEN2K
/* Try to acquire read lock for RWLOCK or return after specfied time. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern struct tm * __REDIRECT (pthread_rwlock_timedrdlock,
+ (pthread_rwlock_t *__restrict __rwlock,
+ struct timespec *__restrict __abstime),
+ __pthread_rwlock_timedrdlock_t64) __THROWNL __nonnull ((1, 2));
+# else
+# define pthread_rwlock_timedrdlock __pthread_rwlock_timedrdlock_t64
+# endif
+#endif
extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
const struct timespec *__restrict
__abstime) __THROWNL __nonnull ((1, 2));
@@ -919,6 +939,16 @@ extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
# ifdef __USE_XOPEN2K
/* Try to acquire write lock for RWLOCK or return after specfied time. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern struct tm * __REDIRECT (pthread_rwlock_timedwrlock,
+ (pthread_rwlock_t *__restrict __rwlock,
+ struct timespec *__restrict __abstime),
+ __pthread_rwlock_timedwrlock_t64) __THROWNL __nonnull ((1, 2));
+# else
+# define pthread_rwlock_timedwrlock __pthread_rwlock_timedwrlock_t64
+# endif
+#endif
extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
const struct timespec *__restrict
__abstime) __THROWNL __nonnull ((1, 2));
@@ -998,6 +1028,17 @@ extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
This function is a cancellation point and therefore not marked with
__THROW. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern struct tm * __REDIRECT (pthread_cond_timedwait,
+ (pthread_cond_t *__restrict __cond,
+ pthread_mutex_t *__restrict __mutex,
+ const struct timespec *__restrict __abstime),
+ __pthread_cond_timedwait_t64) __nonnull ((1, 2, 3));
+# else
+# define pthread_cond_timedwait __pthread_cond_timedwait_t64
+# endif
+#endif
extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex,
const struct timespec *__restrict __abstime)
diff --git a/sysdeps/pthread/semaphore.h b/sysdeps/pthread/semaphore.h
index ff672ebd24..0d2103a982 100644
--- a/sysdeps/pthread/semaphore.h
+++ b/sysdeps/pthread/semaphore.h
@@ -57,6 +57,16 @@ extern int sem_wait (sem_t *__sem);
This function is a cancellation point and therefore not marked with
__THROW. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern struct tm * __REDIRECT (sem_timedwait,
+ (sem_t *__restrict __sem,
+ const struct timespec *__restrict __abstime),
+ __sem_timedwait_t64);
+# else
+# define sem_timedwait __sem_timedwait_t64
+# endif
+#endif
extern int sem_timedwait (sem_t *__restrict __sem,
const struct timespec *__restrict __abstime);
#endif
diff --git a/sysdeps/unix/sysv/linux/bits/stat.h b/sysdeps/unix/sysv/linux/bits/stat.h
index 48ef82d862..fde673ef8d 100644
--- a/sysdeps/unix/sysv/linux/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/bits/stat.h
@@ -119,11 +119,11 @@ struct stat64
struct timespec st_mtim; /* Time of last modification. */
struct timespec st_ctim; /* Time of last status change. */
# else
- __time_t st_atime; /* Time of last access. */
+ time_t st_atime; /* Time of last access. */
unsigned long int st_atimensec; /* Nscecs of last access. */
- __time_t st_mtime; /* Time of last modification. */
+ time_t st_mtime; /* Time of last modification. */
unsigned long int st_mtimensec; /* Nsecs of last modification. */
- __time_t st_ctime; /* Time of last status change. */
+ time_t st_ctime; /* Time of last status change. */
unsigned long int st_ctimensec; /* Nsecs of last status change. */
# endif
__ino64_t st_ino; /* File serial number. */
diff --git a/sysdeps/unix/sysv/linux/sys/timerfd.h b/sysdeps/unix/sysv/linux/sys/timerfd.h
index 4d75e150a1..291f1f6342 100644
--- a/sysdeps/unix/sysv/linux/sys/timerfd.h
+++ b/sysdeps/unix/sysv/linux/sys/timerfd.h
@@ -43,11 +43,30 @@ extern int timerfd_create (__clockid_t __clock_id, int __flags) __THROW;
/* Set next expiration time of interval timer source UFD to UTMR. If
FLAGS has the TFD_TIMER_ABSTIME flag set the timeout value is
absolute. Optionally return the old expiration time in OTMR. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern int __REDIRECT (timerfd_settime, (int __ufd, int __flags,
+ const struct itimerspec *__utmr,
+ struct itimerspec *__otmr),__timerfd_settime64)
+ __THROW;
+# else
+# define timerfd_settime __timerfd_settime64
+# endif
+#endif
extern int timerfd_settime (int __ufd, int __flags,
const struct itimerspec *__utmr,
struct itimerspec *__otmr) __THROW;
/* Return the next expiration time of UFD. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern int __REDIRECT (timerfd_gettime, (int __ufd,
+ struct itimerspec *__otmr),__timerfd_gettime64)
+ __THROW;
+# else
+# define timerfd_gettime __timerfd_gettime64
+# endif
+#endif
extern int timerfd_gettime (int __ufd, struct itimerspec *__otmr) __THROW;
__END_DECLS
diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h
index 0d652c8aeb..4d9fe9bcda 100644
--- a/sysdeps/unix/sysv/linux/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/sys/timex.h
@@ -55,15 +55,43 @@ struct ntptimeval
__BEGIN_DECLS
extern int __adjtimex (struct timex *__ntx) __THROW;
+
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern time_t __REDIRECT (adjtimex, (struct timex *__ntx),
+ __adjtimex_t64) __THROW;
+# else
+# define adjtimex __adjtimex_t64
+# endif
+#endif
extern int adjtimex (struct timex *__ntx) __THROW;
-#ifdef __REDIRECT_NTH
+#if __WORDSIZE > 32 || ! defined(__USE_TIME_BITS64)
+# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
ntp_gettimex);
-#else
+# else
extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW;
+# define ntp_gettime ntp_gettimex
+# endif
+#else
+# if defined(__REDIRECT)
+extern time_t __REDIRECT (ntp_gettimex, (struct ntptimeval *__ntv),
+ __ntp_gettimex_t64) __THROW;
+# else
+# define ntp_gettimex __ntp_gettimex_t64
+# endif
# define ntp_gettime ntp_gettimex
#endif
+
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern int __REDIRECT (ntp_adjtime, (struct timex *__tntx),
+ __ntp_adjtime_t64) __THROW;
+# else
+# define ntp_adjtime __ntp_adjtime_t64
+# endif
+#endif
extern int ntp_adjtime (struct timex *__tntx) __THROW;
__END_DECLS
diff --git a/sysvipc/sys/msg.h b/sysvipc/sys/msg.h
index 1635839617..bfcba02812 100644
--- a/sysvipc/sys/msg.h
+++ b/sysvipc/sys/msg.h
@@ -58,6 +58,15 @@ struct msgbuf
__BEGIN_DECLS
/* Message queue control operation. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern int __REDIRECT (msgctl, (int __msqid, int __cmd,
+ struct msqid_ds *__buf),
+ __msgctl_t64) __THROW;
+# else
+# define msgctl __msgctl_t64
+# endif
+#endif
extern int msgctl (int __msqid, int __cmd, struct msqid_ds *__buf) __THROW;
/* Get messages queue. */
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..4db24b5b24 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),
+ __gettimeofday_t64) __THROW __nonnull((1));
+# else
+# define gettimeofday __gettimeofday_t64
+# 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),
+ __settimeofday_t64) __THROW;
+# else
+# define settimeofday __settimeofday_t64
+# 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),
+ __adjtime_t64) __THROW;
+# else
+# define adjtime __adjtime_t64
+# 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), __getitimer_t64)
+ __THROW;
+# else
+# define getitimer __getitimer_t64
+# 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), __setitimer_t64)
+ __THROW;
+# else
+# define setitimer __setitimer_t64
+# 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 49d30438f3..94271bb5c8 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),
+ __time_t64) __THROW;
+# else
+# define time __time_t64
+# 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), __stime_t64)
+ __THROW;
+# else
+# define stime __stime_t64
+# 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), __nanosleep_t64);
+# else
+# define nanosleep __nanosleep_t64
+# 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