diff --git a/dirent/list.c b/dirent/list.c
index e99b253808..f792084243 100644
--- a/dirent/list.c
+++ b/dirent/list.c
@@ -26,7 +26,7 @@ static int
 test (const char *name)
 {
   DIR *dirp;
-  struct dirent *entp;
+  struct dirent64 *entp;
   int retval = 0;
 
   puts (name);
@@ -39,7 +39,7 @@ test (const char *name)
     }
 
   errno = 0;
-  while ((entp = readdir (dirp)) != NULL)
+  while ((entp = readdir64 (dirp)) != NULL)
     printf ("%s\tfile number %lu\n",
 	    entp->d_name, (unsigned long int) entp->d_fileno);
 
diff --git a/io/Makefile b/io/Makefile
index 2f26bf56db..595707914a 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -62,18 +62,19 @@ static-only-routines = stat fstat lstat stat64 fstat64 lstat64	\
 		       fstatat fstatat64 mknod mknodat
 
 others		:= pwd
-test-srcs	:= ftwtest
+test-srcs	:= ftwtest ftwtest-64
 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 \
-		   tst-renameat tst-fchownat tst-fchmodat tst-faccessat \
-		   tst-symlinkat tst-linkat tst-readlinkat tst-mkdirat \
-		   tst-mknodat tst-mkfifoat tst-ttyname_r bug-ftw5 \
+		   tst-fcntl bug-ftw1 bug-ftw1-64 bug-ftw2 bug-ftw2-64 \
+		   bug-ftw3 bug-ftw3-64 bug-ftw4 bug-ftw5 bug-ftw5-64 \
+		   tst-statvfs tst-openat tst-unlinkat tst-fstatat \
+		   tst-futimesat tst-renameat tst-fchownat tst-fchmodat \
+		   tst-faccessat tst-symlinkat tst-linkat tst-readlinkat \
+		   tst-mkdirat tst-mknodat tst-mkfifoat tst-ttyname_r \
 		   tst-posix_fallocate tst-posix_fallocate64 \
 		   tst-fts tst-fts-lfs tst-open-tmpfile
 
 ifeq ($(run-built-tests),yes)
-tests-special += $(objpfx)ftwtest.out
+tests-special += $(objpfx)ftwtest.out $(objpfx)ftwtest-64.out
 endif
 
 include ../Rules
@@ -113,4 +114,9 @@ ifeq ($(run-built-tests),yes)
 $(objpfx)ftwtest.out: ftwtest-sh $(objpfx)ftwtest
 	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
 	$(evaluate-test)
+
+# Prevent ftwtest and ftwtest-64 runs from overlapping
+$(objpfx)ftwtest-64.out: ftwtest-sh $(objpfx)ftwtest-64 $(objpfx)ftwtest.out
+	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
+	$(evaluate-test)
 endif
diff --git a/io/bug-ftw1-64.c b/io/bug-ftw1-64.c
new file mode 100644
index 0000000000..3ec10190e3
--- /dev/null
+++ b/io/bug-ftw1-64.c
@@ -0,0 +1,3 @@
+#define FTW ftw64
+#define STAT stat64
+#include "bug-ftw1.c"
diff --git a/io/bug-ftw1.c b/io/bug-ftw1.c
index 29c3f7d531..f2466472f1 100644
--- a/io/bug-ftw1.c
+++ b/io/bug-ftw1.c
@@ -17,11 +17,19 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#include <errno.h>
 #include <ftw.h>
 #include <mcheck.h>
 #include <stdio.h>
 #include <string.h>
 
+#ifndef FTW
+#define FTW ftw
+#endif
+
+#ifndef STAT
+#define STAT stat
+#endif
 
 int result;
 int cnt;
@@ -29,7 +37,7 @@ int sawroot;
 
 
 static int
-callback (const char *fname, const struct stat *st, int flag)
+callback (const char *fname, const struct STAT *st, int flag)
 {
   if (++cnt >= 10)
     return 1;
@@ -65,7 +73,10 @@ main (void)
 {
   mtrace ();
 
-  ftw ("/", callback, 10);
+  FTW ("/", callback, 10);
+
+  if (errno == EOVERFLOW)
+    return 77;
 
   if (! sawroot)
     {
diff --git a/io/bug-ftw2-64.c b/io/bug-ftw2-64.c
new file mode 100644
index 0000000000..9395f8f793
--- /dev/null
+++ b/io/bug-ftw2-64.c
@@ -0,0 +1,3 @@
+#define FTW ftw64
+#define STAT stat64
+#include "bug-ftw2.c"
diff --git a/io/bug-ftw2.c b/io/bug-ftw2.c
index ce8823d28e..6b0eabd7d3 100644
--- a/io/bug-ftw2.c
+++ b/io/bug-ftw2.c
@@ -17,11 +17,19 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#include <errno.h>
 #include <ftw.h>
 #include <mcheck.h>
 #include <stdio.h>
 #include <string.h>
 
+#ifndef FTW
+#define FTW ftw
+#endif
+
+#ifndef STAT
+#define STAT stat
+#endif
 
 int cnt;
 int result;
@@ -30,7 +38,7 @@ int sawcur;
 
 
 static int
-callback (const char *fname, const struct stat *st, int flag)
+callback (const char *fname, const struct STAT *st, int flag)
 {
   printf ("%d: \"%s\" -> ", ++cnt, fname);
   if (strcmp (fname, ".") == 0 && sawcur)
@@ -69,7 +77,9 @@ main (void)
 {
   mtrace ();
 
-  ftw (".", callback, 10);
+  FTW (".", callback, 10);
+  if (errno == EOVERFLOW)
+    return 77;
 
   if (! sawcur)
     {
diff --git a/io/bug-ftw3-64.c b/io/bug-ftw3-64.c
new file mode 100644
index 0000000000..822684338e
--- /dev/null
+++ b/io/bug-ftw3-64.c
@@ -0,0 +1,3 @@
+#define FTW ftw64
+#define STAT stat64
+#include "bug-ftw3.c"
diff --git a/io/bug-ftw3.c b/io/bug-ftw3.c
index 19740f49f3..a64c242f19 100644
--- a/io/bug-ftw3.c
+++ b/io/bug-ftw3.c
@@ -5,10 +5,18 @@
 #include <string.h>
 #include <unistd.h>
 
+#ifndef FTW
+#define FTW ftw
+#endif
+
+#ifndef STAT
+#define STAT stat
+#endif
+
 static int cb_called;
 
 static int
-cb (const char *fname, const struct stat *st, int flag)
+cb (const char *fname, const struct STAT *st, int flag)
 {
   printf ("%s %d\n", fname, flag);
   cb_called = 1;
@@ -54,8 +62,10 @@ main (void)
       exit (1);
     }
 
-  r = ftw (dname2, cb, 10);
+  r = FTW (dname2, cb, 10);
   e = errno;
+  if (e == EOVERFLOW)
+    return 77;
   printf ("r = %d", r);
   if (r != 0)
     printf (", errno = %d", errno);
diff --git a/io/bug-ftw5-64.c b/io/bug-ftw5-64.c
new file mode 100644
index 0000000000..dd3a4501cb
--- /dev/null
+++ b/io/bug-ftw5-64.c
@@ -0,0 +1,3 @@
+#define NFTW nftw64
+#define STAT stat64
+#include "bug-ftw5.c"
diff --git a/io/bug-ftw5.c b/io/bug-ftw5.c
index c1cd81d30e..e4327f5e34 100644
--- a/io/bug-ftw5.c
+++ b/io/bug-ftw5.c
@@ -2,8 +2,16 @@
 #include <ftw.h>
 #include <stdio.h>
 
+#ifndef NFTW
+#define NFTW nftw
+#endif
+
+#ifndef STAT
+#define STAT stat
+#endif
+
 static int
-fn (const char *file, const struct stat *sb, int flag, struct FTW *s)
+fn (const char *file, const struct STAT *sb, int flag, struct FTW *s)
 {
   puts (file);
   return FTW_STOP;
@@ -12,8 +20,10 @@ fn (const char *file, const struct stat *sb, int flag, struct FTW *s)
 static int
 do_test (void)
 {
-  if (nftw ("/", fn, 0, FTW_CHDIR | FTW_ACTIONRETVAL) < 0)
+  if (NFTW ("/", fn, 0, FTW_CHDIR | FTW_ACTIONRETVAL) < 0)
     {
+      if (errno == EOVERFLOW)
+        return 77;
       printf ("nftw / FTW_CHDIR: %m\n");
       return 1;
     }
diff --git a/io/ftwtest-64.c b/io/ftwtest-64.c
new file mode 100644
index 0000000000..f5334b5256
--- /dev/null
+++ b/io/ftwtest-64.c
@@ -0,0 +1,3 @@
+#define NFTW nftw64
+#define STAT stat64
+#include "ftwtest.c"
diff --git a/io/ftwtest.c b/io/ftwtest.c
index 77debd2805..f0137a8f1a 100644
--- a/io/ftwtest.c
+++ b/io/ftwtest.c
@@ -7,6 +7,15 @@
 #include <unistd.h>
 #include <sys/stat.h>
 
+#ifndef NFTW
+#define NFTW nftw
+#endif
+
+#ifndef STAT
+#define STAT stat
+#endif
+
+#define STR(x) #x
 
 int do_depth;
 int do_chdir;
@@ -39,7 +48,7 @@ const char *flag2name[] =
 
 
 static int
-cb (const char *name, const struct stat *st, int flag, struct FTW *f)
+cb (const char *name, const struct STAT *st, int flag, struct FTW *f)
 {
   if (do_exit && strcmp (name + f->base, "file@2"))
     return FTW_CONTINUE;
@@ -97,9 +106,9 @@ main (int argc, char *argv[])
 
   char *cw1 = getcwd (NULL, 0);
 
-  r = nftw (optind < argc ? argv[optind] : ".", cb, do_exit ? 1 : 3, flag);
+  r = NFTW (optind < argc ? argv[optind] : ".", cb, do_exit ? 1 : 3, flag);
   if (r < 0)
-    perror ("nftw");
+    perror (STR(NFTW));
 
   char *cw2 = getcwd (NULL, 0);
 
diff --git a/posix/tst-regex.c b/posix/tst-regex.c
index df2c108be5..ab9a854d98 100644
--- a/posix/tst-regex.c
+++ b/posix/tst-regex.c
@@ -57,7 +57,7 @@ do_test (void)
 {
   const char *file;
   int fd;
-  struct stat st;
+  struct stat64 st;
   int result;
   char *inmem;
   char *outmem;
@@ -72,7 +72,7 @@ do_test (void)
   if (fd == -1)
     error (EXIT_FAILURE, errno, "cannot open %s", basename (file));
 
-  if (fstat (fd, &st) != 0)
+  if (fstat64 (fd, &st) != 0)
     error (EXIT_FAILURE, errno, "cannot stat %s", basename (file));
   memlen = st.st_size;
 
diff --git a/timezone/Makefile b/timezone/Makefile
index d6cc7ba357..c0b4ea8020 100644
--- a/timezone/Makefile
+++ b/timezone/Makefile
@@ -60,7 +60,8 @@ tz-cflags = -DTZDIR='"$(zonedir)"' \
 	    -DTZDEFRULES='"$(posixrules-file)"' \
 	    -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone \
 	    -DHAVE_GETTEXT -DUSE_LTZ=0 -D_ISOMAC -DTZ_DOMAIN='"libc"' \
-	    -include $(common-objpfx)config.h -Wno-maybe-uninitialized
+	    -include $(common-objpfx)config.h -Wno-maybe-uninitialized \
+	    -D_FILE_OFFSET_BITS=64
 
 # The -Wno-unused-variable flag is used to prevent GCC 6
 # from warning about time_t_min and time_t_max which are
