public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/y2038] y2038: Add test coverage
@ 2021-06-08 20:49 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2021-06-08 20:49 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f558cda3a3b767b96d14289522b005e754dd9b95

commit f558cda3a3b767b96d14289522b005e754dd9b95
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Feb 17 15:59:34 2021 -0300

    y2038: Add test coverage
    
    It is enabled through a new rule, tests-y2038, which is built only
    when the ABI supports the comapt 64-bit time_t (defined by the
    header time64-compat.h, which also enables the creation of the
    symbol Version for Linux).  It means the tests are not built
    for ABI which already provide default 64-bit time_t.
    
    The new rule already adds the required LFS and 64-bit time_t
    compiler flags.
    
    The current coverage is:
    
      * libc:
        - adjtime                       tst-adjtime-time64
        - adjtimex                      tst-adjtimex-time64
        - clock_adjtime                 tst-clock_adjtime-time64
        - clock_getres                  tst-clock-time64, tst-cpuclock1-time64
        - clock_gettime                 tst-clock-time64, tst-clock2-time64,
                                        tst-cpuclock1-time64
        - clock_nanosleep               tst-clock_nanosleep-time64,
                                        tst-cpuclock1-time64
        - clock_settime                 tst-clock2-time64
        - cnd_timedwait                 tst-cnd-timedwait-time64
        - ctime                         tst-ctime-time64
        - ctime_r                       tst-ctime-time64
        - difftime                      tst-difftime-time64
        - fstat                         tst-stat-time64
        - fstatat                       tst-stat-time64
        - futimens                      tst-futimens-time64
        - futimes                       tst-futimes-time64
        - futimesat                     tst-futimesat-time64
        - fts_*                         tst-fts-time64
        - getitimer                     tst-itimer-timer64
        - getrusage
        - gettimeofday                  tst-clock_nanosleep-time64
        - glob / globfree               tst-gnuglob64-time64
        - gmtime                        tst-gmtime-time64
        - gmtime_r                      tst-gmtime-time64
        - lstat                         tst-stat-time64
        - localtime                     tst-y2039-time64
        - localtime_t                   tst-y2039-time64
        - lutimes                       tst-lutimes-time64
        - mktime                        tst-mktime4-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - msgctl                        test-sysvmsg-time64
        - mtx_timedlock                 tst-mtx-timedlock-time64
        - nanosleep                     tst-cpuclock{12}-time64,
                                        tst-mqueue8-time64, tst-clock-time64
        - nftw / ftw                    ftwtest-time64
        - ntp_adjtime                   tst-ntp_adjtime-time64
        - ntp_gettime                   tst-ntp_gettime-time64
        - ntp_gettimex                  tst-ntp_gettimex-time64
        - ppoll                         tst-ppoll-time64
        - pselect                       tst-pselect-time64
        - pthread_clockjoin_np          tst-join14-time64
        - pthread_cond_clockwait        tst-cond11-time64
        - pthread_cond_timedwait        tst-abstime-time64
        - pthread_mutex_clocklock       tst-abstime-time64
        - pthread_mutex_timedlock       tst-abstime-time64
        - pthread_rwlock_clockrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_clockwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_timedjoin_np          tst-join14-time64
        - recvmmsg                      tst-cancel4_2-time64
        - sched_rr_get_interval         tst-sched_rr_get_interval-time64
        - select                        tst-select-time64
        - sem_clockwait                 tst-sem5-time64
        - sem_timedwait                 tst-sem5-time64
        - semctl                        test-sysvsem-time64
        - semtimedop                    test-sysvsem-time64
        - setitimer                     tst-mqueue2-time64, tst-itimer-timer64
        - settimeofday                  tst-settimeofday-time64
        - shmctl                        test-sysvshm-time64
        - sigtimedwait                  tst-sigtimedwait-time64
        - stat                          tst-stat-time64
        - thrd_sleep                    tst-thrd-sleep-time64
        - time                          tst-mqueue{1248}-time64
        - timegm                        tst-timegm-time64
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
        - timerfd_gettime               tst-timerfd-time64
        - timerfd_settime               tst-timerfd-time64
        - timespec_get                  tst-timespec_get-time64
        - timespec_getres               tst-timespec_getres-time64
        - utime                         tst-utime-time64
        - utimensat                     tst-utimensat-time64
        - utimes                        tst-utimes-time64
        - wait3                         tst-wait3-time64
        - wait4                         tst-wait4-time64
    
      * librt:
        - aio_suspend                   tst-aio6-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
    
      * 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>

Diff:
---
 Makeconfig                                         |  14 +++
 Makerules                                          |  18 +++-
 io/Makefile                                        |  22 ++++-
 io/ftwtest-time64.c                                |   1 +
 io/tst-fts-time64.c                                |   1 +
 io/tst-futimens-time64.c                           |   2 +
 io/tst-futimens.c                                  |   6 +-
 io/tst-futimes-time64.c                            |   2 +
 io/tst-futimes.c                                   |   6 +-
 io/tst-futimesat-time64.c                          |   4 +
 io/tst-futimesat.c                                 |  47 +++++++---
 io/tst-lutimes-time64.c                            |   2 +
 io/tst-lutimes.c                                   |  10 +-
 io/tst-stat-time64.c                               | 102 +++++++++++++++++++++
 io/tst-utime-time64.c                              |   2 +
 io/tst-utime.c                                     |   6 +-
 io/tst-utimensat-time64.c                          |   2 +
 io/tst-utimensat.c                                 |  12 ++-
 io/tst-utimes-time64.c                             |   2 +
 io/tst-utimes.c                                    |   6 +-
 misc/Makefile                                      |   4 +
 misc/tst-pselect-time64.c                          |   1 +
 misc/tst-select-time64.c                           |   1 +
 nptl/Makefile                                      |   3 +
 nptl/tst-cancel4_2-time64.c                        |   1 +
 posix/Makefile                                     |   2 +
 posix/tst-gnuglob64-time64.c                       |   7 ++
 posix/tst-sched_rr_get_interval-time64.c           |   1 +
 posix/tst-wait3-time64.c                           |   1 +
 posix/tst-wait4-time64.c                           |   1 +
 rt/Makefile                                        |   9 ++
 rt/tst-aio6-time64.c                               |   1 +
 rt/tst-cpuclock2-time64.c                          |   1 +
 rt/tst-cpuclock2.c                                 |   9 +-
 rt/tst-mqueue1-time64.c                            |   1 +
 rt/tst-mqueue2-time64.c                            |   1 +
 rt/tst-mqueue4-time64.c                            |   1 +
 rt/tst-mqueue8-time64.c                            |   1 +
 rt/tst-timer4-time64.c                             |   1 +
 sysdeps/pthread/Makefile                           |  10 ++
 sysdeps/pthread/tst-abstime-time64.c               |   1 +
 sysdeps/pthread/tst-cnd-timedwait-time64.c         |   1 +
 sysdeps/pthread/tst-cond11-time64.c                |   1 +
 sysdeps/pthread/tst-join14-time64.c                |   1 +
 sysdeps/pthread/tst-mtx-timedlock-time64.c         |   1 +
 sysdeps/pthread/tst-rwlock14-time64.c              |   1 +
 sysdeps/pthread/tst-sem5-time64.c                  |   1 +
 sysdeps/pthread/tst-thrd-sleep-time64.c            |   1 +
 sysdeps/unix/sysv/linux/Makefile                   |  10 ++
 sysdeps/unix/sysv/linux/tst-adjtimex-time64.c      |   1 +
 sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c |   1 +
 sysdeps/unix/sysv/linux/tst-ntp_adjtime-time64.c   |   1 +
 sysdeps/unix/sysv/linux/tst-ntp_gettime-time64.c   |   1 +
 sysdeps/unix/sysv/linux/tst-ntp_gettimex-time64.c  |   1 +
 sysdeps/unix/sysv/linux/tst-ppoll-time64.c         |   1 +
 sysdeps/unix/sysv/linux/tst-sigtimedwait-time64.c  |   1 +
 sysdeps/unix/sysv/linux/tst-timerfd-time64.c       |   1 +
 sysvipc/Makefile                                   |   2 +
 sysvipc/test-sysvmsg-time64.c                      |   1 +
 sysvipc/test-sysvsem-time64.c                      |   1 +
 sysvipc/test-sysvshm-time64.c                      |   1 +
 time/Makefile                                      |  18 ++++
 time/tst-adjtime-time64.c                          |   1 +
 time/tst-clock-time64.c                            |   1 +
 time/tst-clock2-time64.c                           |   1 +
 time/tst-clock_nanosleep-time64.c                  |   1 +
 time/tst-clock_settime-time64.c                    |   1 +
 time/tst-cpuclock1-time64.c                        |   1 +
 time/tst-ctime-time64.c                            |   1 +
 time/tst-ctime.c                                   |  16 ++++
 time/tst-difftime-time64.c                         |   1 +
 time/tst-gmtime-time64.c                           |   1 +
 time/tst-itimer-time64.c                           |   1 +
 time/tst-mktime4-time64.c                          |   1 +
 time/tst-settimeofday-time64.c                     |   1 +
 time/tst-timegm-time64.c                           |   1 +
 time/tst-timespec_get-time64.c                     |   1 +
 time/tst-timespec_getres-time64.c                  |   1 +
 time/tst-y2039-time64.c                            |   1 +
 time/tst-y2039.c                                   |  10 ++
 80 files changed, 385 insertions(+), 30 deletions(-)

diff --git a/Makeconfig b/Makeconfig
index c3496452b6..b6357d0b19 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1235,6 +1235,20 @@ $(common-objpfx)versions.stmp: $(common-objpfx)Versions.all \
 	touch $@
 endif # avoid-generated
 endif # $(build-shared) = yes
+
+-include $(common-objpfx)time64-compat.mk
+postclean-generated += time64-compat.mk
+
+$(common-objpfx)time64-compat.mk: $(sysd-versions-force) \
+				  $(common-objpfx)time64-compat.i
+	sed '/^[        ]*#/d;/^[       ]*$$/d' $< > $@T
+	mv -f $@T $@
+$(common-objpfx)time64-compat.i: $(..)Makeconfig
+	printf "#include <time64-compat.h>\n#ifdef TIME64_NON_DEFAULT\nhave-time64-compat = yes\n#endif" \
+	| $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - > $@T
+	mv -f $@T $@
+
+
 endif # sysd-sorted-done
 
 # The name under which the run-time dynamic linker is installed.
diff --git a/Makerules b/Makerules
index ca9885436e..12f1a5cb50 100644
--- a/Makerules
+++ b/Makerules
@@ -771,7 +771,8 @@ endif
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
 	     $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
-	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs))
+	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) \
+		$(test-srcs) $(tests-time64) $(xtests-time64))
 ifeq ($(build-programs),yes)
 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
 endif
@@ -1286,6 +1287,21 @@ check: tests
 .PHONY: xcheck
 xcheck: xtests
 
+# Handle tests-time64 and xtests-time64 that should built with LFS
+# and 64-bit time support.
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(tests-time64) $(xtests-time64),\
+	    $(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+ifeq ($(have-time64-compat),yes)
+tests += $(foreach t,$(tests-time64),$(t))
+xtests += $(foreach t,$(xtests-time64),$(t))
+endif
+
 # The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
 # that almost all internal declarations from config.h, libc-symbols.h, and
 # include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
diff --git a/io/Makefile b/io/Makefile
index d35e966258..ba8bd37355 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -59,7 +59,7 @@ routines :=								\
 	ftw64-time64
 
 others		:= pwd
-test-srcs	:= ftwtest
+test-srcs	:= ftwtest ftwtest-time64
 tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-fcntl bug-ftw1 bug-ftw2 bug-ftw3 bug-ftw4 tst-statvfs \
 		   tst-openat tst-unlinkat tst-fstatat tst-futimesat \
@@ -78,12 +78,24 @@ tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-futimens \
 		   tst-utimensat \
 
+tests-time64 := \
+  tst-futimens-time64 \
+  tst-futimes-time64\
+  tst-fts-time64 \
+  tst-lutimes-time64 \
+  tst-stat-time64 \
+  tst-futimesat-time64 \
+  tst-utime-time64 \
+  tst-utimensat-time64 \
+  tst-utimes-time64 \
+
 # Likewise for statx, but we do not need static linking here.
 tests-internal += tst-statx
 tests-static += tst-statx
 
 ifeq ($(run-built-tests),yes)
-tests-special += $(objpfx)ftwtest.out
+tests-special += $(objpfx)ftwtest.out \
+		 $(objpfx)ftwtest-time64.out
 endif
 
 include ../Rules
@@ -125,8 +137,14 @@ tst-statvfs-ARGS = $(objpfx)tst-statvfs tst-statvfs.c /tmp
 
 tst-open-tmpfile-ARGS = --test-dir=$(objpfx)
 
+CFLAGS-ftwtest-time64.c += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+
 ifeq ($(run-built-tests),yes)
 $(objpfx)ftwtest.out: ftwtest-sh $(objpfx)ftwtest
 	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
 	$(evaluate-test)
+
+$(objpfx)ftwtest-time64.out: ftwtest-sh $(objpfx)ftwtest-time64
+	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
+	$(evaluate-test)
 endif
diff --git a/io/ftwtest-time64.c b/io/ftwtest-time64.c
new file mode 100644
index 0000000000..67f1c46826
--- /dev/null
+++ b/io/ftwtest-time64.c
@@ -0,0 +1 @@
+#include "ftwtest.c"
diff --git a/io/tst-fts-time64.c b/io/tst-fts-time64.c
new file mode 100644
index 0000000000..a4a41fe1cf
--- /dev/null
+++ b/io/tst-fts-time64.c
@@ -0,0 +1 @@
+#include "tst-fts.c"
diff --git a/io/tst-futimens-time64.c b/io/tst-futimens-time64.c
new file mode 100644
index 0000000000..88fcb38489
--- /dev/null
+++ b/io/tst-futimens-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimens.c"
diff --git a/io/tst-futimens.c b/io/tst-futimens.c
index b3e3f3137f..4c18ede573 100644
--- a/io/tst-futimens.c
+++ b/io/tst-futimens.c
@@ -20,13 +20,17 @@
 #include <support/xunistd.h>
 #include <sys/stat.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_futimens_helper (const char *file, int fd, const struct timespec *ts)
 {
   int result = futimens (fd, ts);
   TEST_VERIFY_EXIT (result == 0);
 
-  struct stat64 st;
+  struct_stat st;
   xfstat (fd, &st);
 
   /* Check if seconds for atime match */
diff --git a/io/tst-futimes-time64.c b/io/tst-futimes-time64.c
new file mode 100644
index 0000000000..d489c265d1
--- /dev/null
+++ b/io/tst-futimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimes.c"
diff --git a/io/tst-futimes.c b/io/tst-futimes.c
index bdef38d7cb..9575a4b08e 100644
--- a/io/tst-futimes.c
+++ b/io/tst-futimes.c
@@ -21,13 +21,17 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_futimens_helper (const char *file, int fd, const struct timeval *tv)
 {
   int r = futimes (fd, tv);
   TEST_VERIFY_EXIT (r == 0);
 
-  struct stat64 st;
+  struct_stat st;
   xfstat (fd, &st);
 
   /* Check if seconds for atime match */
diff --git a/io/tst-futimesat-time64.c b/io/tst-futimesat-time64.c
new file mode 100644
index 0000000000..f6c0500eef
--- /dev/null
+++ b/io/tst-futimesat-time64.c
@@ -0,0 +1,4 @@
+#define struct_stat  struct stat
+#define fstat        fstat
+#define fstatat      fstatat
+#include "io/tst-futimesat.c"
diff --git a/io/tst-futimesat.c b/io/tst-futimesat.c
index af58ad06dd..c32ab2b668 100644
--- a/io/tst-futimesat.c
+++ b/io/tst-futimesat.c
@@ -1,4 +1,23 @@
+/* futimesat basic tests.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
 #include <dirent.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -7,19 +26,19 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#include <support/test-driver.h>
+#include <support/temp_file.h>
 
-static void prepare (void);
-#define PREPARE(argc, argv) prepare ()
-
-static int do_test (void);
-#define TEST_FUNCTION do_test ()
-
-#include "../test-skeleton.c"
+#ifndef struct_stat
+# define struct_stat struct stat64
+# define fstat       fstat64
+# define fstatat     fstatat64
+#endif
 
 static int dir_fd;
 
 static void
-prepare (void)
+prepare (int argc, char *argv[])
 {
   size_t test_dir_len = strlen (test_dir);
   static const char dir_name[] = "/tst-futimesat.XXXXXX";
@@ -48,7 +67,7 @@ prepare (void)
       exit (1);
     }
 }
-
+#define PREPARE prepare
 
 static int
 do_test (void)
@@ -98,8 +117,8 @@ do_test (void)
   write (fd, "hello", 5);
   puts ("file created");
 
-  struct stat64 st1;
-  if (fstat64 (fd, &st1) != 0)
+  struct_stat st1;
+  if (fstat (fd, &st1) != 0)
     {
       puts ("fstat64 failed");
       return 1;
@@ -118,8 +137,8 @@ do_test (void)
       return 1;
     }
 
-  struct stat64 st2;
-  if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0)
+  struct_stat st2;
+  if (fstatat (dir_fd, "some-file", &st2, 0) != 0)
     {
       puts ("fstatat64 failed");
       return 1;
@@ -146,3 +165,5 @@ do_test (void)
 
   return 0;
 }
+
+#include <support/test-driver.c>
diff --git a/io/tst-lutimes-time64.c b/io/tst-lutimes-time64.c
new file mode 100644
index 0000000000..06caec0a91
--- /dev/null
+++ b/io/tst-lutimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-lutimes.c"
diff --git a/io/tst-lutimes.c b/io/tst-lutimes.c
index b2da3c5796..237a870415 100644
--- a/io/tst-lutimes.c
+++ b/io/tst-lutimes.c
@@ -21,23 +21,27 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_lutimes_helper (const char *testfile, int fd, const char *testlink,
                      const struct timeval *tv)
 {
-  struct stat64 stfile_orig;
+  struct_stat stfile_orig;
   xlstat (testfile, &stfile_orig);
 
   TEST_VERIFY_EXIT (lutimes (testlink, tv) == 0);
 
-  struct stat64 stlink;
+  struct_stat stlink;
   xlstat (testlink, &stlink);
 
   TEST_COMPARE (stlink.st_atime, tv[0].tv_sec);
   TEST_COMPARE (stlink.st_mtime, tv[1].tv_sec);
 
   /* Check if the timestamp from original file is not changed.  */
-  struct stat64 stfile;
+  struct_stat stfile;
   xlstat (testfile, &stfile);
 
   TEST_COMPARE (stfile_orig.st_atime, stfile.st_atime);
diff --git a/io/tst-stat-time64.c b/io/tst-stat-time64.c
new file mode 100644
index 0000000000..c10fe1284a
--- /dev/null
+++ b/io/tst-stat-time64.c
@@ -0,0 +1,102 @@
+/* Basic test of stat with 64 bit time_t interfaces.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <support/check.h>
+#include <support/support.h>
+#include <support/temp_file.h>
+#include <support/xunistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+
+/* The idea of the test is check whether the 64 bit time_t stat implementation
+   returns the expected value for comparable fields, so it does not really
+   matter whether statx uses a fallback implementation or not.  */
+
+static void
+stat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (stat (path, st), 0);
+}
+
+static void
+lstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (lstat (path, st), 0);
+}
+
+static void
+fstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstat (fd, st), 0);
+}
+
+static void
+fstatat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstatat (fd, path, st, 0), 0);
+}
+
+typedef void (*test_t)(int, const char *path, struct stat *);
+
+static int
+do_test (void)
+{
+  char *path;
+  int fd = create_temp_file ("tst-statx-", &path);
+  TEST_VERIFY_EXIT (fd >= 0);
+  support_write_file_string (path, "abc");
+
+  struct statx stx;
+  TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0);
+
+  for (test_t *test = (test_t[]) { stat_check, lstat_check, fstat_check,
+				   fstatat_check, NULL };
+       *test != NULL; test++)
+  {
+    struct stat st;
+    (*test) (fd, path, &st);
+
+    TEST_COMPARE (stx.stx_dev_major, major (st.st_dev));
+    TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev));
+    TEST_COMPARE (stx.stx_ino, st.st_ino);
+    TEST_COMPARE (stx.stx_mode, st.st_mode);
+    TEST_COMPARE (stx.stx_nlink, st.st_nlink);
+    TEST_COMPARE (stx.stx_uid, st.st_uid);
+    TEST_COMPARE (stx.stx_gid, st.st_gid);
+    TEST_COMPARE (stx.stx_rdev_major, major (st.st_rdev));
+    TEST_COMPARE (stx.stx_rdev_minor, minor (st.st_rdev));
+    TEST_COMPARE (stx.stx_blksize, st.st_blksize);
+    TEST_COMPARE (stx.stx_blocks, st.st_blocks);
+
+    TEST_COMPARE (stx.stx_ctime.tv_sec, st.st_ctim.tv_sec);
+    TEST_COMPARE (stx.stx_ctime.tv_nsec, st.st_ctim.tv_nsec);
+    TEST_COMPARE (stx.stx_mtime.tv_sec, st.st_mtim.tv_sec);
+    TEST_COMPARE (stx.stx_mtime.tv_nsec, st.st_mtim.tv_nsec);
+  }
+
+  xclose (fd);
+  free (path);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/io/tst-utime-time64.c b/io/tst-utime-time64.c
new file mode 100644
index 0000000000..eb62f59126
--- /dev/null
+++ b/io/tst-utime-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utime.c"
diff --git a/io/tst-utime.c b/io/tst-utime.c
index 6269ef7929..0144e2a22a 100644
--- a/io/tst-utime.c
+++ b/io/tst-utime.c
@@ -21,13 +21,17 @@
 #include <support/xunistd.h>
 #include <sys/stat.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_utime_helper (const char *file, int fd, const struct utimbuf *ut)
 {
   int result = utime (file, ut);
   TEST_VERIFY_EXIT (result == 0);
 
-  struct stat64 st;
+  struct_stat st;
   xfstat (fd, &st);
 
   /* Check if seconds for actime match */
diff --git a/io/tst-utimensat-time64.c b/io/tst-utimensat-time64.c
new file mode 100644
index 0000000000..7ac7d8df1d
--- /dev/null
+++ b/io/tst-utimensat-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimensat.c"
diff --git a/io/tst-utimensat.c b/io/tst-utimensat.c
index 0c7c8470bc..062abdd8d3 100644
--- a/io/tst-utimensat.c
+++ b/io/tst-utimensat.c
@@ -22,6 +22,10 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_utimesat_helper (const char *testfile, int fd, const char *testlink,
                       const struct timespec *ts)
@@ -29,7 +33,7 @@ test_utimesat_helper (const char *testfile, int fd, const char *testlink,
   {
     TEST_VERIFY_EXIT (utimensat (fd, testfile, ts, 0) == 0);
 
-    struct stat64 st;
+    struct_stat st;
     xfstat (fd, &st);
 
     /* Check if seconds for atime match */
@@ -40,20 +44,20 @@ test_utimesat_helper (const char *testfile, int fd, const char *testlink,
   }
 
   {
-    struct stat64 stfile_orig;
+    struct_stat stfile_orig;
     xlstat (testfile, &stfile_orig);
 
     TEST_VERIFY_EXIT (utimensat (0 /* ignored  */, testlink, ts,
 				 AT_SYMLINK_NOFOLLOW)
 		       == 0);
-    struct stat64 stlink;
+    struct_stat stlink;
     xlstat (testlink, &stlink);
 
     TEST_COMPARE (stlink.st_atime, ts[0].tv_sec);
     TEST_COMPARE (stlink.st_mtime, ts[1].tv_sec);
 
     /* Check if the timestamp from original file is not changed.  */
-    struct stat64 stfile;
+    struct_stat stfile;
     xlstat (testfile, &stfile);
 
     TEST_COMPARE (stfile_orig.st_atime, stfile.st_atime);
diff --git a/io/tst-utimes-time64.c b/io/tst-utimes-time64.c
new file mode 100644
index 0000000000..234ec02541
--- /dev/null
+++ b/io/tst-utimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimes.c"
diff --git a/io/tst-utimes.c b/io/tst-utimes.c
index 991ab0c7d3..e88efff45b 100644
--- a/io/tst-utimes.c
+++ b/io/tst-utimes.c
@@ -22,13 +22,17 @@
 #include <sys/time.h>
 #include <time.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_utimes_helper (const char *file, int fd, const struct timeval *tv)
 {
   int result = utimes (file, tv);
   TEST_VERIFY_EXIT (result == 0);
 
-  struct stat64 st;
+  struct_stat st;
   xfstat (fd, &st);
 
   /* Check if seconds for atime match */
diff --git a/misc/Makefile b/misc/Makefile
index c103b6bff4..f34ab09fe3 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -90,6 +90,10 @@ tests := tst-dirname tst-tsearch tst-fdset tst-mntent tst-hsearch \
 	 tst-ldbl-warn tst-ldbl-error tst-dbl-efgcvt tst-ldbl-efgcvt \
 	 tst-mntent-autofs tst-syscalls tst-mntent-escape tst-select
 
+tests-time64 := \
+  tst-select-time64 \
+  tst-pselect-time64
+
 # Tests which need libdl.
 ifeq (yes,$(build-shared))
 tests += tst-gethostid
diff --git a/misc/tst-pselect-time64.c b/misc/tst-pselect-time64.c
new file mode 100644
index 0000000000..15a1e49292
--- /dev/null
+++ b/misc/tst-pselect-time64.c
@@ -0,0 +1 @@
+#include "tst-pselect.c"
diff --git a/misc/tst-select-time64.c b/misc/tst-select-time64.c
new file mode 100644
index 0000000000..13120bfe31
--- /dev/null
+++ b/misc/tst-select-time64.c
@@ -0,0 +1 @@
+#include "tst-select.c"
diff --git a/nptl/Makefile b/nptl/Makefile
index f7d7a2c7e2..727761e610 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -324,6 +324,9 @@ xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
 	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10 tst-setgroups \
 	tst-mutexpp5 tst-mutexpp9
 
+tests-time64 := \
+  tst-cancel4_2-time64
+
 # This test can run into task limits because of a linux kernel bug
 # and then cause the make process to fail too, see bug 24537.
 xtests += tst-eintr1
diff --git a/nptl/tst-cancel4_2-time64.c b/nptl/tst-cancel4_2-time64.c
new file mode 100644
index 0000000000..4ac086a312
--- /dev/null
+++ b/nptl/tst-cancel4_2-time64.c
@@ -0,0 +1 @@
+#include "tst-cancel4_2.c"
diff --git a/posix/Makefile b/posix/Makefile
index c8c538fcee..8d139e54f6 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -122,7 +122,9 @@ endif
 tests-internal	:= bug-regex5 bug-regex20 bug-regex33 \
 		   tst-rfc3484 tst-rfc3484-2 tst-rfc3484-3
 tests-container := bug-ga2
+tests-time64	:= tst-wait4-time64 tst-wait3-time64 tst-gnuglob64-time64
 xtests		:= tst-getaddrinfo4 tst-getaddrinfo5 tst-sched_rr_get_interval
+xtests-time64	:= tst-sched_rr_get_interval-time64
 ifeq (yes,$(build-shared))
 test-srcs	:= globtest
 tests           += wordexp-test tst-exec tst-spawn tst-spawn2 tst-spawn3
diff --git a/posix/tst-gnuglob64-time64.c b/posix/tst-gnuglob64-time64.c
new file mode 100644
index 0000000000..00922bcdc6
--- /dev/null
+++ b/posix/tst-gnuglob64-time64.c
@@ -0,0 +1,7 @@
+#define GLOB_FUNC glob
+#define GLOB_TYPE glob_t
+#define GLOBFREE_FUNC globfree
+#define DIRENT_STRUCT dirent
+#define STAT_STRUCT stat
+
+#include "tst-gnuglob-skeleton.c"
diff --git a/posix/tst-sched_rr_get_interval-time64.c b/posix/tst-sched_rr_get_interval-time64.c
new file mode 100644
index 0000000000..f4e66d2939
--- /dev/null
+++ b/posix/tst-sched_rr_get_interval-time64.c
@@ -0,0 +1 @@
+#include "tst-sched_rr_get_interval.c"
diff --git a/posix/tst-wait3-time64.c b/posix/tst-wait3-time64.c
new file mode 100644
index 0000000000..2837bc7a9e
--- /dev/null
+++ b/posix/tst-wait3-time64.c
@@ -0,0 +1 @@
+#include "tst-wait3.c"
diff --git a/posix/tst-wait4-time64.c b/posix/tst-wait4-time64.c
new file mode 100644
index 0000000000..12543b270f
--- /dev/null
+++ b/posix/tst-wait4-time64.c
@@ -0,0 +1 @@
+#include "tst-wait4.c"
diff --git a/rt/Makefile b/rt/Makefile
index 97c9bbd9de..797f2da51e 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -51,6 +51,15 @@ tests := tst-shm tst-timer tst-timer2 \
 	 tst-shm-cancel
 tests-internal := tst-timer-sigmask
 
+tests-time64 := \
+  tst-aio6-time64 \
+  tst-cpuclock2-time64 \
+  tst-mqueue1-time64 \
+  tst-mqueue2-time64 \
+  tst-mqueue4-time64 \
+  tst-mqueue8-time64 \
+  tst-timer4-time64
+
 extra-libs := librt
 extra-libs-others := $(extra-libs)
 
diff --git a/rt/tst-aio6-time64.c b/rt/tst-aio6-time64.c
new file mode 100644
index 0000000000..a386a577ec
--- /dev/null
+++ b/rt/tst-aio6-time64.c
@@ -0,0 +1 @@
+#include "tst-aio6.c"
diff --git a/rt/tst-cpuclock2-time64.c b/rt/tst-cpuclock2-time64.c
new file mode 100644
index 0000000000..05775522bb
--- /dev/null
+++ b/rt/tst-cpuclock2-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock2.c"
diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c
index c1c7ed2ad8..eebc3609d0 100644
--- a/rt/tst-cpuclock2.c
+++ b/rt/tst-cpuclock2.c
@@ -21,7 +21,11 @@
 
 #if (_POSIX_THREADS - 0) <= 0
 
-# define TEST_FUNCTION 0
+static int
+do_test ()
+{
+  return 0;
+}
 
 #else
 
@@ -330,7 +334,6 @@ do_test (void)
 
   return result;
 }
-# define TEST_FUNCTION do_test ()
 #endif
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/rt/tst-mqueue1-time64.c b/rt/tst-mqueue1-time64.c
new file mode 100644
index 0000000000..9c600a9a97
--- /dev/null
+++ b/rt/tst-mqueue1-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue1.c"
diff --git a/rt/tst-mqueue2-time64.c b/rt/tst-mqueue2-time64.c
new file mode 100644
index 0000000000..9d49f0b196
--- /dev/null
+++ b/rt/tst-mqueue2-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue2.c"
diff --git a/rt/tst-mqueue4-time64.c b/rt/tst-mqueue4-time64.c
new file mode 100644
index 0000000000..c23a228dc4
--- /dev/null
+++ b/rt/tst-mqueue4-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue4.c"
diff --git a/rt/tst-mqueue8-time64.c b/rt/tst-mqueue8-time64.c
new file mode 100644
index 0000000000..972637f7f5
--- /dev/null
+++ b/rt/tst-mqueue8-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue8.c"
diff --git a/rt/tst-timer4-time64.c b/rt/tst-timer4-time64.c
new file mode 100644
index 0000000000..e47a593f10
--- /dev/null
+++ b/rt/tst-timer4-time64.c
@@ -0,0 +1 @@
+#include "tst-timer4.c"
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index e4690a7bc4..9e6ed3c6f7 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -124,6 +124,16 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
 	 tst-unwind-thread \
 	 tst-pt-vfork1 tst-pt-vfork2 tst-vfork1x tst-vfork2x \
 
+tests-time64 := \
+  tst-abstime-time64 \
+  tst-cnd-timedwait-time64 \
+  tst-cond11-time64 \
+  tst-join14-time64 \
+  tst-mtx-timedlock-time64 \
+  tst-rwlock14-time64 \
+  tst-sem5-time64 \
+  tst-thrd-sleep-time64 \
+
 
 # Files which must not be linked with libpthread.
 tests-nolibpthread += tst-unload
diff --git a/sysdeps/pthread/tst-abstime-time64.c b/sysdeps/pthread/tst-abstime-time64.c
new file mode 100644
index 0000000000..2fc77cb365
--- /dev/null
+++ b/sysdeps/pthread/tst-abstime-time64.c
@@ -0,0 +1 @@
+#include "tst-abstime.c"
diff --git a/sysdeps/pthread/tst-cnd-timedwait-time64.c b/sysdeps/pthread/tst-cnd-timedwait-time64.c
new file mode 100644
index 0000000000..9b2abfd277
--- /dev/null
+++ b/sysdeps/pthread/tst-cnd-timedwait-time64.c
@@ -0,0 +1 @@
+#include "tst-cnd-timedwait.c"
diff --git a/sysdeps/pthread/tst-cond11-time64.c b/sysdeps/pthread/tst-cond11-time64.c
new file mode 100644
index 0000000000..9bccb8ec8b
--- /dev/null
+++ b/sysdeps/pthread/tst-cond11-time64.c
@@ -0,0 +1 @@
+#include "tst-cond11.c"
diff --git a/sysdeps/pthread/tst-join14-time64.c b/sysdeps/pthread/tst-join14-time64.c
new file mode 100644
index 0000000000..bed784ee24
--- /dev/null
+++ b/sysdeps/pthread/tst-join14-time64.c
@@ -0,0 +1 @@
+#include "tst-join14.c"
diff --git a/sysdeps/pthread/tst-mtx-timedlock-time64.c b/sysdeps/pthread/tst-mtx-timedlock-time64.c
new file mode 100644
index 0000000000..b3393c99ef
--- /dev/null
+++ b/sysdeps/pthread/tst-mtx-timedlock-time64.c
@@ -0,0 +1 @@
+#include "tst-mtx-timedlock.c"
diff --git a/sysdeps/pthread/tst-rwlock14-time64.c b/sysdeps/pthread/tst-rwlock14-time64.c
new file mode 100644
index 0000000000..ae9b1912cf
--- /dev/null
+++ b/sysdeps/pthread/tst-rwlock14-time64.c
@@ -0,0 +1 @@
+#include "tst-rwlock14.c"
diff --git a/sysdeps/pthread/tst-sem5-time64.c b/sysdeps/pthread/tst-sem5-time64.c
new file mode 100644
index 0000000000..89c2a14f94
--- /dev/null
+++ b/sysdeps/pthread/tst-sem5-time64.c
@@ -0,0 +1 @@
+#include "tst-sem5.c"
diff --git a/sysdeps/pthread/tst-thrd-sleep-time64.c b/sysdeps/pthread/tst-thrd-sleep-time64.c
new file mode 100644
index 0000000000..02837bd19f
--- /dev/null
+++ b/sysdeps/pthread/tst-thrd-sleep-time64.c
@@ -0,0 +1 @@
+#include "tst-thrd-sleep.c"
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index aedd02fd55..294c366e3b 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -125,6 +125,16 @@ endif
 
 tests-internal += tst-sigcontext-get_pc
 
+tests-time64 += \
+  tst-adjtimex-time64 \
+  tst-clock_adjtime-time64 \
+  tst-ntp_adjtime-time64 \
+  tst-ntp_gettime-time64 \
+  tst-ntp_gettimex-time64 \
+  tst-ppoll-time64 \
+  tst-sigtimedwait-time64 \
+  tst-timerfd-time64 \
+
 CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
 
 # Generate the list of SYS_* macros for the system calls (__NR_*
diff --git a/sysdeps/unix/sysv/linux/tst-adjtimex-time64.c b/sysdeps/unix/sysv/linux/tst-adjtimex-time64.c
new file mode 100644
index 0000000000..2b6988b7c4
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-adjtimex-time64.c
@@ -0,0 +1 @@
+#include "tst-adjtimex.c"
diff --git a/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c b/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
new file mode 100644
index 0000000000..9691e81229
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_adjtime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ntp_adjtime-time64.c b/sysdeps/unix/sysv/linux/tst-ntp_adjtime-time64.c
new file mode 100644
index 0000000000..30e7380b02
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ntp_adjtime-time64.c
@@ -0,0 +1 @@
+#include "tst-ntp_adjtime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ntp_gettime-time64.c b/sysdeps/unix/sysv/linux/tst-ntp_gettime-time64.c
new file mode 100644
index 0000000000..42caa66301
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ntp_gettime-time64.c
@@ -0,0 +1 @@
+#include "tst-ntp_gettime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ntp_gettimex-time64.c b/sysdeps/unix/sysv/linux/tst-ntp_gettimex-time64.c
new file mode 100644
index 0000000000..3f017b3c22
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ntp_gettimex-time64.c
@@ -0,0 +1 @@
+#include "tst-ntp_gettimex.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ppoll-time64.c b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
new file mode 100644
index 0000000000..96ee2faee3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
@@ -0,0 +1 @@
+#include "tst-ppoll.c"
diff --git a/sysdeps/unix/sysv/linux/tst-sigtimedwait-time64.c b/sysdeps/unix/sysv/linux/tst-sigtimedwait-time64.c
new file mode 100644
index 0000000000..1513e81749
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-sigtimedwait-time64.c
@@ -0,0 +1 @@
+#include "tst-sigtimedwait.c"
diff --git a/sysdeps/unix/sysv/linux/tst-timerfd-time64.c b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
new file mode 100644
index 0000000000..bb17f48139
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
@@ -0,0 +1 @@
+#include "tst-timerfd.c"
diff --git a/sysvipc/Makefile b/sysvipc/Makefile
index a534791928..86911803b5 100644
--- a/sysvipc/Makefile
+++ b/sysvipc/Makefile
@@ -32,6 +32,8 @@ routines := ftok \
 
 tests    := test-sysvmsg test-sysvsem test-sysvshm
 
+tests-time64 := test-sysvmsg-time64 test-sysvsem-time64 test-sysvshm-time64
+
 include ../Rules
 
 CFLAGS-msgrcv.c += -fexceptions -fasynchronous-unwind-tables
diff --git a/sysvipc/test-sysvmsg-time64.c b/sysvipc/test-sysvmsg-time64.c
new file mode 100644
index 0000000000..c23e0c337e
--- /dev/null
+++ b/sysvipc/test-sysvmsg-time64.c
@@ -0,0 +1 @@
+#include "test-sysvmsg.c"
diff --git a/sysvipc/test-sysvsem-time64.c b/sysvipc/test-sysvsem-time64.c
new file mode 100644
index 0000000000..05c95068cd
--- /dev/null
+++ b/sysvipc/test-sysvsem-time64.c
@@ -0,0 +1 @@
+#include "test-sysvsem.c"
diff --git a/sysvipc/test-sysvshm-time64.c b/sysvipc/test-sysvshm-time64.c
new file mode 100644
index 0000000000..8e2963f563
--- /dev/null
+++ b/sysvipc/test-sysvshm-time64.c
@@ -0,0 +1 @@
+#include "test-sysvshm.c"
diff --git a/time/Makefile b/time/Makefile
index 805c79c4d0..c84bd5d3ec 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -52,6 +52,24 @@ tests	:= test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
 	   tst-settimeofday tst-itimer tst-gmtime tst-timegm \
 	   tst-timespec_get tst-timespec_getres
 
+tests-time64 := \
+  tst-adjtime-time64 \
+  tst-clock-time64 \
+  tst-clock2-time64 \
+  tst-clock_nanosleep-time64 \
+  tst-clock_settime-time64 \
+  tst-cpuclock1-time64 \
+  tst-ctime-time64 \
+  tst-difftime-time64 \
+  tst-gmtime-time64 \
+  tst-itimer-time64 \
+  tst-mktime4-time64 \
+  tst-settimeofday-time64 \
+  tst-timegm-time64 \
+  tst-timespec_get-time64 \
+  tst-timespec_getres-time64 \
+  tst-y2039-time64
+
 include ../Rules
 
 ifeq ($(run-built-tests),yes)
diff --git a/time/tst-adjtime-time64.c b/time/tst-adjtime-time64.c
new file mode 100644
index 0000000000..097d6efc4b
--- /dev/null
+++ b/time/tst-adjtime-time64.c
@@ -0,0 +1 @@
+#include <tst-adjtime.c>
diff --git a/time/tst-clock-time64.c b/time/tst-clock-time64.c
new file mode 100644
index 0000000000..a1349678c8
--- /dev/null
+++ b/time/tst-clock-time64.c
@@ -0,0 +1 @@
+#include "tst-clock.c"
diff --git a/time/tst-clock2-time64.c b/time/tst-clock2-time64.c
new file mode 100644
index 0000000000..897f47b287
--- /dev/null
+++ b/time/tst-clock2-time64.c
@@ -0,0 +1 @@
+#include "tst-clock2.c"
diff --git a/time/tst-clock_nanosleep-time64.c b/time/tst-clock_nanosleep-time64.c
new file mode 100644
index 0000000000..c8638aa3d2
--- /dev/null
+++ b/time/tst-clock_nanosleep-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_nanosleep.c"
diff --git a/time/tst-clock_settime-time64.c b/time/tst-clock_settime-time64.c
new file mode 100644
index 0000000000..328b04a030
--- /dev/null
+++ b/time/tst-clock_settime-time64.c
@@ -0,0 +1 @@
+#include <tst-clock_settime.c>
diff --git a/time/tst-cpuclock1-time64.c b/time/tst-cpuclock1-time64.c
new file mode 100644
index 0000000000..5a7ffa27ac
--- /dev/null
+++ b/time/tst-cpuclock1-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock1.c"
diff --git a/time/tst-ctime-time64.c b/time/tst-ctime-time64.c
new file mode 100644
index 0000000000..24a5ae98ed
--- /dev/null
+++ b/time/tst-ctime-time64.c
@@ -0,0 +1 @@
+#include "tst-ctime.c"
diff --git a/time/tst-ctime.c b/time/tst-ctime.c
index e89a906bf8..884d69bfa0 100644
--- a/time/tst-ctime.c
+++ b/time/tst-ctime.c
@@ -24,6 +24,7 @@ static int
 do_test (void)
 {
   char *str;
+  char strb[32];
   time_t t;
 
   /* Use glibc time zone extension "TZ=:" to to guarantee that UTC
@@ -36,11 +37,21 @@ do_test (void)
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
+
   /* Check if the max time value for 32 bit time_t can be converted.  */
   t = 0x7fffffff;
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
+
   /* Check if we run on port with 32 bit time_t size */
   time_t tov;
   if (__builtin_add_overflow (t, 1, &tov))
@@ -50,6 +61,11 @@ do_test (void)
   str = ctime (&tov);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&tov, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
+
   return 0;
 }
 
diff --git a/time/tst-difftime-time64.c b/time/tst-difftime-time64.c
new file mode 100644
index 0000000000..751ce6c483
--- /dev/null
+++ b/time/tst-difftime-time64.c
@@ -0,0 +1 @@
+#include "tst-difftime.c"
diff --git a/time/tst-gmtime-time64.c b/time/tst-gmtime-time64.c
new file mode 100644
index 0000000000..0df11c1913
--- /dev/null
+++ b/time/tst-gmtime-time64.c
@@ -0,0 +1 @@
+#include "tst-gmtime.c"
diff --git a/time/tst-itimer-time64.c b/time/tst-itimer-time64.c
new file mode 100644
index 0000000000..ddd2efa175
--- /dev/null
+++ b/time/tst-itimer-time64.c
@@ -0,0 +1 @@
+#include <time/tst-itimer.c>
diff --git a/time/tst-mktime4-time64.c b/time/tst-mktime4-time64.c
new file mode 100644
index 0000000000..bf5197c6f3
--- /dev/null
+++ b/time/tst-mktime4-time64.c
@@ -0,0 +1 @@
+#include "tst-mktime4.c"
diff --git a/time/tst-settimeofday-time64.c b/time/tst-settimeofday-time64.c
new file mode 100644
index 0000000000..185d167a22
--- /dev/null
+++ b/time/tst-settimeofday-time64.c
@@ -0,0 +1 @@
+#include <tst-settimeofday.c>
diff --git a/time/tst-timegm-time64.c b/time/tst-timegm-time64.c
new file mode 100644
index 0000000000..8e3084f74e
--- /dev/null
+++ b/time/tst-timegm-time64.c
@@ -0,0 +1 @@
+#include "tst-timegm.c"
diff --git a/time/tst-timespec_get-time64.c b/time/tst-timespec_get-time64.c
new file mode 100644
index 0000000000..48f336385d
--- /dev/null
+++ b/time/tst-timespec_get-time64.c
@@ -0,0 +1 @@
+#include "tst-timespec_get.c"
diff --git a/time/tst-timespec_getres-time64.c b/time/tst-timespec_getres-time64.c
new file mode 100644
index 0000000000..59a0f36103
--- /dev/null
+++ b/time/tst-timespec_getres-time64.c
@@ -0,0 +1 @@
+#include "tst-timespec_getres.c"
diff --git a/time/tst-y2039-time64.c b/time/tst-y2039-time64.c
new file mode 100644
index 0000000000..3c8a504186
--- /dev/null
+++ b/time/tst-y2039-time64.c
@@ -0,0 +1 @@
+#include "tst-y2039.c"
diff --git a/time/tst-y2039.c b/time/tst-y2039.c
index ef024c0a77..66a22d4c2c 100644
--- a/time/tst-y2039.c
+++ b/time/tst-y2039.c
@@ -37,6 +37,16 @@ do_test (void)
 			> 0);
       puts (buf);
       TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
+
+      /* Same as before but for localtime_r.  */
+      struct tm tmd;
+      tm = localtime_r (&ouch, &tmd);
+      TEST_VERIFY_EXIT (tm == &tmd);
+
+      TEST_VERIFY_EXIT (strftime (buf, sizeof buf, "%Y-%m-%d %H:%M:%S %Z", tm)
+			> 0);
+      puts (buf);
+      TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
     }
   else
     FAIL_UNSUPPORTED ("32-bit time_t");


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [glibc/azanella/y2038] y2038: Add test coverage
@ 2021-05-26 16:26 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2021-05-26 16:26 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4cf9a969e6f3ecdf40042e89b4f77cb0a2383afa

commit 4cf9a969e6f3ecdf40042e89b4f77cb0a2383afa
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Feb 17 15:59:34 2021 -0300

    y2038: Add test coverage
    
    It is enabled through a new rule, tests-y2038, which is built only
    when the ABI supports the comapt 64-bit time_t (defined by the
    header time64-compat.h, which also enables the creation of the
    symbol Version for Linux).  It means the tests are not built
    for ABI which already provide default 64-bit time_t.
    
    The new rule already adds the required LFS and 64-bit time_t
    compiler flags.
    
    The current coverage is:
    
      * libc:
        - adjtime                       tst-adjtime-time64
        - adjtimex                      tst-adjtimex-time64
        - clock_adjtime                 tst-clock_adjtime-time64
        - clock_getres                  tst-clock-time64, tst-cpuclock1-time64
        - clock_gettime                 tst-clock-time64, tst-clock2-time64,
                                        tst-cpuclock1-time64
        - clock_nanosleep               tst-clock_nanosleep-time64,
                                        tst-cpuclock1-time64
        - clock_settime                 tst-clock2-time64
        - cnd_timedwait                 tst-cnd-timedwait-time64
        - ctime                         tst-ctime-time64
        - ctime_r                       tst-ctime-time64
        - difftime                      tst-difftime-time64
        - fstat                         tst-stat-time64
        - fstatat                       tst-stat-time64
        - futimens                      tst-futimens-time64
        - futimes                       tst-futimes-time64
        - futimesat                     tst-futimesat-time64
        - fts_*                         tst-fts-time64
        - getitimer                     tst-itimer-timer64
        - getrusage
        - gettimeofday                  tst-clock_nanosleep-time64
        - glob / globfree               tst-gnuglob64-time64
        - gmtime                        tst-gmtime-time64
        - gmtime_r                      tst-gmtime-time64
        - lstat                         tst-stat-time64
        - localtime                     tst-y2039-time64
        - localtime_t                   tst-y2039-time64
        - lutimes                       tst-lutimes-time64
        - mktime                        tst-mktime4-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - msgctl                        test-sysvmsg-time64
        - mtx_timedlock                 tst-mtx-timedlock-time64
        - nanosleep                     tst-cpuclock{12}-time64,
                                        tst-mqueue8-time64, tst-clock-time64
        - nftw / ftw                    ftwtest-time64
        - ntp_adjtime                   tst-ntp_adjtime-time64
        - ntp_gettime                   tst-ntp_gettime-time64
        - ntp_gettimex                  tst-ntp_gettimex-time64
        - ppoll                         tst-ppoll-time64
        - pselect                       tst-pselect-time64
        - pthread_clockjoin_np          tst-join14-time64
        - pthread_cond_clockwait        tst-cond11-time64
        - pthread_cond_timedwait        tst-abstime-time64
        - pthread_mutex_clocklock       tst-abstime-time64
        - pthread_mutex_timedlock       tst-abstime-time64
        - pthread_rwlock_clockrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_clockwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_timedjoin_np          tst-join14-time64
        - recvmmsg                      tst-cancel4_2-time64
        - sched_rr_get_interval         tst-sched_rr_get_interval-time64
        - select                        tst-select-time64
        - sem_clockwait                 tst-sem5-time64
        - sem_timedwait                 tst-sem5-time64
        - semctl                        test-sysvsem-time64
        - semtimedop                    test-sysvsem-time64
        - setitimer                     tst-mqueue2-time64, tst-itimer-timer64
        - settimeofday                  tst-settimeofday-time64
        - shmctl                        test-sysvshm-time64
        - sigtimedwait                  tst-sigtimedwait-time64
        - stat                          tst-stat-time64
        - thrd_sleep                    tst-thrd-sleep-time64
        - time                          tst-mqueue{1248}-time64
        - timegm                        tst-timegm-time64
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
        - timerfd_gettime               tst-timerfd-time64
        - timerfd_settime               tst-timerfd-time64
        - timespec_get                  tst-timespec_get-time64
        - timespec_getres               tst-timespec_getres-time64
        - utime                         tst-utime-time64
        - utimensat                     tst-utimensat-time64
        - utimes                        tst-utimes-time64
        - wait3                         tst-wait3-time64
        - wait4                         tst-wait4-time64
    
      * librt:
        - aio_suspend                   tst-aio6-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
    
      * libanl:
        - gai_suspend

Diff:
---
 Makeconfig                                         |  14 +++
 Makerules                                          |  18 +++-
 io/Makefile                                        |  22 ++++-
 io/ftwtest-time64.c                                |   1 +
 io/tst-fts-time64.c                                |   1 +
 io/tst-futimens-time64.c                           |   2 +
 io/tst-futimens.c                                  |   6 +-
 io/tst-futimes-time64.c                            |   2 +
 io/tst-futimes.c                                   |   6 +-
 io/tst-futimesat-time64.c                          |   4 +
 io/tst-futimesat.c                                 |  47 +++++++---
 io/tst-lutimes-time64.c                            |   2 +
 io/tst-lutimes.c                                   |  10 +-
 io/tst-stat-time64.c                               | 102 +++++++++++++++++++++
 io/tst-utime-time64.c                              |   2 +
 io/tst-utime.c                                     |   6 +-
 io/tst-utimensat-time64.c                          |   2 +
 io/tst-utimensat.c                                 |  12 ++-
 io/tst-utimes-time64.c                             |   2 +
 io/tst-utimes.c                                    |   6 +-
 misc/Makefile                                      |   4 +
 misc/tst-pselect-time64.c                          |   1 +
 misc/tst-select-time64.c                           |   1 +
 nptl/Makefile                                      |   3 +
 nptl/tst-cancel4_2-time64.c                        |   1 +
 posix/Makefile                                     |   2 +
 posix/tst-gnuglob64-time64.c                       |   7 ++
 posix/tst-sched_rr_get_interval-time64.c           |   1 +
 posix/tst-wait3-time64.c                           |   1 +
 posix/tst-wait4-time64.c                           |   1 +
 rt/Makefile                                        |   9 ++
 rt/tst-aio6-time64.c                               |   1 +
 rt/tst-cpuclock2-time64.c                          |   1 +
 rt/tst-cpuclock2.c                                 |   9 +-
 rt/tst-mqueue1-time64.c                            |   1 +
 rt/tst-mqueue2-time64.c                            |   1 +
 rt/tst-mqueue4-time64.c                            |   1 +
 rt/tst-mqueue8-time64.c                            |   1 +
 rt/tst-timer4-time64.c                             |   1 +
 sysdeps/pthread/Makefile                           |  10 ++
 sysdeps/pthread/tst-abstime-time64.c               |   1 +
 sysdeps/pthread/tst-cnd-timedwait-time64.c         |   1 +
 sysdeps/pthread/tst-cond11-time64.c                |   1 +
 sysdeps/pthread/tst-join14-time64.c                |   1 +
 sysdeps/pthread/tst-mtx-timedlock-time64.c         |   1 +
 sysdeps/pthread/tst-rwlock14-time64.c              |   1 +
 sysdeps/pthread/tst-sem5-time64.c                  |   1 +
 sysdeps/pthread/tst-thrd-sleep-time64.c            |   1 +
 sysdeps/unix/sysv/linux/Makefile                   |  10 ++
 sysdeps/unix/sysv/linux/tst-adjtimex-time64.c      |   1 +
 sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c |   1 +
 sysdeps/unix/sysv/linux/tst-ntp_adjtime-time64.c   |   1 +
 sysdeps/unix/sysv/linux/tst-ntp_gettime-time64.c   |   1 +
 sysdeps/unix/sysv/linux/tst-ntp_gettimex-time64.c  |   1 +
 sysdeps/unix/sysv/linux/tst-ppoll-time64.c         |   1 +
 sysdeps/unix/sysv/linux/tst-sigtimedwait-time64.c  |   1 +
 sysdeps/unix/sysv/linux/tst-timerfd-time64.c       |   1 +
 sysvipc/Makefile                                   |   2 +
 sysvipc/test-sysvmsg-time64.c                      |   1 +
 sysvipc/test-sysvsem-time64.c                      |   1 +
 sysvipc/test-sysvshm-time64.c                      |   1 +
 time/Makefile                                      |  18 ++++
 time/tst-adjtime-time64.c                          |   1 +
 time/tst-clock-time64.c                            |   1 +
 time/tst-clock2-time64.c                           |   1 +
 time/tst-clock_nanosleep-time64.c                  |   1 +
 time/tst-clock_settime-time64.c                    |   1 +
 time/tst-cpuclock1-time64.c                        |   1 +
 time/tst-ctime-time64.c                            |   1 +
 time/tst-ctime.c                                   |  16 ++++
 time/tst-difftime-time64.c                         |   1 +
 time/tst-gmtime-time64.c                           |   1 +
 time/tst-itimer-time64.c                           |   1 +
 time/tst-mktime4-time64.c                          |   1 +
 time/tst-settimeofday-time64.c                     |   1 +
 time/tst-timegm-time64.c                           |   1 +
 time/tst-timespec_get-time64.c                     |   1 +
 time/tst-timespec_getres-time64.c                  |   1 +
 time/tst-y2039-time64.c                            |   1 +
 time/tst-y2039.c                                   |  10 ++
 80 files changed, 385 insertions(+), 30 deletions(-)

diff --git a/Makeconfig b/Makeconfig
index 1d5e45926c..e50d1351a9 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1235,6 +1235,20 @@ $(common-objpfx)versions.stmp: $(common-objpfx)Versions.all \
 	touch $@
 endif # avoid-generated
 endif # $(build-shared) = yes
+
+-include $(common-objpfx)time64-compat.mk
+postclean-generated += time64-compat.mk
+
+$(common-objpfx)time64-compat.mk: $(sysd-versions-force) \
+				  $(common-objpfx)time64-compat.i
+	sed '/^[        ]*#/d;/^[       ]*$$/d' $< > $@T
+	mv -f $@T $@
+$(common-objpfx)time64-compat.i: $(..)Makeconfig
+	printf "#include <time64-compat.h>\n#ifdef TIME64_NON_DEFAULT\nhave-time64-compat = yes\n#endif" \
+	| $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - > $@T
+	mv -f $@T $@
+
+
 endif # sysd-sorted-done
 
 # The name under which the run-time dynamic linker is installed.
diff --git a/Makerules b/Makerules
index ca9885436e..12f1a5cb50 100644
--- a/Makerules
+++ b/Makerules
@@ -771,7 +771,8 @@ endif
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
 	     $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
-	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs))
+	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) \
+		$(test-srcs) $(tests-time64) $(xtests-time64))
 ifeq ($(build-programs),yes)
 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
 endif
@@ -1286,6 +1287,21 @@ check: tests
 .PHONY: xcheck
 xcheck: xtests
 
+# Handle tests-time64 and xtests-time64 that should built with LFS
+# and 64-bit time support.
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(tests-time64) $(xtests-time64),\
+	    $(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+ifeq ($(have-time64-compat),yes)
+tests += $(foreach t,$(tests-time64),$(t))
+xtests += $(foreach t,$(xtests-time64),$(t))
+endif
+
 # The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
 # that almost all internal declarations from config.h, libc-symbols.h, and
 # include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
diff --git a/io/Makefile b/io/Makefile
index d35e966258..ba8bd37355 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -59,7 +59,7 @@ routines :=								\
 	ftw64-time64
 
 others		:= pwd
-test-srcs	:= ftwtest
+test-srcs	:= ftwtest ftwtest-time64
 tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-fcntl bug-ftw1 bug-ftw2 bug-ftw3 bug-ftw4 tst-statvfs \
 		   tst-openat tst-unlinkat tst-fstatat tst-futimesat \
@@ -78,12 +78,24 @@ tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-futimens \
 		   tst-utimensat \
 
+tests-time64 := \
+  tst-futimens-time64 \
+  tst-futimes-time64\
+  tst-fts-time64 \
+  tst-lutimes-time64 \
+  tst-stat-time64 \
+  tst-futimesat-time64 \
+  tst-utime-time64 \
+  tst-utimensat-time64 \
+  tst-utimes-time64 \
+
 # Likewise for statx, but we do not need static linking here.
 tests-internal += tst-statx
 tests-static += tst-statx
 
 ifeq ($(run-built-tests),yes)
-tests-special += $(objpfx)ftwtest.out
+tests-special += $(objpfx)ftwtest.out \
+		 $(objpfx)ftwtest-time64.out
 endif
 
 include ../Rules
@@ -125,8 +137,14 @@ tst-statvfs-ARGS = $(objpfx)tst-statvfs tst-statvfs.c /tmp
 
 tst-open-tmpfile-ARGS = --test-dir=$(objpfx)
 
+CFLAGS-ftwtest-time64.c += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+
 ifeq ($(run-built-tests),yes)
 $(objpfx)ftwtest.out: ftwtest-sh $(objpfx)ftwtest
 	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
 	$(evaluate-test)
+
+$(objpfx)ftwtest-time64.out: ftwtest-sh $(objpfx)ftwtest-time64
+	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
+	$(evaluate-test)
 endif
diff --git a/io/ftwtest-time64.c b/io/ftwtest-time64.c
new file mode 100644
index 0000000000..67f1c46826
--- /dev/null
+++ b/io/ftwtest-time64.c
@@ -0,0 +1 @@
+#include "ftwtest.c"
diff --git a/io/tst-fts-time64.c b/io/tst-fts-time64.c
new file mode 100644
index 0000000000..a4a41fe1cf
--- /dev/null
+++ b/io/tst-fts-time64.c
@@ -0,0 +1 @@
+#include "tst-fts.c"
diff --git a/io/tst-futimens-time64.c b/io/tst-futimens-time64.c
new file mode 100644
index 0000000000..88fcb38489
--- /dev/null
+++ b/io/tst-futimens-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimens.c"
diff --git a/io/tst-futimens.c b/io/tst-futimens.c
index b3e3f3137f..4c18ede573 100644
--- a/io/tst-futimens.c
+++ b/io/tst-futimens.c
@@ -20,13 +20,17 @@
 #include <support/xunistd.h>
 #include <sys/stat.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_futimens_helper (const char *file, int fd, const struct timespec *ts)
 {
   int result = futimens (fd, ts);
   TEST_VERIFY_EXIT (result == 0);
 
-  struct stat64 st;
+  struct_stat st;
   xfstat (fd, &st);
 
   /* Check if seconds for atime match */
diff --git a/io/tst-futimes-time64.c b/io/tst-futimes-time64.c
new file mode 100644
index 0000000000..d489c265d1
--- /dev/null
+++ b/io/tst-futimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimes.c"
diff --git a/io/tst-futimes.c b/io/tst-futimes.c
index bdef38d7cb..9575a4b08e 100644
--- a/io/tst-futimes.c
+++ b/io/tst-futimes.c
@@ -21,13 +21,17 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_futimens_helper (const char *file, int fd, const struct timeval *tv)
 {
   int r = futimes (fd, tv);
   TEST_VERIFY_EXIT (r == 0);
 
-  struct stat64 st;
+  struct_stat st;
   xfstat (fd, &st);
 
   /* Check if seconds for atime match */
diff --git a/io/tst-futimesat-time64.c b/io/tst-futimesat-time64.c
new file mode 100644
index 0000000000..f6c0500eef
--- /dev/null
+++ b/io/tst-futimesat-time64.c
@@ -0,0 +1,4 @@
+#define struct_stat  struct stat
+#define fstat        fstat
+#define fstatat      fstatat
+#include "io/tst-futimesat.c"
diff --git a/io/tst-futimesat.c b/io/tst-futimesat.c
index af58ad06dd..c32ab2b668 100644
--- a/io/tst-futimesat.c
+++ b/io/tst-futimesat.c
@@ -1,4 +1,23 @@
+/* futimesat basic tests.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
 #include <dirent.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -7,19 +26,19 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#include <support/test-driver.h>
+#include <support/temp_file.h>
 
-static void prepare (void);
-#define PREPARE(argc, argv) prepare ()
-
-static int do_test (void);
-#define TEST_FUNCTION do_test ()
-
-#include "../test-skeleton.c"
+#ifndef struct_stat
+# define struct_stat struct stat64
+# define fstat       fstat64
+# define fstatat     fstatat64
+#endif
 
 static int dir_fd;
 
 static void
-prepare (void)
+prepare (int argc, char *argv[])
 {
   size_t test_dir_len = strlen (test_dir);
   static const char dir_name[] = "/tst-futimesat.XXXXXX";
@@ -48,7 +67,7 @@ prepare (void)
       exit (1);
     }
 }
-
+#define PREPARE prepare
 
 static int
 do_test (void)
@@ -98,8 +117,8 @@ do_test (void)
   write (fd, "hello", 5);
   puts ("file created");
 
-  struct stat64 st1;
-  if (fstat64 (fd, &st1) != 0)
+  struct_stat st1;
+  if (fstat (fd, &st1) != 0)
     {
       puts ("fstat64 failed");
       return 1;
@@ -118,8 +137,8 @@ do_test (void)
       return 1;
     }
 
-  struct stat64 st2;
-  if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0)
+  struct_stat st2;
+  if (fstatat (dir_fd, "some-file", &st2, 0) != 0)
     {
       puts ("fstatat64 failed");
       return 1;
@@ -146,3 +165,5 @@ do_test (void)
 
   return 0;
 }
+
+#include <support/test-driver.c>
diff --git a/io/tst-lutimes-time64.c b/io/tst-lutimes-time64.c
new file mode 100644
index 0000000000..06caec0a91
--- /dev/null
+++ b/io/tst-lutimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-lutimes.c"
diff --git a/io/tst-lutimes.c b/io/tst-lutimes.c
index b2da3c5796..237a870415 100644
--- a/io/tst-lutimes.c
+++ b/io/tst-lutimes.c
@@ -21,23 +21,27 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_lutimes_helper (const char *testfile, int fd, const char *testlink,
                      const struct timeval *tv)
 {
-  struct stat64 stfile_orig;
+  struct_stat stfile_orig;
   xlstat (testfile, &stfile_orig);
 
   TEST_VERIFY_EXIT (lutimes (testlink, tv) == 0);
 
-  struct stat64 stlink;
+  struct_stat stlink;
   xlstat (testlink, &stlink);
 
   TEST_COMPARE (stlink.st_atime, tv[0].tv_sec);
   TEST_COMPARE (stlink.st_mtime, tv[1].tv_sec);
 
   /* Check if the timestamp from original file is not changed.  */
-  struct stat64 stfile;
+  struct_stat stfile;
   xlstat (testfile, &stfile);
 
   TEST_COMPARE (stfile_orig.st_atime, stfile.st_atime);
diff --git a/io/tst-stat-time64.c b/io/tst-stat-time64.c
new file mode 100644
index 0000000000..c10fe1284a
--- /dev/null
+++ b/io/tst-stat-time64.c
@@ -0,0 +1,102 @@
+/* Basic test of stat with 64 bit time_t interfaces.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <support/check.h>
+#include <support/support.h>
+#include <support/temp_file.h>
+#include <support/xunistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+
+/* The idea of the test is check whether the 64 bit time_t stat implementation
+   returns the expected value for comparable fields, so it does not really
+   matter whether statx uses a fallback implementation or not.  */
+
+static void
+stat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (stat (path, st), 0);
+}
+
+static void
+lstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (lstat (path, st), 0);
+}
+
+static void
+fstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstat (fd, st), 0);
+}
+
+static void
+fstatat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstatat (fd, path, st, 0), 0);
+}
+
+typedef void (*test_t)(int, const char *path, struct stat *);
+
+static int
+do_test (void)
+{
+  char *path;
+  int fd = create_temp_file ("tst-statx-", &path);
+  TEST_VERIFY_EXIT (fd >= 0);
+  support_write_file_string (path, "abc");
+
+  struct statx stx;
+  TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0);
+
+  for (test_t *test = (test_t[]) { stat_check, lstat_check, fstat_check,
+				   fstatat_check, NULL };
+       *test != NULL; test++)
+  {
+    struct stat st;
+    (*test) (fd, path, &st);
+
+    TEST_COMPARE (stx.stx_dev_major, major (st.st_dev));
+    TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev));
+    TEST_COMPARE (stx.stx_ino, st.st_ino);
+    TEST_COMPARE (stx.stx_mode, st.st_mode);
+    TEST_COMPARE (stx.stx_nlink, st.st_nlink);
+    TEST_COMPARE (stx.stx_uid, st.st_uid);
+    TEST_COMPARE (stx.stx_gid, st.st_gid);
+    TEST_COMPARE (stx.stx_rdev_major, major (st.st_rdev));
+    TEST_COMPARE (stx.stx_rdev_minor, minor (st.st_rdev));
+    TEST_COMPARE (stx.stx_blksize, st.st_blksize);
+    TEST_COMPARE (stx.stx_blocks, st.st_blocks);
+
+    TEST_COMPARE (stx.stx_ctime.tv_sec, st.st_ctim.tv_sec);
+    TEST_COMPARE (stx.stx_ctime.tv_nsec, st.st_ctim.tv_nsec);
+    TEST_COMPARE (stx.stx_mtime.tv_sec, st.st_mtim.tv_sec);
+    TEST_COMPARE (stx.stx_mtime.tv_nsec, st.st_mtim.tv_nsec);
+  }
+
+  xclose (fd);
+  free (path);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/io/tst-utime-time64.c b/io/tst-utime-time64.c
new file mode 100644
index 0000000000..eb62f59126
--- /dev/null
+++ b/io/tst-utime-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utime.c"
diff --git a/io/tst-utime.c b/io/tst-utime.c
index 6269ef7929..0144e2a22a 100644
--- a/io/tst-utime.c
+++ b/io/tst-utime.c
@@ -21,13 +21,17 @@
 #include <support/xunistd.h>
 #include <sys/stat.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_utime_helper (const char *file, int fd, const struct utimbuf *ut)
 {
   int result = utime (file, ut);
   TEST_VERIFY_EXIT (result == 0);
 
-  struct stat64 st;
+  struct_stat st;
   xfstat (fd, &st);
 
   /* Check if seconds for actime match */
diff --git a/io/tst-utimensat-time64.c b/io/tst-utimensat-time64.c
new file mode 100644
index 0000000000..7ac7d8df1d
--- /dev/null
+++ b/io/tst-utimensat-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimensat.c"
diff --git a/io/tst-utimensat.c b/io/tst-utimensat.c
index 0c7c8470bc..062abdd8d3 100644
--- a/io/tst-utimensat.c
+++ b/io/tst-utimensat.c
@@ -22,6 +22,10 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_utimesat_helper (const char *testfile, int fd, const char *testlink,
                       const struct timespec *ts)
@@ -29,7 +33,7 @@ test_utimesat_helper (const char *testfile, int fd, const char *testlink,
   {
     TEST_VERIFY_EXIT (utimensat (fd, testfile, ts, 0) == 0);
 
-    struct stat64 st;
+    struct_stat st;
     xfstat (fd, &st);
 
     /* Check if seconds for atime match */
@@ -40,20 +44,20 @@ test_utimesat_helper (const char *testfile, int fd, const char *testlink,
   }
 
   {
-    struct stat64 stfile_orig;
+    struct_stat stfile_orig;
     xlstat (testfile, &stfile_orig);
 
     TEST_VERIFY_EXIT (utimensat (0 /* ignored  */, testlink, ts,
 				 AT_SYMLINK_NOFOLLOW)
 		       == 0);
-    struct stat64 stlink;
+    struct_stat stlink;
     xlstat (testlink, &stlink);
 
     TEST_COMPARE (stlink.st_atime, ts[0].tv_sec);
     TEST_COMPARE (stlink.st_mtime, ts[1].tv_sec);
 
     /* Check if the timestamp from original file is not changed.  */
-    struct stat64 stfile;
+    struct_stat stfile;
     xlstat (testfile, &stfile);
 
     TEST_COMPARE (stfile_orig.st_atime, stfile.st_atime);
diff --git a/io/tst-utimes-time64.c b/io/tst-utimes-time64.c
new file mode 100644
index 0000000000..234ec02541
--- /dev/null
+++ b/io/tst-utimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimes.c"
diff --git a/io/tst-utimes.c b/io/tst-utimes.c
index 991ab0c7d3..e88efff45b 100644
--- a/io/tst-utimes.c
+++ b/io/tst-utimes.c
@@ -22,13 +22,17 @@
 #include <sys/time.h>
 #include <time.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_utimes_helper (const char *file, int fd, const struct timeval *tv)
 {
   int result = utimes (file, tv);
   TEST_VERIFY_EXIT (result == 0);
 
-  struct stat64 st;
+  struct_stat st;
   xfstat (fd, &st);
 
   /* Check if seconds for atime match */
diff --git a/misc/Makefile b/misc/Makefile
index 38dad737f2..7f51f7163d 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -90,6 +90,10 @@ tests := tst-dirname tst-tsearch tst-fdset tst-mntent tst-hsearch \
 	 tst-ldbl-warn tst-ldbl-error tst-dbl-efgcvt tst-ldbl-efgcvt \
 	 tst-mntent-autofs tst-syscalls tst-mntent-escape tst-select
 
+tests-time64 := \
+  tst-select-time64 \
+  tst-pselect-time64
+
 # Tests which need libdl.
 ifeq (yes,$(build-shared))
 tests += tst-gethostid
diff --git a/misc/tst-pselect-time64.c b/misc/tst-pselect-time64.c
new file mode 100644
index 0000000000..15a1e49292
--- /dev/null
+++ b/misc/tst-pselect-time64.c
@@ -0,0 +1 @@
+#include "tst-pselect.c"
diff --git a/misc/tst-select-time64.c b/misc/tst-select-time64.c
new file mode 100644
index 0000000000..13120bfe31
--- /dev/null
+++ b/misc/tst-select-time64.c
@@ -0,0 +1 @@
+#include "tst-select.c"
diff --git a/nptl/Makefile b/nptl/Makefile
index 16eaf58948..b6103c1703 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -323,6 +323,9 @@ xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
 	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10 tst-setgroups \
 	tst-mutexpp5 tst-mutexpp9
 
+tests-time64 := \
+  tst-cancel4_2-time64
+
 # This test can run into task limits because of a linux kernel bug
 # and then cause the make process to fail too, see bug 24537.
 xtests += tst-eintr1
diff --git a/nptl/tst-cancel4_2-time64.c b/nptl/tst-cancel4_2-time64.c
new file mode 100644
index 0000000000..4ac086a312
--- /dev/null
+++ b/nptl/tst-cancel4_2-time64.c
@@ -0,0 +1 @@
+#include "tst-cancel4_2.c"
diff --git a/posix/Makefile b/posix/Makefile
index 84204b1270..31e745fadc 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -123,7 +123,9 @@ endif
 tests-internal	:= bug-regex5 bug-regex20 bug-regex33 \
 		   tst-rfc3484 tst-rfc3484-2 tst-rfc3484-3
 tests-container := bug-ga2
+tests-time64	:= tst-wait4-time64 tst-wait3-time64 tst-gnuglob64-time64
 xtests		:= tst-getaddrinfo4 tst-getaddrinfo5 tst-sched_rr_get_interval
+xtests-time64	:= tst-sched_rr_get_interval-time64
 ifeq (yes,$(build-shared))
 test-srcs	:= globtest
 tests           += wordexp-test tst-exec tst-spawn tst-spawn2 tst-spawn3
diff --git a/posix/tst-gnuglob64-time64.c b/posix/tst-gnuglob64-time64.c
new file mode 100644
index 0000000000..00922bcdc6
--- /dev/null
+++ b/posix/tst-gnuglob64-time64.c
@@ -0,0 +1,7 @@
+#define GLOB_FUNC glob
+#define GLOB_TYPE glob_t
+#define GLOBFREE_FUNC globfree
+#define DIRENT_STRUCT dirent
+#define STAT_STRUCT stat
+
+#include "tst-gnuglob-skeleton.c"
diff --git a/posix/tst-sched_rr_get_interval-time64.c b/posix/tst-sched_rr_get_interval-time64.c
new file mode 100644
index 0000000000..f4e66d2939
--- /dev/null
+++ b/posix/tst-sched_rr_get_interval-time64.c
@@ -0,0 +1 @@
+#include "tst-sched_rr_get_interval.c"
diff --git a/posix/tst-wait3-time64.c b/posix/tst-wait3-time64.c
new file mode 100644
index 0000000000..2837bc7a9e
--- /dev/null
+++ b/posix/tst-wait3-time64.c
@@ -0,0 +1 @@
+#include "tst-wait3.c"
diff --git a/posix/tst-wait4-time64.c b/posix/tst-wait4-time64.c
new file mode 100644
index 0000000000..12543b270f
--- /dev/null
+++ b/posix/tst-wait4-time64.c
@@ -0,0 +1 @@
+#include "tst-wait4.c"
diff --git a/rt/Makefile b/rt/Makefile
index 97c9bbd9de..797f2da51e 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -51,6 +51,15 @@ tests := tst-shm tst-timer tst-timer2 \
 	 tst-shm-cancel
 tests-internal := tst-timer-sigmask
 
+tests-time64 := \
+  tst-aio6-time64 \
+  tst-cpuclock2-time64 \
+  tst-mqueue1-time64 \
+  tst-mqueue2-time64 \
+  tst-mqueue4-time64 \
+  tst-mqueue8-time64 \
+  tst-timer4-time64
+
 extra-libs := librt
 extra-libs-others := $(extra-libs)
 
diff --git a/rt/tst-aio6-time64.c b/rt/tst-aio6-time64.c
new file mode 100644
index 0000000000..a386a577ec
--- /dev/null
+++ b/rt/tst-aio6-time64.c
@@ -0,0 +1 @@
+#include "tst-aio6.c"
diff --git a/rt/tst-cpuclock2-time64.c b/rt/tst-cpuclock2-time64.c
new file mode 100644
index 0000000000..05775522bb
--- /dev/null
+++ b/rt/tst-cpuclock2-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock2.c"
diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c
index c1c7ed2ad8..eebc3609d0 100644
--- a/rt/tst-cpuclock2.c
+++ b/rt/tst-cpuclock2.c
@@ -21,7 +21,11 @@
 
 #if (_POSIX_THREADS - 0) <= 0
 
-# define TEST_FUNCTION 0
+static int
+do_test ()
+{
+  return 0;
+}
 
 #else
 
@@ -330,7 +334,6 @@ do_test (void)
 
   return result;
 }
-# define TEST_FUNCTION do_test ()
 #endif
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/rt/tst-mqueue1-time64.c b/rt/tst-mqueue1-time64.c
new file mode 100644
index 0000000000..9c600a9a97
--- /dev/null
+++ b/rt/tst-mqueue1-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue1.c"
diff --git a/rt/tst-mqueue2-time64.c b/rt/tst-mqueue2-time64.c
new file mode 100644
index 0000000000..9d49f0b196
--- /dev/null
+++ b/rt/tst-mqueue2-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue2.c"
diff --git a/rt/tst-mqueue4-time64.c b/rt/tst-mqueue4-time64.c
new file mode 100644
index 0000000000..c23a228dc4
--- /dev/null
+++ b/rt/tst-mqueue4-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue4.c"
diff --git a/rt/tst-mqueue8-time64.c b/rt/tst-mqueue8-time64.c
new file mode 100644
index 0000000000..972637f7f5
--- /dev/null
+++ b/rt/tst-mqueue8-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue8.c"
diff --git a/rt/tst-timer4-time64.c b/rt/tst-timer4-time64.c
new file mode 100644
index 0000000000..e47a593f10
--- /dev/null
+++ b/rt/tst-timer4-time64.c
@@ -0,0 +1 @@
+#include "tst-timer4.c"
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index bca642f438..bc982a656e 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -124,6 +124,16 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
 	 tst-unwind-thread \
 	 tst-pt-vfork1 tst-pt-vfork2 tst-vfork1x tst-vfork2x \
 
+tests-time64 := \
+  tst-abstime-time64 \
+  tst-cnd-timedwait-time64 \
+  tst-cond11-time64 \
+  tst-join14-time64 \
+  tst-mtx-timedlock-time64 \
+  tst-rwlock14-time64 \
+  tst-sem5-time64 \
+  tst-thrd-sleep-time64 \
+
 
 # Files which must not be linked with libpthread.
 tests-nolibpthread += tst-unload
diff --git a/sysdeps/pthread/tst-abstime-time64.c b/sysdeps/pthread/tst-abstime-time64.c
new file mode 100644
index 0000000000..2fc77cb365
--- /dev/null
+++ b/sysdeps/pthread/tst-abstime-time64.c
@@ -0,0 +1 @@
+#include "tst-abstime.c"
diff --git a/sysdeps/pthread/tst-cnd-timedwait-time64.c b/sysdeps/pthread/tst-cnd-timedwait-time64.c
new file mode 100644
index 0000000000..9b2abfd277
--- /dev/null
+++ b/sysdeps/pthread/tst-cnd-timedwait-time64.c
@@ -0,0 +1 @@
+#include "tst-cnd-timedwait.c"
diff --git a/sysdeps/pthread/tst-cond11-time64.c b/sysdeps/pthread/tst-cond11-time64.c
new file mode 100644
index 0000000000..9bccb8ec8b
--- /dev/null
+++ b/sysdeps/pthread/tst-cond11-time64.c
@@ -0,0 +1 @@
+#include "tst-cond11.c"
diff --git a/sysdeps/pthread/tst-join14-time64.c b/sysdeps/pthread/tst-join14-time64.c
new file mode 100644
index 0000000000..bed784ee24
--- /dev/null
+++ b/sysdeps/pthread/tst-join14-time64.c
@@ -0,0 +1 @@
+#include "tst-join14.c"
diff --git a/sysdeps/pthread/tst-mtx-timedlock-time64.c b/sysdeps/pthread/tst-mtx-timedlock-time64.c
new file mode 100644
index 0000000000..b3393c99ef
--- /dev/null
+++ b/sysdeps/pthread/tst-mtx-timedlock-time64.c
@@ -0,0 +1 @@
+#include "tst-mtx-timedlock.c"
diff --git a/sysdeps/pthread/tst-rwlock14-time64.c b/sysdeps/pthread/tst-rwlock14-time64.c
new file mode 100644
index 0000000000..ae9b1912cf
--- /dev/null
+++ b/sysdeps/pthread/tst-rwlock14-time64.c
@@ -0,0 +1 @@
+#include "tst-rwlock14.c"
diff --git a/sysdeps/pthread/tst-sem5-time64.c b/sysdeps/pthread/tst-sem5-time64.c
new file mode 100644
index 0000000000..89c2a14f94
--- /dev/null
+++ b/sysdeps/pthread/tst-sem5-time64.c
@@ -0,0 +1 @@
+#include "tst-sem5.c"
diff --git a/sysdeps/pthread/tst-thrd-sleep-time64.c b/sysdeps/pthread/tst-thrd-sleep-time64.c
new file mode 100644
index 0000000000..02837bd19f
--- /dev/null
+++ b/sysdeps/pthread/tst-thrd-sleep-time64.c
@@ -0,0 +1 @@
+#include "tst-thrd-sleep.c"
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 43e015bf69..471abfdc38 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -125,6 +125,16 @@ endif
 
 tests-internal += tst-sigcontext-get_pc
 
+tests-time64 += \
+  tst-adjtimex-time64 \
+  tst-clock_adjtime-time64 \
+  tst-ntp_adjtime-time64 \
+  tst-ntp_gettime-time64 \
+  tst-ntp_gettimex-time64 \
+  tst-ppoll-time64 \
+  tst-sigtimedwait-time64 \
+  tst-timerfd-time64 \
+
 CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
 
 # Generate the list of SYS_* macros for the system calls (__NR_*
diff --git a/sysdeps/unix/sysv/linux/tst-adjtimex-time64.c b/sysdeps/unix/sysv/linux/tst-adjtimex-time64.c
new file mode 100644
index 0000000000..2b6988b7c4
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-adjtimex-time64.c
@@ -0,0 +1 @@
+#include "tst-adjtimex.c"
diff --git a/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c b/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
new file mode 100644
index 0000000000..9691e81229
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_adjtime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ntp_adjtime-time64.c b/sysdeps/unix/sysv/linux/tst-ntp_adjtime-time64.c
new file mode 100644
index 0000000000..30e7380b02
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ntp_adjtime-time64.c
@@ -0,0 +1 @@
+#include "tst-ntp_adjtime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ntp_gettime-time64.c b/sysdeps/unix/sysv/linux/tst-ntp_gettime-time64.c
new file mode 100644
index 0000000000..42caa66301
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ntp_gettime-time64.c
@@ -0,0 +1 @@
+#include "tst-ntp_gettime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ntp_gettimex-time64.c b/sysdeps/unix/sysv/linux/tst-ntp_gettimex-time64.c
new file mode 100644
index 0000000000..3f017b3c22
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ntp_gettimex-time64.c
@@ -0,0 +1 @@
+#include "tst-ntp_gettimex.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ppoll-time64.c b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
new file mode 100644
index 0000000000..96ee2faee3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
@@ -0,0 +1 @@
+#include "tst-ppoll.c"
diff --git a/sysdeps/unix/sysv/linux/tst-sigtimedwait-time64.c b/sysdeps/unix/sysv/linux/tst-sigtimedwait-time64.c
new file mode 100644
index 0000000000..1513e81749
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-sigtimedwait-time64.c
@@ -0,0 +1 @@
+#include "tst-sigtimedwait.c"
diff --git a/sysdeps/unix/sysv/linux/tst-timerfd-time64.c b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
new file mode 100644
index 0000000000..bb17f48139
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
@@ -0,0 +1 @@
+#include "tst-timerfd.c"
diff --git a/sysvipc/Makefile b/sysvipc/Makefile
index a534791928..86911803b5 100644
--- a/sysvipc/Makefile
+++ b/sysvipc/Makefile
@@ -32,6 +32,8 @@ routines := ftok \
 
 tests    := test-sysvmsg test-sysvsem test-sysvshm
 
+tests-time64 := test-sysvmsg-time64 test-sysvsem-time64 test-sysvshm-time64
+
 include ../Rules
 
 CFLAGS-msgrcv.c += -fexceptions -fasynchronous-unwind-tables
diff --git a/sysvipc/test-sysvmsg-time64.c b/sysvipc/test-sysvmsg-time64.c
new file mode 100644
index 0000000000..c23e0c337e
--- /dev/null
+++ b/sysvipc/test-sysvmsg-time64.c
@@ -0,0 +1 @@
+#include "test-sysvmsg.c"
diff --git a/sysvipc/test-sysvsem-time64.c b/sysvipc/test-sysvsem-time64.c
new file mode 100644
index 0000000000..05c95068cd
--- /dev/null
+++ b/sysvipc/test-sysvsem-time64.c
@@ -0,0 +1 @@
+#include "test-sysvsem.c"
diff --git a/sysvipc/test-sysvshm-time64.c b/sysvipc/test-sysvshm-time64.c
new file mode 100644
index 0000000000..8e2963f563
--- /dev/null
+++ b/sysvipc/test-sysvshm-time64.c
@@ -0,0 +1 @@
+#include "test-sysvshm.c"
diff --git a/time/Makefile b/time/Makefile
index 805c79c4d0..c84bd5d3ec 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -52,6 +52,24 @@ tests	:= test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
 	   tst-settimeofday tst-itimer tst-gmtime tst-timegm \
 	   tst-timespec_get tst-timespec_getres
 
+tests-time64 := \
+  tst-adjtime-time64 \
+  tst-clock-time64 \
+  tst-clock2-time64 \
+  tst-clock_nanosleep-time64 \
+  tst-clock_settime-time64 \
+  tst-cpuclock1-time64 \
+  tst-ctime-time64 \
+  tst-difftime-time64 \
+  tst-gmtime-time64 \
+  tst-itimer-time64 \
+  tst-mktime4-time64 \
+  tst-settimeofday-time64 \
+  tst-timegm-time64 \
+  tst-timespec_get-time64 \
+  tst-timespec_getres-time64 \
+  tst-y2039-time64
+
 include ../Rules
 
 ifeq ($(run-built-tests),yes)
diff --git a/time/tst-adjtime-time64.c b/time/tst-adjtime-time64.c
new file mode 100644
index 0000000000..097d6efc4b
--- /dev/null
+++ b/time/tst-adjtime-time64.c
@@ -0,0 +1 @@
+#include <tst-adjtime.c>
diff --git a/time/tst-clock-time64.c b/time/tst-clock-time64.c
new file mode 100644
index 0000000000..a1349678c8
--- /dev/null
+++ b/time/tst-clock-time64.c
@@ -0,0 +1 @@
+#include "tst-clock.c"
diff --git a/time/tst-clock2-time64.c b/time/tst-clock2-time64.c
new file mode 100644
index 0000000000..897f47b287
--- /dev/null
+++ b/time/tst-clock2-time64.c
@@ -0,0 +1 @@
+#include "tst-clock2.c"
diff --git a/time/tst-clock_nanosleep-time64.c b/time/tst-clock_nanosleep-time64.c
new file mode 100644
index 0000000000..c8638aa3d2
--- /dev/null
+++ b/time/tst-clock_nanosleep-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_nanosleep.c"
diff --git a/time/tst-clock_settime-time64.c b/time/tst-clock_settime-time64.c
new file mode 100644
index 0000000000..328b04a030
--- /dev/null
+++ b/time/tst-clock_settime-time64.c
@@ -0,0 +1 @@
+#include <tst-clock_settime.c>
diff --git a/time/tst-cpuclock1-time64.c b/time/tst-cpuclock1-time64.c
new file mode 100644
index 0000000000..5a7ffa27ac
--- /dev/null
+++ b/time/tst-cpuclock1-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock1.c"
diff --git a/time/tst-ctime-time64.c b/time/tst-ctime-time64.c
new file mode 100644
index 0000000000..24a5ae98ed
--- /dev/null
+++ b/time/tst-ctime-time64.c
@@ -0,0 +1 @@
+#include "tst-ctime.c"
diff --git a/time/tst-ctime.c b/time/tst-ctime.c
index e89a906bf8..884d69bfa0 100644
--- a/time/tst-ctime.c
+++ b/time/tst-ctime.c
@@ -24,6 +24,7 @@ static int
 do_test (void)
 {
   char *str;
+  char strb[32];
   time_t t;
 
   /* Use glibc time zone extension "TZ=:" to to guarantee that UTC
@@ -36,11 +37,21 @@ do_test (void)
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
+
   /* Check if the max time value for 32 bit time_t can be converted.  */
   t = 0x7fffffff;
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
+
   /* Check if we run on port with 32 bit time_t size */
   time_t tov;
   if (__builtin_add_overflow (t, 1, &tov))
@@ -50,6 +61,11 @@ do_test (void)
   str = ctime (&tov);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&tov, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
+
   return 0;
 }
 
diff --git a/time/tst-difftime-time64.c b/time/tst-difftime-time64.c
new file mode 100644
index 0000000000..751ce6c483
--- /dev/null
+++ b/time/tst-difftime-time64.c
@@ -0,0 +1 @@
+#include "tst-difftime.c"
diff --git a/time/tst-gmtime-time64.c b/time/tst-gmtime-time64.c
new file mode 100644
index 0000000000..0df11c1913
--- /dev/null
+++ b/time/tst-gmtime-time64.c
@@ -0,0 +1 @@
+#include "tst-gmtime.c"
diff --git a/time/tst-itimer-time64.c b/time/tst-itimer-time64.c
new file mode 100644
index 0000000000..ddd2efa175
--- /dev/null
+++ b/time/tst-itimer-time64.c
@@ -0,0 +1 @@
+#include <time/tst-itimer.c>
diff --git a/time/tst-mktime4-time64.c b/time/tst-mktime4-time64.c
new file mode 100644
index 0000000000..bf5197c6f3
--- /dev/null
+++ b/time/tst-mktime4-time64.c
@@ -0,0 +1 @@
+#include "tst-mktime4.c"
diff --git a/time/tst-settimeofday-time64.c b/time/tst-settimeofday-time64.c
new file mode 100644
index 0000000000..185d167a22
--- /dev/null
+++ b/time/tst-settimeofday-time64.c
@@ -0,0 +1 @@
+#include <tst-settimeofday.c>
diff --git a/time/tst-timegm-time64.c b/time/tst-timegm-time64.c
new file mode 100644
index 0000000000..8e3084f74e
--- /dev/null
+++ b/time/tst-timegm-time64.c
@@ -0,0 +1 @@
+#include "tst-timegm.c"
diff --git a/time/tst-timespec_get-time64.c b/time/tst-timespec_get-time64.c
new file mode 100644
index 0000000000..48f336385d
--- /dev/null
+++ b/time/tst-timespec_get-time64.c
@@ -0,0 +1 @@
+#include "tst-timespec_get.c"
diff --git a/time/tst-timespec_getres-time64.c b/time/tst-timespec_getres-time64.c
new file mode 100644
index 0000000000..59a0f36103
--- /dev/null
+++ b/time/tst-timespec_getres-time64.c
@@ -0,0 +1 @@
+#include "tst-timespec_getres.c"
diff --git a/time/tst-y2039-time64.c b/time/tst-y2039-time64.c
new file mode 100644
index 0000000000..3c8a504186
--- /dev/null
+++ b/time/tst-y2039-time64.c
@@ -0,0 +1 @@
+#include "tst-y2039.c"
diff --git a/time/tst-y2039.c b/time/tst-y2039.c
index ef024c0a77..66a22d4c2c 100644
--- a/time/tst-y2039.c
+++ b/time/tst-y2039.c
@@ -37,6 +37,16 @@ do_test (void)
 			> 0);
       puts (buf);
       TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
+
+      /* Same as before but for localtime_r.  */
+      struct tm tmd;
+      tm = localtime_r (&ouch, &tmd);
+      TEST_VERIFY_EXIT (tm == &tmd);
+
+      TEST_VERIFY_EXIT (strftime (buf, sizeof buf, "%Y-%m-%d %H:%M:%S %Z", tm)
+			> 0);
+      puts (buf);
+      TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
     }
   else
     FAIL_UNSUPPORTED ("32-bit time_t");


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [glibc/azanella/y2038] y2038: Add test coverage
@ 2021-03-05 19:21 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2021-03-05 19:21 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8dd445bf9720eeead5aa13cfc6700340695a9c97

commit 8dd445bf9720eeead5aa13cfc6700340695a9c97
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Feb 17 15:59:34 2021 -0300

    y2038: Add test coverage
    
    It is enabled through a new rule, tests-y2038, which is built only
    when the ABI supports the comapt 64-bit time_t (defined by the
    header time64-compat.h, which also enables the creation of the
    symbol Version for Linux).  It means the tests are not built
    for ABI which already provide default 64-bit time_t.
    
    The new rule already adds the required LFS and 64-bit time_t
    compiler flags.
    
    The current coverage is:
    
      * libc:
        - adjtime
        - adjtimex
        - clock_adjtime                 tst-clock_adjtime-time64
        - clock_getres                  tst-clock-time64, tst-cpuclock1-time64
        - clock_gettime                 tst-clock-time64, tst-clock2-time64,
                                        tst-cpuclock1-time64
        - clock_nanoslee                tst-clock_nanosleep-time64,
                                        tst-cpuclock1-time64
        - clock_settime                 tst-clock2-time64
        - ctime                         tst-ctime-time64
        - ctime_r                       tst-ctime-time64
        - difftime                      tst-difftime-time64
        - fstat                         tst-stat-time64
        - fstatat                       tst-stat-time64
        - futimens                      tst-futimens-time64
        - futimes                       tst-futimes-time64
        - futimesat                     tst-futimesat-time64
        - fts_*                         tst-fts-time64
        - getitimer                     tst-itimer-timer64
        - getrusage
        - gettimeofday                  tst-clock_nanosleep-time64
        - glob / globfree               tst-gnuglob64-time64
        - gmtime                        tst-gmtime-time64
        - gmtime_r                      tst-gmtime-time64
        - lstat                         tst-stat-time64
        - localtime                     tst-y2039-time64
        - localtime_t                   tst-y2039-time64
        - lutimes                       tst-lutimes-time64
        - mktime                        tst-mktime4-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - msgctl                        test-sysvmsg-time64
        - nanosleep                     tst-cpuclock{12}-time64,
                                        tst-mqueue8-time64, tst-clock-time64
        - nftw / ftw                    ftwtest-time64
        - ntp_adjtime
        - ntp_gettime
        - ntp_gettimex
        - ppoll                         tst-ppoll-time64
        - pselect                       tst-pselect-time64
        - recvmmsg                      tst-cancel4_2-time64
        - sched_rr_get_interval         tst-sched_rr_get_interval-time64
        - select
        - semctl                        test-sysvsem-time64
        - semtimedop                    test-sysvsem-time64
        - setitimer                     tst-mqueue2-time64, tst-itimer-timer64
        - settimeofday
        - shmctl                        test-sysvshm-time64
        - sigtimedwait
        - stat                          tst-stat-time64
        - time                          tst-mqueue{1248}-time64
        - timegm                        tst-timegm-time64
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
        - timerfd_gettime               tst-timerfd-time64
        - timerfd_settime               tst-timerfd-time64
        - timespec_get                  tst-timespec_get-time64
        - utime                         tst-utime-time64
        - utimensat                     tst-utimensat-time64
        - utimes                        tst-utimes-time64
        - wait3                         tst-wait3-time64
        - wait4                         tst-wait4-time64
    
      * libpthread:
        - cnd_timedwait                 tst-cnd-timedwait-time64
        - mtx_timedlock                 tst-mtx-timedlock-time64
        - pthread_clockjoin_np          tst-join14-time64
        - pthread_cond_clockwait        tst-cond11-time64
        - pthread_cond_timedwait        tst-abstime-time64
        - pthread_mutex_clocklock       tst-abstime-time64
        - pthread_mutex_timedlock       tst-abstime-time64
        - pthread_rwlock_clockrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_clockwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_timedjoin_np          tst-join14-time64
        - sem_clockwait                 tst-sem5-time64
        - sem_timedwait                 tst-sem5-time64
        - thrd_sleep                    tst-thrd-sleep-time64
    
      * librt:
        - aio_suspend                   tst-aio6-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
    
      * libanl:
        - gai_suspend

Diff:
---
 Makeconfig                                    |  14 ++++
 Makerules                                     |  18 ++++-
 io/Makefile                                   |  16 +++-
 io/ftwtest-time64.c                           |   1 +
 io/tst-fts-time64.c                           |   1 +
 io/tst-futimesat-time64.c                     |   4 +
 io/tst-futimesat.c                            |  47 ++++++++----
 io/tst-stat-time64.c                          | 102 ++++++++++++++++++++++++++
 io/tst-utimensat-time64.c                     |   2 +
 misc/Makefile                                 |   2 +
 misc/tst-pselect-time64.c                     |   1 +
 nptl/Makefile                                 |   3 +
 nptl/tst-cancel4_2-time64.c                   |   1 +
 posix/Makefile                                |   2 +
 posix/tst-gnuglob64-time64.c                  |   7 ++
 posix/tst-sched_rr_get_interval-time64.c      |   1 +
 posix/tst-wait3-time64.c                      |   1 +
 posix/tst-wait4-time64.c                      |   1 +
 rt/Makefile                                   |   9 +++
 rt/tst-aio6-time64.c                          |   1 +
 rt/tst-cpuclock2-time64.c                     |   1 +
 rt/tst-cpuclock2.c                            |   9 ++-
 rt/tst-mqueue1-time64.c                       |   1 +
 rt/tst-mqueue2-time64.c                       |   1 +
 rt/tst-mqueue4-time64.c                       |   1 +
 rt/tst-mqueue8-time64.c                       |   1 +
 rt/tst-timer4-time64.c                        |   1 +
 sysdeps/pthread/Makefile                      |  10 +++
 sysdeps/pthread/tst-abstime-time64.c          |   1 +
 sysdeps/pthread/tst-cnd-timedwait-time64.c    |   1 +
 sysdeps/pthread/tst-cond11-time64.c           |   1 +
 sysdeps/pthread/tst-join14-time64.c           |   1 +
 sysdeps/pthread/tst-mtx-timedlock-time64.c    |   1 +
 sysdeps/pthread/tst-rwlock14-time64.c         |   1 +
 sysdeps/pthread/tst-sem5-time64.c             |   1 +
 sysdeps/pthread/tst-thrd-sleep-time64.c       |   1 +
 sysdeps/unix/sysv/linux/Makefile              |   8 ++
 sysdeps/unix/sysv/linux/Versions              |   4 +-
 sysdeps/unix/sysv/linux/tst-futimens-time64.c |   2 +
 sysdeps/unix/sysv/linux/tst-futimens.c        |   8 +-
 sysdeps/unix/sysv/linux/tst-futimes-time64.c  |   2 +
 sysdeps/unix/sysv/linux/tst-lutimes-time64.c  |   2 +
 sysdeps/unix/sysv/linux/tst-ppoll-time64.c    |   1 +
 sysdeps/unix/sysv/linux/tst-timerfd-time64.c  |   1 +
 sysdeps/unix/sysv/linux/tst-utime-time64.c    |   2 +
 sysdeps/unix/sysv/linux/tst-utime.c           |   6 +-
 sysdeps/unix/sysv/linux/tst-utimes-time64.c   |   2 +
 sysdeps/unix/sysv/linux/tst-utimes.c          |   6 +-
 sysvipc/Makefile                              |   2 +
 sysvipc/test-sysvmsg-time64.c                 |   1 +
 sysvipc/test-sysvsem-time64.c                 |   1 +
 sysvipc/test-sysvshm-time64.c                 |   1 +
 time/Makefile                                 |  15 ++++
 time/tst-adjtime-time64.c                     |   1 +
 time/tst-clock-time64.c                       |   1 +
 time/tst-clock2-time64.c                      |   1 +
 time/tst-clock_nanosleep-time64.c             |   1 +
 time/tst-cpuclock1-time64.c                   |   1 +
 time/tst-ctime-time64.c                       |   1 +
 time/tst-ctime.c                              |  16 ++++
 time/tst-difftime-time64.c                    |   1 +
 time/tst-gmtime-time64.c                      |   1 +
 time/tst-itimer-time64.c                      |   1 +
 time/tst-mktime4-time64.c                     |   1 +
 time/tst-timegm-time64.c                      |   1 +
 time/tst-timespec_get-time64.c                |   1 +
 time/tst-y2039-time64.c                       |   1 +
 time/tst-y2039.c                              |  10 +++
 68 files changed, 346 insertions(+), 24 deletions(-)

diff --git a/Makeconfig b/Makeconfig
index 0a4811b5e5..e12ee30eca 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1227,6 +1227,20 @@ $(common-objpfx)versions.stmp: $(common-objpfx)Versions.all \
 	touch $@
 endif # avoid-generated
 endif # $(build-shared) = yes
+
+-include $(common-objpfx)time64-compat.mk
+postclean-generated += time64-compat.mk
+
+$(common-objpfx)time64-compat.mk: $(sysd-versions-force) \
+				  $(common-objpfx)time64-compat.i
+	sed '/^[        ]*#/d;/^[       ]*$$/d' $< > $@T
+	mv -f $@T $@
+$(common-objpfx)time64-compat.i: $(..)Makeconfig
+	printf "#include <time64-compat.h>\n#ifdef TIME64_NON_DEFAULT\nhave-time64-compat = yes\n#endif" \
+	| $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - > $@T
+	mv -f $@T $@
+
+
 endif # sysd-sorted-done
 
 # The name under which the run-time dynamic linker is installed.
diff --git a/Makerules b/Makerules
index fc5251ffad..f4f641bb26 100644
--- a/Makerules
+++ b/Makerules
@@ -771,7 +771,8 @@ endif
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
 	     $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
-	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs))
+	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) \
+		$(test-srcs) $(tests-time64) $(xtests-time64))
 ifeq ($(build-programs),yes)
 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
 endif
@@ -1286,6 +1287,21 @@ check: tests
 .PHONY: xcheck
 xcheck: xtests
 
+# Handle tests-time64 and xtests-time64 that should built with LFS
+# and 64-bit time support.
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(tests-time64) $(xtests-time64),\
+	    $(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+ifeq ($(have-time64-compat),yes)
+tests += $(foreach t,$(tests-time64),$(t))
+xtests += $(foreach t,$(xtests-time64),$(t))
+endif
+
 # The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
 # that almost all internal declarations from config.h, libc-symbols.h, and
 # include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
diff --git a/io/Makefile b/io/Makefile
index 6c637f7c6d..a39f0ecfc1 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -59,7 +59,7 @@ routines :=								\
 	ftw64-time64
 
 others		:= pwd
-test-srcs	:= ftwtest
+test-srcs	:= ftwtest ftwtest-time64
 tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-fcntl bug-ftw1 bug-ftw2 bug-ftw3 bug-ftw4 tst-statvfs \
 		   tst-openat tst-unlinkat tst-fstatat tst-futimesat \
@@ -72,12 +72,18 @@ tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-ftw-lnk tst-file_change_detection tst-lchmod \
 		   tst-ftw-bz26353 tst-utimensat
 
+tests-time64    := tst-fts-time64 \
+		   tst-stat-time64 \
+		   tst-futimesat-time64 \
+		   tst-utimensat-time64
+
 # Likewise for statx, but we do not need static linking here.
 tests-internal += tst-statx
 tests-static += tst-statx
 
 ifeq ($(run-built-tests),yes)
-tests-special += $(objpfx)ftwtest.out
+tests-special += $(objpfx)ftwtest.out \
+		 $(objpfx)ftwtest-time64.out
 endif
 
 include ../Rules
@@ -118,8 +124,14 @@ tst-statvfs-ARGS = $(objpfx)tst-statvfs tst-statvfs.c /tmp
 
 tst-open-tmpfile-ARGS = --test-dir=$(objpfx)
 
+CFLAGS-ftwtest-time64.c += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+
 ifeq ($(run-built-tests),yes)
 $(objpfx)ftwtest.out: ftwtest-sh $(objpfx)ftwtest
 	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
 	$(evaluate-test)
+
+$(objpfx)ftwtest-time64.out: ftwtest-sh $(objpfx)ftwtest-time64
+	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
+	$(evaluate-test)
 endif
diff --git a/io/ftwtest-time64.c b/io/ftwtest-time64.c
new file mode 100644
index 0000000000..67f1c46826
--- /dev/null
+++ b/io/ftwtest-time64.c
@@ -0,0 +1 @@
+#include "ftwtest.c"
diff --git a/io/tst-fts-time64.c b/io/tst-fts-time64.c
new file mode 100644
index 0000000000..a4a41fe1cf
--- /dev/null
+++ b/io/tst-fts-time64.c
@@ -0,0 +1 @@
+#include "tst-fts.c"
diff --git a/io/tst-futimesat-time64.c b/io/tst-futimesat-time64.c
new file mode 100644
index 0000000000..f6c0500eef
--- /dev/null
+++ b/io/tst-futimesat-time64.c
@@ -0,0 +1,4 @@
+#define struct_stat  struct stat
+#define fstat        fstat
+#define fstatat      fstatat
+#include "io/tst-futimesat.c"
diff --git a/io/tst-futimesat.c b/io/tst-futimesat.c
index af58ad06dd..c32ab2b668 100644
--- a/io/tst-futimesat.c
+++ b/io/tst-futimesat.c
@@ -1,4 +1,23 @@
+/* futimesat basic tests.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
 #include <dirent.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -7,19 +26,19 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#include <support/test-driver.h>
+#include <support/temp_file.h>
 
-static void prepare (void);
-#define PREPARE(argc, argv) prepare ()
-
-static int do_test (void);
-#define TEST_FUNCTION do_test ()
-
-#include "../test-skeleton.c"
+#ifndef struct_stat
+# define struct_stat struct stat64
+# define fstat       fstat64
+# define fstatat     fstatat64
+#endif
 
 static int dir_fd;
 
 static void
-prepare (void)
+prepare (int argc, char *argv[])
 {
   size_t test_dir_len = strlen (test_dir);
   static const char dir_name[] = "/tst-futimesat.XXXXXX";
@@ -48,7 +67,7 @@ prepare (void)
       exit (1);
     }
 }
-
+#define PREPARE prepare
 
 static int
 do_test (void)
@@ -98,8 +117,8 @@ do_test (void)
   write (fd, "hello", 5);
   puts ("file created");
 
-  struct stat64 st1;
-  if (fstat64 (fd, &st1) != 0)
+  struct_stat st1;
+  if (fstat (fd, &st1) != 0)
     {
       puts ("fstat64 failed");
       return 1;
@@ -118,8 +137,8 @@ do_test (void)
       return 1;
     }
 
-  struct stat64 st2;
-  if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0)
+  struct_stat st2;
+  if (fstatat (dir_fd, "some-file", &st2, 0) != 0)
     {
       puts ("fstatat64 failed");
       return 1;
@@ -146,3 +165,5 @@ do_test (void)
 
   return 0;
 }
+
+#include <support/test-driver.c>
diff --git a/io/tst-stat-time64.c b/io/tst-stat-time64.c
new file mode 100644
index 0000000000..c10fe1284a
--- /dev/null
+++ b/io/tst-stat-time64.c
@@ -0,0 +1,102 @@
+/* Basic test of stat with 64 bit time_t interfaces.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <support/check.h>
+#include <support/support.h>
+#include <support/temp_file.h>
+#include <support/xunistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+
+/* The idea of the test is check whether the 64 bit time_t stat implementation
+   returns the expected value for comparable fields, so it does not really
+   matter whether statx uses a fallback implementation or not.  */
+
+static void
+stat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (stat (path, st), 0);
+}
+
+static void
+lstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (lstat (path, st), 0);
+}
+
+static void
+fstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstat (fd, st), 0);
+}
+
+static void
+fstatat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstatat (fd, path, st, 0), 0);
+}
+
+typedef void (*test_t)(int, const char *path, struct stat *);
+
+static int
+do_test (void)
+{
+  char *path;
+  int fd = create_temp_file ("tst-statx-", &path);
+  TEST_VERIFY_EXIT (fd >= 0);
+  support_write_file_string (path, "abc");
+
+  struct statx stx;
+  TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0);
+
+  for (test_t *test = (test_t[]) { stat_check, lstat_check, fstat_check,
+				   fstatat_check, NULL };
+       *test != NULL; test++)
+  {
+    struct stat st;
+    (*test) (fd, path, &st);
+
+    TEST_COMPARE (stx.stx_dev_major, major (st.st_dev));
+    TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev));
+    TEST_COMPARE (stx.stx_ino, st.st_ino);
+    TEST_COMPARE (stx.stx_mode, st.st_mode);
+    TEST_COMPARE (stx.stx_nlink, st.st_nlink);
+    TEST_COMPARE (stx.stx_uid, st.st_uid);
+    TEST_COMPARE (stx.stx_gid, st.st_gid);
+    TEST_COMPARE (stx.stx_rdev_major, major (st.st_rdev));
+    TEST_COMPARE (stx.stx_rdev_minor, minor (st.st_rdev));
+    TEST_COMPARE (stx.stx_blksize, st.st_blksize);
+    TEST_COMPARE (stx.stx_blocks, st.st_blocks);
+
+    TEST_COMPARE (stx.stx_ctime.tv_sec, st.st_ctim.tv_sec);
+    TEST_COMPARE (stx.stx_ctime.tv_nsec, st.st_ctim.tv_nsec);
+    TEST_COMPARE (stx.stx_mtime.tv_sec, st.st_mtim.tv_sec);
+    TEST_COMPARE (stx.stx_mtime.tv_nsec, st.st_mtim.tv_nsec);
+  }
+
+  xclose (fd);
+  free (path);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/io/tst-utimensat-time64.c b/io/tst-utimensat-time64.c
new file mode 100644
index 0000000000..7ac7d8df1d
--- /dev/null
+++ b/io/tst-utimensat-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimensat.c"
diff --git a/misc/Makefile b/misc/Makefile
index cfc15355d6..a8363d4b76 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -90,6 +90,8 @@ tests := tst-dirname tst-tsearch tst-fdset tst-mntent tst-hsearch \
 	 tst-ldbl-warn tst-ldbl-error tst-dbl-efgcvt tst-ldbl-efgcvt \
 	 tst-mntent-autofs tst-syscalls tst-mntent-escape
 
+tests-time64 := tst-pselect-time64
+
 # Tests which need libdl.
 ifeq (yes,$(build-shared))
 tests += tst-gethostid
diff --git a/misc/tst-pselect-time64.c b/misc/tst-pselect-time64.c
new file mode 100644
index 0000000000..15a1e49292
--- /dev/null
+++ b/misc/tst-pselect-time64.c
@@ -0,0 +1 @@
+#include "tst-pselect.c"
diff --git a/nptl/Makefile b/nptl/Makefile
index 33766eaf7a..d1c786e88b 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -380,6 +380,9 @@ xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
 	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10 tst-setgroups \
 	tst-mutexpp5 tst-mutexpp9
 
+tests-time64 := \
+  tst-cancel4_2-time64
+
 # This test can run into task limits because of a linux kernel bug
 # and then cause the make process to fail too, see bug 24537.
 xtests += tst-eintr1
diff --git a/nptl/tst-cancel4_2-time64.c b/nptl/tst-cancel4_2-time64.c
new file mode 100644
index 0000000000..4ac086a312
--- /dev/null
+++ b/nptl/tst-cancel4_2-time64.c
@@ -0,0 +1 @@
+#include "tst-cancel4_2.c"
diff --git a/posix/Makefile b/posix/Makefile
index aba66efde8..e246ff1d14 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -109,7 +109,9 @@ tests-internal	:= bug-regex5 bug-regex20 bug-regex33 \
 		   tst-rfc3484 tst-rfc3484-2 tst-rfc3484-3 \
 		   tst-glob_lstat_compat tst-spawn4-compat
 tests-container := bug-ga2
+tests-time64	:= tst-wait4-time64 tst-wait3-time64 tst-gnuglob64-time64
 xtests		:= tst-getaddrinfo4 tst-getaddrinfo5 tst-sched_rr_get_interval
+xtests-time64	:= tst-sched_rr_get_interval-time64
 ifeq (yes,$(build-shared))
 test-srcs	:= globtest
 tests           += wordexp-test tst-exec tst-spawn tst-spawn2 tst-spawn3
diff --git a/posix/tst-gnuglob64-time64.c b/posix/tst-gnuglob64-time64.c
new file mode 100644
index 0000000000..00922bcdc6
--- /dev/null
+++ b/posix/tst-gnuglob64-time64.c
@@ -0,0 +1,7 @@
+#define GLOB_FUNC glob
+#define GLOB_TYPE glob_t
+#define GLOBFREE_FUNC globfree
+#define DIRENT_STRUCT dirent
+#define STAT_STRUCT stat
+
+#include "tst-gnuglob-skeleton.c"
diff --git a/posix/tst-sched_rr_get_interval-time64.c b/posix/tst-sched_rr_get_interval-time64.c
new file mode 100644
index 0000000000..f4e66d2939
--- /dev/null
+++ b/posix/tst-sched_rr_get_interval-time64.c
@@ -0,0 +1 @@
+#include "tst-sched_rr_get_interval.c"
diff --git a/posix/tst-wait3-time64.c b/posix/tst-wait3-time64.c
new file mode 100644
index 0000000000..2837bc7a9e
--- /dev/null
+++ b/posix/tst-wait3-time64.c
@@ -0,0 +1 @@
+#include "tst-wait3.c"
diff --git a/posix/tst-wait4-time64.c b/posix/tst-wait4-time64.c
new file mode 100644
index 0000000000..12543b270f
--- /dev/null
+++ b/posix/tst-wait4-time64.c
@@ -0,0 +1 @@
+#include "tst-wait4.c"
diff --git a/rt/Makefile b/rt/Makefile
index 7b374f2073..3ce98297f9 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -49,6 +49,15 @@ tests := tst-shm tst-timer tst-timer2 \
 	 tst-shm-cancel
 tests-internal := tst-timer-sigmask
 
+tests-time64 := \
+  tst-aio6-time64 \
+  tst-cpuclock2-time64 \
+  tst-mqueue1-time64 \
+  tst-mqueue2-time64 \
+  tst-mqueue4-time64 \
+  tst-mqueue8-time64 \
+  tst-timer4-time64
+
 extra-libs := librt
 extra-libs-others := $(extra-libs)
 
diff --git a/rt/tst-aio6-time64.c b/rt/tst-aio6-time64.c
new file mode 100644
index 0000000000..a386a577ec
--- /dev/null
+++ b/rt/tst-aio6-time64.c
@@ -0,0 +1 @@
+#include "tst-aio6.c"
diff --git a/rt/tst-cpuclock2-time64.c b/rt/tst-cpuclock2-time64.c
new file mode 100644
index 0000000000..05775522bb
--- /dev/null
+++ b/rt/tst-cpuclock2-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock2.c"
diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c
index c1c7ed2ad8..eebc3609d0 100644
--- a/rt/tst-cpuclock2.c
+++ b/rt/tst-cpuclock2.c
@@ -21,7 +21,11 @@
 
 #if (_POSIX_THREADS - 0) <= 0
 
-# define TEST_FUNCTION 0
+static int
+do_test ()
+{
+  return 0;
+}
 
 #else
 
@@ -330,7 +334,6 @@ do_test (void)
 
   return result;
 }
-# define TEST_FUNCTION do_test ()
 #endif
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/rt/tst-mqueue1-time64.c b/rt/tst-mqueue1-time64.c
new file mode 100644
index 0000000000..9c600a9a97
--- /dev/null
+++ b/rt/tst-mqueue1-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue1.c"
diff --git a/rt/tst-mqueue2-time64.c b/rt/tst-mqueue2-time64.c
new file mode 100644
index 0000000000..9d49f0b196
--- /dev/null
+++ b/rt/tst-mqueue2-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue2.c"
diff --git a/rt/tst-mqueue4-time64.c b/rt/tst-mqueue4-time64.c
new file mode 100644
index 0000000000..c23a228dc4
--- /dev/null
+++ b/rt/tst-mqueue4-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue4.c"
diff --git a/rt/tst-mqueue8-time64.c b/rt/tst-mqueue8-time64.c
new file mode 100644
index 0000000000..972637f7f5
--- /dev/null
+++ b/rt/tst-mqueue8-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue8.c"
diff --git a/rt/tst-timer4-time64.c b/rt/tst-timer4-time64.c
new file mode 100644
index 0000000000..e47a593f10
--- /dev/null
+++ b/rt/tst-timer4-time64.c
@@ -0,0 +1 @@
+#include "tst-timer4.c"
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index 53b65ef349..31df6f97e5 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -109,6 +109,16 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
 	 tst-unwind-thread \
 	 tst-pt-vfork1 tst-pt-vfork2 tst-vfork1x tst-vfork2x \
 
+tests-time64 := \
+  tst-abstime-time64 \
+  tst-cnd-timedwait-time64 \
+  tst-cond11-time64 \
+  tst-join14-time64 \
+  tst-mtx-timedlock-time64 \
+  tst-rwlock14-time64 \
+  tst-sem5-time64 \
+  tst-thrd-sleep-time64 \
+
 
 # Files which must not be linked with libpthread.
 tests-nolibpthread = tst-unload
diff --git a/sysdeps/pthread/tst-abstime-time64.c b/sysdeps/pthread/tst-abstime-time64.c
new file mode 100644
index 0000000000..2fc77cb365
--- /dev/null
+++ b/sysdeps/pthread/tst-abstime-time64.c
@@ -0,0 +1 @@
+#include "tst-abstime.c"
diff --git a/sysdeps/pthread/tst-cnd-timedwait-time64.c b/sysdeps/pthread/tst-cnd-timedwait-time64.c
new file mode 100644
index 0000000000..9b2abfd277
--- /dev/null
+++ b/sysdeps/pthread/tst-cnd-timedwait-time64.c
@@ -0,0 +1 @@
+#include "tst-cnd-timedwait.c"
diff --git a/sysdeps/pthread/tst-cond11-time64.c b/sysdeps/pthread/tst-cond11-time64.c
new file mode 100644
index 0000000000..9bccb8ec8b
--- /dev/null
+++ b/sysdeps/pthread/tst-cond11-time64.c
@@ -0,0 +1 @@
+#include "tst-cond11.c"
diff --git a/sysdeps/pthread/tst-join14-time64.c b/sysdeps/pthread/tst-join14-time64.c
new file mode 100644
index 0000000000..bed784ee24
--- /dev/null
+++ b/sysdeps/pthread/tst-join14-time64.c
@@ -0,0 +1 @@
+#include "tst-join14.c"
diff --git a/sysdeps/pthread/tst-mtx-timedlock-time64.c b/sysdeps/pthread/tst-mtx-timedlock-time64.c
new file mode 100644
index 0000000000..b3393c99ef
--- /dev/null
+++ b/sysdeps/pthread/tst-mtx-timedlock-time64.c
@@ -0,0 +1 @@
+#include "tst-mtx-timedlock.c"
diff --git a/sysdeps/pthread/tst-rwlock14-time64.c b/sysdeps/pthread/tst-rwlock14-time64.c
new file mode 100644
index 0000000000..ae9b1912cf
--- /dev/null
+++ b/sysdeps/pthread/tst-rwlock14-time64.c
@@ -0,0 +1 @@
+#include "tst-rwlock14.c"
diff --git a/sysdeps/pthread/tst-sem5-time64.c b/sysdeps/pthread/tst-sem5-time64.c
new file mode 100644
index 0000000000..89c2a14f94
--- /dev/null
+++ b/sysdeps/pthread/tst-sem5-time64.c
@@ -0,0 +1 @@
+#include "tst-sem5.c"
diff --git a/sysdeps/pthread/tst-thrd-sleep-time64.c b/sysdeps/pthread/tst-thrd-sleep-time64.c
new file mode 100644
index 0000000000..02837bd19f
--- /dev/null
+++ b/sysdeps/pthread/tst-thrd-sleep-time64.c
@@ -0,0 +1 @@
+#include "tst-thrd-sleep.c"
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index fc2a17307c..94ee85d124 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -115,6 +115,14 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
 	 tst-futimes tst-lutimes
 
 tests-internal += tst-ofdlocks-compat tst-sigcontext-get_pc
+tests-time64 += \
+  tst-futimes-time64\
+  tst-futimens-time64 \
+  tst-lutimes-time64 \
+  tst-ppoll-time64 \
+  tst-utime-time64 \
+  tst-utimes-time64 \
+  tst-timerfd-time64
 
 CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
 
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index b53391f613..982b94e625 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -237,7 +237,9 @@ libc {
     __timegm64;
     __timespec_get64;
     __utimensat64;
-     __utimes64;
+    __utimes64;
+    __localtime64;
+    __localtime64_r;
     # misc
     __ntp_gettime64;
     __ntp_gettimex64;
diff --git a/sysdeps/unix/sysv/linux/tst-futimens-time64.c b/sysdeps/unix/sysv/linux/tst-futimens-time64.c
new file mode 100644
index 0000000000..88fcb38489
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-futimens-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimens.c"
diff --git a/sysdeps/unix/sysv/linux/tst-futimens.c b/sysdeps/unix/sysv/linux/tst-futimens.c
index 8f48cfee63..b5b240abf1 100644
--- a/sysdeps/unix/sysv/linux/tst-futimens.c
+++ b/sysdeps/unix/sysv/linux/tst-futimens.c
@@ -24,10 +24,14 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 
 /* struct timespec array with Y2038 threshold minus 2 and 1 seconds.  */
-const struct timespec t1[2] = { { 0x7FFFFFFE, 0 },  { 0x7FFFFFFF, 0 } };
+const static struct timespec t1[2] = { { 0x7FFFFFFE, 0 },  { 0x7FFFFFFF, 0 } };
 
 /* struct timespec array with Y2038 threshold plus 1 and 2 seconds.  */
 const struct timespec t2[2] = { { 0x80000001ULL, 0 },  { 0x80000002ULL, 0 } };
@@ -46,7 +50,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_futimens_helper (const struct timespec *ts)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
diff --git a/sysdeps/unix/sysv/linux/tst-futimes-time64.c b/sysdeps/unix/sysv/linux/tst-futimes-time64.c
new file mode 100644
index 0000000000..d489c265d1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-futimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-lutimes-time64.c b/sysdeps/unix/sysv/linux/tst-lutimes-time64.c
new file mode 100644
index 0000000000..06caec0a91
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-lutimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-lutimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ppoll-time64.c b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
new file mode 100644
index 0000000000..96ee2faee3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
@@ -0,0 +1 @@
+#include "tst-ppoll.c"
diff --git a/sysdeps/unix/sysv/linux/tst-timerfd-time64.c b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
new file mode 100644
index 0000000000..bb17f48139
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
@@ -0,0 +1 @@
+#include "tst-timerfd.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utime-time64.c b/sysdeps/unix/sysv/linux/tst-utime-time64.c
new file mode 100644
index 0000000000..eb62f59126
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-utime-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utime.c b/sysdeps/unix/sysv/linux/tst-utime.c
index 6735421657..d413f130e8 100644
--- a/sysdeps/unix/sysv/linux/tst-utime.c
+++ b/sysdeps/unix/sysv/linux/tst-utime.c
@@ -26,6 +26,10 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 char *testfile;
 
@@ -49,7 +53,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_utime_helper (const struct utimbuf *ut)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
diff --git a/sysdeps/unix/sysv/linux/tst-utimes-time64.c b/sysdeps/unix/sysv/linux/tst-utimes-time64.c
new file mode 100644
index 0000000000..234ec02541
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-utimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utimes.c b/sysdeps/unix/sysv/linux/tst-utimes.c
index 8c7b006a22..c521c89dfa 100644
--- a/sysdeps/unix/sysv/linux/tst-utimes.c
+++ b/sysdeps/unix/sysv/linux/tst-utimes.c
@@ -25,6 +25,10 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 char *testfile;
 
@@ -50,7 +54,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_utime_helper (const struct timeval *tv)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
diff --git a/sysvipc/Makefile b/sysvipc/Makefile
index a534791928..86911803b5 100644
--- a/sysvipc/Makefile
+++ b/sysvipc/Makefile
@@ -32,6 +32,8 @@ routines := ftok \
 
 tests    := test-sysvmsg test-sysvsem test-sysvshm
 
+tests-time64 := test-sysvmsg-time64 test-sysvsem-time64 test-sysvshm-time64
+
 include ../Rules
 
 CFLAGS-msgrcv.c += -fexceptions -fasynchronous-unwind-tables
diff --git a/sysvipc/test-sysvmsg-time64.c b/sysvipc/test-sysvmsg-time64.c
new file mode 100644
index 0000000000..c23e0c337e
--- /dev/null
+++ b/sysvipc/test-sysvmsg-time64.c
@@ -0,0 +1 @@
+#include "test-sysvmsg.c"
diff --git a/sysvipc/test-sysvsem-time64.c b/sysvipc/test-sysvsem-time64.c
new file mode 100644
index 0000000000..05c95068cd
--- /dev/null
+++ b/sysvipc/test-sysvsem-time64.c
@@ -0,0 +1 @@
+#include "test-sysvsem.c"
diff --git a/sysvipc/test-sysvshm-time64.c b/sysvipc/test-sysvshm-time64.c
new file mode 100644
index 0000000000..8e2963f563
--- /dev/null
+++ b/sysvipc/test-sysvshm-time64.c
@@ -0,0 +1 @@
+#include "test-sysvshm.c"
diff --git a/time/Makefile b/time/Makefile
index f14022b334..fee206d3c7 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -51,6 +51,21 @@ tests	:= test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
 	   tst-adjtime tst-ctime tst-difftime tst-mktime4 tst-itimer \
 	   tst-gmtime tst-timegm tst-timespec_get
 
+tests-time64 := \
+  tst-adjtime-time64 \
+  tst-clock-time64 \
+  tst-clock2-time64 \
+  tst-clock_nanosleep-time64 \
+  tst-cpuclock1-time64 \
+  tst-ctime-time64 \
+  tst-difftime-time64 \
+  tst-gmtime-time64 \
+  tst-itimer-time64 \
+  tst-mktime4-time64 \
+  tst-timegm-time64 \
+  tst-timespec_get-time64 \
+  tst-y2039-time64
+
 include ../Rules
 
 ifeq ($(run-built-tests),yes)
diff --git a/time/tst-adjtime-time64.c b/time/tst-adjtime-time64.c
new file mode 100644
index 0000000000..097d6efc4b
--- /dev/null
+++ b/time/tst-adjtime-time64.c
@@ -0,0 +1 @@
+#include <tst-adjtime.c>
diff --git a/time/tst-clock-time64.c b/time/tst-clock-time64.c
new file mode 100644
index 0000000000..a1349678c8
--- /dev/null
+++ b/time/tst-clock-time64.c
@@ -0,0 +1 @@
+#include "tst-clock.c"
diff --git a/time/tst-clock2-time64.c b/time/tst-clock2-time64.c
new file mode 100644
index 0000000000..897f47b287
--- /dev/null
+++ b/time/tst-clock2-time64.c
@@ -0,0 +1 @@
+#include "tst-clock2.c"
diff --git a/time/tst-clock_nanosleep-time64.c b/time/tst-clock_nanosleep-time64.c
new file mode 100644
index 0000000000..c8638aa3d2
--- /dev/null
+++ b/time/tst-clock_nanosleep-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_nanosleep.c"
diff --git a/time/tst-cpuclock1-time64.c b/time/tst-cpuclock1-time64.c
new file mode 100644
index 0000000000..5a7ffa27ac
--- /dev/null
+++ b/time/tst-cpuclock1-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock1.c"
diff --git a/time/tst-ctime-time64.c b/time/tst-ctime-time64.c
new file mode 100644
index 0000000000..24a5ae98ed
--- /dev/null
+++ b/time/tst-ctime-time64.c
@@ -0,0 +1 @@
+#include "tst-ctime.c"
diff --git a/time/tst-ctime.c b/time/tst-ctime.c
index e89a906bf8..884d69bfa0 100644
--- a/time/tst-ctime.c
+++ b/time/tst-ctime.c
@@ -24,6 +24,7 @@ static int
 do_test (void)
 {
   char *str;
+  char strb[32];
   time_t t;
 
   /* Use glibc time zone extension "TZ=:" to to guarantee that UTC
@@ -36,11 +37,21 @@ do_test (void)
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
+
   /* Check if the max time value for 32 bit time_t can be converted.  */
   t = 0x7fffffff;
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
+
   /* Check if we run on port with 32 bit time_t size */
   time_t tov;
   if (__builtin_add_overflow (t, 1, &tov))
@@ -50,6 +61,11 @@ do_test (void)
   str = ctime (&tov);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&tov, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
+
   return 0;
 }
 
diff --git a/time/tst-difftime-time64.c b/time/tst-difftime-time64.c
new file mode 100644
index 0000000000..751ce6c483
--- /dev/null
+++ b/time/tst-difftime-time64.c
@@ -0,0 +1 @@
+#include "tst-difftime.c"
diff --git a/time/tst-gmtime-time64.c b/time/tst-gmtime-time64.c
new file mode 100644
index 0000000000..0df11c1913
--- /dev/null
+++ b/time/tst-gmtime-time64.c
@@ -0,0 +1 @@
+#include "tst-gmtime.c"
diff --git a/time/tst-itimer-time64.c b/time/tst-itimer-time64.c
new file mode 100644
index 0000000000..ddd2efa175
--- /dev/null
+++ b/time/tst-itimer-time64.c
@@ -0,0 +1 @@
+#include <time/tst-itimer.c>
diff --git a/time/tst-mktime4-time64.c b/time/tst-mktime4-time64.c
new file mode 100644
index 0000000000..bf5197c6f3
--- /dev/null
+++ b/time/tst-mktime4-time64.c
@@ -0,0 +1 @@
+#include "tst-mktime4.c"
diff --git a/time/tst-timegm-time64.c b/time/tst-timegm-time64.c
new file mode 100644
index 0000000000..8e3084f74e
--- /dev/null
+++ b/time/tst-timegm-time64.c
@@ -0,0 +1 @@
+#include "tst-timegm.c"
diff --git a/time/tst-timespec_get-time64.c b/time/tst-timespec_get-time64.c
new file mode 100644
index 0000000000..48f336385d
--- /dev/null
+++ b/time/tst-timespec_get-time64.c
@@ -0,0 +1 @@
+#include "tst-timespec_get.c"
diff --git a/time/tst-y2039-time64.c b/time/tst-y2039-time64.c
new file mode 100644
index 0000000000..3c8a504186
--- /dev/null
+++ b/time/tst-y2039-time64.c
@@ -0,0 +1 @@
+#include "tst-y2039.c"
diff --git a/time/tst-y2039.c b/time/tst-y2039.c
index ef024c0a77..66a22d4c2c 100644
--- a/time/tst-y2039.c
+++ b/time/tst-y2039.c
@@ -37,6 +37,16 @@ do_test (void)
 			> 0);
       puts (buf);
       TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
+
+      /* Same as before but for localtime_r.  */
+      struct tm tmd;
+      tm = localtime_r (&ouch, &tmd);
+      TEST_VERIFY_EXIT (tm == &tmd);
+
+      TEST_VERIFY_EXIT (strftime (buf, sizeof buf, "%Y-%m-%d %H:%M:%S %Z", tm)
+			> 0);
+      puts (buf);
+      TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
     }
   else
     FAIL_UNSUPPORTED ("32-bit time_t");


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [glibc/azanella/y2038] y2038: Add test coverage
@ 2021-03-04 17:40 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2021-03-04 17:40 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e3fdc891ab4ac49430579de45221f9375c30eaa6

commit e3fdc891ab4ac49430579de45221f9375c30eaa6
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Feb 17 15:59:34 2021 -0300

    y2038: Add test coverage
    
    A new 'tests-y2038' rule is added, which adds the required 64 bit
    time flags and included in the 'tests' rule.
    
    The current coverage is:
    
      * libc:
        - adjtime                       tst-adjtime-time64
        - adjtimex
        - clock_adjtime                 tst-clock_adjtime-time64
        - clock_getres                  tst-clock-time64, tst-cpuclock1-time64
        - clock_gettime                 tst-clock-time64, tst-clock2-time64,
                                        tst-cpuclock1-time64
        - clock_nanoslee                tst-clock_nanosleep-time64,
                                        tst-cpuclock1-time64
        - clock_settime                 tst-clock2-time64
        - ctime                         tst-ctime-time64
        - ctime_r                       tst-ctime-time64
        - difftime                      tst-difftime-time64
        - fstat                         tst-stat-time64
        - fstatat                       tst-stat-time64
        - futimens                      tst-futimens-time64
        - futimes                       tst-futimes-time64
        - futimesat                     tst-futimesat-time64
        - fts_*                         tst-fts-time64
        - getitimer                     tst-itimer-timer64
        - getrusage
        - gettimeofday                  tst-clock_nanosleep-time64
        - glob / globfree               tst-gnuglob64-time64
        - gmtime                        tst-gmtime-time64
        - gmtime_r                      tst-gmtime-time64
        - lstat                         tst-stat-time64
        - localtime                     tst-y2039-time64
        - localtime_t                   tst-y2039-time64
        - lutimes                       tst-lutimes-time64
        - mktime                        tst-mktime4-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - msgctl                        test-sysvmsg-time64
        - nanosleep                     tst-cpuclock{12}-time64,
                                        tst-mqueue8-time64, tst-clock-time64
        - nftw / ftw                    ftwtest-time64
        - ntp_adjtime
        - ntp_gettime
        - ntp_gettimex
        - ppoll                         tst-ppoll-time64
        - pselect                       tst-pselect-time64
        - recvmmsg                      tst-cancel4_2-time64
        - sched_rr_get_interval         tst-sched_rr_get_interval-time64
        - select
        - semctl                        test-sysvsem-time64
        - semtimedop                    test-sysvsem-time64
        - setitimer                     tst-mqueue2-time64, tst-itimer-timer64
        - settimeofday
        - shmctl                        test-sysvshm-time64
        - sigtimedwait
        - stat                          tst-stat-time64
        - time                          tst-mqueue{1248}-time64
        - timegm                        tst-timegm-time64
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
        - timerfd_gettime               tst-timerfd-time64
        - timerfd_settime               tst-timerfd-time64
        - timespec_get                  tst-timespec_get-time64
        - utime                         tst-utime-time64
        - utimensat                     tst-utimensat-time64
        - utimes                        tst-utimes-time64
        - wait3                         tst-wait3-time64
        - wait4                         tst-wait4-time64
    
      * libpthread:
        - cnd_timedwait                 tst-cnd-timedwait-time64
        - mtx_timedlock                 tst-mtx-timedlock-time64
        - pthread_clockjoin_np          tst-join14-time64
        - pthread_cond_clockwait        tst-cond11-time64
        - pthread_cond_timedwait        tst-abstime-time64
        - pthread_mutex_clocklock       tst-abstime-time64
        - pthread_mutex_timedlock       tst-abstime-time64
        - pthread_rwlock_clockrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_clockwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_timedjoin_np          tst-join14-time64
        - sem_clockwait                 tst-sem5-time64
        - sem_timedwait                 tst-sem5-time64
        - thrd_sleep                    tst-thrd-sleep-time64
    
      * librt:
        - aio_suspend                   tst-aio6-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
    
      * libanl:
        - gai_suspend

Diff:
---
 Makerules                                          |  23 ++++-
 io/Makefile                                        |  16 +++-
 io/ftwtest-time64.c                                |   1 +
 io/tst-fts-time64.c                                |   1 +
 io/tst-futimesat-time64.c                          |   4 +
 io/tst-futimesat.c                                 |  47 +++++++---
 io/tst-stat-time64.c                               | 102 +++++++++++++++++++++
 io/tst-utimensat-time64.c                          |   2 +
 misc/Makefile                                      |   2 +
 misc/tst-pselect-time64.c                          |   1 +
 nptl/Makefile                                      |   3 +
 nptl/tst-cancel4_2-time64.c                        |   1 +
 posix/Makefile                                     |   2 +
 posix/tst-gnuglob64-time64.c                       |   7 ++
 posix/tst-sched_rr_get_interval-time64.c           |   1 +
 posix/tst-wait3-time64.c                           |   1 +
 posix/tst-wait4-time64.c                           |   1 +
 rt/Makefile                                        |   9 ++
 rt/tst-aio6-time64.c                               |   1 +
 rt/tst-cpuclock2-time64.c                          |   1 +
 rt/tst-cpuclock2.c                                 |   9 +-
 rt/tst-mqueue1-time64.c                            |   1 +
 rt/tst-mqueue2-time64.c                            |   1 +
 rt/tst-mqueue4-time64.c                            |   1 +
 rt/tst-mqueue8-time64.c                            |   1 +
 rt/tst-timer4-time64.c                             |   1 +
 sysdeps/pthread/Makefile                           |  10 ++
 sysdeps/pthread/tst-abstime-time64.c               |   1 +
 sysdeps/pthread/tst-cnd-timedwait-time64.c         |   1 +
 sysdeps/pthread/tst-cond11-time64.c                |   1 +
 sysdeps/pthread/tst-join14-time64.c                |   1 +
 sysdeps/pthread/tst-mtx-timedlock-time64.c         |   1 +
 sysdeps/pthread/tst-rwlock14-time64.c              |   1 +
 sysdeps/pthread/tst-sem5-time64.c                  |   1 +
 sysdeps/pthread/tst-thrd-sleep-time64.c            |   1 +
 sysdeps/unix/sysv/linux/Makefile                   |   9 ++
 sysdeps/unix/sysv/linux/Versions                   |   4 +-
 sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c |   1 +
 sysdeps/unix/sysv/linux/tst-futimens-time64.c      |   2 +
 sysdeps/unix/sysv/linux/tst-futimens.c             |   8 +-
 sysdeps/unix/sysv/linux/tst-futimes-time64.c       |   2 +
 sysdeps/unix/sysv/linux/tst-lutimes-time64.c       |   2 +
 sysdeps/unix/sysv/linux/tst-ppoll-time64.c         |   1 +
 sysdeps/unix/sysv/linux/tst-timerfd-time64.c       |   1 +
 sysdeps/unix/sysv/linux/tst-utime-time64.c         |   2 +
 sysdeps/unix/sysv/linux/tst-utime.c                |   6 +-
 sysdeps/unix/sysv/linux/tst-utimes-time64.c        |   2 +
 sysdeps/unix/sysv/linux/tst-utimes.c               |   6 +-
 sysvipc/Makefile                                   |   2 +
 sysvipc/test-sysvmsg-time64.c                      |   1 +
 sysvipc/test-sysvsem-time64.c                      |   1 +
 sysvipc/test-sysvshm-time64.c                      |   1 +
 time/Makefile                                      |  15 +++
 time/tst-adjtime-time64.c                          |   1 +
 time/tst-clock-time64.c                            |   1 +
 time/tst-clock2-time64.c                           |   1 +
 time/tst-clock_nanosleep-time64.c                  |   1 +
 time/tst-cpuclock1-time64.c                        |   1 +
 time/tst-ctime-time64.c                            |   1 +
 time/tst-ctime.c                                   |  16 ++++
 time/tst-difftime-time64.c                         |   1 +
 time/tst-gmtime-time64.c                           |   1 +
 time/tst-itimer-time64.c                           |   1 +
 time/tst-mktime4-time64.c                          |   1 +
 time/tst-timegm-time64.c                           |   1 +
 time/tst-timespec_get-time64.c                     |   1 +
 time/tst-y2039-time64.c                            |   1 +
 time/tst-y2039.c                                   |  10 ++
 68 files changed, 339 insertions(+), 24 deletions(-)

diff --git a/Makerules b/Makerules
index fc5251ffad..aca5d1f4d7 100644
--- a/Makerules
+++ b/Makerules
@@ -771,7 +771,8 @@ endif
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
 	     $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
-	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs))
+	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) \
+		$(test-srcs) $(tests-time64) $(xtests-time64))
 ifeq ($(build-programs),yes)
 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
 endif
@@ -1286,6 +1287,26 @@ check: tests
 .PHONY: xcheck
 xcheck: xtests
 
+# Handle tests-time64 and xtests-time64 that should built with LFS
+# and 64-bit time support.
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(tests-time64),$(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+tests += $(foreach t,$(tests-time64),$(t))
+
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(xtests-time64),$(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+xtests += $(foreach t,$(xtests-time64),$(t))
+
 # The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
 # that almost all internal declarations from config.h, libc-symbols.h, and
 # include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
diff --git a/io/Makefile b/io/Makefile
index 6c637f7c6d..a39f0ecfc1 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -59,7 +59,7 @@ routines :=								\
 	ftw64-time64
 
 others		:= pwd
-test-srcs	:= ftwtest
+test-srcs	:= ftwtest ftwtest-time64
 tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-fcntl bug-ftw1 bug-ftw2 bug-ftw3 bug-ftw4 tst-statvfs \
 		   tst-openat tst-unlinkat tst-fstatat tst-futimesat \
@@ -72,12 +72,18 @@ tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-ftw-lnk tst-file_change_detection tst-lchmod \
 		   tst-ftw-bz26353 tst-utimensat
 
+tests-time64    := tst-fts-time64 \
+		   tst-stat-time64 \
+		   tst-futimesat-time64 \
+		   tst-utimensat-time64
+
 # Likewise for statx, but we do not need static linking here.
 tests-internal += tst-statx
 tests-static += tst-statx
 
 ifeq ($(run-built-tests),yes)
-tests-special += $(objpfx)ftwtest.out
+tests-special += $(objpfx)ftwtest.out \
+		 $(objpfx)ftwtest-time64.out
 endif
 
 include ../Rules
@@ -118,8 +124,14 @@ tst-statvfs-ARGS = $(objpfx)tst-statvfs tst-statvfs.c /tmp
 
 tst-open-tmpfile-ARGS = --test-dir=$(objpfx)
 
+CFLAGS-ftwtest-time64.c += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+
 ifeq ($(run-built-tests),yes)
 $(objpfx)ftwtest.out: ftwtest-sh $(objpfx)ftwtest
 	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
 	$(evaluate-test)
+
+$(objpfx)ftwtest-time64.out: ftwtest-sh $(objpfx)ftwtest-time64
+	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
+	$(evaluate-test)
 endif
diff --git a/io/ftwtest-time64.c b/io/ftwtest-time64.c
new file mode 100644
index 0000000000..67f1c46826
--- /dev/null
+++ b/io/ftwtest-time64.c
@@ -0,0 +1 @@
+#include "ftwtest.c"
diff --git a/io/tst-fts-time64.c b/io/tst-fts-time64.c
new file mode 100644
index 0000000000..a4a41fe1cf
--- /dev/null
+++ b/io/tst-fts-time64.c
@@ -0,0 +1 @@
+#include "tst-fts.c"
diff --git a/io/tst-futimesat-time64.c b/io/tst-futimesat-time64.c
new file mode 100644
index 0000000000..f6c0500eef
--- /dev/null
+++ b/io/tst-futimesat-time64.c
@@ -0,0 +1,4 @@
+#define struct_stat  struct stat
+#define fstat        fstat
+#define fstatat      fstatat
+#include "io/tst-futimesat.c"
diff --git a/io/tst-futimesat.c b/io/tst-futimesat.c
index af58ad06dd..c32ab2b668 100644
--- a/io/tst-futimesat.c
+++ b/io/tst-futimesat.c
@@ -1,4 +1,23 @@
+/* futimesat basic tests.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
 #include <dirent.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -7,19 +26,19 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#include <support/test-driver.h>
+#include <support/temp_file.h>
 
-static void prepare (void);
-#define PREPARE(argc, argv) prepare ()
-
-static int do_test (void);
-#define TEST_FUNCTION do_test ()
-
-#include "../test-skeleton.c"
+#ifndef struct_stat
+# define struct_stat struct stat64
+# define fstat       fstat64
+# define fstatat     fstatat64
+#endif
 
 static int dir_fd;
 
 static void
-prepare (void)
+prepare (int argc, char *argv[])
 {
   size_t test_dir_len = strlen (test_dir);
   static const char dir_name[] = "/tst-futimesat.XXXXXX";
@@ -48,7 +67,7 @@ prepare (void)
       exit (1);
     }
 }
-
+#define PREPARE prepare
 
 static int
 do_test (void)
@@ -98,8 +117,8 @@ do_test (void)
   write (fd, "hello", 5);
   puts ("file created");
 
-  struct stat64 st1;
-  if (fstat64 (fd, &st1) != 0)
+  struct_stat st1;
+  if (fstat (fd, &st1) != 0)
     {
       puts ("fstat64 failed");
       return 1;
@@ -118,8 +137,8 @@ do_test (void)
       return 1;
     }
 
-  struct stat64 st2;
-  if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0)
+  struct_stat st2;
+  if (fstatat (dir_fd, "some-file", &st2, 0) != 0)
     {
       puts ("fstatat64 failed");
       return 1;
@@ -146,3 +165,5 @@ do_test (void)
 
   return 0;
 }
+
+#include <support/test-driver.c>
diff --git a/io/tst-stat-time64.c b/io/tst-stat-time64.c
new file mode 100644
index 0000000000..c10fe1284a
--- /dev/null
+++ b/io/tst-stat-time64.c
@@ -0,0 +1,102 @@
+/* Basic test of stat with 64 bit time_t interfaces.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <support/check.h>
+#include <support/support.h>
+#include <support/temp_file.h>
+#include <support/xunistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+
+/* The idea of the test is check whether the 64 bit time_t stat implementation
+   returns the expected value for comparable fields, so it does not really
+   matter whether statx uses a fallback implementation or not.  */
+
+static void
+stat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (stat (path, st), 0);
+}
+
+static void
+lstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (lstat (path, st), 0);
+}
+
+static void
+fstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstat (fd, st), 0);
+}
+
+static void
+fstatat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstatat (fd, path, st, 0), 0);
+}
+
+typedef void (*test_t)(int, const char *path, struct stat *);
+
+static int
+do_test (void)
+{
+  char *path;
+  int fd = create_temp_file ("tst-statx-", &path);
+  TEST_VERIFY_EXIT (fd >= 0);
+  support_write_file_string (path, "abc");
+
+  struct statx stx;
+  TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0);
+
+  for (test_t *test = (test_t[]) { stat_check, lstat_check, fstat_check,
+				   fstatat_check, NULL };
+       *test != NULL; test++)
+  {
+    struct stat st;
+    (*test) (fd, path, &st);
+
+    TEST_COMPARE (stx.stx_dev_major, major (st.st_dev));
+    TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev));
+    TEST_COMPARE (stx.stx_ino, st.st_ino);
+    TEST_COMPARE (stx.stx_mode, st.st_mode);
+    TEST_COMPARE (stx.stx_nlink, st.st_nlink);
+    TEST_COMPARE (stx.stx_uid, st.st_uid);
+    TEST_COMPARE (stx.stx_gid, st.st_gid);
+    TEST_COMPARE (stx.stx_rdev_major, major (st.st_rdev));
+    TEST_COMPARE (stx.stx_rdev_minor, minor (st.st_rdev));
+    TEST_COMPARE (stx.stx_blksize, st.st_blksize);
+    TEST_COMPARE (stx.stx_blocks, st.st_blocks);
+
+    TEST_COMPARE (stx.stx_ctime.tv_sec, st.st_ctim.tv_sec);
+    TEST_COMPARE (stx.stx_ctime.tv_nsec, st.st_ctim.tv_nsec);
+    TEST_COMPARE (stx.stx_mtime.tv_sec, st.st_mtim.tv_sec);
+    TEST_COMPARE (stx.stx_mtime.tv_nsec, st.st_mtim.tv_nsec);
+  }
+
+  xclose (fd);
+  free (path);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/io/tst-utimensat-time64.c b/io/tst-utimensat-time64.c
new file mode 100644
index 0000000000..7ac7d8df1d
--- /dev/null
+++ b/io/tst-utimensat-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimensat.c"
diff --git a/misc/Makefile b/misc/Makefile
index cfc15355d6..a8363d4b76 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -90,6 +90,8 @@ tests := tst-dirname tst-tsearch tst-fdset tst-mntent tst-hsearch \
 	 tst-ldbl-warn tst-ldbl-error tst-dbl-efgcvt tst-ldbl-efgcvt \
 	 tst-mntent-autofs tst-syscalls tst-mntent-escape
 
+tests-time64 := tst-pselect-time64
+
 # Tests which need libdl.
 ifeq (yes,$(build-shared))
 tests += tst-gethostid
diff --git a/misc/tst-pselect-time64.c b/misc/tst-pselect-time64.c
new file mode 100644
index 0000000000..15a1e49292
--- /dev/null
+++ b/misc/tst-pselect-time64.c
@@ -0,0 +1 @@
+#include "tst-pselect.c"
diff --git a/nptl/Makefile b/nptl/Makefile
index 5f85dd7854..0a0e8d360c 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -380,6 +380,9 @@ xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
 	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10 tst-setgroups \
 	tst-mutexpp5 tst-mutexpp9
 
+tests-time64 := \
+  tst-cancel4_2-time64
+
 # This test can run into task limits because of a linux kernel bug
 # and then cause the make process to fail too, see bug 24537.
 xtests += tst-eintr1
diff --git a/nptl/tst-cancel4_2-time64.c b/nptl/tst-cancel4_2-time64.c
new file mode 100644
index 0000000000..4ac086a312
--- /dev/null
+++ b/nptl/tst-cancel4_2-time64.c
@@ -0,0 +1 @@
+#include "tst-cancel4_2.c"
diff --git a/posix/Makefile b/posix/Makefile
index aba66efde8..e246ff1d14 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -109,7 +109,9 @@ tests-internal	:= bug-regex5 bug-regex20 bug-regex33 \
 		   tst-rfc3484 tst-rfc3484-2 tst-rfc3484-3 \
 		   tst-glob_lstat_compat tst-spawn4-compat
 tests-container := bug-ga2
+tests-time64	:= tst-wait4-time64 tst-wait3-time64 tst-gnuglob64-time64
 xtests		:= tst-getaddrinfo4 tst-getaddrinfo5 tst-sched_rr_get_interval
+xtests-time64	:= tst-sched_rr_get_interval-time64
 ifeq (yes,$(build-shared))
 test-srcs	:= globtest
 tests           += wordexp-test tst-exec tst-spawn tst-spawn2 tst-spawn3
diff --git a/posix/tst-gnuglob64-time64.c b/posix/tst-gnuglob64-time64.c
new file mode 100644
index 0000000000..00922bcdc6
--- /dev/null
+++ b/posix/tst-gnuglob64-time64.c
@@ -0,0 +1,7 @@
+#define GLOB_FUNC glob
+#define GLOB_TYPE glob_t
+#define GLOBFREE_FUNC globfree
+#define DIRENT_STRUCT dirent
+#define STAT_STRUCT stat
+
+#include "tst-gnuglob-skeleton.c"
diff --git a/posix/tst-sched_rr_get_interval-time64.c b/posix/tst-sched_rr_get_interval-time64.c
new file mode 100644
index 0000000000..f4e66d2939
--- /dev/null
+++ b/posix/tst-sched_rr_get_interval-time64.c
@@ -0,0 +1 @@
+#include "tst-sched_rr_get_interval.c"
diff --git a/posix/tst-wait3-time64.c b/posix/tst-wait3-time64.c
new file mode 100644
index 0000000000..2837bc7a9e
--- /dev/null
+++ b/posix/tst-wait3-time64.c
@@ -0,0 +1 @@
+#include "tst-wait3.c"
diff --git a/posix/tst-wait4-time64.c b/posix/tst-wait4-time64.c
new file mode 100644
index 0000000000..12543b270f
--- /dev/null
+++ b/posix/tst-wait4-time64.c
@@ -0,0 +1 @@
+#include "tst-wait4.c"
diff --git a/rt/Makefile b/rt/Makefile
index 7b374f2073..3ce98297f9 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -49,6 +49,15 @@ tests := tst-shm tst-timer tst-timer2 \
 	 tst-shm-cancel
 tests-internal := tst-timer-sigmask
 
+tests-time64 := \
+  tst-aio6-time64 \
+  tst-cpuclock2-time64 \
+  tst-mqueue1-time64 \
+  tst-mqueue2-time64 \
+  tst-mqueue4-time64 \
+  tst-mqueue8-time64 \
+  tst-timer4-time64
+
 extra-libs := librt
 extra-libs-others := $(extra-libs)
 
diff --git a/rt/tst-aio6-time64.c b/rt/tst-aio6-time64.c
new file mode 100644
index 0000000000..a386a577ec
--- /dev/null
+++ b/rt/tst-aio6-time64.c
@@ -0,0 +1 @@
+#include "tst-aio6.c"
diff --git a/rt/tst-cpuclock2-time64.c b/rt/tst-cpuclock2-time64.c
new file mode 100644
index 0000000000..05775522bb
--- /dev/null
+++ b/rt/tst-cpuclock2-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock2.c"
diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c
index c1c7ed2ad8..eebc3609d0 100644
--- a/rt/tst-cpuclock2.c
+++ b/rt/tst-cpuclock2.c
@@ -21,7 +21,11 @@
 
 #if (_POSIX_THREADS - 0) <= 0
 
-# define TEST_FUNCTION 0
+static int
+do_test ()
+{
+  return 0;
+}
 
 #else
 
@@ -330,7 +334,6 @@ do_test (void)
 
   return result;
 }
-# define TEST_FUNCTION do_test ()
 #endif
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/rt/tst-mqueue1-time64.c b/rt/tst-mqueue1-time64.c
new file mode 100644
index 0000000000..9c600a9a97
--- /dev/null
+++ b/rt/tst-mqueue1-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue1.c"
diff --git a/rt/tst-mqueue2-time64.c b/rt/tst-mqueue2-time64.c
new file mode 100644
index 0000000000..9d49f0b196
--- /dev/null
+++ b/rt/tst-mqueue2-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue2.c"
diff --git a/rt/tst-mqueue4-time64.c b/rt/tst-mqueue4-time64.c
new file mode 100644
index 0000000000..c23a228dc4
--- /dev/null
+++ b/rt/tst-mqueue4-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue4.c"
diff --git a/rt/tst-mqueue8-time64.c b/rt/tst-mqueue8-time64.c
new file mode 100644
index 0000000000..972637f7f5
--- /dev/null
+++ b/rt/tst-mqueue8-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue8.c"
diff --git a/rt/tst-timer4-time64.c b/rt/tst-timer4-time64.c
new file mode 100644
index 0000000000..e47a593f10
--- /dev/null
+++ b/rt/tst-timer4-time64.c
@@ -0,0 +1 @@
+#include "tst-timer4.c"
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index eeb64f9fb0..d4bfe2aee5 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -109,6 +109,16 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
 	 tst-unwind-thread \
 	 tst-pt-vfork1 tst-pt-vfork2 tst-vfork1x tst-vfork2x \
 
+tests-time64 := \
+  tst-abstime-time64 \
+  tst-cnd-timedwait-time64 \
+  tst-cond11-time64 \
+  tst-join14-time64 \
+  tst-mtx-timedlock-time64 \
+  tst-rwlock14-time64 \
+  tst-sem5-time64 \
+  tst-thrd-sleep-time64 \
+
 
 # Files which must not be linked with libpthread.
 tests-nolibpthread = tst-unload
diff --git a/sysdeps/pthread/tst-abstime-time64.c b/sysdeps/pthread/tst-abstime-time64.c
new file mode 100644
index 0000000000..2fc77cb365
--- /dev/null
+++ b/sysdeps/pthread/tst-abstime-time64.c
@@ -0,0 +1 @@
+#include "tst-abstime.c"
diff --git a/sysdeps/pthread/tst-cnd-timedwait-time64.c b/sysdeps/pthread/tst-cnd-timedwait-time64.c
new file mode 100644
index 0000000000..9b2abfd277
--- /dev/null
+++ b/sysdeps/pthread/tst-cnd-timedwait-time64.c
@@ -0,0 +1 @@
+#include "tst-cnd-timedwait.c"
diff --git a/sysdeps/pthread/tst-cond11-time64.c b/sysdeps/pthread/tst-cond11-time64.c
new file mode 100644
index 0000000000..9bccb8ec8b
--- /dev/null
+++ b/sysdeps/pthread/tst-cond11-time64.c
@@ -0,0 +1 @@
+#include "tst-cond11.c"
diff --git a/sysdeps/pthread/tst-join14-time64.c b/sysdeps/pthread/tst-join14-time64.c
new file mode 100644
index 0000000000..bed784ee24
--- /dev/null
+++ b/sysdeps/pthread/tst-join14-time64.c
@@ -0,0 +1 @@
+#include "tst-join14.c"
diff --git a/sysdeps/pthread/tst-mtx-timedlock-time64.c b/sysdeps/pthread/tst-mtx-timedlock-time64.c
new file mode 100644
index 0000000000..b3393c99ef
--- /dev/null
+++ b/sysdeps/pthread/tst-mtx-timedlock-time64.c
@@ -0,0 +1 @@
+#include "tst-mtx-timedlock.c"
diff --git a/sysdeps/pthread/tst-rwlock14-time64.c b/sysdeps/pthread/tst-rwlock14-time64.c
new file mode 100644
index 0000000000..ae9b1912cf
--- /dev/null
+++ b/sysdeps/pthread/tst-rwlock14-time64.c
@@ -0,0 +1 @@
+#include "tst-rwlock14.c"
diff --git a/sysdeps/pthread/tst-sem5-time64.c b/sysdeps/pthread/tst-sem5-time64.c
new file mode 100644
index 0000000000..89c2a14f94
--- /dev/null
+++ b/sysdeps/pthread/tst-sem5-time64.c
@@ -0,0 +1 @@
+#include "tst-sem5.c"
diff --git a/sysdeps/pthread/tst-thrd-sleep-time64.c b/sysdeps/pthread/tst-thrd-sleep-time64.c
new file mode 100644
index 0000000000..02837bd19f
--- /dev/null
+++ b/sysdeps/pthread/tst-thrd-sleep-time64.c
@@ -0,0 +1 @@
+#include "tst-thrd-sleep.c"
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index c3ce642b62..9e88ebb9d2 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -115,6 +115,15 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
 	 tst-clock_adjtime tst-futimes tst-lutimes
 
 tests-internal += tst-ofdlocks-compat tst-sigcontext-get_pc
+tests-time64 += \
+  tst-clock_adjtime-time64 \
+  tst-futimes-time64\
+  tst-futimens-time64 \
+  tst-lutimes-time64 \
+  tst-ppoll-time64 \
+  tst-utime-time64 \
+  tst-utimes-time64 \
+  tst-timerfd-time64
 
 CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
 
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index b53391f613..982b94e625 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -237,7 +237,9 @@ libc {
     __timegm64;
     __timespec_get64;
     __utimensat64;
-     __utimes64;
+    __utimes64;
+    __localtime64;
+    __localtime64_r;
     # misc
     __ntp_gettime64;
     __ntp_gettimex64;
diff --git a/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c b/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
new file mode 100644
index 0000000000..9691e81229
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_adjtime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-futimens-time64.c b/sysdeps/unix/sysv/linux/tst-futimens-time64.c
new file mode 100644
index 0000000000..88fcb38489
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-futimens-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimens.c"
diff --git a/sysdeps/unix/sysv/linux/tst-futimens.c b/sysdeps/unix/sysv/linux/tst-futimens.c
index 8f48cfee63..b5b240abf1 100644
--- a/sysdeps/unix/sysv/linux/tst-futimens.c
+++ b/sysdeps/unix/sysv/linux/tst-futimens.c
@@ -24,10 +24,14 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 
 /* struct timespec array with Y2038 threshold minus 2 and 1 seconds.  */
-const struct timespec t1[2] = { { 0x7FFFFFFE, 0 },  { 0x7FFFFFFF, 0 } };
+const static struct timespec t1[2] = { { 0x7FFFFFFE, 0 },  { 0x7FFFFFFF, 0 } };
 
 /* struct timespec array with Y2038 threshold plus 1 and 2 seconds.  */
 const struct timespec t2[2] = { { 0x80000001ULL, 0 },  { 0x80000002ULL, 0 } };
@@ -46,7 +50,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_futimens_helper (const struct timespec *ts)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
diff --git a/sysdeps/unix/sysv/linux/tst-futimes-time64.c b/sysdeps/unix/sysv/linux/tst-futimes-time64.c
new file mode 100644
index 0000000000..d489c265d1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-futimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-lutimes-time64.c b/sysdeps/unix/sysv/linux/tst-lutimes-time64.c
new file mode 100644
index 0000000000..06caec0a91
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-lutimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-lutimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ppoll-time64.c b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
new file mode 100644
index 0000000000..96ee2faee3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
@@ -0,0 +1 @@
+#include "tst-ppoll.c"
diff --git a/sysdeps/unix/sysv/linux/tst-timerfd-time64.c b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
new file mode 100644
index 0000000000..bb17f48139
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
@@ -0,0 +1 @@
+#include "tst-timerfd.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utime-time64.c b/sysdeps/unix/sysv/linux/tst-utime-time64.c
new file mode 100644
index 0000000000..eb62f59126
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-utime-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utime.c b/sysdeps/unix/sysv/linux/tst-utime.c
index 6735421657..d413f130e8 100644
--- a/sysdeps/unix/sysv/linux/tst-utime.c
+++ b/sysdeps/unix/sysv/linux/tst-utime.c
@@ -26,6 +26,10 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 char *testfile;
 
@@ -49,7 +53,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_utime_helper (const struct utimbuf *ut)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
diff --git a/sysdeps/unix/sysv/linux/tst-utimes-time64.c b/sysdeps/unix/sysv/linux/tst-utimes-time64.c
new file mode 100644
index 0000000000..234ec02541
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-utimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utimes.c b/sysdeps/unix/sysv/linux/tst-utimes.c
index 8c7b006a22..c521c89dfa 100644
--- a/sysdeps/unix/sysv/linux/tst-utimes.c
+++ b/sysdeps/unix/sysv/linux/tst-utimes.c
@@ -25,6 +25,10 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 char *testfile;
 
@@ -50,7 +54,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_utime_helper (const struct timeval *tv)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
diff --git a/sysvipc/Makefile b/sysvipc/Makefile
index a534791928..86911803b5 100644
--- a/sysvipc/Makefile
+++ b/sysvipc/Makefile
@@ -32,6 +32,8 @@ routines := ftok \
 
 tests    := test-sysvmsg test-sysvsem test-sysvshm
 
+tests-time64 := test-sysvmsg-time64 test-sysvsem-time64 test-sysvshm-time64
+
 include ../Rules
 
 CFLAGS-msgrcv.c += -fexceptions -fasynchronous-unwind-tables
diff --git a/sysvipc/test-sysvmsg-time64.c b/sysvipc/test-sysvmsg-time64.c
new file mode 100644
index 0000000000..c23e0c337e
--- /dev/null
+++ b/sysvipc/test-sysvmsg-time64.c
@@ -0,0 +1 @@
+#include "test-sysvmsg.c"
diff --git a/sysvipc/test-sysvsem-time64.c b/sysvipc/test-sysvsem-time64.c
new file mode 100644
index 0000000000..05c95068cd
--- /dev/null
+++ b/sysvipc/test-sysvsem-time64.c
@@ -0,0 +1 @@
+#include "test-sysvsem.c"
diff --git a/sysvipc/test-sysvshm-time64.c b/sysvipc/test-sysvshm-time64.c
new file mode 100644
index 0000000000..8e2963f563
--- /dev/null
+++ b/sysvipc/test-sysvshm-time64.c
@@ -0,0 +1 @@
+#include "test-sysvshm.c"
diff --git a/time/Makefile b/time/Makefile
index 29208f35c0..414721ecc5 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -51,6 +51,21 @@ tests	:= test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
 	   tst-adjtime tst-ctime tst-difftime tst-mktime4 tst-clock_settime \
 	   tst-itimer tst-gmtime tst-timegm tst-timespec_get
 
+tests-time64 := \
+  tst-adjtime-time64 \
+  tst-clock-time64 \
+  tst-clock2-time64 \
+  tst-clock_nanosleep-time64 \
+  tst-cpuclock1-time64 \
+  tst-ctime-time64 \
+  tst-difftime-time64 \
+  tst-gmtime-time64 \
+  tst-itimer-time64 \
+  tst-mktime4-time64 \
+  tst-timegm-time64 \
+  tst-timespec_get-time64 \
+  tst-y2039-time64
+
 include ../Rules
 
 ifeq ($(run-built-tests),yes)
diff --git a/time/tst-adjtime-time64.c b/time/tst-adjtime-time64.c
new file mode 100644
index 0000000000..097d6efc4b
--- /dev/null
+++ b/time/tst-adjtime-time64.c
@@ -0,0 +1 @@
+#include <tst-adjtime.c>
diff --git a/time/tst-clock-time64.c b/time/tst-clock-time64.c
new file mode 100644
index 0000000000..a1349678c8
--- /dev/null
+++ b/time/tst-clock-time64.c
@@ -0,0 +1 @@
+#include "tst-clock.c"
diff --git a/time/tst-clock2-time64.c b/time/tst-clock2-time64.c
new file mode 100644
index 0000000000..897f47b287
--- /dev/null
+++ b/time/tst-clock2-time64.c
@@ -0,0 +1 @@
+#include "tst-clock2.c"
diff --git a/time/tst-clock_nanosleep-time64.c b/time/tst-clock_nanosleep-time64.c
new file mode 100644
index 0000000000..c8638aa3d2
--- /dev/null
+++ b/time/tst-clock_nanosleep-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_nanosleep.c"
diff --git a/time/tst-cpuclock1-time64.c b/time/tst-cpuclock1-time64.c
new file mode 100644
index 0000000000..5a7ffa27ac
--- /dev/null
+++ b/time/tst-cpuclock1-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock1.c"
diff --git a/time/tst-ctime-time64.c b/time/tst-ctime-time64.c
new file mode 100644
index 0000000000..24a5ae98ed
--- /dev/null
+++ b/time/tst-ctime-time64.c
@@ -0,0 +1 @@
+#include "tst-ctime.c"
diff --git a/time/tst-ctime.c b/time/tst-ctime.c
index e89a906bf8..884d69bfa0 100644
--- a/time/tst-ctime.c
+++ b/time/tst-ctime.c
@@ -24,6 +24,7 @@ static int
 do_test (void)
 {
   char *str;
+  char strb[32];
   time_t t;
 
   /* Use glibc time zone extension "TZ=:" to to guarantee that UTC
@@ -36,11 +37,21 @@ do_test (void)
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
+
   /* Check if the max time value for 32 bit time_t can be converted.  */
   t = 0x7fffffff;
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
+
   /* Check if we run on port with 32 bit time_t size */
   time_t tov;
   if (__builtin_add_overflow (t, 1, &tov))
@@ -50,6 +61,11 @@ do_test (void)
   str = ctime (&tov);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&tov, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
+
   return 0;
 }
 
diff --git a/time/tst-difftime-time64.c b/time/tst-difftime-time64.c
new file mode 100644
index 0000000000..751ce6c483
--- /dev/null
+++ b/time/tst-difftime-time64.c
@@ -0,0 +1 @@
+#include "tst-difftime.c"
diff --git a/time/tst-gmtime-time64.c b/time/tst-gmtime-time64.c
new file mode 100644
index 0000000000..0df11c1913
--- /dev/null
+++ b/time/tst-gmtime-time64.c
@@ -0,0 +1 @@
+#include "tst-gmtime.c"
diff --git a/time/tst-itimer-time64.c b/time/tst-itimer-time64.c
new file mode 100644
index 0000000000..ddd2efa175
--- /dev/null
+++ b/time/tst-itimer-time64.c
@@ -0,0 +1 @@
+#include <time/tst-itimer.c>
diff --git a/time/tst-mktime4-time64.c b/time/tst-mktime4-time64.c
new file mode 100644
index 0000000000..bf5197c6f3
--- /dev/null
+++ b/time/tst-mktime4-time64.c
@@ -0,0 +1 @@
+#include "tst-mktime4.c"
diff --git a/time/tst-timegm-time64.c b/time/tst-timegm-time64.c
new file mode 100644
index 0000000000..8e3084f74e
--- /dev/null
+++ b/time/tst-timegm-time64.c
@@ -0,0 +1 @@
+#include "tst-timegm.c"
diff --git a/time/tst-timespec_get-time64.c b/time/tst-timespec_get-time64.c
new file mode 100644
index 0000000000..48f336385d
--- /dev/null
+++ b/time/tst-timespec_get-time64.c
@@ -0,0 +1 @@
+#include "tst-timespec_get.c"
diff --git a/time/tst-y2039-time64.c b/time/tst-y2039-time64.c
new file mode 100644
index 0000000000..3c8a504186
--- /dev/null
+++ b/time/tst-y2039-time64.c
@@ -0,0 +1 @@
+#include "tst-y2039.c"
diff --git a/time/tst-y2039.c b/time/tst-y2039.c
index ef024c0a77..66a22d4c2c 100644
--- a/time/tst-y2039.c
+++ b/time/tst-y2039.c
@@ -37,6 +37,16 @@ do_test (void)
 			> 0);
       puts (buf);
       TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
+
+      /* Same as before but for localtime_r.  */
+      struct tm tmd;
+      tm = localtime_r (&ouch, &tmd);
+      TEST_VERIFY_EXIT (tm == &tmd);
+
+      TEST_VERIFY_EXIT (strftime (buf, sizeof buf, "%Y-%m-%d %H:%M:%S %Z", tm)
+			> 0);
+      puts (buf);
+      TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
     }
   else
     FAIL_UNSUPPORTED ("32-bit time_t");


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [glibc/azanella/y2038] y2038: Add test coverage
@ 2021-03-04 11:32 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2021-03-04 11:32 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=874435c4ed69f135b2e01990c69c58b344a990c4

commit 874435c4ed69f135b2e01990c69c58b344a990c4
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Feb 17 15:59:34 2021 -0300

    y2038: Add test coverage
    
    A new 'tests-y2038' rule is added, which adds the required 64 bit
    time flags and included in the 'tests' rule.
    
    The current coverage is:
    
      * libc:
        - adjtime                       tst-adjtime-time64
        - adjtimex
        - clock_adjtime                 tst-clock_adjtime-time64
        - clock_getres                  tst-clock-time64, tst-cpuclock1-time64
        - clock_gettime                 tst-clock-time64, tst-clock2-time64,
                                        tst-cpuclock1-time64
        - clock_nanoslee                tst-clock_nanosleep-time64,
                                        tst-cpuclock1-time64
        - clock_settime                 tst-clock2-time64
        - ctime                         tst-ctime-time64
        - ctime_r                       tst-ctime-time64
        - difftime                      tst-difftime-time64
        - fstat                         tst-stat-time64
        - fstatat                       tst-stat-time64
        - futimens                      tst-futimens-time64
        - futimes                       tst-futimes-time64
        - futimesat                     tst-futimesat-time64
        - fts_*                         tst-fts-time64
        - getitimer                     tst-itimer-timer64
        - getrusage
        - gettimeofday                  tst-clock_nanosleep-time64
        - glob / globfree               tst-gnuglob64-time64
        - gmtime                        tst-gmtime-time64
        - gmtime_r                      tst-gmtime-time64
        - lstat                         tst-stat-time64
        - localtime                     tst-y2039-time64
        - localtime_t                   tst-y2039-time64
        - lutimes                       tst-lutimes-time64
        - mktime                        tst-mktime4-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - msgctl                        test-sysvmsg-time64
        - nanosleep                     tst-cpuclock{12}-time64,
                                        tst-mqueue8-time64, tst-clock-time64
        - nftw / ftw                    ftwtest-time64
        - ntp_adjtime
        - ntp_gettime
        - ntp_gettimex
        - ppoll                         tst-ppoll-time64
        - pselect                       tst-pselect-time64
        - recvmmsg                      tst-cancel4_2-time64
        - sched_rr_get_interval         tst-sched_rr_get_interval-time64
        - select
        - semctl                        test-sysvsem-time64
        - semtimedop                    test-sysvsem-time64
        - setitimer                     tst-mqueue2-time64, tst-itimer-timer64
        - settimeofday
        - shmctl                        test-sysvshm-time64
        - sigtimedwait
        - stat                          tst-stat-time64
        - time                          tst-mqueue{1248}-time64
        - timegm                        tst-timegm-time64
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
        - timerfd_gettime               tst-timerfd-time64
        - timerfd_settime               tst-timerfd-time64
        - timespec_get                  tst-timespec_get-time64
        - utime                         tst-utime-time64
        - utimensat                     tst-utimensat-time64
        - utimes                        tst-utimes-time64
        - wait3                         tst-wait3-time64
        - wait4                         tst-wait4-time64
    
      * libpthread:
        - cnd_timedwait                 tst-cnd-timedwait-time64
        - mtx_timedlock                 tst-mtx-timedlock-time64
        - pthread_clockjoin_np          tst-join14-time64
        - pthread_cond_clockwait        tst-cond11-time64
        - pthread_cond_timedwait        tst-abstime-time64
        - pthread_mutex_clocklock       tst-abstime-time64
        - pthread_mutex_timedlock       tst-abstime-time64
        - pthread_rwlock_clockrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_clockwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_timedjoin_np          tst-join14-time64
        - sem_clockwait                 tst-sem5-time64
        - sem_timedwait                 tst-sem5-time64
        - thrd_sleep                    tst-thrd-sleep-time64
    
      * librt:
        - aio_suspend                   tst-aio6-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
    
      * libanl:
        - gai_suspend

Diff:
---
 Makerules                                          |  23 ++++-
 io/Makefile                                        |  16 +++-
 io/ftwtest-time64.c                                |   1 +
 io/tst-fts-time64.c                                |   1 +
 io/tst-futimesat-time64.c                          |   4 +
 io/tst-futimesat.c                                 |  47 +++++++---
 io/tst-stat-time64.c                               | 102 +++++++++++++++++++++
 io/tst-utimensat-time64.c                          |   2 +
 misc/Makefile                                      |   2 +
 misc/tst-pselect-time64.c                          |   1 +
 nptl/Makefile                                      |   3 +
 nptl/tst-cancel4_2-time64.c                        |   1 +
 posix/Makefile                                     |   2 +
 posix/tst-gnuglob64-time64.c                       |   7 ++
 posix/tst-sched_rr_get_interval-time64.c           |   1 +
 posix/tst-wait3-time64.c                           |   1 +
 posix/tst-wait4-time64.c                           |   1 +
 rt/Makefile                                        |   9 ++
 rt/tst-aio6-time64.c                               |   1 +
 rt/tst-cpuclock2-time64.c                          |   1 +
 rt/tst-cpuclock2.c                                 |   9 +-
 rt/tst-mqueue1-time64.c                            |   1 +
 rt/tst-mqueue2-time64.c                            |   1 +
 rt/tst-mqueue4-time64.c                            |   1 +
 rt/tst-mqueue8-time64.c                            |   1 +
 rt/tst-timer4-time64.c                             |   1 +
 sysdeps/pthread/Makefile                           |  10 ++
 sysdeps/pthread/tst-abstime-time64.c               |   1 +
 sysdeps/pthread/tst-cnd-timedwait-time64.c         |   1 +
 sysdeps/pthread/tst-cond11-time64.c                |   1 +
 sysdeps/pthread/tst-join14-time64.c                |   1 +
 sysdeps/pthread/tst-mtx-timedlock-time64.c         |   1 +
 sysdeps/pthread/tst-rwlock14-time64.c              |   1 +
 sysdeps/pthread/tst-sem5-time64.c                  |   1 +
 sysdeps/pthread/tst-thrd-sleep-time64.c            |   1 +
 sysdeps/unix/sysv/linux/Makefile                   |   9 ++
 sysdeps/unix/sysv/linux/Versions                   |   4 +-
 sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c |   1 +
 sysdeps/unix/sysv/linux/tst-futimens-time64.c      |   2 +
 sysdeps/unix/sysv/linux/tst-futimens.c             |   8 +-
 sysdeps/unix/sysv/linux/tst-futimes-time64.c       |   2 +
 sysdeps/unix/sysv/linux/tst-lutimes-time64.c       |   2 +
 sysdeps/unix/sysv/linux/tst-ppoll-time64.c         |   1 +
 sysdeps/unix/sysv/linux/tst-timerfd-time64.c       |   1 +
 sysdeps/unix/sysv/linux/tst-utime-time64.c         |   2 +
 sysdeps/unix/sysv/linux/tst-utime.c                |   6 +-
 sysdeps/unix/sysv/linux/tst-utimes-time64.c        |   2 +
 sysdeps/unix/sysv/linux/tst-utimes.c               |   6 +-
 sysvipc/Makefile                                   |   2 +
 sysvipc/test-sysvmsg-time64.c                      |   1 +
 sysvipc/test-sysvsem-time64.c                      |   1 +
 sysvipc/test-sysvshm-time64.c                      |   1 +
 time/Makefile                                      |  15 +++
 time/tst-adjtime-time64.c                          |   1 +
 time/tst-clock-time64.c                            |   1 +
 time/tst-clock2-time64.c                           |   1 +
 time/tst-clock_nanosleep-time64.c                  |   1 +
 time/tst-cpuclock1-time64.c                        |   1 +
 time/tst-ctime-time64.c                            |   1 +
 time/tst-ctime.c                                   |  16 ++++
 time/tst-difftime-time64.c                         |   1 +
 time/tst-gmtime-time64.c                           |   1 +
 time/tst-itimer-time64.c                           |   1 +
 time/tst-mktime4-time64.c                          |   1 +
 time/tst-timegm-time64.c                           |   1 +
 time/tst-timespec_get-time64.c                     |   1 +
 time/tst-y2039-time64.c                            |   1 +
 time/tst-y2039.c                                   |  10 ++
 68 files changed, 339 insertions(+), 24 deletions(-)

diff --git a/Makerules b/Makerules
index fc5251ffad..aca5d1f4d7 100644
--- a/Makerules
+++ b/Makerules
@@ -771,7 +771,8 @@ endif
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
 	     $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
-	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs))
+	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) \
+		$(test-srcs) $(tests-time64) $(xtests-time64))
 ifeq ($(build-programs),yes)
 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
 endif
@@ -1286,6 +1287,26 @@ check: tests
 .PHONY: xcheck
 xcheck: xtests
 
+# Handle tests-time64 and xtests-time64 that should built with LFS
+# and 64-bit time support.
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(tests-time64),$(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+tests += $(foreach t,$(tests-time64),$(t))
+
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(xtests-time64),$(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+xtests += $(foreach t,$(xtests-time64),$(t))
+
 # The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
 # that almost all internal declarations from config.h, libc-symbols.h, and
 # include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
diff --git a/io/Makefile b/io/Makefile
index 6c637f7c6d..a39f0ecfc1 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -59,7 +59,7 @@ routines :=								\
 	ftw64-time64
 
 others		:= pwd
-test-srcs	:= ftwtest
+test-srcs	:= ftwtest ftwtest-time64
 tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-fcntl bug-ftw1 bug-ftw2 bug-ftw3 bug-ftw4 tst-statvfs \
 		   tst-openat tst-unlinkat tst-fstatat tst-futimesat \
@@ -72,12 +72,18 @@ tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-ftw-lnk tst-file_change_detection tst-lchmod \
 		   tst-ftw-bz26353 tst-utimensat
 
+tests-time64    := tst-fts-time64 \
+		   tst-stat-time64 \
+		   tst-futimesat-time64 \
+		   tst-utimensat-time64
+
 # Likewise for statx, but we do not need static linking here.
 tests-internal += tst-statx
 tests-static += tst-statx
 
 ifeq ($(run-built-tests),yes)
-tests-special += $(objpfx)ftwtest.out
+tests-special += $(objpfx)ftwtest.out \
+		 $(objpfx)ftwtest-time64.out
 endif
 
 include ../Rules
@@ -118,8 +124,14 @@ tst-statvfs-ARGS = $(objpfx)tst-statvfs tst-statvfs.c /tmp
 
 tst-open-tmpfile-ARGS = --test-dir=$(objpfx)
 
+CFLAGS-ftwtest-time64.c += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+
 ifeq ($(run-built-tests),yes)
 $(objpfx)ftwtest.out: ftwtest-sh $(objpfx)ftwtest
 	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
 	$(evaluate-test)
+
+$(objpfx)ftwtest-time64.out: ftwtest-sh $(objpfx)ftwtest-time64
+	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
+	$(evaluate-test)
 endif
diff --git a/io/ftwtest-time64.c b/io/ftwtest-time64.c
new file mode 100644
index 0000000000..67f1c46826
--- /dev/null
+++ b/io/ftwtest-time64.c
@@ -0,0 +1 @@
+#include "ftwtest.c"
diff --git a/io/tst-fts-time64.c b/io/tst-fts-time64.c
new file mode 100644
index 0000000000..a4a41fe1cf
--- /dev/null
+++ b/io/tst-fts-time64.c
@@ -0,0 +1 @@
+#include "tst-fts.c"
diff --git a/io/tst-futimesat-time64.c b/io/tst-futimesat-time64.c
new file mode 100644
index 0000000000..f6c0500eef
--- /dev/null
+++ b/io/tst-futimesat-time64.c
@@ -0,0 +1,4 @@
+#define struct_stat  struct stat
+#define fstat        fstat
+#define fstatat      fstatat
+#include "io/tst-futimesat.c"
diff --git a/io/tst-futimesat.c b/io/tst-futimesat.c
index af58ad06dd..c32ab2b668 100644
--- a/io/tst-futimesat.c
+++ b/io/tst-futimesat.c
@@ -1,4 +1,23 @@
+/* futimesat basic tests.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
 #include <dirent.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -7,19 +26,19 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#include <support/test-driver.h>
+#include <support/temp_file.h>
 
-static void prepare (void);
-#define PREPARE(argc, argv) prepare ()
-
-static int do_test (void);
-#define TEST_FUNCTION do_test ()
-
-#include "../test-skeleton.c"
+#ifndef struct_stat
+# define struct_stat struct stat64
+# define fstat       fstat64
+# define fstatat     fstatat64
+#endif
 
 static int dir_fd;
 
 static void
-prepare (void)
+prepare (int argc, char *argv[])
 {
   size_t test_dir_len = strlen (test_dir);
   static const char dir_name[] = "/tst-futimesat.XXXXXX";
@@ -48,7 +67,7 @@ prepare (void)
       exit (1);
     }
 }
-
+#define PREPARE prepare
 
 static int
 do_test (void)
@@ -98,8 +117,8 @@ do_test (void)
   write (fd, "hello", 5);
   puts ("file created");
 
-  struct stat64 st1;
-  if (fstat64 (fd, &st1) != 0)
+  struct_stat st1;
+  if (fstat (fd, &st1) != 0)
     {
       puts ("fstat64 failed");
       return 1;
@@ -118,8 +137,8 @@ do_test (void)
       return 1;
     }
 
-  struct stat64 st2;
-  if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0)
+  struct_stat st2;
+  if (fstatat (dir_fd, "some-file", &st2, 0) != 0)
     {
       puts ("fstatat64 failed");
       return 1;
@@ -146,3 +165,5 @@ do_test (void)
 
   return 0;
 }
+
+#include <support/test-driver.c>
diff --git a/io/tst-stat-time64.c b/io/tst-stat-time64.c
new file mode 100644
index 0000000000..c10fe1284a
--- /dev/null
+++ b/io/tst-stat-time64.c
@@ -0,0 +1,102 @@
+/* Basic test of stat with 64 bit time_t interfaces.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <support/check.h>
+#include <support/support.h>
+#include <support/temp_file.h>
+#include <support/xunistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+
+/* The idea of the test is check whether the 64 bit time_t stat implementation
+   returns the expected value for comparable fields, so it does not really
+   matter whether statx uses a fallback implementation or not.  */
+
+static void
+stat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (stat (path, st), 0);
+}
+
+static void
+lstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (lstat (path, st), 0);
+}
+
+static void
+fstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstat (fd, st), 0);
+}
+
+static void
+fstatat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstatat (fd, path, st, 0), 0);
+}
+
+typedef void (*test_t)(int, const char *path, struct stat *);
+
+static int
+do_test (void)
+{
+  char *path;
+  int fd = create_temp_file ("tst-statx-", &path);
+  TEST_VERIFY_EXIT (fd >= 0);
+  support_write_file_string (path, "abc");
+
+  struct statx stx;
+  TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0);
+
+  for (test_t *test = (test_t[]) { stat_check, lstat_check, fstat_check,
+				   fstatat_check, NULL };
+       *test != NULL; test++)
+  {
+    struct stat st;
+    (*test) (fd, path, &st);
+
+    TEST_COMPARE (stx.stx_dev_major, major (st.st_dev));
+    TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev));
+    TEST_COMPARE (stx.stx_ino, st.st_ino);
+    TEST_COMPARE (stx.stx_mode, st.st_mode);
+    TEST_COMPARE (stx.stx_nlink, st.st_nlink);
+    TEST_COMPARE (stx.stx_uid, st.st_uid);
+    TEST_COMPARE (stx.stx_gid, st.st_gid);
+    TEST_COMPARE (stx.stx_rdev_major, major (st.st_rdev));
+    TEST_COMPARE (stx.stx_rdev_minor, minor (st.st_rdev));
+    TEST_COMPARE (stx.stx_blksize, st.st_blksize);
+    TEST_COMPARE (stx.stx_blocks, st.st_blocks);
+
+    TEST_COMPARE (stx.stx_ctime.tv_sec, st.st_ctim.tv_sec);
+    TEST_COMPARE (stx.stx_ctime.tv_nsec, st.st_ctim.tv_nsec);
+    TEST_COMPARE (stx.stx_mtime.tv_sec, st.st_mtim.tv_sec);
+    TEST_COMPARE (stx.stx_mtime.tv_nsec, st.st_mtim.tv_nsec);
+  }
+
+  xclose (fd);
+  free (path);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/io/tst-utimensat-time64.c b/io/tst-utimensat-time64.c
new file mode 100644
index 0000000000..7ac7d8df1d
--- /dev/null
+++ b/io/tst-utimensat-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimensat.c"
diff --git a/misc/Makefile b/misc/Makefile
index cfc15355d6..a8363d4b76 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -90,6 +90,8 @@ tests := tst-dirname tst-tsearch tst-fdset tst-mntent tst-hsearch \
 	 tst-ldbl-warn tst-ldbl-error tst-dbl-efgcvt tst-ldbl-efgcvt \
 	 tst-mntent-autofs tst-syscalls tst-mntent-escape
 
+tests-time64 := tst-pselect-time64
+
 # Tests which need libdl.
 ifeq (yes,$(build-shared))
 tests += tst-gethostid
diff --git a/misc/tst-pselect-time64.c b/misc/tst-pselect-time64.c
new file mode 100644
index 0000000000..15a1e49292
--- /dev/null
+++ b/misc/tst-pselect-time64.c
@@ -0,0 +1 @@
+#include "tst-pselect.c"
diff --git a/nptl/Makefile b/nptl/Makefile
index 5f85dd7854..0a0e8d360c 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -380,6 +380,9 @@ xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
 	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10 tst-setgroups \
 	tst-mutexpp5 tst-mutexpp9
 
+tests-time64 := \
+  tst-cancel4_2-time64
+
 # This test can run into task limits because of a linux kernel bug
 # and then cause the make process to fail too, see bug 24537.
 xtests += tst-eintr1
diff --git a/nptl/tst-cancel4_2-time64.c b/nptl/tst-cancel4_2-time64.c
new file mode 100644
index 0000000000..4ac086a312
--- /dev/null
+++ b/nptl/tst-cancel4_2-time64.c
@@ -0,0 +1 @@
+#include "tst-cancel4_2.c"
diff --git a/posix/Makefile b/posix/Makefile
index aba66efde8..e246ff1d14 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -109,7 +109,9 @@ tests-internal	:= bug-regex5 bug-regex20 bug-regex33 \
 		   tst-rfc3484 tst-rfc3484-2 tst-rfc3484-3 \
 		   tst-glob_lstat_compat tst-spawn4-compat
 tests-container := bug-ga2
+tests-time64	:= tst-wait4-time64 tst-wait3-time64 tst-gnuglob64-time64
 xtests		:= tst-getaddrinfo4 tst-getaddrinfo5 tst-sched_rr_get_interval
+xtests-time64	:= tst-sched_rr_get_interval-time64
 ifeq (yes,$(build-shared))
 test-srcs	:= globtest
 tests           += wordexp-test tst-exec tst-spawn tst-spawn2 tst-spawn3
diff --git a/posix/tst-gnuglob64-time64.c b/posix/tst-gnuglob64-time64.c
new file mode 100644
index 0000000000..00922bcdc6
--- /dev/null
+++ b/posix/tst-gnuglob64-time64.c
@@ -0,0 +1,7 @@
+#define GLOB_FUNC glob
+#define GLOB_TYPE glob_t
+#define GLOBFREE_FUNC globfree
+#define DIRENT_STRUCT dirent
+#define STAT_STRUCT stat
+
+#include "tst-gnuglob-skeleton.c"
diff --git a/posix/tst-sched_rr_get_interval-time64.c b/posix/tst-sched_rr_get_interval-time64.c
new file mode 100644
index 0000000000..f4e66d2939
--- /dev/null
+++ b/posix/tst-sched_rr_get_interval-time64.c
@@ -0,0 +1 @@
+#include "tst-sched_rr_get_interval.c"
diff --git a/posix/tst-wait3-time64.c b/posix/tst-wait3-time64.c
new file mode 100644
index 0000000000..2837bc7a9e
--- /dev/null
+++ b/posix/tst-wait3-time64.c
@@ -0,0 +1 @@
+#include "tst-wait3.c"
diff --git a/posix/tst-wait4-time64.c b/posix/tst-wait4-time64.c
new file mode 100644
index 0000000000..12543b270f
--- /dev/null
+++ b/posix/tst-wait4-time64.c
@@ -0,0 +1 @@
+#include "tst-wait4.c"
diff --git a/rt/Makefile b/rt/Makefile
index 7b374f2073..3ce98297f9 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -49,6 +49,15 @@ tests := tst-shm tst-timer tst-timer2 \
 	 tst-shm-cancel
 tests-internal := tst-timer-sigmask
 
+tests-time64 := \
+  tst-aio6-time64 \
+  tst-cpuclock2-time64 \
+  tst-mqueue1-time64 \
+  tst-mqueue2-time64 \
+  tst-mqueue4-time64 \
+  tst-mqueue8-time64 \
+  tst-timer4-time64
+
 extra-libs := librt
 extra-libs-others := $(extra-libs)
 
diff --git a/rt/tst-aio6-time64.c b/rt/tst-aio6-time64.c
new file mode 100644
index 0000000000..a386a577ec
--- /dev/null
+++ b/rt/tst-aio6-time64.c
@@ -0,0 +1 @@
+#include "tst-aio6.c"
diff --git a/rt/tst-cpuclock2-time64.c b/rt/tst-cpuclock2-time64.c
new file mode 100644
index 0000000000..05775522bb
--- /dev/null
+++ b/rt/tst-cpuclock2-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock2.c"
diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c
index c1c7ed2ad8..eebc3609d0 100644
--- a/rt/tst-cpuclock2.c
+++ b/rt/tst-cpuclock2.c
@@ -21,7 +21,11 @@
 
 #if (_POSIX_THREADS - 0) <= 0
 
-# define TEST_FUNCTION 0
+static int
+do_test ()
+{
+  return 0;
+}
 
 #else
 
@@ -330,7 +334,6 @@ do_test (void)
 
   return result;
 }
-# define TEST_FUNCTION do_test ()
 #endif
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/rt/tst-mqueue1-time64.c b/rt/tst-mqueue1-time64.c
new file mode 100644
index 0000000000..9c600a9a97
--- /dev/null
+++ b/rt/tst-mqueue1-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue1.c"
diff --git a/rt/tst-mqueue2-time64.c b/rt/tst-mqueue2-time64.c
new file mode 100644
index 0000000000..9d49f0b196
--- /dev/null
+++ b/rt/tst-mqueue2-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue2.c"
diff --git a/rt/tst-mqueue4-time64.c b/rt/tst-mqueue4-time64.c
new file mode 100644
index 0000000000..c23a228dc4
--- /dev/null
+++ b/rt/tst-mqueue4-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue4.c"
diff --git a/rt/tst-mqueue8-time64.c b/rt/tst-mqueue8-time64.c
new file mode 100644
index 0000000000..972637f7f5
--- /dev/null
+++ b/rt/tst-mqueue8-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue8.c"
diff --git a/rt/tst-timer4-time64.c b/rt/tst-timer4-time64.c
new file mode 100644
index 0000000000..e47a593f10
--- /dev/null
+++ b/rt/tst-timer4-time64.c
@@ -0,0 +1 @@
+#include "tst-timer4.c"
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index eeb64f9fb0..d4bfe2aee5 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -109,6 +109,16 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
 	 tst-unwind-thread \
 	 tst-pt-vfork1 tst-pt-vfork2 tst-vfork1x tst-vfork2x \
 
+tests-time64 := \
+  tst-abstime-time64 \
+  tst-cnd-timedwait-time64 \
+  tst-cond11-time64 \
+  tst-join14-time64 \
+  tst-mtx-timedlock-time64 \
+  tst-rwlock14-time64 \
+  tst-sem5-time64 \
+  tst-thrd-sleep-time64 \
+
 
 # Files which must not be linked with libpthread.
 tests-nolibpthread = tst-unload
diff --git a/sysdeps/pthread/tst-abstime-time64.c b/sysdeps/pthread/tst-abstime-time64.c
new file mode 100644
index 0000000000..2fc77cb365
--- /dev/null
+++ b/sysdeps/pthread/tst-abstime-time64.c
@@ -0,0 +1 @@
+#include "tst-abstime.c"
diff --git a/sysdeps/pthread/tst-cnd-timedwait-time64.c b/sysdeps/pthread/tst-cnd-timedwait-time64.c
new file mode 100644
index 0000000000..9b2abfd277
--- /dev/null
+++ b/sysdeps/pthread/tst-cnd-timedwait-time64.c
@@ -0,0 +1 @@
+#include "tst-cnd-timedwait.c"
diff --git a/sysdeps/pthread/tst-cond11-time64.c b/sysdeps/pthread/tst-cond11-time64.c
new file mode 100644
index 0000000000..9bccb8ec8b
--- /dev/null
+++ b/sysdeps/pthread/tst-cond11-time64.c
@@ -0,0 +1 @@
+#include "tst-cond11.c"
diff --git a/sysdeps/pthread/tst-join14-time64.c b/sysdeps/pthread/tst-join14-time64.c
new file mode 100644
index 0000000000..bed784ee24
--- /dev/null
+++ b/sysdeps/pthread/tst-join14-time64.c
@@ -0,0 +1 @@
+#include "tst-join14.c"
diff --git a/sysdeps/pthread/tst-mtx-timedlock-time64.c b/sysdeps/pthread/tst-mtx-timedlock-time64.c
new file mode 100644
index 0000000000..b3393c99ef
--- /dev/null
+++ b/sysdeps/pthread/tst-mtx-timedlock-time64.c
@@ -0,0 +1 @@
+#include "tst-mtx-timedlock.c"
diff --git a/sysdeps/pthread/tst-rwlock14-time64.c b/sysdeps/pthread/tst-rwlock14-time64.c
new file mode 100644
index 0000000000..ae9b1912cf
--- /dev/null
+++ b/sysdeps/pthread/tst-rwlock14-time64.c
@@ -0,0 +1 @@
+#include "tst-rwlock14.c"
diff --git a/sysdeps/pthread/tst-sem5-time64.c b/sysdeps/pthread/tst-sem5-time64.c
new file mode 100644
index 0000000000..89c2a14f94
--- /dev/null
+++ b/sysdeps/pthread/tst-sem5-time64.c
@@ -0,0 +1 @@
+#include "tst-sem5.c"
diff --git a/sysdeps/pthread/tst-thrd-sleep-time64.c b/sysdeps/pthread/tst-thrd-sleep-time64.c
new file mode 100644
index 0000000000..02837bd19f
--- /dev/null
+++ b/sysdeps/pthread/tst-thrd-sleep-time64.c
@@ -0,0 +1 @@
+#include "tst-thrd-sleep.c"
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index c3ce642b62..9e88ebb9d2 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -115,6 +115,15 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
 	 tst-clock_adjtime tst-futimes tst-lutimes
 
 tests-internal += tst-ofdlocks-compat tst-sigcontext-get_pc
+tests-time64 += \
+  tst-clock_adjtime-time64 \
+  tst-futimes-time64\
+  tst-futimens-time64 \
+  tst-lutimes-time64 \
+  tst-ppoll-time64 \
+  tst-utime-time64 \
+  tst-utimes-time64 \
+  tst-timerfd-time64
 
 CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
 
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index b53391f613..982b94e625 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -237,7 +237,9 @@ libc {
     __timegm64;
     __timespec_get64;
     __utimensat64;
-     __utimes64;
+    __utimes64;
+    __localtime64;
+    __localtime64_r;
     # misc
     __ntp_gettime64;
     __ntp_gettimex64;
diff --git a/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c b/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
new file mode 100644
index 0000000000..9691e81229
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_adjtime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-futimens-time64.c b/sysdeps/unix/sysv/linux/tst-futimens-time64.c
new file mode 100644
index 0000000000..88fcb38489
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-futimens-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimens.c"
diff --git a/sysdeps/unix/sysv/linux/tst-futimens.c b/sysdeps/unix/sysv/linux/tst-futimens.c
index 8f48cfee63..b5b240abf1 100644
--- a/sysdeps/unix/sysv/linux/tst-futimens.c
+++ b/sysdeps/unix/sysv/linux/tst-futimens.c
@@ -24,10 +24,14 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 
 /* struct timespec array with Y2038 threshold minus 2 and 1 seconds.  */
-const struct timespec t1[2] = { { 0x7FFFFFFE, 0 },  { 0x7FFFFFFF, 0 } };
+const static struct timespec t1[2] = { { 0x7FFFFFFE, 0 },  { 0x7FFFFFFF, 0 } };
 
 /* struct timespec array with Y2038 threshold plus 1 and 2 seconds.  */
 const struct timespec t2[2] = { { 0x80000001ULL, 0 },  { 0x80000002ULL, 0 } };
@@ -46,7 +50,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_futimens_helper (const struct timespec *ts)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
diff --git a/sysdeps/unix/sysv/linux/tst-futimes-time64.c b/sysdeps/unix/sysv/linux/tst-futimes-time64.c
new file mode 100644
index 0000000000..d489c265d1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-futimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-lutimes-time64.c b/sysdeps/unix/sysv/linux/tst-lutimes-time64.c
new file mode 100644
index 0000000000..06caec0a91
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-lutimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-lutimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ppoll-time64.c b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
new file mode 100644
index 0000000000..96ee2faee3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
@@ -0,0 +1 @@
+#include "tst-ppoll.c"
diff --git a/sysdeps/unix/sysv/linux/tst-timerfd-time64.c b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
new file mode 100644
index 0000000000..bb17f48139
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
@@ -0,0 +1 @@
+#include "tst-timerfd.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utime-time64.c b/sysdeps/unix/sysv/linux/tst-utime-time64.c
new file mode 100644
index 0000000000..eb62f59126
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-utime-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utime.c b/sysdeps/unix/sysv/linux/tst-utime.c
index 6735421657..d413f130e8 100644
--- a/sysdeps/unix/sysv/linux/tst-utime.c
+++ b/sysdeps/unix/sysv/linux/tst-utime.c
@@ -26,6 +26,10 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 char *testfile;
 
@@ -49,7 +53,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_utime_helper (const struct utimbuf *ut)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
diff --git a/sysdeps/unix/sysv/linux/tst-utimes-time64.c b/sysdeps/unix/sysv/linux/tst-utimes-time64.c
new file mode 100644
index 0000000000..234ec02541
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-utimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utimes.c b/sysdeps/unix/sysv/linux/tst-utimes.c
index 8c7b006a22..c521c89dfa 100644
--- a/sysdeps/unix/sysv/linux/tst-utimes.c
+++ b/sysdeps/unix/sysv/linux/tst-utimes.c
@@ -25,6 +25,10 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 char *testfile;
 
@@ -50,7 +54,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_utime_helper (const struct timeval *tv)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
diff --git a/sysvipc/Makefile b/sysvipc/Makefile
index a534791928..86911803b5 100644
--- a/sysvipc/Makefile
+++ b/sysvipc/Makefile
@@ -32,6 +32,8 @@ routines := ftok \
 
 tests    := test-sysvmsg test-sysvsem test-sysvshm
 
+tests-time64 := test-sysvmsg-time64 test-sysvsem-time64 test-sysvshm-time64
+
 include ../Rules
 
 CFLAGS-msgrcv.c += -fexceptions -fasynchronous-unwind-tables
diff --git a/sysvipc/test-sysvmsg-time64.c b/sysvipc/test-sysvmsg-time64.c
new file mode 100644
index 0000000000..c23e0c337e
--- /dev/null
+++ b/sysvipc/test-sysvmsg-time64.c
@@ -0,0 +1 @@
+#include "test-sysvmsg.c"
diff --git a/sysvipc/test-sysvsem-time64.c b/sysvipc/test-sysvsem-time64.c
new file mode 100644
index 0000000000..05c95068cd
--- /dev/null
+++ b/sysvipc/test-sysvsem-time64.c
@@ -0,0 +1 @@
+#include "test-sysvsem.c"
diff --git a/sysvipc/test-sysvshm-time64.c b/sysvipc/test-sysvshm-time64.c
new file mode 100644
index 0000000000..8e2963f563
--- /dev/null
+++ b/sysvipc/test-sysvshm-time64.c
@@ -0,0 +1 @@
+#include "test-sysvshm.c"
diff --git a/time/Makefile b/time/Makefile
index 29208f35c0..414721ecc5 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -51,6 +51,21 @@ tests	:= test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
 	   tst-adjtime tst-ctime tst-difftime tst-mktime4 tst-clock_settime \
 	   tst-itimer tst-gmtime tst-timegm tst-timespec_get
 
+tests-time64 := \
+  tst-adjtime-time64 \
+  tst-clock-time64 \
+  tst-clock2-time64 \
+  tst-clock_nanosleep-time64 \
+  tst-cpuclock1-time64 \
+  tst-ctime-time64 \
+  tst-difftime-time64 \
+  tst-gmtime-time64 \
+  tst-itimer-time64 \
+  tst-mktime4-time64 \
+  tst-timegm-time64 \
+  tst-timespec_get-time64 \
+  tst-y2039-time64
+
 include ../Rules
 
 ifeq ($(run-built-tests),yes)
diff --git a/time/tst-adjtime-time64.c b/time/tst-adjtime-time64.c
new file mode 100644
index 0000000000..097d6efc4b
--- /dev/null
+++ b/time/tst-adjtime-time64.c
@@ -0,0 +1 @@
+#include <tst-adjtime.c>
diff --git a/time/tst-clock-time64.c b/time/tst-clock-time64.c
new file mode 100644
index 0000000000..a1349678c8
--- /dev/null
+++ b/time/tst-clock-time64.c
@@ -0,0 +1 @@
+#include "tst-clock.c"
diff --git a/time/tst-clock2-time64.c b/time/tst-clock2-time64.c
new file mode 100644
index 0000000000..897f47b287
--- /dev/null
+++ b/time/tst-clock2-time64.c
@@ -0,0 +1 @@
+#include "tst-clock2.c"
diff --git a/time/tst-clock_nanosleep-time64.c b/time/tst-clock_nanosleep-time64.c
new file mode 100644
index 0000000000..c8638aa3d2
--- /dev/null
+++ b/time/tst-clock_nanosleep-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_nanosleep.c"
diff --git a/time/tst-cpuclock1-time64.c b/time/tst-cpuclock1-time64.c
new file mode 100644
index 0000000000..5a7ffa27ac
--- /dev/null
+++ b/time/tst-cpuclock1-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock1.c"
diff --git a/time/tst-ctime-time64.c b/time/tst-ctime-time64.c
new file mode 100644
index 0000000000..24a5ae98ed
--- /dev/null
+++ b/time/tst-ctime-time64.c
@@ -0,0 +1 @@
+#include "tst-ctime.c"
diff --git a/time/tst-ctime.c b/time/tst-ctime.c
index e89a906bf8..884d69bfa0 100644
--- a/time/tst-ctime.c
+++ b/time/tst-ctime.c
@@ -24,6 +24,7 @@ static int
 do_test (void)
 {
   char *str;
+  char strb[32];
   time_t t;
 
   /* Use glibc time zone extension "TZ=:" to to guarantee that UTC
@@ -36,11 +37,21 @@ do_test (void)
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
+
   /* Check if the max time value for 32 bit time_t can be converted.  */
   t = 0x7fffffff;
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
+
   /* Check if we run on port with 32 bit time_t size */
   time_t tov;
   if (__builtin_add_overflow (t, 1, &tov))
@@ -50,6 +61,11 @@ do_test (void)
   str = ctime (&tov);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&tov, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
+
   return 0;
 }
 
diff --git a/time/tst-difftime-time64.c b/time/tst-difftime-time64.c
new file mode 100644
index 0000000000..751ce6c483
--- /dev/null
+++ b/time/tst-difftime-time64.c
@@ -0,0 +1 @@
+#include "tst-difftime.c"
diff --git a/time/tst-gmtime-time64.c b/time/tst-gmtime-time64.c
new file mode 100644
index 0000000000..0df11c1913
--- /dev/null
+++ b/time/tst-gmtime-time64.c
@@ -0,0 +1 @@
+#include "tst-gmtime.c"
diff --git a/time/tst-itimer-time64.c b/time/tst-itimer-time64.c
new file mode 100644
index 0000000000..ddd2efa175
--- /dev/null
+++ b/time/tst-itimer-time64.c
@@ -0,0 +1 @@
+#include <time/tst-itimer.c>
diff --git a/time/tst-mktime4-time64.c b/time/tst-mktime4-time64.c
new file mode 100644
index 0000000000..bf5197c6f3
--- /dev/null
+++ b/time/tst-mktime4-time64.c
@@ -0,0 +1 @@
+#include "tst-mktime4.c"
diff --git a/time/tst-timegm-time64.c b/time/tst-timegm-time64.c
new file mode 100644
index 0000000000..8e3084f74e
--- /dev/null
+++ b/time/tst-timegm-time64.c
@@ -0,0 +1 @@
+#include "tst-timegm.c"
diff --git a/time/tst-timespec_get-time64.c b/time/tst-timespec_get-time64.c
new file mode 100644
index 0000000000..48f336385d
--- /dev/null
+++ b/time/tst-timespec_get-time64.c
@@ -0,0 +1 @@
+#include "tst-timespec_get.c"
diff --git a/time/tst-y2039-time64.c b/time/tst-y2039-time64.c
new file mode 100644
index 0000000000..3c8a504186
--- /dev/null
+++ b/time/tst-y2039-time64.c
@@ -0,0 +1 @@
+#include "tst-y2039.c"
diff --git a/time/tst-y2039.c b/time/tst-y2039.c
index ef024c0a77..66a22d4c2c 100644
--- a/time/tst-y2039.c
+++ b/time/tst-y2039.c
@@ -37,6 +37,16 @@ do_test (void)
 			> 0);
       puts (buf);
       TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
+
+      /* Same as before but for localtime_r.  */
+      struct tm tmd;
+      tm = localtime_r (&ouch, &tmd);
+      TEST_VERIFY_EXIT (tm == &tmd);
+
+      TEST_VERIFY_EXIT (strftime (buf, sizeof buf, "%Y-%m-%d %H:%M:%S %Z", tm)
+			> 0);
+      puts (buf);
+      TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
     }
   else
     FAIL_UNSUPPORTED ("32-bit time_t");


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [glibc/azanella/y2038] y2038: Add test coverage
@ 2021-03-02 12:34 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2021-03-02 12:34 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=16e6753b0047a3ca78545429f4c246c71f4d1870

commit 16e6753b0047a3ca78545429f4c246c71f4d1870
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Feb 17 15:59:34 2021 -0300

    y2038: Add test coverage
    
    A new 'tests-y2038' rule is added, which adds the required 64 bit
    time flags and included in the 'tests' rule.
    
    The current coverage is:
    
      * libc:
        - adjtime                       tst-adjtime-time64
        - adjtimex
        - clock_adjtime                 tst-clock_adjtime-time64
        - clock_getres                  tst-clock-time64, tst-cpuclock1-time64
        - clock_gettime                 tst-clock-time64, tst-clock2-time64,
                                        tst-cpuclock1-time64
        - clock_nanoslee                tst-clock_nanosleep-time64,
                                        tst-cpuclock1-time64
        - clock_settime                 tst-clock2-time64
        - ctime                         tst-ctime-time64
        - ctime_r                       tst-ctime-time64
        - difftime                      tst-difftime-time64
        - fstat                         tst-stat-time64
        - fstatat                       tst-stat-time64
        - futimens                      tst-futimens-time64
        - futimes                       tst-futimes-time64
        - futimesat                     tst-futimesat-time64
        - getitimer                     tst-itimer-timer64
        - getrusage
        - gettimeofday                  tst-clock_nanosleep-time64
        - gmtime                        tst-gmtime-time64
        - gmtime_r                      tst-gmtime-time64
        - lstat                         tst-stat-time64
        - localtime                     tst-y2039-time64
        - localtime_t                   tst-y2039-time64
        - lutimes                       tst-lutimes-time64
        - mktime                        tst-mktime4-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - msgctl                        test-sysvmsg-time64
        - nanosleep                     tst-cpuclock{12}-time64,
                                        tst-mqueue8-time64, tst-clock-time64
        - ntp_adjtime
        - ntp_gettime
        - ntp_gettimex
        - ppoll                         tst-ppoll-time64
        - pselect                       tst-pselect-time64
        - recvmmsg                      tst-cancel4_2-time64
        - sched_rr_get_interval         tst-sched_rr_get_interval-time64
        - select
        - semctl                        test-sysvsem-time64
        - semtimedop                    test-sysvsem-time64
        - setitimer                     tst-mqueue2-time64, tst-itimer-timer64
        - settimeofday
        - shmctl                        test-sysvshm-time64
        - sigtimedwait
        - stat                          tst-stat-time64
        - time                          tst-mqueue{1248}-time64
        - timegm                        tst-timegm-time64
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
        - timerfd_gettime               tst-timerfd-time64
        - timerfd_settime               tst-timerfd-time64
        - timespec_get                  tst-timespec_get-time64
        - utime                         tst-utime-time64
        - utimensat                     tst-utimensat-time64
        - utimes                        tst-utimes-time64
        - wait3                         tst-wait3-time64
        - wait4                         tst-wait4-time64
    
      * libpthread:
        - cnd_timedwait                 tst-cnd-timedwait-time64
        - mtx_timedlock                 tst-mtx-timedlock-time64
        - pthread_clockjoin_np          tst-join14-time64
        - pthread_cond_clockwait        tst-cond11-time64
        - pthread_cond_timedwait        tst-abstime-time64
        - pthread_mutex_clocklock       tst-abstime-time64
        - pthread_mutex_timedlock       tst-abstime-time64
        - pthread_rwlock_clockrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_clockwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_timedjoin_np          tst-join14-time64
        - sem_clockwait                 tst-sem5-time64
        - sem_timedwait                 tst-sem5-time64
        - thrd_sleep                    tst-thrd-sleep-time64
    
      * librt:
        - aio_suspend                   tst-aio6-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
    
      * libanl:
        - gai_suspend

Diff:
---
 Makerules                                          |  23 ++++-
 io/Makefile                                        |   4 +
 io/tst-futimesat-time64.c                          |   4 +
 io/tst-futimesat.c                                 |  47 +++++++---
 io/tst-stat-time64.c                               | 102 +++++++++++++++++++++
 io/tst-utimensat-time64.c                          |   2 +
 misc/Makefile                                      |   2 +
 misc/tst-pselect-time64.c                          |   1 +
 nptl/Makefile                                      |   3 +
 nptl/tst-cancel4_2-time64.c                        |   1 +
 posix/Makefile                                     |   2 +
 posix/tst-sched_rr_get_interval-time64.c           |   1 +
 posix/tst-wait3-time64.c                           |   1 +
 posix/tst-wait4-time64.c                           |   1 +
 rt/Makefile                                        |   9 ++
 rt/tst-aio6-time64.c                               |   1 +
 rt/tst-cpuclock2-time64.c                          |   1 +
 rt/tst-cpuclock2.c                                 |   9 +-
 rt/tst-mqueue1-time64.c                            |   1 +
 rt/tst-mqueue2-time64.c                            |   1 +
 rt/tst-mqueue4-time64.c                            |   1 +
 rt/tst-mqueue8-time64.c                            |   1 +
 rt/tst-timer4-time64.c                             |   1 +
 sysdeps/pthread/Makefile                           |  10 ++
 sysdeps/pthread/tst-abstime-time64.c               |   1 +
 sysdeps/pthread/tst-cnd-timedwait-time64.c         |   1 +
 sysdeps/pthread/tst-cond11-time64.c                |   1 +
 sysdeps/pthread/tst-join14-time64.c                |   1 +
 sysdeps/pthread/tst-mtx-timedlock-time64.c         |   1 +
 sysdeps/pthread/tst-rwlock14-time64.c              |   1 +
 sysdeps/pthread/tst-sem5-time64.c                  |   1 +
 sysdeps/pthread/tst-thrd-sleep-time64.c            |   1 +
 sysdeps/unix/sysv/linux/Makefile                   |   9 ++
 sysdeps/unix/sysv/linux/Versions                   |   4 +-
 sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c |   1 +
 sysdeps/unix/sysv/linux/tst-futimens-time64.c      |   2 +
 sysdeps/unix/sysv/linux/tst-futimens.c             |  10 +-
 sysdeps/unix/sysv/linux/tst-futimes-time64.c       |   2 +
 sysdeps/unix/sysv/linux/tst-lutimes-time64.c       |   2 +
 sysdeps/unix/sysv/linux/tst-ppoll-time64.c         |   1 +
 sysdeps/unix/sysv/linux/tst-timerfd-time64.c       |   1 +
 sysdeps/unix/sysv/linux/tst-utime-time64.c         |   2 +
 sysdeps/unix/sysv/linux/tst-utime.c                |   6 +-
 sysdeps/unix/sysv/linux/tst-utimes-time64.c        |   2 +
 sysdeps/unix/sysv/linux/tst-utimes.c               |   6 +-
 sysvipc/Makefile                                   |   2 +
 sysvipc/test-sysvmsg-time64.c                      |   1 +
 sysvipc/test-sysvsem-time64.c                      |   1 +
 sysvipc/test-sysvshm-time64.c                      |   1 +
 time/Makefile                                      |  15 +++
 time/tst-adjtime-time64.c                          |   1 +
 time/tst-clock-time64.c                            |   1 +
 time/tst-clock2-time64.c                           |   1 +
 time/tst-clock_nanosleep-time64.c                  |   1 +
 time/tst-cpuclock1-time64.c                        |   1 +
 time/tst-ctime-time64.c                            |   1 +
 time/tst-ctime.c                                   |  16 ++++
 time/tst-difftime-time64.c                         |   1 +
 time/tst-gmtime-time64.c                           |   1 +
 time/tst-itimer-time64.c                           |   1 +
 time/tst-mktime4-time64.c                          |   1 +
 time/tst-timegm-time64.c                           |   1 +
 time/tst-timespec_get-time64.c                     |   1 +
 time/tst-y2039-time64.c                            |   1 +
 time/tst-y2039.c                                   |  10 ++
 65 files changed, 321 insertions(+), 23 deletions(-)

diff --git a/Makerules b/Makerules
index fc5251ffad..aca5d1f4d7 100644
--- a/Makerules
+++ b/Makerules
@@ -771,7 +771,8 @@ endif
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
 	     $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
-	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs))
+	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) \
+		$(test-srcs) $(tests-time64) $(xtests-time64))
 ifeq ($(build-programs),yes)
 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
 endif
@@ -1286,6 +1287,26 @@ check: tests
 .PHONY: xcheck
 xcheck: xtests
 
+# Handle tests-time64 and xtests-time64 that should built with LFS
+# and 64-bit time support.
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(tests-time64),$(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+tests += $(foreach t,$(tests-time64),$(t))
+
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(xtests-time64),$(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+xtests += $(foreach t,$(xtests-time64),$(t))
+
 # The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
 # that almost all internal declarations from config.h, libc-symbols.h, and
 # include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
diff --git a/io/Makefile b/io/Makefile
index 59d36e8782..c6c595d5a3 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -70,6 +70,10 @@ tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-ftw-lnk tst-file_change_detection tst-lchmod \
 		   tst-ftw-bz26353 tst-utimensat
 
+tests-time64    := tst-stat-time64 \
+		   tst-futimesat-time64 \
+		   tst-utimensat-time64
+
 # Likewise for statx, but we do not need static linking here.
 tests-internal += tst-statx
 tests-static += tst-statx
diff --git a/io/tst-futimesat-time64.c b/io/tst-futimesat-time64.c
new file mode 100644
index 0000000000..f6c0500eef
--- /dev/null
+++ b/io/tst-futimesat-time64.c
@@ -0,0 +1,4 @@
+#define struct_stat  struct stat
+#define fstat        fstat
+#define fstatat      fstatat
+#include "io/tst-futimesat.c"
diff --git a/io/tst-futimesat.c b/io/tst-futimesat.c
index af58ad06dd..c32ab2b668 100644
--- a/io/tst-futimesat.c
+++ b/io/tst-futimesat.c
@@ -1,4 +1,23 @@
+/* futimesat basic tests.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
 #include <dirent.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -7,19 +26,19 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#include <support/test-driver.h>
+#include <support/temp_file.h>
 
-static void prepare (void);
-#define PREPARE(argc, argv) prepare ()
-
-static int do_test (void);
-#define TEST_FUNCTION do_test ()
-
-#include "../test-skeleton.c"
+#ifndef struct_stat
+# define struct_stat struct stat64
+# define fstat       fstat64
+# define fstatat     fstatat64
+#endif
 
 static int dir_fd;
 
 static void
-prepare (void)
+prepare (int argc, char *argv[])
 {
   size_t test_dir_len = strlen (test_dir);
   static const char dir_name[] = "/tst-futimesat.XXXXXX";
@@ -48,7 +67,7 @@ prepare (void)
       exit (1);
     }
 }
-
+#define PREPARE prepare
 
 static int
 do_test (void)
@@ -98,8 +117,8 @@ do_test (void)
   write (fd, "hello", 5);
   puts ("file created");
 
-  struct stat64 st1;
-  if (fstat64 (fd, &st1) != 0)
+  struct_stat st1;
+  if (fstat (fd, &st1) != 0)
     {
       puts ("fstat64 failed");
       return 1;
@@ -118,8 +137,8 @@ do_test (void)
       return 1;
     }
 
-  struct stat64 st2;
-  if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0)
+  struct_stat st2;
+  if (fstatat (dir_fd, "some-file", &st2, 0) != 0)
     {
       puts ("fstatat64 failed");
       return 1;
@@ -146,3 +165,5 @@ do_test (void)
 
   return 0;
 }
+
+#include <support/test-driver.c>
diff --git a/io/tst-stat-time64.c b/io/tst-stat-time64.c
new file mode 100644
index 0000000000..c10fe1284a
--- /dev/null
+++ b/io/tst-stat-time64.c
@@ -0,0 +1,102 @@
+/* Basic test of stat with 64 bit time_t interfaces.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <support/check.h>
+#include <support/support.h>
+#include <support/temp_file.h>
+#include <support/xunistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+
+/* The idea of the test is check whether the 64 bit time_t stat implementation
+   returns the expected value for comparable fields, so it does not really
+   matter whether statx uses a fallback implementation or not.  */
+
+static void
+stat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (stat (path, st), 0);
+}
+
+static void
+lstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (lstat (path, st), 0);
+}
+
+static void
+fstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstat (fd, st), 0);
+}
+
+static void
+fstatat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstatat (fd, path, st, 0), 0);
+}
+
+typedef void (*test_t)(int, const char *path, struct stat *);
+
+static int
+do_test (void)
+{
+  char *path;
+  int fd = create_temp_file ("tst-statx-", &path);
+  TEST_VERIFY_EXIT (fd >= 0);
+  support_write_file_string (path, "abc");
+
+  struct statx stx;
+  TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0);
+
+  for (test_t *test = (test_t[]) { stat_check, lstat_check, fstat_check,
+				   fstatat_check, NULL };
+       *test != NULL; test++)
+  {
+    struct stat st;
+    (*test) (fd, path, &st);
+
+    TEST_COMPARE (stx.stx_dev_major, major (st.st_dev));
+    TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev));
+    TEST_COMPARE (stx.stx_ino, st.st_ino);
+    TEST_COMPARE (stx.stx_mode, st.st_mode);
+    TEST_COMPARE (stx.stx_nlink, st.st_nlink);
+    TEST_COMPARE (stx.stx_uid, st.st_uid);
+    TEST_COMPARE (stx.stx_gid, st.st_gid);
+    TEST_COMPARE (stx.stx_rdev_major, major (st.st_rdev));
+    TEST_COMPARE (stx.stx_rdev_minor, minor (st.st_rdev));
+    TEST_COMPARE (stx.stx_blksize, st.st_blksize);
+    TEST_COMPARE (stx.stx_blocks, st.st_blocks);
+
+    TEST_COMPARE (stx.stx_ctime.tv_sec, st.st_ctim.tv_sec);
+    TEST_COMPARE (stx.stx_ctime.tv_nsec, st.st_ctim.tv_nsec);
+    TEST_COMPARE (stx.stx_mtime.tv_sec, st.st_mtim.tv_sec);
+    TEST_COMPARE (stx.stx_mtime.tv_nsec, st.st_mtim.tv_nsec);
+  }
+
+  xclose (fd);
+  free (path);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/io/tst-utimensat-time64.c b/io/tst-utimensat-time64.c
new file mode 100644
index 0000000000..7ac7d8df1d
--- /dev/null
+++ b/io/tst-utimensat-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimensat.c"
diff --git a/misc/Makefile b/misc/Makefile
index cfc15355d6..a8363d4b76 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -90,6 +90,8 @@ tests := tst-dirname tst-tsearch tst-fdset tst-mntent tst-hsearch \
 	 tst-ldbl-warn tst-ldbl-error tst-dbl-efgcvt tst-ldbl-efgcvt \
 	 tst-mntent-autofs tst-syscalls tst-mntent-escape
 
+tests-time64 := tst-pselect-time64
+
 # Tests which need libdl.
 ifeq (yes,$(build-shared))
 tests += tst-gethostid
diff --git a/misc/tst-pselect-time64.c b/misc/tst-pselect-time64.c
new file mode 100644
index 0000000000..15a1e49292
--- /dev/null
+++ b/misc/tst-pselect-time64.c
@@ -0,0 +1 @@
+#include "tst-pselect.c"
diff --git a/nptl/Makefile b/nptl/Makefile
index 5f85dd7854..0a0e8d360c 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -380,6 +380,9 @@ xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
 	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10 tst-setgroups \
 	tst-mutexpp5 tst-mutexpp9
 
+tests-time64 := \
+  tst-cancel4_2-time64
+
 # This test can run into task limits because of a linux kernel bug
 # and then cause the make process to fail too, see bug 24537.
 xtests += tst-eintr1
diff --git a/nptl/tst-cancel4_2-time64.c b/nptl/tst-cancel4_2-time64.c
new file mode 100644
index 0000000000..4ac086a312
--- /dev/null
+++ b/nptl/tst-cancel4_2-time64.c
@@ -0,0 +1 @@
+#include "tst-cancel4_2.c"
diff --git a/posix/Makefile b/posix/Makefile
index 8e31c721e1..471cb0ebcc 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -108,7 +108,9 @@ tests-internal	:= bug-regex5 bug-regex20 bug-regex33 \
 		   tst-rfc3484 tst-rfc3484-2 tst-rfc3484-3 \
 		   tst-glob_lstat_compat tst-spawn4-compat
 tests-container := bug-ga2
+tests-time64	:= tst-wait4-time64 tst-wait3-time64
 xtests		:= tst-getaddrinfo4 tst-getaddrinfo5 tst-sched_rr_get_interval
+xtests-time64	:= tst-sched_rr_get_interval-time64
 ifeq (yes,$(build-shared))
 test-srcs	:= globtest
 tests           += wordexp-test tst-exec tst-spawn tst-spawn2 tst-spawn3
diff --git a/posix/tst-sched_rr_get_interval-time64.c b/posix/tst-sched_rr_get_interval-time64.c
new file mode 100644
index 0000000000..f4e66d2939
--- /dev/null
+++ b/posix/tst-sched_rr_get_interval-time64.c
@@ -0,0 +1 @@
+#include "tst-sched_rr_get_interval.c"
diff --git a/posix/tst-wait3-time64.c b/posix/tst-wait3-time64.c
new file mode 100644
index 0000000000..2837bc7a9e
--- /dev/null
+++ b/posix/tst-wait3-time64.c
@@ -0,0 +1 @@
+#include "tst-wait3.c"
diff --git a/posix/tst-wait4-time64.c b/posix/tst-wait4-time64.c
new file mode 100644
index 0000000000..12543b270f
--- /dev/null
+++ b/posix/tst-wait4-time64.c
@@ -0,0 +1 @@
+#include "tst-wait4.c"
diff --git a/rt/Makefile b/rt/Makefile
index 7b374f2073..3ce98297f9 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -49,6 +49,15 @@ tests := tst-shm tst-timer tst-timer2 \
 	 tst-shm-cancel
 tests-internal := tst-timer-sigmask
 
+tests-time64 := \
+  tst-aio6-time64 \
+  tst-cpuclock2-time64 \
+  tst-mqueue1-time64 \
+  tst-mqueue2-time64 \
+  tst-mqueue4-time64 \
+  tst-mqueue8-time64 \
+  tst-timer4-time64
+
 extra-libs := librt
 extra-libs-others := $(extra-libs)
 
diff --git a/rt/tst-aio6-time64.c b/rt/tst-aio6-time64.c
new file mode 100644
index 0000000000..a386a577ec
--- /dev/null
+++ b/rt/tst-aio6-time64.c
@@ -0,0 +1 @@
+#include "tst-aio6.c"
diff --git a/rt/tst-cpuclock2-time64.c b/rt/tst-cpuclock2-time64.c
new file mode 100644
index 0000000000..05775522bb
--- /dev/null
+++ b/rt/tst-cpuclock2-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock2.c"
diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c
index c1c7ed2ad8..eebc3609d0 100644
--- a/rt/tst-cpuclock2.c
+++ b/rt/tst-cpuclock2.c
@@ -21,7 +21,11 @@
 
 #if (_POSIX_THREADS - 0) <= 0
 
-# define TEST_FUNCTION 0
+static int
+do_test ()
+{
+  return 0;
+}
 
 #else
 
@@ -330,7 +334,6 @@ do_test (void)
 
   return result;
 }
-# define TEST_FUNCTION do_test ()
 #endif
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/rt/tst-mqueue1-time64.c b/rt/tst-mqueue1-time64.c
new file mode 100644
index 0000000000..9c600a9a97
--- /dev/null
+++ b/rt/tst-mqueue1-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue1.c"
diff --git a/rt/tst-mqueue2-time64.c b/rt/tst-mqueue2-time64.c
new file mode 100644
index 0000000000..9d49f0b196
--- /dev/null
+++ b/rt/tst-mqueue2-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue2.c"
diff --git a/rt/tst-mqueue4-time64.c b/rt/tst-mqueue4-time64.c
new file mode 100644
index 0000000000..c23a228dc4
--- /dev/null
+++ b/rt/tst-mqueue4-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue4.c"
diff --git a/rt/tst-mqueue8-time64.c b/rt/tst-mqueue8-time64.c
new file mode 100644
index 0000000000..972637f7f5
--- /dev/null
+++ b/rt/tst-mqueue8-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue8.c"
diff --git a/rt/tst-timer4-time64.c b/rt/tst-timer4-time64.c
new file mode 100644
index 0000000000..e47a593f10
--- /dev/null
+++ b/rt/tst-timer4-time64.c
@@ -0,0 +1 @@
+#include "tst-timer4.c"
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index eeb64f9fb0..d4bfe2aee5 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -109,6 +109,16 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
 	 tst-unwind-thread \
 	 tst-pt-vfork1 tst-pt-vfork2 tst-vfork1x tst-vfork2x \
 
+tests-time64 := \
+  tst-abstime-time64 \
+  tst-cnd-timedwait-time64 \
+  tst-cond11-time64 \
+  tst-join14-time64 \
+  tst-mtx-timedlock-time64 \
+  tst-rwlock14-time64 \
+  tst-sem5-time64 \
+  tst-thrd-sleep-time64 \
+
 
 # Files which must not be linked with libpthread.
 tests-nolibpthread = tst-unload
diff --git a/sysdeps/pthread/tst-abstime-time64.c b/sysdeps/pthread/tst-abstime-time64.c
new file mode 100644
index 0000000000..2fc77cb365
--- /dev/null
+++ b/sysdeps/pthread/tst-abstime-time64.c
@@ -0,0 +1 @@
+#include "tst-abstime.c"
diff --git a/sysdeps/pthread/tst-cnd-timedwait-time64.c b/sysdeps/pthread/tst-cnd-timedwait-time64.c
new file mode 100644
index 0000000000..9b2abfd277
--- /dev/null
+++ b/sysdeps/pthread/tst-cnd-timedwait-time64.c
@@ -0,0 +1 @@
+#include "tst-cnd-timedwait.c"
diff --git a/sysdeps/pthread/tst-cond11-time64.c b/sysdeps/pthread/tst-cond11-time64.c
new file mode 100644
index 0000000000..9bccb8ec8b
--- /dev/null
+++ b/sysdeps/pthread/tst-cond11-time64.c
@@ -0,0 +1 @@
+#include "tst-cond11.c"
diff --git a/sysdeps/pthread/tst-join14-time64.c b/sysdeps/pthread/tst-join14-time64.c
new file mode 100644
index 0000000000..bed784ee24
--- /dev/null
+++ b/sysdeps/pthread/tst-join14-time64.c
@@ -0,0 +1 @@
+#include "tst-join14.c"
diff --git a/sysdeps/pthread/tst-mtx-timedlock-time64.c b/sysdeps/pthread/tst-mtx-timedlock-time64.c
new file mode 100644
index 0000000000..b3393c99ef
--- /dev/null
+++ b/sysdeps/pthread/tst-mtx-timedlock-time64.c
@@ -0,0 +1 @@
+#include "tst-mtx-timedlock.c"
diff --git a/sysdeps/pthread/tst-rwlock14-time64.c b/sysdeps/pthread/tst-rwlock14-time64.c
new file mode 100644
index 0000000000..ae9b1912cf
--- /dev/null
+++ b/sysdeps/pthread/tst-rwlock14-time64.c
@@ -0,0 +1 @@
+#include "tst-rwlock14.c"
diff --git a/sysdeps/pthread/tst-sem5-time64.c b/sysdeps/pthread/tst-sem5-time64.c
new file mode 100644
index 0000000000..89c2a14f94
--- /dev/null
+++ b/sysdeps/pthread/tst-sem5-time64.c
@@ -0,0 +1 @@
+#include "tst-sem5.c"
diff --git a/sysdeps/pthread/tst-thrd-sleep-time64.c b/sysdeps/pthread/tst-thrd-sleep-time64.c
new file mode 100644
index 0000000000..02837bd19f
--- /dev/null
+++ b/sysdeps/pthread/tst-thrd-sleep-time64.c
@@ -0,0 +1 @@
+#include "tst-thrd-sleep.c"
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index bdef626256..94274f3c22 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -114,6 +114,15 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
 	 tst-timerfd tst-ppoll tst-futimens tst-clock_adjtime tst-utime \
 	 tst-utimes tst-futimes tst-lutimes
 tests-internal += tst-ofdlocks-compat tst-sigcontext-get_pc
+tests-time64 += \
+  tst-clock_adjtime-time64 \
+  tst-futimes-time64\
+  tst-futimens-time64 \
+  tst-lutimes-time64 \
+  tst-ppoll-time64 \
+  tst-utime-time64 \
+  tst-utimes-time64 \
+  tst-timerfd-time64
 
 CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
 
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index 45d31a46bc..627f2cbf9d 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -228,7 +228,9 @@ libc {
     __timegm64;
     __timespec_get64;
     __utimensat64;
-     __utimes64;
+    __utimes64;
+    __localtime64;
+    __localtime64_r;
     # misc
     __ntp_gettime64;
     __ntp_gettimex64;
diff --git a/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c b/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
new file mode 100644
index 0000000000..9691e81229
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_adjtime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-futimens-time64.c b/sysdeps/unix/sysv/linux/tst-futimens-time64.c
new file mode 100644
index 0000000000..88fcb38489
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-futimens-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimens.c"
diff --git a/sysdeps/unix/sysv/linux/tst-futimens.c b/sysdeps/unix/sysv/linux/tst-futimens.c
index 522c84d896..96775de65e 100644
--- a/sysdeps/unix/sysv/linux/tst-futimens.c
+++ b/sysdeps/unix/sysv/linux/tst-futimens.c
@@ -23,10 +23,14 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 
 /* struct timespec array with Y2038 threshold minus 2 and 1 seconds.  */
-const struct timespec t1[2] = { { 0x7FFFFFFE, 0 },  { 0x7FFFFFFF, 0 } };
+const static struct timespec t1[2] = { { 0x7FFFFFFE, 0 },  { 0x7FFFFFFF, 0 } };
 
 #define PREPARE do_prepare
 static void
@@ -39,7 +43,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_futimens_helper (const struct timespec *ts)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
@@ -47,7 +51,7 @@ test_futimens_helper (const struct timespec *ts)
   if (__builtin_add_overflow (ts->tv_sec, 0, &t))
     return 0;
 
-  result = futimens(temp_fd, ts);
+  result = futimens (temp_fd, ts);
   TEST_VERIFY_EXIT (result == 0);
 
   xfstat (temp_fd, &st);
diff --git a/sysdeps/unix/sysv/linux/tst-futimes-time64.c b/sysdeps/unix/sysv/linux/tst-futimes-time64.c
new file mode 100644
index 0000000000..d489c265d1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-futimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-lutimes-time64.c b/sysdeps/unix/sysv/linux/tst-lutimes-time64.c
new file mode 100644
index 0000000000..06caec0a91
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-lutimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-lutimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ppoll-time64.c b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
new file mode 100644
index 0000000000..96ee2faee3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
@@ -0,0 +1 @@
+#include "tst-ppoll.c"
diff --git a/sysdeps/unix/sysv/linux/tst-timerfd-time64.c b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
new file mode 100644
index 0000000000..bb17f48139
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
@@ -0,0 +1 @@
+#include "tst-timerfd.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utime-time64.c b/sysdeps/unix/sysv/linux/tst-utime-time64.c
new file mode 100644
index 0000000000..eb62f59126
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-utime-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utime.c b/sysdeps/unix/sysv/linux/tst-utime.c
index fe1869702c..532464a6e9 100644
--- a/sysdeps/unix/sysv/linux/tst-utime.c
+++ b/sysdeps/unix/sysv/linux/tst-utime.c
@@ -25,6 +25,10 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 char *testfile;
 
@@ -48,7 +52,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_utime_helper (const struct utimbuf *ut)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
diff --git a/sysdeps/unix/sysv/linux/tst-utimes-time64.c b/sysdeps/unix/sysv/linux/tst-utimes-time64.c
new file mode 100644
index 0000000000..234ec02541
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-utimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utimes.c b/sysdeps/unix/sysv/linux/tst-utimes.c
index db43660262..acf1af2023 100644
--- a/sysdeps/unix/sysv/linux/tst-utimes.c
+++ b/sysdeps/unix/sysv/linux/tst-utimes.c
@@ -24,6 +24,10 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 static char *testfile;
 
@@ -49,7 +53,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_utime_helper (const struct timeval *tv)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
diff --git a/sysvipc/Makefile b/sysvipc/Makefile
index a534791928..86911803b5 100644
--- a/sysvipc/Makefile
+++ b/sysvipc/Makefile
@@ -32,6 +32,8 @@ routines := ftok \
 
 tests    := test-sysvmsg test-sysvsem test-sysvshm
 
+tests-time64 := test-sysvmsg-time64 test-sysvsem-time64 test-sysvshm-time64
+
 include ../Rules
 
 CFLAGS-msgrcv.c += -fexceptions -fasynchronous-unwind-tables
diff --git a/sysvipc/test-sysvmsg-time64.c b/sysvipc/test-sysvmsg-time64.c
new file mode 100644
index 0000000000..c23e0c337e
--- /dev/null
+++ b/sysvipc/test-sysvmsg-time64.c
@@ -0,0 +1 @@
+#include "test-sysvmsg.c"
diff --git a/sysvipc/test-sysvsem-time64.c b/sysvipc/test-sysvsem-time64.c
new file mode 100644
index 0000000000..05c95068cd
--- /dev/null
+++ b/sysvipc/test-sysvsem-time64.c
@@ -0,0 +1 @@
+#include "test-sysvsem.c"
diff --git a/sysvipc/test-sysvshm-time64.c b/sysvipc/test-sysvshm-time64.c
new file mode 100644
index 0000000000..8e2963f563
--- /dev/null
+++ b/sysvipc/test-sysvshm-time64.c
@@ -0,0 +1 @@
+#include "test-sysvshm.c"
diff --git a/time/Makefile b/time/Makefile
index 29208f35c0..414721ecc5 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -51,6 +51,21 @@ tests	:= test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
 	   tst-adjtime tst-ctime tst-difftime tst-mktime4 tst-clock_settime \
 	   tst-itimer tst-gmtime tst-timegm tst-timespec_get
 
+tests-time64 := \
+  tst-adjtime-time64 \
+  tst-clock-time64 \
+  tst-clock2-time64 \
+  tst-clock_nanosleep-time64 \
+  tst-cpuclock1-time64 \
+  tst-ctime-time64 \
+  tst-difftime-time64 \
+  tst-gmtime-time64 \
+  tst-itimer-time64 \
+  tst-mktime4-time64 \
+  tst-timegm-time64 \
+  tst-timespec_get-time64 \
+  tst-y2039-time64
+
 include ../Rules
 
 ifeq ($(run-built-tests),yes)
diff --git a/time/tst-adjtime-time64.c b/time/tst-adjtime-time64.c
new file mode 100644
index 0000000000..097d6efc4b
--- /dev/null
+++ b/time/tst-adjtime-time64.c
@@ -0,0 +1 @@
+#include <tst-adjtime.c>
diff --git a/time/tst-clock-time64.c b/time/tst-clock-time64.c
new file mode 100644
index 0000000000..a1349678c8
--- /dev/null
+++ b/time/tst-clock-time64.c
@@ -0,0 +1 @@
+#include "tst-clock.c"
diff --git a/time/tst-clock2-time64.c b/time/tst-clock2-time64.c
new file mode 100644
index 0000000000..897f47b287
--- /dev/null
+++ b/time/tst-clock2-time64.c
@@ -0,0 +1 @@
+#include "tst-clock2.c"
diff --git a/time/tst-clock_nanosleep-time64.c b/time/tst-clock_nanosleep-time64.c
new file mode 100644
index 0000000000..c8638aa3d2
--- /dev/null
+++ b/time/tst-clock_nanosleep-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_nanosleep.c"
diff --git a/time/tst-cpuclock1-time64.c b/time/tst-cpuclock1-time64.c
new file mode 100644
index 0000000000..5a7ffa27ac
--- /dev/null
+++ b/time/tst-cpuclock1-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock1.c"
diff --git a/time/tst-ctime-time64.c b/time/tst-ctime-time64.c
new file mode 100644
index 0000000000..24a5ae98ed
--- /dev/null
+++ b/time/tst-ctime-time64.c
@@ -0,0 +1 @@
+#include "tst-ctime.c"
diff --git a/time/tst-ctime.c b/time/tst-ctime.c
index e89a906bf8..884d69bfa0 100644
--- a/time/tst-ctime.c
+++ b/time/tst-ctime.c
@@ -24,6 +24,7 @@ static int
 do_test (void)
 {
   char *str;
+  char strb[32];
   time_t t;
 
   /* Use glibc time zone extension "TZ=:" to to guarantee that UTC
@@ -36,11 +37,21 @@ do_test (void)
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
+
   /* Check if the max time value for 32 bit time_t can be converted.  */
   t = 0x7fffffff;
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
+
   /* Check if we run on port with 32 bit time_t size */
   time_t tov;
   if (__builtin_add_overflow (t, 1, &tov))
@@ -50,6 +61,11 @@ do_test (void)
   str = ctime (&tov);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&tov, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
+
   return 0;
 }
 
diff --git a/time/tst-difftime-time64.c b/time/tst-difftime-time64.c
new file mode 100644
index 0000000000..751ce6c483
--- /dev/null
+++ b/time/tst-difftime-time64.c
@@ -0,0 +1 @@
+#include "tst-difftime.c"
diff --git a/time/tst-gmtime-time64.c b/time/tst-gmtime-time64.c
new file mode 100644
index 0000000000..0df11c1913
--- /dev/null
+++ b/time/tst-gmtime-time64.c
@@ -0,0 +1 @@
+#include "tst-gmtime.c"
diff --git a/time/tst-itimer-time64.c b/time/tst-itimer-time64.c
new file mode 100644
index 0000000000..ddd2efa175
--- /dev/null
+++ b/time/tst-itimer-time64.c
@@ -0,0 +1 @@
+#include <time/tst-itimer.c>
diff --git a/time/tst-mktime4-time64.c b/time/tst-mktime4-time64.c
new file mode 100644
index 0000000000..bf5197c6f3
--- /dev/null
+++ b/time/tst-mktime4-time64.c
@@ -0,0 +1 @@
+#include "tst-mktime4.c"
diff --git a/time/tst-timegm-time64.c b/time/tst-timegm-time64.c
new file mode 100644
index 0000000000..8e3084f74e
--- /dev/null
+++ b/time/tst-timegm-time64.c
@@ -0,0 +1 @@
+#include "tst-timegm.c"
diff --git a/time/tst-timespec_get-time64.c b/time/tst-timespec_get-time64.c
new file mode 100644
index 0000000000..48f336385d
--- /dev/null
+++ b/time/tst-timespec_get-time64.c
@@ -0,0 +1 @@
+#include "tst-timespec_get.c"
diff --git a/time/tst-y2039-time64.c b/time/tst-y2039-time64.c
new file mode 100644
index 0000000000..3c8a504186
--- /dev/null
+++ b/time/tst-y2039-time64.c
@@ -0,0 +1 @@
+#include "tst-y2039.c"
diff --git a/time/tst-y2039.c b/time/tst-y2039.c
index ef024c0a77..66a22d4c2c 100644
--- a/time/tst-y2039.c
+++ b/time/tst-y2039.c
@@ -37,6 +37,16 @@ do_test (void)
 			> 0);
       puts (buf);
       TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
+
+      /* Same as before but for localtime_r.  */
+      struct tm tmd;
+      tm = localtime_r (&ouch, &tmd);
+      TEST_VERIFY_EXIT (tm == &tmd);
+
+      TEST_VERIFY_EXIT (strftime (buf, sizeof buf, "%Y-%m-%d %H:%M:%S %Z", tm)
+			> 0);
+      puts (buf);
+      TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
     }
   else
     FAIL_UNSUPPORTED ("32-bit time_t");


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [glibc/azanella/y2038] y2038: Add test coverage
@ 2021-03-01 17:39 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2021-03-01 17:39 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6dce3973fae284ad90570b571a44885126b66c91

commit 6dce3973fae284ad90570b571a44885126b66c91
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Feb 17 15:59:34 2021 -0300

    y2038: Add test coverage
    
    A new 'tests-y2038' rule is added, which adds the required 64 bit
    time flags and included in the 'tests' rule.
    
    The current coverage is:
    
      * libc:
        - adjtime                       tst-adjtime-time64
        - adjtimex
        - clock_adjtime                 tst-clock_adjtime-time64
        - clock_getres                  tst-clock-time64, tst-cpuclock1-time64
        - clock_gettime                 tst-clock-time64, tst-clock2-time64,
                                        tst-cpuclock1-time64
        - clock_nanoslee                tst-clock_nanosleep-time64,
                                        tst-cpuclock1-time64
        - clock_settime                 tst-clock2-time64
        - ctime                         tst-ctime-time64
        - ctime_r                       tst-ctime-time64
        - difftime                      tst-difftime-time64
        - fstat                         tst-stat-time64
        - fstatat                       tst-stat-time64
        - futimens                      tst-futimens-time64
        - futimes                       tst-futimes-time64
        - futimesat                     tst-futimesat-time64
        - getitimer                     tst-itimer-timer64
        - getrusage
        - gettimeofday                  tst-clock_nanosleep-time64
        - gmtime                        tst-gmtime-time64
        - gmtime_r                      tst-gmtime-time64
        - lstat                         tst-stat-time64
        - localtime                     tst-y2039-time64
        - localtime_t                   tst-y2039-time64
        - lutimes                       tst-lutimes-time64
        - mktime                        tst-mktime4-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - msgctl                        test-sysvmsg-time64
        - nanosleep                     tst-cpuclock{12}-time64,
                                        tst-mqueue8-time64, tst-clock-time64
        - ntp_adjtime
        - ntp_gettime
        - ntp_gettimex
        - ppoll                         tst-ppoll-time64
        - pselect                       tst-pselect-time64
        - recvmmsg                      tst-cancel4_2-time64
        - sched_rr_get_interval         tst-sched_rr_get_interval-time64
        - select
        - semctl                        test-sysvsem-time64
        - semtimedop                    test-sysvsem-time64
        - setitimer                     tst-mqueue2-time64, tst-itimer-timer64
        - settimeofday
        - shmctl                        test-sysvshm-time64
        - sigtimedwait
        - stat                          tst-stat-time64
        - time                          tst-mqueue{1248}-time64
        - timegm                        tst-timegm-time64
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
        - timerfd_gettime               tst-timerfd-time64
        - timerfd_settime               tst-timerfd-time64
        - timespec_get                  tst-timespec_get-time64
        - utime                         tst-utime-time64
        - utimensat                     tst-utimensat-time64
        - utimes                        tst-utimes-time64
        - wait3                         tst-wait3-time64
        - wait4                         tst-wait4-time64
    
      * libpthread:
        - cnd_timedwait                 tst-cnd-timedwait-time64
        - mtx_timedlock                 tst-mtx-timedlock-time64
        - pthread_clockjoin_np          tst-join14-time64
        - pthread_cond_clockwait        tst-cond11-time64
        - pthread_cond_timedwait        tst-abstime-time64
        - pthread_mutex_clocklock       tst-abstime-time64
        - pthread_mutex_timedlock       tst-abstime-time64
        - pthread_rwlock_clockrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_clockwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_timedjoin_np          tst-join14-time64
        - sem_clockwait                 tst-sem5-time64
        - sem_timedwait                 tst-sem5-time64
        - thrd_sleep                    tst-thrd-sleep-time64
    
      * librt:
        - aio_suspend                   tst-aio6-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
    
      * libanl:
        - gai_suspend

Diff:
---
 Makerules                                          |  23 ++++-
 io/Makefile                                        |   4 +
 io/tst-futimesat-time64.c                          |   4 +
 io/tst-futimesat.c                                 |  47 +++++++---
 io/tst-stat-time64.c                               | 102 +++++++++++++++++++++
 io/tst-utimensat-time64.c                          |   2 +
 misc/Makefile                                      |   2 +
 misc/tst-pselect-time64.c                          |   1 +
 nptl/Makefile                                      |   3 +
 nptl/tst-cancel4_2-time64.c                        |   1 +
 posix/Makefile                                     |   2 +
 posix/tst-sched_rr_get_interval-time64.c           |   1 +
 posix/tst-wait3-time64.c                           |   1 +
 posix/tst-wait4-time64.c                           |   1 +
 rt/Makefile                                        |   9 ++
 rt/tst-aio6-time64.c                               |   1 +
 rt/tst-cpuclock2-time64.c                          |   1 +
 rt/tst-cpuclock2.c                                 |   9 +-
 rt/tst-mqueue1-time64.c                            |   1 +
 rt/tst-mqueue2-time64.c                            |   1 +
 rt/tst-mqueue4-time64.c                            |   1 +
 rt/tst-mqueue8-time64.c                            |   1 +
 rt/tst-timer4-time64.c                             |   1 +
 sysdeps/pthread/Makefile                           |  10 ++
 sysdeps/pthread/tst-abstime-time64.c               |   1 +
 sysdeps/pthread/tst-cnd-timedwait-time64.c         |   1 +
 sysdeps/pthread/tst-cond11-time64.c                |   1 +
 sysdeps/pthread/tst-join14-time64.c                |   1 +
 sysdeps/pthread/tst-mtx-timedlock-time64.c         |   1 +
 sysdeps/pthread/tst-rwlock14-time64.c              |   1 +
 sysdeps/pthread/tst-sem5-time64.c                  |   1 +
 sysdeps/pthread/tst-thrd-sleep-time64.c            |   1 +
 sysdeps/unix/sysv/linux/Makefile                   |   9 ++
 sysdeps/unix/sysv/linux/Versions                   |   4 +-
 sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c |   1 +
 sysdeps/unix/sysv/linux/tst-futimens-time64.c      |   2 +
 sysdeps/unix/sysv/linux/tst-futimens.c             |  10 +-
 sysdeps/unix/sysv/linux/tst-futimes-time64.c       |   2 +
 sysdeps/unix/sysv/linux/tst-lutimes-time64.c       |   2 +
 sysdeps/unix/sysv/linux/tst-ppoll-time64.c         |   1 +
 sysdeps/unix/sysv/linux/tst-timerfd-time64.c       |   1 +
 sysdeps/unix/sysv/linux/tst-utime-time64.c         |   2 +
 sysdeps/unix/sysv/linux/tst-utime.c                |   6 +-
 sysdeps/unix/sysv/linux/tst-utimes-time64.c        |   2 +
 sysdeps/unix/sysv/linux/tst-utimes.c               |   6 +-
 sysvipc/Makefile                                   |   2 +
 sysvipc/test-sysvmsg-time64.c                      |   1 +
 sysvipc/test-sysvsem-time64.c                      |   1 +
 sysvipc/test-sysvshm-time64.c                      |   1 +
 time/Makefile                                      |  15 +++
 time/tst-adjtime-time64.c                          |   1 +
 time/tst-clock-time64.c                            |   1 +
 time/tst-clock2-time64.c                           |   1 +
 time/tst-clock_nanosleep-time64.c                  |   1 +
 time/tst-cpuclock1-time64.c                        |   1 +
 time/tst-ctime-time64.c                            |   1 +
 time/tst-ctime.c                                   |  16 ++++
 time/tst-difftime-time64.c                         |   1 +
 time/tst-gmtime-time64.c                           |   1 +
 time/tst-itimer-time64.c                           |   1 +
 time/tst-mktime4-time64.c                          |   1 +
 time/tst-timegm-time64.c                           |   1 +
 time/tst-timespec_get-time64.c                     |   1 +
 time/tst-y2039-time64.c                            |   1 +
 time/tst-y2039.c                                   |  10 ++
 65 files changed, 321 insertions(+), 23 deletions(-)

diff --git a/Makerules b/Makerules
index fc5251ffad..aca5d1f4d7 100644
--- a/Makerules
+++ b/Makerules
@@ -771,7 +771,8 @@ endif
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
 	     $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
-	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs))
+	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) \
+		$(test-srcs) $(tests-time64) $(xtests-time64))
 ifeq ($(build-programs),yes)
 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
 endif
@@ -1286,6 +1287,26 @@ check: tests
 .PHONY: xcheck
 xcheck: xtests
 
+# Handle tests-time64 and xtests-time64 that should built with LFS
+# and 64-bit time support.
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(tests-time64),$(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+tests += $(foreach t,$(tests-time64),$(t))
+
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(xtests-time64),$(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+xtests += $(foreach t,$(xtests-time64),$(t))
+
 # The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
 # that almost all internal declarations from config.h, libc-symbols.h, and
 # include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
diff --git a/io/Makefile b/io/Makefile
index 59d36e8782..c6c595d5a3 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -70,6 +70,10 @@ tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-ftw-lnk tst-file_change_detection tst-lchmod \
 		   tst-ftw-bz26353 tst-utimensat
 
+tests-time64    := tst-stat-time64 \
+		   tst-futimesat-time64 \
+		   tst-utimensat-time64
+
 # Likewise for statx, but we do not need static linking here.
 tests-internal += tst-statx
 tests-static += tst-statx
diff --git a/io/tst-futimesat-time64.c b/io/tst-futimesat-time64.c
new file mode 100644
index 0000000000..f6c0500eef
--- /dev/null
+++ b/io/tst-futimesat-time64.c
@@ -0,0 +1,4 @@
+#define struct_stat  struct stat
+#define fstat        fstat
+#define fstatat      fstatat
+#include "io/tst-futimesat.c"
diff --git a/io/tst-futimesat.c b/io/tst-futimesat.c
index af58ad06dd..c32ab2b668 100644
--- a/io/tst-futimesat.c
+++ b/io/tst-futimesat.c
@@ -1,4 +1,23 @@
+/* futimesat basic tests.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
 #include <dirent.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -7,19 +26,19 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#include <support/test-driver.h>
+#include <support/temp_file.h>
 
-static void prepare (void);
-#define PREPARE(argc, argv) prepare ()
-
-static int do_test (void);
-#define TEST_FUNCTION do_test ()
-
-#include "../test-skeleton.c"
+#ifndef struct_stat
+# define struct_stat struct stat64
+# define fstat       fstat64
+# define fstatat     fstatat64
+#endif
 
 static int dir_fd;
 
 static void
-prepare (void)
+prepare (int argc, char *argv[])
 {
   size_t test_dir_len = strlen (test_dir);
   static const char dir_name[] = "/tst-futimesat.XXXXXX";
@@ -48,7 +67,7 @@ prepare (void)
       exit (1);
     }
 }
-
+#define PREPARE prepare
 
 static int
 do_test (void)
@@ -98,8 +117,8 @@ do_test (void)
   write (fd, "hello", 5);
   puts ("file created");
 
-  struct stat64 st1;
-  if (fstat64 (fd, &st1) != 0)
+  struct_stat st1;
+  if (fstat (fd, &st1) != 0)
     {
       puts ("fstat64 failed");
       return 1;
@@ -118,8 +137,8 @@ do_test (void)
       return 1;
     }
 
-  struct stat64 st2;
-  if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0)
+  struct_stat st2;
+  if (fstatat (dir_fd, "some-file", &st2, 0) != 0)
     {
       puts ("fstatat64 failed");
       return 1;
@@ -146,3 +165,5 @@ do_test (void)
 
   return 0;
 }
+
+#include <support/test-driver.c>
diff --git a/io/tst-stat-time64.c b/io/tst-stat-time64.c
new file mode 100644
index 0000000000..c10fe1284a
--- /dev/null
+++ b/io/tst-stat-time64.c
@@ -0,0 +1,102 @@
+/* Basic test of stat with 64 bit time_t interfaces.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <support/check.h>
+#include <support/support.h>
+#include <support/temp_file.h>
+#include <support/xunistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+
+/* The idea of the test is check whether the 64 bit time_t stat implementation
+   returns the expected value for comparable fields, so it does not really
+   matter whether statx uses a fallback implementation or not.  */
+
+static void
+stat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (stat (path, st), 0);
+}
+
+static void
+lstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (lstat (path, st), 0);
+}
+
+static void
+fstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstat (fd, st), 0);
+}
+
+static void
+fstatat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstatat (fd, path, st, 0), 0);
+}
+
+typedef void (*test_t)(int, const char *path, struct stat *);
+
+static int
+do_test (void)
+{
+  char *path;
+  int fd = create_temp_file ("tst-statx-", &path);
+  TEST_VERIFY_EXIT (fd >= 0);
+  support_write_file_string (path, "abc");
+
+  struct statx stx;
+  TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0);
+
+  for (test_t *test = (test_t[]) { stat_check, lstat_check, fstat_check,
+				   fstatat_check, NULL };
+       *test != NULL; test++)
+  {
+    struct stat st;
+    (*test) (fd, path, &st);
+
+    TEST_COMPARE (stx.stx_dev_major, major (st.st_dev));
+    TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev));
+    TEST_COMPARE (stx.stx_ino, st.st_ino);
+    TEST_COMPARE (stx.stx_mode, st.st_mode);
+    TEST_COMPARE (stx.stx_nlink, st.st_nlink);
+    TEST_COMPARE (stx.stx_uid, st.st_uid);
+    TEST_COMPARE (stx.stx_gid, st.st_gid);
+    TEST_COMPARE (stx.stx_rdev_major, major (st.st_rdev));
+    TEST_COMPARE (stx.stx_rdev_minor, minor (st.st_rdev));
+    TEST_COMPARE (stx.stx_blksize, st.st_blksize);
+    TEST_COMPARE (stx.stx_blocks, st.st_blocks);
+
+    TEST_COMPARE (stx.stx_ctime.tv_sec, st.st_ctim.tv_sec);
+    TEST_COMPARE (stx.stx_ctime.tv_nsec, st.st_ctim.tv_nsec);
+    TEST_COMPARE (stx.stx_mtime.tv_sec, st.st_mtim.tv_sec);
+    TEST_COMPARE (stx.stx_mtime.tv_nsec, st.st_mtim.tv_nsec);
+  }
+
+  xclose (fd);
+  free (path);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/io/tst-utimensat-time64.c b/io/tst-utimensat-time64.c
new file mode 100644
index 0000000000..7ac7d8df1d
--- /dev/null
+++ b/io/tst-utimensat-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimensat.c"
diff --git a/misc/Makefile b/misc/Makefile
index cfc15355d6..a8363d4b76 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -90,6 +90,8 @@ tests := tst-dirname tst-tsearch tst-fdset tst-mntent tst-hsearch \
 	 tst-ldbl-warn tst-ldbl-error tst-dbl-efgcvt tst-ldbl-efgcvt \
 	 tst-mntent-autofs tst-syscalls tst-mntent-escape
 
+tests-time64 := tst-pselect-time64
+
 # Tests which need libdl.
 ifeq (yes,$(build-shared))
 tests += tst-gethostid
diff --git a/misc/tst-pselect-time64.c b/misc/tst-pselect-time64.c
new file mode 100644
index 0000000000..15a1e49292
--- /dev/null
+++ b/misc/tst-pselect-time64.c
@@ -0,0 +1 @@
+#include "tst-pselect.c"
diff --git a/nptl/Makefile b/nptl/Makefile
index 5f85dd7854..0a0e8d360c 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -380,6 +380,9 @@ xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
 	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10 tst-setgroups \
 	tst-mutexpp5 tst-mutexpp9
 
+tests-time64 := \
+  tst-cancel4_2-time64
+
 # This test can run into task limits because of a linux kernel bug
 # and then cause the make process to fail too, see bug 24537.
 xtests += tst-eintr1
diff --git a/nptl/tst-cancel4_2-time64.c b/nptl/tst-cancel4_2-time64.c
new file mode 100644
index 0000000000..4ac086a312
--- /dev/null
+++ b/nptl/tst-cancel4_2-time64.c
@@ -0,0 +1 @@
+#include "tst-cancel4_2.c"
diff --git a/posix/Makefile b/posix/Makefile
index 8e31c721e1..471cb0ebcc 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -108,7 +108,9 @@ tests-internal	:= bug-regex5 bug-regex20 bug-regex33 \
 		   tst-rfc3484 tst-rfc3484-2 tst-rfc3484-3 \
 		   tst-glob_lstat_compat tst-spawn4-compat
 tests-container := bug-ga2
+tests-time64	:= tst-wait4-time64 tst-wait3-time64
 xtests		:= tst-getaddrinfo4 tst-getaddrinfo5 tst-sched_rr_get_interval
+xtests-time64	:= tst-sched_rr_get_interval-time64
 ifeq (yes,$(build-shared))
 test-srcs	:= globtest
 tests           += wordexp-test tst-exec tst-spawn tst-spawn2 tst-spawn3
diff --git a/posix/tst-sched_rr_get_interval-time64.c b/posix/tst-sched_rr_get_interval-time64.c
new file mode 100644
index 0000000000..f4e66d2939
--- /dev/null
+++ b/posix/tst-sched_rr_get_interval-time64.c
@@ -0,0 +1 @@
+#include "tst-sched_rr_get_interval.c"
diff --git a/posix/tst-wait3-time64.c b/posix/tst-wait3-time64.c
new file mode 100644
index 0000000000..2837bc7a9e
--- /dev/null
+++ b/posix/tst-wait3-time64.c
@@ -0,0 +1 @@
+#include "tst-wait3.c"
diff --git a/posix/tst-wait4-time64.c b/posix/tst-wait4-time64.c
new file mode 100644
index 0000000000..12543b270f
--- /dev/null
+++ b/posix/tst-wait4-time64.c
@@ -0,0 +1 @@
+#include "tst-wait4.c"
diff --git a/rt/Makefile b/rt/Makefile
index 7b374f2073..3ce98297f9 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -49,6 +49,15 @@ tests := tst-shm tst-timer tst-timer2 \
 	 tst-shm-cancel
 tests-internal := tst-timer-sigmask
 
+tests-time64 := \
+  tst-aio6-time64 \
+  tst-cpuclock2-time64 \
+  tst-mqueue1-time64 \
+  tst-mqueue2-time64 \
+  tst-mqueue4-time64 \
+  tst-mqueue8-time64 \
+  tst-timer4-time64
+
 extra-libs := librt
 extra-libs-others := $(extra-libs)
 
diff --git a/rt/tst-aio6-time64.c b/rt/tst-aio6-time64.c
new file mode 100644
index 0000000000..a386a577ec
--- /dev/null
+++ b/rt/tst-aio6-time64.c
@@ -0,0 +1 @@
+#include "tst-aio6.c"
diff --git a/rt/tst-cpuclock2-time64.c b/rt/tst-cpuclock2-time64.c
new file mode 100644
index 0000000000..05775522bb
--- /dev/null
+++ b/rt/tst-cpuclock2-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock2.c"
diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c
index c1c7ed2ad8..eebc3609d0 100644
--- a/rt/tst-cpuclock2.c
+++ b/rt/tst-cpuclock2.c
@@ -21,7 +21,11 @@
 
 #if (_POSIX_THREADS - 0) <= 0
 
-# define TEST_FUNCTION 0
+static int
+do_test ()
+{
+  return 0;
+}
 
 #else
 
@@ -330,7 +334,6 @@ do_test (void)
 
   return result;
 }
-# define TEST_FUNCTION do_test ()
 #endif
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/rt/tst-mqueue1-time64.c b/rt/tst-mqueue1-time64.c
new file mode 100644
index 0000000000..9c600a9a97
--- /dev/null
+++ b/rt/tst-mqueue1-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue1.c"
diff --git a/rt/tst-mqueue2-time64.c b/rt/tst-mqueue2-time64.c
new file mode 100644
index 0000000000..9d49f0b196
--- /dev/null
+++ b/rt/tst-mqueue2-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue2.c"
diff --git a/rt/tst-mqueue4-time64.c b/rt/tst-mqueue4-time64.c
new file mode 100644
index 0000000000..c23a228dc4
--- /dev/null
+++ b/rt/tst-mqueue4-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue4.c"
diff --git a/rt/tst-mqueue8-time64.c b/rt/tst-mqueue8-time64.c
new file mode 100644
index 0000000000..972637f7f5
--- /dev/null
+++ b/rt/tst-mqueue8-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue8.c"
diff --git a/rt/tst-timer4-time64.c b/rt/tst-timer4-time64.c
new file mode 100644
index 0000000000..e47a593f10
--- /dev/null
+++ b/rt/tst-timer4-time64.c
@@ -0,0 +1 @@
+#include "tst-timer4.c"
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index eeb64f9fb0..d4bfe2aee5 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -109,6 +109,16 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
 	 tst-unwind-thread \
 	 tst-pt-vfork1 tst-pt-vfork2 tst-vfork1x tst-vfork2x \
 
+tests-time64 := \
+  tst-abstime-time64 \
+  tst-cnd-timedwait-time64 \
+  tst-cond11-time64 \
+  tst-join14-time64 \
+  tst-mtx-timedlock-time64 \
+  tst-rwlock14-time64 \
+  tst-sem5-time64 \
+  tst-thrd-sleep-time64 \
+
 
 # Files which must not be linked with libpthread.
 tests-nolibpthread = tst-unload
diff --git a/sysdeps/pthread/tst-abstime-time64.c b/sysdeps/pthread/tst-abstime-time64.c
new file mode 100644
index 0000000000..2fc77cb365
--- /dev/null
+++ b/sysdeps/pthread/tst-abstime-time64.c
@@ -0,0 +1 @@
+#include "tst-abstime.c"
diff --git a/sysdeps/pthread/tst-cnd-timedwait-time64.c b/sysdeps/pthread/tst-cnd-timedwait-time64.c
new file mode 100644
index 0000000000..9b2abfd277
--- /dev/null
+++ b/sysdeps/pthread/tst-cnd-timedwait-time64.c
@@ -0,0 +1 @@
+#include "tst-cnd-timedwait.c"
diff --git a/sysdeps/pthread/tst-cond11-time64.c b/sysdeps/pthread/tst-cond11-time64.c
new file mode 100644
index 0000000000..9bccb8ec8b
--- /dev/null
+++ b/sysdeps/pthread/tst-cond11-time64.c
@@ -0,0 +1 @@
+#include "tst-cond11.c"
diff --git a/sysdeps/pthread/tst-join14-time64.c b/sysdeps/pthread/tst-join14-time64.c
new file mode 100644
index 0000000000..bed784ee24
--- /dev/null
+++ b/sysdeps/pthread/tst-join14-time64.c
@@ -0,0 +1 @@
+#include "tst-join14.c"
diff --git a/sysdeps/pthread/tst-mtx-timedlock-time64.c b/sysdeps/pthread/tst-mtx-timedlock-time64.c
new file mode 100644
index 0000000000..b3393c99ef
--- /dev/null
+++ b/sysdeps/pthread/tst-mtx-timedlock-time64.c
@@ -0,0 +1 @@
+#include "tst-mtx-timedlock.c"
diff --git a/sysdeps/pthread/tst-rwlock14-time64.c b/sysdeps/pthread/tst-rwlock14-time64.c
new file mode 100644
index 0000000000..ae9b1912cf
--- /dev/null
+++ b/sysdeps/pthread/tst-rwlock14-time64.c
@@ -0,0 +1 @@
+#include "tst-rwlock14.c"
diff --git a/sysdeps/pthread/tst-sem5-time64.c b/sysdeps/pthread/tst-sem5-time64.c
new file mode 100644
index 0000000000..89c2a14f94
--- /dev/null
+++ b/sysdeps/pthread/tst-sem5-time64.c
@@ -0,0 +1 @@
+#include "tst-sem5.c"
diff --git a/sysdeps/pthread/tst-thrd-sleep-time64.c b/sysdeps/pthread/tst-thrd-sleep-time64.c
new file mode 100644
index 0000000000..02837bd19f
--- /dev/null
+++ b/sysdeps/pthread/tst-thrd-sleep-time64.c
@@ -0,0 +1 @@
+#include "tst-thrd-sleep.c"
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index bdef626256..94274f3c22 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -114,6 +114,15 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
 	 tst-timerfd tst-ppoll tst-futimens tst-clock_adjtime tst-utime \
 	 tst-utimes tst-futimes tst-lutimes
 tests-internal += tst-ofdlocks-compat tst-sigcontext-get_pc
+tests-time64 += \
+  tst-clock_adjtime-time64 \
+  tst-futimes-time64\
+  tst-futimens-time64 \
+  tst-lutimes-time64 \
+  tst-ppoll-time64 \
+  tst-utime-time64 \
+  tst-utimes-time64 \
+  tst-timerfd-time64
 
 CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
 
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index 45d31a46bc..627f2cbf9d 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -228,7 +228,9 @@ libc {
     __timegm64;
     __timespec_get64;
     __utimensat64;
-     __utimes64;
+    __utimes64;
+    __localtime64;
+    __localtime64_r;
     # misc
     __ntp_gettime64;
     __ntp_gettimex64;
diff --git a/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c b/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
new file mode 100644
index 0000000000..9691e81229
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_adjtime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-futimens-time64.c b/sysdeps/unix/sysv/linux/tst-futimens-time64.c
new file mode 100644
index 0000000000..88fcb38489
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-futimens-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimens.c"
diff --git a/sysdeps/unix/sysv/linux/tst-futimens.c b/sysdeps/unix/sysv/linux/tst-futimens.c
index 522c84d896..96775de65e 100644
--- a/sysdeps/unix/sysv/linux/tst-futimens.c
+++ b/sysdeps/unix/sysv/linux/tst-futimens.c
@@ -23,10 +23,14 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 
 /* struct timespec array with Y2038 threshold minus 2 and 1 seconds.  */
-const struct timespec t1[2] = { { 0x7FFFFFFE, 0 },  { 0x7FFFFFFF, 0 } };
+const static struct timespec t1[2] = { { 0x7FFFFFFE, 0 },  { 0x7FFFFFFF, 0 } };
 
 #define PREPARE do_prepare
 static void
@@ -39,7 +43,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_futimens_helper (const struct timespec *ts)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
@@ -47,7 +51,7 @@ test_futimens_helper (const struct timespec *ts)
   if (__builtin_add_overflow (ts->tv_sec, 0, &t))
     return 0;
 
-  result = futimens(temp_fd, ts);
+  result = futimens (temp_fd, ts);
   TEST_VERIFY_EXIT (result == 0);
 
   xfstat (temp_fd, &st);
diff --git a/sysdeps/unix/sysv/linux/tst-futimes-time64.c b/sysdeps/unix/sysv/linux/tst-futimes-time64.c
new file mode 100644
index 0000000000..d489c265d1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-futimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-lutimes-time64.c b/sysdeps/unix/sysv/linux/tst-lutimes-time64.c
new file mode 100644
index 0000000000..06caec0a91
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-lutimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-lutimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ppoll-time64.c b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
new file mode 100644
index 0000000000..96ee2faee3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
@@ -0,0 +1 @@
+#include "tst-ppoll.c"
diff --git a/sysdeps/unix/sysv/linux/tst-timerfd-time64.c b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
new file mode 100644
index 0000000000..bb17f48139
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
@@ -0,0 +1 @@
+#include "tst-timerfd.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utime-time64.c b/sysdeps/unix/sysv/linux/tst-utime-time64.c
new file mode 100644
index 0000000000..eb62f59126
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-utime-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utime.c b/sysdeps/unix/sysv/linux/tst-utime.c
index fe1869702c..532464a6e9 100644
--- a/sysdeps/unix/sysv/linux/tst-utime.c
+++ b/sysdeps/unix/sysv/linux/tst-utime.c
@@ -25,6 +25,10 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 char *testfile;
 
@@ -48,7 +52,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_utime_helper (const struct utimbuf *ut)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
diff --git a/sysdeps/unix/sysv/linux/tst-utimes-time64.c b/sysdeps/unix/sysv/linux/tst-utimes-time64.c
new file mode 100644
index 0000000000..234ec02541
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-utimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utimes.c b/sysdeps/unix/sysv/linux/tst-utimes.c
index db43660262..acf1af2023 100644
--- a/sysdeps/unix/sysv/linux/tst-utimes.c
+++ b/sysdeps/unix/sysv/linux/tst-utimes.c
@@ -24,6 +24,10 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 static char *testfile;
 
@@ -49,7 +53,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_utime_helper (const struct timeval *tv)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
diff --git a/sysvipc/Makefile b/sysvipc/Makefile
index a534791928..86911803b5 100644
--- a/sysvipc/Makefile
+++ b/sysvipc/Makefile
@@ -32,6 +32,8 @@ routines := ftok \
 
 tests    := test-sysvmsg test-sysvsem test-sysvshm
 
+tests-time64 := test-sysvmsg-time64 test-sysvsem-time64 test-sysvshm-time64
+
 include ../Rules
 
 CFLAGS-msgrcv.c += -fexceptions -fasynchronous-unwind-tables
diff --git a/sysvipc/test-sysvmsg-time64.c b/sysvipc/test-sysvmsg-time64.c
new file mode 100644
index 0000000000..c23e0c337e
--- /dev/null
+++ b/sysvipc/test-sysvmsg-time64.c
@@ -0,0 +1 @@
+#include "test-sysvmsg.c"
diff --git a/sysvipc/test-sysvsem-time64.c b/sysvipc/test-sysvsem-time64.c
new file mode 100644
index 0000000000..05c95068cd
--- /dev/null
+++ b/sysvipc/test-sysvsem-time64.c
@@ -0,0 +1 @@
+#include "test-sysvsem.c"
diff --git a/sysvipc/test-sysvshm-time64.c b/sysvipc/test-sysvshm-time64.c
new file mode 100644
index 0000000000..8e2963f563
--- /dev/null
+++ b/sysvipc/test-sysvshm-time64.c
@@ -0,0 +1 @@
+#include "test-sysvshm.c"
diff --git a/time/Makefile b/time/Makefile
index 29208f35c0..414721ecc5 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -51,6 +51,21 @@ tests	:= test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
 	   tst-adjtime tst-ctime tst-difftime tst-mktime4 tst-clock_settime \
 	   tst-itimer tst-gmtime tst-timegm tst-timespec_get
 
+tests-time64 := \
+  tst-adjtime-time64 \
+  tst-clock-time64 \
+  tst-clock2-time64 \
+  tst-clock_nanosleep-time64 \
+  tst-cpuclock1-time64 \
+  tst-ctime-time64 \
+  tst-difftime-time64 \
+  tst-gmtime-time64 \
+  tst-itimer-time64 \
+  tst-mktime4-time64 \
+  tst-timegm-time64 \
+  tst-timespec_get-time64 \
+  tst-y2039-time64
+
 include ../Rules
 
 ifeq ($(run-built-tests),yes)
diff --git a/time/tst-adjtime-time64.c b/time/tst-adjtime-time64.c
new file mode 100644
index 0000000000..097d6efc4b
--- /dev/null
+++ b/time/tst-adjtime-time64.c
@@ -0,0 +1 @@
+#include <tst-adjtime.c>
diff --git a/time/tst-clock-time64.c b/time/tst-clock-time64.c
new file mode 100644
index 0000000000..a1349678c8
--- /dev/null
+++ b/time/tst-clock-time64.c
@@ -0,0 +1 @@
+#include "tst-clock.c"
diff --git a/time/tst-clock2-time64.c b/time/tst-clock2-time64.c
new file mode 100644
index 0000000000..897f47b287
--- /dev/null
+++ b/time/tst-clock2-time64.c
@@ -0,0 +1 @@
+#include "tst-clock2.c"
diff --git a/time/tst-clock_nanosleep-time64.c b/time/tst-clock_nanosleep-time64.c
new file mode 100644
index 0000000000..c8638aa3d2
--- /dev/null
+++ b/time/tst-clock_nanosleep-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_nanosleep.c"
diff --git a/time/tst-cpuclock1-time64.c b/time/tst-cpuclock1-time64.c
new file mode 100644
index 0000000000..5a7ffa27ac
--- /dev/null
+++ b/time/tst-cpuclock1-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock1.c"
diff --git a/time/tst-ctime-time64.c b/time/tst-ctime-time64.c
new file mode 100644
index 0000000000..24a5ae98ed
--- /dev/null
+++ b/time/tst-ctime-time64.c
@@ -0,0 +1 @@
+#include "tst-ctime.c"
diff --git a/time/tst-ctime.c b/time/tst-ctime.c
index e89a906bf8..884d69bfa0 100644
--- a/time/tst-ctime.c
+++ b/time/tst-ctime.c
@@ -24,6 +24,7 @@ static int
 do_test (void)
 {
   char *str;
+  char strb[32];
   time_t t;
 
   /* Use glibc time zone extension "TZ=:" to to guarantee that UTC
@@ -36,11 +37,21 @@ do_test (void)
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
+
   /* Check if the max time value for 32 bit time_t can be converted.  */
   t = 0x7fffffff;
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
+
   /* Check if we run on port with 32 bit time_t size */
   time_t tov;
   if (__builtin_add_overflow (t, 1, &tov))
@@ -50,6 +61,11 @@ do_test (void)
   str = ctime (&tov);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&tov, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
+
   return 0;
 }
 
diff --git a/time/tst-difftime-time64.c b/time/tst-difftime-time64.c
new file mode 100644
index 0000000000..751ce6c483
--- /dev/null
+++ b/time/tst-difftime-time64.c
@@ -0,0 +1 @@
+#include "tst-difftime.c"
diff --git a/time/tst-gmtime-time64.c b/time/tst-gmtime-time64.c
new file mode 100644
index 0000000000..0df11c1913
--- /dev/null
+++ b/time/tst-gmtime-time64.c
@@ -0,0 +1 @@
+#include "tst-gmtime.c"
diff --git a/time/tst-itimer-time64.c b/time/tst-itimer-time64.c
new file mode 100644
index 0000000000..ddd2efa175
--- /dev/null
+++ b/time/tst-itimer-time64.c
@@ -0,0 +1 @@
+#include <time/tst-itimer.c>
diff --git a/time/tst-mktime4-time64.c b/time/tst-mktime4-time64.c
new file mode 100644
index 0000000000..bf5197c6f3
--- /dev/null
+++ b/time/tst-mktime4-time64.c
@@ -0,0 +1 @@
+#include "tst-mktime4.c"
diff --git a/time/tst-timegm-time64.c b/time/tst-timegm-time64.c
new file mode 100644
index 0000000000..8e3084f74e
--- /dev/null
+++ b/time/tst-timegm-time64.c
@@ -0,0 +1 @@
+#include "tst-timegm.c"
diff --git a/time/tst-timespec_get-time64.c b/time/tst-timespec_get-time64.c
new file mode 100644
index 0000000000..48f336385d
--- /dev/null
+++ b/time/tst-timespec_get-time64.c
@@ -0,0 +1 @@
+#include "tst-timespec_get.c"
diff --git a/time/tst-y2039-time64.c b/time/tst-y2039-time64.c
new file mode 100644
index 0000000000..3c8a504186
--- /dev/null
+++ b/time/tst-y2039-time64.c
@@ -0,0 +1 @@
+#include "tst-y2039.c"
diff --git a/time/tst-y2039.c b/time/tst-y2039.c
index ef024c0a77..66a22d4c2c 100644
--- a/time/tst-y2039.c
+++ b/time/tst-y2039.c
@@ -37,6 +37,16 @@ do_test (void)
 			> 0);
       puts (buf);
       TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
+
+      /* Same as before but for localtime_r.  */
+      struct tm tmd;
+      tm = localtime_r (&ouch, &tmd);
+      TEST_VERIFY_EXIT (tm == &tmd);
+
+      TEST_VERIFY_EXIT (strftime (buf, sizeof buf, "%Y-%m-%d %H:%M:%S %Z", tm)
+			> 0);
+      puts (buf);
+      TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
     }
   else
     FAIL_UNSUPPORTED ("32-bit time_t");


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [glibc/azanella/y2038] y2038: Add test coverage
@ 2021-02-26 20:44 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2021-02-26 20:44 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5787678cf216febc3702d1462dc708285c7fa264

commit 5787678cf216febc3702d1462dc708285c7fa264
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Feb 17 15:59:34 2021 -0300

    y2038: Add test coverage
    
    A new 'tests-y2038' rule is added, which adds the required 64 bit
    time flags and included in the 'tests' rule.
    
    The current coverage is:
    
      * libc:
        - adjtime
        - adjtimex
        - clock_adjtime
        - clock_getres                  tst-clock-time64, tst-cpuclock1-time64
        - clock_gettime                 tst-clock-time64, tst-clock2-time64,
                                        tst-cpuclock1-time64
        - clock_nanoslee                tst-clock_nanosleep-time64,
                                        tst-cpuclock1-time64
        - clock_settime                 tst-clock2-time64
        - ctime                         tst-ctime-time64
        - ctime_r                       tst-ctime-time64
        - difftime                      tst-difftime-time64
        - fstat                         tst-stat-time64
        - fstatat                       tst-stat-time64
        - futimens                      tst-futimens-time64
        - futimes
        - futimesat                     tst-futimesat-time64
        - getitimer
        - getrusage
        - gettimeofday                  tst-clock_nanosleep-time64
        - gmtime
        - gmtime_r
        - lstat                         tst-stat-time64
        - localtime                     tst-y2039-time64
        - localtime_t                   tst-y2039-time64
        - lutimes
        - mktime                        tst-mktime4-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - msgctl                        test-sysvmsg-time64
        - nanosleep                     tst-cpuclock{12}-time64,
                                        tst-mqueue8-time64, tst-clock-time64
        - ntp_adjtime
        - ntp_gettime
        - ntp_gettimex
        - ppoll                         tst-ppoll-time64
        - pselect                       tst-pselect-time64
        - recvmmsg                      tst-cancel4_2-time64
        - sched_rr_get_interval         tst-sched_rr_get_interval-time64
        - select
        - semctl                        test-sysvsem-time64
        - semtimedop                    test-sysvsem-time64
        - setitimer                     tst-mqueue2-time64
        - settimeofday
        - shmctl                        test-sysvshm-time64
        - sigtimedwait
        - stat                          tst-stat-time64
        - time                          tst-mqueue{1248}-time64
        - timegm
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
        - timerfd_gettime               tst-timerfd-time64
        - timerfd_settime               tst-timerfd-time64
        - timespec_get
        - utime                         tst-utime-time64
        - utimensat
        - utimes                        tst-utimes-time64
        - wait3
        - wait4                         tst-wait4-time64
    
      * libpthread:
        - cnd_timedwait                 tst-cnd-timedwait-time64
        - mtx_timedlock                 tst-mtx-timedlock-time64
        - pthread_clockjoin_np          tst-join14-time64
        - pthread_cond_clockwait        tst-cond11-time64
        - pthread_cond_timedwait        tst-abstime-time64
        - pthread_mutex_clocklock       tst-abstime-time64
        - pthread_mutex_timedlock       tst-abstime-time64
        - pthread_rwlock_clockrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_clockwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedrdlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_rwlock_timedwrlock    tst-abstime-time64, tst-rwlock14-time64
        - pthread_timedjoin_np          tst-join14-time64
        - sem_clockwait                 tst-sem5-time64
        - sem_timedwait                 tst-sem5-time64
        - thrd_sleep                    tst-thrd-sleep-time64
    
      * librt:
        - aio_suspend                   tst-aio6-time64
        - mq_timedreceive               tst-mqueue{1248}-time64
        - mq_timedsend                  tst-mqueue{1248}-time64
        - timer_gettime                 tst-timer4-time64
        - timer_settime                 tst-timer4-time64
    
      * libanl:
        - gai_suspend

Diff:
---
 Makerules                                     |  23 +++++-
 io/Makefile                                   |   3 +
 io/tst-futimesat-time64.c                     |   4 +
 io/tst-futimesat.c                            |  47 ++++++++----
 io/tst-stat-time64.c                          | 102 ++++++++++++++++++++++++++
 misc/Makefile                                 |   2 +
 misc/tst-pselect-time64.c                     |   1 +
 nptl/Makefile                                 |   3 +
 nptl/tst-cancel4_2-time64.c                   |   1 +
 posix/Makefile                                |   2 +
 posix/tst-sched_rr_get_interval-time64.c      |   1 +
 posix/tst-wait4-time64.c                      |   1 +
 rt/Makefile                                   |   9 +++
 rt/tst-aio6-time64.c                          |   1 +
 rt/tst-cpuclock2-time64.c                     |   1 +
 rt/tst-cpuclock2.c                            |   9 ++-
 rt/tst-mqueue1-time64.c                       |   1 +
 rt/tst-mqueue2-time64.c                       |   1 +
 rt/tst-mqueue4-time64.c                       |   1 +
 rt/tst-mqueue8-time64.c                       |   1 +
 rt/tst-timer4-time64.c                        |   1 +
 sysdeps/pthread/Makefile                      |  10 +++
 sysdeps/pthread/tst-abstime-time64.c          |   1 +
 sysdeps/pthread/tst-cnd-timedwait-time64.c    |   1 +
 sysdeps/pthread/tst-cond11-time64.c           |   1 +
 sysdeps/pthread/tst-join14-time64.c           |   1 +
 sysdeps/pthread/tst-mtx-timedlock-time64.c    |   1 +
 sysdeps/pthread/tst-rwlock14-time64.c         |   1 +
 sysdeps/pthread/tst-sem5-time64.c             |   1 +
 sysdeps/pthread/tst-thrd-sleep-time64.c       |   1 +
 sysdeps/unix/sysv/linux/Makefile              |   6 ++
 sysdeps/unix/sysv/linux/Versions              |   4 +-
 sysdeps/unix/sysv/linux/tst-futimens-time64.c |   2 +
 sysdeps/unix/sysv/linux/tst-futimens.c        |  10 ++-
 sysdeps/unix/sysv/linux/tst-ppoll-time64.c    |   1 +
 sysdeps/unix/sysv/linux/tst-timerfd-time64.c  |   1 +
 sysdeps/unix/sysv/linux/tst-utime-time64.c    |   2 +
 sysdeps/unix/sysv/linux/tst-utime.c           |   6 +-
 sysdeps/unix/sysv/linux/tst-utimes-time64.c   |   2 +
 sysdeps/unix/sysv/linux/tst-utimes.c          |   6 +-
 sysvipc/Makefile                              |   2 +
 sysvipc/test-sysvmsg-time64.c                 |   1 +
 sysvipc/test-sysvsem-time64.c                 |   1 +
 sysvipc/test-sysvshm-time64.c                 |   1 +
 time/Makefile                                 |  10 +++
 time/tst-clock-time64.c                       |   1 +
 time/tst-clock2-time64.c                      |   1 +
 time/tst-clock_nanosleep-time64.c             |   1 +
 time/tst-cpuclock1-time64.c                   |   1 +
 time/tst-ctime-time64.c                       |   1 +
 time/tst-ctime.c                              |  16 ++++
 time/tst-difftime-time64.c                    |   1 +
 time/tst-mktime4-time64.c                     |   1 +
 time/tst-y2039-time64.c                       |   1 +
 time/tst-y2039.c                              |  10 +++
 55 files changed, 299 insertions(+), 23 deletions(-)

diff --git a/Makerules b/Makerules
index fc5251ffad..aca5d1f4d7 100644
--- a/Makerules
+++ b/Makerules
@@ -771,7 +771,8 @@ endif
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
 	     $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
-	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs))
+	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) \
+		$(test-srcs) $(tests-time64) $(xtests-time64))
 ifeq ($(build-programs),yes)
 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
 endif
@@ -1286,6 +1287,26 @@ check: tests
 .PHONY: xcheck
 xcheck: xtests
 
+# Handle tests-time64 and xtests-time64 that should built with LFS
+# and 64-bit time support.
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(tests-time64),$(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+tests += $(foreach t,$(tests-time64),$(t))
+
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(xtests-time64),$(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+xtests += $(foreach t,$(xtests-time64),$(t))
+
 # The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
 # that almost all internal declarations from config.h, libc-symbols.h, and
 # include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
diff --git a/io/Makefile b/io/Makefile
index b7bebe923f..8c86335790 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -70,6 +70,9 @@ tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-ftw-lnk tst-file_change_detection tst-lchmod \
 		   tst-ftw-bz26353
 
+tests-time64    := tst-stat-time64 \
+		   tst-futimesat-time64
+
 # Likewise for statx, but we do not need static linking here.
 tests-internal += tst-statx
 tests-static += tst-statx
diff --git a/io/tst-futimesat-time64.c b/io/tst-futimesat-time64.c
new file mode 100644
index 0000000000..f6c0500eef
--- /dev/null
+++ b/io/tst-futimesat-time64.c
@@ -0,0 +1,4 @@
+#define struct_stat  struct stat
+#define fstat        fstat
+#define fstatat      fstatat
+#include "io/tst-futimesat.c"
diff --git a/io/tst-futimesat.c b/io/tst-futimesat.c
index af58ad06dd..c32ab2b668 100644
--- a/io/tst-futimesat.c
+++ b/io/tst-futimesat.c
@@ -1,4 +1,23 @@
+/* futimesat basic tests.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
 #include <dirent.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -7,19 +26,19 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#include <support/test-driver.h>
+#include <support/temp_file.h>
 
-static void prepare (void);
-#define PREPARE(argc, argv) prepare ()
-
-static int do_test (void);
-#define TEST_FUNCTION do_test ()
-
-#include "../test-skeleton.c"
+#ifndef struct_stat
+# define struct_stat struct stat64
+# define fstat       fstat64
+# define fstatat     fstatat64
+#endif
 
 static int dir_fd;
 
 static void
-prepare (void)
+prepare (int argc, char *argv[])
 {
   size_t test_dir_len = strlen (test_dir);
   static const char dir_name[] = "/tst-futimesat.XXXXXX";
@@ -48,7 +67,7 @@ prepare (void)
       exit (1);
     }
 }
-
+#define PREPARE prepare
 
 static int
 do_test (void)
@@ -98,8 +117,8 @@ do_test (void)
   write (fd, "hello", 5);
   puts ("file created");
 
-  struct stat64 st1;
-  if (fstat64 (fd, &st1) != 0)
+  struct_stat st1;
+  if (fstat (fd, &st1) != 0)
     {
       puts ("fstat64 failed");
       return 1;
@@ -118,8 +137,8 @@ do_test (void)
       return 1;
     }
 
-  struct stat64 st2;
-  if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0)
+  struct_stat st2;
+  if (fstatat (dir_fd, "some-file", &st2, 0) != 0)
     {
       puts ("fstatat64 failed");
       return 1;
@@ -146,3 +165,5 @@ do_test (void)
 
   return 0;
 }
+
+#include <support/test-driver.c>
diff --git a/io/tst-stat-time64.c b/io/tst-stat-time64.c
new file mode 100644
index 0000000000..c10fe1284a
--- /dev/null
+++ b/io/tst-stat-time64.c
@@ -0,0 +1,102 @@
+/* Basic test of stat with 64 bit time_t interfaces.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <support/check.h>
+#include <support/support.h>
+#include <support/temp_file.h>
+#include <support/xunistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+
+/* The idea of the test is check whether the 64 bit time_t stat implementation
+   returns the expected value for comparable fields, so it does not really
+   matter whether statx uses a fallback implementation or not.  */
+
+static void
+stat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (stat (path, st), 0);
+}
+
+static void
+lstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (lstat (path, st), 0);
+}
+
+static void
+fstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstat (fd, st), 0);
+}
+
+static void
+fstatat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstatat (fd, path, st, 0), 0);
+}
+
+typedef void (*test_t)(int, const char *path, struct stat *);
+
+static int
+do_test (void)
+{
+  char *path;
+  int fd = create_temp_file ("tst-statx-", &path);
+  TEST_VERIFY_EXIT (fd >= 0);
+  support_write_file_string (path, "abc");
+
+  struct statx stx;
+  TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0);
+
+  for (test_t *test = (test_t[]) { stat_check, lstat_check, fstat_check,
+				   fstatat_check, NULL };
+       *test != NULL; test++)
+  {
+    struct stat st;
+    (*test) (fd, path, &st);
+
+    TEST_COMPARE (stx.stx_dev_major, major (st.st_dev));
+    TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev));
+    TEST_COMPARE (stx.stx_ino, st.st_ino);
+    TEST_COMPARE (stx.stx_mode, st.st_mode);
+    TEST_COMPARE (stx.stx_nlink, st.st_nlink);
+    TEST_COMPARE (stx.stx_uid, st.st_uid);
+    TEST_COMPARE (stx.stx_gid, st.st_gid);
+    TEST_COMPARE (stx.stx_rdev_major, major (st.st_rdev));
+    TEST_COMPARE (stx.stx_rdev_minor, minor (st.st_rdev));
+    TEST_COMPARE (stx.stx_blksize, st.st_blksize);
+    TEST_COMPARE (stx.stx_blocks, st.st_blocks);
+
+    TEST_COMPARE (stx.stx_ctime.tv_sec, st.st_ctim.tv_sec);
+    TEST_COMPARE (stx.stx_ctime.tv_nsec, st.st_ctim.tv_nsec);
+    TEST_COMPARE (stx.stx_mtime.tv_sec, st.st_mtim.tv_sec);
+    TEST_COMPARE (stx.stx_mtime.tv_nsec, st.st_mtim.tv_nsec);
+  }
+
+  xclose (fd);
+  free (path);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/misc/Makefile b/misc/Makefile
index b08d7c68ab..3c4a70d3a7 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -90,6 +90,8 @@ tests := tst-dirname tst-tsearch tst-fdset tst-mntent tst-hsearch \
 	 tst-ldbl-warn tst-ldbl-error tst-dbl-efgcvt tst-ldbl-efgcvt \
 	 tst-mntent-autofs tst-syscalls tst-mntent-escape
 
+tests-time64 := tst-pselect-time64
+
 # Tests which need libdl.
 ifeq (yes,$(build-shared))
 tests += tst-gethostid
diff --git a/misc/tst-pselect-time64.c b/misc/tst-pselect-time64.c
new file mode 100644
index 0000000000..15a1e49292
--- /dev/null
+++ b/misc/tst-pselect-time64.c
@@ -0,0 +1 @@
+#include "tst-pselect.c"
diff --git a/nptl/Makefile b/nptl/Makefile
index 5f85dd7854..0a0e8d360c 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -380,6 +380,9 @@ xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
 	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10 tst-setgroups \
 	tst-mutexpp5 tst-mutexpp9
 
+tests-time64 := \
+  tst-cancel4_2-time64
+
 # This test can run into task limits because of a linux kernel bug
 # and then cause the make process to fail too, see bug 24537.
 xtests += tst-eintr1
diff --git a/nptl/tst-cancel4_2-time64.c b/nptl/tst-cancel4_2-time64.c
new file mode 100644
index 0000000000..4ac086a312
--- /dev/null
+++ b/nptl/tst-cancel4_2-time64.c
@@ -0,0 +1 @@
+#include "tst-cancel4_2.c"
diff --git a/posix/Makefile b/posix/Makefile
index 239fbb340a..5bb2a71f48 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -108,7 +108,9 @@ tests-internal	:= bug-regex5 bug-regex20 bug-regex33 \
 		   tst-rfc3484 tst-rfc3484-2 tst-rfc3484-3 \
 		   tst-glob_lstat_compat tst-spawn4-compat
 tests-container := bug-ga2
+tests-time64	:= tst-wait4-time64
 xtests		:= tst-getaddrinfo4 tst-getaddrinfo5 tst-sched_rr_get_interval
+xtests-time64	:= tst-sched_rr_get_interval-time64
 ifeq (yes,$(build-shared))
 test-srcs	:= globtest
 tests           += wordexp-test tst-exec tst-spawn tst-spawn2 tst-spawn3
diff --git a/posix/tst-sched_rr_get_interval-time64.c b/posix/tst-sched_rr_get_interval-time64.c
new file mode 100644
index 0000000000..f4e66d2939
--- /dev/null
+++ b/posix/tst-sched_rr_get_interval-time64.c
@@ -0,0 +1 @@
+#include "tst-sched_rr_get_interval.c"
diff --git a/posix/tst-wait4-time64.c b/posix/tst-wait4-time64.c
new file mode 100644
index 0000000000..12543b270f
--- /dev/null
+++ b/posix/tst-wait4-time64.c
@@ -0,0 +1 @@
+#include "tst-wait4.c"
diff --git a/rt/Makefile b/rt/Makefile
index 7b374f2073..3ce98297f9 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -49,6 +49,15 @@ tests := tst-shm tst-timer tst-timer2 \
 	 tst-shm-cancel
 tests-internal := tst-timer-sigmask
 
+tests-time64 := \
+  tst-aio6-time64 \
+  tst-cpuclock2-time64 \
+  tst-mqueue1-time64 \
+  tst-mqueue2-time64 \
+  tst-mqueue4-time64 \
+  tst-mqueue8-time64 \
+  tst-timer4-time64
+
 extra-libs := librt
 extra-libs-others := $(extra-libs)
 
diff --git a/rt/tst-aio6-time64.c b/rt/tst-aio6-time64.c
new file mode 100644
index 0000000000..a386a577ec
--- /dev/null
+++ b/rt/tst-aio6-time64.c
@@ -0,0 +1 @@
+#include "tst-aio6.c"
diff --git a/rt/tst-cpuclock2-time64.c b/rt/tst-cpuclock2-time64.c
new file mode 100644
index 0000000000..05775522bb
--- /dev/null
+++ b/rt/tst-cpuclock2-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock2.c"
diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c
index c1c7ed2ad8..eebc3609d0 100644
--- a/rt/tst-cpuclock2.c
+++ b/rt/tst-cpuclock2.c
@@ -21,7 +21,11 @@
 
 #if (_POSIX_THREADS - 0) <= 0
 
-# define TEST_FUNCTION 0
+static int
+do_test ()
+{
+  return 0;
+}
 
 #else
 
@@ -330,7 +334,6 @@ do_test (void)
 
   return result;
 }
-# define TEST_FUNCTION do_test ()
 #endif
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/rt/tst-mqueue1-time64.c b/rt/tst-mqueue1-time64.c
new file mode 100644
index 0000000000..9c600a9a97
--- /dev/null
+++ b/rt/tst-mqueue1-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue1.c"
diff --git a/rt/tst-mqueue2-time64.c b/rt/tst-mqueue2-time64.c
new file mode 100644
index 0000000000..9d49f0b196
--- /dev/null
+++ b/rt/tst-mqueue2-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue2.c"
diff --git a/rt/tst-mqueue4-time64.c b/rt/tst-mqueue4-time64.c
new file mode 100644
index 0000000000..c23a228dc4
--- /dev/null
+++ b/rt/tst-mqueue4-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue4.c"
diff --git a/rt/tst-mqueue8-time64.c b/rt/tst-mqueue8-time64.c
new file mode 100644
index 0000000000..972637f7f5
--- /dev/null
+++ b/rt/tst-mqueue8-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue8.c"
diff --git a/rt/tst-timer4-time64.c b/rt/tst-timer4-time64.c
new file mode 100644
index 0000000000..e47a593f10
--- /dev/null
+++ b/rt/tst-timer4-time64.c
@@ -0,0 +1 @@
+#include "tst-timer4.c"
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index eeb64f9fb0..d4bfe2aee5 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -109,6 +109,16 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
 	 tst-unwind-thread \
 	 tst-pt-vfork1 tst-pt-vfork2 tst-vfork1x tst-vfork2x \
 
+tests-time64 := \
+  tst-abstime-time64 \
+  tst-cnd-timedwait-time64 \
+  tst-cond11-time64 \
+  tst-join14-time64 \
+  tst-mtx-timedlock-time64 \
+  tst-rwlock14-time64 \
+  tst-sem5-time64 \
+  tst-thrd-sleep-time64 \
+
 
 # Files which must not be linked with libpthread.
 tests-nolibpthread = tst-unload
diff --git a/sysdeps/pthread/tst-abstime-time64.c b/sysdeps/pthread/tst-abstime-time64.c
new file mode 100644
index 0000000000..2fc77cb365
--- /dev/null
+++ b/sysdeps/pthread/tst-abstime-time64.c
@@ -0,0 +1 @@
+#include "tst-abstime.c"
diff --git a/sysdeps/pthread/tst-cnd-timedwait-time64.c b/sysdeps/pthread/tst-cnd-timedwait-time64.c
new file mode 100644
index 0000000000..9b2abfd277
--- /dev/null
+++ b/sysdeps/pthread/tst-cnd-timedwait-time64.c
@@ -0,0 +1 @@
+#include "tst-cnd-timedwait.c"
diff --git a/sysdeps/pthread/tst-cond11-time64.c b/sysdeps/pthread/tst-cond11-time64.c
new file mode 100644
index 0000000000..9bccb8ec8b
--- /dev/null
+++ b/sysdeps/pthread/tst-cond11-time64.c
@@ -0,0 +1 @@
+#include "tst-cond11.c"
diff --git a/sysdeps/pthread/tst-join14-time64.c b/sysdeps/pthread/tst-join14-time64.c
new file mode 100644
index 0000000000..bed784ee24
--- /dev/null
+++ b/sysdeps/pthread/tst-join14-time64.c
@@ -0,0 +1 @@
+#include "tst-join14.c"
diff --git a/sysdeps/pthread/tst-mtx-timedlock-time64.c b/sysdeps/pthread/tst-mtx-timedlock-time64.c
new file mode 100644
index 0000000000..b3393c99ef
--- /dev/null
+++ b/sysdeps/pthread/tst-mtx-timedlock-time64.c
@@ -0,0 +1 @@
+#include "tst-mtx-timedlock.c"
diff --git a/sysdeps/pthread/tst-rwlock14-time64.c b/sysdeps/pthread/tst-rwlock14-time64.c
new file mode 100644
index 0000000000..ae9b1912cf
--- /dev/null
+++ b/sysdeps/pthread/tst-rwlock14-time64.c
@@ -0,0 +1 @@
+#include "tst-rwlock14.c"
diff --git a/sysdeps/pthread/tst-sem5-time64.c b/sysdeps/pthread/tst-sem5-time64.c
new file mode 100644
index 0000000000..89c2a14f94
--- /dev/null
+++ b/sysdeps/pthread/tst-sem5-time64.c
@@ -0,0 +1 @@
+#include "tst-sem5.c"
diff --git a/sysdeps/pthread/tst-thrd-sleep-time64.c b/sysdeps/pthread/tst-thrd-sleep-time64.c
new file mode 100644
index 0000000000..02837bd19f
--- /dev/null
+++ b/sysdeps/pthread/tst-thrd-sleep-time64.c
@@ -0,0 +1 @@
+#include "tst-thrd-sleep.c"
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index a15398afdb..13e8fe1575 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -114,6 +114,12 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
 	 tst-timerfd tst-ppoll tst-futimens tst-clock_adjtime tst-utime \
 	 tst-utimes
 tests-internal += tst-ofdlocks-compat tst-sigcontext-get_pc
+tests-time64 += \
+  tst-futimens-time64 \
+  tst-ppoll-time64 \
+  tst-utime-time64 \
+  tst-utimes-time64 \
+  tst-timerfd-time64
 
 CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
 
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index 45d31a46bc..627f2cbf9d 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -228,7 +228,9 @@ libc {
     __timegm64;
     __timespec_get64;
     __utimensat64;
-     __utimes64;
+    __utimes64;
+    __localtime64;
+    __localtime64_r;
     # misc
     __ntp_gettime64;
     __ntp_gettimex64;
diff --git a/sysdeps/unix/sysv/linux/tst-futimens-time64.c b/sysdeps/unix/sysv/linux/tst-futimens-time64.c
new file mode 100644
index 0000000000..88fcb38489
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-futimens-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimens.c"
diff --git a/sysdeps/unix/sysv/linux/tst-futimens.c b/sysdeps/unix/sysv/linux/tst-futimens.c
index 522c84d896..96775de65e 100644
--- a/sysdeps/unix/sysv/linux/tst-futimens.c
+++ b/sysdeps/unix/sysv/linux/tst-futimens.c
@@ -23,10 +23,14 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 
 /* struct timespec array with Y2038 threshold minus 2 and 1 seconds.  */
-const struct timespec t1[2] = { { 0x7FFFFFFE, 0 },  { 0x7FFFFFFF, 0 } };
+const static struct timespec t1[2] = { { 0x7FFFFFFE, 0 },  { 0x7FFFFFFF, 0 } };
 
 #define PREPARE do_prepare
 static void
@@ -39,7 +43,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_futimens_helper (const struct timespec *ts)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
@@ -47,7 +51,7 @@ test_futimens_helper (const struct timespec *ts)
   if (__builtin_add_overflow (ts->tv_sec, 0, &t))
     return 0;
 
-  result = futimens(temp_fd, ts);
+  result = futimens (temp_fd, ts);
   TEST_VERIFY_EXIT (result == 0);
 
   xfstat (temp_fd, &st);
diff --git a/sysdeps/unix/sysv/linux/tst-ppoll-time64.c b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
new file mode 100644
index 0000000000..96ee2faee3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
@@ -0,0 +1 @@
+#include "tst-ppoll.c"
diff --git a/sysdeps/unix/sysv/linux/tst-timerfd-time64.c b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
new file mode 100644
index 0000000000..bb17f48139
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
@@ -0,0 +1 @@
+#include "tst-timerfd.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utime-time64.c b/sysdeps/unix/sysv/linux/tst-utime-time64.c
new file mode 100644
index 0000000000..eb62f59126
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-utime-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utime.c b/sysdeps/unix/sysv/linux/tst-utime.c
index fe1869702c..532464a6e9 100644
--- a/sysdeps/unix/sysv/linux/tst-utime.c
+++ b/sysdeps/unix/sysv/linux/tst-utime.c
@@ -25,6 +25,10 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 char *testfile;
 
@@ -48,7 +52,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_utime_helper (const struct utimbuf *ut)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
diff --git a/sysdeps/unix/sysv/linux/tst-utimes-time64.c b/sysdeps/unix/sysv/linux/tst-utimes-time64.c
new file mode 100644
index 0000000000..234ec02541
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-utimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimes.c"
diff --git a/sysdeps/unix/sysv/linux/tst-utimes.c b/sysdeps/unix/sysv/linux/tst-utimes.c
index db43660262..acf1af2023 100644
--- a/sysdeps/unix/sysv/linux/tst-utimes.c
+++ b/sysdeps/unix/sysv/linux/tst-utimes.c
@@ -24,6 +24,10 @@
 #include <support/xunistd.h>
 #include <support/temp_file.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int temp_fd = -1;
 static char *testfile;
 
@@ -49,7 +53,7 @@ do_prepare (int argc, char *argv[])
 static int
 test_utime_helper (const struct timeval *tv)
 {
-  struct stat64 st;
+  struct_stat st;
   int result;
   time_t t;
 
diff --git a/sysvipc/Makefile b/sysvipc/Makefile
index a534791928..86911803b5 100644
--- a/sysvipc/Makefile
+++ b/sysvipc/Makefile
@@ -32,6 +32,8 @@ routines := ftok \
 
 tests    := test-sysvmsg test-sysvsem test-sysvshm
 
+tests-time64 := test-sysvmsg-time64 test-sysvsem-time64 test-sysvshm-time64
+
 include ../Rules
 
 CFLAGS-msgrcv.c += -fexceptions -fasynchronous-unwind-tables
diff --git a/sysvipc/test-sysvmsg-time64.c b/sysvipc/test-sysvmsg-time64.c
new file mode 100644
index 0000000000..c23e0c337e
--- /dev/null
+++ b/sysvipc/test-sysvmsg-time64.c
@@ -0,0 +1 @@
+#include "test-sysvmsg.c"
diff --git a/sysvipc/test-sysvsem-time64.c b/sysvipc/test-sysvsem-time64.c
new file mode 100644
index 0000000000..05c95068cd
--- /dev/null
+++ b/sysvipc/test-sysvsem-time64.c
@@ -0,0 +1 @@
+#include "test-sysvsem.c"
diff --git a/sysvipc/test-sysvshm-time64.c b/sysvipc/test-sysvshm-time64.c
new file mode 100644
index 0000000000..8e2963f563
--- /dev/null
+++ b/sysvipc/test-sysvshm-time64.c
@@ -0,0 +1 @@
+#include "test-sysvshm.c"
diff --git a/time/Makefile b/time/Makefile
index b3c5368c3b..81cbed9c02 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -50,6 +50,16 @@ tests	:= test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
 	   tst-clock tst-clock2 tst-clock_nanosleep tst-cpuclock1 \
 	   tst-adjtime tst-ctime tst-difftime tst-mktime4 tst-clock_settime
 
+tests-time64 := \
+  tst-clock-time64 \
+  tst-clock2-time64 \
+  tst-clock_nanosleep-time64 \
+  tst-cpuclock1-time64 \
+  tst-ctime-time64 \
+  tst-difftime-time64 \
+  tst-mktime4-time64 \
+  tst-y2039-time64
+
 include ../Rules
 
 ifeq ($(run-built-tests),yes)
diff --git a/time/tst-clock-time64.c b/time/tst-clock-time64.c
new file mode 100644
index 0000000000..a1349678c8
--- /dev/null
+++ b/time/tst-clock-time64.c
@@ -0,0 +1 @@
+#include "tst-clock.c"
diff --git a/time/tst-clock2-time64.c b/time/tst-clock2-time64.c
new file mode 100644
index 0000000000..897f47b287
--- /dev/null
+++ b/time/tst-clock2-time64.c
@@ -0,0 +1 @@
+#include "tst-clock2.c"
diff --git a/time/tst-clock_nanosleep-time64.c b/time/tst-clock_nanosleep-time64.c
new file mode 100644
index 0000000000..c8638aa3d2
--- /dev/null
+++ b/time/tst-clock_nanosleep-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_nanosleep.c"
diff --git a/time/tst-cpuclock1-time64.c b/time/tst-cpuclock1-time64.c
new file mode 100644
index 0000000000..5a7ffa27ac
--- /dev/null
+++ b/time/tst-cpuclock1-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock1.c"
diff --git a/time/tst-ctime-time64.c b/time/tst-ctime-time64.c
new file mode 100644
index 0000000000..24a5ae98ed
--- /dev/null
+++ b/time/tst-ctime-time64.c
@@ -0,0 +1 @@
+#include "tst-ctime.c"
diff --git a/time/tst-ctime.c b/time/tst-ctime.c
index e89a906bf8..884d69bfa0 100644
--- a/time/tst-ctime.c
+++ b/time/tst-ctime.c
@@ -24,6 +24,7 @@ static int
 do_test (void)
 {
   char *str;
+  char strb[32];
   time_t t;
 
   /* Use glibc time zone extension "TZ=:" to to guarantee that UTC
@@ -36,11 +37,21 @@ do_test (void)
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
+
   /* Check if the max time value for 32 bit time_t can be converted.  */
   t = 0x7fffffff;
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
+
   /* Check if we run on port with 32 bit time_t size */
   time_t tov;
   if (__builtin_add_overflow (t, 1, &tov))
@@ -50,6 +61,11 @@ do_test (void)
   str = ctime (&tov);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&tov, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
+
   return 0;
 }
 
diff --git a/time/tst-difftime-time64.c b/time/tst-difftime-time64.c
new file mode 100644
index 0000000000..751ce6c483
--- /dev/null
+++ b/time/tst-difftime-time64.c
@@ -0,0 +1 @@
+#include "tst-difftime.c"
diff --git a/time/tst-mktime4-time64.c b/time/tst-mktime4-time64.c
new file mode 100644
index 0000000000..bf5197c6f3
--- /dev/null
+++ b/time/tst-mktime4-time64.c
@@ -0,0 +1 @@
+#include "tst-mktime4.c"
diff --git a/time/tst-y2039-time64.c b/time/tst-y2039-time64.c
new file mode 100644
index 0000000000..3c8a504186
--- /dev/null
+++ b/time/tst-y2039-time64.c
@@ -0,0 +1 @@
+#include "tst-y2039.c"
diff --git a/time/tst-y2039.c b/time/tst-y2039.c
index ef024c0a77..66a22d4c2c 100644
--- a/time/tst-y2039.c
+++ b/time/tst-y2039.c
@@ -37,6 +37,16 @@ do_test (void)
 			> 0);
       puts (buf);
       TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
+
+      /* Same as before but for localtime_r.  */
+      struct tm tmd;
+      tm = localtime_r (&ouch, &tmd);
+      TEST_VERIFY_EXIT (tm == &tmd);
+
+      TEST_VERIFY_EXIT (strftime (buf, sizeof buf, "%Y-%m-%d %H:%M:%S %Z", tm)
+			> 0);
+      puts (buf);
+      TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
     }
   else
     FAIL_UNSUPPORTED ("32-bit time_t");


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [glibc/azanella/y2038] y2038: Add test coverage
@ 2021-02-23 20:41 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2021-02-23 20:41 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2da1ca6bc2497a6b6836a1bd628375f4c7933c37

commit 2da1ca6bc2497a6b6836a1bd628375f4c7933c37
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Feb 17 15:59:34 2021 -0300

    y2038: Add test coverage
    
    A new 'tests-y2038' rule is added, which adds the required 64 bit
    time flags and included in the 'tests' rule.
    
    The current coverage is:
    
      * libc:
        - adjtime
        - adjtimex
        - clock_adjtime
        - clock_getres                      tst-clock, tst-cpuclock1
        - clock_gettime                     tst-clock, tst-clock2, tst-cpuclock1
        - clock_nanosleep                   tst-clock_nanosleep, tst-cpuclock1
        - clock_settime                     tst-clock2
        - ctime                             tst-ctime
        - ctime_r
        - difftime                          tst-difftime
        - fstat
        - fstatat
        - futimens
        - futimes
        - futimesat
        - getitimer
        - getrusage
        - gettimeofday                      tst-clock_nanosleep
        - gmtime
        - gmtime_r
        - lstat
        - lutimes
        - mktime
        - mq_timedreceive                   tst-mqueue{1248}
        - mq_timedsend                      tst-mqueue{1248}
        - nanosleep                         tst-cpuclock2, tst-mqueue8, tst-clock, tst-cpuclock1
        - ntp_adjtime
        - ntp_gettime
        - ntp_gettimex
        - ppoll64
        - pselect
        - recvmmsg                          tst-cancel4_2
        - sched_rr_get_interval
        - select
        - semtimedop
        - setitimer
        - settimeofday
        - sigtimedwait
        - stat
        - time                              tst-mqueue1, tst-mqueue2, tst-mqueue4, tst-mqueue8
        - timegm
        - timer_gettime                     tst-timer4
        - timer_settime
        - timerfd_gettime
        - timerfd_settime
        - timespec_get
        - utime
        - utimensat
        - utimes
        - wait3
        - wait4_time64
    
      * libpthread:
        - cnd_timedwait
        - mtx_timedlock
        - 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
        - sem_clockwait
        - sem_timedwait
        - thrd_sleep
    
      * librt:
        - aio_suspend
        - mq_timedreceive                   tst-mqueue{1248}
        - mq_timedsend                      tst-mqueue{1248}
        - timer_gettime                     tst-timer4
        - timer_settime                     tst-timer4
    
      * libanl:
        - gai_suspend_time

Diff:
---
 Makerules                        | 13 ++++++++++++-
 nptl/Makefile                    |  3 +++
 nptl/tst-cancel4_2-y2038.c       |  1 +
 rt/Makefile                      |  8 ++++++++
 rt/tst-cpuclock2-y2038.c         |  1 +
 rt/tst-cpuclock2.c               |  9 ++++++---
 rt/tst-mqueue1-y2038.c           |  1 +
 rt/tst-mqueue2-y2038.c           |  1 +
 rt/tst-mqueue4-y2038.c           |  1 +
 rt/tst-mqueue8-y2038.c           |  1 +
 rt/tst-timer4-y2038.c            |  1 +
 time/Makefile                    |  9 +++++++++
 time/tst-clock-y2038.c           |  1 +
 time/tst-clock2-y2038.c          |  1 +
 time/tst-clock_nanosleep-y2038.c |  1 +
 time/tst-cpuclock1-y2038.c       |  1 +
 time/tst-ctime-y2038.c           |  1 +
 time/tst-difftime-y2038.c        |  1 +
 time/tst-mktime4-y2038.c         |  1 +
 19 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/Makerules b/Makerules
index fc5251ffad..0917a0d463 100644
--- a/Makerules
+++ b/Makerules
@@ -771,7 +771,7 @@ endif
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
 	     $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
-	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs))
+	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs) $(tests-y2038))
 ifeq ($(build-programs),yes)
 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
 endif
@@ -1286,6 +1286,17 @@ check: tests
 .PHONY: xcheck
 xcheck: xtests
 
+# Handle tests-y2038 tests they should be built with LFS and 64-bit time
+# support.
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(tests-y2038),$(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+tests += $(foreach t,$(tests-y2038),$(t))
+
 # The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
 # that almost all internal declarations from config.h, libc-symbols.h, and
 # include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
diff --git a/nptl/Makefile b/nptl/Makefile
index 4dd9c6a6a8..3b75590acb 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -375,6 +375,9 @@ xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
 	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10 tst-setgroups \
 	tst-mutexpp5 tst-mutexpp9
 
+tests-y2038 := \
+  tst-cancel4_2-y2038
+
 # This test can run into task limits because of a linux kernel bug
 # and then cause the make process to fail too, see bug 24537.
 xtests += tst-eintr1
diff --git a/nptl/tst-cancel4_2-y2038.c b/nptl/tst-cancel4_2-y2038.c
new file mode 100644
index 0000000000..4ac086a312
--- /dev/null
+++ b/nptl/tst-cancel4_2-y2038.c
@@ -0,0 +1 @@
+#include "tst-cancel4_2.c"
diff --git a/rt/Makefile b/rt/Makefile
index 7b374f2073..5d037ea368 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -49,6 +49,14 @@ tests := tst-shm tst-timer tst-timer2 \
 	 tst-shm-cancel
 tests-internal := tst-timer-sigmask
 
+tests-y2038 := \
+  tst-cpuclock2-y2038 \
+  tst-mqueue1-y2038 \
+  tst-mqueue2-y2038 \
+  tst-mqueue4-y2038 \
+  tst-mqueue8-y2038 \
+  tst-timer4-y2038
+
 extra-libs := librt
 extra-libs-others := $(extra-libs)
 
diff --git a/rt/tst-cpuclock2-y2038.c b/rt/tst-cpuclock2-y2038.c
new file mode 100644
index 0000000000..05775522bb
--- /dev/null
+++ b/rt/tst-cpuclock2-y2038.c
@@ -0,0 +1 @@
+#include "tst-cpuclock2.c"
diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c
index c1c7ed2ad8..eebc3609d0 100644
--- a/rt/tst-cpuclock2.c
+++ b/rt/tst-cpuclock2.c
@@ -21,7 +21,11 @@
 
 #if (_POSIX_THREADS - 0) <= 0
 
-# define TEST_FUNCTION 0
+static int
+do_test ()
+{
+  return 0;
+}
 
 #else
 
@@ -330,7 +334,6 @@ do_test (void)
 
   return result;
 }
-# define TEST_FUNCTION do_test ()
 #endif
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/rt/tst-mqueue1-y2038.c b/rt/tst-mqueue1-y2038.c
new file mode 100644
index 0000000000..9c600a9a97
--- /dev/null
+++ b/rt/tst-mqueue1-y2038.c
@@ -0,0 +1 @@
+#include "tst-mqueue1.c"
diff --git a/rt/tst-mqueue2-y2038.c b/rt/tst-mqueue2-y2038.c
new file mode 100644
index 0000000000..9d49f0b196
--- /dev/null
+++ b/rt/tst-mqueue2-y2038.c
@@ -0,0 +1 @@
+#include "tst-mqueue2.c"
diff --git a/rt/tst-mqueue4-y2038.c b/rt/tst-mqueue4-y2038.c
new file mode 100644
index 0000000000..c23a228dc4
--- /dev/null
+++ b/rt/tst-mqueue4-y2038.c
@@ -0,0 +1 @@
+#include "tst-mqueue4.c"
diff --git a/rt/tst-mqueue8-y2038.c b/rt/tst-mqueue8-y2038.c
new file mode 100644
index 0000000000..972637f7f5
--- /dev/null
+++ b/rt/tst-mqueue8-y2038.c
@@ -0,0 +1 @@
+#include "tst-mqueue8.c"
diff --git a/rt/tst-timer4-y2038.c b/rt/tst-timer4-y2038.c
new file mode 100644
index 0000000000..e47a593f10
--- /dev/null
+++ b/rt/tst-timer4-y2038.c
@@ -0,0 +1 @@
+#include "tst-timer4.c"
diff --git a/time/Makefile b/time/Makefile
index 0d571fb777..8b397d8c66 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -51,6 +51,15 @@ tests	:= test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
 	   tst-adjtime tst-ctime tst-difftime tst-mktime4 tst-clock_settime \
 	   tst-clock_adjtime
 
+tests-y2038 := \
+  tst-clock-y2038 \
+  tst-clock2-y2038 \
+  tst-clock_nanosleep-y2038 \
+  tst-cpuclock1-y2038 \
+  tst-ctime-y2038 \
+  tst-difftime-y2038 \
+  tst-mktime4-y2038
+
 include ../Rules
 
 ifeq ($(run-built-tests),yes)
diff --git a/time/tst-clock-y2038.c b/time/tst-clock-y2038.c
new file mode 100644
index 0000000000..a1349678c8
--- /dev/null
+++ b/time/tst-clock-y2038.c
@@ -0,0 +1 @@
+#include "tst-clock.c"
diff --git a/time/tst-clock2-y2038.c b/time/tst-clock2-y2038.c
new file mode 100644
index 0000000000..897f47b287
--- /dev/null
+++ b/time/tst-clock2-y2038.c
@@ -0,0 +1 @@
+#include "tst-clock2.c"
diff --git a/time/tst-clock_nanosleep-y2038.c b/time/tst-clock_nanosleep-y2038.c
new file mode 100644
index 0000000000..c8638aa3d2
--- /dev/null
+++ b/time/tst-clock_nanosleep-y2038.c
@@ -0,0 +1 @@
+#include "tst-clock_nanosleep.c"
diff --git a/time/tst-cpuclock1-y2038.c b/time/tst-cpuclock1-y2038.c
new file mode 100644
index 0000000000..5a7ffa27ac
--- /dev/null
+++ b/time/tst-cpuclock1-y2038.c
@@ -0,0 +1 @@
+#include "tst-cpuclock1.c"
diff --git a/time/tst-ctime-y2038.c b/time/tst-ctime-y2038.c
new file mode 100644
index 0000000000..24a5ae98ed
--- /dev/null
+++ b/time/tst-ctime-y2038.c
@@ -0,0 +1 @@
+#include "tst-ctime.c"
diff --git a/time/tst-difftime-y2038.c b/time/tst-difftime-y2038.c
new file mode 100644
index 0000000000..751ce6c483
--- /dev/null
+++ b/time/tst-difftime-y2038.c
@@ -0,0 +1 @@
+#include "tst-difftime.c"
diff --git a/time/tst-mktime4-y2038.c b/time/tst-mktime4-y2038.c
new file mode 100644
index 0000000000..bf5197c6f3
--- /dev/null
+++ b/time/tst-mktime4-y2038.c
@@ -0,0 +1 @@
+#include "tst-mktime4.c"


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [glibc/azanella/y2038] y2038: Add test coverage
@ 2021-02-23 12:39 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2021-02-23 12:39 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6ac4892ae861fdf1989777146d91e4bc8bd629a0

commit 6ac4892ae861fdf1989777146d91e4bc8bd629a0
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Feb 17 15:59:34 2021 -0300

    y2038: Add test coverage
    
    A new 'tests-y2038' rule is added, which adds the required 64 bit
    time flags and included in the 'tests' rule.
    
    The current coverage is:
    
      * libc:
        - adjtime
        - adjtimex
        - clock_adjtime
        - clock_getres                      tst-clock, tst-cpuclock1
        - clock_gettime                     tst-clock, tst-clock2, tst-cpuclock1
        - clock_nanosleep                   tst-clock_nanosleep, tst-cpuclock1
        - clock_settime                     tst-clock2
        - ctime                             tst-ctime
        - ctime_r
        - difftime                          tst-difftime
        - fstat
        - fstatat
        - futimens
        - futimes
        - futimesat
        - getitimer
        - getrusage
        - gettimeofday                      tst-clock_nanosleep
        - gmtime
        - gmtime_r
        - lstat
        - lutimes
        - mktime
        - mq_timedreceive                   tst-mqueue{1248}
        - mq_timedsend                      tst-mqueue{1248}
        - nanosleep                         tst-cpuclock2, tst-mqueue8, tst-clock, tst-cpuclock1
        - ntp_adjtime
        - ntp_gettime
        - ntp_gettimex
        - ppoll64
        - pselect
        - recvmmsg                          tst-cancel4_2
        - sched_rr_get_interval
        - select
        - semtimedop
        - setitimer
        - settimeofday
        - sigtimedwait
        - stat
        - time                              tst-mqueue1, tst-mqueue2, tst-mqueue4, tst-mqueue8
        - timegm
        - timer_gettime                     tst-timer4
        - timer_settime
        - timerfd_gettime
        - timerfd_settime
        - timespec_get
        - utime
        - utimensat
        - utimes
        - wait3
        - wait4_time64
    
      * libpthread:
        - cnd_timedwait
        - mtx_timedlock
        - 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
        - sem_clockwait
        - sem_timedwait
        - thrd_sleep
    
      * librt:
        - aio_suspend
        - mq_timedreceive                   tst-mqueue{1248}
        - mq_timedsend                      tst-mqueue{1248}
        - timer_gettime                     tst-timer4
        - timer_settime                     tst-timer4
    
      * libanl:
        - gai_suspend_time

Diff:
---
 Makerules                        | 13 ++++++++++++-
 nptl/Makefile                    |  3 +++
 nptl/tst-cancel4_2-y2038.c       |  1 +
 rt/Makefile                      |  8 ++++++++
 rt/tst-cpuclock2-y2038.c         |  1 +
 rt/tst-cpuclock2.c               |  9 ++++++---
 rt/tst-mqueue1-y2038.c           |  1 +
 rt/tst-mqueue2-y2038.c           |  1 +
 rt/tst-mqueue4-y2038.c           |  1 +
 rt/tst-mqueue8-y2038.c           |  1 +
 rt/tst-timer4-y2038.c            |  1 +
 time/Makefile                    |  9 +++++++++
 time/tst-clock-y2038.c           |  1 +
 time/tst-clock2-y2038.c          |  1 +
 time/tst-clock_nanosleep-y2038.c |  1 +
 time/tst-cpuclock1-y2038.c       |  1 +
 time/tst-ctime-y2038.c           |  1 +
 time/tst-difftime-y2038.c        |  1 +
 time/tst-mktime4-y2038.c         |  1 +
 19 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/Makerules b/Makerules
index fc5251ffad..0917a0d463 100644
--- a/Makerules
+++ b/Makerules
@@ -771,7 +771,7 @@ endif
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
 	     $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
-	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs))
+	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs) $(tests-y2038))
 ifeq ($(build-programs),yes)
 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
 endif
@@ -1286,6 +1286,17 @@ check: tests
 .PHONY: xcheck
 xcheck: xtests
 
+# Handle tests-y2038 tests they should be built with LFS and 64-bit time
+# support.
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(tests-y2038),$(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+tests += $(foreach t,$(tests-y2038),$(t))
+
 # The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
 # that almost all internal declarations from config.h, libc-symbols.h, and
 # include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
diff --git a/nptl/Makefile b/nptl/Makefile
index 4dd9c6a6a8..3b75590acb 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -375,6 +375,9 @@ xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
 	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10 tst-setgroups \
 	tst-mutexpp5 tst-mutexpp9
 
+tests-y2038 := \
+  tst-cancel4_2-y2038
+
 # This test can run into task limits because of a linux kernel bug
 # and then cause the make process to fail too, see bug 24537.
 xtests += tst-eintr1
diff --git a/nptl/tst-cancel4_2-y2038.c b/nptl/tst-cancel4_2-y2038.c
new file mode 100644
index 0000000000..4ac086a312
--- /dev/null
+++ b/nptl/tst-cancel4_2-y2038.c
@@ -0,0 +1 @@
+#include "tst-cancel4_2.c"
diff --git a/rt/Makefile b/rt/Makefile
index 7b374f2073..5d037ea368 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -49,6 +49,14 @@ tests := tst-shm tst-timer tst-timer2 \
 	 tst-shm-cancel
 tests-internal := tst-timer-sigmask
 
+tests-y2038 := \
+  tst-cpuclock2-y2038 \
+  tst-mqueue1-y2038 \
+  tst-mqueue2-y2038 \
+  tst-mqueue4-y2038 \
+  tst-mqueue8-y2038 \
+  tst-timer4-y2038
+
 extra-libs := librt
 extra-libs-others := $(extra-libs)
 
diff --git a/rt/tst-cpuclock2-y2038.c b/rt/tst-cpuclock2-y2038.c
new file mode 100644
index 0000000000..05775522bb
--- /dev/null
+++ b/rt/tst-cpuclock2-y2038.c
@@ -0,0 +1 @@
+#include "tst-cpuclock2.c"
diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c
index c1c7ed2ad8..eebc3609d0 100644
--- a/rt/tst-cpuclock2.c
+++ b/rt/tst-cpuclock2.c
@@ -21,7 +21,11 @@
 
 #if (_POSIX_THREADS - 0) <= 0
 
-# define TEST_FUNCTION 0
+static int
+do_test ()
+{
+  return 0;
+}
 
 #else
 
@@ -330,7 +334,6 @@ do_test (void)
 
   return result;
 }
-# define TEST_FUNCTION do_test ()
 #endif
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/rt/tst-mqueue1-y2038.c b/rt/tst-mqueue1-y2038.c
new file mode 100644
index 0000000000..9c600a9a97
--- /dev/null
+++ b/rt/tst-mqueue1-y2038.c
@@ -0,0 +1 @@
+#include "tst-mqueue1.c"
diff --git a/rt/tst-mqueue2-y2038.c b/rt/tst-mqueue2-y2038.c
new file mode 100644
index 0000000000..9d49f0b196
--- /dev/null
+++ b/rt/tst-mqueue2-y2038.c
@@ -0,0 +1 @@
+#include "tst-mqueue2.c"
diff --git a/rt/tst-mqueue4-y2038.c b/rt/tst-mqueue4-y2038.c
new file mode 100644
index 0000000000..c23a228dc4
--- /dev/null
+++ b/rt/tst-mqueue4-y2038.c
@@ -0,0 +1 @@
+#include "tst-mqueue4.c"
diff --git a/rt/tst-mqueue8-y2038.c b/rt/tst-mqueue8-y2038.c
new file mode 100644
index 0000000000..972637f7f5
--- /dev/null
+++ b/rt/tst-mqueue8-y2038.c
@@ -0,0 +1 @@
+#include "tst-mqueue8.c"
diff --git a/rt/tst-timer4-y2038.c b/rt/tst-timer4-y2038.c
new file mode 100644
index 0000000000..e47a593f10
--- /dev/null
+++ b/rt/tst-timer4-y2038.c
@@ -0,0 +1 @@
+#include "tst-timer4.c"
diff --git a/time/Makefile b/time/Makefile
index 0d571fb777..8b397d8c66 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -51,6 +51,15 @@ tests	:= test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
 	   tst-adjtime tst-ctime tst-difftime tst-mktime4 tst-clock_settime \
 	   tst-clock_adjtime
 
+tests-y2038 := \
+  tst-clock-y2038 \
+  tst-clock2-y2038 \
+  tst-clock_nanosleep-y2038 \
+  tst-cpuclock1-y2038 \
+  tst-ctime-y2038 \
+  tst-difftime-y2038 \
+  tst-mktime4-y2038
+
 include ../Rules
 
 ifeq ($(run-built-tests),yes)
diff --git a/time/tst-clock-y2038.c b/time/tst-clock-y2038.c
new file mode 100644
index 0000000000..a1349678c8
--- /dev/null
+++ b/time/tst-clock-y2038.c
@@ -0,0 +1 @@
+#include "tst-clock.c"
diff --git a/time/tst-clock2-y2038.c b/time/tst-clock2-y2038.c
new file mode 100644
index 0000000000..897f47b287
--- /dev/null
+++ b/time/tst-clock2-y2038.c
@@ -0,0 +1 @@
+#include "tst-clock2.c"
diff --git a/time/tst-clock_nanosleep-y2038.c b/time/tst-clock_nanosleep-y2038.c
new file mode 100644
index 0000000000..c8638aa3d2
--- /dev/null
+++ b/time/tst-clock_nanosleep-y2038.c
@@ -0,0 +1 @@
+#include "tst-clock_nanosleep.c"
diff --git a/time/tst-cpuclock1-y2038.c b/time/tst-cpuclock1-y2038.c
new file mode 100644
index 0000000000..5a7ffa27ac
--- /dev/null
+++ b/time/tst-cpuclock1-y2038.c
@@ -0,0 +1 @@
+#include "tst-cpuclock1.c"
diff --git a/time/tst-ctime-y2038.c b/time/tst-ctime-y2038.c
new file mode 100644
index 0000000000..24a5ae98ed
--- /dev/null
+++ b/time/tst-ctime-y2038.c
@@ -0,0 +1 @@
+#include "tst-ctime.c"
diff --git a/time/tst-difftime-y2038.c b/time/tst-difftime-y2038.c
new file mode 100644
index 0000000000..751ce6c483
--- /dev/null
+++ b/time/tst-difftime-y2038.c
@@ -0,0 +1 @@
+#include "tst-difftime.c"
diff --git a/time/tst-mktime4-y2038.c b/time/tst-mktime4-y2038.c
new file mode 100644
index 0000000000..bf5197c6f3
--- /dev/null
+++ b/time/tst-mktime4-y2038.c
@@ -0,0 +1 @@
+#include "tst-mktime4.c"


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-06-08 20:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 20:49 [glibc/azanella/y2038] y2038: Add test coverage Adhemerval Zanella
  -- strict thread matches above, loose matches on Subject: below --
2021-05-26 16:26 Adhemerval Zanella
2021-03-05 19:21 Adhemerval Zanella
2021-03-04 17:40 Adhemerval Zanella
2021-03-04 11:32 Adhemerval Zanella
2021-03-02 12:34 Adhemerval Zanella
2021-03-01 17:39 Adhemerval Zanella
2021-02-26 20:44 Adhemerval Zanella
2021-02-23 20:41 Adhemerval Zanella
2021-02-23 12:39 Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).