about summary refs log tree commit diff
path: root/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32
diff options
context:
space:
mode:
Diffstat (limited to 'REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32')
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/Versions5
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c86
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c35
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c47
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c36
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c46
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c37
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/getdents.c115
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c45
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c51
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h60
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/sendfile.c45
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c36
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list5
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c45
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c51
16 files changed, 745 insertions, 0 deletions
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/Versions b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/Versions
new file mode 100644
index 0000000000..cdc6022015
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/Versions
@@ -0,0 +1,5 @@
+libc {
+  GLIBC_2.15 {
+    fallocate64;
+  }
+}
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c
new file mode 100644
index 0000000000..20399f9310
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c
@@ -0,0 +1,86 @@
+/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <assert.h>
+#include <errno.h>
+#include <sysdep-cancel.h>	/* Must come before <fcntl.h>.  */
+#include <fcntl.h>
+#include <stdarg.h>
+
+#include <sys/syscall.h>
+
+
+static int
+do_fcntl (int fd, int cmd, void *arg)
+{
+  if (cmd != F_GETOWN)
+    return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
+
+  INTERNAL_SYSCALL_DECL (err);
+  struct f_owner_ex fex;
+  int res = INTERNAL_SYSCALL (fcntl64, err, 3, fd, F_GETOWN_EX, &fex);
+  if (!INTERNAL_SYSCALL_ERROR_P (res, err))
+    return fex.type == F_OWNER_GID ? -fex.pid : fex.pid;
+
+  __set_errno (INTERNAL_SYSCALL_ERRNO (res, err));
+  return -1;
+}
+
+
+#ifndef NO_CANCELLATION
+int
+__fcntl_nocancel (int fd, int cmd, ...)
+{
+  va_list ap;
+  void *arg;
+
+  va_start (ap, cmd);
+  arg = va_arg (ap, void *);
+  va_end (ap);
+
+  return do_fcntl (fd, cmd, arg);
+}
+#endif
+
+
+int
+__libc_fcntl (int fd, int cmd, ...)
+{
+  va_list ap;
+  void *arg;
+
+  va_start (ap, cmd);
+  arg = va_arg (ap, void *);
+  va_end (ap);
+
+  if (SINGLE_THREAD_P || cmd != F_SETLKW)
+    return do_fcntl (fd, cmd, arg);
+
+  int oldtype = LIBC_CANCEL_ASYNC ();
+
+  int result = do_fcntl (fd, cmd, arg);
+
+  LIBC_CANCEL_RESET (oldtype);
+
+  return result;
+}
+libc_hidden_def (__libc_fcntl)
+
+weak_alias (__libc_fcntl, __fcntl)
+libc_hidden_weak (__fcntl)
+weak_alias (__libc_fcntl, fcntl)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
new file mode 100644
index 0000000000..4c0a83040d
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <sys/statfs.h>
+#include <kernel_stat.h>
+#include <stddef.h>
+
+#if !STATFS_IS_STATFS64
+#include "overflow.h"
+
+/* Return information about the filesystem on which FD resides.  */
+int
+__fstatfs (int fd, struct statfs *buf)
+{
+  int rc = INLINE_SYSCALL (fstatfs64, 3, fd, sizeof (*buf), buf);
+  return rc ?: statfs_overflow (buf);
+}
+weak_alias (__fstatfs, fstatfs)
+#endif
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c
new file mode 100644
index 0000000000..55c830731d
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <kernel_stat.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+#if !XSTAT_IS_XSTAT64
+#include "overflow.h"
+
+/* Get information about the file FD in BUF.  */
+int
+__fxstat (int vers, int fd, struct stat *buf)
+{
+  if (vers == _STAT_VER_KERNEL)
+    {
+      int rc = INLINE_SYSCALL (fstat64, 2, fd, buf);
+      return rc ?: stat_overflow (buf);
+    }
+
+  errno = EINVAL;
+  return -1;
+}
+
+hidden_def (__fxstat)
+weak_alias (__fxstat, _fxstat);
+#endif
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c
new file mode 100644
index 0000000000..c7f128c622
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c
@@ -0,0 +1,36 @@
+/* __fxstat64 () implementation.
+   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+/* Hide the prototypes for __fxstat and _fxstat so that GCC will not
+   complain about the different function signatures if they are aliased
+   to  __fxstat64.  If XSTAT_IS_XSTAT64 is set to non-zero then the stat and
+   stat64 structures have an identical layout but different type names.  */
+
+#define __fxstat __fxstat_disable
+#define _fxstat _fxstat_disable
+
+#include <sysdeps/unix/sysv/linux/fxstat64.c>
+
+#undef __fxstat
+#undef _fxstat
+#if XSTAT_IS_XSTAT64
+weak_alias (__fxstat64, __fxstat)
+weak_alias (__fxstat64, _fxstat)
+hidden_ver (__fxstat64, __fxstat)
+#endif
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c
new file mode 100644
index 0000000000..2c1feea6b6
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <kernel_stat.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+#if !XSTAT_IS_XSTAT64
+#include "overflow.h"
+
+/* Get information about the file NAME in BUF.  */
+int
+__fxstatat (int vers, int fd, const char *file, struct stat *buf, int flag)
+{
+  if (vers == _STAT_VER_KERNEL)
+    {
+      int rc = INLINE_SYSCALL (fstatat64, 4, fd, file, buf, flag);
+      return rc ?: stat_overflow (buf);
+    }
+
+  errno = EINVAL;
+  return -1;
+}
+libc_hidden_def (__fxstatat)
+#endif
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c
new file mode 100644
index 0000000000..93fa42b686
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c
@@ -0,0 +1,37 @@
+/* __fxstatat64 () implementation.
+   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+/* Hide the prototype for __fxstatat so that GCC will not complain about
+   the different function signature if it is aliased to  __fxstatat64.
+   If XSTAT_IS_XSTAT64 is set to non-zero then the stat and stat64 structures
+   have an identical layout but different type names.  */
+
+#define __fxstatat __fxstatat_disable
+
+#include <sys/stat.h>
+#undef _STAT_VER_LINUX
+#define _STAT_VER_LINUX _STAT_VER_KERNEL
+
+#include <sysdeps/unix/sysv/linux/fxstatat64.c>
+
+#undef __fxstatat
+#if XSTAT_IS_XSTAT64
+weak_alias (__fxstatat64, __fxstatat)
+libc_hidden_ver (__fxstatat64, __fxstatat)
+#endif
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/getdents.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/getdents.c
new file mode 100644
index 0000000000..9f1c991694
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/getdents.c
@@ -0,0 +1,115 @@
+/* Copyright (C) 1993-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Simplified from sysdeps/unix/sysv/linux/getdents.c.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <alloca.h>
+#include <assert.h>
+#include <errno.h>
+#include <dirent.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <sys/types.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* Pack the dirent64 struct down into 32-bit offset/inode fields, and
+   ensure that no overflow occurs.  */
+ssize_t
+__getdents (int fd, char *buf, size_t nbytes)
+{
+  union
+  {
+    struct dirent64 k;  /* Kernel structure.  */
+    struct dirent u;
+    char b[1];
+  } *kbuf = (void *) buf, *outp, *inp;
+  size_t kbytes = nbytes;
+  off64_t last_offset = -1;
+  ssize_t retval;
+
+  const size_t size_diff = (offsetof (struct dirent64, d_name)
+                            - offsetof (struct dirent, d_name));
+  if (nbytes <= sizeof (struct dirent))
+    {
+      kbytes = nbytes + offsetof (struct dirent64, d_name)
+        - offsetof (struct dirent, d_name);
+      kbuf = __alloca(kbytes);
+    }
+
+  retval = INLINE_SYSCALL (getdents64, 3, fd, kbuf, kbytes);
+  if (retval == -1)
+    return -1;
+
+  /* These two pointers might alias the same memory buffer.
+     Standard C requires that we always use the same type for them,
+     so we must use the union type.  */
+  inp = kbuf;
+  outp = (void *) buf;
+
+  while (&inp->b < &kbuf->b + retval)
+    {
+      const size_t alignment = __alignof__ (struct dirent);
+      /* Since inp->k.d_reclen is already aligned for the kernel
+         structure this may compute a value that is bigger
+         than necessary.  */
+      size_t old_reclen = inp->k.d_reclen;
+      size_t new_reclen = ((old_reclen - size_diff + alignment - 1)
+                           & ~(alignment - 1));
+
+      /* Copy the data out of the old structure into temporary space.
+         Then copy the name, which may overlap if BUF == KBUF.  */
+      const uint64_t d_ino = inp->k.d_ino;
+      const int64_t d_off = inp->k.d_off;
+      const uint8_t d_type = inp->k.d_type;
+
+      memmove (outp->u.d_name, inp->k.d_name,
+               old_reclen - offsetof (struct dirent64, d_name));
+
+      /* Now we have copied the data from INP and access only OUTP.  */
+
+      outp->u.d_ino = d_ino;
+      outp->u.d_off = d_off;
+      if ((sizeof (outp->u.d_ino) != sizeof (inp->k.d_ino)
+           && outp->u.d_ino != d_ino)
+          || (sizeof (outp->u.d_off) != sizeof (inp->k.d_off)
+              && outp->u.d_off != d_off))
+        {
+          /* Overflow.  If there was at least one entry before this one,
+             return them without error, otherwise signal overflow.  */
+          if (last_offset != -1)
+            {
+              __lseek64 (fd, last_offset, SEEK_SET);
+              return outp->b - buf;
+            }
+          __set_errno (EOVERFLOW);
+          return -1;
+        }
+
+      last_offset = d_off;
+      outp->u.d_reclen = new_reclen;
+      outp->u.d_type = d_type;
+
+      inp = (void *) inp + old_reclen;
+      outp = (void *) outp + new_reclen;
+    }
+
+  return outp->b - buf;
+}
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c
new file mode 100644
index 0000000000..db4f4919fc
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <stddef.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <kernel_stat.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+#if !XSTAT_IS_XSTAT64
+#include "overflow.h"
+
+/* Get information about the file NAME in BUF.  */
+int
+__lxstat (int vers, const char *name, struct stat *buf)
+{
+  if (vers == _STAT_VER_KERNEL)
+    {
+      int rc = INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf,
+                               AT_SYMLINK_NOFOLLOW);
+      return rc ?: stat_overflow (buf);
+    }
+  errno = EINVAL;
+  return -1;
+}
+hidden_def (__lxstat)
+#endif
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c
new file mode 100644
index 0000000000..647939a74c
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+/* Hide the prototype for __lxstat so that GCC will not complain about
+   the different function signature if it is aliased to  __lxstat64.
+   If XSTAT_IS_XSTAT64 is set to non-zero then the stat and stat64
+   structures have an identical layout but different type names.  */
+
+#define __lxstat __lxstat_disable
+
+#include <errno.h>
+#include <stddef.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <kernel_stat.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* Get information about the file NAME in BUF.  */
+int
+__lxstat64 (int vers, const char *name, struct stat64 *buf)
+{
+  if (vers == _STAT_VER_KERNEL)
+    return INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf,
+                           AT_SYMLINK_NOFOLLOW);
+  errno = EINVAL;
+  return -1;
+}
+hidden_def (__lxstat64)
+
+#undef __lxstat
+#if XSTAT_IS_XSTAT64
+strong_alias (__lxstat64, __lxstat)
+hidden_ver (__lxstat64, __lxstat)
+#endif
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
new file mode 100644
index 0000000000..4c993ac817
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
@@ -0,0 +1,60 @@
+/* Overflow tests for stat, statfs, and lseek functions.
+   Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sys/stat.h>
+#include <sys/statfs.h>
+
+/* Test for overflows of structures where we ask the kernel to fill them
+   in with standard 64-bit syscalls but return them through APIs that
+   only expose the low 32 bits of some fields.  */
+
+static inline off_t lseek_overflow (loff_t res)
+{
+  off_t retval = (off_t) res;
+  if (retval == res)
+    return retval;
+
+  __set_errno (EOVERFLOW);
+  return (off_t) -1;
+}
+
+static inline int stat_overflow (struct stat *buf)
+{
+  if (buf->__st_ino_pad == 0 && buf->__st_size_pad == 0 &&
+      buf->__st_blocks_pad == 0)
+    return 0;
+
+  __set_errno (EOVERFLOW);
+  return -1;
+}
+
+/* Note that f_files and f_ffree may validly be a sign-extended -1.  */
+static inline int statfs_overflow (struct statfs *buf)
+{
+  if (buf->__f_blocks_pad == 0 && buf->__f_bfree_pad == 0 &&
+      buf->__f_bavail_pad == 0 &&
+      (buf->__f_files_pad == 0 ||
+       (buf->f_files == -1U && buf->__f_files_pad == -1)) &&
+      (buf->__f_ffree_pad == 0 ||
+       (buf->f_ffree == -1U && buf->__f_ffree_pad == -1)))
+    return 0;
+
+  __set_errno (EOVERFLOW);
+  return -1;
+}
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/sendfile.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/sendfile.c
new file mode 100644
index 0000000000..2c252cc2cf
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/sendfile.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sys/sendfile.h>
+#include <errno.h>
+
+/* Send COUNT bytes from file associated with IN_FD starting at OFFSET to
+   descriptor OUT_FD.  */
+ssize_t
+sendfile (int out_fd, int in_fd, off_t *offset, size_t count)
+{
+  __off64_t off64;
+  int rc;
+
+  if (offset != NULL)
+    {
+      if (*offset < 0 || (off_t) (*offset + count) < 0)
+        {
+          __set_errno (EINVAL);
+          return -1;
+        }
+      off64 = *offset;
+    }
+
+  rc = INLINE_SYSCALL (sendfile64, 4, out_fd, in_fd,
+                       offset ? &off64 : NULL, count);
+  if (offset)
+    *offset = off64;
+  return rc;
+}
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
new file mode 100644
index 0000000000..11da0021d6
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <sys/statfs.h>
+#include <kernel_stat.h>
+#include <stddef.h>
+
+#if !STATFS_IS_STATFS64
+#include "overflow.h"
+
+/* Return information about the filesystem on which FILE resides.  */
+int
+__statfs (const char *file, struct statfs *buf)
+{
+  int rc = INLINE_SYSCALL (statfs64, 3, file, sizeof (*buf), buf);
+  return rc ?: statfs_overflow (buf);
+}
+libc_hidden_def (__statfs)
+weak_alias (__statfs, statfs)
+#endif
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
new file mode 100644
index 0000000000..b775008a37
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
@@ -0,0 +1,5 @@
+# File name	Caller	Syscall name	# args	Strong name	Weak names
+
+# rlimit APIs
+prlimit64	EXTRA	prlimit64	i:iipp	prlimit64
+fanotify_mark	EXTRA	fanotify_mark	i:iiiiis	fanotify_mark
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c
new file mode 100644
index 0000000000..91c1c9be6d
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <stddef.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <kernel_stat.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+#if !XSTAT_IS_XSTAT64
+#include "overflow.h"
+
+/* Get information about the file NAME in BUF.  */
+int
+__xstat (int vers, const char *name, struct stat *buf)
+{
+  if (vers == _STAT_VER_KERNEL)
+    {
+      int rc = INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf, 0);
+      return rc ?: stat_overflow (buf);
+    }
+
+  errno = EINVAL;
+  return -1;
+}
+hidden_def (__xstat)
+#endif
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c
new file mode 100644
index 0000000000..5ef0614eb6
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+/* Hide the prototype for __xstat so that GCC will not complain about
+   the different function signature if it is aliased to  __xstat64.
+   If XSTAT_IS_XSTAT64 is set to non-zero then the stat and stat64
+   structures have an identical layout but different type names.  */
+
+#define __xstat __xstat_disable
+
+#include <errno.h>
+#include <stddef.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <kernel_stat.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* Get information about the file NAME in BUF.  */
+int
+__xstat64 (int vers, const char *name, struct stat64 *buf)
+{
+  if (vers == _STAT_VER_KERNEL)
+    return INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf, 0);
+
+  errno = EINVAL;
+  return -1;
+}
+hidden_def (__xstat64)
+
+#undef __xstat
+#if XSTAT_IS_XSTAT64
+strong_alias (__xstat64, __xstat)
+hidden_ver (__xstat64, __xstat)
+#endif