aboutsummaryrefslogtreecommitdiff
path: root/io
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-02-17 13:35:19 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-06-15 10:42:11 -0300
commit47f24c21ee38701ae275aa9e451f70fa3e77478c (patch)
treeb4cc52206173fb2ed427a1e797769d12369a89ad /io
parent8af344feb5ae3e6e3374a6cf2175b44cc904a94e (diff)
downloadglibc-47f24c21ee38701ae275aa9e451f70fa3e77478c.tar
glibc-47f24c21ee38701ae275aa9e451f70fa3e77478c.tar.gz
glibc-47f24c21ee38701ae275aa9e451f70fa3e77478c.tar.bz2
glibc-47f24c21ee38701ae275aa9e451f70fa3e77478c.zip
y2038: Add support for 64-bit time on legacy ABIs
A new build flag, _TIME_BITS, enables the usage of the newer 64-bit time symbols for legacy ABI (where 32-bit time_t is default). The 64 bit time support is only enabled if LFS (_FILE_OFFSET_BITS=64) is also used. Different than LFS support, the y2038 symbols are added only for the required ABIs (armhf, csky, hppa, i386, m68k, microblaze, mips32, mips64-n32, nios2, powerpc32, sparc32, s390-32, and sh). The ABIs with 64-bit time support are unchanged, both for symbol and types redirection. On Linux the full 64-bit time support requires a minimum of kernel version v5.1. Otherwise, the 32-bit fallbacks are used and might results in error with overflow return code (EOVERFLOW). The i686-gnu does not yet support 64-bit time. This patch exports following rediretions to support 64-bit time: * libc: adjtime adjtimex clock_adjtime clock_getres clock_gettime clock_nanosleep clock_settime cnd_timedwait ctime ctime_r difftime fstat fstatat futimens futimes futimesat getitimer getrusage gettimeofday gmtime gmtime_r localtime localtime_r lstat_time lutimes mktime msgctl mtx_timedlock nanosleep nanosleep ntp_gettime ntp_gettimex ppoll pselec pselect pthread_clockjoin_np pthread_cond_clockwait pthread_cond_timedwait pthread_mutex_clocklock pthread_mutex_timedlock pthread_rwlock_clockrdlock pthread_rwlock_clockwrlock pthread_rwlock_timedrdlock pthread_rwlock_timedwrlock pthread_timedjoin_np recvmmsg sched_rr_get_interval select sem_clockwait semctl semtimedop sem_timedwait setitimer settimeofday shmctl sigtimedwait stat thrd_sleep time timegm timerfd_gettime timerfd_settime timespec_get utime utimensat utimes utimes wait3 wait4 * librt: aio_suspend mq_timedreceive mq_timedsend timer_gettime timer_settime * libanl: gai_suspend Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'io')
-rw-r--r--io/sys/poll.h11
-rw-r--r--io/sys/stat.h113
-rw-r--r--io/utime.h11
3 files changed, 125 insertions, 10 deletions
diff --git a/io/sys/poll.h b/io/sys/poll.h
index 08f29df540..e640efb2bc 100644
--- a/io/sys/poll.h
+++ b/io/sys/poll.h
@@ -66,6 +66,17 @@ extern int ppoll (struct pollfd *__fds, nfds_t __nfds,
const __sigset_t *__ss)
__attr_access ((__write_only__, 1, 2));
+# ifdef __USE_TIME_BITS64
+# ifdef __REDIRECT
+extern int __REDIRECT (ppoll, (struct pollfd *__fds, nfds_t __nfds,
+ const struct timespec *__timeout,
+ const __sigset_t *__ss),
+ __ppoll64)
+ __attr_access ((__write_only__, 1, 2));
+# else
+# define ppoll __ppoll64
+# endif
+# endif
#endif
__END_DECLS
diff --git a/io/sys/stat.h b/io/sys/stat.h
index 549375c087..f7874ec5ba 100644
--- a/io/sys/stat.h
+++ b/io/sys/stat.h
@@ -209,21 +209,51 @@ extern int stat (const char *__restrict __file,
that file descriptor FD is open on and put them in BUF. */
extern int fstat (int __fd, struct stat *__buf) __THROW __nonnull ((2));
#else
-# ifdef __REDIRECT_NTH
+# ifdef __USE_TIME_BITS64
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (stat, (const char *__restrict __file,
+ struct stat *__restrict __buf),
+ __stat64_time64)
+ __nonnull ((1, 2));
+extern int __REDIRECT_NTH (fstat, (int __fd, struct stat *__buf),
+ __fstat64_time64)
+ __nonnull ((2));
+# else
+# define stat __stat64_time64
+# define fstat __fstat64_time64
+# endif
+# else
+# ifdef __REDIRECT_NTH
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));
-# else
-# define stat stat64
-# define fstat fstat64
+# else
+# define stat stat64
+# define fstat fstat64
+# endif
# endif
#endif
#ifdef __USE_LARGEFILE64
+# ifndef __USE_TIME_BITS64
extern int stat64 (const char *__restrict __file,
struct stat64 *__restrict __buf) __THROW __nonnull ((1, 2));
extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
+# else
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (stat64, (const char *__restrict __file,
+ struct stat64 *__restrict __buf),
+ __stat64_time64)
+ __nonnull ((1, 2));
+extern int __REDIRECT_NTH (fstat64, (int __fd, struct stat64 *__buf),
+ __fstat64_time64)
+ __nonnull ((2));
+# else
+# define stat64 __stat64_time64
+# define fstat64 __fstat64_time
+# endif
+# endif
#endif
#ifdef __USE_ATFILE
@@ -235,20 +265,44 @@ extern int fstatat (int __fd, const char *__restrict __file,
struct stat *__restrict __buf, int __flag)
__THROW __nonnull ((2, 3));
# else
-# ifdef __REDIRECT_NTH
+# ifdef __USE_TIME_BITS64
+# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (fstatat, (int __fd, const char *__restrict __file,
struct stat *__restrict __buf,
int __flag),
- fstatat64) __nonnull ((2, 3));
+ __fstatat64_time64) __nonnull ((2, 3));
+# else
+# define fstatat __fstatat64_time64
+# endif
# else
-# define fstatat fstatat64
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (fstatat, (int __fd, const char *__restrict __file,
+ struct stat *__restrict __buf,
+ int __flag),
+ fstatat64) __nonnull ((2, 3));
+# else
+# define fstatat fstatat64
+# endif
# endif
# endif
# ifdef __USE_LARGEFILE64
+# ifndef __USE_TIME_BITS64
extern int fstatat64 (int __fd, const char *__restrict __file,
struct stat64 *__restrict __buf, int __flag)
__THROW __nonnull ((2, 3));
+# else
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (fstatat64, (int __fd,
+ const char *__restrict __file,
+ struct stat64 *__restrict __buf,
+ int __flag),
+ __fstatat64_time64)
+ __nonnull ((2, 3));
+# else
+# define fstatat64 __fstatat64_time64
+# endif
+# endif
# endif
#endif
@@ -259,19 +313,37 @@ extern int fstatat64 (int __fd, const char *__restrict __file,
extern int lstat (const char *__restrict __file,
struct stat *__restrict __buf) __THROW __nonnull ((1, 2));
# else
-# ifdef __REDIRECT_NTH
+# ifdef __USE_TIME_BITS64
+# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (lstat,
(const char *__restrict __file,
- struct stat *__restrict __buf), lstat64)
+ struct stat *__restrict __buf), __lstat64_time64)
__nonnull ((1, 2));
+# else
+# define lstat __lstat64_time64
+# endif
# else
-# define lstat lstat64
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (lstat,
+ (const char *__restrict __file,
+ struct stat *__restrict __buf), lstat64)
+ __nonnull ((1, 2));
+# else
+# define lstat lstat64
+# endif
# endif
# endif
# ifdef __USE_LARGEFILE64
+# ifndef __USE_TIME_BITS64
extern int lstat64 (const char *__restrict __file,
struct stat64 *__restrict __buf)
__THROW __nonnull ((1, 2));
+# else
+extern int __REDIRECT_NTH (lstat64, (const char *__restrict __file,
+ struct stat64 *__restrict __buf),
+ __lstat64_time64)
+ __nonnull ((1, 2));
+# endif
# endif
#endif
@@ -355,17 +427,38 @@ extern int mkfifoat (int __fd, const char *__path, __mode_t __mode)
#endif
#ifdef __USE_ATFILE
+# ifndef __USE_TIME_BITS64
/* Set file access and modification times relative to directory file
descriptor. */
extern int utimensat (int __fd, const char *__path,
const struct timespec __times[2],
int __flags)
__THROW __nonnull ((2));
+# else
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (utimensat, (int fd, const char *__path,
+ const struct timespec __times[2],
+ int flags),
+ __utimensat64) __nonnull ((2));
+# else
+# define utimensat __utimensat64
+# endif
+# endif
#endif
#ifdef __USE_XOPEN2K8
+# ifndef __USE_TIME_BITS64
/* Set file access and modification times of the file associated with FD. */
extern int futimens (int __fd, const struct timespec __times[2]) __THROW;
+
+# else
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (futimens, (int fd, const struct timespec __times[2]),
+ __futimens64);
+# else
+# define futimens __futimens64
+# endif
+# endif
#endif
#ifdef __USE_GNU
diff --git a/io/utime.h b/io/utime.h
index c7612d0838..1a645a3fff 100644
--- a/io/utime.h
+++ b/io/utime.h
@@ -46,10 +46,21 @@ struct utimbuf
/* 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. */
+#ifndef __USE_TIME_BITS64
extern int utime (const char *__file,
const struct utimbuf *__file_times)
__THROW __nonnull ((1));
+#else
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (utime, (const char *__file,
+ const struct utimbuf *__file_times),
+ __utime64);
+# else
+# define utime __utime64
+# endif
+#endif
+
__END_DECLS
#endif /* utime.h */