about summary refs log tree commit diff
path: root/REORG.TODO/sysdeps/unix/sysv/linux/generic
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
committerZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
commit5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch)
tree4470480d904b65cf14ca524f96f79eca818c3eaf /REORG.TODO/sysdeps/unix/sysv/linux/generic
parent199fc19d3aaaf57944ef036e15904febe877fc93 (diff)
downloadglibc-zack/build-layout-experiment.tar.gz
glibc-zack/build-layout-experiment.tar.xz
glibc-zack/build-layout-experiment.zip
Prepare for radical source tree reorganization. zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage
directory, REORG.TODO, except for files that will certainly still
exist in their current form at top level when we're done (COPYING,
COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which
are moved to the new directory OldChangeLogs, instead), and the
generated file INSTALL (which is just deleted; in the new order, there
will be no generated files checked into version control).
Diffstat (limited to 'REORG.TODO/sysdeps/unix/sysv/linux/generic')
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/Makefile3
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/README11
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/____longjmp_chk.c57
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/fcntl.h56
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/msq.h84
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/sem.h92
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/shm.h111
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/stat.h171
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/statfs.h86
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/typesizes.h84
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/brk.c45
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/chmod.c31
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/chown.c32
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/dl-origin.c81
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/dup2.c37
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/epoll_create.c38
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/futimesat.c51
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/getdents.c1
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/getdents64.c37
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/inotify_init.c32
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/kernel_stat.h30
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/lchown.c32
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/link.c31
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/lxstat.c48
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/mkdir.c33
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/pipe.c33
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/readlink.c31
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/readlink_chk.c39
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/rmdir.c31
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/symlink.c30
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/syscalls.list12
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/sysctl.c32
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/sysdep.h35
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/umount.c30
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/unlink.c31
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/ustat.c32
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/utimes.c45
-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
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/xmknod.c54
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/generic/xstat.c48
55 files changed, 2542 insertions, 0 deletions
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/Makefile b/REORG.TODO/sysdeps/unix/sysv/linux/generic/Makefile
new file mode 100644
index 0000000000..7e27e79772
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),misc)
+sysdep_routines += epoll_create inotify_init
+endif
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/README b/REORG.TODO/sysdeps/unix/sysv/linux/generic/README
new file mode 100644
index 0000000000..301a6107e1
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/README
@@ -0,0 +1,11 @@
+This hierarchy supports Linux systems using the new
+asm-generic/unistd.h, which removes many familiar old syscalls.  For
+example, to implement open(), newer Linux architectures require glibc
+to invoke the __NR_openat syscall with AT_FDCWD.  This hierarchy
+provides all those implementations.
+
+It also provides support for 32-bit platforms using the 64-bit kernel
+syscall APIs, as the 32-bit ones are no longer provided.  Note that
+newer ILP32 environments (x32 or AArch64:ILP32, for example) are
+converting to use more 64-bit types in kernel syscalls, so that aspect
+of this support is in more flux as of this writing.
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/____longjmp_chk.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/____longjmp_chk.c
new file mode 100644
index 0000000000..1c0f040976
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/____longjmp_chk.c
@@ -0,0 +1,57 @@
+/* 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 <jmpbuf-offsets.h>
+#include <sysdep.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stackinfo.h>
+
+#ifdef _STACK_GROWS_DOWN
+#define called_from(this, saved) ((this) < (saved))
+#else
+#define called_from(this, saved) ((this) > (saved))
+#endif
+
+extern void ____longjmp_chk (__jmp_buf __env, int __val)
+  __attribute__ ((__noreturn__));
+
+void ____longjmp_chk (__jmp_buf env, int val)
+{
+  void *this_frame = __builtin_frame_address (0);
+  void *saved_frame = JB_FRAME_ADDRESS (env);
+  INTERNAL_SYSCALL_DECL (err);
+  stack_t ss;
+
+  /* If "env" is from a frame that called us, we're all set.  */
+  if (called_from(this_frame, saved_frame))
+    __longjmp (env, val);
+
+  /* If we can't get the current stack state, give up and do the longjmp. */
+  if (INTERNAL_SYSCALL (sigaltstack, err, 2, NULL, &ss) != 0)
+    __longjmp (env, val);
+
+  /* If we we are executing on the alternate stack and within the
+     bounds, do the longjmp.  */
+  if (ss.ss_flags == SS_ONSTACK &&
+      (this_frame >= ss.ss_sp && this_frame < (ss.ss_sp + ss.ss_size)))
+    __longjmp (env, val);
+
+  __fortify_fail ("longjmp causes uninitialized stack frame");
+}
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/fcntl.h b/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/fcntl.h
new file mode 100644
index 0000000000..0767467f82
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/fcntl.h
@@ -0,0 +1,56 @@
+/* O_*, F_*, FD_* bit values for the generic Linux ABI.
+   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/>.  */
+
+#ifndef	_FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 64
+# define __O_LARGEFILE	0
+#endif
+
+struct flock
+  {
+    short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+    short int l_whence;	/* Where `l_start' is relative to (like `lseek').  */
+#ifndef __USE_FILE_OFFSET64
+    __off_t l_start;	/* Offset where the lock begins.  */
+    __off_t l_len;	/* Size of the locked area; zero means until EOF.  */
+#else
+    __off64_t l_start;	/* Offset where the lock begins.  */
+    __off64_t l_len;	/* Size of the locked area; zero means until EOF.  */
+#endif
+    __pid_t l_pid;	/* Process holding the lock.  */
+  };
+
+#ifdef __USE_LARGEFILE64
+struct flock64
+  {
+    short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+    short int l_whence;	/* Where `l_start' is relative to (like `lseek').  */
+    __off64_t l_start;	/* Offset where the lock begins.  */
+    __off64_t l_len;	/* Size of the locked area; zero means until EOF.  */
+    __pid_t l_pid;	/* Process holding the lock.  */
+  };
+#endif
+
+/* Include generic Linux declarations.  */
+#include <bits/fcntl-linux.h>
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/msq.h b/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/msq.h
new file mode 100644
index 0000000000..fc80473af6
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/msq.h
@@ -0,0 +1,84 @@
+/* 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/>.  */
+
+#ifndef _SYS_MSG_H
+# error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
+#endif
+
+#include <bits/types.h>
+#include <bits/wordsize.h>
+
+/* Define options for message queue functions.  */
+#define MSG_NOERROR	010000	/* no error if message is too big */
+#ifdef __USE_GNU
+# define MSG_EXCEPT	020000	/* recv any msg except of specified type */
+# define MSG_COPY	040000	/* copy (not remove) all queue messages */
+#endif
+
+/* Types used in the structure definition.  */
+typedef unsigned long int msgqnum_t;
+typedef unsigned long int msglen_t;
+
+/* Structure of record for one message inside the kernel.
+   The type `struct msg' is opaque.  */
+struct msqid_ds
+{
+  struct ipc_perm msg_perm;	/* structure describing operation permission */
+  __time_t msg_stime;		/* time of last msgsnd command */
+#if __WORDSIZE == 32
+  unsigned long int __glibc_reserved1;
+#endif
+  __time_t msg_rtime;		/* time of last msgrcv command */
+#if __WORDSIZE == 32
+  unsigned long int __glibc_reserved2;
+#endif
+  __time_t msg_ctime;		/* time of last change */
+#if __WORDSIZE == 32
+  unsigned long int __glibc_reserved3;
+#endif
+  unsigned long int __msg_cbytes; /* current number of bytes on queue */
+  msgqnum_t msg_qnum;		/* number of messages currently on queue */
+  msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
+  __pid_t msg_lspid;		/* pid of last msgsnd() */
+  __pid_t msg_lrpid;		/* pid of last msgrcv() */
+  unsigned long int __glibc_reserved4;
+  unsigned long int __glibc_reserved5;
+};
+
+#ifdef __USE_MISC
+
+# define msg_cbytes	__msg_cbytes
+
+/* ipcs ctl commands */
+# define MSG_STAT 11
+# define MSG_INFO 12
+
+/* buffer for msgctl calls IPC_INFO, MSG_INFO */
+struct msginfo
+  {
+    int msgpool;
+    int msgmap;
+    int msgmax;
+    int msgmnb;
+    int msgmni;
+    int msgssz;
+    int msgtql;
+    unsigned short int msgseg;
+  };
+
+#endif /* __USE_MISC */
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/sem.h b/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/sem.h
new file mode 100644
index 0000000000..718ee74403
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/sem.h
@@ -0,0 +1,92 @@
+/* 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/>.  */
+
+#ifndef _SYS_SEM_H
+# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
+#endif
+
+#include <sys/types.h>
+#include <bits/wordsize.h>
+
+/* Flags for `semop'.  */
+#define SEM_UNDO	0x1000		/* undo the operation on exit */
+
+/* Commands for `semctl'.  */
+#define GETPID		11		/* get sempid */
+#define GETVAL		12		/* get semval */
+#define GETALL		13		/* get all semval's */
+#define GETNCNT		14		/* get semncnt */
+#define GETZCNT		15		/* get semzcnt */
+#define SETVAL		16		/* set semval */
+#define SETALL		17		/* set all semval's */
+
+
+/* Data structure describing a set of semaphores.  */
+struct semid_ds
+{
+  struct ipc_perm sem_perm;		/* operation permission struct */
+  __time_t sem_otime;			/* last semop() time */
+#if __WORDSIZE == 32
+  unsigned long int __glibc_reserved1;
+#endif
+  __time_t sem_ctime;			/* last time changed by semctl() */
+#if __WORDSIZE == 32
+  unsigned long int __glibc_reserved2;
+#endif
+  unsigned long int sem_nsems;		/* number of semaphores in set */
+  unsigned long int __glibc_reserved3;
+  unsigned long int __glibc_reserved4;
+};
+
+/* The user should define a union like the following to use it for arguments
+   for `semctl'.
+
+   union semun
+   {
+     int val;				<= value for SETVAL
+     struct semid_ds *buf;		<= buffer for IPC_STAT & IPC_SET
+     unsigned short int *array;		<= array for GETALL & SETALL
+     struct seminfo *__buf;		<= buffer for IPC_INFO
+   };
+
+   Previous versions of this file used to define this union but this is
+   incorrect.  One can test the macro _SEM_SEMUN_UNDEFINED to see whether
+   one must define the union or not.  */
+#define _SEM_SEMUN_UNDEFINED	1
+
+#ifdef __USE_MISC
+
+/* ipcs ctl cmds */
+# define SEM_STAT 18
+# define SEM_INFO 19
+
+struct seminfo
+{
+  int semmap;
+  int semmni;
+  int semmns;
+  int semmnu;
+  int semmsl;
+  int semopm;
+  int semume;
+  int semusz;
+  int semvmx;
+  int semaem;
+};
+
+#endif /* __USE_MISC */
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/shm.h b/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/shm.h
new file mode 100644
index 0000000000..057b85c601
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/shm.h
@@ -0,0 +1,111 @@
+/* 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/>.  */
+
+#ifndef _SYS_SHM_H
+# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
+#endif
+
+#include <bits/types.h>
+#include <bits/wordsize.h>
+
+/* Permission flag for shmget.  */
+#define SHM_R		0400		/* or S_IRUGO from <linux/stat.h> */
+#define SHM_W		0200		/* or S_IWUGO from <linux/stat.h> */
+
+/* Flags for `shmat'.  */
+#define SHM_RDONLY	010000		/* attach read-only else read-write */
+#define SHM_RND		020000		/* round attach address to SHMLBA */
+#define SHM_REMAP	040000		/* take-over region on attach */
+#define SHM_EXEC	0100000		/* execution access */
+
+/* Commands for `shmctl'.  */
+#define SHM_LOCK	11		/* lock segment (root only) */
+#define SHM_UNLOCK	12		/* unlock segment (root only) */
+
+__BEGIN_DECLS
+
+/* Segment low boundary address multiple.  */
+#define SHMLBA		(__getpagesize ())
+extern int __getpagesize (void) __THROW __attribute__ ((__const__));
+
+
+/* Type to count number of attaches.  */
+typedef unsigned long int shmatt_t;
+
+/* Data structure describing a shared memory segment.  */
+struct shmid_ds
+  {
+    struct ipc_perm shm_perm;		/* operation permission struct */
+    size_t shm_segsz;			/* size of segment in bytes */
+    __time_t shm_atime;			/* time of last shmat() */
+#if __WORDSIZE == 32
+    unsigned long int __glibc_reserved1;
+#endif
+    __time_t shm_dtime;			/* time of last shmdt() */
+#if __WORDSIZE == 32
+    unsigned long int __glibc_reserved2;
+#endif
+    __time_t shm_ctime;			/* time of last change by shmctl() */
+#if __WORDSIZE == 32
+    unsigned long int __glibc_reserved3;
+#endif
+    __pid_t shm_cpid;			/* pid of creator */
+    __pid_t shm_lpid;			/* pid of last shmop */
+    shmatt_t shm_nattch;		/* number of current attaches */
+    unsigned long int __glibc_reserved4;
+    unsigned long int __glibc_reserved5;
+  };
+
+#ifdef __USE_MISC
+
+/* ipcs ctl commands */
+# define SHM_STAT 	13
+# define SHM_INFO 	14
+
+/* shm_mode upper byte flags */
+# define SHM_DEST	01000	/* segment will be destroyed on last detach */
+# define SHM_LOCKED	02000   /* segment will not be swapped */
+# define SHM_HUGETLB	04000	/* segment is mapped via hugetlb */
+# define SHM_NORESERVE	010000	/* don't check for reservations */
+
+struct	shminfo
+  {
+    unsigned long int shmmax;
+    unsigned long int shmmin;
+    unsigned long int shmmni;
+    unsigned long int shmseg;
+    unsigned long int shmall;
+    unsigned long int __glibc_reserved1;
+    unsigned long int __glibc_reserved2;
+    unsigned long int __glibc_reserved3;
+    unsigned long int __glibc_reserved4;
+  };
+
+struct shm_info
+  {
+    int used_ids;
+    unsigned long int shm_tot;	/* total allocated shm */
+    unsigned long int shm_rss;	/* total resident shm */
+    unsigned long int shm_swp;	/* total swapped shm */
+    unsigned long int swap_attempts;
+    unsigned long int swap_successes;
+  };
+
+#endif /* __USE_MISC */
+
+__END_DECLS
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/stat.h b/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/stat.h
new file mode 100644
index 0000000000..6b2ee71e28
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/stat.h
@@ -0,0 +1,171 @@
+/* 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/>.  */
+
+#if !defined _SYS_STAT_H && !defined _FCNTL_H
+# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+#ifndef _BITS_STAT_H
+#define _BITS_STAT_H	1
+
+#include <endian.h>
+#include <bits/wordsize.h>
+
+/* 64-bit libc uses the kernel's 'struct stat', accessed via the
+   stat() syscall; 32-bit libc uses the kernel's 'struct stat64'
+   and accesses it via the stat64() syscall.  All the various
+   APIs offered by libc use the kernel shape for their struct stat
+   structure; the only difference is that 32-bit programs not
+   using __USE_FILE_OFFSET64 only see the low 32 bits of some
+   of the fields (specifically st_ino, st_size, and st_blocks).  */
+#define _STAT_VER_KERNEL	0
+#define _STAT_VER_LINUX		0
+#define _STAT_VER		_STAT_VER_KERNEL
+
+/* Versions of the `xmknod' interface.  */
+#define _MKNOD_VER_LINUX	0
+
+#if defined __USE_FILE_OFFSET64
+# define __field64(type, type64, name) type64 name
+#elif __WORDSIZE == 64
+# define __field64(type, type64, name) type name
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+# define __field64(type, type64, name) \
+  type name __attribute__((__aligned__ (__alignof__ (type64)))); int __##name##_pad
+#else
+# define __field64(type, type64, name) \
+  int __##name##_pad __attribute__((__aligned__ (__alignof__ (type64)))); type name
+#endif
+
+struct stat
+  {
+    __dev_t st_dev;		/* Device.  */
+    __field64(__ino_t, __ino64_t, st_ino);  /* File serial number. */
+    __mode_t st_mode;		/* File mode.  */
+    __nlink_t st_nlink;		/* Link count.  */
+    __uid_t st_uid;		/* User ID of the file's owner.	*/
+    __gid_t st_gid;		/* Group ID of the file's group.*/
+    __dev_t st_rdev;		/* Device number, if device.  */
+    __dev_t __pad1;
+    __field64(__off_t, __off64_t, st_size);  /* Size of file, in bytes. */
+    __blksize_t st_blksize;	/* Optimal block size for I/O.  */
+    int __pad2;
+    __field64(__blkcnt_t, __blkcnt64_t, st_blocks);  /* 512-byte blocks */
+#ifdef __USE_XOPEN2K8
+    /* Nanosecond resolution timestamps are stored in a format
+       equivalent to 'struct timespec'.  This is the type used
+       whenever possible but the Unix namespace rules do not allow the
+       identifier 'timespec' to appear in the <sys/stat.h> header.
+       Therefore we have to handle the use of this header in strictly
+       standard-compliant sources special.  */
+    struct timespec st_atim;		/* Time of last access.  */
+    struct timespec st_mtim;		/* Time of last modification.  */
+    struct timespec st_ctim;		/* Time of last status change.  */
+# define st_atime st_atim.tv_sec	/* Backward compatibility.  */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
+    __time_t st_atime;			/* Time of last access.  */
+    unsigned long int st_atimensec;	/* Nscecs of last access.  */
+    __time_t st_mtime;			/* Time of last modification.  */
+    unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
+    __time_t st_ctime;			/* Time of last status change.  */
+    unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
+#endif
+    int __glibc_reserved[2];
+  };
+
+#undef __field64
+
+#ifdef __USE_LARGEFILE64
+struct stat64
+  {
+    __dev_t st_dev;		/* Device.  */
+    __ino64_t st_ino;		/* File serial number.	*/
+    __mode_t st_mode;		/* File mode.  */
+    __nlink_t st_nlink;		/* Link count.  */
+    __uid_t st_uid;		/* User ID of the file's owner.	*/
+    __gid_t st_gid;		/* Group ID of the file's group.*/
+    __dev_t st_rdev;		/* Device number, if device.  */
+    __dev_t __pad1;
+    __off64_t st_size;		/* Size of file, in bytes.  */
+    __blksize_t st_blksize;	/* Optimal block size for I/O.  */
+    int __pad2;
+    __blkcnt64_t st_blocks;	/* Nr. 512-byte blocks allocated.  */
+#ifdef __USE_XOPEN2K8
+    /* Nanosecond resolution timestamps are stored in a format
+       equivalent to 'struct timespec'.  This is the type used
+       whenever possible but the Unix namespace rules do not allow the
+       identifier 'timespec' to appear in the <sys/stat.h> header.
+       Therefore we have to handle the use of this header in strictly
+       standard-compliant sources special.  */
+    struct timespec st_atim;		/* Time of last access.  */
+    struct timespec st_mtim;		/* Time of last modification.  */
+    struct timespec st_ctim;		/* Time of last status change.  */
+#else
+    __time_t st_atime;			/* Time of last access.  */
+    unsigned long int st_atimensec;	/* Nscecs of last access.  */
+    __time_t st_mtime;			/* Time of last modification.  */
+    unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
+    __time_t st_ctime;			/* Time of last status change.  */
+    unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
+#endif
+    int __glibc_reserved[2];
+  };
+#endif
+
+/* Tell code we have these members.  */
+#define	_STATBUF_ST_BLKSIZE
+#define _STATBUF_ST_RDEV
+/* Nanosecond resolution time values are supported.  */
+#define _STATBUF_ST_NSEC
+
+/* Encoding of the file mode.  */
+
+#define	__S_IFMT	0170000	/* These bits determine file type.  */
+
+/* File types.  */
+#define	__S_IFDIR	0040000	/* Directory.  */
+#define	__S_IFCHR	0020000	/* Character device.  */
+#define	__S_IFBLK	0060000	/* Block device.  */
+#define	__S_IFREG	0100000	/* Regular file.  */
+#define	__S_IFIFO	0010000	/* FIFO.  */
+#define	__S_IFLNK	0120000	/* Symbolic link.  */
+#define	__S_IFSOCK	0140000	/* Socket.  */
+
+/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
+   they do it by enforcing the correct use of the macros.  */
+#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
+#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
+#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
+
+/* Protection bits.  */
+
+#define	__S_ISUID	04000	/* Set user ID on execution.  */
+#define	__S_ISGID	02000	/* Set group ID on execution.  */
+#define	__S_ISVTX	01000	/* Save swapped text after use (sticky).  */
+#define	__S_IREAD	0400	/* Read by owner.  */
+#define	__S_IWRITE	0200	/* Write by owner.  */
+#define	__S_IEXEC	0100	/* Execute by owner.  */
+
+#ifdef __USE_ATFILE
+# define UTIME_NOW	((1l << 30) - 1l)
+# define UTIME_OMIT	((1l << 30) - 2l)
+#endif
+
+#endif /* bits/stat.h */
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/statfs.h b/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/statfs.h
new file mode 100644
index 0000000000..8dc8f0aa79
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/statfs.h
@@ -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/>.  */
+
+#ifndef _SYS_STATFS_H
+# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
+#endif
+
+#include <endian.h>
+#include <bits/types.h>
+#include <bits/wordsize.h>
+
+/* 64-bit libc uses the kernel's 'struct statfs', accessed via the
+   statfs() syscall; 32-bit libc uses the kernel's 'struct statfs64'
+   and accesses it via the statfs64() syscall.  All the various
+   APIs offered by libc use the kernel shape for their struct statfs
+   structure; the only difference is that 32-bit programs not
+   using __USE_FILE_OFFSET64 only see the low 32 bits of some
+   of the fields (the __fsblkcnt_t and __fsfilcnt_t fields).  */
+
+#if defined __USE_FILE_OFFSET64
+# define __field64(type, type64, name) type64 name
+#elif __WORDSIZE == 64
+# define __field64(type, type64, name) type name
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+# define __field64(type, type64, name) \
+  type name __attribute__((__aligned__ (__alignof__ (type64)))); int __##name##_pad
+#else
+# define __field64(type, type64, name) \
+  int __##name##_pad __attribute__((__aligned__ (__alignof__ (type64)))); type name
+#endif
+
+struct statfs
+  {
+    __SWORD_TYPE f_type;
+    __SWORD_TYPE f_bsize;
+    __field64(__fsblkcnt_t, __fsblkcnt64_t, f_blocks);
+    __field64(__fsblkcnt_t, __fsblkcnt64_t, f_bfree);
+    __field64(__fsblkcnt_t, __fsblkcnt64_t, f_bavail);
+    __field64(__fsfilcnt_t, __fsfilcnt64_t, f_files);
+    __field64(__fsfilcnt_t, __fsfilcnt64_t, f_ffree);
+    __fsid_t f_fsid;
+    __SWORD_TYPE f_namelen;
+    __SWORD_TYPE f_frsize;
+    __SWORD_TYPE f_flags;
+    __SWORD_TYPE f_spare[4];
+  };
+
+#undef __field64
+
+#ifdef __USE_LARGEFILE64
+struct statfs64
+  {
+    __SWORD_TYPE f_type;
+    __SWORD_TYPE f_bsize;
+    __fsblkcnt64_t f_blocks;
+    __fsblkcnt64_t f_bfree;
+    __fsblkcnt64_t f_bavail;
+    __fsfilcnt64_t f_files;
+    __fsfilcnt64_t f_ffree;
+    __fsid_t f_fsid;
+    __SWORD_TYPE f_namelen;
+    __SWORD_TYPE f_frsize;
+    __SWORD_TYPE f_flags;
+    __SWORD_TYPE f_spare[4];
+  };
+#endif
+
+/* Tell code we have these members.  */
+#define _STATFS_F_NAMELEN
+#define _STATFS_F_FRSIZE
+#define _STATFS_F_FLAGS
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
new file mode 100644
index 0000000000..49e911ef8c
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
@@ -0,0 +1,84 @@
+/* bits/typesizes.h -- underlying types for *_t.  For the generic Linux ABI.
+   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/>.  */
+
+#ifndef _BITS_TYPES_H
+# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
+#endif
+
+#ifndef	_BITS_TYPESIZES_H
+#define	_BITS_TYPESIZES_H	1
+
+/* See <bits/types.h> for the meaning of these macros.  This file exists so
+   that <bits/types.h> need not vary across different GNU platforms.  */
+
+#define __DEV_T_TYPE		__UQUAD_TYPE
+#define __UID_T_TYPE		__U32_TYPE
+#define __GID_T_TYPE		__U32_TYPE
+#define __INO_T_TYPE		__ULONGWORD_TYPE
+#define __INO64_T_TYPE		__UQUAD_TYPE
+#define __MODE_T_TYPE		__U32_TYPE
+#define __NLINK_T_TYPE		__U32_TYPE
+#define __OFF_T_TYPE		__SLONGWORD_TYPE
+#define __OFF64_T_TYPE		__SQUAD_TYPE
+#define __PID_T_TYPE		__S32_TYPE
+#define __RLIM_T_TYPE		__ULONGWORD_TYPE
+#define __RLIM64_T_TYPE		__UQUAD_TYPE
+#define	__BLKCNT_T_TYPE		__SLONGWORD_TYPE
+#define	__BLKCNT64_T_TYPE	__SQUAD_TYPE
+#define	__FSBLKCNT_T_TYPE	__ULONGWORD_TYPE
+#define	__FSBLKCNT64_T_TYPE	__UQUAD_TYPE
+#define	__FSFILCNT_T_TYPE	__ULONGWORD_TYPE
+#define	__FSFILCNT64_T_TYPE	__UQUAD_TYPE
+#define	__FSWORD_T_TYPE		__SWORD_TYPE
+#define	__ID_T_TYPE		__U32_TYPE
+#define __CLOCK_T_TYPE		__SLONGWORD_TYPE
+#define __TIME_T_TYPE		__SLONGWORD_TYPE
+#define __USECONDS_T_TYPE	__U32_TYPE
+#define __SUSECONDS_T_TYPE	__SLONGWORD_TYPE
+#define __DADDR_T_TYPE		__S32_TYPE
+#define __KEY_T_TYPE		__S32_TYPE
+#define __CLOCKID_T_TYPE	__S32_TYPE
+#define __TIMER_T_TYPE		void *
+#define __BLKSIZE_T_TYPE	__S32_TYPE
+#define __FSID_T_TYPE		struct { int __val[2]; }
+#define __SSIZE_T_TYPE		__SWORD_TYPE
+#define __SYSCALL_SLONG_TYPE	__SLONGWORD_TYPE
+#define __SYSCALL_ULONG_TYPE	__ULONGWORD_TYPE
+#define __CPU_MASK_TYPE 	__ULONGWORD_TYPE
+
+#ifdef __LP64__
+/* Tell the libc code that off_t and off64_t are actually the same type
+   for all ABI purposes, even if possibly expressed as different base types
+   for C type-checking purposes.  */
+# define __OFF_T_MATCHES_OFF64_T	1
+
+/* Same for ino_t and ino64_t.  */
+# define __INO_T_MATCHES_INO64_T	1
+
+/* And for __rlim_t and __rlim64_t.  */
+# define __RLIM_T_MATCHES_RLIM64_T	1
+#else
+# define __RLIM_T_MATCHES_RLIM64_T	0
+#endif
+
+/* Number of descriptors that can fit in an `fd_set'.  */
+#define	__FD_SETSIZE		1024
+
+
+#endif /* bits/typesizes.h */
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/brk.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/brk.c
new file mode 100644
index 0000000000..7838ecdb9b
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/brk.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 <unistd.h>
+#include <sysdep.h>
+
+/* This must be initialized data because commons can't have aliases.  */
+void *__curbrk = 0;
+
+/* Old braindamage in GCC's crtstuff.c requires this symbol in an attempt
+   to work around different old braindamage in the old Linux ELF dynamic
+   linker.  */
+weak_alias (__curbrk, ___brk_addr)
+
+int
+__brk (void *addr)
+{
+  INTERNAL_SYSCALL_DECL (err);
+
+  __curbrk = (void *) INTERNAL_SYSCALL (brk, err, 1, addr);
+  if (__curbrk < addr)
+    {
+      __set_errno (ENOMEM);
+      return -1;
+    }
+
+  return 0;
+}
+weak_alias (__brk, brk)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/chmod.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/chmod.c
new file mode 100644
index 0000000000..41d6d9851f
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/chmod.c
@@ -0,0 +1,31 @@
+/* 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 <sys/types.h>
+
+/* Change the protections of FILE to MODE.  */
+int
+__chmod (const char *file, mode_t mode)
+{
+  return INLINE_SYSCALL (fchmodat, 3, AT_FDCWD, file, mode);
+}
+weak_alias (__chmod, chmod)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/chown.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/chown.c
new file mode 100644
index 0000000000..1917f44f65
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/chown.c
@@ -0,0 +1,32 @@
+/* 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 <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+
+/* Change the owner and group of FILE.  */
+int
+__chown (const char *file, uid_t owner, gid_t group)
+{
+  return INLINE_SYSCALL (fchownat, 5, AT_FDCWD, file, owner, group, 0);
+}
+libc_hidden_def (__chown)
+weak_alias (__chown, chown)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/dl-origin.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/dl-origin.c
new file mode 100644
index 0000000000..04ea9044be
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/dl-origin.c
@@ -0,0 +1,81 @@
+/* Find path of executable.
+   Copyright (C) 1998-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   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 <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/param.h>
+#include <ldsodefs.h>
+#include <sysdep.h>
+
+#include <dl-dst.h>
+
+/* On Linux >= 2.1 systems which have the dcache implementation we can get
+   the path of the application from the /proc/self/exe symlink.  Try this
+   first and fall back on the generic method if necessary.  */
+
+const char *
+_dl_get_origin (void)
+{
+  char linkval[PATH_MAX];
+  char *result;
+  int len;
+  INTERNAL_SYSCALL_DECL (err);
+
+  len = INTERNAL_SYSCALL (readlinkat, err, 4, AT_FDCWD, "/proc/self/exe",
+                          linkval, sizeof (linkval));
+  if (! INTERNAL_SYSCALL_ERROR_P (len, err) && len > 0 && linkval[0] != '[')
+    {
+      /* We can use this value.  */
+      assert (linkval[0] == '/');
+      while (len > 1 && linkval[len - 1] != '/')
+	--len;
+      result = (char *) malloc (len + 1);
+      if (result == NULL)
+	result = (char *) -1;
+      else if (len == 1)
+	memcpy (result, "/", 2);
+      else
+	*((char *) __mempcpy (result, linkval, len - 1)) = '\0';
+    }
+  else
+    {
+      result = (char *) -1;
+      /* We use the environment variable LD_ORIGIN_PATH.  If it is set make
+	 a copy and strip out trailing slashes.  */
+      if (GLRO(dl_origin_path) != NULL)
+	{
+	  size_t len = strlen (GLRO(dl_origin_path));
+	  result = (char *) malloc (len + 1);
+	  if (result == NULL)
+	    result = (char *) -1;
+	  else
+	    {
+	      char *cp = __mempcpy (result, GLRO(dl_origin_path), len);
+	      while (cp > result + 1 && cp[-1] == '/')
+		--cp;
+	      *cp = '\0';
+	    }
+	}
+    }
+
+  return result;
+}
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/dup2.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/dup2.c
new file mode 100644
index 0000000000..c86b85bff1
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/dup2.c
@@ -0,0 +1,37 @@
+/* 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 <limits.h>
+#include <unistd.h>
+
+/* Duplicate FD to FD2, closing the old FD2 and making FD2 be
+   open the same file as FD is.  Return FD2 or -1.  */
+int
+__dup2 (int fd, int fd2)
+{
+  /* For the degenerate case, check if the fd is valid (by trying to
+     get the file status flags) and return it, or else return EBADF.  */
+  if (fd == fd2)
+    return __libc_fcntl (fd, F_GETFL, 0) < 0 ? -1 : fd;
+
+  return INLINE_SYSCALL (dup3, 3, fd, fd2, 0);
+}
+libc_hidden_def (__dup2)
+weak_alias (__dup2, dup2)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/epoll_create.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/epoll_create.c
new file mode 100644
index 0000000000..6034bccca5
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/epoll_create.c
@@ -0,0 +1,38 @@
+/* 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 <stddef.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/epoll.h>
+
+libc_hidden_proto (epoll_create)
+
+int
+epoll_create (int size)
+{
+  if (size <= 0)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return INLINE_SYSCALL (epoll_create1, 1, 0);
+}
+libc_hidden_def (epoll_create)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/futimesat.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/futimesat.c
new file mode 100644
index 0000000000..afc580a8c6
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/futimesat.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 2005-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 <string.h>
+#include <utime.h>
+#include <sys/time.h>
+#include <sysdep.h>
+
+
+/* Change the access time of FILE relative to FD to TVP[0] and
+   the modification time of FILE to TVP[1].  */
+int
+futimesat (int fd, const char *file, const struct timeval tvp[2])
+{
+  struct timespec tsp[2];
+  int result;
+
+  if (tvp)
+    {
+      if (tvp[0].tv_usec >= 1000000 || tvp[0].tv_usec < 0 ||
+          tvp[1].tv_usec >= 1000000 || tvp[1].tv_usec < 0)
+        {
+          __set_errno (EINVAL);
+          return -1;
+        }
+      TIMEVAL_TO_TIMESPEC (&tvp[0], &tsp[0]);
+      TIMEVAL_TO_TIMESPEC (&tvp[1], &tsp[1]);
+    }
+
+  result = INLINE_SYSCALL (utimensat, 4, fd, file, tvp ? tsp : NULL, 0);
+  return result;
+}
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/getdents.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/getdents.c
new file mode 100644
index 0000000000..14dbbc71a0
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/getdents.c
@@ -0,0 +1 @@
+/* Defined in getdents64.c */
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/getdents64.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/getdents64.c
new file mode 100644
index 0000000000..2334201bc4
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/getdents64.c
@@ -0,0 +1,37 @@
+/* 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 <stddef.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <bits/wordsize.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* The kernel struct linux_dirent64 matches the 'struct getdents64' type.  */
+ssize_t
+__getdents64 (int fd, char *buf, size_t nbytes)
+{
+  return INLINE_SYSCALL (getdents64, 3, fd, buf, nbytes);
+}
+
+#if __WORDSIZE == 64
+strong_alias (__getdents64, __getdents)
+#endif
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/inotify_init.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/inotify_init.c
new file mode 100644
index 0000000000..cbf2034d99
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/inotify_init.c
@@ -0,0 +1,32 @@
+/* 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 <stddef.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/inotify.h>
+
+libc_hidden_proto (inotify_init)
+
+int
+inotify_init (void)
+{
+  return INLINE_SYSCALL (inotify_init1, 1, 0);
+}
+libc_hidden_def (inotify_init)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/kernel_stat.h b/REORG.TODO/sysdeps/unix/sysv/linux/generic/kernel_stat.h
new file mode 100644
index 0000000000..574907b0da
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/kernel_stat.h
@@ -0,0 +1,30 @@
+/* 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 <bits/wordsize.h>
+
+#define STAT_IS_KERNEL_STAT 1
+
+/* We provide separate 32-bit API versions that check for EOVERFLOW. */
+#if __WORDSIZE == 64
+# define XSTAT_IS_XSTAT64 1
+#else
+# define XSTAT_IS_XSTAT64 0
+#endif
+
+#define STATFS_IS_STATFS64 0
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/lchown.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/lchown.c
new file mode 100644
index 0000000000..c69a85fb1c
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/lchown.c
@@ -0,0 +1,32 @@
+/* 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 <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+
+/* Change the owner and group of FILE.  */
+int
+__lchown (const char *file, uid_t owner, gid_t group)
+{
+  return INLINE_SYSCALL (fchownat, 5, AT_FDCWD, file, owner, group,
+                         AT_SYMLINK_NOFOLLOW);
+}
+weak_alias (__lchown, lchown)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/link.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/link.c
new file mode 100644
index 0000000000..d2e5ed968f
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/link.c
@@ -0,0 +1,31 @@
+/* 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 <unistd.h>
+#include <fcntl.h>
+
+/* Make a link to FROM called TO.  */
+int
+__link (const char *from, const char *to)
+{
+  return INLINE_SYSCALL (linkat, 5, AT_FDCWD, from, AT_FDCWD, to, 0);
+}
+
+weak_alias (__link, link)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/lxstat.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/lxstat.c
new file mode 100644
index 0000000000..becc17c531
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/lxstat.c
@@ -0,0 +1,48 @@
+/* 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/>.  */
+
+/* Ignore prototype to avoid error if we alias __lxstat and __lxstat64. */
+#define __lxstat64 __lxstat64_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
+__lxstat (int vers, const char *name, struct stat *buf)
+{
+  if (vers == _STAT_VER_KERNEL)
+    return INLINE_SYSCALL (newfstatat, 4, AT_FDCWD, name, buf,
+                           AT_SYMLINK_NOFOLLOW);
+  errno = EINVAL;
+  return -1;
+}
+
+hidden_def (__lxstat)
+weak_alias (__lxstat, _lxstat);
+#if XSTAT_IS_XSTAT64
+#undef __lxstat64
+strong_alias (__lxstat, __lxstat64);
+hidden_ver (__lxstat, __lxstat64)
+#endif
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/mkdir.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/mkdir.c
new file mode 100644
index 0000000000..6571d29ca3
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/mkdir.c
@@ -0,0 +1,33 @@
+/* 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 <sysdep.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+
+/* Create a directory named PATH with protections MODE.  */
+int
+__mkdir (const char *path, mode_t mode)
+{
+  return INLINE_SYSCALL (mkdirat, 3, AT_FDCWD, path, mode);
+}
+weak_alias (__mkdir, mkdir)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/pipe.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/pipe.c
new file mode 100644
index 0000000000..4b3c5bd3b2
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/pipe.c
@@ -0,0 +1,33 @@
+/* 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 <unistd.h>
+#include <stddef.h>
+
+/* Create a one-way communication channel (__pipe).
+   If successful, two file descriptors are stored in PIPEDES;
+   bytes written on PIPEDES[1] can be read from PIPEDES[0].
+   Returns 0 if successful, -1 if not.  */
+int
+__pipe (int __pipedes[2])
+{
+  return INLINE_SYSCALL (pipe2, 2, __pipedes, 0);
+}
+libc_hidden_def (__pipe)
+weak_alias (__pipe, pipe)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/readlink.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/readlink.c
new file mode 100644
index 0000000000..ad2d018a4f
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/readlink.c
@@ -0,0 +1,31 @@
+/* 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 <unistd.h>
+#include <fcntl.h>
+
+/* Read the contents of the symbolic link PATH into no more than
+   LEN bytes of BUF.  The contents are not null-terminated.
+   Returns the number of characters read, or -1 for errors.  */
+ssize_t
+__readlink (const char *path, char *buf, size_t len)
+{
+  return INLINE_SYSCALL (readlinkat, 4, AT_FDCWD, path, buf, len);
+}
+weak_alias (__readlink, readlink)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/readlink_chk.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/readlink_chk.c
new file mode 100644
index 0000000000..54b108fead
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/readlink_chk.c
@@ -0,0 +1,39 @@
+/* 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 <unistd.h>
+#include <fcntl.h>
+#include <sys/param.h>
+#ifdef HAVE_INLINED_SYSCALLS
+# include <errno.h>
+# include <sysdep.h>
+#endif
+
+
+ssize_t
+__readlink_chk (const char *path, void *buf, size_t len, size_t buflen)
+{
+  if (len > buflen)
+    __chk_fail ();
+
+#ifdef HAVE_INLINED_SYSCALLS
+  return INLINE_SYSCALL (readlinkat, 4, AT_FDCWD, path, buf, len);
+#else
+  return __readlink (path, buf, len);
+#endif
+}
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/rmdir.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/rmdir.c
new file mode 100644
index 0000000000..2048c08b06
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/rmdir.c
@@ -0,0 +1,31 @@
+/* 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 <unistd.h>
+#include <fcntl.h>
+
+
+/* Remove the directory PATH.  */
+int
+__rmdir (const char *path)
+{
+  return INLINE_SYSCALL (unlinkat, 3, AT_FDCWD, path, AT_REMOVEDIR);
+}
+weak_alias (__rmdir, rmdir)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/symlink.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/symlink.c
new file mode 100644
index 0000000000..70cc4ab70d
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/symlink.c
@@ -0,0 +1,30 @@
+/* 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 <unistd.h>
+#include <fcntl.h>
+
+/* Make a link to FROM called TO.  */
+int
+__symlink (const char *from, const char *to)
+{
+  return INLINE_SYSCALL (symlinkat, 3, from, AT_FDCWD, to);
+}
+weak_alias (__symlink, symlink)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/syscalls.list b/REORG.TODO/sysdeps/unix/sysv/linux/generic/syscalls.list
new file mode 100644
index 0000000000..ed8b216d47
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/syscalls.list
@@ -0,0 +1,12 @@
+# File name	Caller	Syscall name	# args	Strong name	Weak names
+
+# Socket APIs
+socket		-	socket		i:iii	__socket	socket
+socketpair	-	socketpair	i:iiif	__socketpair	socketpair
+bind		-	bind		i:ipi	__bind		bind
+listen		-	listen		i:ii	__listen	listen
+getsockname	-	getsockname	i:ipp	__getsockname	getsockname
+getpeername	-	getpeername	i:ipp	__getpeername	getpeername
+setsockopt	-	setsockopt	i:iiibn	__setsockopt	setsockopt
+getsockopt	-	getsockopt	i:iiiBN	__getsockopt	getsockopt
+shutdown	-	shutdown	i:ii	__shutdown	shutdown
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/sysctl.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/sysctl.c
new file mode 100644
index 0000000000..f9961d4cdb
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/sysctl.c
@@ -0,0 +1,32 @@
+/* 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 <sysdep.h>
+#include <sys/syscall.h>
+
+/* This deprecated syscall is no longer used (replaced with /proc/sys).  */
+int
+sysctl (int *name, int nlen, void *oldval, size_t *oldlenp,
+        void *newval, size_t newlen)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (sysctl)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/sysdep.h b/REORG.TODO/sysdeps/unix/sysv/linux/generic/sysdep.h
new file mode 100644
index 0000000000..0e854ad69e
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/sysdep.h
@@ -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 <bits/wordsize.h>
+#include <kernel-features.h>
+#include <sysdeps/unix/sysdep.h>
+#include <sysdeps/unix/sysv/linux/sysdep.h>
+
+/* Provide the common name to allow more code reuse.  */
+#ifdef __NR_llseek
+# define __NR__llseek __NR_llseek
+#endif
+
+#if __WORDSIZE == 64
+/* By defining the older names, glibc will build syscall wrappers for
+   both pread and pread64; sysdeps/unix/sysv/linux/wordsize-64/pread64.c
+   will suppress generating any separate code for pread64.c.  */
+#define __NR_pread __NR_pread64
+#define __NR_pwrite __NR_pwrite64
+#endif
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/umount.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/umount.c
new file mode 100644
index 0000000000..6b933c6e43
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/umount.c
@@ -0,0 +1,30 @@
+/* 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/>.  */
+
+/* Since the generic Linux syscall ABI doesn't have an oldumount system call,
+   do what the kernel does down here.  */
+
+extern long int __umount2 (const char *name, int flags);
+
+long int
+__umount (const char *name)
+{
+  return __umount2 (name, 0);
+}
+
+weak_alias (__umount, umount);
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/unlink.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/unlink.c
new file mode 100644
index 0000000000..25953f2145
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/unlink.c
@@ -0,0 +1,31 @@
+/* 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 <unistd.h>
+#include <fcntl.h>
+
+
+/* Remove the link named NAME.  */
+int
+__unlink (const char *name)
+{
+  return INLINE_SYSCALL (unlinkat, 3, AT_FDCWD, name, 0);
+}
+weak_alias (__unlink, unlink)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/ustat.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/ustat.c
new file mode 100644
index 0000000000..780d931a5c
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/ustat.c
@@ -0,0 +1,32 @@
+/* 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/ustat.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* This deprecated syscall is no longer used (replaced with fstat).  */
+int
+ustat (dev_t dev, struct ustat *ubuf)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (ustat)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/utimes.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/utimes.c
new file mode 100644
index 0000000000..de8d6d9df7
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/utimes.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 <utime.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <sysdep.h>
+
+
+/* Change the access time of FILE to TVP[0] and
+   the modification time of FILE to TVP[1].  */
+int
+__utimes (const char *file, const struct timeval tvp[2])
+{
+  struct timespec ts[2];
+  struct timespec *tsp = NULL;
+
+  if (tvp)
+    {
+      TIMEVAL_TO_TIMESPEC (&tvp[0], &ts[0]);
+      TIMEVAL_TO_TIMESPEC (&tvp[1], &ts[1]);
+      tsp = &ts[0];
+    }
+
+  return INLINE_SYSCALL (utimensat, 4, AT_FDCWD, file, tsp, 0);
+}
+
+weak_alias (__utimes, utimes)
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
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/xmknod.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/xmknod.c
new file mode 100644
index 0000000000..5e91539894
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/xmknod.c
@@ -0,0 +1,54 @@
+/* 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 <sys/types.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* Create a device file named PATH, with permission and special bits MODE
+   and device number DEV (which can be constructed from major and minor
+   device numbers with the `makedev' macro above).  */
+int
+__xmknod (int vers, const char *path, mode_t mode, dev_t *dev)
+{
+  unsigned long long int k_dev;
+
+  if (vers != _MKNOD_VER)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  /* We must convert the value to dev_t type used by the kernel.  */
+  k_dev = (*dev) & ((1ULL << 32) - 1);
+  if (k_dev != *dev)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return INLINE_SYSCALL (mknodat, 4, AT_FDCWD, path, mode,
+                         (unsigned int) k_dev);
+}
+weak_alias (__xmknod, _xmknod)
+libc_hidden_def (__xmknod)
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/generic/xstat.c b/REORG.TODO/sysdeps/unix/sysv/linux/generic/xstat.c
new file mode 100644
index 0000000000..1a7277a802
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/generic/xstat.c
@@ -0,0 +1,48 @@
+/* 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/>.  */
+
+/* Ignore prototype to avoid error if we alias __xstat and __xstat64. */
+#define __xstat64 __xstat64_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
+__xstat (int vers, const char *name, struct stat *buf)
+{
+  if (vers == _STAT_VER_KERNEL)
+    return INLINE_SYSCALL (newfstatat, 4, AT_FDCWD, name, buf, 0);
+
+  errno = EINVAL;
+  return -1;
+}
+
+hidden_def (__xstat)
+weak_alias (__xstat, _xstat);
+#if XSTAT_IS_XSTAT64
+#undef __xstat64
+strong_alias (__xstat, __xstat64);
+hidden_ver (__xstat, __xstat64)
+#endif