Merge "Update processed linux/fs.h header file" into jb-mr2-dev
diff --git a/ABI-bugs.txt b/ABI-bugs.txt
new file mode 100644
index 0000000..83ee952
--- /dev/null
+++ b/ABI-bugs.txt
@@ -0,0 +1,15 @@
+KNOWN ABI BUGS
+--------------
+
+  time_t is 32-bit. http://b/5819737
+
+  off_t is 32-bit. There is off64_t, but no _FILE_OFFSET_BITS support.
+
+  sigset_t is too small on ARM and x86 (but correct on MIPS), so support
+  for real-time signals is broken. http://b/5828899
+
+  Too few TLS slots mean we can't allocate 128 pthread_key_t instances,
+  which POSIX says should be the minimum.
+
+  atexit(3) handlers registered by a shared library aren't called on
+  dlclose(3); this only affects ARM. http://b/4998315
diff --git a/libc/Android.mk b/libc/Android.mk
index 21d3089..f53fcc8 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -11,7 +11,6 @@
 	unistd/exec.c \
 	unistd/fnmatch.c \
 	unistd/getopt_long.c \
-	unistd/popen.c \
 	unistd/syslog.c \
 	unistd/system.c \
 	unistd/time.c \
@@ -150,7 +149,6 @@
 	bionic/isatty.c \
 	bionic/issetugid.c \
 	bionic/ldexp.c \
-	bionic/logd_write.c \
 	bionic/lseek64.c \
 	bionic/md5.c \
 	bionic/memchr.c \
@@ -205,7 +203,6 @@
 	bionic/unlockpt.c \
 	bionic/usleep.c \
 	bionic/utmp.c \
-	bionic/wait.c \
 	bionic/wcscoll.c \
 	netbsd/gethnamaddr.c \
 	netbsd/inet/nsap_addr.c \
@@ -239,7 +236,6 @@
 libc_bionic_src_files := \
     bionic/assert.cpp \
     bionic/brk.cpp \
-    bionic/debug_format.cpp \
     bionic/dirent.cpp \
     bionic/__errno.c \
     bionic/eventfd.cpp \
@@ -247,6 +243,7 @@
     bionic/getauxval.cpp \
     bionic/getcwd.cpp \
     bionic/libc_init_common.cpp \
+    bionic/libc_logging.cpp \
     bionic/libgen.cpp \
     bionic/__memcpy_chk.cpp \
     bionic/__memmove_chk.cpp \
@@ -287,6 +284,7 @@
     bionic/__umask_chk.cpp \
     bionic/__vsnprintf_chk.cpp \
     bionic/__vsprintf_chk.cpp \
+    bionic/wait.cpp \
     bionic/wchar.cpp \
 
 libc_upstream_freebsd_src_files := \
@@ -326,6 +324,7 @@
     upstream-netbsd/libc/gen/ftw.c \
     upstream-netbsd/libc/gen/nftw.c \
     upstream-netbsd/libc/gen/nice.c \
+    upstream-netbsd/libc/gen/popen.c \
     upstream-netbsd/libc/gen/psignal.c \
     upstream-netbsd/libc/gen/setjmperr.c \
     upstream-netbsd/libc/gen/utime.c \
@@ -367,7 +366,6 @@
 ifeq ($(TARGET_ARCH),arm)
 libc_common_src_files += \
 	bionic/memmove.c.arm \
-	bionic/socketcalls.c \
 	string/bcopy.c \
 	string/strncmp.c \
 
@@ -677,7 +675,7 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := bionic/__stack_chk_fail.cpp bionic/__stack_chk_guard.cpp
+LOCAL_SRC_FILES := bionic/__stack_chk_fail.cpp
 LOCAL_CFLAGS := $(libc_common_cflags) -fno-stack-protector -Werror
 LOCAL_C_INCLUDES := $(libc_common_c_includes)
 LOCAL_MODULE := libbionic_ssp
diff --git a/libc/NOTICE b/libc/NOTICE
index 3be0f85..730fa46 100644
--- a/libc/NOTICE
+++ b/libc/NOTICE
@@ -4030,6 +4030,34 @@
 
 -------------------------------------------------------------------
 
+Copyright (c) 2013 ARM Ltd
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the company may not be used to endorse or promote
+   products derived from this software without specific prior written
+   permission.
+
+THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-------------------------------------------------------------------
+
 Copyright (c)1999 Citrus Project,
 All rights reserved.
 
diff --git a/libc/README b/libc/README
deleted file mode 100644
index d92d85d..0000000
--- a/libc/README
+++ /dev/null
@@ -1,54 +0,0 @@
-Welcome to Bionic, Android's small and custom C library for the Android
-platform.
-
-Bionic is mainly a port of the BSD C library to our Linux kernel with the
-following additions/changes:
-
-- no support for locales
-- no support for wide chars (i.e. multi-byte characters)
-- its own smallish implementation of pthreads based on Linux futexes
-- support for x86, ARM and ARM thumb CPU instruction sets and kernel interfaces
-
-Bionic is released under the standard 3-clause BSD License
-
-Bionic doesn't want to implement all features of a traditional C library, we only
-add features to it as we need them, and we try to keep things as simple and small
-as possible. Our goal is not to support scaling to thousands of concurrent threads
-on multi-processors machines; we're running this on cell-phones, damnit !!
-
-Note that Bionic doesn't provide a libthread_db or a libm implementation.
-
-
-Adding new syscalls:
-====================
-
-Bionic provides the gensyscalls.py Python script to automatically generate syscall
-stubs from the list defined in the file SYSCALLS.TXT. You can thus add a new syscall
-by doing the following:
-
-- edit SYSCALLS.TXT
-- add a new line describing your syscall, it should look like:
-
-   return_type  syscall_name(parameters)    syscall_number
-
-- in the event where you want to differentiate the syscall function from its entry name,
-  use the alternate:
-
-   return_type  funcname:syscall_name(parameters)  syscall_number
-
-- additionally, if the syscall number is different between ARM and x86, use:
-
-   return_type  funcname[:syscall_name](parameters)   arm_number,x86_number
-
-- a syscall number can be -1 to indicate that the syscall is not implemented on
-  a given platform, for example:
-
-   void   __set_tls(void*)   arm_number,-1
-
-
-the comments in SYSCALLS.TXT contain more information about the line format
-
-You can also use the 'checksyscalls.py' script to check that all the syscall
-numbers you entered are correct. It does so by looking at the values defined in
-your Linux kernel headers. The script indicates where the values are incorrect
-and what is expected instead.
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index dc139bd..bf56ffe 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -25,7 +25,10 @@
 #      - additionally, if the syscall number is different amoung ARM, and x86, MIPS use:
 #        return_type funcname[:syscall_name](parameters) arm_number,x86_number,mips_number
 #
-# the file is processed by a python script named gensyscalls.py
+# This file is processed by a python script named gensyscalls.py.
+#
+# The checksyscalls.py script can check that the syscall numbers here are
+# correct by comparing them to the numbers in the Linux kernel headers.
 #
 
 # process management
@@ -34,6 +37,7 @@
 pid_t   __fork:fork (void)           2
 pid_t   _waitpid:waitpid (pid_t, int*, int, struct rusage*)   -1,7,7
 int     __waitid:waitid(int, pid_t, struct siginfo_t*, int,void*)          280,284,278
+pid_t   wait4(pid_t pid, int *status, int options, struct rusage *rusage)   114
 
 # NOTE: this system call is never called directly, but we list it there
 #       to have __NR_clone properly defined.
@@ -280,7 +284,6 @@
 
 # other
 int     uname(struct utsname *)  122
-pid_t   __wait4:wait4(pid_t pid, int *status, int options, struct rusage *rusage)   114
 mode_t  umask(mode_t)  60
 int      __reboot:reboot(int, int, int, void *)  88
 int     __syslog:syslog(int, char *, int)  103
@@ -308,8 +311,8 @@
 int     eventfd:eventfd2(unsigned int, int)  356,328,325
 
 # ARM-specific ARM_NR_BASE == 0x0f0000 == 983040
-int     __set_tls:ARM_set_tls(void*)                                 983045,-1,-1
-int     cacheflush:ARM_cacheflush(long start, long end, long flags)  983042,-1,-1
+int     __set_tls:__ARM_NR_set_tls(void*)                                 983045,-1,-1
+int     cacheflush:__ARM_NR_cacheflush(long start, long end, long flags)  983042,-1,-1
 
 # MIPS-specific
 int	_flush_cache:cacheflush(char *addr, const int nbytes, const int op)	-1,-1,147
diff --git a/libc/arch-arm/arm.mk b/libc/arch-arm/arm.mk
index 2def30b..d15ec9d 100644
--- a/libc/arch-arm/arm.mk
+++ b/libc/arch-arm/arm.mk
@@ -14,7 +14,6 @@
     arch-arm/bionic/_setjmp.S \
     arch-arm/bionic/setjmp.S \
     arch-arm/bionic/sigsetjmp.S \
-    arch-arm/bionic/strcmp.S \
     arch-arm/bionic/strcpy.S \
     arch-arm/bionic/strlen.c.arm \
     arch-arm/bionic/syscall.S \
diff --git a/libc/arch-arm/bionic/_exit_with_stack_teardown.S b/libc/arch-arm/bionic/_exit_with_stack_teardown.S
index b00ea28..ac79d43 100644
--- a/libc/arch-arm/bionic/_exit_with_stack_teardown.S
+++ b/libc/arch-arm/bionic/_exit_with_stack_teardown.S
@@ -27,7 +27,7 @@
  */
 
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 // void _exit_with_stack_teardown(void* stackBase, int stackSize, int retCode)
 ENTRY(_exit_with_stack_teardown)
diff --git a/libc/arch-arm/bionic/atexit_legacy.c b/libc/arch-arm/bionic/atexit_legacy.c
index 6e299ac..f35c68d 100644
--- a/libc/arch-arm/bionic/atexit_legacy.c
+++ b/libc/arch-arm/bionic/atexit_legacy.c
@@ -27,7 +27,7 @@
  */
 
 #include <sys/types.h>
-#include <private/logd.h>
+#include <private/libc_logging.h>
 #include <stdio.h>
 
 /*
@@ -52,7 +52,7 @@
      */
     static char const warning[] = "WARNING: generic atexit() called from legacy shared library\n";
 
-    __libc_android_log_write(ANDROID_LOG_WARN, "libc", warning);
+    __libc_format_log(ANDROID_LOG_WARN, "libc", warning);
     fprintf(stderr, warning);
 
     return (__cxa_atexit((void (*)(void *))func, NULL, NULL));
diff --git a/libc/arch-arm/bionic/clone.S b/libc/arch-arm/bionic/clone.S
index 13bc7d7..01eb966 100644
--- a/libc/arch-arm/bionic/clone.S
+++ b/libc/arch-arm/bionic/clone.S
@@ -26,8 +26,9 @@
  * SUCH DAMAGE.
  */
 
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 // int  __pthread_clone(void* (*fn)(void*), void* child_stack, int flags, void* arg);
 ENTRY(__pthread_clone)
@@ -45,10 +46,12 @@
     movs    r0, r0
     beq     1f
 
-    # In parent, reload saved registers then either exit or set errno.
+    # In parent, reload saved registers then either return or set errno.
     ldmfd   sp!, {r4, r7}
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 
 1:  # The child.
     # pick the function arg and call address off the stack and jump
@@ -94,10 +97,12 @@
     movs    r0, r0
     beq     1f
 
-    # In the parent, reload saved registers then either exit or set errno.
+    # In the parent, reload saved registers then either return or set errno.
     ldmfd   sp!, {r4, r5, r6, r7}
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 
 1:  # The child.
     ldr    r0, [sp, #-4]
diff --git a/libc/arch-arm/bionic/futex_arm.S b/libc/arch-arm/bionic/futex_arm.S
index bbd0629..e21a385 100644
--- a/libc/arch-arm/bionic/futex_arm.S
+++ b/libc/arch-arm/bionic/futex_arm.S
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 #include <machine/asm.h>
 
 #define FUTEX_WAIT 0
diff --git a/libc/arch-arm/bionic/kill.S b/libc/arch-arm/bionic/kill.S
index 33dfc2b..723602a 100644
--- a/libc/arch-arm/bionic/kill.S
+++ b/libc/arch-arm/bionic/kill.S
@@ -25,6 +25,11 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
+#include <linux/err.h>
+#include <asm/unistd.h>
+#include <machine/asm.h>
+
 /* unlike our auto-generated syscall stubs, this code saves lr
    on the stack, as well as a few other registers. this makes
    our stack unwinder happy, when we generate debug stack
@@ -32,19 +37,14 @@
    abort due to a fatal runtime error (e.g. detection
    of a corrupted malloc heap).
 */
-#include <sys/linux-syscalls.h>
-#include <machine/asm.h>
-
-#ifndef __NR_kill
-#define __NR_kill   37
-#endif
 
 ENTRY(kill)
     stmfd   sp!, {r4-r7, ip, lr}
     ldr     r7, =__NR_kill
     swi     #0
     ldmfd   sp!, {r4-r7, ip, lr}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(kill)
diff --git a/libc/arch-arm/bionic/syscall.S b/libc/arch-arm/bionic/syscall.S
index 69f3bec..510d298 100644
--- a/libc/arch-arm/bionic/syscall.S
+++ b/libc/arch-arm/bionic/syscall.S
@@ -26,8 +26,8 @@
  * SUCH DAMAGE.
  */
 
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(syscall)
     mov     ip, sp
@@ -39,7 +39,8 @@
     ldmfd   ip, {r3, r4, r5, r6}
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(syscall)
diff --git a/libc/arch-arm/bionic/tgkill.S b/libc/arch-arm/bionic/tgkill.S
index da5c0af..f46cb58 100644
--- a/libc/arch-arm/bionic/tgkill.S
+++ b/libc/arch-arm/bionic/tgkill.S
@@ -25,6 +25,11 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
+#include <linux/err.h>
+#include <asm/unistd.h>
+#include <machine/asm.h>
+
 /* unlike our auto-generated syscall stubs, this code saves lr
    on the stack, as well as a few other registers. this makes
    our stack unwinder happy, when we generate debug stack
@@ -33,19 +38,13 @@
    of a corrupted malloc heap).
 */
 
-#include <sys/linux-syscalls.h>
-#include <machine/asm.h>
-
-#ifndef __NR_tgkill
-#define __NR_tgkill  268
-#endif
-
 ENTRY(tgkill)
     stmfd   sp!, {r4-r7, ip, lr}
     ldr     r7, =__NR_tgkill
     swi     #0
     ldmfd   sp!, {r4-r7, ip, lr}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(tgkill)
diff --git a/libc/arch-arm/bionic/tkill.S b/libc/arch-arm/bionic/tkill.S
index fdc5ed4..fd6e21e 100644
--- a/libc/arch-arm/bionic/tkill.S
+++ b/libc/arch-arm/bionic/tkill.S
@@ -25,6 +25,11 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
+#include <linux/err.h>
+#include <asm/unistd.h>
+#include <machine/asm.h>
+
 /* unlike our auto-generated syscall stubs, this code saves lr
    on the stack, as well as a few other registers. this makes
    our stack unwinder happy, when we generate debug stack
@@ -33,19 +38,13 @@
    of a corrupted malloc heap).
 */
 
-#include <sys/linux-syscalls.h>
-#include <machine/asm.h>
-
-#ifndef __NR_tkill
-#define __NR_tkill  238
-#endif
-
 ENTRY(tkill)
     stmfd   sp!, {r4-r7, ip, lr}
     ldr     r7, =__NR_tkill
     swi     #0
     ldmfd   sp!, {r4-r7, ip, lr}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(tkill)
diff --git a/libc/arch-arm/cortex-a15/bionic/strcmp.S b/libc/arch-arm/cortex-a15/bionic/strcmp.S
new file mode 100644
index 0000000..7aff7c4
--- /dev/null
+++ b/libc/arch-arm/cortex-a15/bionic/strcmp.S
@@ -0,0 +1,377 @@
+/*
+ * Copyright (c) 2013 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the company may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/cpu-features.h>
+#include <machine/asm.h>
+
+#ifdef __ARMEB__
+#define S2LOMEM lsl
+#define S2LOMEMEQ lsleq
+#define S2HIMEM lsr
+#define MSB 0x000000ff
+#define LSB 0xff000000
+#define BYTE0_OFFSET 24
+#define BYTE1_OFFSET 16
+#define BYTE2_OFFSET 8
+#define BYTE3_OFFSET 0
+#else /* not  __ARMEB__ */
+#define S2LOMEM lsr
+#define S2LOMEMEQ lsreq
+#define S2HIMEM lsl
+#define BYTE0_OFFSET 0
+#define BYTE1_OFFSET 8
+#define BYTE2_OFFSET 16
+#define BYTE3_OFFSET 24
+#define MSB 0xff000000
+#define LSB 0x000000ff
+#endif /* not  __ARMEB__ */
+
+.syntax         unified
+
+#if defined (__thumb__)
+        .thumb
+        .thumb_func
+#endif
+
+ENTRY(strcmp)
+      /* Use LDRD whenever possible.  */
+
+/* The main thing to look out for when comparing large blocks is that
+   the loads do not cross a page boundary when loading past the index
+   of the byte with the first difference or the first string-terminator.
+
+   For example, if the strings are identical and the string-terminator
+   is at index k, byte by byte comparison will not load beyond address
+   s1+k and s2+k; word by word comparison may load up to 3 bytes beyond
+   k; double word - up to 7 bytes.  If the load of these bytes crosses
+   a page boundary, it might cause a memory fault (if the page is not mapped)
+   that would not have happened in byte by byte comparison.
+
+   If an address is (double) word aligned, then a load of a (double) word
+   from that address will not cross a page boundary.
+   Therefore, the algorithm below considers word and double-word alignment
+   of strings separately.  */
+
+/* High-level description of the algorithm.
+
+   * The fast path: if both strings are double-word aligned,
+     use LDRD to load two words from each string in every loop iteration.
+   * If the strings have the same offset from a word boundary,
+     use LDRB to load and compare byte by byte until
+     the first string is aligned to a word boundary (at most 3 bytes).
+     This is optimized for quick return on short unaligned strings.
+   * If the strings have the same offset from a double-word boundary,
+     use LDRD to load two words from each string in every loop iteration, as in the fast path.
+   * If the strings do not have the same offset from a double-word boundary,
+     load a word from the second string before the loop to initialize the queue.
+     Use LDRD to load two words from every string in every loop iteration.
+     Inside the loop, load the second word from the second string only after comparing
+     the first word, using the queued value, to guarantee safety across page boundaries.
+   * If the strings do not have the same offset from a word boundary,
+     use LDR and a shift queue. Order of loads and comparisons matters,
+     similarly to the previous case.
+
+   * Use UADD8 and SEL to compare words, and use REV and CLZ to compute the return value.
+   * The only difference between ARM and Thumb modes is the use of CBZ instruction.
+   * The only difference between big and little endian is the use of REV in little endian
+     to compute the return value, instead of MOV.
+*/
+
+        .macro m_cbz reg label
+#ifdef __thumb2__
+        cbz     \reg, \label
+#else   /* not defined __thumb2__ */
+        cmp     \reg, #0
+        beq     \label
+#endif /* not defined __thumb2__ */
+        .endm /* m_cbz */
+
+        .macro m_cbnz reg label
+#ifdef __thumb2__
+        cbnz    \reg, \label
+#else   /* not defined __thumb2__ */
+        cmp     \reg, #0
+        bne     \label
+#endif /* not defined __thumb2__ */
+        .endm /* m_cbnz */
+
+        .macro  init
+        /* Macro to save temporary registers and prepare magic values.  */
+        subs    sp, sp, #16
+        strd    r4, r5, [sp, #8]
+        strd    r6, r7, [sp]
+        mvn     r6, #0  /* all F */
+        mov     r7, #0  /* all 0 */
+        .endm   /* init */
+
+        .macro  magic_compare_and_branch w1 w2 label
+        /* Macro to compare registers w1 and w2 and conditionally branch to label.  */
+        cmp     \w1, \w2        /* Are w1 and w2 the same?  */
+        magic_find_zero_bytes \w1
+        it      eq
+        cmpeq   ip, #0          /* Is there a zero byte in w1?  */
+        bne     \label
+        .endm /* magic_compare_and_branch */
+
+        .macro  magic_find_zero_bytes w1
+        /* Macro to find all-zero bytes in w1, result is in ip.  */
+#if (defined (__ARM_FEATURE_DSP))
+        uadd8   ip, \w1, r6
+        sel     ip, r7, r6
+#else /* not defined (__ARM_FEATURE_DSP) */
+        /* __ARM_FEATURE_DSP is not defined for some Cortex-M processors.
+        Coincidently, these processors only have Thumb-2 mode, where we can use the
+        the (large) magic constant available directly as an immediate in instructions.
+        Note that we cannot use the magic constant in ARM mode, where we need
+        to create the constant in a register.  */
+        sub     ip, \w1, #0x01010101
+        bic     ip, ip, \w1
+        and     ip, ip, #0x80808080
+#endif /* not defined (__ARM_FEATURE_DSP) */
+        .endm /* magic_find_zero_bytes */
+
+        .macro  setup_return w1 w2
+#ifdef __ARMEB__
+        mov     r1, \w1
+        mov     r2, \w2
+#else /* not  __ARMEB__ */
+        rev     r1, \w1
+        rev     r2, \w2
+#endif /* not  __ARMEB__ */
+        .endm /* setup_return */
+
+        pld [r0, #0]
+        pld [r1, #0]
+
+        /* Are both strings double-word aligned?  */
+        orr     ip, r0, r1
+        tst     ip, #7
+        bne     do_align
+
+        /* Fast path.  */
+        init
+
+doubleword_aligned:
+
+        /* Get here when the strings to compare are double-word aligned.  */
+        /* Compare two words in every iteration.  */
+        .p2align        2
+2:
+        pld [r0, #16]
+        pld [r1, #16]
+
+        /* Load the next double-word from each string.  */
+        ldrd    r2, r3, [r0], #8
+        ldrd    r4, r5, [r1], #8
+
+        magic_compare_and_branch w1=r2, w2=r4, label=return_24
+        magic_compare_and_branch w1=r3, w2=r5, label=return_35
+        b       2b
+
+do_align:
+        /* Is the first string word-aligned?  */
+        ands    ip, r0, #3
+        beq     word_aligned_r0
+
+        /* Fast compare byte by byte until the first string is word-aligned.  */
+        /* The offset of r0 from a word boundary is in ip. Thus, the number of bytes
+        to read until the next word boundary is 4-ip.  */
+        bic     r0, r0, #3
+        ldr     r2, [r0], #4
+        lsls    ip, ip, #31
+        beq     byte2
+        bcs     byte3
+
+byte1:
+        ldrb    ip, [r1], #1
+        uxtb    r3, r2, ror #BYTE1_OFFSET
+        subs    ip, r3, ip
+        bne     fast_return
+        m_cbz   reg=r3, label=fast_return
+
+byte2:
+        ldrb    ip, [r1], #1
+        uxtb    r3, r2, ror #BYTE2_OFFSET
+        subs    ip, r3, ip
+        bne     fast_return
+        m_cbz   reg=r3, label=fast_return
+
+byte3:
+        ldrb    ip, [r1], #1
+        uxtb    r3, r2, ror #BYTE3_OFFSET
+        subs    ip, r3, ip
+        bne     fast_return
+        m_cbnz  reg=r3, label=word_aligned_r0
+
+fast_return:
+        mov     r0, ip
+        bx      lr
+
+word_aligned_r0:
+        init
+        /* The first string is word-aligned.  */
+        /* Is the second string word-aligned?  */
+        ands    ip, r1, #3
+        bne     strcmp_unaligned
+
+word_aligned:
+        /* The strings are word-aligned. */
+        /* Is the first string double-word aligned?  */
+        tst     r0, #4
+        beq     doubleword_aligned_r0
+
+        /* If r0 is not double-word aligned yet, align it by loading
+        and comparing the next word from each string.  */
+        ldr     r2, [r0], #4
+        ldr     r4, [r1], #4
+        magic_compare_and_branch w1=r2 w2=r4 label=return_24
+
+doubleword_aligned_r0:
+        /* Get here when r0 is double-word aligned.  */
+        /* Is r1 doubleword_aligned?  */
+        tst     r1, #4
+        beq     doubleword_aligned
+
+        /* Get here when the strings to compare are word-aligned,
+        r0 is double-word aligned, but r1 is not double-word aligned.  */
+
+        /* Initialize the queue.  */
+        ldr     r5, [r1], #4
+
+        /* Compare two words in every iteration.  */
+        .p2align        2
+3:
+        pld [r0, #16]
+        pld [r1, #16]
+
+        /* Load the next double-word from each string and compare.  */
+        ldrd    r2, r3, [r0], #8
+        magic_compare_and_branch w1=r2 w2=r5 label=return_25
+        ldrd    r4, r5, [r1], #8
+        magic_compare_and_branch w1=r3 w2=r4 label=return_34
+        b       3b
+
+        .macro miscmp_word offsetlo offsethi
+        /* Macro to compare misaligned strings.  */
+        /* r0, r1 are word-aligned, and at least one of the strings
+        is not double-word aligned.  */
+        /* Compare one word in every loop iteration.  */
+        /* OFFSETLO is the original bit-offset of r1 from a word-boundary,
+        OFFSETHI is 32 - OFFSETLO (i.e., offset from the next word).  */
+
+        /* Initialize the shift queue.  */
+        ldr     r5, [r1], #4
+
+        /* Compare one word from each string in every loop iteration.  */
+        .p2align        2
+7:
+        ldr     r3, [r0], #4
+        S2LOMEM r5, r5, #\offsetlo
+        magic_find_zero_bytes w1=r3
+        cmp     r7, ip, S2HIMEM #\offsetlo
+        and     r2, r3, r6, S2LOMEM #\offsetlo
+        it      eq
+        cmpeq   r2, r5
+        bne     return_25
+        ldr     r5, [r1], #4
+        cmp     ip, #0
+        eor r3, r2, r3
+        S2HIMEM r2, r5, #\offsethi
+        it      eq
+        cmpeq   r3, r2
+        bne     return_32
+        b       7b
+        .endm /* miscmp_word */
+
+strcmp_unaligned:
+        /* r0 is word-aligned, r1 is at offset ip from a word.  */
+        /* Align r1 to the (previous) word-boundary.  */
+        bic     r1, r1, #3
+
+        /* Unaligned comparison word by word using LDRs. */
+        cmp     ip, #2
+        beq     miscmp_word_16                    /* If ip == 2.  */
+        bge     miscmp_word_24                    /* If ip == 3.  */
+        miscmp_word offsetlo=8 offsethi=24        /* If ip == 1.  */
+miscmp_word_16:  miscmp_word offsetlo=16 offsethi=16
+miscmp_word_24:  miscmp_word offsetlo=24 offsethi=8
+
+
+return_32:
+        setup_return w1=r3, w2=r2
+        b       do_return
+return_34:
+        setup_return w1=r3, w2=r4
+        b       do_return
+return_25:
+        setup_return w1=r2, w2=r5
+        b       do_return
+return_35:
+        setup_return w1=r3, w2=r5
+        b       do_return
+return_24:
+        setup_return w1=r2, w2=r4
+
+do_return:
+
+#ifdef __ARMEB__
+        mov     r0, ip
+#else /* not  __ARMEB__ */
+        rev     r0, ip
+#endif /* not  __ARMEB__ */
+
+        /* Restore temporaries early, before computing the return value.  */
+        ldrd    r6, r7, [sp]
+        ldrd    r4, r5, [sp, #8]
+        adds    sp, sp, #16
+
+        /* There is a zero or a different byte between r1 and r2.  */
+        /* r0 contains a mask of all-zero bytes in r1.  */
+        /* Using r0 and not ip here because cbz requires low register.  */
+        m_cbz   reg=r0, label=compute_return_value
+        clz     r0, r0
+        /* r0 contains the number of bits on the left of the first all-zero byte in r1.  */
+        rsb     r0, r0, #24
+        /* Here, r0 contains the number of bits on the right of the first all-zero byte in r1.  */
+        lsr     r1, r1, r0
+        lsr     r2, r2, r0
+
+compute_return_value:
+        movs    r0, #1
+        cmp     r1, r2
+        /* The return value is computed as follows.
+        If r1>r2 then (C==1 and Z==0) and LS doesn't hold and r0 is #1 at return.
+        If r1<r2 then (C==0 and Z==0) and we execute SBC with carry_in=0,
+        which means r0:=r0-r0-1 and r0 is #-1 at return.
+        If r1=r2 then (C==1 and Z==1) and we execute SBC with carry_in=1,
+        which means r0:=r0-r0 and r0 is #0 at return.
+        (C==0 and Z==1) cannot happen because the carry bit is "not borrow".  */
+        it      ls
+        sbcls   r0, r0, r0
+        bx      lr
+END(strcmp)
diff --git a/libc/arch-arm/cortex-a15/cortex-a15.mk b/libc/arch-arm/cortex-a15/cortex-a15.mk
index 4534808..d8193f8 100644
--- a/libc/arch-arm/cortex-a15/cortex-a15.mk
+++ b/libc/arch-arm/cortex-a15/cortex-a15.mk
@@ -1,4 +1,5 @@
 $(call libc-add-cpu-variant-src,MEMCPY,arch-arm/cortex-a15/bionic/memcpy.S)
 $(call libc-add-cpu-variant-src,MEMSET,arch-arm/cortex-a15/bionic/memset.S)
+$(call libc-add-cpu-variant-src,STRCMP,arch-arm/cortex-a15/bionic/strcmp.S)
 
 include bionic/libc/arch-arm/generic/generic.mk
diff --git a/libc/arch-arm/cortex-a7/cortex-a7.mk b/libc/arch-arm/cortex-a7/cortex-a7.mk
new file mode 100644
index 0000000..9af03d9
--- /dev/null
+++ b/libc/arch-arm/cortex-a7/cortex-a7.mk
@@ -0,0 +1 @@
+include bionic/libc/arch-arm/cortex-a15/cortex-a15.mk
diff --git a/libc/arch-arm/cortex-a9/bionic/strcmp.S b/libc/arch-arm/cortex-a9/bionic/strcmp.S
new file mode 100644
index 0000000..9597d0d
--- /dev/null
+++ b/libc/arch-arm/cortex-a9/bionic/strcmp.S
@@ -0,0 +1,544 @@
+/*
+ * Copyright (c) 2013 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the company may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/cpu-features.h>
+#include <machine/asm.h>
+
+#ifdef __ARMEB__
+#define S2LOMEM lsl
+#define S2LOMEMEQ lsleq
+#define S2HIMEM lsr
+#define MSB 0x000000ff
+#define LSB 0xff000000
+#define BYTE0_OFFSET 24
+#define BYTE1_OFFSET 16
+#define BYTE2_OFFSET 8
+#define BYTE3_OFFSET 0
+#else /* not  __ARMEB__ */
+#define S2LOMEM lsr
+#define S2LOMEMEQ lsreq
+#define S2HIMEM lsl
+#define BYTE0_OFFSET 0
+#define BYTE1_OFFSET 8
+#define BYTE2_OFFSET 16
+#define BYTE3_OFFSET 24
+#define MSB 0xff000000
+#define LSB 0x000000ff
+#endif /* not  __ARMEB__ */
+
+.syntax         unified
+
+#if defined (__thumb__)
+        .thumb
+        .thumb_func
+#endif
+
+ENTRY(strcmp)
+      /* Use LDRD whenever possible.  */
+
+/* The main thing to look out for when comparing large blocks is that
+   the loads do not cross a page boundary when loading past the index
+   of the byte with the first difference or the first string-terminator.
+
+   For example, if the strings are identical and the string-terminator
+   is at index k, byte by byte comparison will not load beyond address
+   s1+k and s2+k; word by word comparison may load up to 3 bytes beyond
+   k; double word - up to 7 bytes.  If the load of these bytes crosses
+   a page boundary, it might cause a memory fault (if the page is not mapped)
+   that would not have happened in byte by byte comparison.
+
+   If an address is (double) word aligned, then a load of a (double) word
+   from that address will not cross a page boundary.
+   Therefore, the algorithm below considers word and double-word alignment
+   of strings separately.  */
+
+/* High-level description of the algorithm.
+
+   * The fast path: if both strings are double-word aligned,
+     use LDRD to load two words from each string in every loop iteration.
+   * If the strings have the same offset from a word boundary,
+     use LDRB to load and compare byte by byte until
+     the first string is aligned to a word boundary (at most 3 bytes).
+     This is optimized for quick return on short unaligned strings.
+   * If the strings have the same offset from a double-word boundary,
+     use LDRD to load two words from each string in every loop iteration, as in the fast path.
+   * If the strings do not have the same offset from a double-word boundary,
+     load a word from the second string before the loop to initialize the queue.
+     Use LDRD to load two words from every string in every loop iteration.
+     Inside the loop, load the second word from the second string only after comparing
+     the first word, using the queued value, to guarantee safety across page boundaries.
+   * If the strings do not have the same offset from a word boundary,
+     use LDR and a shift queue. Order of loads and comparisons matters,
+     similarly to the previous case.
+
+   * Use UADD8 and SEL to compare words, and use REV and CLZ to compute the return value.
+   * The only difference between ARM and Thumb modes is the use of CBZ instruction.
+   * The only difference between big and little endian is the use of REV in little endian
+     to compute the return value, instead of MOV.
+*/
+
+        .macro m_cbz reg label
+#ifdef __thumb2__
+        cbz     \reg, \label
+#else   /* not defined __thumb2__ */
+        cmp     \reg, #0
+        beq     \label
+#endif /* not defined __thumb2__ */
+        .endm /* m_cbz */
+
+        .macro m_cbnz reg label
+#ifdef __thumb2__
+        cbnz    \reg, \label
+#else   /* not defined __thumb2__ */
+        cmp     \reg, #0
+        bne     \label
+#endif /* not defined __thumb2__ */
+        .endm /* m_cbnz */
+
+        .macro  init
+        /* Macro to save temporary registers and prepare magic values.  */
+        subs    sp, sp, #16
+        strd    r4, r5, [sp, #8]
+        strd    r6, r7, [sp]
+        mvn     r6, #0  /* all F */
+        mov     r7, #0  /* all 0 */
+        .endm   /* init */
+
+        .macro  magic_compare_and_branch w1 w2 label
+        /* Macro to compare registers w1 and w2 and conditionally branch to label.  */
+        cmp     \w1, \w2        /* Are w1 and w2 the same?  */
+        magic_find_zero_bytes \w1
+        it      eq
+        cmpeq   ip, #0          /* Is there a zero byte in w1?  */
+        bne     \label
+        .endm /* magic_compare_and_branch */
+
+        .macro  magic_find_zero_bytes w1
+        /* Macro to find all-zero bytes in w1, result is in ip.  */
+#if (defined (__ARM_FEATURE_DSP))
+        uadd8   ip, \w1, r6
+        sel     ip, r7, r6
+#else /* not defined (__ARM_FEATURE_DSP) */
+        /* __ARM_FEATURE_DSP is not defined for some Cortex-M processors.
+        Coincidently, these processors only have Thumb-2 mode, where we can use the
+        the (large) magic constant available directly as an immediate in instructions.
+        Note that we cannot use the magic constant in ARM mode, where we need
+        to create the constant in a register.  */
+        sub     ip, \w1, #0x01010101
+        bic     ip, ip, \w1
+        and     ip, ip, #0x80808080
+#endif /* not defined (__ARM_FEATURE_DSP) */
+        .endm /* magic_find_zero_bytes */
+
+        .macro  setup_return w1 w2
+#ifdef __ARMEB__
+        mov     r1, \w1
+        mov     r2, \w2
+#else /* not  __ARMEB__ */
+        rev     r1, \w1
+        rev     r2, \w2
+#endif /* not  __ARMEB__ */
+        .endm /* setup_return */
+
+        pld [r0, #0]
+        pld [r1, #0]
+
+        /* Are both strings double-word aligned?  */
+        orr     ip, r0, r1
+        tst     ip, #7
+        bne     do_align
+
+        /* Fast path.  */
+        init
+
+doubleword_aligned:
+
+        /* Get here when the strings to compare are double-word aligned.  */
+        /* Compare two words in every iteration.  */
+        .p2align        2
+2:
+        pld [r0, #16]
+        pld [r1, #16]
+
+        /* Load the next double-word from each string.  */
+        ldrd    r2, r3, [r0], #8
+        ldrd    r4, r5, [r1], #8
+
+        magic_compare_and_branch w1=r2, w2=r4, label=return_24
+        magic_compare_and_branch w1=r3, w2=r5, label=return_35
+        b       2b
+
+do_align:
+        /* Is the first string word-aligned?  */
+        ands    ip, r0, #3
+        beq     word_aligned_r0
+
+        /* Fast compare byte by byte until the first string is word-aligned.  */
+        /* The offset of r0 from a word boundary is in ip. Thus, the number of bytes
+        to read until the next word boundary is 4-ip.  */
+        bic     r0, r0, #3
+        ldr     r2, [r0], #4
+        lsls    ip, ip, #31
+        beq     byte2
+        bcs     byte3
+
+byte1:
+        ldrb    ip, [r1], #1
+        uxtb    r3, r2, ror #BYTE1_OFFSET
+        subs    ip, r3, ip
+        bne     fast_return
+        m_cbz   reg=r3, label=fast_return
+
+byte2:
+        ldrb    ip, [r1], #1
+        uxtb    r3, r2, ror #BYTE2_OFFSET
+        subs    ip, r3, ip
+        bne     fast_return
+        m_cbz   reg=r3, label=fast_return
+
+byte3:
+        ldrb    ip, [r1], #1
+        uxtb    r3, r2, ror #BYTE3_OFFSET
+        subs    ip, r3, ip
+        bne     fast_return
+        m_cbnz  reg=r3, label=word_aligned_r0
+
+fast_return:
+        mov     r0, ip
+        bx      lr
+
+word_aligned_r0:
+        init
+        /* The first string is word-aligned.  */
+        /* Is the second string word-aligned?  */
+        ands    ip, r1, #3
+        bne     strcmp_unaligned
+
+word_aligned:
+        /* The strings are word-aligned. */
+        /* Is the first string double-word aligned?  */
+        tst     r0, #4
+        beq     doubleword_aligned_r0
+
+        /* If r0 is not double-word aligned yet, align it by loading
+        and comparing the next word from each string.  */
+        ldr     r2, [r0], #4
+        ldr     r4, [r1], #4
+        magic_compare_and_branch w1=r2 w2=r4 label=return_24
+
+doubleword_aligned_r0:
+        /* Get here when r0 is double-word aligned.  */
+        /* Is r1 doubleword_aligned?  */
+        tst     r1, #4
+        beq     doubleword_aligned
+
+        /* Get here when the strings to compare are word-aligned,
+        r0 is double-word aligned, but r1 is not double-word aligned.  */
+
+        /* Initialize the queue.  */
+        ldr     r5, [r1], #4
+
+        /* Compare two words in every iteration.  */
+        .p2align        2
+3:
+        pld [r0, #16]
+        pld [r1, #16]
+
+        /* Load the next double-word from each string and compare.  */
+        ldrd    r2, r3, [r0], #8
+        magic_compare_and_branch w1=r2 w2=r5 label=return_25
+        ldrd    r4, r5, [r1], #8
+        magic_compare_and_branch w1=r3 w2=r4 label=return_34
+        b       3b
+
+        .macro miscmp_word offsetlo offsethi
+        /* Macro to compare misaligned strings.  */
+        /* r0, r1 are word-aligned, and at least one of the strings
+        is not double-word aligned.  */
+        /* Compare one word in every loop iteration.  */
+        /* OFFSETLO is the original bit-offset of r1 from a word-boundary,
+        OFFSETHI is 32 - OFFSETLO (i.e., offset from the next word).  */
+
+        /* Initialize the shift queue.  */
+        ldr     r5, [r1], #4
+
+        /* Compare one word from each string in every loop iteration.  */
+        .p2align        2
+7:
+        ldr     r3, [r0], #4
+        S2LOMEM r5, r5, #\offsetlo
+        magic_find_zero_bytes w1=r3
+        cmp     r7, ip, S2HIMEM #\offsetlo
+        and     r2, r3, r6, S2LOMEM #\offsetlo
+        it      eq
+        cmpeq   r2, r5
+        bne     return_25
+        ldr     r5, [r1], #4
+        cmp     ip, #0
+        eor r3, r2, r3
+        S2HIMEM r2, r5, #\offsethi
+        it      eq
+        cmpeq   r3, r2
+        bne     return_32
+        b       7b
+        .endm /* miscmp_word */
+
+return_32:
+        setup_return w1=r3, w2=r2
+        b       do_return
+return_34:
+        setup_return w1=r3, w2=r4
+        b       do_return
+return_25:
+        setup_return w1=r2, w2=r5
+        b       do_return
+return_35:
+        setup_return w1=r3, w2=r5
+        b       do_return
+return_24:
+        setup_return w1=r2, w2=r4
+
+do_return:
+
+#ifdef __ARMEB__
+        mov     r0, ip
+#else /* not  __ARMEB__ */
+        rev     r0, ip
+#endif /* not  __ARMEB__ */
+
+        /* Restore temporaries early, before computing the return value.  */
+        ldrd    r6, r7, [sp]
+        ldrd    r4, r5, [sp, #8]
+        adds    sp, sp, #16
+
+        /* There is a zero or a different byte between r1 and r2.  */
+        /* r0 contains a mask of all-zero bytes in r1.  */
+        /* Using r0 and not ip here because cbz requires low register.  */
+        m_cbz   reg=r0, label=compute_return_value
+        clz     r0, r0
+        /* r0 contains the number of bits on the left of the first all-zero byte in r1.  */
+        rsb     r0, r0, #24
+        /* Here, r0 contains the number of bits on the right of the first all-zero byte in r1.  */
+        lsr     r1, r1, r0
+        lsr     r2, r2, r0
+
+compute_return_value:
+        movs    r0, #1
+        cmp     r1, r2
+        /* The return value is computed as follows.
+        If r1>r2 then (C==1 and Z==0) and LS doesn't hold and r0 is #1 at return.
+        If r1<r2 then (C==0 and Z==0) and we execute SBC with carry_in=0,
+        which means r0:=r0-r0-1 and r0 is #-1 at return.
+        If r1=r2 then (C==1 and Z==1) and we execute SBC with carry_in=1,
+        which means r0:=r0-r0 and r0 is #0 at return.
+        (C==0 and Z==1) cannot happen because the carry bit is "not borrow".  */
+        it      ls
+        sbcls   r0, r0, r0
+        bx      lr
+
+    /* The code from the previous version of strcmp.S handles all of the
+     * cases where the first string and seconds string cannot both be
+     * aligned to a word boundary faster than the new algorithm. See
+     * bionic/libc/arch-arm/cortex-a15/bionic/strcmp.S for the unedited
+     * version of the code.
+     */
+strcmp_unaligned:
+	wp1 .req r0
+	wp2 .req r1
+	b1  .req r2
+	w1  .req r4
+	w2  .req r5
+	t1  .req ip
+	@ r3 is scratch
+
+2:
+	mov	b1, #1
+	orr	b1, b1, b1, lsl #8
+	orr	b1, b1, b1, lsl #16
+
+	and	t1, wp2, #3
+	bic	wp2, wp2, #3
+	ldr	w1, [wp1], #4
+	ldr	w2, [wp2], #4
+	cmp	t1, #2
+	beq	2f
+	bhi	3f
+
+	/* Critical inner Loop: Block with 3 bytes initial overlap */
+	.p2align	2
+1:
+	bic	t1, w1, #MSB
+	cmp	t1, w2, S2LOMEM #8
+	sub	r3, w1, b1
+	bic	r3, r3, w1
+	bne	4f
+	ands	r3, r3, b1, lsl #7
+	it	eq
+	ldreq	w2, [wp2], #4
+	bne	5f
+	eor	t1, t1, w1
+	cmp	t1, w2, S2HIMEM #24
+	bne	6f
+	ldr	w1, [wp1], #4
+	b	1b
+4:
+	S2LOMEM	w2, w2, #8
+	b	8f
+
+5:
+#ifdef __ARMEB__
+	/* The syndrome value may contain false ones if the string ends
+	 * with the bytes 0x01 0x00
+	 */
+	tst	w1, #0xff000000
+	itt	ne
+	tstne	w1, #0x00ff0000
+	tstne	w1, #0x0000ff00
+	beq	7f
+#else
+	bics	r3, r3, #0xff000000
+	bne	7f
+#endif
+	ldrb	w2, [wp2]
+	S2LOMEM	t1, w1, #24
+#ifdef __ARMEB__
+	lsl	w2, w2, #24
+#endif
+	b	8f
+
+6:
+	S2LOMEM	t1, w1, #24
+	and	w2, w2, #LSB
+	b	8f
+
+	/* Critical inner Loop: Block with 2 bytes initial overlap */
+	.p2align	2
+2:
+	S2HIMEM	t1, w1, #16
+	sub	r3, w1, b1
+	S2LOMEM	t1, t1, #16
+	bic	r3, r3, w1
+	cmp	t1, w2, S2LOMEM #16
+	bne	4f
+	ands	r3, r3, b1, lsl #7
+	it	eq
+	ldreq	w2, [wp2], #4
+	bne	5f
+	eor	t1, t1, w1
+	cmp	t1, w2, S2HIMEM #16
+	bne	6f
+	ldr	w1, [wp1], #4
+	b	2b
+
+5:
+#ifdef __ARMEB__
+	/* The syndrome value may contain false ones if the string ends
+	 * with the bytes 0x01 0x00
+	 */
+	tst	w1, #0xff000000
+	it	ne
+	tstne	w1, #0x00ff0000
+	beq	7f
+#else
+	lsls	r3, r3, #16
+	bne	7f
+#endif
+	ldrh	w2, [wp2]
+	S2LOMEM	t1, w1, #16
+#ifdef __ARMEB__
+	lsl	w2, w2, #16
+#endif
+	b	8f
+
+6:
+	S2HIMEM	w2, w2, #16
+	S2LOMEM	t1, w1, #16
+4:
+	S2LOMEM	w2, w2, #16
+	b	8f
+
+	/* Critical inner Loop: Block with 1 byte initial overlap */
+	.p2align	2
+3:
+	and	t1, w1, #LSB
+	cmp	t1, w2, S2LOMEM #24
+	sub	r3, w1, b1
+	bic	r3, r3, w1
+	bne	4f
+	ands	r3, r3, b1, lsl #7
+	it	eq
+	ldreq	w2, [wp2], #4
+	bne	5f
+	eor	t1, t1, w1
+	cmp	t1, w2, S2HIMEM #8
+	bne	6f
+	ldr	w1, [wp1], #4
+	b	3b
+4:
+	S2LOMEM	w2, w2, #24
+	b	8f
+5:
+	/* The syndrome value may contain false ones if the string ends
+	 * with the bytes 0x01 0x00
+	 */
+	tst	w1, #LSB
+	beq	7f
+	ldr	w2, [wp2], #4
+6:
+	S2LOMEM	t1, w1, #8
+	bic	w2, w2, #MSB
+	b	8f
+7:
+	mov	r0, #0
+
+    /* Restore registers and stack. */
+    ldrd    r6, r7, [sp]
+    ldrd    r4, r5, [sp, #8]
+    adds    sp, sp, #16
+
+	bx	lr
+
+8:
+	and	r2, t1, #LSB
+	and	r0, w2, #LSB
+	cmp	r0, #1
+	it	cs
+	cmpcs	r0, r2
+	itt	eq
+	S2LOMEMEQ	t1, t1, #8
+	S2LOMEMEQ	w2, w2, #8
+	beq	8b
+	sub	r0, r2, r0
+
+    /* Restore registers and stack. */
+    ldrd    r6, r7, [sp]
+    ldrd    r4, r5, [sp, #8]
+    adds    sp, sp, #16
+
+	bx	lr
+END(strcmp)
diff --git a/libc/arch-arm/cortex-a9/cortex-a9.mk b/libc/arch-arm/cortex-a9/cortex-a9.mk
index 9166413..4862933 100644
--- a/libc/arch-arm/cortex-a9/cortex-a9.mk
+++ b/libc/arch-arm/cortex-a9/cortex-a9.mk
@@ -1,4 +1,5 @@
 $(call libc-add-cpu-variant-src,MEMCPY,arch-arm/cortex-a9/bionic/memcpy.S)
 $(call libc-add-cpu-variant-src,MEMSET,arch-arm/cortex-a9/bionic/memset.S)
+$(call libc-add-cpu-variant-src,STRCMP,arch-arm/cortex-a9/bionic/strcmp.S)
 
 include bionic/libc/arch-arm/generic/generic.mk
diff --git a/libc/arch-arm/generic/bionic/strcmp.S b/libc/arch-arm/generic/bionic/strcmp.S
new file mode 100644
index 0000000..764a531
--- /dev/null
+++ b/libc/arch-arm/generic/bionic/strcmp.S
@@ -0,0 +1,317 @@
+/*
+ * Copyright (c) 2011 The Android Open Source Project
+ * Copyright (c) 2008 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the company may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/cpu-features.h>
+#include <machine/asm.h>
+
+	.text
+
+#ifdef __ARMEB__
+#define SHFT2LSB lsl
+#define SHFT2LSBEQ lsleq
+#define SHFT2MSB lsr
+#define SHFT2MSBEQ lsreq
+#define MSB 0x000000ff
+#define LSB 0xff000000
+#else
+#define SHFT2LSB lsr
+#define SHFT2LSBEQ lsreq
+#define SHFT2MSB lsl
+#define SHFT2MSBEQ lsleq
+#define MSB 0xff000000
+#define LSB 0x000000ff
+#endif
+
+#define magic1(REG) REG
+#define magic2(REG) REG, lsl #7
+
+ENTRY(strcmp)
+	PLD(r0, #0)
+	PLD(r1, #0)
+	eor	r2, r0, r1
+	tst	r2, #3
+
+	/* Strings not at same byte offset from a word boundary.  */
+	bne	.Lstrcmp_unaligned
+	ands	r2, r0, #3
+	bic	r0, r0, #3
+	bic	r1, r1, #3
+	ldr	ip, [r0], #4
+	it	eq
+	ldreq	r3, [r1], #4
+	beq	1f
+
+	/* Although s1 and s2 have identical initial alignment, they are
+	 * not currently word aligned.  Rather than comparing bytes,
+	 * make sure that any bytes fetched from before the addressed
+	 * bytes are forced to 0xff.  Then they will always compare
+	 * equal.
+	 */
+	eor	r2, r2, #3
+	lsl	r2, r2, #3
+	mvn	r3, #MSB
+	SHFT2LSB	r2, r3, r2
+	ldr	r3, [r1], #4
+	orr	ip, ip, r2
+	orr	r3, r3, r2
+1:
+	/* Load the 'magic' constant 0x01010101. */
+	str	r4, [sp, #-4]!
+	mov	r4, #1
+	orr	r4, r4, r4, lsl #8
+	orr	r4, r4, r4, lsl #16
+	.p2align	2
+4:
+	PLD(r0, #8)
+	PLD(r1, #8)
+	sub	r2, ip, magic1(r4)
+	cmp	ip, r3
+	itttt	eq
+
+	/* check for any zero bytes in first word */
+	biceq	r2, r2, ip
+	tsteq	r2, magic2(r4)
+	ldreq	ip, [r0], #4
+	ldreq	r3, [r1], #4
+	beq	4b
+2:
+	/* There's a zero or a different byte in the word */
+	SHFT2MSB	r0, ip, #24
+	SHFT2LSB	ip, ip, #8
+	cmp	r0, #1
+	it	cs
+	cmpcs	r0, r3, SHFT2MSB #24
+	it	eq
+	SHFT2LSBEQ r3, r3, #8
+	beq	2b
+	/* On a big-endian machine, r0 contains the desired byte in bits
+	 * 0-7; on a little-endian machine they are in bits 24-31.  In
+	 * both cases the other bits in r0 are all zero.  For r3 the
+	 * interesting byte is at the other end of the word, but the
+	 * other bits are not necessarily zero.  We need a signed result
+	 * representing the differnece in the unsigned bytes, so for the
+	 * little-endian case we can't just shift the interesting bits up.
+	 */
+#ifdef __ARMEB__
+	sub	r0, r0, r3, lsr #24
+#else
+	and	r3, r3, #255
+	/* No RSB instruction in Thumb2 */
+#ifdef __thumb2__
+	lsr	r0, r0, #24
+	sub	r0, r0, r3
+#else
+	rsb	r0, r3, r0, lsr #24
+#endif
+#endif
+	ldr	r4, [sp], #4
+	bx	lr
+
+.Lstrcmp_unaligned:
+	wp1 .req r0
+	wp2 .req r1
+	b1  .req r2
+	w1  .req r4
+	w2  .req r5
+	t1  .req ip
+	@ r3 is scratch
+
+	/* First of all, compare bytes until wp1(sp1) is word-aligned. */
+1:
+	tst	wp1, #3
+	beq	2f
+	ldrb	r2, [wp1], #1
+	ldrb	r3, [wp2], #1
+	cmp	r2, #1
+	it	cs
+	cmpcs	r2, r3
+	beq	1b
+	sub	r0, r2, r3
+	bx	lr
+
+2:
+	str	r5, [sp, #-4]!
+	str	r4, [sp, #-4]!
+	mov	b1, #1
+	orr	b1, b1, b1, lsl #8
+	orr	b1, b1, b1, lsl #16
+
+	and	t1, wp2, #3
+	bic	wp2, wp2, #3
+	ldr	w1, [wp1], #4
+	ldr	w2, [wp2], #4
+	cmp	t1, #2
+	beq	2f
+	bhi	3f
+
+	/* Critical inner Loop: Block with 3 bytes initial overlap */
+	.p2align	2
+1:
+	bic	t1, w1, #MSB
+	cmp	t1, w2, SHFT2LSB #8
+	sub	r3, w1, b1
+	bic	r3, r3, w1
+	bne	4f
+	ands	r3, r3, b1, lsl #7
+	it	eq
+	ldreq	w2, [wp2], #4
+	bne	5f
+	eor	t1, t1, w1
+	cmp	t1, w2, SHFT2MSB #24
+	bne	6f
+	ldr	w1, [wp1], #4
+	b	1b
+4:
+	SHFT2LSB	w2, w2, #8
+	b	8f
+
+5:
+#ifdef __ARMEB__
+	/* The syndrome value may contain false ones if the string ends
+	 * with the bytes 0x01 0x00
+	 */
+	tst	w1, #0xff000000
+	itt	ne
+	tstne	w1, #0x00ff0000
+	tstne	w1, #0x0000ff00
+	beq	7f
+#else
+	bics	r3, r3, #0xff000000
+	bne	7f
+#endif
+	ldrb	w2, [wp2]
+	SHFT2LSB	t1, w1, #24
+#ifdef __ARMEB__
+	lsl	w2, w2, #24
+#endif
+	b	8f
+
+6:
+	SHFT2LSB	t1, w1, #24
+	and	w2, w2, #LSB
+	b	8f
+
+	/* Critical inner Loop: Block with 2 bytes initial overlap */
+	.p2align	2
+2:
+	SHFT2MSB	t1, w1, #16
+	sub	r3, w1, b1
+	SHFT2LSB	t1, t1, #16
+	bic	r3, r3, w1
+	cmp	t1, w2, SHFT2LSB #16
+	bne	4f
+	ands	r3, r3, b1, lsl #7
+	it	eq
+	ldreq	w2, [wp2], #4
+	bne	5f
+	eor	t1, t1, w1
+	cmp	t1, w2, SHFT2MSB #16
+	bne	6f
+	ldr	w1, [wp1], #4
+	b	2b
+
+5:
+#ifdef __ARMEB__
+	/* The syndrome value may contain false ones if the string ends
+	 * with the bytes 0x01 0x00
+	 */
+	tst	w1, #0xff000000
+	it	ne
+	tstne	w1, #0x00ff0000
+	beq	7f
+#else
+	lsls	r3, r3, #16
+	bne	7f
+#endif
+	ldrh	w2, [wp2]
+	SHFT2LSB	t1, w1, #16
+#ifdef __ARMEB__
+	lsl	w2, w2, #16
+#endif
+	b	8f
+
+6:
+	SHFT2MSB	w2, w2, #16
+	SHFT2LSB	t1, w1, #16
+4:
+	SHFT2LSB	w2, w2, #16
+	b	8f
+
+	/* Critical inner Loop: Block with 1 byte initial overlap */
+	.p2align	2
+3:
+	and	t1, w1, #LSB
+	cmp	t1, w2, SHFT2LSB #24
+	sub	r3, w1, b1
+	bic	r3, r3, w1
+	bne	4f
+	ands	r3, r3, b1, lsl #7
+	it	eq
+	ldreq	w2, [wp2], #4
+	bne	5f
+	eor	t1, t1, w1
+	cmp	t1, w2, SHFT2MSB #8
+	bne	6f
+	ldr	w1, [wp1], #4
+	b	3b
+4:
+	SHFT2LSB	w2, w2, #24
+	b	8f
+5:
+	/* The syndrome value may contain false ones if the string ends
+	 * with the bytes 0x01 0x00
+	 */
+	tst	w1, #LSB
+	beq	7f
+	ldr	w2, [wp2], #4
+6:
+	SHFT2LSB	t1, w1, #8
+	bic	w2, w2, #MSB
+	b	8f
+7:
+	mov	r0, #0
+	ldr	r4, [sp], #4
+	ldr	r5, [sp], #4
+	bx	lr
+
+8:
+	and	r2, t1, #LSB
+	and	r0, w2, #LSB
+	cmp	r0, #1
+	it	cs
+	cmpcs	r0, r2
+	itt	eq
+	SHFT2LSBEQ	t1, t1, #8
+	SHFT2LSBEQ	w2, w2, #8
+	beq	8b
+	sub	r0, r2, r0
+	ldr	r4, [sp], #4
+	ldr	r5, [sp], #4
+	bx	lr
+END(strcmp)
diff --git a/libc/arch-arm/generic/generic.mk b/libc/arch-arm/generic/generic.mk
index 46bd067..358b1e6 100644
--- a/libc/arch-arm/generic/generic.mk
+++ b/libc/arch-arm/generic/generic.mk
@@ -1,2 +1,3 @@
 $(call libc-add-cpu-variant-src,MEMCPY,arch-arm/generic/bionic/memcpy.S)
 $(call libc-add-cpu-variant-src,MEMSET,arch-arm/generic/bionic/memset.S)
+$(call libc-add-cpu-variant-src,STRCMP,arch-arm/generic/bionic/strcmp.S)
diff --git a/libc/arch-arm/krait/bionic/strcmp.S b/libc/arch-arm/krait/bionic/strcmp.S
new file mode 100644
index 0000000..d614b9d
--- /dev/null
+++ b/libc/arch-arm/krait/bionic/strcmp.S
@@ -0,0 +1,477 @@
+/*
+ * Copyright (c) 2013 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the company may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/cpu-features.h>
+#include <machine/asm.h>
+
+#ifdef __ARMEB__
+#define S2LOMEM lsl
+#define S2LOMEMEQ lsleq
+#define S2HIMEM lsr
+#define MSB 0x000000ff
+#define LSB 0xff000000
+#define BYTE0_OFFSET 24
+#define BYTE1_OFFSET 16
+#define BYTE2_OFFSET 8
+#define BYTE3_OFFSET 0
+#else /* not  __ARMEB__ */
+#define S2LOMEM lsr
+#define S2LOMEMEQ lsreq
+#define S2HIMEM lsl
+#define BYTE0_OFFSET 0
+#define BYTE1_OFFSET 8
+#define BYTE2_OFFSET 16
+#define BYTE3_OFFSET 24
+#define MSB 0xff000000
+#define LSB 0x000000ff
+#endif /* not  __ARMEB__ */
+
+.syntax         unified
+
+#if defined (__thumb__)
+        .thumb
+        .thumb_func
+#endif
+
+ENTRY(strcmp)
+      /* Use LDRD whenever possible.  */
+
+/* The main thing to look out for when comparing large blocks is that
+   the loads do not cross a page boundary when loading past the index
+   of the byte with the first difference or the first string-terminator.
+
+   For example, if the strings are identical and the string-terminator
+   is at index k, byte by byte comparison will not load beyond address
+   s1+k and s2+k; word by word comparison may load up to 3 bytes beyond
+   k; double word - up to 7 bytes.  If the load of these bytes crosses
+   a page boundary, it might cause a memory fault (if the page is not mapped)
+   that would not have happened in byte by byte comparison.
+
+   If an address is (double) word aligned, then a load of a (double) word
+   from that address will not cross a page boundary.
+   Therefore, the algorithm below considers word and double-word alignment
+   of strings separately.  */
+
+/* High-level description of the algorithm.
+
+   * The fast path: if both strings are double-word aligned,
+     use LDRD to load two words from each string in every loop iteration.
+   * If the strings have the same offset from a word boundary,
+     use LDRB to load and compare byte by byte until
+     the first string is aligned to a word boundary (at most 3 bytes).
+     This is optimized for quick return on short unaligned strings.
+   * If the strings have the same offset from a double-word boundary,
+     use LDRD to load two words from each string in every loop iteration, as in the fast path.
+   * If the strings do not have the same offset from a double-word boundary,
+     load a word from the second string before the loop to initialize the queue.
+     Use LDRD to load two words from every string in every loop iteration.
+     Inside the loop, load the second word from the second string only after comparing
+     the first word, using the queued value, to guarantee safety across page boundaries.
+   * If the strings do not have the same offset from a word boundary,
+     use LDR and a shift queue. Order of loads and comparisons matters,
+     similarly to the previous case.
+
+   * Use UADD8 and SEL to compare words, and use REV and CLZ to compute the return value.
+   * The only difference between ARM and Thumb modes is the use of CBZ instruction.
+   * The only difference between big and little endian is the use of REV in little endian
+     to compute the return value, instead of MOV.
+*/
+
+        .macro m_cbz reg label
+#ifdef __thumb2__
+        cbz     \reg, \label
+#else   /* not defined __thumb2__ */
+        cmp     \reg, #0
+        beq     \label
+#endif /* not defined __thumb2__ */
+        .endm /* m_cbz */
+
+        .macro m_cbnz reg label
+#ifdef __thumb2__
+        cbnz    \reg, \label
+#else   /* not defined __thumb2__ */
+        cmp     \reg, #0
+        bne     \label
+#endif /* not defined __thumb2__ */
+        .endm /* m_cbnz */
+
+        .macro  init
+        /* Macro to save temporary registers and prepare magic values.  */
+        subs    sp, sp, #16
+        strd    r4, r5, [sp, #8]
+        strd    r6, r7, [sp]
+        mvn     r6, #0  /* all F */
+        mov     r7, #0  /* all 0 */
+        .endm   /* init */
+
+        .macro  magic_compare_and_branch w1 w2 label
+        /* Macro to compare registers w1 and w2 and conditionally branch to label.  */
+        cmp     \w1, \w2        /* Are w1 and w2 the same?  */
+        magic_find_zero_bytes \w1
+        it      eq
+        cmpeq   ip, #0          /* Is there a zero byte in w1?  */
+        bne     \label
+        .endm /* magic_compare_and_branch */
+
+        .macro  magic_find_zero_bytes w1
+        /* Macro to find all-zero bytes in w1, result is in ip.  */
+#if (defined (__ARM_FEATURE_DSP))
+        uadd8   ip, \w1, r6
+        sel     ip, r7, r6
+#else /* not defined (__ARM_FEATURE_DSP) */
+        /* __ARM_FEATURE_DSP is not defined for some Cortex-M processors.
+        Coincidently, these processors only have Thumb-2 mode, where we can use the
+        the (large) magic constant available directly as an immediate in instructions.
+        Note that we cannot use the magic constant in ARM mode, where we need
+        to create the constant in a register.  */
+        sub     ip, \w1, #0x01010101
+        bic     ip, ip, \w1
+        and     ip, ip, #0x80808080
+#endif /* not defined (__ARM_FEATURE_DSP) */
+        .endm /* magic_find_zero_bytes */
+
+        .macro  setup_return w1 w2
+#ifdef __ARMEB__
+        mov     r1, \w1
+        mov     r2, \w2
+#else /* not  __ARMEB__ */
+        rev     r1, \w1
+        rev     r2, \w2
+#endif /* not  __ARMEB__ */
+        .endm /* setup_return */
+
+        pld [r0, #0]
+        pld [r1, #0]
+
+        /* Are both strings double-word aligned?  */
+        orr     ip, r0, r1
+        tst     ip, #7
+        bne     do_align
+
+        /* Fast path.  */
+        init
+
+doubleword_aligned:
+
+        /* Get here when the strings to compare are double-word aligned.  */
+        /* Compare two words in every iteration.  */
+        .p2align        2
+2:
+        pld [r0, #16]
+        pld [r1, #16]
+
+        /* Load the next double-word from each string.  */
+        ldrd    r2, r3, [r0], #8
+        ldrd    r4, r5, [r1], #8
+
+        magic_compare_and_branch w1=r2, w2=r4, label=return_24
+        magic_compare_and_branch w1=r3, w2=r5, label=return_35
+        b       2b
+
+do_align:
+        /* Is the first string word-aligned?  */
+        ands    ip, r0, #3
+        beq     word_aligned_r0
+
+        /* Fast compare byte by byte until the first string is word-aligned.  */
+        /* The offset of r0 from a word boundary is in ip. Thus, the number of bytes
+        to read until the next word boundary is 4-ip.  */
+        bic     r0, r0, #3
+        ldr     r2, [r0], #4
+        lsls    ip, ip, #31
+        beq     byte2
+        bcs     byte3
+
+byte1:
+        ldrb    ip, [r1], #1
+        uxtb    r3, r2, ror #BYTE1_OFFSET
+        subs    ip, r3, ip
+        bne     fast_return
+        m_cbz   reg=r3, label=fast_return
+
+byte2:
+        ldrb    ip, [r1], #1
+        uxtb    r3, r2, ror #BYTE2_OFFSET
+        subs    ip, r3, ip
+        bne     fast_return
+        m_cbz   reg=r3, label=fast_return
+
+byte3:
+        ldrb    ip, [r1], #1
+        uxtb    r3, r2, ror #BYTE3_OFFSET
+        subs    ip, r3, ip
+        bne     fast_return
+        m_cbnz  reg=r3, label=word_aligned_r0
+
+fast_return:
+        mov     r0, ip
+        bx      lr
+
+word_aligned_r0:
+        init
+        /* The first string is word-aligned.  */
+        /* Is the second string word-aligned?  */
+        ands    ip, r1, #3
+        bne     strcmp_unaligned
+
+word_aligned:
+        /* The strings are word-aligned. */
+        /* Is the first string double-word aligned?  */
+        tst     r0, #4
+        beq     doubleword_aligned_r0
+
+        /* If r0 is not double-word aligned yet, align it by loading
+        and comparing the next word from each string.  */
+        ldr     r2, [r0], #4
+        ldr     r4, [r1], #4
+        magic_compare_and_branch w1=r2 w2=r4 label=return_24
+
+doubleword_aligned_r0:
+        /* Get here when r0 is double-word aligned.  */
+        /* Is r1 doubleword_aligned?  */
+        tst     r1, #4
+        beq     doubleword_aligned
+
+        /* Get here when the strings to compare are word-aligned,
+        r0 is double-word aligned, but r1 is not double-word aligned.  */
+
+        /* Initialize the queue.  */
+        ldr     r5, [r1], #4
+
+        /* Compare two words in every iteration.  */
+        .p2align        2
+3:
+        pld [r0, #16]
+        pld [r1, #16]
+
+        /* Load the next double-word from each string and compare.  */
+        ldrd    r2, r3, [r0], #8
+        magic_compare_and_branch w1=r2 w2=r5 label=return_25
+        ldrd    r4, r5, [r1], #8
+        magic_compare_and_branch w1=r3 w2=r4 label=return_34
+        b       3b
+
+        .macro miscmp_word offsetlo offsethi
+        /* Macro to compare misaligned strings.  */
+        /* r0, r1 are word-aligned, and at least one of the strings
+        is not double-word aligned.  */
+        /* Compare one word in every loop iteration.  */
+        /* OFFSETLO is the original bit-offset of r1 from a word-boundary,
+        OFFSETHI is 32 - OFFSETLO (i.e., offset from the next word).  */
+
+        /* Initialize the shift queue.  */
+        ldr     r5, [r1], #4
+
+        /* Compare one word from each string in every loop iteration.  */
+        .p2align        2
+7:
+        ldr     r3, [r0], #4
+        S2LOMEM r5, r5, #\offsetlo
+        magic_find_zero_bytes w1=r3
+        cmp     r7, ip, S2HIMEM #\offsetlo
+        and     r2, r3, r6, S2LOMEM #\offsetlo
+        it      eq
+        cmpeq   r2, r5
+        bne     return_25
+        ldr     r5, [r1], #4
+        cmp     ip, #0
+        eor r3, r2, r3
+        S2HIMEM r2, r5, #\offsethi
+        it      eq
+        cmpeq   r3, r2
+        bne     return_32
+        b       7b
+        .endm /* miscmp_word */
+
+strcmp_unaligned:
+        /* r0 is word-aligned, r1 is at offset ip from a word.  */
+        /* Align r1 to the (previous) word-boundary.  */
+        bic     r1, r1, #3
+
+        /* Unaligned comparison word by word using LDRs. */
+        cmp     ip, #2
+        beq     miscmp_word_16                    /* If ip == 2.  */
+        bge     miscmp_word_24                    /* If ip == 3.  */
+        miscmp_word offsetlo=8 offsethi=24        /* If ip == 1.  */
+miscmp_word_24:  miscmp_word offsetlo=24 offsethi=8
+
+
+return_32:
+        setup_return w1=r3, w2=r2
+        b       do_return
+return_34:
+        setup_return w1=r3, w2=r4
+        b       do_return
+return_25:
+        setup_return w1=r2, w2=r5
+        b       do_return
+return_35:
+        setup_return w1=r3, w2=r5
+        b       do_return
+return_24:
+        setup_return w1=r2, w2=r4
+
+do_return:
+
+#ifdef __ARMEB__
+        mov     r0, ip
+#else /* not  __ARMEB__ */
+        rev     r0, ip
+#endif /* not  __ARMEB__ */
+
+        /* Restore temporaries early, before computing the return value.  */
+        ldrd    r6, r7, [sp]
+        ldrd    r4, r5, [sp, #8]
+        adds    sp, sp, #16
+
+        /* There is a zero or a different byte between r1 and r2.  */
+        /* r0 contains a mask of all-zero bytes in r1.  */
+        /* Using r0 and not ip here because cbz requires low register.  */
+        m_cbz   reg=r0, label=compute_return_value
+        clz     r0, r0
+        /* r0 contains the number of bits on the left of the first all-zero byte in r1.  */
+        rsb     r0, r0, #24
+        /* Here, r0 contains the number of bits on the right of the first all-zero byte in r1.  */
+        lsr     r1, r1, r0
+        lsr     r2, r2, r0
+
+compute_return_value:
+        movs    r0, #1
+        cmp     r1, r2
+        /* The return value is computed as follows.
+        If r1>r2 then (C==1 and Z==0) and LS doesn't hold and r0 is #1 at return.
+        If r1<r2 then (C==0 and Z==0) and we execute SBC with carry_in=0,
+        which means r0:=r0-r0-1 and r0 is #-1 at return.
+        If r1=r2 then (C==1 and Z==1) and we execute SBC with carry_in=1,
+        which means r0:=r0-r0 and r0 is #0 at return.
+        (C==0 and Z==1) cannot happen because the carry bit is "not borrow".  */
+        it      ls
+        sbcls   r0, r0, r0
+        bx      lr
+
+    /* The code from the previous version of strcmp.S handles this
+     * particular case (the second string is 2 bytes off a word alignment)
+     * faster than any current version. In this very specific case, use the
+     * previous version. See bionic/libc/arch-arm/cortex-a15/bionic/strcmp.S
+     * for the unedited version of this code.
+     */
+miscmp_word_16:
+	wp1 .req r0
+	wp2 .req r1
+	b1  .req r2
+	w1  .req r4
+	w2  .req r5
+	t1  .req ip
+	@ r3 is scratch
+
+    /* At this point, wp1 (r0) has already been word-aligned. */
+2:
+	mov	b1, #1
+	orr	b1, b1, b1, lsl #8
+	orr	b1, b1, b1, lsl #16
+
+	and	t1, wp2, #3
+	bic	wp2, wp2, #3
+	ldr	w1, [wp1], #4
+	ldr	w2, [wp2], #4
+
+	/* Critical inner Loop: Block with 2 bytes initial overlap */
+	.p2align	2
+2:
+	S2HIMEM	t1, w1, #16
+	sub	r3, w1, b1
+	S2LOMEM	t1, t1, #16
+	bic	r3, r3, w1
+	cmp	t1, w2, S2LOMEM #16
+	bne	4f
+	ands	r3, r3, b1, lsl #7
+	it	eq
+	ldreq	w2, [wp2], #4
+	bne	5f
+	eor	t1, t1, w1
+	cmp	t1, w2, S2HIMEM #16
+	bne	6f
+	ldr	w1, [wp1], #4
+	b	2b
+
+5:
+#ifdef __ARMEB__
+	/* The syndrome value may contain false ones if the string ends
+	 * with the bytes 0x01 0x00
+	 */
+	tst	w1, #0xff000000
+	it	ne
+	tstne	w1, #0x00ff0000
+	beq	7f
+#else
+	lsls	r3, r3, #16
+	bne	7f
+#endif
+	ldrh	w2, [wp2]
+	S2LOMEM	t1, w1, #16
+#ifdef __ARMEB__
+	lsl	w2, w2, #16
+#endif
+	b	8f
+
+6:
+	S2HIMEM	w2, w2, #16
+	S2LOMEM	t1, w1, #16
+4:
+	S2LOMEM	w2, w2, #16
+	b	8f
+
+7:
+	mov	r0, #0
+
+    /* Restore registers and stack. */
+    ldrd    r6, r7, [sp]
+    ldrd    r4, r5, [sp, #8]
+    adds    sp, sp, #16
+
+	bx	lr
+
+8:
+	and	r2, t1, #LSB
+	and	r0, w2, #LSB
+	cmp	r0, #1
+	it	cs
+	cmpcs	r0, r2
+	itt	eq
+	S2LOMEMEQ	t1, t1, #8
+	S2LOMEMEQ	w2, w2, #8
+	beq	8b
+	sub	r0, r2, r0
+
+    /* Restore registers and stack. */
+    ldrd    r6, r7, [sp]
+    ldrd    r4, r5, [sp, #8]
+    adds    sp, sp, #16
+
+	bx	lr
+END(strcmp)
diff --git a/libc/arch-arm/krait/krait.mk b/libc/arch-arm/krait/krait.mk
index ab55d24..4847f86 100644
--- a/libc/arch-arm/krait/krait.mk
+++ b/libc/arch-arm/krait/krait.mk
@@ -1,4 +1,5 @@
 $(call libc-add-cpu-variant-src,MEMCPY,arch-arm/krait/bionic/memcpy.S)
 $(call libc-add-cpu-variant-src,MEMSET,arch-arm/krait/bionic/memset.S)
+$(call libc-add-cpu-variant-src,STRCMP,arch-arm/krait/bionic/strcmp.S)
 
 include bionic/libc/arch-arm/generic/generic.mk
diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk
index 5cb46b5..9eb5136 100644
--- a/libc/arch-arm/syscalls.mk
+++ b/libc/arch-arm/syscalls.mk
@@ -4,6 +4,7 @@
 syscall_src += arch-arm/syscalls/_exit_thread.S
 syscall_src += arch-arm/syscalls/__fork.S
 syscall_src += arch-arm/syscalls/__waitid.S
+syscall_src += arch-arm/syscalls/wait4.S
 syscall_src += arch-arm/syscalls/__sys_clone.S
 syscall_src += arch-arm/syscalls/execve.S
 syscall_src += arch-arm/syscalls/__setuid.S
@@ -180,7 +181,6 @@
 syscall_src += arch-arm/syscalls/ioprio_set.S
 syscall_src += arch-arm/syscalls/ioprio_get.S
 syscall_src += arch-arm/syscalls/uname.S
-syscall_src += arch-arm/syscalls/__wait4.S
 syscall_src += arch-arm/syscalls/umask.S
 syscall_src += arch-arm/syscalls/__reboot.S
 syscall_src += arch-arm/syscalls/__syslog.S
diff --git a/libc/arch-arm/syscalls/__brk.S b/libc/arch-arm/syscalls/__brk.S
index e4fcab0..40fa49a 100644
--- a/libc/arch-arm/syscalls/__brk.S
+++ b/libc/arch-arm/syscalls/__brk.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__brk)
     mov     ip, r7
     ldr     r7, =__NR_brk
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__brk)
diff --git a/libc/arch-arm/syscalls/__fcntl.S b/libc/arch-arm/syscalls/__fcntl.S
index ee82ef1..126fb0f 100644
--- a/libc/arch-arm/syscalls/__fcntl.S
+++ b/libc/arch-arm/syscalls/__fcntl.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__fcntl)
     mov     ip, r7
     ldr     r7, =__NR_fcntl
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__fcntl)
diff --git a/libc/arch-arm/syscalls/__fcntl64.S b/libc/arch-arm/syscalls/__fcntl64.S
index 96cc16b..b7bc87b 100644
--- a/libc/arch-arm/syscalls/__fcntl64.S
+++ b/libc/arch-arm/syscalls/__fcntl64.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__fcntl64)
     mov     ip, r7
     ldr     r7, =__NR_fcntl64
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__fcntl64)
diff --git a/libc/arch-arm/syscalls/__fork.S b/libc/arch-arm/syscalls/__fork.S
index 9df9702..3bb2fb8 100644
--- a/libc/arch-arm/syscalls/__fork.S
+++ b/libc/arch-arm/syscalls/__fork.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__fork)
     mov     ip, r7
     ldr     r7, =__NR_fork
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__fork)
diff --git a/libc/arch-arm/syscalls/__fstatfs64.S b/libc/arch-arm/syscalls/__fstatfs64.S
index 6e90214..afbad24 100644
--- a/libc/arch-arm/syscalls/__fstatfs64.S
+++ b/libc/arch-arm/syscalls/__fstatfs64.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__fstatfs64)
     mov     ip, r7
     ldr     r7, =__NR_fstatfs64
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__fstatfs64)
diff --git a/libc/arch-arm/syscalls/__getcpu.S b/libc/arch-arm/syscalls/__getcpu.S
index 7976b06..3b2cbd9 100644
--- a/libc/arch-arm/syscalls/__getcpu.S
+++ b/libc/arch-arm/syscalls/__getcpu.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__getcpu)
     mov     ip, r7
     ldr     r7, =__NR_getcpu
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__getcpu)
diff --git a/libc/arch-arm/syscalls/__getcwd.S b/libc/arch-arm/syscalls/__getcwd.S
index 6fc2d64..7783e03 100644
--- a/libc/arch-arm/syscalls/__getcwd.S
+++ b/libc/arch-arm/syscalls/__getcwd.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__getcwd)
     mov     ip, r7
     ldr     r7, =__NR_getcwd
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__getcwd)
diff --git a/libc/arch-arm/syscalls/__getpriority.S b/libc/arch-arm/syscalls/__getpriority.S
index 6fb2a43..7a6ebec 100644
--- a/libc/arch-arm/syscalls/__getpriority.S
+++ b/libc/arch-arm/syscalls/__getpriority.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__getpriority)
     mov     ip, r7
     ldr     r7, =__NR_getpriority
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__getpriority)
diff --git a/libc/arch-arm/syscalls/__ioctl.S b/libc/arch-arm/syscalls/__ioctl.S
index 56fd607..ce20a71 100644
--- a/libc/arch-arm/syscalls/__ioctl.S
+++ b/libc/arch-arm/syscalls/__ioctl.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__ioctl)
     mov     ip, r7
     ldr     r7, =__NR_ioctl
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__ioctl)
diff --git a/libc/arch-arm/syscalls/__llseek.S b/libc/arch-arm/syscalls/__llseek.S
index 9893886..af3b38c 100644
--- a/libc/arch-arm/syscalls/__llseek.S
+++ b/libc/arch-arm/syscalls/__llseek.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__llseek)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR__llseek
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__llseek)
diff --git a/libc/arch-arm/syscalls/__mmap2.S b/libc/arch-arm/syscalls/__mmap2.S
index 542b3e0..c0c5b55 100644
--- a/libc/arch-arm/syscalls/__mmap2.S
+++ b/libc/arch-arm/syscalls/__mmap2.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__mmap2)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_mmap2
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__mmap2)
diff --git a/libc/arch-arm/syscalls/__open.S b/libc/arch-arm/syscalls/__open.S
index 589d5ad..a3f35be 100644
--- a/libc/arch-arm/syscalls/__open.S
+++ b/libc/arch-arm/syscalls/__open.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__open)
     mov     ip, r7
     ldr     r7, =__NR_open
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__open)
diff --git a/libc/arch-arm/syscalls/__openat.S b/libc/arch-arm/syscalls/__openat.S
index 10c30d3..ea1a3a7 100644
--- a/libc/arch-arm/syscalls/__openat.S
+++ b/libc/arch-arm/syscalls/__openat.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__openat)
     mov     ip, r7
     ldr     r7, =__NR_openat
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__openat)
diff --git a/libc/arch-arm/syscalls/__ptrace.S b/libc/arch-arm/syscalls/__ptrace.S
index 72acd70..b1abf87 100644
--- a/libc/arch-arm/syscalls/__ptrace.S
+++ b/libc/arch-arm/syscalls/__ptrace.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__ptrace)
     mov     ip, r7
     ldr     r7, =__NR_ptrace
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__ptrace)
diff --git a/libc/arch-arm/syscalls/__reboot.S b/libc/arch-arm/syscalls/__reboot.S
index 07898a0..ad2bc8d 100644
--- a/libc/arch-arm/syscalls/__reboot.S
+++ b/libc/arch-arm/syscalls/__reboot.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__reboot)
     mov     ip, r7
     ldr     r7, =__NR_reboot
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__reboot)
diff --git a/libc/arch-arm/syscalls/__rt_sigaction.S b/libc/arch-arm/syscalls/__rt_sigaction.S
index 31d4c1e..0a4be2a 100644
--- a/libc/arch-arm/syscalls/__rt_sigaction.S
+++ b/libc/arch-arm/syscalls/__rt_sigaction.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__rt_sigaction)
     mov     ip, r7
     ldr     r7, =__NR_rt_sigaction
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__rt_sigaction)
diff --git a/libc/arch-arm/syscalls/__rt_sigprocmask.S b/libc/arch-arm/syscalls/__rt_sigprocmask.S
index 640a7ee..0008da2 100644
--- a/libc/arch-arm/syscalls/__rt_sigprocmask.S
+++ b/libc/arch-arm/syscalls/__rt_sigprocmask.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__rt_sigprocmask)
     mov     ip, r7
     ldr     r7, =__NR_rt_sigprocmask
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__rt_sigprocmask)
diff --git a/libc/arch-arm/syscalls/__rt_sigtimedwait.S b/libc/arch-arm/syscalls/__rt_sigtimedwait.S
index ad725af..02c4d18 100644
--- a/libc/arch-arm/syscalls/__rt_sigtimedwait.S
+++ b/libc/arch-arm/syscalls/__rt_sigtimedwait.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__rt_sigtimedwait)
     mov     ip, r7
     ldr     r7, =__NR_rt_sigtimedwait
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__rt_sigtimedwait)
diff --git a/libc/arch-arm/syscalls/__sched_getaffinity.S b/libc/arch-arm/syscalls/__sched_getaffinity.S
index bee1674..c02f7fd 100644
--- a/libc/arch-arm/syscalls/__sched_getaffinity.S
+++ b/libc/arch-arm/syscalls/__sched_getaffinity.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__sched_getaffinity)
     mov     ip, r7
     ldr     r7, =__NR_sched_getaffinity
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__sched_getaffinity)
diff --git a/libc/arch-arm/syscalls/__set_tls.S b/libc/arch-arm/syscalls/__set_tls.S
index 3039b35..73142ba 100644
--- a/libc/arch-arm/syscalls/__set_tls.S
+++ b/libc/arch-arm/syscalls/__set_tls.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__set_tls)
     mov     ip, r7
-    ldr     r7, =__NR_ARM_set_tls
+    ldr     r7, =__ARM_NR_set_tls
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__set_tls)
diff --git a/libc/arch-arm/syscalls/__setresuid.S b/libc/arch-arm/syscalls/__setresuid.S
index 1877bbf..0fd8ae6 100644
--- a/libc/arch-arm/syscalls/__setresuid.S
+++ b/libc/arch-arm/syscalls/__setresuid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__setresuid)
     mov     ip, r7
     ldr     r7, =__NR_setresuid32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__setresuid)
diff --git a/libc/arch-arm/syscalls/__setreuid.S b/libc/arch-arm/syscalls/__setreuid.S
index 2129cb2..bc2fe84 100644
--- a/libc/arch-arm/syscalls/__setreuid.S
+++ b/libc/arch-arm/syscalls/__setreuid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__setreuid)
     mov     ip, r7
     ldr     r7, =__NR_setreuid32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__setreuid)
diff --git a/libc/arch-arm/syscalls/__setuid.S b/libc/arch-arm/syscalls/__setuid.S
index 9df2f89..f7b94da 100644
--- a/libc/arch-arm/syscalls/__setuid.S
+++ b/libc/arch-arm/syscalls/__setuid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__setuid)
     mov     ip, r7
     ldr     r7, =__NR_setuid32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__setuid)
diff --git a/libc/arch-arm/syscalls/__sigsuspend.S b/libc/arch-arm/syscalls/__sigsuspend.S
index 8f1ff55..dc519d2 100644
--- a/libc/arch-arm/syscalls/__sigsuspend.S
+++ b/libc/arch-arm/syscalls/__sigsuspend.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__sigsuspend)
     mov     ip, r7
     ldr     r7, =__NR_sigsuspend
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__sigsuspend)
diff --git a/libc/arch-arm/syscalls/__statfs64.S b/libc/arch-arm/syscalls/__statfs64.S
index f8d63a3..4ba592e 100644
--- a/libc/arch-arm/syscalls/__statfs64.S
+++ b/libc/arch-arm/syscalls/__statfs64.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__statfs64)
     mov     ip, r7
     ldr     r7, =__NR_statfs64
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__statfs64)
diff --git a/libc/arch-arm/syscalls/__sys_clone.S b/libc/arch-arm/syscalls/__sys_clone.S
index 48046bc..7308c21 100644
--- a/libc/arch-arm/syscalls/__sys_clone.S
+++ b/libc/arch-arm/syscalls/__sys_clone.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__sys_clone)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_clone
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__sys_clone)
diff --git a/libc/arch-arm/syscalls/__syslog.S b/libc/arch-arm/syscalls/__syslog.S
index 8ad0271..1588903 100644
--- a/libc/arch-arm/syscalls/__syslog.S
+++ b/libc/arch-arm/syscalls/__syslog.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__syslog)
     mov     ip, r7
     ldr     r7, =__NR_syslog
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__syslog)
diff --git a/libc/arch-arm/syscalls/__timer_create.S b/libc/arch-arm/syscalls/__timer_create.S
index fcb4e3f..eedff93 100644
--- a/libc/arch-arm/syscalls/__timer_create.S
+++ b/libc/arch-arm/syscalls/__timer_create.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__timer_create)
     mov     ip, r7
     ldr     r7, =__NR_timer_create
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__timer_create)
diff --git a/libc/arch-arm/syscalls/__timer_delete.S b/libc/arch-arm/syscalls/__timer_delete.S
index de303fc..be29c40 100644
--- a/libc/arch-arm/syscalls/__timer_delete.S
+++ b/libc/arch-arm/syscalls/__timer_delete.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__timer_delete)
     mov     ip, r7
     ldr     r7, =__NR_timer_delete
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__timer_delete)
diff --git a/libc/arch-arm/syscalls/__timer_getoverrun.S b/libc/arch-arm/syscalls/__timer_getoverrun.S
index a96b047..11dd91c 100644
--- a/libc/arch-arm/syscalls/__timer_getoverrun.S
+++ b/libc/arch-arm/syscalls/__timer_getoverrun.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__timer_getoverrun)
     mov     ip, r7
     ldr     r7, =__NR_timer_getoverrun
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__timer_getoverrun)
diff --git a/libc/arch-arm/syscalls/__timer_gettime.S b/libc/arch-arm/syscalls/__timer_gettime.S
index 6e6bbf5..46f9a5e 100644
--- a/libc/arch-arm/syscalls/__timer_gettime.S
+++ b/libc/arch-arm/syscalls/__timer_gettime.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__timer_gettime)
     mov     ip, r7
     ldr     r7, =__NR_timer_gettime
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__timer_gettime)
diff --git a/libc/arch-arm/syscalls/__timer_settime.S b/libc/arch-arm/syscalls/__timer_settime.S
index bcbe298..f5ada76 100644
--- a/libc/arch-arm/syscalls/__timer_settime.S
+++ b/libc/arch-arm/syscalls/__timer_settime.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__timer_settime)
     mov     ip, r7
     ldr     r7, =__NR_timer_settime
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__timer_settime)
diff --git a/libc/arch-arm/syscalls/__wait4.S b/libc/arch-arm/syscalls/__wait4.S
deleted file mode 100644
index 2a0e5c4..0000000
--- a/libc/arch-arm/syscalls/__wait4.S
+++ /dev/null
@@ -1,13 +0,0 @@
-/* autogenerated by gensyscalls.py */
-#include <machine/asm.h>
-#include <sys/linux-syscalls.h>
-
-ENTRY(__wait4)
-    mov     ip, r7
-    ldr     r7, =__NR_wait4
-    swi     #0
-    mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
-END(__wait4)
diff --git a/libc/arch-arm/syscalls/__waitid.S b/libc/arch-arm/syscalls/__waitid.S
index 9950e9c..8db2812 100644
--- a/libc/arch-arm/syscalls/__waitid.S
+++ b/libc/arch-arm/syscalls/__waitid.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(__waitid)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_waitid
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(__waitid)
diff --git a/libc/arch-arm/syscalls/_exit.S b/libc/arch-arm/syscalls/_exit.S
index ab444ce..069a4ec 100644
--- a/libc/arch-arm/syscalls/_exit.S
+++ b/libc/arch-arm/syscalls/_exit.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(_exit)
     mov     ip, r7
     ldr     r7, =__NR_exit_group
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(_exit)
diff --git a/libc/arch-arm/syscalls/_exit_thread.S b/libc/arch-arm/syscalls/_exit_thread.S
index 53a21fb..b41d7b4 100644
--- a/libc/arch-arm/syscalls/_exit_thread.S
+++ b/libc/arch-arm/syscalls/_exit_thread.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(_exit_thread)
     mov     ip, r7
     ldr     r7, =__NR_exit
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(_exit_thread)
diff --git a/libc/arch-arm/syscalls/accept.S b/libc/arch-arm/syscalls/accept.S
index b1a2d72..674bafe 100644
--- a/libc/arch-arm/syscalls/accept.S
+++ b/libc/arch-arm/syscalls/accept.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(accept)
     mov     ip, r7
     ldr     r7, =__NR_accept
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(accept)
diff --git a/libc/arch-arm/syscalls/access.S b/libc/arch-arm/syscalls/access.S
index c0b0333..6eaeca9 100644
--- a/libc/arch-arm/syscalls/access.S
+++ b/libc/arch-arm/syscalls/access.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(access)
     mov     ip, r7
     ldr     r7, =__NR_access
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(access)
diff --git a/libc/arch-arm/syscalls/acct.S b/libc/arch-arm/syscalls/acct.S
index 5485be1..27a4136 100644
--- a/libc/arch-arm/syscalls/acct.S
+++ b/libc/arch-arm/syscalls/acct.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(acct)
     mov     ip, r7
     ldr     r7, =__NR_acct
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(acct)
diff --git a/libc/arch-arm/syscalls/bind.S b/libc/arch-arm/syscalls/bind.S
index 1bb5843..641405f 100644
--- a/libc/arch-arm/syscalls/bind.S
+++ b/libc/arch-arm/syscalls/bind.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(bind)
     mov     ip, r7
     ldr     r7, =__NR_bind
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(bind)
diff --git a/libc/arch-arm/syscalls/cacheflush.S b/libc/arch-arm/syscalls/cacheflush.S
index fd7f68d..3551274 100644
--- a/libc/arch-arm/syscalls/cacheflush.S
+++ b/libc/arch-arm/syscalls/cacheflush.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(cacheflush)
     mov     ip, r7
-    ldr     r7, =__NR_ARM_cacheflush
+    ldr     r7, =__ARM_NR_cacheflush
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(cacheflush)
diff --git a/libc/arch-arm/syscalls/capget.S b/libc/arch-arm/syscalls/capget.S
index 1f425a0..08c0f38 100644
--- a/libc/arch-arm/syscalls/capget.S
+++ b/libc/arch-arm/syscalls/capget.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(capget)
     mov     ip, r7
     ldr     r7, =__NR_capget
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(capget)
diff --git a/libc/arch-arm/syscalls/capset.S b/libc/arch-arm/syscalls/capset.S
index 13ebd5a..90aa343 100644
--- a/libc/arch-arm/syscalls/capset.S
+++ b/libc/arch-arm/syscalls/capset.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(capset)
     mov     ip, r7
     ldr     r7, =__NR_capset
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(capset)
diff --git a/libc/arch-arm/syscalls/chdir.S b/libc/arch-arm/syscalls/chdir.S
index 4965495..e6485a6 100644
--- a/libc/arch-arm/syscalls/chdir.S
+++ b/libc/arch-arm/syscalls/chdir.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(chdir)
     mov     ip, r7
     ldr     r7, =__NR_chdir
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(chdir)
diff --git a/libc/arch-arm/syscalls/chmod.S b/libc/arch-arm/syscalls/chmod.S
index ed9d52f..4b98ca6 100644
--- a/libc/arch-arm/syscalls/chmod.S
+++ b/libc/arch-arm/syscalls/chmod.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(chmod)
     mov     ip, r7
     ldr     r7, =__NR_chmod
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(chmod)
diff --git a/libc/arch-arm/syscalls/chown.S b/libc/arch-arm/syscalls/chown.S
index ff1cec2..7838a2a 100644
--- a/libc/arch-arm/syscalls/chown.S
+++ b/libc/arch-arm/syscalls/chown.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(chown)
     mov     ip, r7
     ldr     r7, =__NR_chown32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(chown)
diff --git a/libc/arch-arm/syscalls/chroot.S b/libc/arch-arm/syscalls/chroot.S
index bc8e3fe..f3534b6 100644
--- a/libc/arch-arm/syscalls/chroot.S
+++ b/libc/arch-arm/syscalls/chroot.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(chroot)
     mov     ip, r7
     ldr     r7, =__NR_chroot
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(chroot)
diff --git a/libc/arch-arm/syscalls/clock_getres.S b/libc/arch-arm/syscalls/clock_getres.S
index 66cf9ec..81a2cdc 100644
--- a/libc/arch-arm/syscalls/clock_getres.S
+++ b/libc/arch-arm/syscalls/clock_getres.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(clock_getres)
     mov     ip, r7
     ldr     r7, =__NR_clock_getres
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(clock_getres)
diff --git a/libc/arch-arm/syscalls/clock_gettime.S b/libc/arch-arm/syscalls/clock_gettime.S
index 4e42c82..e26d700 100644
--- a/libc/arch-arm/syscalls/clock_gettime.S
+++ b/libc/arch-arm/syscalls/clock_gettime.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(clock_gettime)
     mov     ip, r7
     ldr     r7, =__NR_clock_gettime
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(clock_gettime)
diff --git a/libc/arch-arm/syscalls/clock_nanosleep.S b/libc/arch-arm/syscalls/clock_nanosleep.S
index 6d530a2..dc0584f 100644
--- a/libc/arch-arm/syscalls/clock_nanosleep.S
+++ b/libc/arch-arm/syscalls/clock_nanosleep.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(clock_nanosleep)
     mov     ip, r7
     ldr     r7, =__NR_clock_nanosleep
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(clock_nanosleep)
diff --git a/libc/arch-arm/syscalls/clock_settime.S b/libc/arch-arm/syscalls/clock_settime.S
index e9374b5..2596f53 100644
--- a/libc/arch-arm/syscalls/clock_settime.S
+++ b/libc/arch-arm/syscalls/clock_settime.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(clock_settime)
     mov     ip, r7
     ldr     r7, =__NR_clock_settime
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(clock_settime)
diff --git a/libc/arch-arm/syscalls/close.S b/libc/arch-arm/syscalls/close.S
index eb4cb62..2225929 100644
--- a/libc/arch-arm/syscalls/close.S
+++ b/libc/arch-arm/syscalls/close.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(close)
     mov     ip, r7
     ldr     r7, =__NR_close
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(close)
diff --git a/libc/arch-arm/syscalls/connect.S b/libc/arch-arm/syscalls/connect.S
index b97b4fe..0d4682a 100644
--- a/libc/arch-arm/syscalls/connect.S
+++ b/libc/arch-arm/syscalls/connect.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(connect)
     mov     ip, r7
     ldr     r7, =__NR_connect
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(connect)
diff --git a/libc/arch-arm/syscalls/delete_module.S b/libc/arch-arm/syscalls/delete_module.S
index 0994994..345c012 100644
--- a/libc/arch-arm/syscalls/delete_module.S
+++ b/libc/arch-arm/syscalls/delete_module.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(delete_module)
     mov     ip, r7
     ldr     r7, =__NR_delete_module
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(delete_module)
diff --git a/libc/arch-arm/syscalls/dup.S b/libc/arch-arm/syscalls/dup.S
index 8854342..060d555 100644
--- a/libc/arch-arm/syscalls/dup.S
+++ b/libc/arch-arm/syscalls/dup.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(dup)
     mov     ip, r7
     ldr     r7, =__NR_dup
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(dup)
diff --git a/libc/arch-arm/syscalls/dup2.S b/libc/arch-arm/syscalls/dup2.S
index 0dcc57f..9465860 100644
--- a/libc/arch-arm/syscalls/dup2.S
+++ b/libc/arch-arm/syscalls/dup2.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(dup2)
     mov     ip, r7
     ldr     r7, =__NR_dup2
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(dup2)
diff --git a/libc/arch-arm/syscalls/epoll_create.S b/libc/arch-arm/syscalls/epoll_create.S
index 92a2781..b2894e6 100644
--- a/libc/arch-arm/syscalls/epoll_create.S
+++ b/libc/arch-arm/syscalls/epoll_create.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(epoll_create)
     mov     ip, r7
     ldr     r7, =__NR_epoll_create
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(epoll_create)
diff --git a/libc/arch-arm/syscalls/epoll_ctl.S b/libc/arch-arm/syscalls/epoll_ctl.S
index b3c630f..7a56b99 100644
--- a/libc/arch-arm/syscalls/epoll_ctl.S
+++ b/libc/arch-arm/syscalls/epoll_ctl.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(epoll_ctl)
     mov     ip, r7
     ldr     r7, =__NR_epoll_ctl
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(epoll_ctl)
diff --git a/libc/arch-arm/syscalls/epoll_wait.S b/libc/arch-arm/syscalls/epoll_wait.S
index 3ccac91..11252be 100644
--- a/libc/arch-arm/syscalls/epoll_wait.S
+++ b/libc/arch-arm/syscalls/epoll_wait.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(epoll_wait)
     mov     ip, r7
     ldr     r7, =__NR_epoll_wait
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(epoll_wait)
diff --git a/libc/arch-arm/syscalls/eventfd.S b/libc/arch-arm/syscalls/eventfd.S
index 754f019..602aecd 100644
--- a/libc/arch-arm/syscalls/eventfd.S
+++ b/libc/arch-arm/syscalls/eventfd.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(eventfd)
     mov     ip, r7
     ldr     r7, =__NR_eventfd2
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(eventfd)
diff --git a/libc/arch-arm/syscalls/execve.S b/libc/arch-arm/syscalls/execve.S
index 49e5b13..00de4b8 100644
--- a/libc/arch-arm/syscalls/execve.S
+++ b/libc/arch-arm/syscalls/execve.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(execve)
     mov     ip, r7
     ldr     r7, =__NR_execve
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(execve)
diff --git a/libc/arch-arm/syscalls/faccessat.S b/libc/arch-arm/syscalls/faccessat.S
index 5ade517..567451e 100644
--- a/libc/arch-arm/syscalls/faccessat.S
+++ b/libc/arch-arm/syscalls/faccessat.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(faccessat)
     mov     ip, r7
     ldr     r7, =__NR_faccessat
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(faccessat)
diff --git a/libc/arch-arm/syscalls/fchdir.S b/libc/arch-arm/syscalls/fchdir.S
index 96a047d..170324e 100644
--- a/libc/arch-arm/syscalls/fchdir.S
+++ b/libc/arch-arm/syscalls/fchdir.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(fchdir)
     mov     ip, r7
     ldr     r7, =__NR_fchdir
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(fchdir)
diff --git a/libc/arch-arm/syscalls/fchmod.S b/libc/arch-arm/syscalls/fchmod.S
index b096a8c..657a565 100644
--- a/libc/arch-arm/syscalls/fchmod.S
+++ b/libc/arch-arm/syscalls/fchmod.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(fchmod)
     mov     ip, r7
     ldr     r7, =__NR_fchmod
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(fchmod)
diff --git a/libc/arch-arm/syscalls/fchmodat.S b/libc/arch-arm/syscalls/fchmodat.S
index 8c87598..acdf6c8 100644
--- a/libc/arch-arm/syscalls/fchmodat.S
+++ b/libc/arch-arm/syscalls/fchmodat.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(fchmodat)
     mov     ip, r7
     ldr     r7, =__NR_fchmodat
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(fchmodat)
diff --git a/libc/arch-arm/syscalls/fchown.S b/libc/arch-arm/syscalls/fchown.S
index 2f7e92b..6d75eb4 100644
--- a/libc/arch-arm/syscalls/fchown.S
+++ b/libc/arch-arm/syscalls/fchown.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(fchown)
     mov     ip, r7
     ldr     r7, =__NR_fchown32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(fchown)
diff --git a/libc/arch-arm/syscalls/fchownat.S b/libc/arch-arm/syscalls/fchownat.S
index 1482832..31864ec 100644
--- a/libc/arch-arm/syscalls/fchownat.S
+++ b/libc/arch-arm/syscalls/fchownat.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(fchownat)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_fchownat
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(fchownat)
diff --git a/libc/arch-arm/syscalls/fdatasync.S b/libc/arch-arm/syscalls/fdatasync.S
index 31818c8..62b89cc 100644
--- a/libc/arch-arm/syscalls/fdatasync.S
+++ b/libc/arch-arm/syscalls/fdatasync.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(fdatasync)
     mov     ip, r7
     ldr     r7, =__NR_fdatasync
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(fdatasync)
diff --git a/libc/arch-arm/syscalls/fgetxattr.S b/libc/arch-arm/syscalls/fgetxattr.S
index 6f3eb3d..e8cc8d3 100644
--- a/libc/arch-arm/syscalls/fgetxattr.S
+++ b/libc/arch-arm/syscalls/fgetxattr.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(fgetxattr)
     mov     ip, r7
     ldr     r7, =__NR_fgetxattr
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(fgetxattr)
diff --git a/libc/arch-arm/syscalls/flistxattr.S b/libc/arch-arm/syscalls/flistxattr.S
index 38e856d..fe8d876 100644
--- a/libc/arch-arm/syscalls/flistxattr.S
+++ b/libc/arch-arm/syscalls/flistxattr.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(flistxattr)
     mov     ip, r7
     ldr     r7, =__NR_flistxattr
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(flistxattr)
diff --git a/libc/arch-arm/syscalls/flock.S b/libc/arch-arm/syscalls/flock.S
index 3732bfe..2e28b1b 100644
--- a/libc/arch-arm/syscalls/flock.S
+++ b/libc/arch-arm/syscalls/flock.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(flock)
     mov     ip, r7
     ldr     r7, =__NR_flock
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(flock)
diff --git a/libc/arch-arm/syscalls/fremovexattr.S b/libc/arch-arm/syscalls/fremovexattr.S
index 45cf803..9fab8f3 100644
--- a/libc/arch-arm/syscalls/fremovexattr.S
+++ b/libc/arch-arm/syscalls/fremovexattr.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(fremovexattr)
     mov     ip, r7
     ldr     r7, =__NR_fremovexattr
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(fremovexattr)
diff --git a/libc/arch-arm/syscalls/fsetxattr.S b/libc/arch-arm/syscalls/fsetxattr.S
index 176cad9..87ed835 100644
--- a/libc/arch-arm/syscalls/fsetxattr.S
+++ b/libc/arch-arm/syscalls/fsetxattr.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(fsetxattr)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_fsetxattr
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(fsetxattr)
diff --git a/libc/arch-arm/syscalls/fstat.S b/libc/arch-arm/syscalls/fstat.S
index d314213..6ad5589 100644
--- a/libc/arch-arm/syscalls/fstat.S
+++ b/libc/arch-arm/syscalls/fstat.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(fstat)
     mov     ip, r7
     ldr     r7, =__NR_fstat64
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(fstat)
diff --git a/libc/arch-arm/syscalls/fstatat.S b/libc/arch-arm/syscalls/fstatat.S
index 8cf1a57..f4577dc 100644
--- a/libc/arch-arm/syscalls/fstatat.S
+++ b/libc/arch-arm/syscalls/fstatat.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(fstatat)
     mov     ip, r7
     ldr     r7, =__NR_fstatat64
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(fstatat)
diff --git a/libc/arch-arm/syscalls/fsync.S b/libc/arch-arm/syscalls/fsync.S
index 52cfa53..54f7d57 100644
--- a/libc/arch-arm/syscalls/fsync.S
+++ b/libc/arch-arm/syscalls/fsync.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(fsync)
     mov     ip, r7
     ldr     r7, =__NR_fsync
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(fsync)
diff --git a/libc/arch-arm/syscalls/ftruncate.S b/libc/arch-arm/syscalls/ftruncate.S
index 14cd87d..659bfbf 100644
--- a/libc/arch-arm/syscalls/ftruncate.S
+++ b/libc/arch-arm/syscalls/ftruncate.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(ftruncate)
     mov     ip, r7
     ldr     r7, =__NR_ftruncate
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(ftruncate)
diff --git a/libc/arch-arm/syscalls/ftruncate64.S b/libc/arch-arm/syscalls/ftruncate64.S
index 0e1b42b..123897d 100644
--- a/libc/arch-arm/syscalls/ftruncate64.S
+++ b/libc/arch-arm/syscalls/ftruncate64.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(ftruncate64)
     mov     ip, r7
     ldr     r7, =__NR_ftruncate64
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(ftruncate64)
diff --git a/libc/arch-arm/syscalls/futex.S b/libc/arch-arm/syscalls/futex.S
index 47219e3..27b15b7 100644
--- a/libc/arch-arm/syscalls/futex.S
+++ b/libc/arch-arm/syscalls/futex.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(futex)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_futex
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(futex)
diff --git a/libc/arch-arm/syscalls/getdents.S b/libc/arch-arm/syscalls/getdents.S
index e6c3028..8506f29 100644
--- a/libc/arch-arm/syscalls/getdents.S
+++ b/libc/arch-arm/syscalls/getdents.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getdents)
     mov     ip, r7
     ldr     r7, =__NR_getdents64
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getdents)
diff --git a/libc/arch-arm/syscalls/getegid.S b/libc/arch-arm/syscalls/getegid.S
index 22794d1..7dc524e 100644
--- a/libc/arch-arm/syscalls/getegid.S
+++ b/libc/arch-arm/syscalls/getegid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getegid)
     mov     ip, r7
     ldr     r7, =__NR_getegid32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getegid)
diff --git a/libc/arch-arm/syscalls/geteuid.S b/libc/arch-arm/syscalls/geteuid.S
index cfb318f..64cc074 100644
--- a/libc/arch-arm/syscalls/geteuid.S
+++ b/libc/arch-arm/syscalls/geteuid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(geteuid)
     mov     ip, r7
     ldr     r7, =__NR_geteuid32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(geteuid)
diff --git a/libc/arch-arm/syscalls/getgid.S b/libc/arch-arm/syscalls/getgid.S
index 085061e..a56a160 100644
--- a/libc/arch-arm/syscalls/getgid.S
+++ b/libc/arch-arm/syscalls/getgid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getgid)
     mov     ip, r7
     ldr     r7, =__NR_getgid32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getgid)
diff --git a/libc/arch-arm/syscalls/getgroups.S b/libc/arch-arm/syscalls/getgroups.S
index c426d87..3ed236d 100644
--- a/libc/arch-arm/syscalls/getgroups.S
+++ b/libc/arch-arm/syscalls/getgroups.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getgroups)
     mov     ip, r7
     ldr     r7, =__NR_getgroups32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getgroups)
diff --git a/libc/arch-arm/syscalls/getitimer.S b/libc/arch-arm/syscalls/getitimer.S
index 5d832d9..091450f 100644
--- a/libc/arch-arm/syscalls/getitimer.S
+++ b/libc/arch-arm/syscalls/getitimer.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getitimer)
     mov     ip, r7
     ldr     r7, =__NR_getitimer
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getitimer)
diff --git a/libc/arch-arm/syscalls/getpeername.S b/libc/arch-arm/syscalls/getpeername.S
index ced69f7..8b956bf 100644
--- a/libc/arch-arm/syscalls/getpeername.S
+++ b/libc/arch-arm/syscalls/getpeername.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getpeername)
     mov     ip, r7
     ldr     r7, =__NR_getpeername
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getpeername)
diff --git a/libc/arch-arm/syscalls/getpgid.S b/libc/arch-arm/syscalls/getpgid.S
index d599f1e..cbc510f 100644
--- a/libc/arch-arm/syscalls/getpgid.S
+++ b/libc/arch-arm/syscalls/getpgid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getpgid)
     mov     ip, r7
     ldr     r7, =__NR_getpgid
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getpgid)
diff --git a/libc/arch-arm/syscalls/getpid.S b/libc/arch-arm/syscalls/getpid.S
index ef19d25..ecb125b 100644
--- a/libc/arch-arm/syscalls/getpid.S
+++ b/libc/arch-arm/syscalls/getpid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getpid)
     mov     ip, r7
     ldr     r7, =__NR_getpid
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getpid)
diff --git a/libc/arch-arm/syscalls/getppid.S b/libc/arch-arm/syscalls/getppid.S
index 1fe30d4..4a775e7 100644
--- a/libc/arch-arm/syscalls/getppid.S
+++ b/libc/arch-arm/syscalls/getppid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getppid)
     mov     ip, r7
     ldr     r7, =__NR_getppid
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getppid)
diff --git a/libc/arch-arm/syscalls/getresgid.S b/libc/arch-arm/syscalls/getresgid.S
index e8d2129..e574ef3 100644
--- a/libc/arch-arm/syscalls/getresgid.S
+++ b/libc/arch-arm/syscalls/getresgid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getresgid)
     mov     ip, r7
     ldr     r7, =__NR_getresgid32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getresgid)
diff --git a/libc/arch-arm/syscalls/getresuid.S b/libc/arch-arm/syscalls/getresuid.S
index cdfe0f7..9c8b0bf 100644
--- a/libc/arch-arm/syscalls/getresuid.S
+++ b/libc/arch-arm/syscalls/getresuid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getresuid)
     mov     ip, r7
     ldr     r7, =__NR_getresuid32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getresuid)
diff --git a/libc/arch-arm/syscalls/getrlimit.S b/libc/arch-arm/syscalls/getrlimit.S
index 3acbf95..21380f9 100644
--- a/libc/arch-arm/syscalls/getrlimit.S
+++ b/libc/arch-arm/syscalls/getrlimit.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getrlimit)
     mov     ip, r7
     ldr     r7, =__NR_ugetrlimit
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getrlimit)
diff --git a/libc/arch-arm/syscalls/getrusage.S b/libc/arch-arm/syscalls/getrusage.S
index e17fc4a..131c58f 100644
--- a/libc/arch-arm/syscalls/getrusage.S
+++ b/libc/arch-arm/syscalls/getrusage.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getrusage)
     mov     ip, r7
     ldr     r7, =__NR_getrusage
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getrusage)
diff --git a/libc/arch-arm/syscalls/getsid.S b/libc/arch-arm/syscalls/getsid.S
index 06e6d67..e5ffd5f 100644
--- a/libc/arch-arm/syscalls/getsid.S
+++ b/libc/arch-arm/syscalls/getsid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getsid)
     mov     ip, r7
     ldr     r7, =__NR_getsid
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getsid)
diff --git a/libc/arch-arm/syscalls/getsockname.S b/libc/arch-arm/syscalls/getsockname.S
index 458814f..ec0f930 100644
--- a/libc/arch-arm/syscalls/getsockname.S
+++ b/libc/arch-arm/syscalls/getsockname.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getsockname)
     mov     ip, r7
     ldr     r7, =__NR_getsockname
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getsockname)
diff --git a/libc/arch-arm/syscalls/getsockopt.S b/libc/arch-arm/syscalls/getsockopt.S
index d52f441..95f79af 100644
--- a/libc/arch-arm/syscalls/getsockopt.S
+++ b/libc/arch-arm/syscalls/getsockopt.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getsockopt)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_getsockopt
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getsockopt)
diff --git a/libc/arch-arm/syscalls/gettid.S b/libc/arch-arm/syscalls/gettid.S
index f35c7ea..b8dd120 100644
--- a/libc/arch-arm/syscalls/gettid.S
+++ b/libc/arch-arm/syscalls/gettid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(gettid)
     mov     ip, r7
     ldr     r7, =__NR_gettid
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(gettid)
diff --git a/libc/arch-arm/syscalls/gettimeofday.S b/libc/arch-arm/syscalls/gettimeofday.S
index 113413e..9f43b98 100644
--- a/libc/arch-arm/syscalls/gettimeofday.S
+++ b/libc/arch-arm/syscalls/gettimeofday.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(gettimeofday)
     mov     ip, r7
     ldr     r7, =__NR_gettimeofday
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(gettimeofday)
diff --git a/libc/arch-arm/syscalls/getuid.S b/libc/arch-arm/syscalls/getuid.S
index 20ed7f9..02fb6fc 100644
--- a/libc/arch-arm/syscalls/getuid.S
+++ b/libc/arch-arm/syscalls/getuid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getuid)
     mov     ip, r7
     ldr     r7, =__NR_getuid32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getuid)
diff --git a/libc/arch-arm/syscalls/getxattr.S b/libc/arch-arm/syscalls/getxattr.S
index 0a7cbef..354d948 100644
--- a/libc/arch-arm/syscalls/getxattr.S
+++ b/libc/arch-arm/syscalls/getxattr.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(getxattr)
     mov     ip, r7
     ldr     r7, =__NR_getxattr
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(getxattr)
diff --git a/libc/arch-arm/syscalls/init_module.S b/libc/arch-arm/syscalls/init_module.S
index de41a7e..c72c34c 100644
--- a/libc/arch-arm/syscalls/init_module.S
+++ b/libc/arch-arm/syscalls/init_module.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(init_module)
     mov     ip, r7
     ldr     r7, =__NR_init_module
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(init_module)
diff --git a/libc/arch-arm/syscalls/inotify_add_watch.S b/libc/arch-arm/syscalls/inotify_add_watch.S
index aa8fcb7..c994677 100644
--- a/libc/arch-arm/syscalls/inotify_add_watch.S
+++ b/libc/arch-arm/syscalls/inotify_add_watch.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(inotify_add_watch)
     mov     ip, r7
     ldr     r7, =__NR_inotify_add_watch
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(inotify_add_watch)
diff --git a/libc/arch-arm/syscalls/inotify_init.S b/libc/arch-arm/syscalls/inotify_init.S
index 56d4b93..3713303 100644
--- a/libc/arch-arm/syscalls/inotify_init.S
+++ b/libc/arch-arm/syscalls/inotify_init.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(inotify_init)
     mov     ip, r7
     ldr     r7, =__NR_inotify_init
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(inotify_init)
diff --git a/libc/arch-arm/syscalls/inotify_rm_watch.S b/libc/arch-arm/syscalls/inotify_rm_watch.S
index 4315061..d740de0 100644
--- a/libc/arch-arm/syscalls/inotify_rm_watch.S
+++ b/libc/arch-arm/syscalls/inotify_rm_watch.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(inotify_rm_watch)
     mov     ip, r7
     ldr     r7, =__NR_inotify_rm_watch
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(inotify_rm_watch)
diff --git a/libc/arch-arm/syscalls/ioprio_get.S b/libc/arch-arm/syscalls/ioprio_get.S
index d3bd796..bb1dd1a 100644
--- a/libc/arch-arm/syscalls/ioprio_get.S
+++ b/libc/arch-arm/syscalls/ioprio_get.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(ioprio_get)
     mov     ip, r7
     ldr     r7, =__NR_ioprio_get
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(ioprio_get)
diff --git a/libc/arch-arm/syscalls/ioprio_set.S b/libc/arch-arm/syscalls/ioprio_set.S
index c42d305..064a399 100644
--- a/libc/arch-arm/syscalls/ioprio_set.S
+++ b/libc/arch-arm/syscalls/ioprio_set.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(ioprio_set)
     mov     ip, r7
     ldr     r7, =__NR_ioprio_set
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(ioprio_set)
diff --git a/libc/arch-arm/syscalls/klogctl.S b/libc/arch-arm/syscalls/klogctl.S
index 1356815..f97cf1a 100644
--- a/libc/arch-arm/syscalls/klogctl.S
+++ b/libc/arch-arm/syscalls/klogctl.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(klogctl)
     mov     ip, r7
     ldr     r7, =__NR_syslog
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(klogctl)
diff --git a/libc/arch-arm/syscalls/lchown.S b/libc/arch-arm/syscalls/lchown.S
index 56902a3..e5738b5 100644
--- a/libc/arch-arm/syscalls/lchown.S
+++ b/libc/arch-arm/syscalls/lchown.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(lchown)
     mov     ip, r7
     ldr     r7, =__NR_lchown32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(lchown)
diff --git a/libc/arch-arm/syscalls/lgetxattr.S b/libc/arch-arm/syscalls/lgetxattr.S
index cc30d63..7af744e 100644
--- a/libc/arch-arm/syscalls/lgetxattr.S
+++ b/libc/arch-arm/syscalls/lgetxattr.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(lgetxattr)
     mov     ip, r7
     ldr     r7, =__NR_lgetxattr
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(lgetxattr)
diff --git a/libc/arch-arm/syscalls/link.S b/libc/arch-arm/syscalls/link.S
index dab8fa6..e074ed0 100644
--- a/libc/arch-arm/syscalls/link.S
+++ b/libc/arch-arm/syscalls/link.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(link)
     mov     ip, r7
     ldr     r7, =__NR_link
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(link)
diff --git a/libc/arch-arm/syscalls/listen.S b/libc/arch-arm/syscalls/listen.S
index fac3702..21f4271 100644
--- a/libc/arch-arm/syscalls/listen.S
+++ b/libc/arch-arm/syscalls/listen.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(listen)
     mov     ip, r7
     ldr     r7, =__NR_listen
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(listen)
diff --git a/libc/arch-arm/syscalls/listxattr.S b/libc/arch-arm/syscalls/listxattr.S
index 8c7fc9b..9094a6c 100644
--- a/libc/arch-arm/syscalls/listxattr.S
+++ b/libc/arch-arm/syscalls/listxattr.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(listxattr)
     mov     ip, r7
     ldr     r7, =__NR_listxattr
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(listxattr)
diff --git a/libc/arch-arm/syscalls/llistxattr.S b/libc/arch-arm/syscalls/llistxattr.S
index 9cade18..72d790f 100644
--- a/libc/arch-arm/syscalls/llistxattr.S
+++ b/libc/arch-arm/syscalls/llistxattr.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(llistxattr)
     mov     ip, r7
     ldr     r7, =__NR_llistxattr
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(llistxattr)
diff --git a/libc/arch-arm/syscalls/lremovexattr.S b/libc/arch-arm/syscalls/lremovexattr.S
index d4a7b82..729c4fa 100644
--- a/libc/arch-arm/syscalls/lremovexattr.S
+++ b/libc/arch-arm/syscalls/lremovexattr.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(lremovexattr)
     mov     ip, r7
     ldr     r7, =__NR_lremovexattr
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(lremovexattr)
diff --git a/libc/arch-arm/syscalls/lseek.S b/libc/arch-arm/syscalls/lseek.S
index a452856..91f8029 100644
--- a/libc/arch-arm/syscalls/lseek.S
+++ b/libc/arch-arm/syscalls/lseek.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(lseek)
     mov     ip, r7
     ldr     r7, =__NR_lseek
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(lseek)
diff --git a/libc/arch-arm/syscalls/lsetxattr.S b/libc/arch-arm/syscalls/lsetxattr.S
index bde7c24..c0177ee 100644
--- a/libc/arch-arm/syscalls/lsetxattr.S
+++ b/libc/arch-arm/syscalls/lsetxattr.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(lsetxattr)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_lsetxattr
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(lsetxattr)
diff --git a/libc/arch-arm/syscalls/lstat.S b/libc/arch-arm/syscalls/lstat.S
index 69f2146..be9ebaa 100644
--- a/libc/arch-arm/syscalls/lstat.S
+++ b/libc/arch-arm/syscalls/lstat.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(lstat)
     mov     ip, r7
     ldr     r7, =__NR_lstat64
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(lstat)
diff --git a/libc/arch-arm/syscalls/madvise.S b/libc/arch-arm/syscalls/madvise.S
index 02944a2..d7f7776 100644
--- a/libc/arch-arm/syscalls/madvise.S
+++ b/libc/arch-arm/syscalls/madvise.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(madvise)
     mov     ip, r7
     ldr     r7, =__NR_madvise
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(madvise)
diff --git a/libc/arch-arm/syscalls/mincore.S b/libc/arch-arm/syscalls/mincore.S
index 5ffdc11..744b1e4 100644
--- a/libc/arch-arm/syscalls/mincore.S
+++ b/libc/arch-arm/syscalls/mincore.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(mincore)
     mov     ip, r7
     ldr     r7, =__NR_mincore
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(mincore)
diff --git a/libc/arch-arm/syscalls/mkdir.S b/libc/arch-arm/syscalls/mkdir.S
index c2aa080..4163318 100644
--- a/libc/arch-arm/syscalls/mkdir.S
+++ b/libc/arch-arm/syscalls/mkdir.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(mkdir)
     mov     ip, r7
     ldr     r7, =__NR_mkdir
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(mkdir)
diff --git a/libc/arch-arm/syscalls/mkdirat.S b/libc/arch-arm/syscalls/mkdirat.S
index 421c70a..da583ca 100644
--- a/libc/arch-arm/syscalls/mkdirat.S
+++ b/libc/arch-arm/syscalls/mkdirat.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(mkdirat)
     mov     ip, r7
     ldr     r7, =__NR_mkdirat
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(mkdirat)
diff --git a/libc/arch-arm/syscalls/mknod.S b/libc/arch-arm/syscalls/mknod.S
index 4aca2c5..15716d3 100644
--- a/libc/arch-arm/syscalls/mknod.S
+++ b/libc/arch-arm/syscalls/mknod.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(mknod)
     mov     ip, r7
     ldr     r7, =__NR_mknod
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(mknod)
diff --git a/libc/arch-arm/syscalls/mlock.S b/libc/arch-arm/syscalls/mlock.S
index 5c8e74d..d00ea01 100644
--- a/libc/arch-arm/syscalls/mlock.S
+++ b/libc/arch-arm/syscalls/mlock.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(mlock)
     mov     ip, r7
     ldr     r7, =__NR_mlock
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(mlock)
diff --git a/libc/arch-arm/syscalls/mlockall.S b/libc/arch-arm/syscalls/mlockall.S
index a89545a..44940f1 100644
--- a/libc/arch-arm/syscalls/mlockall.S
+++ b/libc/arch-arm/syscalls/mlockall.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(mlockall)
     mov     ip, r7
     ldr     r7, =__NR_mlockall
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(mlockall)
diff --git a/libc/arch-arm/syscalls/mount.S b/libc/arch-arm/syscalls/mount.S
index eb1624c..b2ef6f8 100644
--- a/libc/arch-arm/syscalls/mount.S
+++ b/libc/arch-arm/syscalls/mount.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(mount)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_mount
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(mount)
diff --git a/libc/arch-arm/syscalls/mprotect.S b/libc/arch-arm/syscalls/mprotect.S
index 06238bf..e5258fd 100644
--- a/libc/arch-arm/syscalls/mprotect.S
+++ b/libc/arch-arm/syscalls/mprotect.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(mprotect)
     mov     ip, r7
     ldr     r7, =__NR_mprotect
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(mprotect)
diff --git a/libc/arch-arm/syscalls/mremap.S b/libc/arch-arm/syscalls/mremap.S
index 29b308b..04ba2bc 100644
--- a/libc/arch-arm/syscalls/mremap.S
+++ b/libc/arch-arm/syscalls/mremap.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(mremap)
     mov     ip, r7
     ldr     r7, =__NR_mremap
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(mremap)
diff --git a/libc/arch-arm/syscalls/msync.S b/libc/arch-arm/syscalls/msync.S
index af8fc0c..bcd892d 100644
--- a/libc/arch-arm/syscalls/msync.S
+++ b/libc/arch-arm/syscalls/msync.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(msync)
     mov     ip, r7
     ldr     r7, =__NR_msync
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(msync)
diff --git a/libc/arch-arm/syscalls/munlock.S b/libc/arch-arm/syscalls/munlock.S
index 42df37e..deed697 100644
--- a/libc/arch-arm/syscalls/munlock.S
+++ b/libc/arch-arm/syscalls/munlock.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(munlock)
     mov     ip, r7
     ldr     r7, =__NR_munlock
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(munlock)
diff --git a/libc/arch-arm/syscalls/munlockall.S b/libc/arch-arm/syscalls/munlockall.S
index c0fca33..18881f4 100644
--- a/libc/arch-arm/syscalls/munlockall.S
+++ b/libc/arch-arm/syscalls/munlockall.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(munlockall)
     mov     ip, r7
     ldr     r7, =__NR_munlockall
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(munlockall)
diff --git a/libc/arch-arm/syscalls/munmap.S b/libc/arch-arm/syscalls/munmap.S
index 9d7b60f..3f52da4 100644
--- a/libc/arch-arm/syscalls/munmap.S
+++ b/libc/arch-arm/syscalls/munmap.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(munmap)
     mov     ip, r7
     ldr     r7, =__NR_munmap
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(munmap)
diff --git a/libc/arch-arm/syscalls/nanosleep.S b/libc/arch-arm/syscalls/nanosleep.S
index 7f4cda6..de826ea 100644
--- a/libc/arch-arm/syscalls/nanosleep.S
+++ b/libc/arch-arm/syscalls/nanosleep.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(nanosleep)
     mov     ip, r7
     ldr     r7, =__NR_nanosleep
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(nanosleep)
diff --git a/libc/arch-arm/syscalls/pause.S b/libc/arch-arm/syscalls/pause.S
index 1238f4b..de54834 100644
--- a/libc/arch-arm/syscalls/pause.S
+++ b/libc/arch-arm/syscalls/pause.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(pause)
     mov     ip, r7
     ldr     r7, =__NR_pause
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(pause)
diff --git a/libc/arch-arm/syscalls/perf_event_open.S b/libc/arch-arm/syscalls/perf_event_open.S
index 39710a5..7b997e6 100644
--- a/libc/arch-arm/syscalls/perf_event_open.S
+++ b/libc/arch-arm/syscalls/perf_event_open.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(perf_event_open)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_perf_event_open
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(perf_event_open)
diff --git a/libc/arch-arm/syscalls/personality.S b/libc/arch-arm/syscalls/personality.S
index f338d71..e4e8e40 100644
--- a/libc/arch-arm/syscalls/personality.S
+++ b/libc/arch-arm/syscalls/personality.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(personality)
     mov     ip, r7
     ldr     r7, =__NR_personality
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(personality)
diff --git a/libc/arch-arm/syscalls/pipe.S b/libc/arch-arm/syscalls/pipe.S
index ec0efb1..62cc9c7 100644
--- a/libc/arch-arm/syscalls/pipe.S
+++ b/libc/arch-arm/syscalls/pipe.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(pipe)
     mov     ip, r7
     ldr     r7, =__NR_pipe
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(pipe)
diff --git a/libc/arch-arm/syscalls/pipe2.S b/libc/arch-arm/syscalls/pipe2.S
index f79c8f5..bb72289 100644
--- a/libc/arch-arm/syscalls/pipe2.S
+++ b/libc/arch-arm/syscalls/pipe2.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(pipe2)
     mov     ip, r7
     ldr     r7, =__NR_pipe2
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(pipe2)
diff --git a/libc/arch-arm/syscalls/poll.S b/libc/arch-arm/syscalls/poll.S
index d9831ab..71d4c81 100644
--- a/libc/arch-arm/syscalls/poll.S
+++ b/libc/arch-arm/syscalls/poll.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(poll)
     mov     ip, r7
     ldr     r7, =__NR_poll
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(poll)
diff --git a/libc/arch-arm/syscalls/prctl.S b/libc/arch-arm/syscalls/prctl.S
index 009dc54..ae32ba5 100644
--- a/libc/arch-arm/syscalls/prctl.S
+++ b/libc/arch-arm/syscalls/prctl.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(prctl)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_prctl
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(prctl)
diff --git a/libc/arch-arm/syscalls/pread64.S b/libc/arch-arm/syscalls/pread64.S
index 0090fd3..9626695 100644
--- a/libc/arch-arm/syscalls/pread64.S
+++ b/libc/arch-arm/syscalls/pread64.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(pread64)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_pread64
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(pread64)
diff --git a/libc/arch-arm/syscalls/pwrite64.S b/libc/arch-arm/syscalls/pwrite64.S
index 444d78f..e7dc09c 100644
--- a/libc/arch-arm/syscalls/pwrite64.S
+++ b/libc/arch-arm/syscalls/pwrite64.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(pwrite64)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_pwrite64
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(pwrite64)
diff --git a/libc/arch-arm/syscalls/read.S b/libc/arch-arm/syscalls/read.S
index ab0583a..2b12305 100644
--- a/libc/arch-arm/syscalls/read.S
+++ b/libc/arch-arm/syscalls/read.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(read)
     mov     ip, r7
     ldr     r7, =__NR_read
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(read)
diff --git a/libc/arch-arm/syscalls/readahead.S b/libc/arch-arm/syscalls/readahead.S
index 6aa8265..7ed2dda 100644
--- a/libc/arch-arm/syscalls/readahead.S
+++ b/libc/arch-arm/syscalls/readahead.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(readahead)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_readahead
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(readahead)
diff --git a/libc/arch-arm/syscalls/readlink.S b/libc/arch-arm/syscalls/readlink.S
index 90b0ea6..1085db6 100644
--- a/libc/arch-arm/syscalls/readlink.S
+++ b/libc/arch-arm/syscalls/readlink.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(readlink)
     mov     ip, r7
     ldr     r7, =__NR_readlink
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(readlink)
diff --git a/libc/arch-arm/syscalls/readv.S b/libc/arch-arm/syscalls/readv.S
index 9f8b8db..7857c43 100644
--- a/libc/arch-arm/syscalls/readv.S
+++ b/libc/arch-arm/syscalls/readv.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(readv)
     mov     ip, r7
     ldr     r7, =__NR_readv
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(readv)
diff --git a/libc/arch-arm/syscalls/recvfrom.S b/libc/arch-arm/syscalls/recvfrom.S
index df6302f..c105a4a 100644
--- a/libc/arch-arm/syscalls/recvfrom.S
+++ b/libc/arch-arm/syscalls/recvfrom.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(recvfrom)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_recvfrom
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(recvfrom)
diff --git a/libc/arch-arm/syscalls/recvmsg.S b/libc/arch-arm/syscalls/recvmsg.S
index 00746a1..f8ad706 100644
--- a/libc/arch-arm/syscalls/recvmsg.S
+++ b/libc/arch-arm/syscalls/recvmsg.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(recvmsg)
     mov     ip, r7
     ldr     r7, =__NR_recvmsg
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(recvmsg)
diff --git a/libc/arch-arm/syscalls/removexattr.S b/libc/arch-arm/syscalls/removexattr.S
index 82fb9e0..2da9be8 100644
--- a/libc/arch-arm/syscalls/removexattr.S
+++ b/libc/arch-arm/syscalls/removexattr.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(removexattr)
     mov     ip, r7
     ldr     r7, =__NR_removexattr
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(removexattr)
diff --git a/libc/arch-arm/syscalls/rename.S b/libc/arch-arm/syscalls/rename.S
index dfe0b0e..654623c 100644
--- a/libc/arch-arm/syscalls/rename.S
+++ b/libc/arch-arm/syscalls/rename.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(rename)
     mov     ip, r7
     ldr     r7, =__NR_rename
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(rename)
diff --git a/libc/arch-arm/syscalls/renameat.S b/libc/arch-arm/syscalls/renameat.S
index aa42b78..9ec5937 100644
--- a/libc/arch-arm/syscalls/renameat.S
+++ b/libc/arch-arm/syscalls/renameat.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(renameat)
     mov     ip, r7
     ldr     r7, =__NR_renameat
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(renameat)
diff --git a/libc/arch-arm/syscalls/rmdir.S b/libc/arch-arm/syscalls/rmdir.S
index c2d5c5a..89985ec 100644
--- a/libc/arch-arm/syscalls/rmdir.S
+++ b/libc/arch-arm/syscalls/rmdir.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(rmdir)
     mov     ip, r7
     ldr     r7, =__NR_rmdir
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(rmdir)
diff --git a/libc/arch-arm/syscalls/sched_get_priority_max.S b/libc/arch-arm/syscalls/sched_get_priority_max.S
index 703ddeb..d90afe7 100644
--- a/libc/arch-arm/syscalls/sched_get_priority_max.S
+++ b/libc/arch-arm/syscalls/sched_get_priority_max.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sched_get_priority_max)
     mov     ip, r7
     ldr     r7, =__NR_sched_get_priority_max
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sched_get_priority_max)
diff --git a/libc/arch-arm/syscalls/sched_get_priority_min.S b/libc/arch-arm/syscalls/sched_get_priority_min.S
index deea8ae..4fbddfe 100644
--- a/libc/arch-arm/syscalls/sched_get_priority_min.S
+++ b/libc/arch-arm/syscalls/sched_get_priority_min.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sched_get_priority_min)
     mov     ip, r7
     ldr     r7, =__NR_sched_get_priority_min
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sched_get_priority_min)
diff --git a/libc/arch-arm/syscalls/sched_getparam.S b/libc/arch-arm/syscalls/sched_getparam.S
index 194d4a2..1d9406a 100644
--- a/libc/arch-arm/syscalls/sched_getparam.S
+++ b/libc/arch-arm/syscalls/sched_getparam.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sched_getparam)
     mov     ip, r7
     ldr     r7, =__NR_sched_getparam
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sched_getparam)
diff --git a/libc/arch-arm/syscalls/sched_getscheduler.S b/libc/arch-arm/syscalls/sched_getscheduler.S
index fd3cec5..f34fb98 100644
--- a/libc/arch-arm/syscalls/sched_getscheduler.S
+++ b/libc/arch-arm/syscalls/sched_getscheduler.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sched_getscheduler)
     mov     ip, r7
     ldr     r7, =__NR_sched_getscheduler
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sched_getscheduler)
diff --git a/libc/arch-arm/syscalls/sched_rr_get_interval.S b/libc/arch-arm/syscalls/sched_rr_get_interval.S
index 21a5788..cbd6288 100644
--- a/libc/arch-arm/syscalls/sched_rr_get_interval.S
+++ b/libc/arch-arm/syscalls/sched_rr_get_interval.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sched_rr_get_interval)
     mov     ip, r7
     ldr     r7, =__NR_sched_rr_get_interval
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sched_rr_get_interval)
diff --git a/libc/arch-arm/syscalls/sched_setaffinity.S b/libc/arch-arm/syscalls/sched_setaffinity.S
index c980ed0..2a718ea 100644
--- a/libc/arch-arm/syscalls/sched_setaffinity.S
+++ b/libc/arch-arm/syscalls/sched_setaffinity.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sched_setaffinity)
     mov     ip, r7
     ldr     r7, =__NR_sched_setaffinity
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sched_setaffinity)
diff --git a/libc/arch-arm/syscalls/sched_setparam.S b/libc/arch-arm/syscalls/sched_setparam.S
index 993078d..e5b3fe6 100644
--- a/libc/arch-arm/syscalls/sched_setparam.S
+++ b/libc/arch-arm/syscalls/sched_setparam.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sched_setparam)
     mov     ip, r7
     ldr     r7, =__NR_sched_setparam
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sched_setparam)
diff --git a/libc/arch-arm/syscalls/sched_setscheduler.S b/libc/arch-arm/syscalls/sched_setscheduler.S
index d0ac1de..287c08d 100644
--- a/libc/arch-arm/syscalls/sched_setscheduler.S
+++ b/libc/arch-arm/syscalls/sched_setscheduler.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sched_setscheduler)
     mov     ip, r7
     ldr     r7, =__NR_sched_setscheduler
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sched_setscheduler)
diff --git a/libc/arch-arm/syscalls/sched_yield.S b/libc/arch-arm/syscalls/sched_yield.S
index 00bdfbd..7652ff1 100644
--- a/libc/arch-arm/syscalls/sched_yield.S
+++ b/libc/arch-arm/syscalls/sched_yield.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sched_yield)
     mov     ip, r7
     ldr     r7, =__NR_sched_yield
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sched_yield)
diff --git a/libc/arch-arm/syscalls/select.S b/libc/arch-arm/syscalls/select.S
index edd77a3..09fb52b 100644
--- a/libc/arch-arm/syscalls/select.S
+++ b/libc/arch-arm/syscalls/select.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(select)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR__newselect
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(select)
diff --git a/libc/arch-arm/syscalls/sendfile.S b/libc/arch-arm/syscalls/sendfile.S
index 9e4c70c..fb4b38c 100644
--- a/libc/arch-arm/syscalls/sendfile.S
+++ b/libc/arch-arm/syscalls/sendfile.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sendfile)
     mov     ip, r7
     ldr     r7, =__NR_sendfile
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sendfile)
diff --git a/libc/arch-arm/syscalls/sendmsg.S b/libc/arch-arm/syscalls/sendmsg.S
index 1b54aee..21c0223 100644
--- a/libc/arch-arm/syscalls/sendmsg.S
+++ b/libc/arch-arm/syscalls/sendmsg.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sendmsg)
     mov     ip, r7
     ldr     r7, =__NR_sendmsg
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sendmsg)
diff --git a/libc/arch-arm/syscalls/sendto.S b/libc/arch-arm/syscalls/sendto.S
index 302ba8a..7f64293 100644
--- a/libc/arch-arm/syscalls/sendto.S
+++ b/libc/arch-arm/syscalls/sendto.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sendto)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_sendto
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sendto)
diff --git a/libc/arch-arm/syscalls/setgid.S b/libc/arch-arm/syscalls/setgid.S
index 09045ad..0084688 100644
--- a/libc/arch-arm/syscalls/setgid.S
+++ b/libc/arch-arm/syscalls/setgid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(setgid)
     mov     ip, r7
     ldr     r7, =__NR_setgid32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(setgid)
diff --git a/libc/arch-arm/syscalls/setgroups.S b/libc/arch-arm/syscalls/setgroups.S
index e4c36b5..3c1d94f 100644
--- a/libc/arch-arm/syscalls/setgroups.S
+++ b/libc/arch-arm/syscalls/setgroups.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(setgroups)
     mov     ip, r7
     ldr     r7, =__NR_setgroups32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(setgroups)
diff --git a/libc/arch-arm/syscalls/setitimer.S b/libc/arch-arm/syscalls/setitimer.S
index dfb7a46..9038878 100644
--- a/libc/arch-arm/syscalls/setitimer.S
+++ b/libc/arch-arm/syscalls/setitimer.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(setitimer)
     mov     ip, r7
     ldr     r7, =__NR_setitimer
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(setitimer)
diff --git a/libc/arch-arm/syscalls/setpgid.S b/libc/arch-arm/syscalls/setpgid.S
index c558063..bf639a2 100644
--- a/libc/arch-arm/syscalls/setpgid.S
+++ b/libc/arch-arm/syscalls/setpgid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(setpgid)
     mov     ip, r7
     ldr     r7, =__NR_setpgid
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(setpgid)
diff --git a/libc/arch-arm/syscalls/setpriority.S b/libc/arch-arm/syscalls/setpriority.S
index 683da34..b16158b 100644
--- a/libc/arch-arm/syscalls/setpriority.S
+++ b/libc/arch-arm/syscalls/setpriority.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(setpriority)
     mov     ip, r7
     ldr     r7, =__NR_setpriority
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(setpriority)
diff --git a/libc/arch-arm/syscalls/setregid.S b/libc/arch-arm/syscalls/setregid.S
index 2062d05..efc20a5 100644
--- a/libc/arch-arm/syscalls/setregid.S
+++ b/libc/arch-arm/syscalls/setregid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(setregid)
     mov     ip, r7
     ldr     r7, =__NR_setregid32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(setregid)
diff --git a/libc/arch-arm/syscalls/setresgid.S b/libc/arch-arm/syscalls/setresgid.S
index 089c7a7..55c804d 100644
--- a/libc/arch-arm/syscalls/setresgid.S
+++ b/libc/arch-arm/syscalls/setresgid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(setresgid)
     mov     ip, r7
     ldr     r7, =__NR_setresgid32
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(setresgid)
diff --git a/libc/arch-arm/syscalls/setrlimit.S b/libc/arch-arm/syscalls/setrlimit.S
index 02b8db4..23974f7 100644
--- a/libc/arch-arm/syscalls/setrlimit.S
+++ b/libc/arch-arm/syscalls/setrlimit.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(setrlimit)
     mov     ip, r7
     ldr     r7, =__NR_setrlimit
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(setrlimit)
diff --git a/libc/arch-arm/syscalls/setsid.S b/libc/arch-arm/syscalls/setsid.S
index d82c347..5cd27c2 100644
--- a/libc/arch-arm/syscalls/setsid.S
+++ b/libc/arch-arm/syscalls/setsid.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(setsid)
     mov     ip, r7
     ldr     r7, =__NR_setsid
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(setsid)
diff --git a/libc/arch-arm/syscalls/setsockopt.S b/libc/arch-arm/syscalls/setsockopt.S
index 7ca91dd..2d185d9 100644
--- a/libc/arch-arm/syscalls/setsockopt.S
+++ b/libc/arch-arm/syscalls/setsockopt.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(setsockopt)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_setsockopt
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(setsockopt)
diff --git a/libc/arch-arm/syscalls/settimeofday.S b/libc/arch-arm/syscalls/settimeofday.S
index 44f5e66..f71f139 100644
--- a/libc/arch-arm/syscalls/settimeofday.S
+++ b/libc/arch-arm/syscalls/settimeofday.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(settimeofday)
     mov     ip, r7
     ldr     r7, =__NR_settimeofday
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(settimeofday)
diff --git a/libc/arch-arm/syscalls/setxattr.S b/libc/arch-arm/syscalls/setxattr.S
index e86fe9f..702be89 100644
--- a/libc/arch-arm/syscalls/setxattr.S
+++ b/libc/arch-arm/syscalls/setxattr.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(setxattr)
     mov     ip, sp
@@ -10,7 +11,8 @@
     ldr     r7, =__NR_setxattr
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(setxattr)
diff --git a/libc/arch-arm/syscalls/shutdown.S b/libc/arch-arm/syscalls/shutdown.S
index cc96f56..2f521dc 100644
--- a/libc/arch-arm/syscalls/shutdown.S
+++ b/libc/arch-arm/syscalls/shutdown.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(shutdown)
     mov     ip, r7
     ldr     r7, =__NR_shutdown
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(shutdown)
diff --git a/libc/arch-arm/syscalls/sigaction.S b/libc/arch-arm/syscalls/sigaction.S
index 699f55d..375ec04 100644
--- a/libc/arch-arm/syscalls/sigaction.S
+++ b/libc/arch-arm/syscalls/sigaction.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sigaction)
     mov     ip, r7
     ldr     r7, =__NR_sigaction
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sigaction)
diff --git a/libc/arch-arm/syscalls/sigaltstack.S b/libc/arch-arm/syscalls/sigaltstack.S
index 0f34eab..ca68004 100644
--- a/libc/arch-arm/syscalls/sigaltstack.S
+++ b/libc/arch-arm/syscalls/sigaltstack.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sigaltstack)
     mov     ip, r7
     ldr     r7, =__NR_sigaltstack
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sigaltstack)
diff --git a/libc/arch-arm/syscalls/signalfd4.S b/libc/arch-arm/syscalls/signalfd4.S
index 6f07fbe..a3dce34 100644
--- a/libc/arch-arm/syscalls/signalfd4.S
+++ b/libc/arch-arm/syscalls/signalfd4.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(signalfd4)
     mov     ip, r7
     ldr     r7, =__NR_signalfd4
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(signalfd4)
diff --git a/libc/arch-arm/syscalls/sigpending.S b/libc/arch-arm/syscalls/sigpending.S
index b541288..ba667a0 100644
--- a/libc/arch-arm/syscalls/sigpending.S
+++ b/libc/arch-arm/syscalls/sigpending.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sigpending)
     mov     ip, r7
     ldr     r7, =__NR_sigpending
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sigpending)
diff --git a/libc/arch-arm/syscalls/sigprocmask.S b/libc/arch-arm/syscalls/sigprocmask.S
index d169474..f935340 100644
--- a/libc/arch-arm/syscalls/sigprocmask.S
+++ b/libc/arch-arm/syscalls/sigprocmask.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sigprocmask)
     mov     ip, r7
     ldr     r7, =__NR_sigprocmask
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sigprocmask)
diff --git a/libc/arch-arm/syscalls/socket.S b/libc/arch-arm/syscalls/socket.S
index 1003bd4..3caae09 100644
--- a/libc/arch-arm/syscalls/socket.S
+++ b/libc/arch-arm/syscalls/socket.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(socket)
     mov     ip, r7
     ldr     r7, =__NR_socket
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(socket)
diff --git a/libc/arch-arm/syscalls/socketpair.S b/libc/arch-arm/syscalls/socketpair.S
index 65bef68..0e4db77 100644
--- a/libc/arch-arm/syscalls/socketpair.S
+++ b/libc/arch-arm/syscalls/socketpair.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(socketpair)
     mov     ip, r7
     ldr     r7, =__NR_socketpair
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(socketpair)
diff --git a/libc/arch-arm/syscalls/stat.S b/libc/arch-arm/syscalls/stat.S
index 17b63cc..c5c310c 100644
--- a/libc/arch-arm/syscalls/stat.S
+++ b/libc/arch-arm/syscalls/stat.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(stat)
     mov     ip, r7
     ldr     r7, =__NR_stat64
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(stat)
diff --git a/libc/arch-arm/syscalls/symlink.S b/libc/arch-arm/syscalls/symlink.S
index ac569af..406d7b2 100644
--- a/libc/arch-arm/syscalls/symlink.S
+++ b/libc/arch-arm/syscalls/symlink.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(symlink)
     mov     ip, r7
     ldr     r7, =__NR_symlink
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(symlink)
diff --git a/libc/arch-arm/syscalls/sync.S b/libc/arch-arm/syscalls/sync.S
index ef6cb16..3efe263 100644
--- a/libc/arch-arm/syscalls/sync.S
+++ b/libc/arch-arm/syscalls/sync.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sync)
     mov     ip, r7
     ldr     r7, =__NR_sync
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sync)
diff --git a/libc/arch-arm/syscalls/sysinfo.S b/libc/arch-arm/syscalls/sysinfo.S
index a891735..056c03e 100644
--- a/libc/arch-arm/syscalls/sysinfo.S
+++ b/libc/arch-arm/syscalls/sysinfo.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(sysinfo)
     mov     ip, r7
     ldr     r7, =__NR_sysinfo
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(sysinfo)
diff --git a/libc/arch-arm/syscalls/times.S b/libc/arch-arm/syscalls/times.S
index 051f34d..b60f7d2 100644
--- a/libc/arch-arm/syscalls/times.S
+++ b/libc/arch-arm/syscalls/times.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(times)
     mov     ip, r7
     ldr     r7, =__NR_times
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(times)
diff --git a/libc/arch-arm/syscalls/truncate.S b/libc/arch-arm/syscalls/truncate.S
index 3bb68cd..697700c 100644
--- a/libc/arch-arm/syscalls/truncate.S
+++ b/libc/arch-arm/syscalls/truncate.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(truncate)
     mov     ip, r7
     ldr     r7, =__NR_truncate
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(truncate)
diff --git a/libc/arch-arm/syscalls/umask.S b/libc/arch-arm/syscalls/umask.S
index 78e43e0..df7544d 100644
--- a/libc/arch-arm/syscalls/umask.S
+++ b/libc/arch-arm/syscalls/umask.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(umask)
     mov     ip, r7
     ldr     r7, =__NR_umask
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(umask)
diff --git a/libc/arch-arm/syscalls/umount2.S b/libc/arch-arm/syscalls/umount2.S
index 605359e..60bf7b2 100644
--- a/libc/arch-arm/syscalls/umount2.S
+++ b/libc/arch-arm/syscalls/umount2.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(umount2)
     mov     ip, r7
     ldr     r7, =__NR_umount2
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(umount2)
diff --git a/libc/arch-arm/syscalls/uname.S b/libc/arch-arm/syscalls/uname.S
index db0860b..5182c3f 100644
--- a/libc/arch-arm/syscalls/uname.S
+++ b/libc/arch-arm/syscalls/uname.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(uname)
     mov     ip, r7
     ldr     r7, =__NR_uname
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(uname)
diff --git a/libc/arch-arm/syscalls/unlink.S b/libc/arch-arm/syscalls/unlink.S
index 8ef33df..1a74ee4 100644
--- a/libc/arch-arm/syscalls/unlink.S
+++ b/libc/arch-arm/syscalls/unlink.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(unlink)
     mov     ip, r7
     ldr     r7, =__NR_unlink
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(unlink)
diff --git a/libc/arch-arm/syscalls/unlinkat.S b/libc/arch-arm/syscalls/unlinkat.S
index eb822e4..66d734d 100644
--- a/libc/arch-arm/syscalls/unlinkat.S
+++ b/libc/arch-arm/syscalls/unlinkat.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(unlinkat)
     mov     ip, r7
     ldr     r7, =__NR_unlinkat
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(unlinkat)
diff --git a/libc/arch-arm/syscalls/unshare.S b/libc/arch-arm/syscalls/unshare.S
index ec77f3a..e5515c7 100644
--- a/libc/arch-arm/syscalls/unshare.S
+++ b/libc/arch-arm/syscalls/unshare.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(unshare)
     mov     ip, r7
     ldr     r7, =__NR_unshare
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(unshare)
diff --git a/libc/arch-arm/syscalls/utimensat.S b/libc/arch-arm/syscalls/utimensat.S
index 976a667..a13feac 100644
--- a/libc/arch-arm/syscalls/utimensat.S
+++ b/libc/arch-arm/syscalls/utimensat.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(utimensat)
     mov     ip, r7
     ldr     r7, =__NR_utimensat
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(utimensat)
diff --git a/libc/arch-arm/syscalls/utimes.S b/libc/arch-arm/syscalls/utimes.S
index 8966626..65acb25 100644
--- a/libc/arch-arm/syscalls/utimes.S
+++ b/libc/arch-arm/syscalls/utimes.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(utimes)
     mov     ip, r7
     ldr     r7, =__NR_utimes
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(utimes)
diff --git a/libc/arch-arm/syscalls/vfork.S b/libc/arch-arm/syscalls/vfork.S
index 89cbda2..e8a1022 100644
--- a/libc/arch-arm/syscalls/vfork.S
+++ b/libc/arch-arm/syscalls/vfork.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(vfork)
     mov     ip, r7
     ldr     r7, =__NR_vfork
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(vfork)
diff --git a/libc/arch-arm/syscalls/wait4.S b/libc/arch-arm/syscalls/wait4.S
new file mode 100644
index 0000000..f895acf
--- /dev/null
+++ b/libc/arch-arm/syscalls/wait4.S
@@ -0,0 +1,15 @@
+/* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
+#include <machine/asm.h>
+
+ENTRY(wait4)
+    mov     ip, r7
+    ldr     r7, =__NR_wait4
+    swi     #0
+    mov     r7, ip
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
+END(wait4)
diff --git a/libc/arch-arm/syscalls/write.S b/libc/arch-arm/syscalls/write.S
index c257915..1302feb 100644
--- a/libc/arch-arm/syscalls/write.S
+++ b/libc/arch-arm/syscalls/write.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(write)
     mov     ip, r7
     ldr     r7, =__NR_write
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(write)
diff --git a/libc/arch-arm/syscalls/writev.S b/libc/arch-arm/syscalls/writev.S
index 521e10c..bcf3521 100644
--- a/libc/arch-arm/syscalls/writev.S
+++ b/libc/arch-arm/syscalls/writev.S
@@ -1,13 +1,15 @@
 /* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(writev)
     mov     ip, r7
     ldr     r7, =__NR_writev
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(writev)
diff --git a/libc/arch-mips/bionic/cacheflush.c b/libc/arch-mips/bionic/cacheflush.c
index 1911687..97e67d4 100644
--- a/libc/arch-mips/bionic/cacheflush.c
+++ b/libc/arch-mips/bionic/cacheflush.c
@@ -29,8 +29,7 @@
 #include <sys/cachectl.h>
 
 #ifdef DEBUG
-#include <private/logd.h>
-#include <private/debug_format.h>
+#include <private/libc_logging.h>
 #define  XLOG(...) __libc_format_log(ANDROID_LOG_DEBUG,"libc-cacheflush",__VA_ARGS__)
 #endif
 
diff --git a/libc/arch-mips/bionic/clone.S b/libc/arch-mips/bionic/clone.S
index 007e909..94e18a2 100644
--- a/libc/arch-mips/bionic/clone.S
+++ b/libc/arch-mips/bionic/clone.S
@@ -25,9 +25,10 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#include <linux/sched.h>
-#include <sys/linux-syscalls.h>
+
+#include <asm/unistd.h>
 #include <linux/errno.h>
+#include <linux/sched.h>
 
 	.text
 	.type __pthread_clone, @function
diff --git a/libc/arch-mips/syscalls.mk b/libc/arch-mips/syscalls.mk
index 7e40c2e..0b8eccd 100644
--- a/libc/arch-mips/syscalls.mk
+++ b/libc/arch-mips/syscalls.mk
@@ -5,6 +5,7 @@
 syscall_src += arch-mips/syscalls/__fork.S
 syscall_src += arch-mips/syscalls/_waitpid.S
 syscall_src += arch-mips/syscalls/__waitid.S
+syscall_src += arch-mips/syscalls/wait4.S
 syscall_src += arch-mips/syscalls/__sys_clone.S
 syscall_src += arch-mips/syscalls/execve.S
 syscall_src += arch-mips/syscalls/__setuid.S
@@ -183,7 +184,6 @@
 syscall_src += arch-mips/syscalls/ioprio_set.S
 syscall_src += arch-mips/syscalls/ioprio_get.S
 syscall_src += arch-mips/syscalls/uname.S
-syscall_src += arch-mips/syscalls/__wait4.S
 syscall_src += arch-mips/syscalls/umask.S
 syscall_src += arch-mips/syscalls/__reboot.S
 syscall_src += arch-mips/syscalls/__syslog.S
diff --git a/libc/arch-mips/syscalls/__brk.S b/libc/arch-mips/syscalls/__brk.S
index 1f09772..9797b9d 100644
--- a/libc/arch-mips/syscalls/__brk.S
+++ b/libc/arch-mips/syscalls/__brk.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __brk
     .align 4
diff --git a/libc/arch-mips/syscalls/__fcntl.S b/libc/arch-mips/syscalls/__fcntl.S
index 6dd76e3..b6a0fda 100644
--- a/libc/arch-mips/syscalls/__fcntl.S
+++ b/libc/arch-mips/syscalls/__fcntl.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __fcntl
     .align 4
diff --git a/libc/arch-mips/syscalls/__fcntl64.S b/libc/arch-mips/syscalls/__fcntl64.S
index e82e382..d2725e3 100644
--- a/libc/arch-mips/syscalls/__fcntl64.S
+++ b/libc/arch-mips/syscalls/__fcntl64.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __fcntl64
     .align 4
diff --git a/libc/arch-mips/syscalls/__fork.S b/libc/arch-mips/syscalls/__fork.S
index db30472..e8d1dea 100644
--- a/libc/arch-mips/syscalls/__fork.S
+++ b/libc/arch-mips/syscalls/__fork.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __fork
     .align 4
diff --git a/libc/arch-mips/syscalls/__fstatfs64.S b/libc/arch-mips/syscalls/__fstatfs64.S
index 6485d10..0e9bce4 100644
--- a/libc/arch-mips/syscalls/__fstatfs64.S
+++ b/libc/arch-mips/syscalls/__fstatfs64.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __fstatfs64
     .align 4
diff --git a/libc/arch-mips/syscalls/__getcpu.S b/libc/arch-mips/syscalls/__getcpu.S
index 90d59f4..052510f 100644
--- a/libc/arch-mips/syscalls/__getcpu.S
+++ b/libc/arch-mips/syscalls/__getcpu.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __getcpu
     .align 4
diff --git a/libc/arch-mips/syscalls/__getcwd.S b/libc/arch-mips/syscalls/__getcwd.S
index e8fa340..11a7a94 100644
--- a/libc/arch-mips/syscalls/__getcwd.S
+++ b/libc/arch-mips/syscalls/__getcwd.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __getcwd
     .align 4
diff --git a/libc/arch-mips/syscalls/__getpriority.S b/libc/arch-mips/syscalls/__getpriority.S
index 7cabd31..b1bf9ea 100644
--- a/libc/arch-mips/syscalls/__getpriority.S
+++ b/libc/arch-mips/syscalls/__getpriority.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __getpriority
     .align 4
diff --git a/libc/arch-mips/syscalls/__ioctl.S b/libc/arch-mips/syscalls/__ioctl.S
index 2524e02..d072bd8 100644
--- a/libc/arch-mips/syscalls/__ioctl.S
+++ b/libc/arch-mips/syscalls/__ioctl.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __ioctl
     .align 4
diff --git a/libc/arch-mips/syscalls/__llseek.S b/libc/arch-mips/syscalls/__llseek.S
index fbfd583..4248e0c 100644
--- a/libc/arch-mips/syscalls/__llseek.S
+++ b/libc/arch-mips/syscalls/__llseek.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __llseek
     .align 4
diff --git a/libc/arch-mips/syscalls/__mmap2.S b/libc/arch-mips/syscalls/__mmap2.S
index 98f97eb..8f4534c 100644
--- a/libc/arch-mips/syscalls/__mmap2.S
+++ b/libc/arch-mips/syscalls/__mmap2.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __mmap2
     .align 4
diff --git a/libc/arch-mips/syscalls/__open.S b/libc/arch-mips/syscalls/__open.S
index 0ccb286..9c0a7c6 100644
--- a/libc/arch-mips/syscalls/__open.S
+++ b/libc/arch-mips/syscalls/__open.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __open
     .align 4
diff --git a/libc/arch-mips/syscalls/__openat.S b/libc/arch-mips/syscalls/__openat.S
index 04399b4..f2451b4 100644
--- a/libc/arch-mips/syscalls/__openat.S
+++ b/libc/arch-mips/syscalls/__openat.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __openat
     .align 4
diff --git a/libc/arch-mips/syscalls/__ptrace.S b/libc/arch-mips/syscalls/__ptrace.S
index 0bcba9f..f892650 100644
--- a/libc/arch-mips/syscalls/__ptrace.S
+++ b/libc/arch-mips/syscalls/__ptrace.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __ptrace
     .align 4
diff --git a/libc/arch-mips/syscalls/__reboot.S b/libc/arch-mips/syscalls/__reboot.S
index 5e8e57a..dcd68e4 100644
--- a/libc/arch-mips/syscalls/__reboot.S
+++ b/libc/arch-mips/syscalls/__reboot.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __reboot
     .align 4
diff --git a/libc/arch-mips/syscalls/__rt_sigaction.S b/libc/arch-mips/syscalls/__rt_sigaction.S
index 43a571a..b828681 100644
--- a/libc/arch-mips/syscalls/__rt_sigaction.S
+++ b/libc/arch-mips/syscalls/__rt_sigaction.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __rt_sigaction
     .align 4
diff --git a/libc/arch-mips/syscalls/__rt_sigprocmask.S b/libc/arch-mips/syscalls/__rt_sigprocmask.S
index 59a8894..6faf1ef 100644
--- a/libc/arch-mips/syscalls/__rt_sigprocmask.S
+++ b/libc/arch-mips/syscalls/__rt_sigprocmask.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __rt_sigprocmask
     .align 4
diff --git a/libc/arch-mips/syscalls/__rt_sigtimedwait.S b/libc/arch-mips/syscalls/__rt_sigtimedwait.S
index dae872e..1a6ae6e 100644
--- a/libc/arch-mips/syscalls/__rt_sigtimedwait.S
+++ b/libc/arch-mips/syscalls/__rt_sigtimedwait.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __rt_sigtimedwait
     .align 4
diff --git a/libc/arch-mips/syscalls/__sched_getaffinity.S b/libc/arch-mips/syscalls/__sched_getaffinity.S
index cc01ff2..4099baa 100644
--- a/libc/arch-mips/syscalls/__sched_getaffinity.S
+++ b/libc/arch-mips/syscalls/__sched_getaffinity.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __sched_getaffinity
     .align 4
diff --git a/libc/arch-mips/syscalls/__set_thread_area.S b/libc/arch-mips/syscalls/__set_thread_area.S
index 2aac901..d198513 100644
--- a/libc/arch-mips/syscalls/__set_thread_area.S
+++ b/libc/arch-mips/syscalls/__set_thread_area.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __set_thread_area
     .align 4
diff --git a/libc/arch-mips/syscalls/__setresuid.S b/libc/arch-mips/syscalls/__setresuid.S
index e00d2e1..e43e121 100644
--- a/libc/arch-mips/syscalls/__setresuid.S
+++ b/libc/arch-mips/syscalls/__setresuid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __setresuid
     .align 4
diff --git a/libc/arch-mips/syscalls/__setreuid.S b/libc/arch-mips/syscalls/__setreuid.S
index b45f3fc..72bca16 100644
--- a/libc/arch-mips/syscalls/__setreuid.S
+++ b/libc/arch-mips/syscalls/__setreuid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __setreuid
     .align 4
diff --git a/libc/arch-mips/syscalls/__setuid.S b/libc/arch-mips/syscalls/__setuid.S
index c221526..360552c 100644
--- a/libc/arch-mips/syscalls/__setuid.S
+++ b/libc/arch-mips/syscalls/__setuid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __setuid
     .align 4
diff --git a/libc/arch-mips/syscalls/__sigsuspend.S b/libc/arch-mips/syscalls/__sigsuspend.S
index b622efe..2b6f6d7 100644
--- a/libc/arch-mips/syscalls/__sigsuspend.S
+++ b/libc/arch-mips/syscalls/__sigsuspend.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __sigsuspend
     .align 4
diff --git a/libc/arch-mips/syscalls/__statfs64.S b/libc/arch-mips/syscalls/__statfs64.S
index 4d1b17f..167f338 100644
--- a/libc/arch-mips/syscalls/__statfs64.S
+++ b/libc/arch-mips/syscalls/__statfs64.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __statfs64
     .align 4
diff --git a/libc/arch-mips/syscalls/__sys_clone.S b/libc/arch-mips/syscalls/__sys_clone.S
index 3451e02..718466b 100644
--- a/libc/arch-mips/syscalls/__sys_clone.S
+++ b/libc/arch-mips/syscalls/__sys_clone.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __sys_clone
     .align 4
diff --git a/libc/arch-mips/syscalls/__syslog.S b/libc/arch-mips/syscalls/__syslog.S
index bdc194d..8b30c50 100644
--- a/libc/arch-mips/syscalls/__syslog.S
+++ b/libc/arch-mips/syscalls/__syslog.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __syslog
     .align 4
diff --git a/libc/arch-mips/syscalls/__timer_create.S b/libc/arch-mips/syscalls/__timer_create.S
index 140d0d1..7d34312 100644
--- a/libc/arch-mips/syscalls/__timer_create.S
+++ b/libc/arch-mips/syscalls/__timer_create.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __timer_create
     .align 4
diff --git a/libc/arch-mips/syscalls/__timer_delete.S b/libc/arch-mips/syscalls/__timer_delete.S
index 4f362e6..45c95bc 100644
--- a/libc/arch-mips/syscalls/__timer_delete.S
+++ b/libc/arch-mips/syscalls/__timer_delete.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __timer_delete
     .align 4
diff --git a/libc/arch-mips/syscalls/__timer_getoverrun.S b/libc/arch-mips/syscalls/__timer_getoverrun.S
index 68afa1c..2175ecd 100644
--- a/libc/arch-mips/syscalls/__timer_getoverrun.S
+++ b/libc/arch-mips/syscalls/__timer_getoverrun.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __timer_getoverrun
     .align 4
diff --git a/libc/arch-mips/syscalls/__timer_gettime.S b/libc/arch-mips/syscalls/__timer_gettime.S
index 4a70da6..3d5944f 100644
--- a/libc/arch-mips/syscalls/__timer_gettime.S
+++ b/libc/arch-mips/syscalls/__timer_gettime.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __timer_gettime
     .align 4
diff --git a/libc/arch-mips/syscalls/__timer_settime.S b/libc/arch-mips/syscalls/__timer_settime.S
index ad84606..387ab4a 100644
--- a/libc/arch-mips/syscalls/__timer_settime.S
+++ b/libc/arch-mips/syscalls/__timer_settime.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __timer_settime
     .align 4
diff --git a/libc/arch-mips/syscalls/__waitid.S b/libc/arch-mips/syscalls/__waitid.S
index 83e5aa3..979a22b 100644
--- a/libc/arch-mips/syscalls/__waitid.S
+++ b/libc/arch-mips/syscalls/__waitid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl __waitid
     .align 4
diff --git a/libc/arch-mips/syscalls/_exit.S b/libc/arch-mips/syscalls/_exit.S
index b7ec876..c6f84f5 100644
--- a/libc/arch-mips/syscalls/_exit.S
+++ b/libc/arch-mips/syscalls/_exit.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl _exit
     .align 4
diff --git a/libc/arch-mips/syscalls/_exit_thread.S b/libc/arch-mips/syscalls/_exit_thread.S
index 0af9d3d..d5547e8 100644
--- a/libc/arch-mips/syscalls/_exit_thread.S
+++ b/libc/arch-mips/syscalls/_exit_thread.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl _exit_thread
     .align 4
diff --git a/libc/arch-mips/syscalls/_flush_cache.S b/libc/arch-mips/syscalls/_flush_cache.S
index 07dee66..cee9dbc 100644
--- a/libc/arch-mips/syscalls/_flush_cache.S
+++ b/libc/arch-mips/syscalls/_flush_cache.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl _flush_cache
     .align 4
diff --git a/libc/arch-mips/syscalls/_waitpid.S b/libc/arch-mips/syscalls/_waitpid.S
index 20db3a8..be5887f 100644
--- a/libc/arch-mips/syscalls/_waitpid.S
+++ b/libc/arch-mips/syscalls/_waitpid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl _waitpid
     .align 4
diff --git a/libc/arch-mips/syscalls/accept.S b/libc/arch-mips/syscalls/accept.S
index c19216e..c9b4772 100644
--- a/libc/arch-mips/syscalls/accept.S
+++ b/libc/arch-mips/syscalls/accept.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl accept
     .align 4
diff --git a/libc/arch-mips/syscalls/access.S b/libc/arch-mips/syscalls/access.S
index a22ed92..2b4bec4 100644
--- a/libc/arch-mips/syscalls/access.S
+++ b/libc/arch-mips/syscalls/access.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl access
     .align 4
diff --git a/libc/arch-mips/syscalls/acct.S b/libc/arch-mips/syscalls/acct.S
index 5235ede..598f762 100644
--- a/libc/arch-mips/syscalls/acct.S
+++ b/libc/arch-mips/syscalls/acct.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl acct
     .align 4
diff --git a/libc/arch-mips/syscalls/bind.S b/libc/arch-mips/syscalls/bind.S
index 4f00922..58ab603 100644
--- a/libc/arch-mips/syscalls/bind.S
+++ b/libc/arch-mips/syscalls/bind.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl bind
     .align 4
diff --git a/libc/arch-mips/syscalls/capget.S b/libc/arch-mips/syscalls/capget.S
index 80e55ee..e6d8755 100644
--- a/libc/arch-mips/syscalls/capget.S
+++ b/libc/arch-mips/syscalls/capget.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl capget
     .align 4
diff --git a/libc/arch-mips/syscalls/capset.S b/libc/arch-mips/syscalls/capset.S
index 0e4a3be..412d62e 100644
--- a/libc/arch-mips/syscalls/capset.S
+++ b/libc/arch-mips/syscalls/capset.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl capset
     .align 4
diff --git a/libc/arch-mips/syscalls/chdir.S b/libc/arch-mips/syscalls/chdir.S
index 42eb37c..217e000 100644
--- a/libc/arch-mips/syscalls/chdir.S
+++ b/libc/arch-mips/syscalls/chdir.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl chdir
     .align 4
diff --git a/libc/arch-mips/syscalls/chmod.S b/libc/arch-mips/syscalls/chmod.S
index 7ea3ede..7f7f8ee 100644
--- a/libc/arch-mips/syscalls/chmod.S
+++ b/libc/arch-mips/syscalls/chmod.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl chmod
     .align 4
diff --git a/libc/arch-mips/syscalls/chown.S b/libc/arch-mips/syscalls/chown.S
index 5fb1e32..8064572 100644
--- a/libc/arch-mips/syscalls/chown.S
+++ b/libc/arch-mips/syscalls/chown.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl chown
     .align 4
diff --git a/libc/arch-mips/syscalls/chroot.S b/libc/arch-mips/syscalls/chroot.S
index fafb6a2..07b28e9 100644
--- a/libc/arch-mips/syscalls/chroot.S
+++ b/libc/arch-mips/syscalls/chroot.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl chroot
     .align 4
diff --git a/libc/arch-mips/syscalls/clock_getres.S b/libc/arch-mips/syscalls/clock_getres.S
index 4021b14..c7c8de1 100644
--- a/libc/arch-mips/syscalls/clock_getres.S
+++ b/libc/arch-mips/syscalls/clock_getres.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl clock_getres
     .align 4
diff --git a/libc/arch-mips/syscalls/clock_gettime.S b/libc/arch-mips/syscalls/clock_gettime.S
index ba7afb9..b89c9d0 100644
--- a/libc/arch-mips/syscalls/clock_gettime.S
+++ b/libc/arch-mips/syscalls/clock_gettime.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl clock_gettime
     .align 4
diff --git a/libc/arch-mips/syscalls/clock_nanosleep.S b/libc/arch-mips/syscalls/clock_nanosleep.S
index 1a9aef5..ec85361 100644
--- a/libc/arch-mips/syscalls/clock_nanosleep.S
+++ b/libc/arch-mips/syscalls/clock_nanosleep.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl clock_nanosleep
     .align 4
diff --git a/libc/arch-mips/syscalls/clock_settime.S b/libc/arch-mips/syscalls/clock_settime.S
index 65d4388..3e6f2e6 100644
--- a/libc/arch-mips/syscalls/clock_settime.S
+++ b/libc/arch-mips/syscalls/clock_settime.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl clock_settime
     .align 4
diff --git a/libc/arch-mips/syscalls/close.S b/libc/arch-mips/syscalls/close.S
index 07ff4e3..115c286 100644
--- a/libc/arch-mips/syscalls/close.S
+++ b/libc/arch-mips/syscalls/close.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl close
     .align 4
diff --git a/libc/arch-mips/syscalls/connect.S b/libc/arch-mips/syscalls/connect.S
index d1fc280..13300e2 100644
--- a/libc/arch-mips/syscalls/connect.S
+++ b/libc/arch-mips/syscalls/connect.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl connect
     .align 4
diff --git a/libc/arch-mips/syscalls/delete_module.S b/libc/arch-mips/syscalls/delete_module.S
index db80ba7..b820c7d 100644
--- a/libc/arch-mips/syscalls/delete_module.S
+++ b/libc/arch-mips/syscalls/delete_module.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl delete_module
     .align 4
diff --git a/libc/arch-mips/syscalls/dup.S b/libc/arch-mips/syscalls/dup.S
index e815749..da45c9e 100644
--- a/libc/arch-mips/syscalls/dup.S
+++ b/libc/arch-mips/syscalls/dup.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl dup
     .align 4
diff --git a/libc/arch-mips/syscalls/dup2.S b/libc/arch-mips/syscalls/dup2.S
index 6fb151f..d040ef3 100644
--- a/libc/arch-mips/syscalls/dup2.S
+++ b/libc/arch-mips/syscalls/dup2.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl dup2
     .align 4
diff --git a/libc/arch-mips/syscalls/epoll_create.S b/libc/arch-mips/syscalls/epoll_create.S
index e5e420b..2f4ac7f 100644
--- a/libc/arch-mips/syscalls/epoll_create.S
+++ b/libc/arch-mips/syscalls/epoll_create.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl epoll_create
     .align 4
diff --git a/libc/arch-mips/syscalls/epoll_ctl.S b/libc/arch-mips/syscalls/epoll_ctl.S
index f4f9f05..92b5425 100644
--- a/libc/arch-mips/syscalls/epoll_ctl.S
+++ b/libc/arch-mips/syscalls/epoll_ctl.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl epoll_ctl
     .align 4
diff --git a/libc/arch-mips/syscalls/epoll_wait.S b/libc/arch-mips/syscalls/epoll_wait.S
index 64d33fb..7665a10 100644
--- a/libc/arch-mips/syscalls/epoll_wait.S
+++ b/libc/arch-mips/syscalls/epoll_wait.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl epoll_wait
     .align 4
diff --git a/libc/arch-mips/syscalls/eventfd.S b/libc/arch-mips/syscalls/eventfd.S
index 5c4e22b..48d4c04 100644
--- a/libc/arch-mips/syscalls/eventfd.S
+++ b/libc/arch-mips/syscalls/eventfd.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl eventfd
     .align 4
diff --git a/libc/arch-mips/syscalls/execve.S b/libc/arch-mips/syscalls/execve.S
index 31b9276..2f279b8 100644
--- a/libc/arch-mips/syscalls/execve.S
+++ b/libc/arch-mips/syscalls/execve.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl execve
     .align 4
diff --git a/libc/arch-mips/syscalls/faccessat.S b/libc/arch-mips/syscalls/faccessat.S
index 97db4c0..93346f1 100644
--- a/libc/arch-mips/syscalls/faccessat.S
+++ b/libc/arch-mips/syscalls/faccessat.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl faccessat
     .align 4
diff --git a/libc/arch-mips/syscalls/fchdir.S b/libc/arch-mips/syscalls/fchdir.S
index 93298bd..d3aa8d9 100644
--- a/libc/arch-mips/syscalls/fchdir.S
+++ b/libc/arch-mips/syscalls/fchdir.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl fchdir
     .align 4
diff --git a/libc/arch-mips/syscalls/fchmod.S b/libc/arch-mips/syscalls/fchmod.S
index f483567..3837f18 100644
--- a/libc/arch-mips/syscalls/fchmod.S
+++ b/libc/arch-mips/syscalls/fchmod.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl fchmod
     .align 4
diff --git a/libc/arch-mips/syscalls/fchmodat.S b/libc/arch-mips/syscalls/fchmodat.S
index 8ba1bbe..77487ab 100644
--- a/libc/arch-mips/syscalls/fchmodat.S
+++ b/libc/arch-mips/syscalls/fchmodat.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl fchmodat
     .align 4
diff --git a/libc/arch-mips/syscalls/fchown.S b/libc/arch-mips/syscalls/fchown.S
index 24fc08f..ba2ec81 100644
--- a/libc/arch-mips/syscalls/fchown.S
+++ b/libc/arch-mips/syscalls/fchown.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl fchown
     .align 4
diff --git a/libc/arch-mips/syscalls/fchownat.S b/libc/arch-mips/syscalls/fchownat.S
index 983ed56..5b464e3 100644
--- a/libc/arch-mips/syscalls/fchownat.S
+++ b/libc/arch-mips/syscalls/fchownat.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl fchownat
     .align 4
diff --git a/libc/arch-mips/syscalls/fdatasync.S b/libc/arch-mips/syscalls/fdatasync.S
index 312439d..45d43fd 100644
--- a/libc/arch-mips/syscalls/fdatasync.S
+++ b/libc/arch-mips/syscalls/fdatasync.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl fdatasync
     .align 4
diff --git a/libc/arch-mips/syscalls/fgetxattr.S b/libc/arch-mips/syscalls/fgetxattr.S
index 7e77e61..454e809 100644
--- a/libc/arch-mips/syscalls/fgetxattr.S
+++ b/libc/arch-mips/syscalls/fgetxattr.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl fgetxattr
     .align 4
diff --git a/libc/arch-mips/syscalls/flistxattr.S b/libc/arch-mips/syscalls/flistxattr.S
index 26e26e1..319d45a 100644
--- a/libc/arch-mips/syscalls/flistxattr.S
+++ b/libc/arch-mips/syscalls/flistxattr.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl flistxattr
     .align 4
diff --git a/libc/arch-mips/syscalls/flock.S b/libc/arch-mips/syscalls/flock.S
index f9a3142..41d0deb 100644
--- a/libc/arch-mips/syscalls/flock.S
+++ b/libc/arch-mips/syscalls/flock.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl flock
     .align 4
diff --git a/libc/arch-mips/syscalls/fremovexattr.S b/libc/arch-mips/syscalls/fremovexattr.S
index db3eb6c..449e00c 100644
--- a/libc/arch-mips/syscalls/fremovexattr.S
+++ b/libc/arch-mips/syscalls/fremovexattr.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl fremovexattr
     .align 4
diff --git a/libc/arch-mips/syscalls/fsetxattr.S b/libc/arch-mips/syscalls/fsetxattr.S
index 9e666f2..5c7731a 100644
--- a/libc/arch-mips/syscalls/fsetxattr.S
+++ b/libc/arch-mips/syscalls/fsetxattr.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl fsetxattr
     .align 4
diff --git a/libc/arch-mips/syscalls/fstat.S b/libc/arch-mips/syscalls/fstat.S
index 73d7235..201e94c 100644
--- a/libc/arch-mips/syscalls/fstat.S
+++ b/libc/arch-mips/syscalls/fstat.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl fstat
     .align 4
diff --git a/libc/arch-mips/syscalls/fstatat.S b/libc/arch-mips/syscalls/fstatat.S
index 3ae229e..e22d6fd 100644
--- a/libc/arch-mips/syscalls/fstatat.S
+++ b/libc/arch-mips/syscalls/fstatat.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl fstatat
     .align 4
diff --git a/libc/arch-mips/syscalls/fsync.S b/libc/arch-mips/syscalls/fsync.S
index e1cd316..168bc88 100644
--- a/libc/arch-mips/syscalls/fsync.S
+++ b/libc/arch-mips/syscalls/fsync.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl fsync
     .align 4
diff --git a/libc/arch-mips/syscalls/ftruncate.S b/libc/arch-mips/syscalls/ftruncate.S
index 5d72b43..aa84e1f 100644
--- a/libc/arch-mips/syscalls/ftruncate.S
+++ b/libc/arch-mips/syscalls/ftruncate.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl ftruncate
     .align 4
diff --git a/libc/arch-mips/syscalls/ftruncate64.S b/libc/arch-mips/syscalls/ftruncate64.S
index 216ae38..398069c 100644
--- a/libc/arch-mips/syscalls/ftruncate64.S
+++ b/libc/arch-mips/syscalls/ftruncate64.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl ftruncate64
     .align 4
diff --git a/libc/arch-mips/syscalls/futex.S b/libc/arch-mips/syscalls/futex.S
index 65e537a..2cf4eb0 100644
--- a/libc/arch-mips/syscalls/futex.S
+++ b/libc/arch-mips/syscalls/futex.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl futex
     .align 4
diff --git a/libc/arch-mips/syscalls/getdents.S b/libc/arch-mips/syscalls/getdents.S
index 8ff0f26..4a4f63c 100644
--- a/libc/arch-mips/syscalls/getdents.S
+++ b/libc/arch-mips/syscalls/getdents.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getdents
     .align 4
diff --git a/libc/arch-mips/syscalls/getegid.S b/libc/arch-mips/syscalls/getegid.S
index dc2a04b..c6b6ccb 100644
--- a/libc/arch-mips/syscalls/getegid.S
+++ b/libc/arch-mips/syscalls/getegid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getegid
     .align 4
diff --git a/libc/arch-mips/syscalls/geteuid.S b/libc/arch-mips/syscalls/geteuid.S
index 8beca88..cdcf793 100644
--- a/libc/arch-mips/syscalls/geteuid.S
+++ b/libc/arch-mips/syscalls/geteuid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl geteuid
     .align 4
diff --git a/libc/arch-mips/syscalls/getgid.S b/libc/arch-mips/syscalls/getgid.S
index 6a615ee..af25ff0 100644
--- a/libc/arch-mips/syscalls/getgid.S
+++ b/libc/arch-mips/syscalls/getgid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getgid
     .align 4
diff --git a/libc/arch-mips/syscalls/getgroups.S b/libc/arch-mips/syscalls/getgroups.S
index 8be7308..35b62a6 100644
--- a/libc/arch-mips/syscalls/getgroups.S
+++ b/libc/arch-mips/syscalls/getgroups.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getgroups
     .align 4
diff --git a/libc/arch-mips/syscalls/getitimer.S b/libc/arch-mips/syscalls/getitimer.S
index 3df1d11..82e6a45 100644
--- a/libc/arch-mips/syscalls/getitimer.S
+++ b/libc/arch-mips/syscalls/getitimer.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getitimer
     .align 4
diff --git a/libc/arch-mips/syscalls/getpeername.S b/libc/arch-mips/syscalls/getpeername.S
index 4a3beda..771ac55 100644
--- a/libc/arch-mips/syscalls/getpeername.S
+++ b/libc/arch-mips/syscalls/getpeername.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getpeername
     .align 4
diff --git a/libc/arch-mips/syscalls/getpgid.S b/libc/arch-mips/syscalls/getpgid.S
index fd79351..1b4834c 100644
--- a/libc/arch-mips/syscalls/getpgid.S
+++ b/libc/arch-mips/syscalls/getpgid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getpgid
     .align 4
diff --git a/libc/arch-mips/syscalls/getpid.S b/libc/arch-mips/syscalls/getpid.S
index f52e31b..819e954 100644
--- a/libc/arch-mips/syscalls/getpid.S
+++ b/libc/arch-mips/syscalls/getpid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getpid
     .align 4
diff --git a/libc/arch-mips/syscalls/getppid.S b/libc/arch-mips/syscalls/getppid.S
index 5e3fe19..a03a7a7 100644
--- a/libc/arch-mips/syscalls/getppid.S
+++ b/libc/arch-mips/syscalls/getppid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getppid
     .align 4
diff --git a/libc/arch-mips/syscalls/getresgid.S b/libc/arch-mips/syscalls/getresgid.S
index 8e9bf39..fe751fb 100644
--- a/libc/arch-mips/syscalls/getresgid.S
+++ b/libc/arch-mips/syscalls/getresgid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getresgid
     .align 4
diff --git a/libc/arch-mips/syscalls/getresuid.S b/libc/arch-mips/syscalls/getresuid.S
index ff27cde..a81f6bc 100644
--- a/libc/arch-mips/syscalls/getresuid.S
+++ b/libc/arch-mips/syscalls/getresuid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getresuid
     .align 4
diff --git a/libc/arch-mips/syscalls/getrlimit.S b/libc/arch-mips/syscalls/getrlimit.S
index 72ed7d8..22827e0 100644
--- a/libc/arch-mips/syscalls/getrlimit.S
+++ b/libc/arch-mips/syscalls/getrlimit.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getrlimit
     .align 4
diff --git a/libc/arch-mips/syscalls/getrusage.S b/libc/arch-mips/syscalls/getrusage.S
index 4c0f7d0..9555799 100644
--- a/libc/arch-mips/syscalls/getrusage.S
+++ b/libc/arch-mips/syscalls/getrusage.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getrusage
     .align 4
diff --git a/libc/arch-mips/syscalls/getsid.S b/libc/arch-mips/syscalls/getsid.S
index 2c089ac..ea454b6 100644
--- a/libc/arch-mips/syscalls/getsid.S
+++ b/libc/arch-mips/syscalls/getsid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getsid
     .align 4
diff --git a/libc/arch-mips/syscalls/getsockname.S b/libc/arch-mips/syscalls/getsockname.S
index e3d41f9..c8cc037 100644
--- a/libc/arch-mips/syscalls/getsockname.S
+++ b/libc/arch-mips/syscalls/getsockname.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getsockname
     .align 4
diff --git a/libc/arch-mips/syscalls/getsockopt.S b/libc/arch-mips/syscalls/getsockopt.S
index d55ae6a..f2ad135 100644
--- a/libc/arch-mips/syscalls/getsockopt.S
+++ b/libc/arch-mips/syscalls/getsockopt.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getsockopt
     .align 4
diff --git a/libc/arch-mips/syscalls/gettid.S b/libc/arch-mips/syscalls/gettid.S
index de37df5..84556cc 100644
--- a/libc/arch-mips/syscalls/gettid.S
+++ b/libc/arch-mips/syscalls/gettid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl gettid
     .align 4
diff --git a/libc/arch-mips/syscalls/gettimeofday.S b/libc/arch-mips/syscalls/gettimeofday.S
index a9a93a5..50270cb 100644
--- a/libc/arch-mips/syscalls/gettimeofday.S
+++ b/libc/arch-mips/syscalls/gettimeofday.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl gettimeofday
     .align 4
diff --git a/libc/arch-mips/syscalls/getuid.S b/libc/arch-mips/syscalls/getuid.S
index e5ba698..5e820d1 100644
--- a/libc/arch-mips/syscalls/getuid.S
+++ b/libc/arch-mips/syscalls/getuid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getuid
     .align 4
diff --git a/libc/arch-mips/syscalls/getxattr.S b/libc/arch-mips/syscalls/getxattr.S
index 6c70579..9ca843c 100644
--- a/libc/arch-mips/syscalls/getxattr.S
+++ b/libc/arch-mips/syscalls/getxattr.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl getxattr
     .align 4
diff --git a/libc/arch-mips/syscalls/init_module.S b/libc/arch-mips/syscalls/init_module.S
index 5cfbd2f..baf4dba 100644
--- a/libc/arch-mips/syscalls/init_module.S
+++ b/libc/arch-mips/syscalls/init_module.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl init_module
     .align 4
diff --git a/libc/arch-mips/syscalls/inotify_add_watch.S b/libc/arch-mips/syscalls/inotify_add_watch.S
index 8dde667..329368e 100644
--- a/libc/arch-mips/syscalls/inotify_add_watch.S
+++ b/libc/arch-mips/syscalls/inotify_add_watch.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl inotify_add_watch
     .align 4
diff --git a/libc/arch-mips/syscalls/inotify_init.S b/libc/arch-mips/syscalls/inotify_init.S
index cde4667..14b8c73 100644
--- a/libc/arch-mips/syscalls/inotify_init.S
+++ b/libc/arch-mips/syscalls/inotify_init.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl inotify_init
     .align 4
diff --git a/libc/arch-mips/syscalls/inotify_rm_watch.S b/libc/arch-mips/syscalls/inotify_rm_watch.S
index 1b2964e..deff837 100644
--- a/libc/arch-mips/syscalls/inotify_rm_watch.S
+++ b/libc/arch-mips/syscalls/inotify_rm_watch.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl inotify_rm_watch
     .align 4
diff --git a/libc/arch-mips/syscalls/ioprio_get.S b/libc/arch-mips/syscalls/ioprio_get.S
index f7f2441..ad0b0cb 100644
--- a/libc/arch-mips/syscalls/ioprio_get.S
+++ b/libc/arch-mips/syscalls/ioprio_get.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl ioprio_get
     .align 4
diff --git a/libc/arch-mips/syscalls/ioprio_set.S b/libc/arch-mips/syscalls/ioprio_set.S
index 33a30e7..d119819 100644
--- a/libc/arch-mips/syscalls/ioprio_set.S
+++ b/libc/arch-mips/syscalls/ioprio_set.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl ioprio_set
     .align 4
diff --git a/libc/arch-mips/syscalls/kill.S b/libc/arch-mips/syscalls/kill.S
index a6640ff..4792015 100644
--- a/libc/arch-mips/syscalls/kill.S
+++ b/libc/arch-mips/syscalls/kill.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl kill
     .align 4
diff --git a/libc/arch-mips/syscalls/klogctl.S b/libc/arch-mips/syscalls/klogctl.S
index 8c41dcf..ff862ed 100644
--- a/libc/arch-mips/syscalls/klogctl.S
+++ b/libc/arch-mips/syscalls/klogctl.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl klogctl
     .align 4
diff --git a/libc/arch-mips/syscalls/lchown.S b/libc/arch-mips/syscalls/lchown.S
index 9fb4660..4de65f8 100644
--- a/libc/arch-mips/syscalls/lchown.S
+++ b/libc/arch-mips/syscalls/lchown.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl lchown
     .align 4
diff --git a/libc/arch-mips/syscalls/lgetxattr.S b/libc/arch-mips/syscalls/lgetxattr.S
index d546d28..e6c18b7 100644
--- a/libc/arch-mips/syscalls/lgetxattr.S
+++ b/libc/arch-mips/syscalls/lgetxattr.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl lgetxattr
     .align 4
diff --git a/libc/arch-mips/syscalls/link.S b/libc/arch-mips/syscalls/link.S
index 4096b44..c3a9903 100644
--- a/libc/arch-mips/syscalls/link.S
+++ b/libc/arch-mips/syscalls/link.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl link
     .align 4
diff --git a/libc/arch-mips/syscalls/listen.S b/libc/arch-mips/syscalls/listen.S
index f365d1d..324f486 100644
--- a/libc/arch-mips/syscalls/listen.S
+++ b/libc/arch-mips/syscalls/listen.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl listen
     .align 4
diff --git a/libc/arch-mips/syscalls/listxattr.S b/libc/arch-mips/syscalls/listxattr.S
index 90b4544..52871af 100644
--- a/libc/arch-mips/syscalls/listxattr.S
+++ b/libc/arch-mips/syscalls/listxattr.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl listxattr
     .align 4
diff --git a/libc/arch-mips/syscalls/llistxattr.S b/libc/arch-mips/syscalls/llistxattr.S
index e74bf85..f48a657 100644
--- a/libc/arch-mips/syscalls/llistxattr.S
+++ b/libc/arch-mips/syscalls/llistxattr.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl llistxattr
     .align 4
diff --git a/libc/arch-mips/syscalls/lremovexattr.S b/libc/arch-mips/syscalls/lremovexattr.S
index a8d8df9..f19ae18 100644
--- a/libc/arch-mips/syscalls/lremovexattr.S
+++ b/libc/arch-mips/syscalls/lremovexattr.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl lremovexattr
     .align 4
diff --git a/libc/arch-mips/syscalls/lseek.S b/libc/arch-mips/syscalls/lseek.S
index bf486ac..3dc9b36 100644
--- a/libc/arch-mips/syscalls/lseek.S
+++ b/libc/arch-mips/syscalls/lseek.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl lseek
     .align 4
diff --git a/libc/arch-mips/syscalls/lsetxattr.S b/libc/arch-mips/syscalls/lsetxattr.S
index 19a0fdf..77484a9 100644
--- a/libc/arch-mips/syscalls/lsetxattr.S
+++ b/libc/arch-mips/syscalls/lsetxattr.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl lsetxattr
     .align 4
diff --git a/libc/arch-mips/syscalls/lstat.S b/libc/arch-mips/syscalls/lstat.S
index 355d1da..a961ccb 100644
--- a/libc/arch-mips/syscalls/lstat.S
+++ b/libc/arch-mips/syscalls/lstat.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl lstat
     .align 4
diff --git a/libc/arch-mips/syscalls/madvise.S b/libc/arch-mips/syscalls/madvise.S
index 4df7325..08cd8ca 100644
--- a/libc/arch-mips/syscalls/madvise.S
+++ b/libc/arch-mips/syscalls/madvise.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl madvise
     .align 4
diff --git a/libc/arch-mips/syscalls/mincore.S b/libc/arch-mips/syscalls/mincore.S
index 8f467cd..7f6a1d0 100644
--- a/libc/arch-mips/syscalls/mincore.S
+++ b/libc/arch-mips/syscalls/mincore.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl mincore
     .align 4
diff --git a/libc/arch-mips/syscalls/mkdir.S b/libc/arch-mips/syscalls/mkdir.S
index abf7db8..baa1860 100644
--- a/libc/arch-mips/syscalls/mkdir.S
+++ b/libc/arch-mips/syscalls/mkdir.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl mkdir
     .align 4
diff --git a/libc/arch-mips/syscalls/mkdirat.S b/libc/arch-mips/syscalls/mkdirat.S
index 4ccbe3b..158359a 100644
--- a/libc/arch-mips/syscalls/mkdirat.S
+++ b/libc/arch-mips/syscalls/mkdirat.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl mkdirat
     .align 4
diff --git a/libc/arch-mips/syscalls/mknod.S b/libc/arch-mips/syscalls/mknod.S
index 5ebb0ad..1b03962 100644
--- a/libc/arch-mips/syscalls/mknod.S
+++ b/libc/arch-mips/syscalls/mknod.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl mknod
     .align 4
diff --git a/libc/arch-mips/syscalls/mlock.S b/libc/arch-mips/syscalls/mlock.S
index 99aca6e..34eae89 100644
--- a/libc/arch-mips/syscalls/mlock.S
+++ b/libc/arch-mips/syscalls/mlock.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl mlock
     .align 4
diff --git a/libc/arch-mips/syscalls/mlockall.S b/libc/arch-mips/syscalls/mlockall.S
index 393c090..3c2d852 100644
--- a/libc/arch-mips/syscalls/mlockall.S
+++ b/libc/arch-mips/syscalls/mlockall.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl mlockall
     .align 4
diff --git a/libc/arch-mips/syscalls/mount.S b/libc/arch-mips/syscalls/mount.S
index 1b3385a..2319e39 100644
--- a/libc/arch-mips/syscalls/mount.S
+++ b/libc/arch-mips/syscalls/mount.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl mount
     .align 4
diff --git a/libc/arch-mips/syscalls/mprotect.S b/libc/arch-mips/syscalls/mprotect.S
index 4dc3bea..c54c33f 100644
--- a/libc/arch-mips/syscalls/mprotect.S
+++ b/libc/arch-mips/syscalls/mprotect.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl mprotect
     .align 4
diff --git a/libc/arch-mips/syscalls/mremap.S b/libc/arch-mips/syscalls/mremap.S
index 721ccd9..c92b313 100644
--- a/libc/arch-mips/syscalls/mremap.S
+++ b/libc/arch-mips/syscalls/mremap.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl mremap
     .align 4
diff --git a/libc/arch-mips/syscalls/msync.S b/libc/arch-mips/syscalls/msync.S
index 37e1c9a..9ebd2b1 100644
--- a/libc/arch-mips/syscalls/msync.S
+++ b/libc/arch-mips/syscalls/msync.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl msync
     .align 4
diff --git a/libc/arch-mips/syscalls/munlock.S b/libc/arch-mips/syscalls/munlock.S
index befc282..1018413 100644
--- a/libc/arch-mips/syscalls/munlock.S
+++ b/libc/arch-mips/syscalls/munlock.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl munlock
     .align 4
diff --git a/libc/arch-mips/syscalls/munlockall.S b/libc/arch-mips/syscalls/munlockall.S
index 20fa7b8..d41dd1c 100644
--- a/libc/arch-mips/syscalls/munlockall.S
+++ b/libc/arch-mips/syscalls/munlockall.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl munlockall
     .align 4
diff --git a/libc/arch-mips/syscalls/munmap.S b/libc/arch-mips/syscalls/munmap.S
index 5b717a9..0ccd072 100644
--- a/libc/arch-mips/syscalls/munmap.S
+++ b/libc/arch-mips/syscalls/munmap.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl munmap
     .align 4
diff --git a/libc/arch-mips/syscalls/nanosleep.S b/libc/arch-mips/syscalls/nanosleep.S
index 58ace12..6bbbcc1 100644
--- a/libc/arch-mips/syscalls/nanosleep.S
+++ b/libc/arch-mips/syscalls/nanosleep.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl nanosleep
     .align 4
diff --git a/libc/arch-mips/syscalls/pause.S b/libc/arch-mips/syscalls/pause.S
index 70346b4..ba95fa5 100644
--- a/libc/arch-mips/syscalls/pause.S
+++ b/libc/arch-mips/syscalls/pause.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl pause
     .align 4
diff --git a/libc/arch-mips/syscalls/perf_event_open.S b/libc/arch-mips/syscalls/perf_event_open.S
index 22c9c3c..3867c2d 100644
--- a/libc/arch-mips/syscalls/perf_event_open.S
+++ b/libc/arch-mips/syscalls/perf_event_open.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl perf_event_open
     .align 4
diff --git a/libc/arch-mips/syscalls/personality.S b/libc/arch-mips/syscalls/personality.S
index 0020469..1570ac5 100644
--- a/libc/arch-mips/syscalls/personality.S
+++ b/libc/arch-mips/syscalls/personality.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl personality
     .align 4
diff --git a/libc/arch-mips/syscalls/pipe2.S b/libc/arch-mips/syscalls/pipe2.S
index 9dfde29..906be63 100644
--- a/libc/arch-mips/syscalls/pipe2.S
+++ b/libc/arch-mips/syscalls/pipe2.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl pipe2
     .align 4
diff --git a/libc/arch-mips/syscalls/poll.S b/libc/arch-mips/syscalls/poll.S
index c1fec97..9e3b142 100644
--- a/libc/arch-mips/syscalls/poll.S
+++ b/libc/arch-mips/syscalls/poll.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl poll
     .align 4
diff --git a/libc/arch-mips/syscalls/prctl.S b/libc/arch-mips/syscalls/prctl.S
index aaf1344..a9b1ac8 100644
--- a/libc/arch-mips/syscalls/prctl.S
+++ b/libc/arch-mips/syscalls/prctl.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl prctl
     .align 4
diff --git a/libc/arch-mips/syscalls/pread64.S b/libc/arch-mips/syscalls/pread64.S
index 86e817c..51d84a9 100644
--- a/libc/arch-mips/syscalls/pread64.S
+++ b/libc/arch-mips/syscalls/pread64.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl pread64
     .align 4
diff --git a/libc/arch-mips/syscalls/pwrite64.S b/libc/arch-mips/syscalls/pwrite64.S
index a8dcd98..46dfdf6 100644
--- a/libc/arch-mips/syscalls/pwrite64.S
+++ b/libc/arch-mips/syscalls/pwrite64.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl pwrite64
     .align 4
diff --git a/libc/arch-mips/syscalls/read.S b/libc/arch-mips/syscalls/read.S
index 75816cd..ee6e61a 100644
--- a/libc/arch-mips/syscalls/read.S
+++ b/libc/arch-mips/syscalls/read.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl read
     .align 4
diff --git a/libc/arch-mips/syscalls/readahead.S b/libc/arch-mips/syscalls/readahead.S
index 5ec600d..95c4e5b 100644
--- a/libc/arch-mips/syscalls/readahead.S
+++ b/libc/arch-mips/syscalls/readahead.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl readahead
     .align 4
diff --git a/libc/arch-mips/syscalls/readlink.S b/libc/arch-mips/syscalls/readlink.S
index ccdd596..2acf566 100644
--- a/libc/arch-mips/syscalls/readlink.S
+++ b/libc/arch-mips/syscalls/readlink.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl readlink
     .align 4
diff --git a/libc/arch-mips/syscalls/readv.S b/libc/arch-mips/syscalls/readv.S
index 0561c18..e0cea4e 100644
--- a/libc/arch-mips/syscalls/readv.S
+++ b/libc/arch-mips/syscalls/readv.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl readv
     .align 4
diff --git a/libc/arch-mips/syscalls/recvfrom.S b/libc/arch-mips/syscalls/recvfrom.S
index cf3441d..c34e506 100644
--- a/libc/arch-mips/syscalls/recvfrom.S
+++ b/libc/arch-mips/syscalls/recvfrom.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl recvfrom
     .align 4
diff --git a/libc/arch-mips/syscalls/recvmsg.S b/libc/arch-mips/syscalls/recvmsg.S
index 5f22c49..b47d866 100644
--- a/libc/arch-mips/syscalls/recvmsg.S
+++ b/libc/arch-mips/syscalls/recvmsg.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl recvmsg
     .align 4
diff --git a/libc/arch-mips/syscalls/removexattr.S b/libc/arch-mips/syscalls/removexattr.S
index 7d12b96..55c8e59 100644
--- a/libc/arch-mips/syscalls/removexattr.S
+++ b/libc/arch-mips/syscalls/removexattr.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl removexattr
     .align 4
diff --git a/libc/arch-mips/syscalls/rename.S b/libc/arch-mips/syscalls/rename.S
index 950d579..e36dcba 100644
--- a/libc/arch-mips/syscalls/rename.S
+++ b/libc/arch-mips/syscalls/rename.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl rename
     .align 4
diff --git a/libc/arch-mips/syscalls/renameat.S b/libc/arch-mips/syscalls/renameat.S
index a2f3c4f..893c245 100644
--- a/libc/arch-mips/syscalls/renameat.S
+++ b/libc/arch-mips/syscalls/renameat.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl renameat
     .align 4
diff --git a/libc/arch-mips/syscalls/rmdir.S b/libc/arch-mips/syscalls/rmdir.S
index 2f77d0d..79f36c4 100644
--- a/libc/arch-mips/syscalls/rmdir.S
+++ b/libc/arch-mips/syscalls/rmdir.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl rmdir
     .align 4
diff --git a/libc/arch-mips/syscalls/sched_get_priority_max.S b/libc/arch-mips/syscalls/sched_get_priority_max.S
index 158b0fe..16095c4 100644
--- a/libc/arch-mips/syscalls/sched_get_priority_max.S
+++ b/libc/arch-mips/syscalls/sched_get_priority_max.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sched_get_priority_max
     .align 4
diff --git a/libc/arch-mips/syscalls/sched_get_priority_min.S b/libc/arch-mips/syscalls/sched_get_priority_min.S
index 8c07d72..96cd2e6 100644
--- a/libc/arch-mips/syscalls/sched_get_priority_min.S
+++ b/libc/arch-mips/syscalls/sched_get_priority_min.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sched_get_priority_min
     .align 4
diff --git a/libc/arch-mips/syscalls/sched_getparam.S b/libc/arch-mips/syscalls/sched_getparam.S
index 6aba7cf..c781c4a 100644
--- a/libc/arch-mips/syscalls/sched_getparam.S
+++ b/libc/arch-mips/syscalls/sched_getparam.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sched_getparam
     .align 4
diff --git a/libc/arch-mips/syscalls/sched_getscheduler.S b/libc/arch-mips/syscalls/sched_getscheduler.S
index 33d7f49..8cbc0f5 100644
--- a/libc/arch-mips/syscalls/sched_getscheduler.S
+++ b/libc/arch-mips/syscalls/sched_getscheduler.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sched_getscheduler
     .align 4
diff --git a/libc/arch-mips/syscalls/sched_rr_get_interval.S b/libc/arch-mips/syscalls/sched_rr_get_interval.S
index e634ed0..3e010db 100644
--- a/libc/arch-mips/syscalls/sched_rr_get_interval.S
+++ b/libc/arch-mips/syscalls/sched_rr_get_interval.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sched_rr_get_interval
     .align 4
diff --git a/libc/arch-mips/syscalls/sched_setaffinity.S b/libc/arch-mips/syscalls/sched_setaffinity.S
index aefc240..7910dc7 100644
--- a/libc/arch-mips/syscalls/sched_setaffinity.S
+++ b/libc/arch-mips/syscalls/sched_setaffinity.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sched_setaffinity
     .align 4
diff --git a/libc/arch-mips/syscalls/sched_setparam.S b/libc/arch-mips/syscalls/sched_setparam.S
index 4d646bd..04bda4f 100644
--- a/libc/arch-mips/syscalls/sched_setparam.S
+++ b/libc/arch-mips/syscalls/sched_setparam.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sched_setparam
     .align 4
diff --git a/libc/arch-mips/syscalls/sched_setscheduler.S b/libc/arch-mips/syscalls/sched_setscheduler.S
index a79e39c..0c42759 100644
--- a/libc/arch-mips/syscalls/sched_setscheduler.S
+++ b/libc/arch-mips/syscalls/sched_setscheduler.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sched_setscheduler
     .align 4
diff --git a/libc/arch-mips/syscalls/sched_yield.S b/libc/arch-mips/syscalls/sched_yield.S
index c7c99dc..58f4796 100644
--- a/libc/arch-mips/syscalls/sched_yield.S
+++ b/libc/arch-mips/syscalls/sched_yield.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sched_yield
     .align 4
diff --git a/libc/arch-mips/syscalls/select.S b/libc/arch-mips/syscalls/select.S
index ce4112f..6f6431a 100644
--- a/libc/arch-mips/syscalls/select.S
+++ b/libc/arch-mips/syscalls/select.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl select
     .align 4
diff --git a/libc/arch-mips/syscalls/sendfile.S b/libc/arch-mips/syscalls/sendfile.S
index c4c176e..179801f 100644
--- a/libc/arch-mips/syscalls/sendfile.S
+++ b/libc/arch-mips/syscalls/sendfile.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sendfile
     .align 4
diff --git a/libc/arch-mips/syscalls/sendmsg.S b/libc/arch-mips/syscalls/sendmsg.S
index 1913f13..0341243 100644
--- a/libc/arch-mips/syscalls/sendmsg.S
+++ b/libc/arch-mips/syscalls/sendmsg.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sendmsg
     .align 4
diff --git a/libc/arch-mips/syscalls/sendto.S b/libc/arch-mips/syscalls/sendto.S
index f17743d..aea43e2 100644
--- a/libc/arch-mips/syscalls/sendto.S
+++ b/libc/arch-mips/syscalls/sendto.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sendto
     .align 4
diff --git a/libc/arch-mips/syscalls/setgid.S b/libc/arch-mips/syscalls/setgid.S
index 83dbfe5..81dfba7 100644
--- a/libc/arch-mips/syscalls/setgid.S
+++ b/libc/arch-mips/syscalls/setgid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl setgid
     .align 4
diff --git a/libc/arch-mips/syscalls/setgroups.S b/libc/arch-mips/syscalls/setgroups.S
index ef9327d..d2d69ed 100644
--- a/libc/arch-mips/syscalls/setgroups.S
+++ b/libc/arch-mips/syscalls/setgroups.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl setgroups
     .align 4
diff --git a/libc/arch-mips/syscalls/setitimer.S b/libc/arch-mips/syscalls/setitimer.S
index b042e07..7e63d91 100644
--- a/libc/arch-mips/syscalls/setitimer.S
+++ b/libc/arch-mips/syscalls/setitimer.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl setitimer
     .align 4
diff --git a/libc/arch-mips/syscalls/setpgid.S b/libc/arch-mips/syscalls/setpgid.S
index 2ddc828..2bc0c4b 100644
--- a/libc/arch-mips/syscalls/setpgid.S
+++ b/libc/arch-mips/syscalls/setpgid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl setpgid
     .align 4
diff --git a/libc/arch-mips/syscalls/setpriority.S b/libc/arch-mips/syscalls/setpriority.S
index 02550e9..996b8e1 100644
--- a/libc/arch-mips/syscalls/setpriority.S
+++ b/libc/arch-mips/syscalls/setpriority.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl setpriority
     .align 4
diff --git a/libc/arch-mips/syscalls/setregid.S b/libc/arch-mips/syscalls/setregid.S
index 619b3a1..dea7218 100644
--- a/libc/arch-mips/syscalls/setregid.S
+++ b/libc/arch-mips/syscalls/setregid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl setregid
     .align 4
diff --git a/libc/arch-mips/syscalls/setresgid.S b/libc/arch-mips/syscalls/setresgid.S
index 3ff94c7..a793385 100644
--- a/libc/arch-mips/syscalls/setresgid.S
+++ b/libc/arch-mips/syscalls/setresgid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl setresgid
     .align 4
diff --git a/libc/arch-mips/syscalls/setrlimit.S b/libc/arch-mips/syscalls/setrlimit.S
index 3ec37c5..b3d94a0 100644
--- a/libc/arch-mips/syscalls/setrlimit.S
+++ b/libc/arch-mips/syscalls/setrlimit.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl setrlimit
     .align 4
diff --git a/libc/arch-mips/syscalls/setsid.S b/libc/arch-mips/syscalls/setsid.S
index 2a09663..fc263b6 100644
--- a/libc/arch-mips/syscalls/setsid.S
+++ b/libc/arch-mips/syscalls/setsid.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl setsid
     .align 4
diff --git a/libc/arch-mips/syscalls/setsockopt.S b/libc/arch-mips/syscalls/setsockopt.S
index dc5e62f..a8232ae 100644
--- a/libc/arch-mips/syscalls/setsockopt.S
+++ b/libc/arch-mips/syscalls/setsockopt.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl setsockopt
     .align 4
diff --git a/libc/arch-mips/syscalls/settimeofday.S b/libc/arch-mips/syscalls/settimeofday.S
index f7c03ea..7a5a89e 100644
--- a/libc/arch-mips/syscalls/settimeofday.S
+++ b/libc/arch-mips/syscalls/settimeofday.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl settimeofday
     .align 4
diff --git a/libc/arch-mips/syscalls/setxattr.S b/libc/arch-mips/syscalls/setxattr.S
index baa78a4..0b2c052 100644
--- a/libc/arch-mips/syscalls/setxattr.S
+++ b/libc/arch-mips/syscalls/setxattr.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl setxattr
     .align 4
diff --git a/libc/arch-mips/syscalls/shutdown.S b/libc/arch-mips/syscalls/shutdown.S
index b80d99b..545c8f7 100644
--- a/libc/arch-mips/syscalls/shutdown.S
+++ b/libc/arch-mips/syscalls/shutdown.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl shutdown
     .align 4
diff --git a/libc/arch-mips/syscalls/sigaction.S b/libc/arch-mips/syscalls/sigaction.S
index 700da54..306bc2b 100644
--- a/libc/arch-mips/syscalls/sigaction.S
+++ b/libc/arch-mips/syscalls/sigaction.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sigaction
     .align 4
diff --git a/libc/arch-mips/syscalls/sigaltstack.S b/libc/arch-mips/syscalls/sigaltstack.S
index d2a4a9a..bd74428 100644
--- a/libc/arch-mips/syscalls/sigaltstack.S
+++ b/libc/arch-mips/syscalls/sigaltstack.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sigaltstack
     .align 4
diff --git a/libc/arch-mips/syscalls/signalfd4.S b/libc/arch-mips/syscalls/signalfd4.S
index 7e4082c..0039778 100644
--- a/libc/arch-mips/syscalls/signalfd4.S
+++ b/libc/arch-mips/syscalls/signalfd4.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl signalfd4
     .align 4
diff --git a/libc/arch-mips/syscalls/sigpending.S b/libc/arch-mips/syscalls/sigpending.S
index 68df4db..45baa4f 100644
--- a/libc/arch-mips/syscalls/sigpending.S
+++ b/libc/arch-mips/syscalls/sigpending.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sigpending
     .align 4
diff --git a/libc/arch-mips/syscalls/sigprocmask.S b/libc/arch-mips/syscalls/sigprocmask.S
index 17c01cb..a4049bb 100644
--- a/libc/arch-mips/syscalls/sigprocmask.S
+++ b/libc/arch-mips/syscalls/sigprocmask.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sigprocmask
     .align 4
diff --git a/libc/arch-mips/syscalls/socket.S b/libc/arch-mips/syscalls/socket.S
index e7d43f9..3423bb7 100644
--- a/libc/arch-mips/syscalls/socket.S
+++ b/libc/arch-mips/syscalls/socket.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl socket
     .align 4
diff --git a/libc/arch-mips/syscalls/socketpair.S b/libc/arch-mips/syscalls/socketpair.S
index 97c67af..fd2b2e1 100644
--- a/libc/arch-mips/syscalls/socketpair.S
+++ b/libc/arch-mips/syscalls/socketpair.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl socketpair
     .align 4
diff --git a/libc/arch-mips/syscalls/stat.S b/libc/arch-mips/syscalls/stat.S
index aec910d..9a12ba8 100644
--- a/libc/arch-mips/syscalls/stat.S
+++ b/libc/arch-mips/syscalls/stat.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl stat
     .align 4
diff --git a/libc/arch-mips/syscalls/symlink.S b/libc/arch-mips/syscalls/symlink.S
index f81c6dd..b74b545 100644
--- a/libc/arch-mips/syscalls/symlink.S
+++ b/libc/arch-mips/syscalls/symlink.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl symlink
     .align 4
diff --git a/libc/arch-mips/syscalls/sync.S b/libc/arch-mips/syscalls/sync.S
index a122873..1a9f981 100644
--- a/libc/arch-mips/syscalls/sync.S
+++ b/libc/arch-mips/syscalls/sync.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sync
     .align 4
diff --git a/libc/arch-mips/syscalls/syscall.S b/libc/arch-mips/syscalls/syscall.S
index 2192bd5..17b0835 100644
--- a/libc/arch-mips/syscalls/syscall.S
+++ b/libc/arch-mips/syscalls/syscall.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl syscall
     .align 4
diff --git a/libc/arch-mips/syscalls/sysinfo.S b/libc/arch-mips/syscalls/sysinfo.S
index 4577af9..ba0b121 100644
--- a/libc/arch-mips/syscalls/sysinfo.S
+++ b/libc/arch-mips/syscalls/sysinfo.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl sysinfo
     .align 4
diff --git a/libc/arch-mips/syscalls/tgkill.S b/libc/arch-mips/syscalls/tgkill.S
index 57b3a85..169ba79 100644
--- a/libc/arch-mips/syscalls/tgkill.S
+++ b/libc/arch-mips/syscalls/tgkill.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl tgkill
     .align 4
diff --git a/libc/arch-mips/syscalls/times.S b/libc/arch-mips/syscalls/times.S
index 3e8950d..e53cdb0 100644
--- a/libc/arch-mips/syscalls/times.S
+++ b/libc/arch-mips/syscalls/times.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl times
     .align 4
diff --git a/libc/arch-mips/syscalls/tkill.S b/libc/arch-mips/syscalls/tkill.S
index 3037baa..f1439cc 100644
--- a/libc/arch-mips/syscalls/tkill.S
+++ b/libc/arch-mips/syscalls/tkill.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl tkill
     .align 4
diff --git a/libc/arch-mips/syscalls/truncate.S b/libc/arch-mips/syscalls/truncate.S
index 4a8f12c..b16df81 100644
--- a/libc/arch-mips/syscalls/truncate.S
+++ b/libc/arch-mips/syscalls/truncate.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl truncate
     .align 4
diff --git a/libc/arch-mips/syscalls/umask.S b/libc/arch-mips/syscalls/umask.S
index eee911e..b952e69 100644
--- a/libc/arch-mips/syscalls/umask.S
+++ b/libc/arch-mips/syscalls/umask.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl umask
     .align 4
diff --git a/libc/arch-mips/syscalls/umount2.S b/libc/arch-mips/syscalls/umount2.S
index c6d9df6..1e5a0bb 100644
--- a/libc/arch-mips/syscalls/umount2.S
+++ b/libc/arch-mips/syscalls/umount2.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl umount2
     .align 4
diff --git a/libc/arch-mips/syscalls/uname.S b/libc/arch-mips/syscalls/uname.S
index 7e4f780..7bda6b8 100644
--- a/libc/arch-mips/syscalls/uname.S
+++ b/libc/arch-mips/syscalls/uname.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl uname
     .align 4
diff --git a/libc/arch-mips/syscalls/unlink.S b/libc/arch-mips/syscalls/unlink.S
index fd8dad9..e08bb3e 100644
--- a/libc/arch-mips/syscalls/unlink.S
+++ b/libc/arch-mips/syscalls/unlink.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl unlink
     .align 4
diff --git a/libc/arch-mips/syscalls/unlinkat.S b/libc/arch-mips/syscalls/unlinkat.S
index 793ab5e..0e09db1 100644
--- a/libc/arch-mips/syscalls/unlinkat.S
+++ b/libc/arch-mips/syscalls/unlinkat.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl unlinkat
     .align 4
diff --git a/libc/arch-mips/syscalls/unshare.S b/libc/arch-mips/syscalls/unshare.S
index 11af354..75bb6d6 100644
--- a/libc/arch-mips/syscalls/unshare.S
+++ b/libc/arch-mips/syscalls/unshare.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl unshare
     .align 4
diff --git a/libc/arch-mips/syscalls/utimensat.S b/libc/arch-mips/syscalls/utimensat.S
index 435c49e..0d00cf2 100644
--- a/libc/arch-mips/syscalls/utimensat.S
+++ b/libc/arch-mips/syscalls/utimensat.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl utimensat
     .align 4
diff --git a/libc/arch-mips/syscalls/utimes.S b/libc/arch-mips/syscalls/utimes.S
index 8ce1e44..85a5443 100644
--- a/libc/arch-mips/syscalls/utimes.S
+++ b/libc/arch-mips/syscalls/utimes.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl utimes
     .align 4
diff --git a/libc/arch-mips/syscalls/__wait4.S b/libc/arch-mips/syscalls/wait4.S
similarity index 72%
rename from libc/arch-mips/syscalls/__wait4.S
rename to libc/arch-mips/syscalls/wait4.S
index 713b7cb..368b5d5 100644
--- a/libc/arch-mips/syscalls/__wait4.S
+++ b/libc/arch-mips/syscalls/wait4.S
@@ -1,11 +1,11 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
-    .globl __wait4
+    .globl wait4
     .align 4
-    .ent __wait4
+    .ent wait4
 
-__wait4:
+wait4:
     .set noreorder
     .cpload $t9
     li $v0, __NR_wait4
@@ -19,4 +19,4 @@
     j $t9
     nop
     .set reorder
-    .end __wait4
+    .end wait4
diff --git a/libc/arch-mips/syscalls/write.S b/libc/arch-mips/syscalls/write.S
index a772ace..edcf356 100644
--- a/libc/arch-mips/syscalls/write.S
+++ b/libc/arch-mips/syscalls/write.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl write
     .align 4
diff --git a/libc/arch-mips/syscalls/writev.S b/libc/arch-mips/syscalls/writev.S
index bdacb42..48c0a69 100644
--- a/libc/arch-mips/syscalls/writev.S
+++ b/libc/arch-mips/syscalls/writev.S
@@ -1,5 +1,5 @@
 /* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl writev
     .align 4
diff --git a/libc/arch-x86/bionic/__get_tls.c b/libc/arch-x86/bionic/__get_tls.c
old mode 100755
new mode 100644
diff --git a/libc/arch-x86/bionic/__set_tls.c b/libc/arch-x86/bionic/__set_tls.c
old mode 100755
new mode 100644
diff --git a/libc/arch-x86/bionic/__stack_chk_fail_local.h b/libc/arch-x86/bionic/__stack_chk_fail_local.h
old mode 100755
new mode 100644
diff --git a/libc/arch-x86/bionic/_exit_with_stack_teardown.S b/libc/arch-x86/bionic/_exit_with_stack_teardown.S
index e2bb6ad..aad3f0b 100644
--- a/libc/arch-x86/bionic/_exit_with_stack_teardown.S
+++ b/libc/arch-x86/bionic/_exit_with_stack_teardown.S
@@ -1,5 +1,5 @@
+#include <asm/unistd.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 // void _exit_with_stack_teardown(void *stackBase, int stackSize, int *retCode)
 ENTRY(_exit_with_stack_teardown)
diff --git a/libc/arch-x86/bionic/clone.S b/libc/arch-x86/bionic/clone.S
index 80e3c75..457cb4a 100644
--- a/libc/arch-x86/bionic/clone.S
+++ b/libc/arch-x86/bionic/clone.S
@@ -1,5 +1,5 @@
+#include <asm/unistd.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 // int  __pthread_clone(void* (*fn)(void*), void* tls, int flags, void* arg);
 ENTRY(__pthread_clone)
diff --git a/libc/arch-x86/bionic/crtbegin.c b/libc/arch-x86/bionic/crtbegin.c
old mode 100755
new mode 100644
diff --git a/libc/arch-x86/bionic/crtbegin_so.c b/libc/arch-x86/bionic/crtbegin_so.c
old mode 100755
new mode 100644
diff --git a/libc/arch-x86/bionic/futex_x86.S b/libc/arch-x86/bionic/futex_x86.S
index 36a28e8..fa33758 100644
--- a/libc/arch-x86/bionic/futex_x86.S
+++ b/libc/arch-x86/bionic/futex_x86.S
@@ -1,5 +1,5 @@
+#include <asm/unistd.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 #define FUTEX_WAIT 0
 #define FUTEX_WAKE 1
diff --git a/libc/arch-x86/bionic/syscall.S b/libc/arch-x86/bionic/syscall.S
index ef816b6..4452da4 100644
--- a/libc/arch-x86/bionic/syscall.S
+++ b/libc/arch-x86/bionic/syscall.S
@@ -10,8 +10,8 @@
  *	%ebp: arg5                -   callee save
  */
 
+#include <asm/unistd.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(syscall)
     # Push the callee save registers.
diff --git a/libc/arch-x86/bionic/vfork.S b/libc/arch-x86/bionic/vfork.S
index 235be0c..7b62449 100644
--- a/libc/arch-x86/bionic/vfork.S
+++ b/libc/arch-x86/bionic/vfork.S
@@ -1,10 +1,5 @@
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
-
-#ifndef __NR_vfork
-#define __NR_vfork  190
-#endif
-
+#include <asm/unistd.h>
 
 /* Get rid of the stack modifications (popl/ret) after vfork() success.
  * vfork is VERY sneaky. One has to be very careful about what can be done
diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk
index e196c02..b4ad564 100644
--- a/libc/arch-x86/syscalls.mk
+++ b/libc/arch-x86/syscalls.mk
@@ -5,6 +5,7 @@
 syscall_src += arch-x86/syscalls/__fork.S
 syscall_src += arch-x86/syscalls/_waitpid.S
 syscall_src += arch-x86/syscalls/__waitid.S
+syscall_src += arch-x86/syscalls/wait4.S
 syscall_src += arch-x86/syscalls/__sys_clone.S
 syscall_src += arch-x86/syscalls/execve.S
 syscall_src += arch-x86/syscalls/__setuid.S
@@ -184,7 +185,6 @@
 syscall_src += arch-x86/syscalls/ioprio_set.S
 syscall_src += arch-x86/syscalls/ioprio_get.S
 syscall_src += arch-x86/syscalls/uname.S
-syscall_src += arch-x86/syscalls/__wait4.S
 syscall_src += arch-x86/syscalls/umask.S
 syscall_src += arch-x86/syscalls/__reboot.S
 syscall_src += arch-x86/syscalls/__syslog.S
diff --git a/libc/arch-x86/syscalls/__brk.S b/libc/arch-x86/syscalls/__brk.S
index f7a81ff..b26e187 100644
--- a/libc/arch-x86/syscalls/__brk.S
+++ b/libc/arch-x86/syscalls/__brk.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__brk)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_brk, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__fcntl.S b/libc/arch-x86/syscalls/__fcntl.S
index 9f74d86..328df24 100644
--- a/libc/arch-x86/syscalls/__fcntl.S
+++ b/libc/arch-x86/syscalls/__fcntl.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__fcntl)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_fcntl, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__fcntl64.S b/libc/arch-x86/syscalls/__fcntl64.S
index c59f490..b0fb981 100644
--- a/libc/arch-x86/syscalls/__fcntl64.S
+++ b/libc/arch-x86/syscalls/__fcntl64.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__fcntl64)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_fcntl64, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__fork.S b/libc/arch-x86/syscalls/__fork.S
index 557714d..98e00c8 100644
--- a/libc/arch-x86/syscalls/__fork.S
+++ b/libc/arch-x86/syscalls/__fork.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__fork)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_fork, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__fstatfs64.S b/libc/arch-x86/syscalls/__fstatfs64.S
index 9943362..aeb6863 100644
--- a/libc/arch-x86/syscalls/__fstatfs64.S
+++ b/libc/arch-x86/syscalls/__fstatfs64.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__fstatfs64)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_fstatfs64, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__getcpu.S b/libc/arch-x86/syscalls/__getcpu.S
index 152f5c8..f50782c 100644
--- a/libc/arch-x86/syscalls/__getcpu.S
+++ b/libc/arch-x86/syscalls/__getcpu.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__getcpu)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_getcpu, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__getcwd.S b/libc/arch-x86/syscalls/__getcwd.S
index 2e30d9b..9337342 100644
--- a/libc/arch-x86/syscalls/__getcwd.S
+++ b/libc/arch-x86/syscalls/__getcwd.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__getcwd)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_getcwd, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__getpriority.S b/libc/arch-x86/syscalls/__getpriority.S
index a015127..60fa3bb 100644
--- a/libc/arch-x86/syscalls/__getpriority.S
+++ b/libc/arch-x86/syscalls/__getpriority.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__getpriority)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_getpriority, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__ioctl.S b/libc/arch-x86/syscalls/__ioctl.S
index db85a19..0e8d189 100644
--- a/libc/arch-x86/syscalls/__ioctl.S
+++ b/libc/arch-x86/syscalls/__ioctl.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__ioctl)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_ioctl, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__llseek.S b/libc/arch-x86/syscalls/__llseek.S
index 7811f6b..b347886 100644
--- a/libc/arch-x86/syscalls/__llseek.S
+++ b/libc/arch-x86/syscalls/__llseek.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__llseek)
     pushl   %ebx
@@ -15,7 +16,7 @@
     mov     40(%esp), %edi
     movl    $__NR__llseek, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__mmap2.S b/libc/arch-x86/syscalls/__mmap2.S
index 535a891..010a989 100644
--- a/libc/arch-x86/syscalls/__mmap2.S
+++ b/libc/arch-x86/syscalls/__mmap2.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__mmap2)
     pushl   %ebx
@@ -17,7 +18,7 @@
     mov     48(%esp), %ebp
     movl    $__NR_mmap2, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__open.S b/libc/arch-x86/syscalls/__open.S
index b878231..87cda45 100644
--- a/libc/arch-x86/syscalls/__open.S
+++ b/libc/arch-x86/syscalls/__open.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__open)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_open, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__openat.S b/libc/arch-x86/syscalls/__openat.S
index faf8013..31db1dc 100644
--- a/libc/arch-x86/syscalls/__openat.S
+++ b/libc/arch-x86/syscalls/__openat.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__openat)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_openat, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__ptrace.S b/libc/arch-x86/syscalls/__ptrace.S
index f574cf0..1f143cc 100644
--- a/libc/arch-x86/syscalls/__ptrace.S
+++ b/libc/arch-x86/syscalls/__ptrace.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__ptrace)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_ptrace, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__reboot.S b/libc/arch-x86/syscalls/__reboot.S
index 626a955..a32e8a8 100644
--- a/libc/arch-x86/syscalls/__reboot.S
+++ b/libc/arch-x86/syscalls/__reboot.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__reboot)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_reboot, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__rt_sigaction.S b/libc/arch-x86/syscalls/__rt_sigaction.S
index ef9893b..957bca1 100644
--- a/libc/arch-x86/syscalls/__rt_sigaction.S
+++ b/libc/arch-x86/syscalls/__rt_sigaction.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__rt_sigaction)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_rt_sigaction, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__rt_sigprocmask.S b/libc/arch-x86/syscalls/__rt_sigprocmask.S
index 930c9b2..a23e079 100644
--- a/libc/arch-x86/syscalls/__rt_sigprocmask.S
+++ b/libc/arch-x86/syscalls/__rt_sigprocmask.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__rt_sigprocmask)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_rt_sigprocmask, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__rt_sigtimedwait.S b/libc/arch-x86/syscalls/__rt_sigtimedwait.S
index ba867f5..cf2b2a2 100644
--- a/libc/arch-x86/syscalls/__rt_sigtimedwait.S
+++ b/libc/arch-x86/syscalls/__rt_sigtimedwait.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__rt_sigtimedwait)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_rt_sigtimedwait, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__sched_getaffinity.S b/libc/arch-x86/syscalls/__sched_getaffinity.S
index 2a40b65..da9f08a 100644
--- a/libc/arch-x86/syscalls/__sched_getaffinity.S
+++ b/libc/arch-x86/syscalls/__sched_getaffinity.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__sched_getaffinity)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_sched_getaffinity, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__set_thread_area.S b/libc/arch-x86/syscalls/__set_thread_area.S
index dc4a561..37f41d0 100644
--- a/libc/arch-x86/syscalls/__set_thread_area.S
+++ b/libc/arch-x86/syscalls/__set_thread_area.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__set_thread_area)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_set_thread_area, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__setresuid.S b/libc/arch-x86/syscalls/__setresuid.S
index c604984..c16d2fb 100644
--- a/libc/arch-x86/syscalls/__setresuid.S
+++ b/libc/arch-x86/syscalls/__setresuid.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__setresuid)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_setresuid32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__setreuid.S b/libc/arch-x86/syscalls/__setreuid.S
index 5818739..2ba521d 100644
--- a/libc/arch-x86/syscalls/__setreuid.S
+++ b/libc/arch-x86/syscalls/__setreuid.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__setreuid)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_setreuid32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__setuid.S b/libc/arch-x86/syscalls/__setuid.S
index df578b8..092ceb0 100644
--- a/libc/arch-x86/syscalls/__setuid.S
+++ b/libc/arch-x86/syscalls/__setuid.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__setuid)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_setuid32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__sigsuspend.S b/libc/arch-x86/syscalls/__sigsuspend.S
index b09f872..c69665f 100644
--- a/libc/arch-x86/syscalls/__sigsuspend.S
+++ b/libc/arch-x86/syscalls/__sigsuspend.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__sigsuspend)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_sigsuspend, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__statfs64.S b/libc/arch-x86/syscalls/__statfs64.S
index 4f46bd7..58785ad 100644
--- a/libc/arch-x86/syscalls/__statfs64.S
+++ b/libc/arch-x86/syscalls/__statfs64.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__statfs64)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_statfs64, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__sys_clone.S b/libc/arch-x86/syscalls/__sys_clone.S
index a5ce170..17e7c3b 100644
--- a/libc/arch-x86/syscalls/__sys_clone.S
+++ b/libc/arch-x86/syscalls/__sys_clone.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__sys_clone)
     pushl   %ebx
@@ -15,7 +16,7 @@
     mov     40(%esp), %edi
     movl    $__NR_clone, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__syslog.S b/libc/arch-x86/syscalls/__syslog.S
index 9d36779..1216d75 100644
--- a/libc/arch-x86/syscalls/__syslog.S
+++ b/libc/arch-x86/syscalls/__syslog.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__syslog)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_syslog, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__timer_create.S b/libc/arch-x86/syscalls/__timer_create.S
index b319f1b..1817afc 100644
--- a/libc/arch-x86/syscalls/__timer_create.S
+++ b/libc/arch-x86/syscalls/__timer_create.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__timer_create)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_timer_create, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__timer_delete.S b/libc/arch-x86/syscalls/__timer_delete.S
index 7fb5930..1472a99 100644
--- a/libc/arch-x86/syscalls/__timer_delete.S
+++ b/libc/arch-x86/syscalls/__timer_delete.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__timer_delete)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_timer_delete, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__timer_getoverrun.S b/libc/arch-x86/syscalls/__timer_getoverrun.S
index 477a3d8..2204682 100644
--- a/libc/arch-x86/syscalls/__timer_getoverrun.S
+++ b/libc/arch-x86/syscalls/__timer_getoverrun.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__timer_getoverrun)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_timer_getoverrun, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__timer_gettime.S b/libc/arch-x86/syscalls/__timer_gettime.S
index ee5604d..e45e4ef 100644
--- a/libc/arch-x86/syscalls/__timer_gettime.S
+++ b/libc/arch-x86/syscalls/__timer_gettime.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__timer_gettime)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_timer_gettime, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__timer_settime.S b/libc/arch-x86/syscalls/__timer_settime.S
index 9758f61..71a9182 100644
--- a/libc/arch-x86/syscalls/__timer_settime.S
+++ b/libc/arch-x86/syscalls/__timer_settime.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__timer_settime)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_timer_settime, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__waitid.S b/libc/arch-x86/syscalls/__waitid.S
index 12f1ac8..2588b26 100644
--- a/libc/arch-x86/syscalls/__waitid.S
+++ b/libc/arch-x86/syscalls/__waitid.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(__waitid)
     pushl   %ebx
@@ -15,7 +16,7 @@
     mov     40(%esp), %edi
     movl    $__NR_waitid, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/_exit.S b/libc/arch-x86/syscalls/_exit.S
index e17f925..9ce3e71 100644
--- a/libc/arch-x86/syscalls/_exit.S
+++ b/libc/arch-x86/syscalls/_exit.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(_exit)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_exit_group, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/_exit_thread.S b/libc/arch-x86/syscalls/_exit_thread.S
index a371350..cc12916 100644
--- a/libc/arch-x86/syscalls/_exit_thread.S
+++ b/libc/arch-x86/syscalls/_exit_thread.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(_exit_thread)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_exit, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/_waitpid.S b/libc/arch-x86/syscalls/_waitpid.S
index 59bf20e..8ed7898 100644
--- a/libc/arch-x86/syscalls/_waitpid.S
+++ b/libc/arch-x86/syscalls/_waitpid.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(_waitpid)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_waitpid, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/accept.S b/libc/arch-x86/syscalls/accept.S
index f5fcb5d..5678205 100644
--- a/libc/arch-x86/syscalls/accept.S
+++ b/libc/arch-x86/syscalls/accept.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(accept)
     pushl   %ebx
@@ -10,7 +11,7 @@
     addl    $12, %ecx
     movl    $__NR_socketcall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/access.S b/libc/arch-x86/syscalls/access.S
index 0f68574..a21ec43 100644
--- a/libc/arch-x86/syscalls/access.S
+++ b/libc/arch-x86/syscalls/access.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(access)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_access, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/acct.S b/libc/arch-x86/syscalls/acct.S
index bf991d6..d5d2a1a 100644
--- a/libc/arch-x86/syscalls/acct.S
+++ b/libc/arch-x86/syscalls/acct.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(acct)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_acct, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/bind.S b/libc/arch-x86/syscalls/bind.S
index ff6ae9f..77a4f12 100644
--- a/libc/arch-x86/syscalls/bind.S
+++ b/libc/arch-x86/syscalls/bind.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(bind)
     pushl   %ebx
@@ -10,7 +11,7 @@
     addl    $12, %ecx
     movl    $__NR_socketcall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/capget.S b/libc/arch-x86/syscalls/capget.S
index 55960f1..f563ce6 100644
--- a/libc/arch-x86/syscalls/capget.S
+++ b/libc/arch-x86/syscalls/capget.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(capget)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_capget, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/capset.S b/libc/arch-x86/syscalls/capset.S
index c8703c7..7ab426b 100644
--- a/libc/arch-x86/syscalls/capset.S
+++ b/libc/arch-x86/syscalls/capset.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(capset)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_capset, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/chdir.S b/libc/arch-x86/syscalls/chdir.S
index d40d099..bab9614 100644
--- a/libc/arch-x86/syscalls/chdir.S
+++ b/libc/arch-x86/syscalls/chdir.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(chdir)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_chdir, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/chmod.S b/libc/arch-x86/syscalls/chmod.S
index 307e196..a3d22c7 100644
--- a/libc/arch-x86/syscalls/chmod.S
+++ b/libc/arch-x86/syscalls/chmod.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(chmod)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_chmod, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/chown.S b/libc/arch-x86/syscalls/chown.S
index 800bf04..48c2b23 100644
--- a/libc/arch-x86/syscalls/chown.S
+++ b/libc/arch-x86/syscalls/chown.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(chown)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_chown32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/chroot.S b/libc/arch-x86/syscalls/chroot.S
index 24d2d10..ea640e6 100644
--- a/libc/arch-x86/syscalls/chroot.S
+++ b/libc/arch-x86/syscalls/chroot.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(chroot)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_chroot, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/clock_getres.S b/libc/arch-x86/syscalls/clock_getres.S
index da332aa..806b7e4 100644
--- a/libc/arch-x86/syscalls/clock_getres.S
+++ b/libc/arch-x86/syscalls/clock_getres.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(clock_getres)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_clock_getres, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/clock_gettime.S b/libc/arch-x86/syscalls/clock_gettime.S
index 41ac5e2..2f87d12 100644
--- a/libc/arch-x86/syscalls/clock_gettime.S
+++ b/libc/arch-x86/syscalls/clock_gettime.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(clock_gettime)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_clock_gettime, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/clock_nanosleep.S b/libc/arch-x86/syscalls/clock_nanosleep.S
index cd163df..d691301 100644
--- a/libc/arch-x86/syscalls/clock_nanosleep.S
+++ b/libc/arch-x86/syscalls/clock_nanosleep.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(clock_nanosleep)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_clock_nanosleep, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/clock_settime.S b/libc/arch-x86/syscalls/clock_settime.S
index 18237c4..a13b20a 100644
--- a/libc/arch-x86/syscalls/clock_settime.S
+++ b/libc/arch-x86/syscalls/clock_settime.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(clock_settime)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_clock_settime, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/close.S b/libc/arch-x86/syscalls/close.S
index 76175c7..0e80403 100644
--- a/libc/arch-x86/syscalls/close.S
+++ b/libc/arch-x86/syscalls/close.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(close)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_close, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/connect.S b/libc/arch-x86/syscalls/connect.S
index e87b123..f55d31c 100644
--- a/libc/arch-x86/syscalls/connect.S
+++ b/libc/arch-x86/syscalls/connect.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(connect)
     pushl   %ebx
@@ -10,7 +11,7 @@
     addl    $12, %ecx
     movl    $__NR_socketcall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/delete_module.S b/libc/arch-x86/syscalls/delete_module.S
index 10a06a3..a319310 100644
--- a/libc/arch-x86/syscalls/delete_module.S
+++ b/libc/arch-x86/syscalls/delete_module.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(delete_module)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_delete_module, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/dup.S b/libc/arch-x86/syscalls/dup.S
index 80259fe..7304681 100644
--- a/libc/arch-x86/syscalls/dup.S
+++ b/libc/arch-x86/syscalls/dup.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(dup)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_dup, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/dup2.S b/libc/arch-x86/syscalls/dup2.S
index 43def66..d6cee81 100644
--- a/libc/arch-x86/syscalls/dup2.S
+++ b/libc/arch-x86/syscalls/dup2.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(dup2)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_dup2, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/epoll_create.S b/libc/arch-x86/syscalls/epoll_create.S
index 0bdc885..061f173 100644
--- a/libc/arch-x86/syscalls/epoll_create.S
+++ b/libc/arch-x86/syscalls/epoll_create.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(epoll_create)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_epoll_create, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/epoll_ctl.S b/libc/arch-x86/syscalls/epoll_ctl.S
index 43175d2..5228da3 100644
--- a/libc/arch-x86/syscalls/epoll_ctl.S
+++ b/libc/arch-x86/syscalls/epoll_ctl.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(epoll_ctl)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_epoll_ctl, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/epoll_wait.S b/libc/arch-x86/syscalls/epoll_wait.S
index e2d61c0..e395a5e 100644
--- a/libc/arch-x86/syscalls/epoll_wait.S
+++ b/libc/arch-x86/syscalls/epoll_wait.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(epoll_wait)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_epoll_wait, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/eventfd.S b/libc/arch-x86/syscalls/eventfd.S
index 338696f..4e96a7b 100644
--- a/libc/arch-x86/syscalls/eventfd.S
+++ b/libc/arch-x86/syscalls/eventfd.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(eventfd)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_eventfd2, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/execve.S b/libc/arch-x86/syscalls/execve.S
index c7e3ca5..3028e8f 100644
--- a/libc/arch-x86/syscalls/execve.S
+++ b/libc/arch-x86/syscalls/execve.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(execve)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_execve, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/faccessat.S b/libc/arch-x86/syscalls/faccessat.S
index 6733029..c7c3b20 100644
--- a/libc/arch-x86/syscalls/faccessat.S
+++ b/libc/arch-x86/syscalls/faccessat.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(faccessat)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_faccessat, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/fchdir.S b/libc/arch-x86/syscalls/fchdir.S
index 23aa6e2..2d6a4fd 100644
--- a/libc/arch-x86/syscalls/fchdir.S
+++ b/libc/arch-x86/syscalls/fchdir.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(fchdir)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_fchdir, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/fchmod.S b/libc/arch-x86/syscalls/fchmod.S
index 019eb07..d1e2b1b 100644
--- a/libc/arch-x86/syscalls/fchmod.S
+++ b/libc/arch-x86/syscalls/fchmod.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(fchmod)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_fchmod, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/fchmodat.S b/libc/arch-x86/syscalls/fchmodat.S
index f7292f9..b46522b 100644
--- a/libc/arch-x86/syscalls/fchmodat.S
+++ b/libc/arch-x86/syscalls/fchmodat.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(fchmodat)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_fchmodat, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/fchown.S b/libc/arch-x86/syscalls/fchown.S
index f17c0d6..d09f965 100644
--- a/libc/arch-x86/syscalls/fchown.S
+++ b/libc/arch-x86/syscalls/fchown.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(fchown)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_fchown32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/fchownat.S b/libc/arch-x86/syscalls/fchownat.S
index 7648d79..ad958db 100644
--- a/libc/arch-x86/syscalls/fchownat.S
+++ b/libc/arch-x86/syscalls/fchownat.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(fchownat)
     pushl   %ebx
@@ -15,7 +16,7 @@
     mov     40(%esp), %edi
     movl    $__NR_fchownat, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/fdatasync.S b/libc/arch-x86/syscalls/fdatasync.S
index 2808e0f..7b912aa 100644
--- a/libc/arch-x86/syscalls/fdatasync.S
+++ b/libc/arch-x86/syscalls/fdatasync.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(fdatasync)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_fdatasync, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/fgetxattr.S b/libc/arch-x86/syscalls/fgetxattr.S
index beaab09..e81c257 100644
--- a/libc/arch-x86/syscalls/fgetxattr.S
+++ b/libc/arch-x86/syscalls/fgetxattr.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(fgetxattr)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_fgetxattr, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/flistxattr.S b/libc/arch-x86/syscalls/flistxattr.S
index 95935c0..2d398d1 100644
--- a/libc/arch-x86/syscalls/flistxattr.S
+++ b/libc/arch-x86/syscalls/flistxattr.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(flistxattr)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_flistxattr, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/flock.S b/libc/arch-x86/syscalls/flock.S
index 156844c..cad1420 100644
--- a/libc/arch-x86/syscalls/flock.S
+++ b/libc/arch-x86/syscalls/flock.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(flock)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_flock, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/fremovexattr.S b/libc/arch-x86/syscalls/fremovexattr.S
index 32d0bdc..837efb8 100644
--- a/libc/arch-x86/syscalls/fremovexattr.S
+++ b/libc/arch-x86/syscalls/fremovexattr.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(fremovexattr)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_fremovexattr, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/fsetxattr.S b/libc/arch-x86/syscalls/fsetxattr.S
index c3d588e..ae0e0f8 100644
--- a/libc/arch-x86/syscalls/fsetxattr.S
+++ b/libc/arch-x86/syscalls/fsetxattr.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(fsetxattr)
     pushl   %ebx
@@ -15,7 +16,7 @@
     mov     40(%esp), %edi
     movl    $__NR_fsetxattr, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/fstat.S b/libc/arch-x86/syscalls/fstat.S
index 95301d9..4fd1d5a 100644
--- a/libc/arch-x86/syscalls/fstat.S
+++ b/libc/arch-x86/syscalls/fstat.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(fstat)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_fstat64, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/fstatat.S b/libc/arch-x86/syscalls/fstatat.S
index 947f4da..f07b405 100644
--- a/libc/arch-x86/syscalls/fstatat.S
+++ b/libc/arch-x86/syscalls/fstatat.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(fstatat)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_fstatat64, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/fsync.S b/libc/arch-x86/syscalls/fsync.S
index 363b334..f9e4bc3 100644
--- a/libc/arch-x86/syscalls/fsync.S
+++ b/libc/arch-x86/syscalls/fsync.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(fsync)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_fsync, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/ftruncate.S b/libc/arch-x86/syscalls/ftruncate.S
index 1ed3f96..9d27c14 100644
--- a/libc/arch-x86/syscalls/ftruncate.S
+++ b/libc/arch-x86/syscalls/ftruncate.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(ftruncate)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_ftruncate, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/ftruncate64.S b/libc/arch-x86/syscalls/ftruncate64.S
index fa6dbef..a121add 100644
--- a/libc/arch-x86/syscalls/ftruncate64.S
+++ b/libc/arch-x86/syscalls/ftruncate64.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(ftruncate64)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_ftruncate64, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/futex.S b/libc/arch-x86/syscalls/futex.S
index f72be1b..7f0684f 100644
--- a/libc/arch-x86/syscalls/futex.S
+++ b/libc/arch-x86/syscalls/futex.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(futex)
     pushl   %ebx
@@ -17,7 +18,7 @@
     mov     48(%esp), %ebp
     movl    $__NR_futex, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getdents.S b/libc/arch-x86/syscalls/getdents.S
index c5d2721..c17a5a7 100644
--- a/libc/arch-x86/syscalls/getdents.S
+++ b/libc/arch-x86/syscalls/getdents.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getdents)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_getdents64, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getegid.S b/libc/arch-x86/syscalls/getegid.S
index c26ebc2..0f055e1 100644
--- a/libc/arch-x86/syscalls/getegid.S
+++ b/libc/arch-x86/syscalls/getegid.S
@@ -1,11 +1,12 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getegid)
     movl    $__NR_getegid32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/geteuid.S b/libc/arch-x86/syscalls/geteuid.S
index a7761e8..a308137 100644
--- a/libc/arch-x86/syscalls/geteuid.S
+++ b/libc/arch-x86/syscalls/geteuid.S
@@ -1,11 +1,12 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(geteuid)
     movl    $__NR_geteuid32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getgid.S b/libc/arch-x86/syscalls/getgid.S
index 7a51200..0b43991 100644
--- a/libc/arch-x86/syscalls/getgid.S
+++ b/libc/arch-x86/syscalls/getgid.S
@@ -1,11 +1,12 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getgid)
     movl    $__NR_getgid32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getgroups.S b/libc/arch-x86/syscalls/getgroups.S
index 35bc3f5..c92a692 100644
--- a/libc/arch-x86/syscalls/getgroups.S
+++ b/libc/arch-x86/syscalls/getgroups.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getgroups)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_getgroups32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getitimer.S b/libc/arch-x86/syscalls/getitimer.S
index 79957da..04f01c0 100644
--- a/libc/arch-x86/syscalls/getitimer.S
+++ b/libc/arch-x86/syscalls/getitimer.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getitimer)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_getitimer, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getpeername.S b/libc/arch-x86/syscalls/getpeername.S
index 3831990..1a385ad 100644
--- a/libc/arch-x86/syscalls/getpeername.S
+++ b/libc/arch-x86/syscalls/getpeername.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getpeername)
     pushl   %ebx
@@ -10,7 +11,7 @@
     addl    $12, %ecx
     movl    $__NR_socketcall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getpgid.S b/libc/arch-x86/syscalls/getpgid.S
index f49abbf..d1a8d26 100644
--- a/libc/arch-x86/syscalls/getpgid.S
+++ b/libc/arch-x86/syscalls/getpgid.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getpgid)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_getpgid, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getpid.S b/libc/arch-x86/syscalls/getpid.S
index 29703e8..f9e3613 100644
--- a/libc/arch-x86/syscalls/getpid.S
+++ b/libc/arch-x86/syscalls/getpid.S
@@ -1,11 +1,12 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getpid)
     movl    $__NR_getpid, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getppid.S b/libc/arch-x86/syscalls/getppid.S
index dc89d6e..afbc81a 100644
--- a/libc/arch-x86/syscalls/getppid.S
+++ b/libc/arch-x86/syscalls/getppid.S
@@ -1,11 +1,12 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getppid)
     movl    $__NR_getppid, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getresgid.S b/libc/arch-x86/syscalls/getresgid.S
index 08a37e7..c1adb5c 100644
--- a/libc/arch-x86/syscalls/getresgid.S
+++ b/libc/arch-x86/syscalls/getresgid.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getresgid)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_getresgid32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getresuid.S b/libc/arch-x86/syscalls/getresuid.S
index 435a901..4bbf637 100644
--- a/libc/arch-x86/syscalls/getresuid.S
+++ b/libc/arch-x86/syscalls/getresuid.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getresuid)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_getresuid32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getrlimit.S b/libc/arch-x86/syscalls/getrlimit.S
index 8f6edd6..09b2fd5 100644
--- a/libc/arch-x86/syscalls/getrlimit.S
+++ b/libc/arch-x86/syscalls/getrlimit.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getrlimit)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_ugetrlimit, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getrusage.S b/libc/arch-x86/syscalls/getrusage.S
index ee47f3d..f180213 100644
--- a/libc/arch-x86/syscalls/getrusage.S
+++ b/libc/arch-x86/syscalls/getrusage.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getrusage)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_getrusage, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getsid.S b/libc/arch-x86/syscalls/getsid.S
index 876bf6a..5b1a32f 100644
--- a/libc/arch-x86/syscalls/getsid.S
+++ b/libc/arch-x86/syscalls/getsid.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getsid)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_getsid, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getsockname.S b/libc/arch-x86/syscalls/getsockname.S
index b28ecb8..9e7cec1 100644
--- a/libc/arch-x86/syscalls/getsockname.S
+++ b/libc/arch-x86/syscalls/getsockname.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getsockname)
     pushl   %ebx
@@ -10,7 +11,7 @@
     addl    $12, %ecx
     movl    $__NR_socketcall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getsockopt.S b/libc/arch-x86/syscalls/getsockopt.S
index 190b6f2..c210749 100644
--- a/libc/arch-x86/syscalls/getsockopt.S
+++ b/libc/arch-x86/syscalls/getsockopt.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getsockopt)
     pushl   %ebx
@@ -10,7 +11,7 @@
     addl    $12, %ecx
     movl    $__NR_socketcall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/gettid.S b/libc/arch-x86/syscalls/gettid.S
index c1e6ba0..d14f320 100644
--- a/libc/arch-x86/syscalls/gettid.S
+++ b/libc/arch-x86/syscalls/gettid.S
@@ -1,11 +1,12 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(gettid)
     movl    $__NR_gettid, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/gettimeofday.S b/libc/arch-x86/syscalls/gettimeofday.S
index 34b9982..2fa118d 100644
--- a/libc/arch-x86/syscalls/gettimeofday.S
+++ b/libc/arch-x86/syscalls/gettimeofday.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(gettimeofday)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_gettimeofday, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getuid.S b/libc/arch-x86/syscalls/getuid.S
index e82b8b0..08b9cce 100644
--- a/libc/arch-x86/syscalls/getuid.S
+++ b/libc/arch-x86/syscalls/getuid.S
@@ -1,11 +1,12 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getuid)
     movl    $__NR_getuid32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/getxattr.S b/libc/arch-x86/syscalls/getxattr.S
index 92f7c30..64990ef 100644
--- a/libc/arch-x86/syscalls/getxattr.S
+++ b/libc/arch-x86/syscalls/getxattr.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(getxattr)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_getxattr, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/init_module.S b/libc/arch-x86/syscalls/init_module.S
index 3ef9b36..9d1daad 100644
--- a/libc/arch-x86/syscalls/init_module.S
+++ b/libc/arch-x86/syscalls/init_module.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(init_module)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_init_module, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/inotify_add_watch.S b/libc/arch-x86/syscalls/inotify_add_watch.S
index 7b57f3c..fc9c087 100644
--- a/libc/arch-x86/syscalls/inotify_add_watch.S
+++ b/libc/arch-x86/syscalls/inotify_add_watch.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(inotify_add_watch)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_inotify_add_watch, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/inotify_init.S b/libc/arch-x86/syscalls/inotify_init.S
index c19174b..ffc4a2a 100644
--- a/libc/arch-x86/syscalls/inotify_init.S
+++ b/libc/arch-x86/syscalls/inotify_init.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(inotify_init)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_inotify_init, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/inotify_rm_watch.S b/libc/arch-x86/syscalls/inotify_rm_watch.S
index 351bdc2..08d208c 100644
--- a/libc/arch-x86/syscalls/inotify_rm_watch.S
+++ b/libc/arch-x86/syscalls/inotify_rm_watch.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(inotify_rm_watch)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_inotify_rm_watch, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/ioprio_get.S b/libc/arch-x86/syscalls/ioprio_get.S
index b64662f..63f1111 100644
--- a/libc/arch-x86/syscalls/ioprio_get.S
+++ b/libc/arch-x86/syscalls/ioprio_get.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(ioprio_get)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_ioprio_get, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/ioprio_set.S b/libc/arch-x86/syscalls/ioprio_set.S
index 6f2a4f3..2b4d87e 100644
--- a/libc/arch-x86/syscalls/ioprio_set.S
+++ b/libc/arch-x86/syscalls/ioprio_set.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(ioprio_set)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_ioprio_set, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/kill.S b/libc/arch-x86/syscalls/kill.S
index 99fe9a9..260fe73 100644
--- a/libc/arch-x86/syscalls/kill.S
+++ b/libc/arch-x86/syscalls/kill.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(kill)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_kill, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/klogctl.S b/libc/arch-x86/syscalls/klogctl.S
index e9f8b79..32db1af 100644
--- a/libc/arch-x86/syscalls/klogctl.S
+++ b/libc/arch-x86/syscalls/klogctl.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(klogctl)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_syslog, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/lchown.S b/libc/arch-x86/syscalls/lchown.S
index 779f703..9bd1c9a 100644
--- a/libc/arch-x86/syscalls/lchown.S
+++ b/libc/arch-x86/syscalls/lchown.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(lchown)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_lchown32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/lgetxattr.S b/libc/arch-x86/syscalls/lgetxattr.S
index 3781bff..bb5a7ba 100644
--- a/libc/arch-x86/syscalls/lgetxattr.S
+++ b/libc/arch-x86/syscalls/lgetxattr.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(lgetxattr)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_lgetxattr, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/link.S b/libc/arch-x86/syscalls/link.S
index dac7d0e..4419149 100644
--- a/libc/arch-x86/syscalls/link.S
+++ b/libc/arch-x86/syscalls/link.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(link)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_link, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/listen.S b/libc/arch-x86/syscalls/listen.S
index 8f63945..0c4d6b0 100644
--- a/libc/arch-x86/syscalls/listen.S
+++ b/libc/arch-x86/syscalls/listen.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(listen)
     pushl   %ebx
@@ -10,7 +11,7 @@
     addl    $12, %ecx
     movl    $__NR_socketcall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/listxattr.S b/libc/arch-x86/syscalls/listxattr.S
index 853c47b..059c2aa 100644
--- a/libc/arch-x86/syscalls/listxattr.S
+++ b/libc/arch-x86/syscalls/listxattr.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(listxattr)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_listxattr, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/llistxattr.S b/libc/arch-x86/syscalls/llistxattr.S
index cd7038b..a6023eb 100644
--- a/libc/arch-x86/syscalls/llistxattr.S
+++ b/libc/arch-x86/syscalls/llistxattr.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(llistxattr)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_llistxattr, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/lremovexattr.S b/libc/arch-x86/syscalls/lremovexattr.S
index 93973d6..2bfd91b 100644
--- a/libc/arch-x86/syscalls/lremovexattr.S
+++ b/libc/arch-x86/syscalls/lremovexattr.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(lremovexattr)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_lremovexattr, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/lseek.S b/libc/arch-x86/syscalls/lseek.S
index f6250e6..d7b3b19 100644
--- a/libc/arch-x86/syscalls/lseek.S
+++ b/libc/arch-x86/syscalls/lseek.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(lseek)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_lseek, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/lsetxattr.S b/libc/arch-x86/syscalls/lsetxattr.S
index c5dbc30..05790e7 100644
--- a/libc/arch-x86/syscalls/lsetxattr.S
+++ b/libc/arch-x86/syscalls/lsetxattr.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(lsetxattr)
     pushl   %ebx
@@ -15,7 +16,7 @@
     mov     40(%esp), %edi
     movl    $__NR_lsetxattr, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/lstat.S b/libc/arch-x86/syscalls/lstat.S
index 4e25fae..7b8187e 100644
--- a/libc/arch-x86/syscalls/lstat.S
+++ b/libc/arch-x86/syscalls/lstat.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(lstat)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_lstat64, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/madvise.S b/libc/arch-x86/syscalls/madvise.S
index bf3e5dc..bf8b518 100644
--- a/libc/arch-x86/syscalls/madvise.S
+++ b/libc/arch-x86/syscalls/madvise.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(madvise)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_madvise, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/mincore.S b/libc/arch-x86/syscalls/mincore.S
index 37df639..42a612a 100644
--- a/libc/arch-x86/syscalls/mincore.S
+++ b/libc/arch-x86/syscalls/mincore.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(mincore)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_mincore, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/mkdir.S b/libc/arch-x86/syscalls/mkdir.S
index 16a5c03..d8cdbd4 100644
--- a/libc/arch-x86/syscalls/mkdir.S
+++ b/libc/arch-x86/syscalls/mkdir.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(mkdir)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_mkdir, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/mkdirat.S b/libc/arch-x86/syscalls/mkdirat.S
index ece2c27..844a2b9 100644
--- a/libc/arch-x86/syscalls/mkdirat.S
+++ b/libc/arch-x86/syscalls/mkdirat.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(mkdirat)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_mkdirat, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/mknod.S b/libc/arch-x86/syscalls/mknod.S
index 22fc390..eebef21 100644
--- a/libc/arch-x86/syscalls/mknod.S
+++ b/libc/arch-x86/syscalls/mknod.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(mknod)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_mknod, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/mlock.S b/libc/arch-x86/syscalls/mlock.S
index 5010e00..9c91682 100644
--- a/libc/arch-x86/syscalls/mlock.S
+++ b/libc/arch-x86/syscalls/mlock.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(mlock)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_mlock, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/mlockall.S b/libc/arch-x86/syscalls/mlockall.S
index 849b44f..6bf571b 100644
--- a/libc/arch-x86/syscalls/mlockall.S
+++ b/libc/arch-x86/syscalls/mlockall.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(mlockall)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_mlockall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/mount.S b/libc/arch-x86/syscalls/mount.S
index 9ceeab9..255f223 100644
--- a/libc/arch-x86/syscalls/mount.S
+++ b/libc/arch-x86/syscalls/mount.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(mount)
     pushl   %ebx
@@ -15,7 +16,7 @@
     mov     40(%esp), %edi
     movl    $__NR_mount, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/mprotect.S b/libc/arch-x86/syscalls/mprotect.S
index 4438bfe..c2b6a0f 100644
--- a/libc/arch-x86/syscalls/mprotect.S
+++ b/libc/arch-x86/syscalls/mprotect.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(mprotect)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_mprotect, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/mremap.S b/libc/arch-x86/syscalls/mremap.S
index d33a8dc..6c366dc 100644
--- a/libc/arch-x86/syscalls/mremap.S
+++ b/libc/arch-x86/syscalls/mremap.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(mremap)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_mremap, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/msync.S b/libc/arch-x86/syscalls/msync.S
index 2da5bc7..15b052d 100644
--- a/libc/arch-x86/syscalls/msync.S
+++ b/libc/arch-x86/syscalls/msync.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(msync)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_msync, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/munlock.S b/libc/arch-x86/syscalls/munlock.S
index 574d17b..1c7db58 100644
--- a/libc/arch-x86/syscalls/munlock.S
+++ b/libc/arch-x86/syscalls/munlock.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(munlock)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_munlock, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/munlockall.S b/libc/arch-x86/syscalls/munlockall.S
index f69316a..9e38a91 100644
--- a/libc/arch-x86/syscalls/munlockall.S
+++ b/libc/arch-x86/syscalls/munlockall.S
@@ -1,11 +1,12 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(munlockall)
     movl    $__NR_munlockall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/munmap.S b/libc/arch-x86/syscalls/munmap.S
index 91c73c1..a62eb92 100644
--- a/libc/arch-x86/syscalls/munmap.S
+++ b/libc/arch-x86/syscalls/munmap.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(munmap)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_munmap, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/nanosleep.S b/libc/arch-x86/syscalls/nanosleep.S
index 6d2df08..8cf0d8f 100644
--- a/libc/arch-x86/syscalls/nanosleep.S
+++ b/libc/arch-x86/syscalls/nanosleep.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(nanosleep)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_nanosleep, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/pause.S b/libc/arch-x86/syscalls/pause.S
index 70be691..ff9d76c 100644
--- a/libc/arch-x86/syscalls/pause.S
+++ b/libc/arch-x86/syscalls/pause.S
@@ -1,11 +1,12 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(pause)
     movl    $__NR_pause, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/perf_event_open.S b/libc/arch-x86/syscalls/perf_event_open.S
index 6466b45..fa39a2a 100644
--- a/libc/arch-x86/syscalls/perf_event_open.S
+++ b/libc/arch-x86/syscalls/perf_event_open.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(perf_event_open)
     pushl   %ebx
@@ -15,7 +16,7 @@
     mov     40(%esp), %edi
     movl    $__NR_perf_event_open, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/personality.S b/libc/arch-x86/syscalls/personality.S
index b23b592..045f3de 100644
--- a/libc/arch-x86/syscalls/personality.S
+++ b/libc/arch-x86/syscalls/personality.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(personality)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_personality, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/pipe.S b/libc/arch-x86/syscalls/pipe.S
index 1560bad..b906e6d 100644
--- a/libc/arch-x86/syscalls/pipe.S
+++ b/libc/arch-x86/syscalls/pipe.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(pipe)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_pipe, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/pipe2.S b/libc/arch-x86/syscalls/pipe2.S
index 55fe08f..bf3ccf6 100644
--- a/libc/arch-x86/syscalls/pipe2.S
+++ b/libc/arch-x86/syscalls/pipe2.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(pipe2)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_pipe2, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/poll.S b/libc/arch-x86/syscalls/poll.S
index 541d657..3261857 100644
--- a/libc/arch-x86/syscalls/poll.S
+++ b/libc/arch-x86/syscalls/poll.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(poll)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_poll, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/prctl.S b/libc/arch-x86/syscalls/prctl.S
index 56720fe..bcaf2d8 100644
--- a/libc/arch-x86/syscalls/prctl.S
+++ b/libc/arch-x86/syscalls/prctl.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(prctl)
     pushl   %ebx
@@ -15,7 +16,7 @@
     mov     40(%esp), %edi
     movl    $__NR_prctl, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/pread64.S b/libc/arch-x86/syscalls/pread64.S
index 987e9b8..b9fcb54 100644
--- a/libc/arch-x86/syscalls/pread64.S
+++ b/libc/arch-x86/syscalls/pread64.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(pread64)
     pushl   %ebx
@@ -15,7 +16,7 @@
     mov     40(%esp), %edi
     movl    $__NR_pread64, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/pwrite64.S b/libc/arch-x86/syscalls/pwrite64.S
index 8773a20..f689cc6 100644
--- a/libc/arch-x86/syscalls/pwrite64.S
+++ b/libc/arch-x86/syscalls/pwrite64.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(pwrite64)
     pushl   %ebx
@@ -15,7 +16,7 @@
     mov     40(%esp), %edi
     movl    $__NR_pwrite64, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/read.S b/libc/arch-x86/syscalls/read.S
index 98b7c12..bccc1bb 100644
--- a/libc/arch-x86/syscalls/read.S
+++ b/libc/arch-x86/syscalls/read.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(read)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_read, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/readahead.S b/libc/arch-x86/syscalls/readahead.S
index b0c0018..e72cc7a 100644
--- a/libc/arch-x86/syscalls/readahead.S
+++ b/libc/arch-x86/syscalls/readahead.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(readahead)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_readahead, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/readlink.S b/libc/arch-x86/syscalls/readlink.S
index 393b5d4..7444728 100644
--- a/libc/arch-x86/syscalls/readlink.S
+++ b/libc/arch-x86/syscalls/readlink.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(readlink)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_readlink, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/readv.S b/libc/arch-x86/syscalls/readv.S
index d626068..6ff3002 100644
--- a/libc/arch-x86/syscalls/readv.S
+++ b/libc/arch-x86/syscalls/readv.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(readv)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_readv, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/recvfrom.S b/libc/arch-x86/syscalls/recvfrom.S
index 98558e1..f3d9d6a 100644
--- a/libc/arch-x86/syscalls/recvfrom.S
+++ b/libc/arch-x86/syscalls/recvfrom.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(recvfrom)
     pushl   %ebx
@@ -10,7 +11,7 @@
     addl    $12, %ecx
     movl    $__NR_socketcall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/recvmsg.S b/libc/arch-x86/syscalls/recvmsg.S
index 8b3c7bd..9c4f9e2 100644
--- a/libc/arch-x86/syscalls/recvmsg.S
+++ b/libc/arch-x86/syscalls/recvmsg.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(recvmsg)
     pushl   %ebx
@@ -10,7 +11,7 @@
     addl    $12, %ecx
     movl    $__NR_socketcall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/removexattr.S b/libc/arch-x86/syscalls/removexattr.S
index e2211e8..a086eb7 100644
--- a/libc/arch-x86/syscalls/removexattr.S
+++ b/libc/arch-x86/syscalls/removexattr.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(removexattr)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_removexattr, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/rename.S b/libc/arch-x86/syscalls/rename.S
index 43be210..9f40818 100644
--- a/libc/arch-x86/syscalls/rename.S
+++ b/libc/arch-x86/syscalls/rename.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(rename)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_rename, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/renameat.S b/libc/arch-x86/syscalls/renameat.S
index 8084045..e3ffe7b 100644
--- a/libc/arch-x86/syscalls/renameat.S
+++ b/libc/arch-x86/syscalls/renameat.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(renameat)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_renameat, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/rmdir.S b/libc/arch-x86/syscalls/rmdir.S
index b16375c..627c41a 100644
--- a/libc/arch-x86/syscalls/rmdir.S
+++ b/libc/arch-x86/syscalls/rmdir.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(rmdir)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_rmdir, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sched_get_priority_max.S b/libc/arch-x86/syscalls/sched_get_priority_max.S
index 713b02d..fb696cc 100644
--- a/libc/arch-x86/syscalls/sched_get_priority_max.S
+++ b/libc/arch-x86/syscalls/sched_get_priority_max.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sched_get_priority_max)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_sched_get_priority_max, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sched_get_priority_min.S b/libc/arch-x86/syscalls/sched_get_priority_min.S
index de6768f..f1884f1 100644
--- a/libc/arch-x86/syscalls/sched_get_priority_min.S
+++ b/libc/arch-x86/syscalls/sched_get_priority_min.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sched_get_priority_min)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_sched_get_priority_min, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sched_getparam.S b/libc/arch-x86/syscalls/sched_getparam.S
index eabc562..0214c6c 100644
--- a/libc/arch-x86/syscalls/sched_getparam.S
+++ b/libc/arch-x86/syscalls/sched_getparam.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sched_getparam)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_sched_getparam, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sched_getscheduler.S b/libc/arch-x86/syscalls/sched_getscheduler.S
index 2a6c8f7..aaba953 100644
--- a/libc/arch-x86/syscalls/sched_getscheduler.S
+++ b/libc/arch-x86/syscalls/sched_getscheduler.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sched_getscheduler)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_sched_getscheduler, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sched_rr_get_interval.S b/libc/arch-x86/syscalls/sched_rr_get_interval.S
index 3f032d5..c2745c7 100644
--- a/libc/arch-x86/syscalls/sched_rr_get_interval.S
+++ b/libc/arch-x86/syscalls/sched_rr_get_interval.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sched_rr_get_interval)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_sched_rr_get_interval, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sched_setaffinity.S b/libc/arch-x86/syscalls/sched_setaffinity.S
index 988f6b4..40f09f2 100644
--- a/libc/arch-x86/syscalls/sched_setaffinity.S
+++ b/libc/arch-x86/syscalls/sched_setaffinity.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sched_setaffinity)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_sched_setaffinity, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sched_setparam.S b/libc/arch-x86/syscalls/sched_setparam.S
index a250783..b3c2c1f 100644
--- a/libc/arch-x86/syscalls/sched_setparam.S
+++ b/libc/arch-x86/syscalls/sched_setparam.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sched_setparam)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_sched_setparam, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sched_setscheduler.S b/libc/arch-x86/syscalls/sched_setscheduler.S
index c6851ba..c57ed7b 100644
--- a/libc/arch-x86/syscalls/sched_setscheduler.S
+++ b/libc/arch-x86/syscalls/sched_setscheduler.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sched_setscheduler)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_sched_setscheduler, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sched_yield.S b/libc/arch-x86/syscalls/sched_yield.S
index 3dcc7fc..e40e2da 100644
--- a/libc/arch-x86/syscalls/sched_yield.S
+++ b/libc/arch-x86/syscalls/sched_yield.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sched_yield)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_sched_yield, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/select.S b/libc/arch-x86/syscalls/select.S
index b665281..1f19918 100644
--- a/libc/arch-x86/syscalls/select.S
+++ b/libc/arch-x86/syscalls/select.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(select)
     pushl   %ebx
@@ -15,7 +16,7 @@
     mov     40(%esp), %edi
     movl    $__NR__newselect, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sendfile.S b/libc/arch-x86/syscalls/sendfile.S
index b36fa1f..fed0456 100644
--- a/libc/arch-x86/syscalls/sendfile.S
+++ b/libc/arch-x86/syscalls/sendfile.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sendfile)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_sendfile, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sendmsg.S b/libc/arch-x86/syscalls/sendmsg.S
index 119d632..9b9dee1 100644
--- a/libc/arch-x86/syscalls/sendmsg.S
+++ b/libc/arch-x86/syscalls/sendmsg.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sendmsg)
     pushl   %ebx
@@ -10,7 +11,7 @@
     addl    $12, %ecx
     movl    $__NR_socketcall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sendto.S b/libc/arch-x86/syscalls/sendto.S
index 82208fe..315ed4c 100644
--- a/libc/arch-x86/syscalls/sendto.S
+++ b/libc/arch-x86/syscalls/sendto.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sendto)
     pushl   %ebx
@@ -10,7 +11,7 @@
     addl    $12, %ecx
     movl    $__NR_socketcall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/setgid.S b/libc/arch-x86/syscalls/setgid.S
index 37f5ffe..4704047 100644
--- a/libc/arch-x86/syscalls/setgid.S
+++ b/libc/arch-x86/syscalls/setgid.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(setgid)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_setgid32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/setgroups.S b/libc/arch-x86/syscalls/setgroups.S
index 20266e0..f55d84f 100644
--- a/libc/arch-x86/syscalls/setgroups.S
+++ b/libc/arch-x86/syscalls/setgroups.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(setgroups)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_setgroups32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/setitimer.S b/libc/arch-x86/syscalls/setitimer.S
index 97ee7c6..713c5c6 100644
--- a/libc/arch-x86/syscalls/setitimer.S
+++ b/libc/arch-x86/syscalls/setitimer.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(setitimer)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_setitimer, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/setpgid.S b/libc/arch-x86/syscalls/setpgid.S
index 8ff9273..f90001a 100644
--- a/libc/arch-x86/syscalls/setpgid.S
+++ b/libc/arch-x86/syscalls/setpgid.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(setpgid)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_setpgid, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/setpriority.S b/libc/arch-x86/syscalls/setpriority.S
index 7358a89..973302e 100644
--- a/libc/arch-x86/syscalls/setpriority.S
+++ b/libc/arch-x86/syscalls/setpriority.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(setpriority)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_setpriority, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/setregid.S b/libc/arch-x86/syscalls/setregid.S
index bbe092f..6842540 100644
--- a/libc/arch-x86/syscalls/setregid.S
+++ b/libc/arch-x86/syscalls/setregid.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(setregid)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_setregid32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/setresgid.S b/libc/arch-x86/syscalls/setresgid.S
index c235837..ce598c1 100644
--- a/libc/arch-x86/syscalls/setresgid.S
+++ b/libc/arch-x86/syscalls/setresgid.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(setresgid)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_setresgid32, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/setrlimit.S b/libc/arch-x86/syscalls/setrlimit.S
index d7f5072..0c11b75 100644
--- a/libc/arch-x86/syscalls/setrlimit.S
+++ b/libc/arch-x86/syscalls/setrlimit.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(setrlimit)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_setrlimit, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/setsid.S b/libc/arch-x86/syscalls/setsid.S
index 684b304..235b4fb 100644
--- a/libc/arch-x86/syscalls/setsid.S
+++ b/libc/arch-x86/syscalls/setsid.S
@@ -1,11 +1,12 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(setsid)
     movl    $__NR_setsid, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/setsockopt.S b/libc/arch-x86/syscalls/setsockopt.S
index 9c70116..6219859 100644
--- a/libc/arch-x86/syscalls/setsockopt.S
+++ b/libc/arch-x86/syscalls/setsockopt.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(setsockopt)
     pushl   %ebx
@@ -10,7 +11,7 @@
     addl    $12, %ecx
     movl    $__NR_socketcall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/settimeofday.S b/libc/arch-x86/syscalls/settimeofday.S
index bc95fec..f06aee7 100644
--- a/libc/arch-x86/syscalls/settimeofday.S
+++ b/libc/arch-x86/syscalls/settimeofday.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(settimeofday)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_settimeofday, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/setxattr.S b/libc/arch-x86/syscalls/setxattr.S
index 9dc87e3..f6110cc 100644
--- a/libc/arch-x86/syscalls/setxattr.S
+++ b/libc/arch-x86/syscalls/setxattr.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(setxattr)
     pushl   %ebx
@@ -15,7 +16,7 @@
     mov     40(%esp), %edi
     movl    $__NR_setxattr, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/shutdown.S b/libc/arch-x86/syscalls/shutdown.S
index 7fa36a1..997138c 100644
--- a/libc/arch-x86/syscalls/shutdown.S
+++ b/libc/arch-x86/syscalls/shutdown.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(shutdown)
     pushl   %ebx
@@ -10,7 +11,7 @@
     addl    $12, %ecx
     movl    $__NR_socketcall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sigaction.S b/libc/arch-x86/syscalls/sigaction.S
index 4fd5993..499c821 100644
--- a/libc/arch-x86/syscalls/sigaction.S
+++ b/libc/arch-x86/syscalls/sigaction.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sigaction)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_sigaction, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sigaltstack.S b/libc/arch-x86/syscalls/sigaltstack.S
index 830c99f..7cdd1eb 100644
--- a/libc/arch-x86/syscalls/sigaltstack.S
+++ b/libc/arch-x86/syscalls/sigaltstack.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sigaltstack)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_sigaltstack, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/signalfd4.S b/libc/arch-x86/syscalls/signalfd4.S
index 57e0233..399ad35 100644
--- a/libc/arch-x86/syscalls/signalfd4.S
+++ b/libc/arch-x86/syscalls/signalfd4.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(signalfd4)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_signalfd4, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sigpending.S b/libc/arch-x86/syscalls/sigpending.S
index 2f009b2..e26f189 100644
--- a/libc/arch-x86/syscalls/sigpending.S
+++ b/libc/arch-x86/syscalls/sigpending.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sigpending)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_sigpending, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sigprocmask.S b/libc/arch-x86/syscalls/sigprocmask.S
index 81cdfa2..fb12ea2 100644
--- a/libc/arch-x86/syscalls/sigprocmask.S
+++ b/libc/arch-x86/syscalls/sigprocmask.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sigprocmask)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_sigprocmask, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/socket.S b/libc/arch-x86/syscalls/socket.S
index 8cc93bd..b7a20de 100644
--- a/libc/arch-x86/syscalls/socket.S
+++ b/libc/arch-x86/syscalls/socket.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(socket)
     pushl   %ebx
@@ -10,7 +11,7 @@
     addl    $12, %ecx
     movl    $__NR_socketcall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/socketpair.S b/libc/arch-x86/syscalls/socketpair.S
index ccfc847..02c02ac 100644
--- a/libc/arch-x86/syscalls/socketpair.S
+++ b/libc/arch-x86/syscalls/socketpair.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(socketpair)
     pushl   %ebx
@@ -10,7 +11,7 @@
     addl    $12, %ecx
     movl    $__NR_socketcall, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/stat.S b/libc/arch-x86/syscalls/stat.S
index 83d1af8..2cdf1a0 100644
--- a/libc/arch-x86/syscalls/stat.S
+++ b/libc/arch-x86/syscalls/stat.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(stat)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_stat64, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/symlink.S b/libc/arch-x86/syscalls/symlink.S
index dbc5490..6c27dc1 100644
--- a/libc/arch-x86/syscalls/symlink.S
+++ b/libc/arch-x86/syscalls/symlink.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(symlink)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_symlink, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sync.S b/libc/arch-x86/syscalls/sync.S
index f337c2c..d2a4691 100644
--- a/libc/arch-x86/syscalls/sync.S
+++ b/libc/arch-x86/syscalls/sync.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sync)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_sync, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/sysinfo.S b/libc/arch-x86/syscalls/sysinfo.S
index ef9fcb0..b0fcd1d 100644
--- a/libc/arch-x86/syscalls/sysinfo.S
+++ b/libc/arch-x86/syscalls/sysinfo.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(sysinfo)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_sysinfo, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/tgkill.S b/libc/arch-x86/syscalls/tgkill.S
index 6d5dc88..ac8e7f6 100644
--- a/libc/arch-x86/syscalls/tgkill.S
+++ b/libc/arch-x86/syscalls/tgkill.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(tgkill)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_tgkill, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/times.S b/libc/arch-x86/syscalls/times.S
index 04991a8..62f3039 100644
--- a/libc/arch-x86/syscalls/times.S
+++ b/libc/arch-x86/syscalls/times.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(times)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_times, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/tkill.S b/libc/arch-x86/syscalls/tkill.S
index 51eb1c8..38a7a80 100644
--- a/libc/arch-x86/syscalls/tkill.S
+++ b/libc/arch-x86/syscalls/tkill.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(tkill)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_tkill, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/truncate.S b/libc/arch-x86/syscalls/truncate.S
index 9e9b08d..ace7128 100644
--- a/libc/arch-x86/syscalls/truncate.S
+++ b/libc/arch-x86/syscalls/truncate.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(truncate)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_truncate, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/umask.S b/libc/arch-x86/syscalls/umask.S
index f2bf7b0..f238975 100644
--- a/libc/arch-x86/syscalls/umask.S
+++ b/libc/arch-x86/syscalls/umask.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(umask)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_umask, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/umount2.S b/libc/arch-x86/syscalls/umount2.S
index 1949489..3bc04c8 100644
--- a/libc/arch-x86/syscalls/umount2.S
+++ b/libc/arch-x86/syscalls/umount2.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(umount2)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_umount2, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/uname.S b/libc/arch-x86/syscalls/uname.S
index 9b2c746..00c1a0c 100644
--- a/libc/arch-x86/syscalls/uname.S
+++ b/libc/arch-x86/syscalls/uname.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(uname)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_uname, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/unlink.S b/libc/arch-x86/syscalls/unlink.S
index 0d9ce84..60e7b47 100644
--- a/libc/arch-x86/syscalls/unlink.S
+++ b/libc/arch-x86/syscalls/unlink.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(unlink)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_unlink, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/unlinkat.S b/libc/arch-x86/syscalls/unlinkat.S
index d05b488..2e1a04f 100644
--- a/libc/arch-x86/syscalls/unlinkat.S
+++ b/libc/arch-x86/syscalls/unlinkat.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(unlinkat)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_unlinkat, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/unshare.S b/libc/arch-x86/syscalls/unshare.S
index da0f563..f5b9a44 100644
--- a/libc/arch-x86/syscalls/unshare.S
+++ b/libc/arch-x86/syscalls/unshare.S
@@ -1,13 +1,14 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(unshare)
     pushl   %ebx
     mov     8(%esp), %ebx
     movl    $__NR_unshare, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/utimensat.S b/libc/arch-x86/syscalls/utimensat.S
index fb1d630..ab31922 100644
--- a/libc/arch-x86/syscalls/utimensat.S
+++ b/libc/arch-x86/syscalls/utimensat.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(utimensat)
     pushl   %ebx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_utimensat, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/utimes.S b/libc/arch-x86/syscalls/utimes.S
index 189f6b9..4ca4a8d 100644
--- a/libc/arch-x86/syscalls/utimes.S
+++ b/libc/arch-x86/syscalls/utimes.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(utimes)
     pushl   %ebx
@@ -9,7 +10,7 @@
     mov     16(%esp), %ecx
     movl    $__NR_utimes, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/__wait4.S b/libc/arch-x86/syscalls/wait4.S
similarity index 82%
rename from libc/arch-x86/syscalls/__wait4.S
rename to libc/arch-x86/syscalls/wait4.S
index 23165a3..9de704a 100644
--- a/libc/arch-x86/syscalls/__wait4.S
+++ b/libc/arch-x86/syscalls/wait4.S
@@ -1,8 +1,9 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
-ENTRY(__wait4)
+ENTRY(wait4)
     pushl   %ebx
     pushl   %ecx
     pushl   %edx
@@ -13,7 +14,7 @@
     mov     32(%esp), %esi
     movl    $__NR_wait4, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
@@ -26,4 +27,4 @@
     popl    %ecx
     popl    %ebx
     ret
-END(__wait4)
+END(wait4)
diff --git a/libc/arch-x86/syscalls/write.S b/libc/arch-x86/syscalls/write.S
index 7f0b030..11d0c72 100644
--- a/libc/arch-x86/syscalls/write.S
+++ b/libc/arch-x86/syscalls/write.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(write)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_write, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/arch-x86/syscalls/writev.S b/libc/arch-x86/syscalls/writev.S
index 0757a44..a158a14 100644
--- a/libc/arch-x86/syscalls/writev.S
+++ b/libc/arch-x86/syscalls/writev.S
@@ -1,6 +1,7 @@
 /* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(writev)
     pushl   %ebx
@@ -11,7 +12,7 @@
     mov     24(%esp), %edx
     movl    $__NR_writev, %eax
     int     $0x80
-    cmpl    $-129, %eax
+    cmpl    $-MAX_ERRNO, %eax
     jb      1f
     negl    %eax
     pushl   %eax
diff --git a/libc/bionic/__fgets_chk.cpp b/libc/bionic/__fgets_chk.cpp
index 6ae97cc..429eda5 100644
--- a/libc/bionic/__fgets_chk.cpp
+++ b/libc/bionic/__fgets_chk.cpp
@@ -28,7 +28,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 /*
  * __fgets_chk. Called in place of fgets() when we know the
diff --git a/libc/bionic/__memcpy_chk.cpp b/libc/bionic/__memcpy_chk.cpp
index 7a98cb7..b36cfdd 100644
--- a/libc/bionic/__memcpy_chk.cpp
+++ b/libc/bionic/__memcpy_chk.cpp
@@ -29,7 +29,7 @@
 #undef _FORTIFY_SOURCE
 #include <string.h>
 #include <stdlib.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 /*
  * Runtime implementation of __memcpy_chk.
diff --git a/libc/bionic/__memmove_chk.cpp b/libc/bionic/__memmove_chk.cpp
index 51f2e1c..ff770b5 100644
--- a/libc/bionic/__memmove_chk.cpp
+++ b/libc/bionic/__memmove_chk.cpp
@@ -28,7 +28,7 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 /*
  * Runtime implementation of __builtin____memmove_chk.
diff --git a/libc/bionic/__memset_chk.cpp b/libc/bionic/__memset_chk.cpp
index 99a12ad..b201ed2 100644
--- a/libc/bionic/__memset_chk.cpp
+++ b/libc/bionic/__memset_chk.cpp
@@ -28,7 +28,7 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 /*
  * Runtime implementation of __builtin____memset_chk.
diff --git a/libc/bionic/__set_errno.cpp b/libc/bionic/__set_errno.cpp
index 5b249c8..af6a68e 100644
--- a/libc/bionic/__set_errno.cpp
+++ b/libc/bionic/__set_errno.cpp
@@ -28,25 +28,11 @@
 
 #include <errno.h>
 
-// These functions are called from our assembler syscall stubs.
+// This function is called from our assembler syscall stubs.
 // C/C++ code should just assign 'errno' instead.
 
-// TODO: should be __LIBC_HIDDEN__, but already exported by NDK :-(
-// TODO: this isn't used on ARM.
+// TODO: this should be __LIBC_HIDDEN__ but was exposed in <errno.h> in the NDK.
 extern "C" int __set_errno(int n) {
   errno = n;
   return -1;
 }
-
-// TODO: this is only used on ARM, but is exported by NDK on all platforms :-(
-extern "C" __LIBC_HIDDEN__ int __set_syscall_errno(int n) {
-  // Some syscalls, mmap() for example, have valid return
-  // values that are "negative".  Since errno values are not
-  // greater than 131 on Linux, we will just consider
-  // anything significantly out of range as not-an-error.
-  if(n > -256) {
-    return __set_errno(-n);
-  } else {
-    return n;
-  }
-}
diff --git a/libc/bionic/__stack_chk_fail.cpp b/libc/bionic/__stack_chk_fail.cpp
index cae66b1..d5031ac 100644
--- a/libc/bionic/__stack_chk_fail.cpp
+++ b/libc/bionic/__stack_chk_fail.cpp
@@ -29,8 +29,7 @@
 #include <stdlib.h>
 
 #include "bionic_ssp.h"
-#include "debug_format.h"
-#include "logd.h"
+#include "libc_logging.h"
 
 void __stack_chk_fail() {
   __libc_format_log(ANDROID_LOG_FATAL, "libc", "stack corruption detected");
diff --git a/libc/bionic/__stack_chk_guard.cpp b/libc/bionic/__stack_chk_guard.cpp
deleted file mode 100644
index a695caf..0000000
--- a/libc/bionic/__stack_chk_guard.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "bionic_ssp.h"
-
-#include <sys/auxv.h>
-
-uintptr_t __stack_chk_guard = 0;
-
-static void __attribute__((constructor)) __init_stack_check_guard() {
-  // AT_RANDOM is a pointer to 16 bytes of randomness on the stack.
-  __stack_chk_guard = *reinterpret_cast<uintptr_t*>(getauxval(AT_RANDOM));
-}
diff --git a/libc/bionic/__strcat_chk.cpp b/libc/bionic/__strcat_chk.cpp
index 2450da6..fb46e0d 100644
--- a/libc/bionic/__strcat_chk.cpp
+++ b/libc/bionic/__strcat_chk.cpp
@@ -28,7 +28,7 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 #include <safe_iop.h>
 
 /*
diff --git a/libc/bionic/__strcpy_chk.cpp b/libc/bionic/__strcpy_chk.cpp
index 74ceda1..bfb6642 100644
--- a/libc/bionic/__strcpy_chk.cpp
+++ b/libc/bionic/__strcpy_chk.cpp
@@ -28,7 +28,7 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 /*
  * Runtime implementation of __builtin____strcpy_chk.
diff --git a/libc/bionic/__strlcat_chk.cpp b/libc/bionic/__strlcat_chk.cpp
index 12676f4..96f62f9 100644
--- a/libc/bionic/__strlcat_chk.cpp
+++ b/libc/bionic/__strlcat_chk.cpp
@@ -28,7 +28,7 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 /*
  * __strlcat_chk. Called in place of strlcat() when we know the
diff --git a/libc/bionic/__strlcpy_chk.cpp b/libc/bionic/__strlcpy_chk.cpp
index 62fa14b..636966b 100644
--- a/libc/bionic/__strlcpy_chk.cpp
+++ b/libc/bionic/__strlcpy_chk.cpp
@@ -28,7 +28,7 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 /*
  * __strlcpy_chk. Called in place of strlcpy() when we know the
diff --git a/libc/bionic/__strlen_chk.cpp b/libc/bionic/__strlen_chk.cpp
index 5cc052e..6ebf09c 100644
--- a/libc/bionic/__strlen_chk.cpp
+++ b/libc/bionic/__strlen_chk.cpp
@@ -28,7 +28,7 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 /*
  * Runtime implementation of __strlen_chk.
diff --git a/libc/bionic/__strncat_chk.cpp b/libc/bionic/__strncat_chk.cpp
index 32a3962..ab28541 100644
--- a/libc/bionic/__strncat_chk.cpp
+++ b/libc/bionic/__strncat_chk.cpp
@@ -28,7 +28,7 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 #include <safe_iop.h>
 
 /*
diff --git a/libc/bionic/__strncpy_chk.cpp b/libc/bionic/__strncpy_chk.cpp
index c9676ed..0f1797e 100644
--- a/libc/bionic/__strncpy_chk.cpp
+++ b/libc/bionic/__strncpy_chk.cpp
@@ -28,7 +28,7 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 /*
  * Runtime implementation of __builtin____strncpy_chk.
diff --git a/libc/bionic/__umask_chk.cpp b/libc/bionic/__umask_chk.cpp
index e1bc96d..ff67ed6 100644
--- a/libc/bionic/__umask_chk.cpp
+++ b/libc/bionic/__umask_chk.cpp
@@ -30,7 +30,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 #include <stdlib.h>
 
 /*
diff --git a/libc/bionic/__vsnprintf_chk.cpp b/libc/bionic/__vsnprintf_chk.cpp
index 95d4915..0fdda3e 100644
--- a/libc/bionic/__vsnprintf_chk.cpp
+++ b/libc/bionic/__vsnprintf_chk.cpp
@@ -29,7 +29,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 /*
  * Runtime implementation of __builtin____vsnprintf_chk.
diff --git a/libc/bionic/__vsprintf_chk.cpp b/libc/bionic/__vsprintf_chk.cpp
index e1d10f5..12b0ca6 100644
--- a/libc/bionic/__vsprintf_chk.cpp
+++ b/libc/bionic/__vsprintf_chk.cpp
@@ -29,7 +29,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 /*
  * Runtime implementation of __builtin____vsprintf_chk.
diff --git a/libc/bionic/assert.cpp b/libc/bionic/assert.cpp
index e38c16d..6f221a5 100644
--- a/libc/bionic/assert.cpp
+++ b/libc/bionic/assert.cpp
@@ -32,8 +32,7 @@
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <private/debug_format.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 // We log to stderr for the benefit of "adb shell" users, and the log for the benefit
 // of regular app developers who want to see their asserts.
diff --git a/libc/bionic/debug_stacktrace.cpp b/libc/bionic/debug_stacktrace.cpp
index 9d53ad2..87dbba3 100644
--- a/libc/bionic/debug_stacktrace.cpp
+++ b/libc/bionic/debug_stacktrace.cpp
@@ -33,9 +33,8 @@
 #include <unwind.h>
 #include <sys/types.h>
 
-#include "debug_format.h"
 #include "debug_mapinfo.h"
-#include "logd.h"
+#include "libc_logging.h"
 
 /* depends how the system includes define this */
 #ifdef HAVE_UNWIND_CONTEXT_STRUCT
diff --git a/libc/bionic/dlmalloc.c b/libc/bionic/dlmalloc.c
index 1ed3205..87f772b 100644
--- a/libc/bionic/dlmalloc.c
+++ b/libc/bionic/dlmalloc.c
@@ -24,8 +24,7 @@
 
 #include <linux/ashmem.h>
 
-#include <private/debug_format.h>
-#include <private/logd.h>
+#include <private/libc_logging.h>
 
 // Send dlmalloc errors to the log.
 static void __bionic_heap_corruption_error(const char* function);
@@ -48,7 +47,8 @@
 }
 
 static void __bionic_heap_usage_error(const char* function, void* address) {
-  __libc_format_log(ANDROID_LOG_FATAL, "libc", "@@@ ABORTING: invalid address %p passed to %s",
+  __libc_format_log(ANDROID_LOG_FATAL, "libc",
+                    "@@@ ABORTING: invalid address or address of corrupt block %p passed to %s",
                     address, function);
   // So that we can get a memory dump around the specific address.
   *((int**) 0xdeadbaad) = (int*) address;
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp
index 6038056..33ec1db 100644
--- a/libc/bionic/libc_init_common.cpp
+++ b/libc/bionic/libc_init_common.cpp
@@ -26,21 +26,24 @@
  * SUCH DAMAGE.
  */
 
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <elf.h>
-#include <asm/page.h>
-#include "pthread_internal.h"
-#include "atexit.h"
-#include "KernelArgumentBlock.h"
 #include "libc_init_common.h"
 
+#include <asm/page.h>
 #include <bionic_tls.h>
+#include <elf.h>
 #include <errno.h>
-#include <private/bionic_auxv.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/auxv.h>
+#include <unistd.h>
+
+#include "atexit.h"
+#include "private/bionic_auxv.h"
+#include "private/bionic_ssp.h"
+#include "private/KernelArgumentBlock.h"
+#include "pthread_internal.h"
 
 extern "C" unsigned __get_sp(void);
 extern "C" int __system_properties_init(void);
@@ -51,6 +54,9 @@
 // Declared in <unistd.h>.
 char** environ;
 
+// Declared in <private/bionic_ssp.h>.
+uintptr_t __stack_chk_guard = 0;
+
 // Declared in <asm/page.h>.
 unsigned int __page_size = PAGE_SIZE;
 unsigned int __page_shift = PAGE_SHIFT;
@@ -91,6 +97,9 @@
   __libc_auxv = args.auxv;
   __progname = args.argv[0] ? args.argv[0] : "<unknown>";
 
+  // AT_RANDOM is a pointer to 16 bytes of randomness on the stack.
+  __stack_chk_guard = *reinterpret_cast<uintptr_t*>(getauxval(AT_RANDOM));
+
   // Get the main thread from TLS and add it to the thread list.
   pthread_internal_t* main_thread = __get_thread();
   main_thread->allocated_on_heap = false;
diff --git a/libc/bionic/libc_init_common.h b/libc/bionic/libc_init_common.h
index 23ac305..14105f8 100644
--- a/libc/bionic/libc_init_common.h
+++ b/libc/bionic/libc_init_common.h
@@ -50,7 +50,7 @@
 
 #if defined(__cplusplus)
 struct KernelArgumentBlock;
-void __libc_init_common(KernelArgumentBlock& args);
+void __LIBC_HIDDEN__ __libc_init_common(KernelArgumentBlock& args);
 #endif
 
 #endif
diff --git a/libc/bionic/libc_init_dynamic.cpp b/libc/bionic/libc_init_dynamic.cpp
index af03fb0..88e87a7 100644
--- a/libc/bionic/libc_init_dynamic.cpp
+++ b/libc/bionic/libc_init_dynamic.cpp
@@ -63,9 +63,7 @@
 // that its address is listed in libc.so's .init_array section.
 // This ensures that the function is called by the dynamic linker
 // as soon as the shared library is loaded.
-void __attribute__((constructor)) __libc_preinit(void);
-
-void __libc_preinit() {
+__attribute__((constructor)) static void __libc_preinit() {
   // Read the kernel argument block pointer from TLS.
   void* tls = const_cast<void*>(__get_tls());
   KernelArgumentBlock** args_slot = &reinterpret_cast<KernelArgumentBlock**>(tls)[TLS_SLOT_BIONIC_PREINIT];
@@ -82,7 +80,7 @@
   malloc_debug_init();
 }
 
-void __libc_postfini() {
+__LIBC_HIDDEN__ void __libc_postfini() {
   // A hook for the debug malloc library to let it know that we're shutting down.
   malloc_debug_fini();
 }
diff --git a/libc/bionic/debug_format.cpp b/libc/bionic/libc_logging.cpp
similarity index 85%
rename from libc/bionic/debug_format.cpp
rename to libc/bionic/libc_logging.cpp
index 793f8b1..755dc81 100644
--- a/libc/bionic/debug_format.cpp
+++ b/libc/bionic/libc_logging.cpp
@@ -26,13 +26,15 @@
  * SUCH DAMAGE.
  */
 
-#include <../private/debug_format.h> // Relative path so we can #include this for testing.
+#include <../private/libc_logging.h> // Relative path so we can #include this .cpp file for testing.
+#include <../private/ScopedPthreadMutexLocker.h>
 
 #include <assert.h>
 #include <errno.h>
+#include <pthread.h>
 #include <stdarg.h>
 #include <stddef.h>
-#include <stdint.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
@@ -218,29 +220,30 @@
 #include <fcntl.h>
 #include <sys/uio.h>
 
+static pthread_mutex_t gLogInitializationLock = PTHREAD_MUTEX_INITIALIZER;
+
 int __libc_format_log_va_list(int priority, const char* tag, const char* fmt, va_list args) {
   char buf[1024];
-  int result = vformat_buffer(buf, sizeof buf, fmt, args);
+  int buf_strlen = vformat_buffer(buf, sizeof(buf), fmt, args);
 
-  static int log_fd = -1;
-  if (log_fd == -1) {
-    log_fd = open("/dev/log/main", O_WRONLY);
-    if (log_fd == -1) {
-      return result;
+  static int main_log_fd = -1;
+  if (main_log_fd == -1) {
+    ScopedPthreadMutexLocker locker(&gLogInitializationLock);
+    main_log_fd = TEMP_FAILURE_RETRY(open("/dev/log/main", O_CLOEXEC | O_WRONLY));
+    if (main_log_fd == -1) {
+      return -1;
     }
   }
 
   struct iovec vec[3];
-  vec[0].iov_base = (unsigned char *) &priority;
+  vec[0].iov_base = &priority;
   vec[0].iov_len = 1;
-  vec[1].iov_base = (void *) tag;
+  vec[1].iov_base = const_cast<char*>(tag);
   vec[1].iov_len = strlen(tag) + 1;
-  vec[2].iov_base = (void *) buf;
-  vec[2].iov_len = strlen(buf) + 1;
+  vec[2].iov_base = const_cast<char*>(buf);
+  vec[2].iov_len = buf_strlen + 1;
 
-  TEMP_FAILURE_RETRY(writev(log_fd, vec, 3));
-
-  return result;
+  return TEMP_FAILURE_RETRY(writev(main_log_fd, vec, 3));
 }
 
 int __libc_format_log(int priority, const char* tag, const char* format, ...) {
@@ -516,3 +519,44 @@
         }
     }
 }
+
+// must be kept in sync with frameworks/base/core/java/android/util/EventLog.java
+enum AndroidEventLogType {
+  EVENT_TYPE_INT      = 0,
+  EVENT_TYPE_LONG     = 1,
+  EVENT_TYPE_STRING   = 2,
+  EVENT_TYPE_LIST     = 3,
+};
+
+static int __libc_android_log_event(int32_t tag, char type, const void* payload, size_t len) {
+  struct iovec vec[3];
+  vec[0].iov_base = &tag;
+  vec[0].iov_len = sizeof(tag);
+  vec[1].iov_base = &type;
+  vec[1].iov_len = sizeof(type);
+  vec[2].iov_base = const_cast<void*>(payload);
+  vec[2].iov_len = len;
+
+  static int event_log_fd = -1;
+  if (event_log_fd == -1) {
+    ScopedPthreadMutexLocker locker(&gLogInitializationLock);
+    event_log_fd = TEMP_FAILURE_RETRY(open("/dev/log/events", O_CLOEXEC | O_WRONLY));
+  }
+  return TEMP_FAILURE_RETRY(writev(event_log_fd, vec, 3));
+}
+
+void __libc_android_log_event_int(int32_t tag, int value) {
+  __libc_android_log_event(tag, EVENT_TYPE_INT, &value, sizeof(value));
+}
+
+void __libc_android_log_event_uid(int32_t tag) {
+  __libc_android_log_event_int(tag, getuid());
+}
+
+void __fortify_chk_fail(const char *msg, uint32_t tag) {
+  __libc_format_log(ANDROID_LOG_FATAL, "libc", "FORTIFY_SOURCE: %s. Calling abort().\n", msg);
+  if (tag != 0) {
+    __libc_android_log_event_uid(tag);
+  }
+  abort();
+}
diff --git a/libc/bionic/logd_write.c b/libc/bionic/logd_write.c
deleted file mode 100644
index 11c0e68..0000000
--- a/libc/bionic/logd_write.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <time.h>
-#include <stdio.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <arpa/inet.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <fcntl.h>
-
-#include "logd.h"
-
-/* should match system/core/include/cutils/logger.h */
-#define LOGGER_LOG_MAIN     "log/main"
-#define LOGGER_LOG_RADIO    "log/radio"
-#define LOGGER_LOG_EVENTS   "log/events"
-#define LOGGER_LOG_SYSTEM   "log/system"
-
-#include <pthread.h>
-
-/* IMPORTANT IMPORTANT IMPORTANT: TECHNICAL NOTE
- *
- * Some of the functions below can be called when our malloc() implementation
- * has detected that the heap is corrupted, or even from a signal handler.
- *
- * These functions should *not* use a function that allocates heap memory
- * or is not signal-safe. Using direct system calls is acceptable, and we
- * also assume that pthread_mutex_lock/unlock can be used too.
- */
-
-#define LOG_BUF_SIZE    1024
-
-typedef enum {
-    LOG_ID_NONE = 0,
-    LOG_ID_MAIN,
-    LOG_ID_RADIO,
-    LOG_ID_EVENTS,
-    LOG_ID_MAX
-} log_id_t;
-
-/* logger handles writing to object, pointed by log channel id */
-typedef int (*logger_function_t)(log_id_t log_id, struct iovec *vec);
-
-typedef struct {
-    logger_function_t logger;
-    int               fd;
-    const char        *path;
-} log_channel_t;
-
-static int __write_to_log_init(log_id_t log_id, struct iovec *vec);
-static int __write_to_log_null(log_id_t log_id, struct iovec *vec);
-
-static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER;
-
-static log_channel_t log_channels[LOG_ID_MAX] = {
-    { __write_to_log_null, -1, NULL },
-    { __write_to_log_init, -1, "/dev/"LOGGER_LOG_MAIN },
-    { __write_to_log_init, -1, "/dev/"LOGGER_LOG_RADIO },
-    { __write_to_log_init, -1, "/dev/"LOGGER_LOG_EVENTS }
-};
-
-/* Important: see technical note at start of source file */
-static int __write_to_log_null(log_id_t log_id, struct iovec *vec)
-{
-    /*
-     * ALTERED behaviour from previous version
-     * always returns successful result
-     */
-    int    i = 0;
-    size_t res = 0;
-
-    for ( ; i < 3; ++i) {
-        res += vec[i].iov_len;
-    }
-
-    return (int)res;
-}
-
-/*
- *  it's supposed, that log_id contains valid id always.
- *  this check must be performed in higher level functions
- */
-/* Important: see technical note at start of source file */
-static int __write_to_log_kernel(log_id_t log_id, struct iovec *vec)
-{
-    return TEMP_FAILURE_RETRY( writev(log_channels[log_id].fd, vec, 3) );
-}
-
-/* Important: see technical note at start of source file */
-static int __write_to_log_init(log_id_t log_id, struct iovec *vec)
-{
-    if ((LOG_ID_NONE < log_id) && (log_id < LOG_ID_MAX)) {
-        int fd;
-
-        pthread_mutex_lock(&log_init_lock);
-
-        fd = TEMP_FAILURE_RETRY(open(log_channels[log_id].path, O_WRONLY));
-
-        log_channels[log_id].logger =
-            (fd < 0) ? __write_to_log_null : __write_to_log_kernel;
-        log_channels[log_id].fd = fd;
-
-        log_channels[log_id].fd = fd;
-
-        pthread_mutex_unlock(&log_init_lock);
-
-        return log_channels[log_id].logger(log_id, vec);
-    }
-
-    /* log_id is invalid */
-    return -1;
-}
-
-/* Important: see technical note at start of source file */
-__LIBC_HIDDEN__
-int __libc_android_log_write(int prio, const char *tag, const char *msg)
-{
-    struct iovec vec[3];
-    log_id_t log_id = LOG_ID_MAIN;
-
-    if (tag == NULL)
-        tag = "";
-
-    if (!strcmp(tag, "HTC_RIL"))
-        log_id = LOG_ID_RADIO;
-
-    vec[0].iov_base   = (unsigned char *) &prio;
-    vec[0].iov_len    = 1;
-    vec[1].iov_base   = (void *) tag;
-    vec[1].iov_len    = strlen(tag) + 1;
-    vec[2].iov_base   = (void *) msg;
-    vec[2].iov_len    = strlen(msg) + 1;
-
-    return log_channels[log_id].logger(log_id, vec);
-}
-
-/* The functions below are not designed to be called from a heap panic
- * function or from a signal handler. As such, they are free to use complex
- * C library functions like vsnprintf()
- */
-__LIBC_HIDDEN__
-int __libc_android_log_vprint(int prio, const char *tag, const char *fmt,
-                              va_list ap)
-{
-    char buf[LOG_BUF_SIZE];
-
-    vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
-
-    return __libc_android_log_write(prio, tag, buf);
-}
-
-__LIBC_HIDDEN__
-int __libc_android_log_print(int prio, const char *tag, const char *fmt, ...)
-{
-    va_list ap;
-    char buf[LOG_BUF_SIZE];
-
-    va_start(ap, fmt);
-    vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
-    va_end(ap);
-
-    return __libc_android_log_write(prio, tag, buf);
-}
-
-__LIBC_HIDDEN__
-int __libc_android_log_assert(const char *cond, const char *tag,
-			      const char *fmt, ...)
-{
-    va_list ap;
-    char buf[LOG_BUF_SIZE];
-
-    va_start(ap, fmt);
-    vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
-    va_end(ap);
-
-    __libc_android_log_write(ANDROID_LOG_FATAL, tag, buf);
-
-    exit(1);
-
-    return -1;
-}
-
-/*
- * Event logging.
- */
-
-// must be kept in sync with frameworks/base/core/java/android/util/EventLog.java
-typedef enum {
-    EVENT_TYPE_INT      = 0,
-    EVENT_TYPE_LONG     = 1,
-    EVENT_TYPE_STRING   = 2,
-    EVENT_TYPE_LIST     = 3,
-} AndroidEventLogType;
-
-static int __libc_android_log_btwrite(int32_t tag, char type, const void *payload, size_t len)
-{
-    struct iovec vec[3];
-
-    vec[0].iov_base = &tag;
-    vec[0].iov_len = sizeof(tag);
-    vec[1].iov_base = &type;
-    vec[1].iov_len = sizeof(type);
-    vec[2].iov_base = (void*)payload;
-    vec[2].iov_len = len;
-
-    return log_channels[LOG_ID_EVENTS].logger(LOG_ID_EVENTS, vec);
-}
-
-__LIBC_HIDDEN__
-void __libc_android_log_event_int(int32_t tag, int value)
-{
-    __libc_android_log_btwrite(tag, EVENT_TYPE_INT, &value, sizeof(value));
-}
-
-__LIBC_HIDDEN__
-void __libc_android_log_event_uid(int32_t tag)
-{
-    __libc_android_log_event_int(tag, getuid());
-}
-
-__LIBC_HIDDEN__
-void __fortify_chk_fail(const char *msg, uint32_t tag) {
-    __libc_format_log(ANDROID_LOG_FATAL, "libc", "FORTIFY_SOURCE: %s. Calling abort().\n", msg);
-    if (tag != 0) {
-        __libc_android_log_event_uid(tag);
-    }
-    abort();
-}
diff --git a/libc/bionic/malloc_debug_check.cpp b/libc/bionic/malloc_debug_check.cpp
index 2ae98b6..91cf287 100644
--- a/libc/bionic/malloc_debug_check.cpp
+++ b/libc/bionic/malloc_debug_check.cpp
@@ -48,7 +48,7 @@
 #include "debug_mapinfo.h"
 #include "debug_stacktrace.h"
 #include "dlmalloc.h"
-#include "logd.h"
+#include "libc_logging.h"
 #include "malloc_debug_common.h"
 #include "ScopedPthreadMutexLocker.h"
 
diff --git a/libc/bionic/malloc_debug_common.cpp b/libc/bionic/malloc_debug_common.cpp
index a05a5ef..2148d20 100644
--- a/libc/bionic/malloc_debug_common.cpp
+++ b/libc/bionic/malloc_debug_common.cpp
@@ -249,7 +249,7 @@
 #include <sys/system_properties.h>
 #include <dlfcn.h>
 #include <stdio.h>
-#include "logd.h"
+#include "libc_logging.h"
 
 /* Table for dispatching malloc calls, depending on environment. */
 static MallocDebug gMallocUse __attribute__((aligned(32))) = {
diff --git a/libc/bionic/malloc_debug_common.h b/libc/bionic/malloc_debug_common.h
index e15ccd0..12d0e65 100644
--- a/libc/bionic/malloc_debug_common.h
+++ b/libc/bionic/malloc_debug_common.h
@@ -35,7 +35,7 @@
 
 #include <stdlib.h>
 
-#include <private/debug_format.h>
+#include "libc_logging.h"
 
 #define HASHTABLE_SIZE      1543
 #define BACKTRACE_SIZE      32
diff --git a/libc/bionic/malloc_debug_leak.cpp b/libc/bionic/malloc_debug_leak.cpp
index 9e63a86..2db8a1f 100644
--- a/libc/bionic/malloc_debug_leak.cpp
+++ b/libc/bionic/malloc_debug_leak.cpp
@@ -47,7 +47,7 @@
 
 #include "debug_stacktrace.h"
 #include "dlmalloc.h"
-#include "logd.h"
+#include "libc_logging.h"
 #include "malloc_debug_common.h"
 #include "ScopedPthreadMutexLocker.h"
 
diff --git a/libc/bionic/malloc_debug_qemu.cpp b/libc/bionic/malloc_debug_qemu.cpp
index 812a451..08225c1 100644
--- a/libc/bionic/malloc_debug_qemu.cpp
+++ b/libc/bionic/malloc_debug_qemu.cpp
@@ -51,7 +51,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include "dlmalloc.h"
-#include "logd.h"
+#include "libc_logging.h"
 #include "malloc_debug_common.h"
 
 /* This file should be included into the build only when
diff --git a/libc/bionic/open.c b/libc/bionic/open.c
index be4f04b..e3573a3 100644
--- a/libc/bionic/open.c
+++ b/libc/bionic/open.c
@@ -29,7 +29,7 @@
 #include <fcntl.h>
 #include <stdarg.h>
 #include <stdlib.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 extern int  __open(const char*, int, int);
 
@@ -60,4 +60,3 @@
 
     return __open(pathname, flags, 0);
 }
-
diff --git a/libc/bionic/openat.c b/libc/bionic/openat.c
index c1abbaa..2d09d17 100644
--- a/libc/bionic/openat.c
+++ b/libc/bionic/openat.c
@@ -29,7 +29,7 @@
 #include <fcntl.h>
 #include <stdarg.h>
 #include <stdlib.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 extern int  __openat(int, const char*, int, int);
 
@@ -61,4 +61,3 @@
 
     return __openat(fd, pathname, flags, 0);
 }
-
diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp
index 368c46d..15f18aa 100644
--- a/libc/bionic/pthread_create.cpp
+++ b/libc/bionic/pthread_create.cpp
@@ -35,8 +35,7 @@
 
 #include "private/bionic_ssp.h"
 #include "private/bionic_tls.h"
-#include "private/debug_format.h"
-#include "private/logd.h"
+#include "private/libc_logging.h"
 #include "private/thread_private.h"
 #include "private/ErrnoRestorer.h"
 #include "private/ScopedPthreadMutexLocker.h"
diff --git a/libc/bionic/pthread_debug.cpp b/libc/bionic/pthread_debug.cpp
index f8f0c59..94c23de 100644
--- a/libc/bionic/pthread_debug.cpp
+++ b/libc/bionic/pthread_debug.cpp
@@ -43,9 +43,7 @@
 #include "bionic_tls.h"
 #include "debug_mapinfo.h"
 #include "debug_stacktrace.h"
-#include "logd.h"
-
-#include <private/debug_format.h>
+#include "libc_logging.h"
 
 /*
  * ===========================================================================
diff --git a/libc/bionic/pthread_key.cpp b/libc/bionic/pthread_key.cpp
index b01f9bd..c793fc6 100644
--- a/libc/bionic/pthread_key.cpp
+++ b/libc/bionic/pthread_key.cpp
@@ -185,8 +185,8 @@
   }
 };
 
-tls_map_t ScopedTlsMapAccess::s_tls_map_;
-pthread_mutex_t ScopedTlsMapAccess::s_tls_map_lock_;
+__LIBC_HIDDEN__ tls_map_t ScopedTlsMapAccess::s_tls_map_;
+__LIBC_HIDDEN__ pthread_mutex_t ScopedTlsMapAccess::s_tls_map_lock_;
 
 __LIBC_HIDDEN__ void pthread_key_clean_all() {
   ScopedTlsMapAccess tls_map;
diff --git a/libc/bionic/pthread_setname_np.cpp b/libc/bionic/pthread_setname_np.cpp
index 6162aea..e0ecace 100644
--- a/libc/bionic/pthread_setname_np.cpp
+++ b/libc/bionic/pthread_setname_np.cpp
@@ -35,6 +35,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include "pthread_accessor.h"
 #include "pthread_internal.h"
 #include "private/ErrnoRestorer.h"
 
@@ -42,10 +43,10 @@
 #define MAX_TASK_COMM_LEN 16
 #define TASK_COMM_FMT "/proc/self/task/%d/comm"
 
-int pthread_setname_np(pthread_t thread, const char* thread_name) {
+int pthread_setname_np(pthread_t t, const char* thread_name) {
   ErrnoRestorer errno_restorer;
 
-  if (thread == 0 || thread_name == NULL) {
+  if (thread_name == NULL) {
     return EINVAL;
   }
 
@@ -55,14 +56,21 @@
   }
 
   // Changing our own name is an easy special case.
-  if (thread == pthread_self()) {
+  if (t == pthread_self()) {
     return prctl(PR_SET_NAME, thread_name) ? errno : 0;
   }
 
-  // Have to change another thread's name.
-  pthread_internal_t* t = reinterpret_cast<pthread_internal_t*>(thread);
+  // We have to change another thread's name.
+  pid_t tid = 0;
+  {
+    pthread_accessor thread(t);
+    if (thread.get() == NULL) {
+      return ESRCH;
+    }
+    tid = thread->tid;
+  }
   char comm_name[sizeof(TASK_COMM_FMT) + 8];
-  snprintf(comm_name, sizeof(comm_name), TASK_COMM_FMT, t->tid);
+  snprintf(comm_name, sizeof(comm_name), TASK_COMM_FMT, tid);
   int fd = open(comm_name, O_WRONLY);
   if (fd == -1) {
     return errno;
@@ -72,7 +80,7 @@
 
   if (n < 0) {
     return errno;
-  } else if ((size_t)n != thread_name_len) {
+  } else if (n != static_cast<ssize_t>(thread_name_len)) {
     return EIO;
   }
   return 0;
diff --git a/libc/bionic/socketcalls.c b/libc/bionic/socketcalls.c
deleted file mode 100644
index 51bdf57..0000000
--- a/libc/bionic/socketcalls.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <unistd.h>
-#include <sys/socket.h>
-#include <sys/linux-syscalls.h>
-
-enum
-{
-    SYS_SOCKET = 1,
-    SYS_BIND,
-    SYS_CONNECT,
-    SYS_LISTEN,
-    SYS_ACCEPT,
-    SYS_GETSOCKNAME,
-    SYS_GETPEERNAME,
-    SYS_SOCKETPAIR,
-    SYS_SEND,
-    SYS_RECV,
-    SYS_SENDTO,
-    SYS_RECVFROM,
-    SYS_SHUTDOWN,
-    SYS_SETSOCKOPT,
-    SYS_GETSOCKOPT,
-    SYS_SENDMSG,
-    SYS_RECVMSG
-};
-
-#ifndef __NR_socket
-int socket(int domain, int type, int protocol)
-{
-    unsigned long  t[3];
-
-    t[0] = (unsigned long) domain;
-    t[1] = (unsigned long) type;
-    t[2] = (unsigned long) protocol;
-
-    return (int) __socketcall( SYS_SOCKET, t );
-}
-#endif /* !__NR_socket */
-
-
-#ifndef __NR_bind
-int bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen)
-{
-    unsigned long  t[3];
-
-    t[0] = (unsigned long) sockfd;
-    t[1] = (unsigned long) my_addr;
-    t[2] = (unsigned long) addrlen;
-
-    return (int) __socketcall( SYS_BIND, t );
-}
-#endif  /* !__NR_bind */
-
-#ifndef __NR_connect
-int connect(int sockfd, const struct sockaddr *serv_addr, socklen_t  addrlen )
-{
-    unsigned long  t[3];
-
-    t[0] = (unsigned long) sockfd;
-    t[1] = (unsigned long) serv_addr;
-    t[2] = (unsigned long) addrlen;
-
-    return (int) __socketcall( SYS_CONNECT, t );
-}
-#endif /* !__NR_connect */
-
-#ifndef __NR_listen
-int listen(int s, int backlog)
-{
-    unsigned long  t[2];
-
-    t[0] = (unsigned long) s;
-    t[1] = (unsigned long) backlog;
-
-    return (int) __socketcall( SYS_LISTEN, t );
-}
-#endif /* __NR_listen */
-
-#ifndef __NR_accept
-int accept(int sock, struct sockaddr *adresse, socklen_t *longueur)
-{
-    unsigned long  t[3];
-
-    t[0] = (unsigned long) sock;
-    t[1] = (unsigned long) adresse;
-    t[2] = (unsigned long) longueur;
-
-    return (int) __socketcall( SYS_ACCEPT, t );
-}
-#endif /* __NR_accept */
-
-#ifndef __NR_getsockname
-int getsockname(int s, struct sockaddr * name, socklen_t * namelen )
-{
-    unsigned long  t[3];
-
-    t[0] = (unsigned long) s;
-    t[1] = (unsigned long) name;
-    t[2] = (unsigned long) namelen;
-
-    return (int) __socketcall( SYS_GETSOCKNAME, t );
-}
-#endif /* __NR_getsockname */
-
-#ifndef __NR_getpeername
-int getpeername(int s, struct sockaddr *name, socklen_t *namelen)
-{
-    unsigned long  t[3];
-
-    t[0] = (unsigned long) s;
-    t[1] = (unsigned long) name;
-    t[2] = (unsigned long) namelen;
-
-    return (int) __socketcall( SYS_GETPEERNAME, t );
-}
-#endif /* !__NR_getpeername */
-
-#ifndef __NR_socketpair
-int socketpair(int d, int type, int protocol, int sv[2])
-{
-    unsigned long  t[4];
-
-    t[0] = (unsigned long) d;
-    t[1] = (unsigned long) type;
-    t[2] = (unsigned long) protocol;
-    t[3] = (unsigned long) sv;
-
-    return (int) __socketcall( SYS_SOCKETPAIR, t );
-}
-#endif /* __NR_socketpair */
-
-#ifndef __NR_sendto
-ssize_t sendto(int socket, const void *message, size_t length, int flags,
-      const struct sockaddr *dest_addr, socklen_t dest_len)
-{
-    unsigned long  t[6];
-
-    t[0] = (unsigned long) socket;
-    t[1] = (unsigned long) message;
-    t[2] = (unsigned long) length;
-    t[3] = (unsigned long) flags;
-    t[4] = (unsigned long) dest_addr;
-    t[5] = (unsigned long) dest_len;
-
-   return __socketcall( SYS_SENDTO, t );
-}
-#endif /* !__NR_sendto */
-
-#ifndef __NR_recvfrom
-ssize_t recvfrom(int socket, void *buffer, size_t length, unsigned int flags,
-             const struct sockaddr *address, socklen_t *address_len)
-{
-    unsigned long  t[6];
-
-    t[0] = (unsigned long) socket;
-    t[1] = (unsigned long) buffer;
-    t[2] = (unsigned long) length;
-    t[3] = (unsigned long) flags;
-    t[4] = (unsigned long) address;
-    t[5] = (unsigned long) address_len;
-
-   return __socketcall( SYS_RECVFROM, t );
-}
-#endif /* !__NR_recvfrom */
-
-#ifndef __NR_shutdown
-int shutdown(int socket, int how)
-{
-    unsigned long  t[2];
-
-    t[0] = (unsigned long) socket;
-    t[1] = (unsigned long) how;
-
-   return (int) __socketcall( SYS_SHUTDOWN, t );
-}
-#endif /* !__NR_shutdown */
-
-#ifndef __NR_setsockopt
-int  setsockopt( int  s, int  level, int  optname, const void*  optval, socklen_t  optlen )
-{
-    unsigned long  t[5];
-
-    t[0] = (unsigned long) s;
-    t[1] = (unsigned long) level;
-    t[2] = (unsigned long) optname;
-    t[3] = (unsigned long) optval;
-    t[4] = (unsigned long) optlen;
-
-   return (int) __socketcall( SYS_SETSOCKOPT, t );
-}
-#endif /* !__NR_setsockopt */
-
-#ifndef __NR_getsockopt
-int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
-{
-    unsigned long  t[5];
-
-    t[0] = (unsigned long) s;
-    t[1] = (unsigned long) level;
-    t[2] = (unsigned long) optname;
-    t[3] = (unsigned long) optval;
-    t[4] = (unsigned long) optlen;
-
-    return (int) __socketcall( SYS_GETSOCKOPT, t );
-}
-#endif /* !__NR_getsockopt */
-
-#ifndef __NR_sendmsg
-int sendmsg (int socket, const struct msghdr *message, unsigned int flags)
-{
-    unsigned long  t[3];
-
-    t[0] = (unsigned long) socket;
-    t[1] = (unsigned long) message;
-    t[2] = (unsigned long) flags;
-
-   return __socketcall( SYS_SENDMSG, t );
-}
-#endif /* __NR_sendmsg */
-
-#ifndef __NR_recvmsg
-int recvmsg(int socket, struct msghdr *message, unsigned int flags)
-{
-    unsigned long  t[3];
-
-    t[0] = (unsigned long) socket;
-    t[1] = (unsigned long) message;
-    t[2] = (unsigned long) flags;
-
-   return __socketcall( SYS_RECVMSG, t );
-}
-#endif /* __NR_recvmsg */
-
diff --git a/libc/bionic/stubs.cpp b/libc/bionic/stubs.cpp
index 8ddc326..e8411b7 100644
--- a/libc/bionic/stubs.cpp
+++ b/libc/bionic/stubs.cpp
@@ -38,9 +38,8 @@
 #include <unistd.h>
 
 #include "private/android_filesystem_config.h"
-#include "private/debug_format.h"
 #include "private/ErrnoRestorer.h"
-#include "private/logd.h"
+#include "private/libc_logging.h"
 
 // Thread-specific state for the non-reentrant functions.
 static pthread_once_t stubs_once = PTHREAD_ONCE_INIT;
diff --git a/libc/bionic/wait.c b/libc/bionic/wait.cpp
similarity index 65%
rename from libc/bionic/wait.c
rename to libc/bionic/wait.cpp
index f1db086..7dbcec2 100644
--- a/libc/bionic/wait.c
+++ b/libc/bionic/wait.cpp
@@ -25,29 +25,30 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+
 #include <sys/wait.h>
 #include <stddef.h>
 
-extern pid_t  __wait4 (pid_t pid, int *status, int options, struct rusage *rusage);
-extern int    __waitid(idtype_t which, id_t id, siginfo_t *info, int options, struct rusage *ru);
+extern "C" int __waitid(idtype_t which, id_t id, siginfo_t* info, int options, struct rusage* ru);
 
-pid_t  wait( int*  status )
-{
-    return __wait4( (pid_t)-1, status, 0, NULL );
+pid_t wait(int* status) {
+  return wait4(-1, status, 0, NULL);
 }
 
-pid_t  wait3(int*  status, int options, struct rusage*  rusage)
-{
-    return __wait4( (pid_t)-1, status, options, rusage );
+pid_t wait3(int* status, int options, struct rusage* rusage) {
+  return wait4(-1, status, options, rusage);
 }
 
-pid_t  waitpid(pid_t  pid, int*  status, int  options)
-{
-    return __wait4( pid, status, options, NULL );
+pid_t waitpid(pid_t pid, int* status, int options) {
+  return wait4(pid, status, options, NULL);
 }
 
-int  waitid(idtype_t which, id_t id, siginfo_t *info, int options)
-{
-    /* the system call takes an option struct rusage that we don't need */
-    return __waitid(which, id, info, options, NULL);
+int waitid(idtype_t which, id_t id, siginfo_t* info, int options) {
+  /* the system call takes an option struct rusage that we don't need */
+  return __waitid(which, id, info, options, NULL);
+}
+
+// TODO: remove this backward compatibility hack (for jb-mr1 strace binaries).
+extern "C" pid_t __wait4(pid_t pid, int* status, int options, struct rusage* rusage) {
+  return wait4(pid, status, options, rusage);
 }
diff --git a/libc/docs/OVERVIEW.TXT b/libc/docs/OVERVIEW.TXT
deleted file mode 100644
index a0a3493..0000000
--- a/libc/docs/OVERVIEW.TXT
+++ /dev/null
@@ -1,393 +0,0 @@
-Bionic C Library Overview:
-==========================
-
-Introduction:
-
-Core Philosophy:
-
-  The core idea behind Bionic's design is: KEEP IT REALLY SIMPLE.
-
-  This implies that the C library should only provide lightweight wrappers
-  around kernel facilities and not try to be too smart to deal with edge cases.
-
-  The name "Bionic" comes from the fact that it is part-BSD and part-Linux:
-  its source code consists in a mix of BSD C library pieces with custom
-  Linux-specific bits used to deal with threads, processes, signals and a few
-  others things.
-
-  All original BSD pieces carry the BSD copyright disclaimer. Bionic-specific 
-  bits carry the Android Open Source Project copyright disclaimer. And
-  everything is released under the BSD license.
-
-Architectures:
-
-  Bionic currently supports the ARM and x86 instruction sets. In theory, it
-  should be possible to support more, but this may require a little work (e.g.
-  adding system call IDs to SYSCALLS.TXT, described below, or modifying the
-  dynamic linker).
-
-  The ARM-specific code is under arch-arm/ and the x86-specific one is under
-  arch-x86/
-
-  Note that the x86 version is only meant to run on an x86 Android device. We
-  make absolutely no claim that you could build and use Bionic on a stock x86
-  Linux distribution (though that would be cool, so patches are welcomed :-))
-
-Syscall stubs:
-
-  Each system call function is implemented by a tiny assembler source fragment
-  (called a "syscall stub"), which is generated automatically by
-  tools/gensyscalls.py which reads the SYSCALLS.TXT file for input.
-
-  SYSCALLS.TXT contains the list of all syscall stubs to generate, along with
-  the corresponding syscall numeric identifier (which may differ between ARM
-  and x86), and its signature
-
-  If you modify this file, you may want to use tools/checksyscalls.py which
-  checks its content against official Linux kernel header files, and will
-  report errors when invalid syscall ids are used.
-
-  Sometimes, the C library function is really a wrapper that calls the
-  corresponding syscall with another name. For example, the exit() function
-  is provided by the C library and calls the _exit() syscall stub.
-
-  See SYSCALLS.TXT for documentation and details.
-
-
-time_t:
-
-  time_t is 32-bit as defined by the kernel on 32-bit CPUs. A 64-bit version
-  would be preferrable to avoid the Y2038 bug, but the kernel maintainers
-  consider that this is not needed at the moment.
-
-  Instead, Bionic provides a <time64.h> header that defines a time64_t type,
-  and related functions like mktime64(), localtime64(), etc...
-
-  strftime() uses time64_t internally, so the '%s' format (seconds since the
-  epoch) is supported for dates >= 2038.
-
-
-strftime_tz():
-
-  Bionic also provides the non-standard strftime_tz() function, a variant
-  of strftime() which also accepts a time locale descriptor as defined
-  by "struct strftime_locale" in <time.h>.
-
-  This function is used by the low-level framework code in Android.
-
-
-Timezone management:
-
-  The name of the current timezone is taken from the TZ environment variable,
-  if defined. Otherwise, the system property named 'persist.sys.timezone' is
-  checked instead.
-
-  The zoneinfo timezone database and index files are located under directory
-  /system/usr/share/zoneinfo, instead of the more Posix-compliant path of
-  /usr/share/zoneinfo
-
-
-off_t:
-
-  For similar reasons, off_t is 32-bit. We define loff_t as the 64-bit variant
-  due to BSD inheritance, but off64_t should be available as a typedef to ease
-  porting of current Linux-specific code.
-
-
-Linux kernel headers:
-
-  Bionic comes with its own set of "clean" Linux kernel headers to allow
-  user-space code to use kernel-specific declarations (e.g. IOCTLs, structure
-  declarations, constants, etc...). They are located in:
-
-     ./kernel/common,
-     ./kernel/arch-arm
-     ./kernel/arch-x86
-
-  These headers have been generated by a tool (kernel/tools/update-all.py) to
-  only include the public definitions from the original Linux kernel headers.
-
-  If you want to know why and how this is done, read kernel/README.TXT to get
-  all the (gory) details.
-
-
-PThread implementation:
-
-   Bionic's C library comes with its own pthread implementation bundled in.
-   This is different from other historical C libraries which:
-
-    - place it in an external library (-lpthread)
-    - play linker tricks with weak symbols at dynamic link time
-
-   The support for real-time features (a.k.a. -lrt) is also bundled in the
-   C library.
-
-   The implementation is based on futexes and strives to provide *very* short
-   code paths for common operations. Notable features are the following:
-
-      - pthread_mutex_t, pthread_cond_t are only 4 bytes each.
-
-      - Normal, recursive and error-check mutexes are supported, and the code
-        path is heavily optimized for the normal case, which is used most of
-        the time.
-
-      - Process-shared mutexes and condition variables are not supported.
-        Their implementation requires far more complexity and was absolutely
-        not needed for Android (which uses other inter-process synchronization
-        capabilities).
-
-        Note that they could be added in the future without breaking the ABI
-        by specifying more sophisticated code paths (which may make the common
-        paths slightly slower though).
-
-      - There is currently no support for read/write locks, priority-ceiling in
-        mutexes and other more advanced features. Again, the main idea being
-        that this was not needed for Android at all but could be added in the
-        future.
-
-pthread_cancel():
-
-   pthread_cancel() will *not* be supported in Bionic, because doing this would
-   involve making the C library significantly bigger for very little benefit.
-
-   Consider that:
-
-     - A proper implementation must insert pthread cancellation checks in a lot
-       of different places of the C library. And conformance is very difficult
-       to test properly.
-
-     - A proper implementation must also clean up resources, like releasing
-       memory, or unlocking mutexes, properly if the cancellation happens in a
-       complex function (e.g. inside gethostbyname() or fprintf() + complex
-       formatting rules). This tends to slow down the path of many functions.
-
-     - pthread cancellation cannot stop all threads: e.g. it can't do anything
-       against an infinite loop
-
-     - pthread cancellation itself has short-comings and isn't very portable
-       (see http://advogato.org/person/slamb/diary.html?start=49 for example).
-
-   All of this is contrary to the Bionic design goals. If your code depends on
-   thread cancellation, please consider alternatives.
-
-   Note however that Bionic does implement pthread_cleanup_push() and
-   pthread_cleanup_pop(), which can be used to handle cleanups that happen when
-   a thread voluntarily exits through pthread_exit() or returning from its
-   main function.
-
-
-pthread_once():
-
-  Do not call fork() within a callback provided to pthread_once(). Doing this
-  may result in a deadlock in the child process the next time it calls
-  pthread_once().
-
-  Also, you can't throw a C++ Exception from the callback (see C++ Exception
-  Support below).
-
-  The current implementation of pthread_once() lacks the necessary support of
-  multi-core-safe double-checked-locking (read and write barriers).
-
-
-Thread-specific data
-
-  The thread-specific storage only provides for a bit less than 64
-  pthread_key_t objects to each process. The implementation provides 64 real
-  slots but also uses about 5 of them (exact number may depend on
-  implementation) for its own use (e.g. two slots are pre-allocated by the C
-  library to speed-up the Android OpenGL sub-system).
-
-  Note that Posix mandates a minimum of 128 slots, but we do not claim to be
-  Posix-compliant.
-
-  Except for the main thread, the TLS area is stored at the top of the stack.
-  See comments in bionic/libc/bionic/pthread.c for details.
-
-  At the moment, thread-local storage defined through the __thread compiler
-  keyword is not supported by the Bionic C library and dynamic linker.
-
-
-Multi-core support
-
-  At the moment, Bionic does not provide or use read/write memory barriers.
-  This means that using it on certain multi-core systems might not be
-  supported, depending on its exact CPU architecture.
-
-
-Android-specific features:
-
-  Bionic provides a small number of Android-specific features to its clients:
-
-  - access to system properties:
-
-       Android provides a simple shared value/key space to all processes on the
-       system. It stores a liberal number of 'properties', each of them being a
-       simple size-limited string that can be associated to a size-limited
-       string value.
-
-       The header <sys/system_properties.h> can be used to read system
-       properties and also defines the maximum size of keys and values.
-
-   - Android-specific user/group management:
-
-       There is no /etc/passwd or /etc/groups in Android. By design, it is
-       meant to be used by a single handset user. On the other hand, Android
-       uses the Linux user/group management features extensively to secure
-       process permissions, like access to various filesystem directories.
-
-       In the Android scheme, each installed application gets its own
-       uid_t/gid_t starting from 10000; lower numerical ids are reserved for
-       system daemons.
-
-       getpwnam() recognizes some hard-coded subsystems names (e.g. "radio")
-       and will translate them to their low-user-id values. It also recognizes
-       "app_1234" as the synthetic name of the application that was installed
-       with uid 10000 + 1234, which is 11234. getgrnam() works similarly
-
-       getgrouplist() will always return a single group for any user name,
-       which is the one passed as an input parameter.
-
-       getgrgid() will similarly only return a structure that contains a
-       single-element members list, corresponding to the user with the same
-       numerical value than the group.
-
-       See bionic/libc/bionic/stubs.c for more details.
-
-    - getservent()
-
-       There is no /etc/services on Android. Instead the C library embeds a
-       constant list of services in its executable, which is parsed on demand
-       by the various functions that depend on it. See
-       bionic/libc/netbsd/net/getservent.c and
-       bionic/libc/netbsd/net/services.h
-
-       The list of services defined internally might change liberally in the
-       future. This feature is mostly historically and is very rarely used.
-
-       The getservent() returns thread-local data. getservbyport() and
-       getservbyname() are also implemented in a similar fashion.
-
-     - getprotoent()
-
-       There is no /etc/protocol on Android. Bionic does not currently
-       implement getprotoent() and related functions. If added, it will
-       likely be done in a way similar to getservent()
-
-DNS resolver:
-
-  Bionic uses a NetBSD-derived resolver library which has been modified in
-  the following ways:
-
-     - don't implement the name-server-switch feature (a.k.a. <nsswitch.h>)
-
-     - read /system/etc/resolv.conf instead of /etc/resolv.conf
-
-     - get the list of servers and the search domains for this process's
-       current interface from the dns cache.  This information is sent
-       from the framework via cache functions.
-
-     - when performing a query, use a properly randomized Query ID (instead of
-       a incremented one), for increased security.
-
-     - when performing a query, bind the local client socket to a random port
-       for increased security.
-
-     - get rid of *many* unfortunate thread-safety issues in the original code
-
-  Bionic does *not* expose implementation details of its DNS resolver; the
-  content of <arpa/nameser.h> is intentionally blank. The resolver
-  implementation might change completely in the future.
-
-
-PThread Real-Time Timers:
-
-  timer_create(), timer_gettime(), timer_settime() and timer_getoverrun() are
-  supported.
-
-  Bionic also now supports SIGEV_THREAD real-time timers (see timer_create()).
-  The implementation simply uses a single thread per timer, unlike GLibc which
-  uses complex heuristics to try to use the less threads possible when several
-  timers with compatible properties are used.
-
-  This means that if your code uses a lot of SIGEV_THREAD timers, your program
-  may consume a lot of memory. However, if your program needs many of these
-  timers, it'd better handle timeout events directly instead.
-
-  Other timers (e.g. SIGEV_SIGNAL) are handled by the kernel and use much less
-  system resources.
-
-
-Binary Compatibility:
-
-  Bionic is *not* in any way binary-compatible with the GNU C Library, ucLibc
-  or any known Linux C library. This means several things:
-
-  - You cannot expect to build something against the GNU C Library headers and
-    have it dynamically link properly to Bionic later.
-
-  - You should *really* use the Android toolchain to build your program against
-    Bionic. The toolchain deals with many important details that are crucial
-    to get something working properly.
-
-  Failure to do so will usually result in the inability to run or link your
-  program, or even runtime crashes. Several random web pages on the Internet
-  describe how you can succesfully write a "hello-world" program with the
-  ARM GNU toolchain. These examples usually work by chance, if anything else,
-  and you should not follow these instructions unless you want to waste a lot
-  of your time in the process.
-
-  Note however that you *can* generate a binary that is built against the
-  GNU C Library headers and then statically linked to it. The corresponding
-  executable should be able to run (if it doesn't use dlopen()/dlsym())
-
-
-Dynamic Linker:
-
-  Bionic comes with its own dynamic linker (just like ld.so on Linux really
-  comes from GLibc). This linker does not support all the relocations
-  generated by other GCC ARM toolchains.
-
-
-C++ Exceptions Support:
-
-  At the moment, Bionic doesn't support C++ exceptions, what this really means
-  is the following:
-
-    - If pthread_once() is called with a C++ callback that throws an exception,
-      then the C library will keep the corresponding pthread_once_t mutex
-      locked. Any further call to pthread_once() will result in a deadlock.
-
-      A proper implementation should be able to register a C++ exception
-      cleanup handler before the callback to properly unlock the
-      pthread_once_t. Unfortunately this requires tricky assembly code that
-      is highly dependent on the compiler.
-
-      This feature is not planned to be supported anytime soon.
-
-    - The same problem may arise if you throw an exception within a callback
-      called from the C library. Fortunately, these cases are very rare in the
-      real-world, but any callback you provide to the C library should *not*
-      throw an exception.
-
-    - Bionic lacks a few support functions to have exception support work
-      properly.
-
-System V IPCs:
-
-  Bionic intentionally does not provide support for System-V IPCs mechanisms,
-  like the ones provided by semget(), shmget(), msgget(). The reason for this
-  is to avoid denial-of-service. For a detailed rationale about this, please
-  read the file docs/SYSV-IPCS.TXT.
-
-Include Paths:
-
-  The Android build system should automatically provide the necessary include
-  paths required to build against the C library headers. However, if you want
-  to do that yourself, you will need to add:
-
-      libc/arch-$ARCH/include
-      libc/include
-      libc/kernel/common
-      libc/kernel/arch-$ARCH
-
-  to your C include path.
diff --git a/libc/docs/SYSV-IPC.TXT b/libc/docs/SYSV-IPC.TXT
deleted file mode 100644
index 5a3eef0..0000000
--- a/libc/docs/SYSV-IPC.TXT
+++ /dev/null
@@ -1,103 +0,0 @@
-Android does not support System V IPCs, i.e. the facilities provided by the
-following standard Posix headers:
-
-  <sys/sem.h>   /* SysV semaphores */
-  <sys/shm.h>   /* SysV shared memory segments */
-  <sys/msg.h>   /* SysV message queues */
-  <sys/ipc.h>   /* General IPC definitions */
-
-The reason for this is due to the fact that, by design, they lead to global
-kernel resource leakage.
-
-For example, there is no way to automatically release a SysV semaphore
-allocated in the kernel when:
-
-- a buggy or malicious process exits
-- a non-buggy and non-malicious process crashes or is explicitely killed.
-
-Killing processes automatically to make room for new ones is an
-important part of Android's application lifecycle implementation. This means
-that, even assuming only non-buggy and non-malicious code, it is very likely
-that over time, the kernel global tables used to implement SysV IPCs will fill
-up.
-
-At that point, strange failures are likely to occur and prevent programs that
-use them to run properly until the next reboot of the system.
-
-And we can't ignore potential malicious applications. As a proof of concept
-here is a simple exploit that you can run on a standard Linux box today:
-
---------------- cut here ------------------------
-#include <sys/sem.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#define  NUM_SEMAPHORES  32
-#define  MAX_FAILS       10
-
-int  main(void)
-{
-    int   counter = 0;
-    int   fails   = 0;
-
-    if (counter == IPC_PRIVATE)
-        counter++;
-
-    printf( "%d (NUM_SEMAPHORES=%d)\n", counter, NUM_SEMAPHORES);
-
-    for (;;) {
-        int  ret = fork();
-        int  status;
-
-        if (ret < 0) {
-            perror("fork:");
-            break;
-        }
-        if (ret == 0) {
-            /* in the child */
-            ret = semget( (key_t)counter, NUM_SEMAPHORES, IPC_CREAT );
-            if (ret < 0) {
-                return errno;
-            }
-            return 0;
-        }
-        else {
-            /* in the parent */
-            ret = wait(&status);
-            if (ret < 0) {
-                perror("waitpid:");
-                break;
-            }
-            if (status != 0) {
-                status = WEXITSTATUS(status);
-                fprintf(stderr, "child %d FAIL at counter=%d: %d\n", ret,
-                                counter, status);
-                if (++fails >= MAX_FAILS)
-                    break;
-            }
-        }
-
-        counter++;
-        if ((counter % 1000) == 0) {
-            printf("%d\n", counter);
-        }
-        if (counter == IPC_PRIVATE)
-            counter++;
-    }
-    return 0;
-}
---------------- cut here ------------------------
-
-If you run it on a typical Linux distribution today, you'll discover that it
-will quickly fill up the kernel's table of unique key_t values, and that
-strange things will happen in some parts of the system, but not all.
-
-(You can use the "ipcs -u" command to get a summary describing the kernel
- tables and their allocations)
-
-For example, in our experience, anything program launched after that that
-calls strerror() will simply crash. The USB sub-system starts spoutting weird
-errors to the system console, etc...
diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h
index 7ab7205..de2e3e3 100644
--- a/libc/include/fcntl.h
+++ b/libc/include/fcntl.h
@@ -49,7 +49,7 @@
 extern int  fcntl(int   fd, int   command, ...);
 extern int  creat(const char*  path, mode_t  mode);
 
-#if defined(__BIONIC_FORTIFY_INLINE)
+#if defined(__BIONIC_FORTIFY)
 
 extern void __creat_error()
     __attribute__((__error__ ("called with O_CREAT, but missing mode")));
@@ -101,7 +101,7 @@
     return __openat_real(dirfd, pathname, flags, __builtin_va_arg_pack());
 }
 
-#endif /* defined(__BIONIC_FORTIFY_INLINE) */
+#endif /* defined(__BIONIC_FORTIFY) */
 
 __END_DECLS
 
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index 62882db..fdf747d 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -457,7 +457,7 @@
 __END_DECLS
 #endif /* _GNU_SOURCE */
 
-#if defined(__BIONIC_FORTIFY_INLINE)
+#if defined(__BIONIC_FORTIFY)
 
 __BEGIN_DECLS
 
@@ -538,6 +538,6 @@
 
 __END_DECLS
 
-#endif /* defined(__BIONIC_FORTIFY_INLINE) */
+#endif /* defined(__BIONIC_FORTIFY) */
 
 #endif /* _STDIO_H_ */
diff --git a/libc/include/string.h b/libc/include/string.h
index 63e768e..56d89a4 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -84,7 +84,7 @@
 extern int    strcoll(const char *, const char *) __purefunc;
 extern size_t strxfrm(char *, const char *, size_t);
 
-#if defined(__BIONIC_FORTIFY_INLINE)
+#if defined(__BIONIC_FORTIFY)
 
 extern void __memcpy_dest_size_error()
     __attribute__((__error__("memcpy called with size bigger than destination")));
@@ -258,7 +258,7 @@
 }
 
 
-#endif /* defined(__BIONIC_FORTIFY_INLINE) */
+#endif /* defined(__BIONIC_FORTIFY) */
 
 __END_DECLS
 
diff --git a/libc/include/strings.h b/libc/include/strings.h
index 0ee691d..e72798b 100644
--- a/libc/include/strings.h
+++ b/libc/include/strings.h
@@ -50,12 +50,12 @@
 int	 strcasecmp(const char *, const char *);
 int	 strncasecmp(const char *, const char *, size_t);
 
-#if defined(__BIONIC_FORTIFY_INLINE)
+#if defined(__BIONIC_FORTIFY)
 __BIONIC_FORTIFY_INLINE
 void bzero (void *s, size_t n) {
     __builtin___memset_chk(s, '\0', n, __builtin_object_size (s, 0));
 }
-#endif /* defined(__BIONIC_FORTIFY_INLINE) */
+#endif /* defined(__BIONIC_FORTIFY) */
 
 __END_DECLS
 
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index 3617aba..1976d6a 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -516,13 +516,14 @@
 #include <android/api-level.h>
 
 #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 && !defined(__clang__)
+#define __BIONIC_FORTIFY 1
 #define __BIONIC_FORTIFY_INLINE \
     extern inline \
     __attribute__ ((always_inline)) \
     __attribute__ ((gnu_inline)) \
     __attribute__ ((artificial))
-#define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1)
 #endif
+#define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1)
 
 /* Android-added: for FreeBSD's libm. */
 #define __weak_reference(sym,alias) \
diff --git a/libc/include/sys/glibc-syscalls.h b/libc/include/sys/glibc-syscalls.h
new file mode 100644
index 0000000..44f37c8
--- /dev/null
+++ b/libc/include/sys/glibc-syscalls.h
@@ -0,0 +1,1050 @@
+/* Auto-generated by gensyscalls.py; do not edit. */
+#ifndef _BIONIC_GLIBC_SYSCALLS_H_
+#define _BIONIC_GLIBC_SYSCALLS_H_
+#if defined(__arm__)
+#define SYS_accept __NR_accept
+#define SYS_accept4 __NR_accept4
+#define SYS_access __NR_access
+#define SYS_acct __NR_acct
+#define SYS_add_key __NR_add_key
+#define SYS_adjtimex __NR_adjtimex
+#define SYS_alarm __NR_alarm
+#define SYS_arm_fadvise64_64 __NR_arm_fadvise64_64
+#define SYS_arm_sync_file_range __NR_arm_sync_file_range
+#define SYS_bdflush __NR_bdflush
+#define SYS_bind __NR_bind
+#define SYS_brk __NR_brk
+#define SYS_capget __NR_capget
+#define SYS_capset __NR_capset
+#define SYS_chdir __NR_chdir
+#define SYS_chmod __NR_chmod
+#define SYS_chown __NR_chown
+#define SYS_chown32 __NR_chown32
+#define SYS_chroot __NR_chroot
+#define SYS_clock_adjtime __NR_clock_adjtime
+#define SYS_clock_getres __NR_clock_getres
+#define SYS_clock_gettime __NR_clock_gettime
+#define SYS_clock_nanosleep __NR_clock_nanosleep
+#define SYS_clock_settime __NR_clock_settime
+#define SYS_clone __NR_clone
+#define SYS_close __NR_close
+#define SYS_connect __NR_connect
+#define SYS_creat __NR_creat
+#define SYS_delete_module __NR_delete_module
+#define SYS_dup __NR_dup
+#define SYS_dup2 __NR_dup2
+#define SYS_dup3 __NR_dup3
+#define SYS_epoll_create __NR_epoll_create
+#define SYS_epoll_create1 __NR_epoll_create1
+#define SYS_epoll_ctl __NR_epoll_ctl
+#define SYS_epoll_pwait __NR_epoll_pwait
+#define SYS_epoll_wait __NR_epoll_wait
+#define SYS_eventfd __NR_eventfd
+#define SYS_eventfd2 __NR_eventfd2
+#define SYS_execve __NR_execve
+#define SYS_exit __NR_exit
+#define SYS_exit_group __NR_exit_group
+#define SYS_faccessat __NR_faccessat
+#define SYS_fallocate __NR_fallocate
+#define SYS_fanotify_init __NR_fanotify_init
+#define SYS_fanotify_mark __NR_fanotify_mark
+#define SYS_fchdir __NR_fchdir
+#define SYS_fchmod __NR_fchmod
+#define SYS_fchmodat __NR_fchmodat
+#define SYS_fchown __NR_fchown
+#define SYS_fchown32 __NR_fchown32
+#define SYS_fchownat __NR_fchownat
+#define SYS_fcntl __NR_fcntl
+#define SYS_fcntl64 __NR_fcntl64
+#define SYS_fdatasync __NR_fdatasync
+#define SYS_fgetxattr __NR_fgetxattr
+#define SYS_flistxattr __NR_flistxattr
+#define SYS_flock __NR_flock
+#define SYS_fork __NR_fork
+#define SYS_fremovexattr __NR_fremovexattr
+#define SYS_fsetxattr __NR_fsetxattr
+#define SYS_fstat __NR_fstat
+#define SYS_fstat64 __NR_fstat64
+#define SYS_fstatat64 __NR_fstatat64
+#define SYS_fstatfs __NR_fstatfs
+#define SYS_fstatfs64 __NR_fstatfs64
+#define SYS_fsync __NR_fsync
+#define SYS_ftruncate __NR_ftruncate
+#define SYS_ftruncate64 __NR_ftruncate64
+#define SYS_futex __NR_futex
+#define SYS_futimesat __NR_futimesat
+#define SYS_get_mempolicy __NR_get_mempolicy
+#define SYS_get_robust_list __NR_get_robust_list
+#define SYS_getcpu __NR_getcpu
+#define SYS_getcwd __NR_getcwd
+#define SYS_getdents __NR_getdents
+#define SYS_getdents64 __NR_getdents64
+#define SYS_getegid __NR_getegid
+#define SYS_getegid32 __NR_getegid32
+#define SYS_geteuid __NR_geteuid
+#define SYS_geteuid32 __NR_geteuid32
+#define SYS_getgid __NR_getgid
+#define SYS_getgid32 __NR_getgid32
+#define SYS_getgroups __NR_getgroups
+#define SYS_getgroups32 __NR_getgroups32
+#define SYS_getitimer __NR_getitimer
+#define SYS_getpeername __NR_getpeername
+#define SYS_getpgid __NR_getpgid
+#define SYS_getpgrp __NR_getpgrp
+#define SYS_getpid __NR_getpid
+#define SYS_getppid __NR_getppid
+#define SYS_getpriority __NR_getpriority
+#define SYS_getresgid __NR_getresgid
+#define SYS_getresgid32 __NR_getresgid32
+#define SYS_getresuid __NR_getresuid
+#define SYS_getresuid32 __NR_getresuid32
+#define SYS_getrlimit __NR_getrlimit
+#define SYS_getrusage __NR_getrusage
+#define SYS_getsid __NR_getsid
+#define SYS_getsockname __NR_getsockname
+#define SYS_getsockopt __NR_getsockopt
+#define SYS_gettid __NR_gettid
+#define SYS_gettimeofday __NR_gettimeofday
+#define SYS_getuid __NR_getuid
+#define SYS_getuid32 __NR_getuid32
+#define SYS_getxattr __NR_getxattr
+#define SYS_init_module __NR_init_module
+#define SYS_inotify_add_watch __NR_inotify_add_watch
+#define SYS_inotify_init __NR_inotify_init
+#define SYS_inotify_init1 __NR_inotify_init1
+#define SYS_inotify_rm_watch __NR_inotify_rm_watch
+#define SYS_io_cancel __NR_io_cancel
+#define SYS_io_destroy __NR_io_destroy
+#define SYS_io_getevents __NR_io_getevents
+#define SYS_io_setup __NR_io_setup
+#define SYS_io_submit __NR_io_submit
+#define SYS_ioctl __NR_ioctl
+#define SYS_ioprio_get __NR_ioprio_get
+#define SYS_ioprio_set __NR_ioprio_set
+#define SYS_ipc __NR_ipc
+#define SYS_kexec_load __NR_kexec_load
+#define SYS_keyctl __NR_keyctl
+#define SYS_kill __NR_kill
+#define SYS_lchown __NR_lchown
+#define SYS_lchown32 __NR_lchown32
+#define SYS_lgetxattr __NR_lgetxattr
+#define SYS_link __NR_link
+#define SYS_linkat __NR_linkat
+#define SYS_listen __NR_listen
+#define SYS_listxattr __NR_listxattr
+#define SYS_llistxattr __NR_llistxattr
+#define SYS_lookup_dcookie __NR_lookup_dcookie
+#define SYS_lremovexattr __NR_lremovexattr
+#define SYS_lseek __NR_lseek
+#define SYS_lsetxattr __NR_lsetxattr
+#define SYS_lstat __NR_lstat
+#define SYS_lstat64 __NR_lstat64
+#define SYS_madvise __NR_madvise
+#define SYS_mbind __NR_mbind
+#define SYS_mincore __NR_mincore
+#define SYS_mkdir __NR_mkdir
+#define SYS_mkdirat __NR_mkdirat
+#define SYS_mknod __NR_mknod
+#define SYS_mknodat __NR_mknodat
+#define SYS_mlock __NR_mlock
+#define SYS_mlockall __NR_mlockall
+#define SYS_mmap __NR_mmap
+#define SYS_mmap2 __NR_mmap2
+#define SYS_mount __NR_mount
+#define SYS_move_pages __NR_move_pages
+#define SYS_mprotect __NR_mprotect
+#define SYS_mq_getsetattr __NR_mq_getsetattr
+#define SYS_mq_notify __NR_mq_notify
+#define SYS_mq_open __NR_mq_open
+#define SYS_mq_timedreceive __NR_mq_timedreceive
+#define SYS_mq_timedsend __NR_mq_timedsend
+#define SYS_mq_unlink __NR_mq_unlink
+#define SYS_mremap __NR_mremap
+#define SYS_msgctl __NR_msgctl
+#define SYS_msgget __NR_msgget
+#define SYS_msgrcv __NR_msgrcv
+#define SYS_msgsnd __NR_msgsnd
+#define SYS_msync __NR_msync
+#define SYS_munlock __NR_munlock
+#define SYS_munlockall __NR_munlockall
+#define SYS_munmap __NR_munmap
+#define SYS_name_to_handle_at __NR_name_to_handle_at
+#define SYS_nanosleep __NR_nanosleep
+#define SYS_nfsservctl __NR_nfsservctl
+#define SYS_nice __NR_nice
+#define SYS_open __NR_open
+#define SYS_open_by_handle_at __NR_open_by_handle_at
+#define SYS_openat __NR_openat
+#define SYS_pause __NR_pause
+#define SYS_pciconfig_iobase __NR_pciconfig_iobase
+#define SYS_pciconfig_read __NR_pciconfig_read
+#define SYS_pciconfig_write __NR_pciconfig_write
+#define SYS_perf_event_open __NR_perf_event_open
+#define SYS_personality __NR_personality
+#define SYS_pipe __NR_pipe
+#define SYS_pipe2 __NR_pipe2
+#define SYS_pivot_root __NR_pivot_root
+#define SYS_poll __NR_poll
+#define SYS_ppoll __NR_ppoll
+#define SYS_prctl __NR_prctl
+#define SYS_pread64 __NR_pread64
+#define SYS_preadv __NR_preadv
+#define SYS_prlimit64 __NR_prlimit64
+#define SYS_process_vm_readv __NR_process_vm_readv
+#define SYS_process_vm_writev __NR_process_vm_writev
+#define SYS_pselect6 __NR_pselect6
+#define SYS_ptrace __NR_ptrace
+#define SYS_pwrite64 __NR_pwrite64
+#define SYS_pwritev __NR_pwritev
+#define SYS_quotactl __NR_quotactl
+#define SYS_read __NR_read
+#define SYS_readahead __NR_readahead
+#define SYS_readdir __NR_readdir
+#define SYS_readlink __NR_readlink
+#define SYS_readlinkat __NR_readlinkat
+#define SYS_readv __NR_readv
+#define SYS_reboot __NR_reboot
+#define SYS_recv __NR_recv
+#define SYS_recvfrom __NR_recvfrom
+#define SYS_recvmmsg __NR_recvmmsg
+#define SYS_recvmsg __NR_recvmsg
+#define SYS_remap_file_pages __NR_remap_file_pages
+#define SYS_removexattr __NR_removexattr
+#define SYS_rename __NR_rename
+#define SYS_renameat __NR_renameat
+#define SYS_request_key __NR_request_key
+#define SYS_restart_syscall __NR_restart_syscall
+#define SYS_rmdir __NR_rmdir
+#define SYS_rt_sigaction __NR_rt_sigaction
+#define SYS_rt_sigpending __NR_rt_sigpending
+#define SYS_rt_sigprocmask __NR_rt_sigprocmask
+#define SYS_rt_sigqueueinfo __NR_rt_sigqueueinfo
+#define SYS_rt_sigreturn __NR_rt_sigreturn
+#define SYS_rt_sigsuspend __NR_rt_sigsuspend
+#define SYS_rt_sigtimedwait __NR_rt_sigtimedwait
+#define SYS_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo
+#define SYS_sched_get_priority_max __NR_sched_get_priority_max
+#define SYS_sched_get_priority_min __NR_sched_get_priority_min
+#define SYS_sched_getaffinity __NR_sched_getaffinity
+#define SYS_sched_getparam __NR_sched_getparam
+#define SYS_sched_getscheduler __NR_sched_getscheduler
+#define SYS_sched_rr_get_interval __NR_sched_rr_get_interval
+#define SYS_sched_setaffinity __NR_sched_setaffinity
+#define SYS_sched_setparam __NR_sched_setparam
+#define SYS_sched_setscheduler __NR_sched_setscheduler
+#define SYS_sched_yield __NR_sched_yield
+#define SYS_select __NR_select
+#define SYS_semctl __NR_semctl
+#define SYS_semget __NR_semget
+#define SYS_semop __NR_semop
+#define SYS_semtimedop __NR_semtimedop
+#define SYS_send __NR_send
+#define SYS_sendfile __NR_sendfile
+#define SYS_sendfile64 __NR_sendfile64
+#define SYS_sendmmsg __NR_sendmmsg
+#define SYS_sendmsg __NR_sendmsg
+#define SYS_sendto __NR_sendto
+#define SYS_set_mempolicy __NR_set_mempolicy
+#define SYS_set_robust_list __NR_set_robust_list
+#define SYS_set_tid_address __NR_set_tid_address
+#define SYS_setdomainname __NR_setdomainname
+#define SYS_setfsgid __NR_setfsgid
+#define SYS_setfsgid32 __NR_setfsgid32
+#define SYS_setfsuid __NR_setfsuid
+#define SYS_setfsuid32 __NR_setfsuid32
+#define SYS_setgid __NR_setgid
+#define SYS_setgid32 __NR_setgid32
+#define SYS_setgroups __NR_setgroups
+#define SYS_setgroups32 __NR_setgroups32
+#define SYS_sethostname __NR_sethostname
+#define SYS_setitimer __NR_setitimer
+#define SYS_setns __NR_setns
+#define SYS_setpgid __NR_setpgid
+#define SYS_setpriority __NR_setpriority
+#define SYS_setregid __NR_setregid
+#define SYS_setregid32 __NR_setregid32
+#define SYS_setresgid __NR_setresgid
+#define SYS_setresgid32 __NR_setresgid32
+#define SYS_setresuid __NR_setresuid
+#define SYS_setresuid32 __NR_setresuid32
+#define SYS_setreuid __NR_setreuid
+#define SYS_setreuid32 __NR_setreuid32
+#define SYS_setrlimit __NR_setrlimit
+#define SYS_setsid __NR_setsid
+#define SYS_setsockopt __NR_setsockopt
+#define SYS_settimeofday __NR_settimeofday
+#define SYS_setuid __NR_setuid
+#define SYS_setuid32 __NR_setuid32
+#define SYS_setxattr __NR_setxattr
+#define SYS_shmat __NR_shmat
+#define SYS_shmctl __NR_shmctl
+#define SYS_shmdt __NR_shmdt
+#define SYS_shmget __NR_shmget
+#define SYS_shutdown __NR_shutdown
+#define SYS_sigaction __NR_sigaction
+#define SYS_sigaltstack __NR_sigaltstack
+#define SYS_signalfd __NR_signalfd
+#define SYS_signalfd4 __NR_signalfd4
+#define SYS_sigpending __NR_sigpending
+#define SYS_sigprocmask __NR_sigprocmask
+#define SYS_sigreturn __NR_sigreturn
+#define SYS_sigsuspend __NR_sigsuspend
+#define SYS_socket __NR_socket
+#define SYS_socketcall __NR_socketcall
+#define SYS_socketpair __NR_socketpair
+#define SYS_splice __NR_splice
+#define SYS_stat __NR_stat
+#define SYS_stat64 __NR_stat64
+#define SYS_statfs __NR_statfs
+#define SYS_statfs64 __NR_statfs64
+#define SYS_stime __NR_stime
+#define SYS_swapoff __NR_swapoff
+#define SYS_swapon __NR_swapon
+#define SYS_symlink __NR_symlink
+#define SYS_symlinkat __NR_symlinkat
+#define SYS_sync __NR_sync
+#define SYS_sync_file_range2 __NR_sync_file_range2
+#define SYS_syncfs __NR_syncfs
+#define SYS_syscall __NR_syscall
+#define SYS_sysfs __NR_sysfs
+#define SYS_sysinfo __NR_sysinfo
+#define SYS_syslog __NR_syslog
+#define SYS_tee __NR_tee
+#define SYS_tgkill __NR_tgkill
+#define SYS_time __NR_time
+#define SYS_timer_create __NR_timer_create
+#define SYS_timer_delete __NR_timer_delete
+#define SYS_timer_getoverrun __NR_timer_getoverrun
+#define SYS_timer_gettime __NR_timer_gettime
+#define SYS_timer_settime __NR_timer_settime
+#define SYS_timerfd_create __NR_timerfd_create
+#define SYS_timerfd_gettime __NR_timerfd_gettime
+#define SYS_timerfd_settime __NR_timerfd_settime
+#define SYS_times __NR_times
+#define SYS_tkill __NR_tkill
+#define SYS_truncate __NR_truncate
+#define SYS_truncate64 __NR_truncate64
+#define SYS_ugetrlimit __NR_ugetrlimit
+#define SYS_umask __NR_umask
+#define SYS_umount __NR_umount
+#define SYS_umount2 __NR_umount2
+#define SYS_uname __NR_uname
+#define SYS_unlink __NR_unlink
+#define SYS_unlinkat __NR_unlinkat
+#define SYS_unshare __NR_unshare
+#define SYS_uselib __NR_uselib
+#define SYS_ustat __NR_ustat
+#define SYS_utime __NR_utime
+#define SYS_utimensat __NR_utimensat
+#define SYS_utimes __NR_utimes
+#define SYS_vfork __NR_vfork
+#define SYS_vhangup __NR_vhangup
+#define SYS_vmsplice __NR_vmsplice
+#define SYS_vserver __NR_vserver
+#define SYS_wait4 __NR_wait4
+#define SYS_waitid __NR_waitid
+#define SYS_write __NR_write
+#define SYS_writev __NR_writev
+#elif defined(__mips__)
+#define SYS_accept __NR_accept
+#define SYS_accept4 __NR_accept4
+#define SYS_access __NR_access
+#define SYS_acct __NR_acct
+#define SYS_add_key __NR_add_key
+#define SYS_adjtimex __NR_adjtimex
+#define SYS_afs_syscall __NR_afs_syscall
+#define SYS_alarm __NR_alarm
+#define SYS_bdflush __NR_bdflush
+#define SYS_bind __NR_bind
+#define SYS_break __NR_break
+#define SYS_brk __NR_brk
+#define SYS_cachectl __NR_cachectl
+#define SYS_cacheflush __NR_cacheflush
+#define SYS_capget __NR_capget
+#define SYS_capset __NR_capset
+#define SYS_chdir __NR_chdir
+#define SYS_chmod __NR_chmod
+#define SYS_chown __NR_chown
+#define SYS_chroot __NR_chroot
+#define SYS_clock_adjtime __NR_clock_adjtime
+#define SYS_clock_getres __NR_clock_getres
+#define SYS_clock_gettime __NR_clock_gettime
+#define SYS_clock_nanosleep __NR_clock_nanosleep
+#define SYS_clock_settime __NR_clock_settime
+#define SYS_clone __NR_clone
+#define SYS_close __NR_close
+#define SYS_connect __NR_connect
+#define SYS_creat __NR_creat
+#define SYS_create_module __NR_create_module
+#define SYS_delete_module __NR_delete_module
+#define SYS_dup __NR_dup
+#define SYS_dup2 __NR_dup2
+#define SYS_dup3 __NR_dup3
+#define SYS_epoll_create __NR_epoll_create
+#define SYS_epoll_create1 __NR_epoll_create1
+#define SYS_epoll_ctl __NR_epoll_ctl
+#define SYS_epoll_pwait __NR_epoll_pwait
+#define SYS_epoll_wait __NR_epoll_wait
+#define SYS_eventfd __NR_eventfd
+#define SYS_eventfd2 __NR_eventfd2
+#define SYS_execve __NR_execve
+#define SYS_exit __NR_exit
+#define SYS_exit_group __NR_exit_group
+#define SYS_faccessat __NR_faccessat
+#define SYS_fadvise64 __NR_fadvise64
+#define SYS_fallocate __NR_fallocate
+#define SYS_fanotify_init __NR_fanotify_init
+#define SYS_fanotify_mark __NR_fanotify_mark
+#define SYS_fchdir __NR_fchdir
+#define SYS_fchmod __NR_fchmod
+#define SYS_fchmodat __NR_fchmodat
+#define SYS_fchown __NR_fchown
+#define SYS_fchownat __NR_fchownat
+#define SYS_fcntl __NR_fcntl
+#define SYS_fcntl64 __NR_fcntl64
+#define SYS_fdatasync __NR_fdatasync
+#define SYS_fgetxattr __NR_fgetxattr
+#define SYS_flistxattr __NR_flistxattr
+#define SYS_flock __NR_flock
+#define SYS_fork __NR_fork
+#define SYS_fremovexattr __NR_fremovexattr
+#define SYS_fsetxattr __NR_fsetxattr
+#define SYS_fstat __NR_fstat
+#define SYS_fstat64 __NR_fstat64
+#define SYS_fstatat64 __NR_fstatat64
+#define SYS_fstatfs __NR_fstatfs
+#define SYS_fstatfs64 __NR_fstatfs64
+#define SYS_fsync __NR_fsync
+#define SYS_ftime __NR_ftime
+#define SYS_ftruncate __NR_ftruncate
+#define SYS_ftruncate64 __NR_ftruncate64
+#define SYS_futex __NR_futex
+#define SYS_futimesat __NR_futimesat
+#define SYS_get_kernel_syms __NR_get_kernel_syms
+#define SYS_get_mempolicy __NR_get_mempolicy
+#define SYS_get_robust_list __NR_get_robust_list
+#define SYS_getcpu __NR_getcpu
+#define SYS_getcwd __NR_getcwd
+#define SYS_getdents __NR_getdents
+#define SYS_getdents64 __NR_getdents64
+#define SYS_getegid __NR_getegid
+#define SYS_geteuid __NR_geteuid
+#define SYS_getgid __NR_getgid
+#define SYS_getgroups __NR_getgroups
+#define SYS_getitimer __NR_getitimer
+#define SYS_getpeername __NR_getpeername
+#define SYS_getpgid __NR_getpgid
+#define SYS_getpgrp __NR_getpgrp
+#define SYS_getpid __NR_getpid
+#define SYS_getpmsg __NR_getpmsg
+#define SYS_getppid __NR_getppid
+#define SYS_getpriority __NR_getpriority
+#define SYS_getresgid __NR_getresgid
+#define SYS_getresuid __NR_getresuid
+#define SYS_getrlimit __NR_getrlimit
+#define SYS_getrusage __NR_getrusage
+#define SYS_getsid __NR_getsid
+#define SYS_getsockname __NR_getsockname
+#define SYS_getsockopt __NR_getsockopt
+#define SYS_gettid __NR_gettid
+#define SYS_gettimeofday __NR_gettimeofday
+#define SYS_getuid __NR_getuid
+#define SYS_getxattr __NR_getxattr
+#define SYS_gtty __NR_gtty
+#define SYS_idle __NR_idle
+#define SYS_init_module __NR_init_module
+#define SYS_inotify_add_watch __NR_inotify_add_watch
+#define SYS_inotify_init __NR_inotify_init
+#define SYS_inotify_init1 __NR_inotify_init1
+#define SYS_inotify_rm_watch __NR_inotify_rm_watch
+#define SYS_io_cancel __NR_io_cancel
+#define SYS_io_destroy __NR_io_destroy
+#define SYS_io_getevents __NR_io_getevents
+#define SYS_io_setup __NR_io_setup
+#define SYS_io_submit __NR_io_submit
+#define SYS_ioctl __NR_ioctl
+#define SYS_ioperm __NR_ioperm
+#define SYS_iopl __NR_iopl
+#define SYS_ioprio_get __NR_ioprio_get
+#define SYS_ioprio_set __NR_ioprio_set
+#define SYS_ipc __NR_ipc
+#define SYS_kexec_load __NR_kexec_load
+#define SYS_keyctl __NR_keyctl
+#define SYS_kill __NR_kill
+#define SYS_lchown __NR_lchown
+#define SYS_lgetxattr __NR_lgetxattr
+#define SYS_link __NR_link
+#define SYS_linkat __NR_linkat
+#define SYS_listen __NR_listen
+#define SYS_listxattr __NR_listxattr
+#define SYS_llistxattr __NR_llistxattr
+#define SYS_lock __NR_lock
+#define SYS_lookup_dcookie __NR_lookup_dcookie
+#define SYS_lremovexattr __NR_lremovexattr
+#define SYS_lseek __NR_lseek
+#define SYS_lsetxattr __NR_lsetxattr
+#define SYS_lstat __NR_lstat
+#define SYS_lstat64 __NR_lstat64
+#define SYS_madvise __NR_madvise
+#define SYS_mbind __NR_mbind
+#define SYS_migrate_pages __NR_migrate_pages
+#define SYS_mincore __NR_mincore
+#define SYS_mkdir __NR_mkdir
+#define SYS_mkdirat __NR_mkdirat
+#define SYS_mknod __NR_mknod
+#define SYS_mknodat __NR_mknodat
+#define SYS_mlock __NR_mlock
+#define SYS_mlockall __NR_mlockall
+#define SYS_mmap __NR_mmap
+#define SYS_mmap2 __NR_mmap2
+#define SYS_modify_ldt __NR_modify_ldt
+#define SYS_mount __NR_mount
+#define SYS_move_pages __NR_move_pages
+#define SYS_mprotect __NR_mprotect
+#define SYS_mpx __NR_mpx
+#define SYS_mq_getsetattr __NR_mq_getsetattr
+#define SYS_mq_notify __NR_mq_notify
+#define SYS_mq_open __NR_mq_open
+#define SYS_mq_timedreceive __NR_mq_timedreceive
+#define SYS_mq_timedsend __NR_mq_timedsend
+#define SYS_mq_unlink __NR_mq_unlink
+#define SYS_mremap __NR_mremap
+#define SYS_msgctl __NR_msgctl
+#define SYS_msgget __NR_msgget
+#define SYS_msgrcv __NR_msgrcv
+#define SYS_msgsnd __NR_msgsnd
+#define SYS_msync __NR_msync
+#define SYS_munlock __NR_munlock
+#define SYS_munlockall __NR_munlockall
+#define SYS_munmap __NR_munmap
+#define SYS_name_to_handle_at __NR_name_to_handle_at
+#define SYS_nanosleep __NR_nanosleep
+#define SYS_newfstatat __NR_newfstatat
+#define SYS_nfsservctl __NR_nfsservctl
+#define SYS_nice __NR_nice
+#define SYS_open __NR_open
+#define SYS_open_by_handle_at __NR_open_by_handle_at
+#define SYS_openat __NR_openat
+#define SYS_pause __NR_pause
+#define SYS_perf_event_open __NR_perf_event_open
+#define SYS_personality __NR_personality
+#define SYS_pipe __NR_pipe
+#define SYS_pipe2 __NR_pipe2
+#define SYS_pivot_root __NR_pivot_root
+#define SYS_poll __NR_poll
+#define SYS_ppoll __NR_ppoll
+#define SYS_prctl __NR_prctl
+#define SYS_pread64 __NR_pread64
+#define SYS_preadv __NR_preadv
+#define SYS_prlimit64 __NR_prlimit64
+#define SYS_process_vm_readv __NR_process_vm_readv
+#define SYS_process_vm_writev __NR_process_vm_writev
+#define SYS_prof __NR_prof
+#define SYS_profil __NR_profil
+#define SYS_pselect6 __NR_pselect6
+#define SYS_ptrace __NR_ptrace
+#define SYS_putpmsg __NR_putpmsg
+#define SYS_pwrite64 __NR_pwrite64
+#define SYS_pwritev __NR_pwritev
+#define SYS_query_module __NR_query_module
+#define SYS_quotactl __NR_quotactl
+#define SYS_read __NR_read
+#define SYS_readahead __NR_readahead
+#define SYS_readdir __NR_readdir
+#define SYS_readlink __NR_readlink
+#define SYS_readlinkat __NR_readlinkat
+#define SYS_readv __NR_readv
+#define SYS_reboot __NR_reboot
+#define SYS_recv __NR_recv
+#define SYS_recvfrom __NR_recvfrom
+#define SYS_recvmmsg __NR_recvmmsg
+#define SYS_recvmsg __NR_recvmsg
+#define SYS_remap_file_pages __NR_remap_file_pages
+#define SYS_removexattr __NR_removexattr
+#define SYS_rename __NR_rename
+#define SYS_renameat __NR_renameat
+#define SYS_request_key __NR_request_key
+#define SYS_reserved177 __NR_reserved177
+#define SYS_reserved193 __NR_reserved193
+#define SYS_reserved221 __NR_reserved221
+#define SYS_reserved82 __NR_reserved82
+#define SYS_restart_syscall __NR_restart_syscall
+#define SYS_rmdir __NR_rmdir
+#define SYS_rt_sigaction __NR_rt_sigaction
+#define SYS_rt_sigpending __NR_rt_sigpending
+#define SYS_rt_sigprocmask __NR_rt_sigprocmask
+#define SYS_rt_sigqueueinfo __NR_rt_sigqueueinfo
+#define SYS_rt_sigreturn __NR_rt_sigreturn
+#define SYS_rt_sigsuspend __NR_rt_sigsuspend
+#define SYS_rt_sigtimedwait __NR_rt_sigtimedwait
+#define SYS_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo
+#define SYS_sched_get_priority_max __NR_sched_get_priority_max
+#define SYS_sched_get_priority_min __NR_sched_get_priority_min
+#define SYS_sched_getaffinity __NR_sched_getaffinity
+#define SYS_sched_getparam __NR_sched_getparam
+#define SYS_sched_getscheduler __NR_sched_getscheduler
+#define SYS_sched_rr_get_interval __NR_sched_rr_get_interval
+#define SYS_sched_setaffinity __NR_sched_setaffinity
+#define SYS_sched_setparam __NR_sched_setparam
+#define SYS_sched_setscheduler __NR_sched_setscheduler
+#define SYS_sched_yield __NR_sched_yield
+#define SYS_semctl __NR_semctl
+#define SYS_semget __NR_semget
+#define SYS_semop __NR_semop
+#define SYS_semtimedop __NR_semtimedop
+#define SYS_send __NR_send
+#define SYS_sendfile __NR_sendfile
+#define SYS_sendfile64 __NR_sendfile64
+#define SYS_sendmmsg __NR_sendmmsg
+#define SYS_sendmsg __NR_sendmsg
+#define SYS_sendto __NR_sendto
+#define SYS_set_mempolicy __NR_set_mempolicy
+#define SYS_set_robust_list __NR_set_robust_list
+#define SYS_set_thread_area __NR_set_thread_area
+#define SYS_set_tid_address __NR_set_tid_address
+#define SYS_setdomainname __NR_setdomainname
+#define SYS_setfsgid __NR_setfsgid
+#define SYS_setfsuid __NR_setfsuid
+#define SYS_setgid __NR_setgid
+#define SYS_setgroups __NR_setgroups
+#define SYS_sethostname __NR_sethostname
+#define SYS_setitimer __NR_setitimer
+#define SYS_setns __NR_setns
+#define SYS_setpgid __NR_setpgid
+#define SYS_setpriority __NR_setpriority
+#define SYS_setregid __NR_setregid
+#define SYS_setresgid __NR_setresgid
+#define SYS_setresuid __NR_setresuid
+#define SYS_setreuid __NR_setreuid
+#define SYS_setrlimit __NR_setrlimit
+#define SYS_setsid __NR_setsid
+#define SYS_setsockopt __NR_setsockopt
+#define SYS_settimeofday __NR_settimeofday
+#define SYS_setuid __NR_setuid
+#define SYS_setxattr __NR_setxattr
+#define SYS_sgetmask __NR_sgetmask
+#define SYS_shmat __NR_shmat
+#define SYS_shmctl __NR_shmctl
+#define SYS_shmdt __NR_shmdt
+#define SYS_shmget __NR_shmget
+#define SYS_shutdown __NR_shutdown
+#define SYS_sigaction __NR_sigaction
+#define SYS_sigaltstack __NR_sigaltstack
+#define SYS_signal __NR_signal
+#define SYS_signalfd __NR_signalfd
+#define SYS_signalfd4 __NR_signalfd4
+#define SYS_sigpending __NR_sigpending
+#define SYS_sigprocmask __NR_sigprocmask
+#define SYS_sigreturn __NR_sigreturn
+#define SYS_sigsuspend __NR_sigsuspend
+#define SYS_socket __NR_socket
+#define SYS_socketcall __NR_socketcall
+#define SYS_socketpair __NR_socketpair
+#define SYS_splice __NR_splice
+#define SYS_ssetmask __NR_ssetmask
+#define SYS_stat __NR_stat
+#define SYS_stat64 __NR_stat64
+#define SYS_statfs __NR_statfs
+#define SYS_statfs64 __NR_statfs64
+#define SYS_stime __NR_stime
+#define SYS_stty __NR_stty
+#define SYS_swapoff __NR_swapoff
+#define SYS_swapon __NR_swapon
+#define SYS_symlink __NR_symlink
+#define SYS_symlinkat __NR_symlinkat
+#define SYS_sync __NR_sync
+#define SYS_sync_file_range __NR_sync_file_range
+#define SYS_syncfs __NR_syncfs
+#define SYS_syscall __NR_syscall
+#define SYS_sysfs __NR_sysfs
+#define SYS_sysinfo __NR_sysinfo
+#define SYS_syslog __NR_syslog
+#define SYS_sysmips __NR_sysmips
+#define SYS_tee __NR_tee
+#define SYS_tgkill __NR_tgkill
+#define SYS_time __NR_time
+#define SYS_timer_create __NR_timer_create
+#define SYS_timer_delete __NR_timer_delete
+#define SYS_timer_getoverrun __NR_timer_getoverrun
+#define SYS_timer_gettime __NR_timer_gettime
+#define SYS_timer_settime __NR_timer_settime
+#define SYS_timerfd __NR_timerfd
+#define SYS_timerfd_create __NR_timerfd_create
+#define SYS_timerfd_gettime __NR_timerfd_gettime
+#define SYS_timerfd_settime __NR_timerfd_settime
+#define SYS_times __NR_times
+#define SYS_tkill __NR_tkill
+#define SYS_truncate __NR_truncate
+#define SYS_truncate64 __NR_truncate64
+#define SYS_ulimit __NR_ulimit
+#define SYS_umask __NR_umask
+#define SYS_umount __NR_umount
+#define SYS_umount2 __NR_umount2
+#define SYS_uname __NR_uname
+#define SYS_unlink __NR_unlink
+#define SYS_unlinkat __NR_unlinkat
+#define SYS_unshare __NR_unshare
+#define SYS_unused109 __NR_unused109
+#define SYS_unused150 __NR_unused150
+#define SYS_unused18 __NR_unused18
+#define SYS_unused28 __NR_unused28
+#define SYS_unused59 __NR_unused59
+#define SYS_unused84 __NR_unused84
+#define SYS_uselib __NR_uselib
+#define SYS_ustat __NR_ustat
+#define SYS_utime __NR_utime
+#define SYS_utimensat __NR_utimensat
+#define SYS_utimes __NR_utimes
+#define SYS_vhangup __NR_vhangup
+#define SYS_vm86 __NR_vm86
+#define SYS_vmsplice __NR_vmsplice
+#define SYS_vserver __NR_vserver
+#define SYS_wait4 __NR_wait4
+#define SYS_waitid __NR_waitid
+#define SYS_waitpid __NR_waitpid
+#define SYS_write __NR_write
+#define SYS_writev __NR_writev
+#elif defined(__i386__)
+#define SYS_access __NR_access
+#define SYS_acct __NR_acct
+#define SYS_add_key __NR_add_key
+#define SYS_adjtimex __NR_adjtimex
+#define SYS_afs_syscall __NR_afs_syscall
+#define SYS_alarm __NR_alarm
+#define SYS_bdflush __NR_bdflush
+#define SYS_break __NR_break
+#define SYS_brk __NR_brk
+#define SYS_capget __NR_capget
+#define SYS_capset __NR_capset
+#define SYS_chdir __NR_chdir
+#define SYS_chmod __NR_chmod
+#define SYS_chown __NR_chown
+#define SYS_chown32 __NR_chown32
+#define SYS_chroot __NR_chroot
+#define SYS_clock_adjtime __NR_clock_adjtime
+#define SYS_clock_getres __NR_clock_getres
+#define SYS_clock_gettime __NR_clock_gettime
+#define SYS_clock_nanosleep __NR_clock_nanosleep
+#define SYS_clock_settime __NR_clock_settime
+#define SYS_clone __NR_clone
+#define SYS_close __NR_close
+#define SYS_creat __NR_creat
+#define SYS_create_module __NR_create_module
+#define SYS_delete_module __NR_delete_module
+#define SYS_dup __NR_dup
+#define SYS_dup2 __NR_dup2
+#define SYS_dup3 __NR_dup3
+#define SYS_epoll_create __NR_epoll_create
+#define SYS_epoll_create1 __NR_epoll_create1
+#define SYS_epoll_ctl __NR_epoll_ctl
+#define SYS_epoll_pwait __NR_epoll_pwait
+#define SYS_epoll_wait __NR_epoll_wait
+#define SYS_eventfd __NR_eventfd
+#define SYS_eventfd2 __NR_eventfd2
+#define SYS_execve __NR_execve
+#define SYS_exit __NR_exit
+#define SYS_exit_group __NR_exit_group
+#define SYS_faccessat __NR_faccessat
+#define SYS_fadvise64 __NR_fadvise64
+#define SYS_fadvise64_64 __NR_fadvise64_64
+#define SYS_fallocate __NR_fallocate
+#define SYS_fanotify_init __NR_fanotify_init
+#define SYS_fanotify_mark __NR_fanotify_mark
+#define SYS_fchdir __NR_fchdir
+#define SYS_fchmod __NR_fchmod
+#define SYS_fchmodat __NR_fchmodat
+#define SYS_fchown __NR_fchown
+#define SYS_fchown32 __NR_fchown32
+#define SYS_fchownat __NR_fchownat
+#define SYS_fcntl __NR_fcntl
+#define SYS_fcntl64 __NR_fcntl64
+#define SYS_fdatasync __NR_fdatasync
+#define SYS_fgetxattr __NR_fgetxattr
+#define SYS_flistxattr __NR_flistxattr
+#define SYS_flock __NR_flock
+#define SYS_fork __NR_fork
+#define SYS_fremovexattr __NR_fremovexattr
+#define SYS_fsetxattr __NR_fsetxattr
+#define SYS_fstat __NR_fstat
+#define SYS_fstat64 __NR_fstat64
+#define SYS_fstatat64 __NR_fstatat64
+#define SYS_fstatfs __NR_fstatfs
+#define SYS_fstatfs64 __NR_fstatfs64
+#define SYS_fsync __NR_fsync
+#define SYS_ftime __NR_ftime
+#define SYS_ftruncate __NR_ftruncate
+#define SYS_ftruncate64 __NR_ftruncate64
+#define SYS_futex __NR_futex
+#define SYS_futimesat __NR_futimesat
+#define SYS_get_kernel_syms __NR_get_kernel_syms
+#define SYS_get_mempolicy __NR_get_mempolicy
+#define SYS_get_robust_list __NR_get_robust_list
+#define SYS_get_thread_area __NR_get_thread_area
+#define SYS_getcpu __NR_getcpu
+#define SYS_getcwd __NR_getcwd
+#define SYS_getdents __NR_getdents
+#define SYS_getdents64 __NR_getdents64
+#define SYS_getegid __NR_getegid
+#define SYS_getegid32 __NR_getegid32
+#define SYS_geteuid __NR_geteuid
+#define SYS_geteuid32 __NR_geteuid32
+#define SYS_getgid __NR_getgid
+#define SYS_getgid32 __NR_getgid32
+#define SYS_getgroups __NR_getgroups
+#define SYS_getgroups32 __NR_getgroups32
+#define SYS_getitimer __NR_getitimer
+#define SYS_getpgid __NR_getpgid
+#define SYS_getpgrp __NR_getpgrp
+#define SYS_getpid __NR_getpid
+#define SYS_getpmsg __NR_getpmsg
+#define SYS_getppid __NR_getppid
+#define SYS_getpriority __NR_getpriority
+#define SYS_getresgid __NR_getresgid
+#define SYS_getresgid32 __NR_getresgid32
+#define SYS_getresuid __NR_getresuid
+#define SYS_getresuid32 __NR_getresuid32
+#define SYS_getrlimit __NR_getrlimit
+#define SYS_getrusage __NR_getrusage
+#define SYS_getsid __NR_getsid
+#define SYS_gettid __NR_gettid
+#define SYS_gettimeofday __NR_gettimeofday
+#define SYS_getuid __NR_getuid
+#define SYS_getuid32 __NR_getuid32
+#define SYS_getxattr __NR_getxattr
+#define SYS_gtty __NR_gtty
+#define SYS_idle __NR_idle
+#define SYS_init_module __NR_init_module
+#define SYS_inotify_add_watch __NR_inotify_add_watch
+#define SYS_inotify_init __NR_inotify_init
+#define SYS_inotify_init1 __NR_inotify_init1
+#define SYS_inotify_rm_watch __NR_inotify_rm_watch
+#define SYS_io_cancel __NR_io_cancel
+#define SYS_io_destroy __NR_io_destroy
+#define SYS_io_getevents __NR_io_getevents
+#define SYS_io_setup __NR_io_setup
+#define SYS_io_submit __NR_io_submit
+#define SYS_ioctl __NR_ioctl
+#define SYS_ioperm __NR_ioperm
+#define SYS_iopl __NR_iopl
+#define SYS_ioprio_get __NR_ioprio_get
+#define SYS_ioprio_set __NR_ioprio_set
+#define SYS_ipc __NR_ipc
+#define SYS_kexec_load __NR_kexec_load
+#define SYS_keyctl __NR_keyctl
+#define SYS_kill __NR_kill
+#define SYS_lchown __NR_lchown
+#define SYS_lchown32 __NR_lchown32
+#define SYS_lgetxattr __NR_lgetxattr
+#define SYS_link __NR_link
+#define SYS_linkat __NR_linkat
+#define SYS_listxattr __NR_listxattr
+#define SYS_llistxattr __NR_llistxattr
+#define SYS_lock __NR_lock
+#define SYS_lookup_dcookie __NR_lookup_dcookie
+#define SYS_lremovexattr __NR_lremovexattr
+#define SYS_lseek __NR_lseek
+#define SYS_lsetxattr __NR_lsetxattr
+#define SYS_lstat __NR_lstat
+#define SYS_lstat64 __NR_lstat64
+#define SYS_madvise __NR_madvise
+#define SYS_madvise1 __NR_madvise1
+#define SYS_mbind __NR_mbind
+#define SYS_migrate_pages __NR_migrate_pages
+#define SYS_mincore __NR_mincore
+#define SYS_mkdir __NR_mkdir
+#define SYS_mkdirat __NR_mkdirat
+#define SYS_mknod __NR_mknod
+#define SYS_mknodat __NR_mknodat
+#define SYS_mlock __NR_mlock
+#define SYS_mlockall __NR_mlockall
+#define SYS_mmap __NR_mmap
+#define SYS_mmap2 __NR_mmap2
+#define SYS_modify_ldt __NR_modify_ldt
+#define SYS_mount __NR_mount
+#define SYS_move_pages __NR_move_pages
+#define SYS_mprotect __NR_mprotect
+#define SYS_mpx __NR_mpx
+#define SYS_mq_getsetattr __NR_mq_getsetattr
+#define SYS_mq_notify __NR_mq_notify
+#define SYS_mq_open __NR_mq_open
+#define SYS_mq_timedreceive __NR_mq_timedreceive
+#define SYS_mq_timedsend __NR_mq_timedsend
+#define SYS_mq_unlink __NR_mq_unlink
+#define SYS_mremap __NR_mremap
+#define SYS_msync __NR_msync
+#define SYS_munlock __NR_munlock
+#define SYS_munlockall __NR_munlockall
+#define SYS_munmap __NR_munmap
+#define SYS_name_to_handle_at __NR_name_to_handle_at
+#define SYS_nanosleep __NR_nanosleep
+#define SYS_nfsservctl __NR_nfsservctl
+#define SYS_nice __NR_nice
+#define SYS_oldfstat __NR_oldfstat
+#define SYS_oldlstat __NR_oldlstat
+#define SYS_oldolduname __NR_oldolduname
+#define SYS_oldstat __NR_oldstat
+#define SYS_olduname __NR_olduname
+#define SYS_open __NR_open
+#define SYS_open_by_handle_at __NR_open_by_handle_at
+#define SYS_openat __NR_openat
+#define SYS_pause __NR_pause
+#define SYS_perf_event_open __NR_perf_event_open
+#define SYS_personality __NR_personality
+#define SYS_pipe __NR_pipe
+#define SYS_pipe2 __NR_pipe2
+#define SYS_pivot_root __NR_pivot_root
+#define SYS_poll __NR_poll
+#define SYS_ppoll __NR_ppoll
+#define SYS_prctl __NR_prctl
+#define SYS_pread64 __NR_pread64
+#define SYS_preadv __NR_preadv
+#define SYS_prlimit64 __NR_prlimit64
+#define SYS_prof __NR_prof
+#define SYS_profil __NR_profil
+#define SYS_pselect6 __NR_pselect6
+#define SYS_ptrace __NR_ptrace
+#define SYS_putpmsg __NR_putpmsg
+#define SYS_pwrite64 __NR_pwrite64
+#define SYS_pwritev __NR_pwritev
+#define SYS_query_module __NR_query_module
+#define SYS_quotactl __NR_quotactl
+#define SYS_read __NR_read
+#define SYS_readahead __NR_readahead
+#define SYS_readdir __NR_readdir
+#define SYS_readlink __NR_readlink
+#define SYS_readlinkat __NR_readlinkat
+#define SYS_readv __NR_readv
+#define SYS_reboot __NR_reboot
+#define SYS_recvmmsg __NR_recvmmsg
+#define SYS_remap_file_pages __NR_remap_file_pages
+#define SYS_removexattr __NR_removexattr
+#define SYS_rename __NR_rename
+#define SYS_renameat __NR_renameat
+#define SYS_request_key __NR_request_key
+#define SYS_restart_syscall __NR_restart_syscall
+#define SYS_rmdir __NR_rmdir
+#define SYS_rt_sigaction __NR_rt_sigaction
+#define SYS_rt_sigpending __NR_rt_sigpending
+#define SYS_rt_sigprocmask __NR_rt_sigprocmask
+#define SYS_rt_sigqueueinfo __NR_rt_sigqueueinfo
+#define SYS_rt_sigreturn __NR_rt_sigreturn
+#define SYS_rt_sigsuspend __NR_rt_sigsuspend
+#define SYS_rt_sigtimedwait __NR_rt_sigtimedwait
+#define SYS_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo
+#define SYS_sched_get_priority_max __NR_sched_get_priority_max
+#define SYS_sched_get_priority_min __NR_sched_get_priority_min
+#define SYS_sched_getaffinity __NR_sched_getaffinity
+#define SYS_sched_getparam __NR_sched_getparam
+#define SYS_sched_getscheduler __NR_sched_getscheduler
+#define SYS_sched_rr_get_interval __NR_sched_rr_get_interval
+#define SYS_sched_setaffinity __NR_sched_setaffinity
+#define SYS_sched_setparam __NR_sched_setparam
+#define SYS_sched_setscheduler __NR_sched_setscheduler
+#define SYS_sched_yield __NR_sched_yield
+#define SYS_select __NR_select
+#define SYS_sendfile __NR_sendfile
+#define SYS_sendfile64 __NR_sendfile64
+#define SYS_sendmmsg __NR_sendmmsg
+#define SYS_set_mempolicy __NR_set_mempolicy
+#define SYS_set_robust_list __NR_set_robust_list
+#define SYS_set_thread_area __NR_set_thread_area
+#define SYS_set_tid_address __NR_set_tid_address
+#define SYS_setdomainname __NR_setdomainname
+#define SYS_setfsgid __NR_setfsgid
+#define SYS_setfsgid32 __NR_setfsgid32
+#define SYS_setfsuid __NR_setfsuid
+#define SYS_setfsuid32 __NR_setfsuid32
+#define SYS_setgid __NR_setgid
+#define SYS_setgid32 __NR_setgid32
+#define SYS_setgroups __NR_setgroups
+#define SYS_setgroups32 __NR_setgroups32
+#define SYS_sethostname __NR_sethostname
+#define SYS_setitimer __NR_setitimer
+#define SYS_setns __NR_setns
+#define SYS_setpgid __NR_setpgid
+#define SYS_setpriority __NR_setpriority
+#define SYS_setregid __NR_setregid
+#define SYS_setregid32 __NR_setregid32
+#define SYS_setresgid __NR_setresgid
+#define SYS_setresgid32 __NR_setresgid32
+#define SYS_setresuid __NR_setresuid
+#define SYS_setresuid32 __NR_setresuid32
+#define SYS_setreuid __NR_setreuid
+#define SYS_setreuid32 __NR_setreuid32
+#define SYS_setrlimit __NR_setrlimit
+#define SYS_setsid __NR_setsid
+#define SYS_settimeofday __NR_settimeofday
+#define SYS_setuid __NR_setuid
+#define SYS_setuid32 __NR_setuid32
+#define SYS_setxattr __NR_setxattr
+#define SYS_sgetmask __NR_sgetmask
+#define SYS_sigaction __NR_sigaction
+#define SYS_sigaltstack __NR_sigaltstack
+#define SYS_signal __NR_signal
+#define SYS_signalfd __NR_signalfd
+#define SYS_signalfd4 __NR_signalfd4
+#define SYS_sigpending __NR_sigpending
+#define SYS_sigprocmask __NR_sigprocmask
+#define SYS_sigreturn __NR_sigreturn
+#define SYS_sigsuspend __NR_sigsuspend
+#define SYS_socketcall __NR_socketcall
+#define SYS_splice __NR_splice
+#define SYS_ssetmask __NR_ssetmask
+#define SYS_stat __NR_stat
+#define SYS_stat64 __NR_stat64
+#define SYS_statfs __NR_statfs
+#define SYS_statfs64 __NR_statfs64
+#define SYS_stime __NR_stime
+#define SYS_stty __NR_stty
+#define SYS_swapoff __NR_swapoff
+#define SYS_swapon __NR_swapon
+#define SYS_symlink __NR_symlink
+#define SYS_symlinkat __NR_symlinkat
+#define SYS_sync __NR_sync
+#define SYS_sync_file_range __NR_sync_file_range
+#define SYS_syncfs __NR_syncfs
+#define SYS_sysfs __NR_sysfs
+#define SYS_sysinfo __NR_sysinfo
+#define SYS_syslog __NR_syslog
+#define SYS_tee __NR_tee
+#define SYS_tgkill __NR_tgkill
+#define SYS_time __NR_time
+#define SYS_timer_create __NR_timer_create
+#define SYS_timer_delete __NR_timer_delete
+#define SYS_timer_getoverrun __NR_timer_getoverrun
+#define SYS_timer_gettime __NR_timer_gettime
+#define SYS_timer_settime __NR_timer_settime
+#define SYS_timerfd_create __NR_timerfd_create
+#define SYS_timerfd_gettime __NR_timerfd_gettime
+#define SYS_timerfd_settime __NR_timerfd_settime
+#define SYS_times __NR_times
+#define SYS_tkill __NR_tkill
+#define SYS_truncate __NR_truncate
+#define SYS_truncate64 __NR_truncate64
+#define SYS_ugetrlimit __NR_ugetrlimit
+#define SYS_ulimit __NR_ulimit
+#define SYS_umask __NR_umask
+#define SYS_umount __NR_umount
+#define SYS_umount2 __NR_umount2
+#define SYS_uname __NR_uname
+#define SYS_unlink __NR_unlink
+#define SYS_unlinkat __NR_unlinkat
+#define SYS_unshare __NR_unshare
+#define SYS_uselib __NR_uselib
+#define SYS_ustat __NR_ustat
+#define SYS_utime __NR_utime
+#define SYS_utimensat __NR_utimensat
+#define SYS_utimes __NR_utimes
+#define SYS_vfork __NR_vfork
+#define SYS_vhangup __NR_vhangup
+#define SYS_vm86 __NR_vm86
+#define SYS_vm86old __NR_vm86old
+#define SYS_vmsplice __NR_vmsplice
+#define SYS_vserver __NR_vserver
+#define SYS_wait4 __NR_wait4
+#define SYS_waitid __NR_waitid
+#define SYS_waitpid __NR_waitpid
+#define SYS_write __NR_write
+#define SYS_writev __NR_writev
+#endif
+#endif /* _BIONIC_GLIBC_SYSCALLS_H_ */
diff --git a/libc/include/sys/linux-syscalls.h b/libc/include/sys/linux-syscalls.h
deleted file mode 100644
index 738d9e8..0000000
--- a/libc/include/sys/linux-syscalls.h
+++ /dev/null
@@ -1,476 +0,0 @@
-/* auto-generated by gensyscalls.py, do not touch */
-#ifndef _BIONIC_LINUX_SYSCALLS_H_
-#define _BIONIC_LINUX_SYSCALLS_H_
-
-#if !defined __ASM_ARM_UNISTD_H && !defined __ASM_I386_UNISTD_H && !defined __ASM_MIPS_UNISTD_H
-#if defined __arm__ && !defined __ARM_EABI__ && !defined __thumb__
-  #  define __NR_SYSCALL_BASE 0x900000
-#elif defined(__mips__)
-  #  define __NR_SYSCALL_BASE 4000
-#else
-  #  define __NR_SYSCALL_BASE 0
-#endif
-
-#define __NR_exit                         (__NR_SYSCALL_BASE + 1)
-#define __NR_fork                         (__NR_SYSCALL_BASE + 2)
-#define __NR_read                         (__NR_SYSCALL_BASE + 3)
-#define __NR_write                        (__NR_SYSCALL_BASE + 4)
-#define __NR_open                         (__NR_SYSCALL_BASE + 5)
-#define __NR_close                        (__NR_SYSCALL_BASE + 6)
-#define __NR_link                         (__NR_SYSCALL_BASE + 9)
-#define __NR_unlink                       (__NR_SYSCALL_BASE + 10)
-#define __NR_execve                       (__NR_SYSCALL_BASE + 11)
-#define __NR_chdir                        (__NR_SYSCALL_BASE + 12)
-#define __NR_mknod                        (__NR_SYSCALL_BASE + 14)
-#define __NR_chmod                        (__NR_SYSCALL_BASE + 15)
-#define __NR_lseek                        (__NR_SYSCALL_BASE + 19)
-#define __NR_getpid                       (__NR_SYSCALL_BASE + 20)
-#define __NR_mount                        (__NR_SYSCALL_BASE + 21)
-#define __NR_ptrace                       (__NR_SYSCALL_BASE + 26)
-#define __NR_pause                        (__NR_SYSCALL_BASE + 29)
-#define __NR_access                       (__NR_SYSCALL_BASE + 33)
-#define __NR_sync                         (__NR_SYSCALL_BASE + 36)
-#define __NR_rename                       (__NR_SYSCALL_BASE + 38)
-#define __NR_mkdir                        (__NR_SYSCALL_BASE + 39)
-#define __NR_rmdir                        (__NR_SYSCALL_BASE + 40)
-#define __NR_dup                          (__NR_SYSCALL_BASE + 41)
-#define __NR_times                        (__NR_SYSCALL_BASE + 43)
-#define __NR_brk                          (__NR_SYSCALL_BASE + 45)
-#define __NR_acct                         (__NR_SYSCALL_BASE + 51)
-#define __NR_umount2                      (__NR_SYSCALL_BASE + 52)
-#define __NR_ioctl                        (__NR_SYSCALL_BASE + 54)
-#define __NR_fcntl                        (__NR_SYSCALL_BASE + 55)
-#define __NR_setpgid                      (__NR_SYSCALL_BASE + 57)
-#define __NR_umask                        (__NR_SYSCALL_BASE + 60)
-#define __NR_chroot                       (__NR_SYSCALL_BASE + 61)
-#define __NR_dup2                         (__NR_SYSCALL_BASE + 63)
-#define __NR_getppid                      (__NR_SYSCALL_BASE + 64)
-#define __NR_setsid                       (__NR_SYSCALL_BASE + 66)
-#define __NR_sigaction                    (__NR_SYSCALL_BASE + 67)
-#define __NR_sigpending                   (__NR_SYSCALL_BASE + 73)
-#define __NR_setrlimit                    (__NR_SYSCALL_BASE + 75)
-#define __NR_getrusage                    (__NR_SYSCALL_BASE + 77)
-#define __NR_gettimeofday                 (__NR_SYSCALL_BASE + 78)
-#define __NR_settimeofday                 (__NR_SYSCALL_BASE + 79)
-#define __NR_symlink                      (__NR_SYSCALL_BASE + 83)
-#define __NR_readlink                     (__NR_SYSCALL_BASE + 85)
-#define __NR_reboot                       (__NR_SYSCALL_BASE + 88)
-#define __NR_munmap                       (__NR_SYSCALL_BASE + 91)
-#define __NR_truncate                     (__NR_SYSCALL_BASE + 92)
-#define __NR_ftruncate                    (__NR_SYSCALL_BASE + 93)
-#define __NR_fchmod                       (__NR_SYSCALL_BASE + 94)
-#define __NR_getpriority                  (__NR_SYSCALL_BASE + 96)
-#define __NR_setpriority                  (__NR_SYSCALL_BASE + 97)
-#define __NR_syslog                       (__NR_SYSCALL_BASE + 103)
-#define __NR_syslog                       (__NR_SYSCALL_BASE + 103)
-#define __NR_setitimer                    (__NR_SYSCALL_BASE + 104)
-#define __NR_getitimer                    (__NR_SYSCALL_BASE + 105)
-#define __NR_wait4                        (__NR_SYSCALL_BASE + 114)
-#define __NR_sysinfo                      (__NR_SYSCALL_BASE + 116)
-#define __NR_fsync                        (__NR_SYSCALL_BASE + 118)
-#define __NR_clone                        (__NR_SYSCALL_BASE + 120)
-#define __NR_uname                        (__NR_SYSCALL_BASE + 122)
-#define __NR_mprotect                     (__NR_SYSCALL_BASE + 125)
-#define __NR_sigprocmask                  (__NR_SYSCALL_BASE + 126)
-#define __NR_init_module                  (__NR_SYSCALL_BASE + 128)
-#define __NR_delete_module                (__NR_SYSCALL_BASE + 129)
-#define __NR_getpgid                      (__NR_SYSCALL_BASE + 132)
-#define __NR_fchdir                       (__NR_SYSCALL_BASE + 133)
-#define __NR_personality                  (__NR_SYSCALL_BASE + 136)
-#define __NR__llseek                      (__NR_SYSCALL_BASE + 140)
-#define __NR__newselect                   (__NR_SYSCALL_BASE + 142)
-#define __NR_flock                        (__NR_SYSCALL_BASE + 143)
-#define __NR_msync                        (__NR_SYSCALL_BASE + 144)
-#define __NR_readv                        (__NR_SYSCALL_BASE + 145)
-#define __NR_writev                       (__NR_SYSCALL_BASE + 146)
-
-#ifdef __arm__
-#define __NR_exit_group                   (__NR_SYSCALL_BASE + 248)
-#define __NR_waitid                       (__NR_SYSCALL_BASE + 280)
-#define __NR_setuid32                     (__NR_SYSCALL_BASE + 213)
-#define __NR_getuid32                     (__NR_SYSCALL_BASE + 199)
-#define __NR_getgid32                     (__NR_SYSCALL_BASE + 200)
-#define __NR_geteuid32                    (__NR_SYSCALL_BASE + 201)
-#define __NR_getegid32                    (__NR_SYSCALL_BASE + 202)
-#define __NR_getresuid32                  (__NR_SYSCALL_BASE + 209)
-#define __NR_getresgid32                  (__NR_SYSCALL_BASE + 211)
-#define __NR_gettid                       (__NR_SYSCALL_BASE + 224)
-#define __NR_readahead                    (__NR_SYSCALL_BASE + 225)
-#define __NR_getgroups32                  (__NR_SYSCALL_BASE + 205)
-#define __NR_getsid                       (__NR_SYSCALL_BASE + 147)
-#define __NR_setgid32                     (__NR_SYSCALL_BASE + 214)
-#define __NR_setreuid32                   (__NR_SYSCALL_BASE + 203)
-#define __NR_setresuid32                  (__NR_SYSCALL_BASE + 208)
-#define __NR_setresgid32                  (__NR_SYSCALL_BASE + 210)
-#define __NR_ugetrlimit                   (__NR_SYSCALL_BASE + 191)
-#define __NR_setgroups32                  (__NR_SYSCALL_BASE + 206)
-#define __NR_vfork                        (__NR_SYSCALL_BASE + 190)
-#define __NR_setregid32                   (__NR_SYSCALL_BASE + 204)
-#define __NR_prctl                        (__NR_SYSCALL_BASE + 172)
-#define __NR_capget                       (__NR_SYSCALL_BASE + 184)
-#define __NR_capset                       (__NR_SYSCALL_BASE + 185)
-#define __NR_sigaltstack                  (__NR_SYSCALL_BASE + 186)
-#define __NR_pread64                      (__NR_SYSCALL_BASE + 180)
-#define __NR_pwrite64                     (__NR_SYSCALL_BASE + 181)
-#define __NR_openat                       (__NR_SYSCALL_BASE + 322)
-#define __NR_mmap2                        (__NR_SYSCALL_BASE + 192)
-#define __NR_mremap                       (__NR_SYSCALL_BASE + 163)
-#define __NR_madvise                      (__NR_SYSCALL_BASE + 220)
-#define __NR_mlock                        (__NR_SYSCALL_BASE + 150)
-#define __NR_munlock                      (__NR_SYSCALL_BASE + 151)
-#define __NR_mlockall                     (__NR_SYSCALL_BASE + 152)
-#define __NR_munlockall                   (__NR_SYSCALL_BASE + 153)
-#define __NR_mincore                      (__NR_SYSCALL_BASE + 219)
-#define __NR_pipe                         (__NR_SYSCALL_BASE + 42)
-#define __NR_pipe2                        (__NR_SYSCALL_BASE + 359)
-#define __NR_ftruncate64                  (__NR_SYSCALL_BASE + 194)
-#define __NR_getdents64                   (__NR_SYSCALL_BASE + 217)
-#define __NR_fdatasync                    (__NR_SYSCALL_BASE + 148)
-#define __NR_fchown32                     (__NR_SYSCALL_BASE + 207)
-#define __NR_fcntl64                      (__NR_SYSCALL_BASE + 221)
-#define __NR_fstatfs64                    (__NR_SYSCALL_BASE + 267)
-#define __NR_sendfile                     (__NR_SYSCALL_BASE + 187)
-#define __NR_fstatat64                    (__NR_SYSCALL_BASE + 327)
-#define __NR_mkdirat                      (__NR_SYSCALL_BASE + 323)
-#define __NR_fchownat                     (__NR_SYSCALL_BASE + 325)
-#define __NR_fchmodat                     (__NR_SYSCALL_BASE + 333)
-#define __NR_renameat                     (__NR_SYSCALL_BASE + 329)
-#define __NR_fsetxattr                    (__NR_SYSCALL_BASE + 228)
-#define __NR_fgetxattr                    (__NR_SYSCALL_BASE + 231)
-#define __NR_flistxattr                   (__NR_SYSCALL_BASE + 234)
-#define __NR_fremovexattr                 (__NR_SYSCALL_BASE + 237)
-#define __NR_unlinkat                     (__NR_SYSCALL_BASE + 328)
-#define __NR_chown32                      (__NR_SYSCALL_BASE + 212)
-#define __NR_lchown32                     (__NR_SYSCALL_BASE + 198)
-#define __NR_fstat64                      (__NR_SYSCALL_BASE + 197)
-#define __NR_stat64                       (__NR_SYSCALL_BASE + 195)
-#define __NR_lstat64                      (__NR_SYSCALL_BASE + 196)
-#define __NR_getcwd                       (__NR_SYSCALL_BASE + 183)
-#define __NR_faccessat                    (__NR_SYSCALL_BASE + 334)
-#define __NR_setxattr                     (__NR_SYSCALL_BASE + 226)
-#define __NR_lsetxattr                    (__NR_SYSCALL_BASE + 227)
-#define __NR_getxattr                     (__NR_SYSCALL_BASE + 229)
-#define __NR_lgetxattr                    (__NR_SYSCALL_BASE + 230)
-#define __NR_listxattr                    (__NR_SYSCALL_BASE + 232)
-#define __NR_llistxattr                   (__NR_SYSCALL_BASE + 233)
-#define __NR_removexattr                  (__NR_SYSCALL_BASE + 235)
-#define __NR_lremovexattr                 (__NR_SYSCALL_BASE + 236)
-#define __NR_statfs64                     (__NR_SYSCALL_BASE + 266)
-#define __NR_unshare                      (__NR_SYSCALL_BASE + 337)
-#define __NR_nanosleep                    (__NR_SYSCALL_BASE + 162)
-#define __NR_clock_gettime                (__NR_SYSCALL_BASE + 263)
-#define __NR_clock_settime                (__NR_SYSCALL_BASE + 262)
-#define __NR_clock_getres                 (__NR_SYSCALL_BASE + 264)
-#define __NR_clock_nanosleep              (__NR_SYSCALL_BASE + 265)
-#define __NR_timer_create                 (__NR_SYSCALL_BASE + 257)
-#define __NR_timer_settime                (__NR_SYSCALL_BASE + 258)
-#define __NR_timer_gettime                (__NR_SYSCALL_BASE + 259)
-#define __NR_timer_getoverrun             (__NR_SYSCALL_BASE + 260)
-#define __NR_timer_delete                 (__NR_SYSCALL_BASE + 261)
-#define __NR_utimes                       (__NR_SYSCALL_BASE + 269)
-#define __NR_utimensat                    (__NR_SYSCALL_BASE + 348)
-#define __NR_sigsuspend                   (__NR_SYSCALL_BASE + 72)
-#define __NR_rt_sigaction                 (__NR_SYSCALL_BASE + 174)
-#define __NR_rt_sigprocmask               (__NR_SYSCALL_BASE + 175)
-#define __NR_rt_sigtimedwait              (__NR_SYSCALL_BASE + 177)
-#define __NR_signalfd4                    (__NR_SYSCALL_BASE + 355)
-#define __NR_socket                       (__NR_SYSCALL_BASE + 281)
-#define __NR_socketpair                   (__NR_SYSCALL_BASE + 288)
-#define __NR_bind                         (__NR_SYSCALL_BASE + 282)
-#define __NR_connect                      (__NR_SYSCALL_BASE + 283)
-#define __NR_listen                       (__NR_SYSCALL_BASE + 284)
-#define __NR_accept                       (__NR_SYSCALL_BASE + 285)
-#define __NR_getsockname                  (__NR_SYSCALL_BASE + 286)
-#define __NR_getpeername                  (__NR_SYSCALL_BASE + 287)
-#define __NR_sendto                       (__NR_SYSCALL_BASE + 290)
-#define __NR_recvfrom                     (__NR_SYSCALL_BASE + 292)
-#define __NR_shutdown                     (__NR_SYSCALL_BASE + 293)
-#define __NR_setsockopt                   (__NR_SYSCALL_BASE + 294)
-#define __NR_getsockopt                   (__NR_SYSCALL_BASE + 295)
-#define __NR_sendmsg                      (__NR_SYSCALL_BASE + 296)
-#define __NR_recvmsg                      (__NR_SYSCALL_BASE + 297)
-#define __NR_sched_setscheduler           (__NR_SYSCALL_BASE + 156)
-#define __NR_sched_getscheduler           (__NR_SYSCALL_BASE + 157)
-#define __NR_sched_yield                  (__NR_SYSCALL_BASE + 158)
-#define __NR_sched_setparam               (__NR_SYSCALL_BASE + 154)
-#define __NR_sched_getparam               (__NR_SYSCALL_BASE + 155)
-#define __NR_sched_get_priority_max       (__NR_SYSCALL_BASE + 159)
-#define __NR_sched_get_priority_min       (__NR_SYSCALL_BASE + 160)
-#define __NR_sched_rr_get_interval        (__NR_SYSCALL_BASE + 161)
-#define __NR_sched_setaffinity            (__NR_SYSCALL_BASE + 241)
-#define __NR_sched_getaffinity            (__NR_SYSCALL_BASE + 242)
-#define __NR_getcpu                       (__NR_SYSCALL_BASE + 345)
-#define __NR_ioprio_set                   (__NR_SYSCALL_BASE + 314)
-#define __NR_ioprio_get                   (__NR_SYSCALL_BASE + 315)
-#define __NR_perf_event_open              (__NR_SYSCALL_BASE + 364)
-#define __NR_futex                        (__NR_SYSCALL_BASE + 240)
-#define __NR_epoll_create                 (__NR_SYSCALL_BASE + 250)
-#define __NR_epoll_ctl                    (__NR_SYSCALL_BASE + 251)
-#define __NR_epoll_wait                   (__NR_SYSCALL_BASE + 252)
-#define __NR_inotify_init                 (__NR_SYSCALL_BASE + 316)
-#define __NR_inotify_add_watch            (__NR_SYSCALL_BASE + 317)
-#define __NR_inotify_rm_watch             (__NR_SYSCALL_BASE + 318)
-#define __NR_poll                         (__NR_SYSCALL_BASE + 168)
-#define __NR_eventfd2                     (__NR_SYSCALL_BASE + 356)
-#define __NR_ARM_set_tls                  (__NR_SYSCALL_BASE + 983045)
-#define __NR_ARM_cacheflush               (__NR_SYSCALL_BASE + 983042)
-#endif
-
-#ifdef __i386__
-#define __NR_waitpid                      (__NR_SYSCALL_BASE + 7)
-#define __NR_kill                         (__NR_SYSCALL_BASE + 37)
-#define __NR_pipe                         (__NR_SYSCALL_BASE + 42)
-#define __NR_sigsuspend                   (__NR_SYSCALL_BASE + 72)
-#define __NR_socketcall                   (__NR_SYSCALL_BASE + 102)
-#define __NR_getsid                       (__NR_SYSCALL_BASE + 147)
-#define __NR_fdatasync                    (__NR_SYSCALL_BASE + 148)
-#define __NR_mlock                        (__NR_SYSCALL_BASE + 150)
-#define __NR_munlock                      (__NR_SYSCALL_BASE + 151)
-#define __NR_mlockall                     (__NR_SYSCALL_BASE + 152)
-#define __NR_munlockall                   (__NR_SYSCALL_BASE + 153)
-#define __NR_sched_setparam               (__NR_SYSCALL_BASE + 154)
-#define __NR_sched_getparam               (__NR_SYSCALL_BASE + 155)
-#define __NR_sched_setscheduler           (__NR_SYSCALL_BASE + 156)
-#define __NR_sched_getscheduler           (__NR_SYSCALL_BASE + 157)
-#define __NR_sched_yield                  (__NR_SYSCALL_BASE + 158)
-#define __NR_sched_get_priority_max       (__NR_SYSCALL_BASE + 159)
-#define __NR_sched_get_priority_min       (__NR_SYSCALL_BASE + 160)
-#define __NR_sched_rr_get_interval        (__NR_SYSCALL_BASE + 161)
-#define __NR_nanosleep                    (__NR_SYSCALL_BASE + 162)
-#define __NR_mremap                       (__NR_SYSCALL_BASE + 163)
-#define __NR_poll                         (__NR_SYSCALL_BASE + 168)
-#define __NR_prctl                        (__NR_SYSCALL_BASE + 172)
-#define __NR_rt_sigaction                 (__NR_SYSCALL_BASE + 174)
-#define __NR_rt_sigprocmask               (__NR_SYSCALL_BASE + 175)
-#define __NR_rt_sigtimedwait              (__NR_SYSCALL_BASE + 177)
-#define __NR_pread64                      (__NR_SYSCALL_BASE + 180)
-#define __NR_pwrite64                     (__NR_SYSCALL_BASE + 181)
-#define __NR_getcwd                       (__NR_SYSCALL_BASE + 183)
-#define __NR_capget                       (__NR_SYSCALL_BASE + 184)
-#define __NR_capset                       (__NR_SYSCALL_BASE + 185)
-#define __NR_sigaltstack                  (__NR_SYSCALL_BASE + 186)
-#define __NR_sendfile                     (__NR_SYSCALL_BASE + 187)
-#define __NR_ugetrlimit                   (__NR_SYSCALL_BASE + 191)
-#define __NR_mmap2                        (__NR_SYSCALL_BASE + 192)
-#define __NR_ftruncate64                  (__NR_SYSCALL_BASE + 194)
-#define __NR_stat64                       (__NR_SYSCALL_BASE + 195)
-#define __NR_lstat64                      (__NR_SYSCALL_BASE + 196)
-#define __NR_fstat64                      (__NR_SYSCALL_BASE + 197)
-#define __NR_lchown32                     (__NR_SYSCALL_BASE + 198)
-#define __NR_getuid32                     (__NR_SYSCALL_BASE + 199)
-#define __NR_getgid32                     (__NR_SYSCALL_BASE + 200)
-#define __NR_geteuid32                    (__NR_SYSCALL_BASE + 201)
-#define __NR_getegid32                    (__NR_SYSCALL_BASE + 202)
-#define __NR_setreuid32                   (__NR_SYSCALL_BASE + 203)
-#define __NR_setregid32                   (__NR_SYSCALL_BASE + 204)
-#define __NR_getgroups32                  (__NR_SYSCALL_BASE + 205)
-#define __NR_setgroups32                  (__NR_SYSCALL_BASE + 206)
-#define __NR_fchown32                     (__NR_SYSCALL_BASE + 207)
-#define __NR_setresuid32                  (__NR_SYSCALL_BASE + 208)
-#define __NR_getresuid32                  (__NR_SYSCALL_BASE + 209)
-#define __NR_setresgid32                  (__NR_SYSCALL_BASE + 210)
-#define __NR_getresgid32                  (__NR_SYSCALL_BASE + 211)
-#define __NR_chown32                      (__NR_SYSCALL_BASE + 212)
-#define __NR_setuid32                     (__NR_SYSCALL_BASE + 213)
-#define __NR_setgid32                     (__NR_SYSCALL_BASE + 214)
-#define __NR_mincore                      (__NR_SYSCALL_BASE + 218)
-#define __NR_madvise                      (__NR_SYSCALL_BASE + 219)
-#define __NR_getdents64                   (__NR_SYSCALL_BASE + 220)
-#define __NR_fcntl64                      (__NR_SYSCALL_BASE + 221)
-#define __NR_gettid                       (__NR_SYSCALL_BASE + 224)
-#define __NR_readahead                    (__NR_SYSCALL_BASE + 225)
-#define __NR_setxattr                     (__NR_SYSCALL_BASE + 226)
-#define __NR_lsetxattr                    (__NR_SYSCALL_BASE + 227)
-#define __NR_fsetxattr                    (__NR_SYSCALL_BASE + 228)
-#define __NR_getxattr                     (__NR_SYSCALL_BASE + 229)
-#define __NR_lgetxattr                    (__NR_SYSCALL_BASE + 230)
-#define __NR_fgetxattr                    (__NR_SYSCALL_BASE + 231)
-#define __NR_listxattr                    (__NR_SYSCALL_BASE + 232)
-#define __NR_llistxattr                   (__NR_SYSCALL_BASE + 233)
-#define __NR_flistxattr                   (__NR_SYSCALL_BASE + 234)
-#define __NR_removexattr                  (__NR_SYSCALL_BASE + 235)
-#define __NR_lremovexattr                 (__NR_SYSCALL_BASE + 236)
-#define __NR_fremovexattr                 (__NR_SYSCALL_BASE + 237)
-#define __NR_tkill                        (__NR_SYSCALL_BASE + 238)
-#define __NR_futex                        (__NR_SYSCALL_BASE + 240)
-#define __NR_sched_setaffinity            (__NR_SYSCALL_BASE + 241)
-#define __NR_sched_getaffinity            (__NR_SYSCALL_BASE + 242)
-#define __NR_set_thread_area              (__NR_SYSCALL_BASE + 243)
-#define __NR_exit_group                   (__NR_SYSCALL_BASE + 252)
-#define __NR_epoll_create                 (__NR_SYSCALL_BASE + 254)
-#define __NR_epoll_ctl                    (__NR_SYSCALL_BASE + 255)
-#define __NR_epoll_wait                   (__NR_SYSCALL_BASE + 256)
-#define __NR_timer_create                 (__NR_SYSCALL_BASE + 259)
-#define __NR_timer_settime                (__NR_SYSCALL_BASE + 260)
-#define __NR_timer_gettime                (__NR_SYSCALL_BASE + 261)
-#define __NR_timer_getoverrun             (__NR_SYSCALL_BASE + 262)
-#define __NR_timer_delete                 (__NR_SYSCALL_BASE + 263)
-#define __NR_clock_settime                (__NR_SYSCALL_BASE + 264)
-#define __NR_clock_gettime                (__NR_SYSCALL_BASE + 265)
-#define __NR_clock_getres                 (__NR_SYSCALL_BASE + 266)
-#define __NR_clock_nanosleep              (__NR_SYSCALL_BASE + 267)
-#define __NR_statfs64                     (__NR_SYSCALL_BASE + 268)
-#define __NR_fstatfs64                    (__NR_SYSCALL_BASE + 269)
-#define __NR_tgkill                       (__NR_SYSCALL_BASE + 270)
-#define __NR_utimes                       (__NR_SYSCALL_BASE + 271)
-#define __NR_waitid                       (__NR_SYSCALL_BASE + 284)
-#define __NR_ioprio_set                   (__NR_SYSCALL_BASE + 289)
-#define __NR_ioprio_get                   (__NR_SYSCALL_BASE + 290)
-#define __NR_inotify_init                 (__NR_SYSCALL_BASE + 291)
-#define __NR_inotify_add_watch            (__NR_SYSCALL_BASE + 292)
-#define __NR_inotify_rm_watch             (__NR_SYSCALL_BASE + 293)
-#define __NR_openat                       (__NR_SYSCALL_BASE + 295)
-#define __NR_mkdirat                      (__NR_SYSCALL_BASE + 296)
-#define __NR_fchownat                     (__NR_SYSCALL_BASE + 298)
-#define __NR_fstatat64                    (__NR_SYSCALL_BASE + 300)
-#define __NR_unlinkat                     (__NR_SYSCALL_BASE + 301)
-#define __NR_renameat                     (__NR_SYSCALL_BASE + 302)
-#define __NR_fchmodat                     (__NR_SYSCALL_BASE + 306)
-#define __NR_faccessat                    (__NR_SYSCALL_BASE + 307)
-#define __NR_unshare                      (__NR_SYSCALL_BASE + 310)
-#define __NR_getcpu                       (__NR_SYSCALL_BASE + 318)
-#define __NR_utimensat                    (__NR_SYSCALL_BASE + 320)
-#define __NR_signalfd4                    (__NR_SYSCALL_BASE + 327)
-#define __NR_eventfd2                     (__NR_SYSCALL_BASE + 328)
-#define __NR_pipe2                        (__NR_SYSCALL_BASE + 331)
-#define __NR_perf_event_open              (__NR_SYSCALL_BASE + 336)
-#endif
-
-#ifdef __mips__
-#define __NR_syscall                      (__NR_SYSCALL_BASE + 0)
-#define __NR_waitpid                      (__NR_SYSCALL_BASE + 7)
-#define __NR_lchown                       (__NR_SYSCALL_BASE + 16)
-#define __NR_setuid                       (__NR_SYSCALL_BASE + 23)
-#define __NR_getuid                       (__NR_SYSCALL_BASE + 24)
-#define __NR_kill                         (__NR_SYSCALL_BASE + 37)
-#define __NR_setgid                       (__NR_SYSCALL_BASE + 46)
-#define __NR_getgid                       (__NR_SYSCALL_BASE + 47)
-#define __NR_geteuid                      (__NR_SYSCALL_BASE + 49)
-#define __NR_getegid                      (__NR_SYSCALL_BASE + 50)
-#define __NR_setreuid                     (__NR_SYSCALL_BASE + 70)
-#define __NR_setregid                     (__NR_SYSCALL_BASE + 71)
-#define __NR_sigsuspend                   (__NR_SYSCALL_BASE + 72)
-#define __NR_getrlimit                    (__NR_SYSCALL_BASE + 76)
-#define __NR_getgroups                    (__NR_SYSCALL_BASE + 80)
-#define __NR_setgroups                    (__NR_SYSCALL_BASE + 81)
-#define __NR_fchown                       (__NR_SYSCALL_BASE + 95)
-#define __NR_cacheflush                   (__NR_SYSCALL_BASE + 147)
-#define __NR_getsid                       (__NR_SYSCALL_BASE + 151)
-#define __NR_fdatasync                    (__NR_SYSCALL_BASE + 152)
-#define __NR_mlock                        (__NR_SYSCALL_BASE + 154)
-#define __NR_munlock                      (__NR_SYSCALL_BASE + 155)
-#define __NR_mlockall                     (__NR_SYSCALL_BASE + 156)
-#define __NR_munlockall                   (__NR_SYSCALL_BASE + 157)
-#define __NR_sched_setparam               (__NR_SYSCALL_BASE + 158)
-#define __NR_sched_getparam               (__NR_SYSCALL_BASE + 159)
-#define __NR_sched_setscheduler           (__NR_SYSCALL_BASE + 160)
-#define __NR_sched_getscheduler           (__NR_SYSCALL_BASE + 161)
-#define __NR_sched_yield                  (__NR_SYSCALL_BASE + 162)
-#define __NR_sched_get_priority_max       (__NR_SYSCALL_BASE + 163)
-#define __NR_sched_get_priority_min       (__NR_SYSCALL_BASE + 164)
-#define __NR_sched_rr_get_interval        (__NR_SYSCALL_BASE + 165)
-#define __NR_nanosleep                    (__NR_SYSCALL_BASE + 166)
-#define __NR_mremap                       (__NR_SYSCALL_BASE + 167)
-#define __NR_accept                       (__NR_SYSCALL_BASE + 168)
-#define __NR_bind                         (__NR_SYSCALL_BASE + 169)
-#define __NR_connect                      (__NR_SYSCALL_BASE + 170)
-#define __NR_getpeername                  (__NR_SYSCALL_BASE + 171)
-#define __NR_getsockname                  (__NR_SYSCALL_BASE + 172)
-#define __NR_getsockopt                   (__NR_SYSCALL_BASE + 173)
-#define __NR_listen                       (__NR_SYSCALL_BASE + 174)
-#define __NR_recvfrom                     (__NR_SYSCALL_BASE + 176)
-#define __NR_recvmsg                      (__NR_SYSCALL_BASE + 177)
-#define __NR_sendmsg                      (__NR_SYSCALL_BASE + 179)
-#define __NR_sendto                       (__NR_SYSCALL_BASE + 180)
-#define __NR_setsockopt                   (__NR_SYSCALL_BASE + 181)
-#define __NR_shutdown                     (__NR_SYSCALL_BASE + 182)
-#define __NR_socket                       (__NR_SYSCALL_BASE + 183)
-#define __NR_socketpair                   (__NR_SYSCALL_BASE + 184)
-#define __NR_setresuid                    (__NR_SYSCALL_BASE + 185)
-#define __NR_getresuid                    (__NR_SYSCALL_BASE + 186)
-#define __NR_poll                         (__NR_SYSCALL_BASE + 188)
-#define __NR_setresgid                    (__NR_SYSCALL_BASE + 190)
-#define __NR_getresgid                    (__NR_SYSCALL_BASE + 191)
-#define __NR_prctl                        (__NR_SYSCALL_BASE + 192)
-#define __NR_rt_sigaction                 (__NR_SYSCALL_BASE + 194)
-#define __NR_rt_sigprocmask               (__NR_SYSCALL_BASE + 195)
-#define __NR_rt_sigtimedwait              (__NR_SYSCALL_BASE + 197)
-#define __NR_pread64                      (__NR_SYSCALL_BASE + 200)
-#define __NR_pwrite64                     (__NR_SYSCALL_BASE + 201)
-#define __NR_chown                        (__NR_SYSCALL_BASE + 202)
-#define __NR_getcwd                       (__NR_SYSCALL_BASE + 203)
-#define __NR_capget                       (__NR_SYSCALL_BASE + 204)
-#define __NR_capset                       (__NR_SYSCALL_BASE + 205)
-#define __NR_sigaltstack                  (__NR_SYSCALL_BASE + 206)
-#define __NR_sendfile                     (__NR_SYSCALL_BASE + 207)
-#define __NR_mmap2                        (__NR_SYSCALL_BASE + 210)
-#define __NR_ftruncate64                  (__NR_SYSCALL_BASE + 212)
-#define __NR_stat64                       (__NR_SYSCALL_BASE + 213)
-#define __NR_lstat64                      (__NR_SYSCALL_BASE + 214)
-#define __NR_fstat64                      (__NR_SYSCALL_BASE + 215)
-#define __NR_mincore                      (__NR_SYSCALL_BASE + 217)
-#define __NR_madvise                      (__NR_SYSCALL_BASE + 218)
-#define __NR_getdents64                   (__NR_SYSCALL_BASE + 219)
-#define __NR_fcntl64                      (__NR_SYSCALL_BASE + 220)
-#define __NR_gettid                       (__NR_SYSCALL_BASE + 222)
-#define __NR_readahead                    (__NR_SYSCALL_BASE + 223)
-#define __NR_setxattr                     (__NR_SYSCALL_BASE + 224)
-#define __NR_lsetxattr                    (__NR_SYSCALL_BASE + 225)
-#define __NR_fsetxattr                    (__NR_SYSCALL_BASE + 226)
-#define __NR_getxattr                     (__NR_SYSCALL_BASE + 227)
-#define __NR_lgetxattr                    (__NR_SYSCALL_BASE + 228)
-#define __NR_fgetxattr                    (__NR_SYSCALL_BASE + 229)
-#define __NR_listxattr                    (__NR_SYSCALL_BASE + 230)
-#define __NR_llistxattr                   (__NR_SYSCALL_BASE + 231)
-#define __NR_flistxattr                   (__NR_SYSCALL_BASE + 232)
-#define __NR_removexattr                  (__NR_SYSCALL_BASE + 233)
-#define __NR_lremovexattr                 (__NR_SYSCALL_BASE + 234)
-#define __NR_fremovexattr                 (__NR_SYSCALL_BASE + 235)
-#define __NR_tkill                        (__NR_SYSCALL_BASE + 236)
-#define __NR_futex                        (__NR_SYSCALL_BASE + 238)
-#define __NR_sched_setaffinity            (__NR_SYSCALL_BASE + 239)
-#define __NR_sched_getaffinity            (__NR_SYSCALL_BASE + 240)
-#define __NR_exit_group                   (__NR_SYSCALL_BASE + 246)
-#define __NR_epoll_create                 (__NR_SYSCALL_BASE + 248)
-#define __NR_epoll_ctl                    (__NR_SYSCALL_BASE + 249)
-#define __NR_epoll_wait                   (__NR_SYSCALL_BASE + 250)
-#define __NR_statfs64                     (__NR_SYSCALL_BASE + 255)
-#define __NR_fstatfs64                    (__NR_SYSCALL_BASE + 256)
-#define __NR_timer_create                 (__NR_SYSCALL_BASE + 257)
-#define __NR_timer_settime                (__NR_SYSCALL_BASE + 258)
-#define __NR_timer_gettime                (__NR_SYSCALL_BASE + 259)
-#define __NR_timer_getoverrun             (__NR_SYSCALL_BASE + 260)
-#define __NR_timer_delete                 (__NR_SYSCALL_BASE + 261)
-#define __NR_clock_settime                (__NR_SYSCALL_BASE + 262)
-#define __NR_clock_gettime                (__NR_SYSCALL_BASE + 263)
-#define __NR_clock_getres                 (__NR_SYSCALL_BASE + 264)
-#define __NR_clock_nanosleep              (__NR_SYSCALL_BASE + 265)
-#define __NR_tgkill                       (__NR_SYSCALL_BASE + 266)
-#define __NR_utimes                       (__NR_SYSCALL_BASE + 267)
-#define __NR_waitid                       (__NR_SYSCALL_BASE + 278)
-#define __NR_set_thread_area              (__NR_SYSCALL_BASE + 283)
-#define __NR_inotify_init                 (__NR_SYSCALL_BASE + 284)
-#define __NR_inotify_add_watch            (__NR_SYSCALL_BASE + 285)
-#define __NR_inotify_rm_watch             (__NR_SYSCALL_BASE + 286)
-#define __NR_openat                       (__NR_SYSCALL_BASE + 288)
-#define __NR_mkdirat                      (__NR_SYSCALL_BASE + 289)
-#define __NR_fchownat                     (__NR_SYSCALL_BASE + 291)
-#define __NR_fstatat64                    (__NR_SYSCALL_BASE + 293)
-#define __NR_unlinkat                     (__NR_SYSCALL_BASE + 294)
-#define __NR_renameat                     (__NR_SYSCALL_BASE + 295)
-#define __NR_fchmodat                     (__NR_SYSCALL_BASE + 299)
-#define __NR_faccessat                    (__NR_SYSCALL_BASE + 300)
-#define __NR_unshare                      (__NR_SYSCALL_BASE + 303)
-#define __NR_getcpu                       (__NR_SYSCALL_BASE + 312)
-#define __NR_ioprio_set                   (__NR_SYSCALL_BASE + 314)
-#define __NR_ioprio_get                   (__NR_SYSCALL_BASE + 315)
-#define __NR_utimensat                    (__NR_SYSCALL_BASE + 316)
-#define __NR_signalfd4                    (__NR_SYSCALL_BASE + 324)
-#define __NR_eventfd2                     (__NR_SYSCALL_BASE + 325)
-#define __NR_pipe2                        (__NR_SYSCALL_BASE + 328)
-#define __NR_perf_event_open              (__NR_SYSCALL_BASE + 333)
-#endif
-
-#endif
-
-#endif /* _BIONIC_LINUX_SYSCALLS_H_ */
diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h
index 05b221f..4e8beb6 100644
--- a/libc/include/sys/stat.h
+++ b/libc/include/sys/stat.h
@@ -129,7 +129,7 @@
 extern int    mknod(const char *, mode_t, dev_t);
 extern mode_t umask(mode_t);
 
-#if defined(__BIONIC_FORTIFY_INLINE)
+#if defined(__BIONIC_FORTIFY)
 
 extern mode_t __umask_chk(mode_t);
 extern mode_t __umask_real(mode_t)
@@ -147,7 +147,7 @@
   }
   return __umask_chk(mode);
 }
-#endif /* defined(__BIONIC_FORTIFY_INLINE) */
+#endif /* defined(__BIONIC_FORTIFY) */
 
 
 #define  stat64    stat
diff --git a/libc/include/sys/syscall.h b/libc/include/sys/syscall.h
index 7055518..a44b2e5 100644
--- a/libc/include/sys/syscall.h
+++ b/libc/include/sys/syscall.h
@@ -33,6 +33,8 @@
 #include <sys/types.h>
 #include <asm/unistd.h>
 
+#include <sys/glibc-syscalls.h> /* glibc-compatible SYS_* aliases for our __NR_* names. */
+
 __BEGIN_DECLS
 
 int syscall(int number, ...);
diff --git a/libc/include/sys/types.h b/libc/include/sys/types.h
index 850e22e..a0ce405 100644
--- a/libc/include/sys/types.h
+++ b/libc/include/sys/types.h
@@ -85,17 +85,13 @@
 
 #ifndef _SSIZE_T_DEFINED_
 #define _SSIZE_T_DEFINED_
-/* Traditionally, bionic's ssize_t was "long int". This causes GCC to emit warnings when you
+/* Traditionally, bionic's ssize_t was "long int". This caused GCC to emit warnings when you
  * pass a ssize_t to a printf-style function. The correct type is __kernel_ssize_t, which is
  * "int", which isn't an ABI change for C code (because they're the same size) but is an ABI
  * change for C++ because "int" and "long int" mangle to "i" and "l" respectively. So until
- * we can fix the ABI, this is the best we can do. http://b/8253769. */
-#if defined(__cplusplus)
-typedef long int  ssize_t;
-#else
+ * we can fix the ABI, this change should not be propagated to the NDK. http://b/8253769. */
 typedef __kernel_ssize_t ssize_t;
 #endif
-#endif
 
 typedef __kernel_suseconds_t  suseconds_t;
 typedef __kernel_time_t       time_t;
diff --git a/libc/kernel/common/linux/err.h b/libc/kernel/common/linux/err.h
index 442a1d8..ae0cf3c 100644
--- a/libc/kernel/common/linux/err.h
+++ b/libc/kernel/common/linux/err.h
@@ -22,5 +22,8 @@
 #include <asm/errno.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MAX_ERRNO 4095
+#ifndef __ASSEMBLY__
 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/libc/kernel/tools/utils.py b/libc/kernel/tools/utils.py
index e2820d1..8ec7353 100644
--- a/libc/kernel/tools/utils.py
+++ b/libc/kernel/tools/utils.py
@@ -72,117 +72,6 @@
 
         path = os.path.dirname(path)
 
-def find_bionic_root():
-    file = find_file_from_upwards(None, "SYSCALLS.TXT")
-    if file:
-        return os.path.dirname(file)
-    else:
-        return None
-
-def find_kernel_headers():
-    """try to find the directory containing the kernel headers for this machine"""
-    status, version = commands.getstatusoutput( "uname -r" )  # get Linux kernel version
-    if status != 0:
-        D("could not execute 'uname -r' command properly")
-        return None
-
-    # get rid of the "-xenU" suffix that is found in Xen virtual machines
-    if len(version) > 5 and version[-5:] == "-xenU":
-        version = version[:-5]
-
-    path = "/usr/src/linux-headers-" + version
-    D("probing %s for kernel headers" % (path+"/include"))
-    ret = os.path.isdir( path )
-    if ret:
-        D("found kernel headers in: %s" % (path + "/include"))
-        return path
-    return None
-
-
-# parser for the SYSCALLS.TXT file
-#
-class SysCallsTxtParser:
-    def __init__(self):
-        self.syscalls = []
-        self.lineno   = 0
-
-    def E(msg):
-        print "%d: %s" % (self.lineno, msg)
-
-    def parse_line(self, line):
-        pos_lparen = line.find('(')
-        E          = self.E
-        if pos_lparen < 0:
-            E("missing left parenthesis in '%s'" % line)
-            return
-
-        pos_rparen = line.rfind(')')
-        if pos_rparen < 0 or pos_rparen <= pos_lparen:
-            E("missing or misplaced right parenthesis in '%s'" % line)
-            return
-
-        return_type = line[:pos_lparen].strip().split()
-        if len(return_type) < 2:
-            E("missing return type in '%s'" % line)
-            return
-
-        syscall_func = return_type[-1]
-        return_type  = string.join(return_type[:-1],' ')
-
-        pos_colon = syscall_func.find(':')
-        if pos_colon < 0:
-            syscall_name = syscall_func
-        else:
-            if pos_colon == 0 or pos_colon+1 >= len(syscall_func):
-                E("misplaced colon in '%s'" % line)
-                return
-            syscall_name = syscall_func[pos_colon+1:]
-            syscall_func = syscall_func[:pos_colon]
-
-        if pos_rparen > pos_lparen+1:
-            syscall_params = line[pos_lparen+1:pos_rparen].split(',')
-            params         = string.join(syscall_params,',')
-        else:
-            syscall_params = []
-            params         = "void"
-
-        number = line[pos_rparen+1:].strip()
-        if number == "stub":
-            syscall_id  = -1
-            syscall_id2 = -1
-        else:
-            try:
-                if number[0] == '#':
-                    number = number[1:].strip()
-                numbers = string.split(number,',')
-                syscall_id  = int(numbers[0])
-                syscall_id2 = syscall_id
-                if len(numbers) > 1:
-                    syscall_id2 = int(numbers[1])
-            except:
-                E("invalid syscall number in '%s'" % line)
-                return
-
-        t = { "id"     : syscall_id,
-              "id2"    : syscall_id2,
-              "name"   : syscall_name,
-              "func"   : syscall_func,
-              "params" : syscall_params,
-              "decl"   : "%-15s  %s (%s);" % (return_type, syscall_func, params) }
-
-        self.syscalls.append(t)
-
-    def parse_file(self, file_path):
-        fp = open(file_path)
-        for line in fp.xreadlines():
-            self.lineno += 1
-            line = line.strip()
-            if not line: continue
-            if line[0] == '#': continue
-            self.parse_line(line)
-
-        fp.close()
-
 
 class StringOutput:
     def __init__(self):
diff --git a/libc/netbsd/resolv/res_cache.c b/libc/netbsd/resolv/res_cache.c
index 08a2557..829bf10 100644
--- a/libc/netbsd/resolv/res_cache.c
+++ b/libc/netbsd/resolv/res_cache.c
@@ -171,9 +171,8 @@
 
 #undef XLOG
 #if DEBUG
-#  include <logd.h>
-#  define  XLOG(...)   \
-    __libc_android_log_print(ANDROID_LOG_DEBUG,"libc",__VA_ARGS__)
+#  include "libc_logging.h"
+#  define XLOG(...)  __libc_format_log(ANDROID_LOG_DEBUG,"libc",__VA_ARGS__)
 
 #include <stdio.h>
 #include <stdarg.h>
@@ -707,9 +706,9 @@
 _dnsPacket_bprintQR(DnsPacket*  packet, char*  p, char*  end)
 {
 #define  QQ(x)   { DNS_TYPE_##x, #x }
-    static const struct { 
+    static const struct {
         const char*  typeBytes;
-        const char*  typeString; 
+        const char*  typeString;
     } qTypes[] =
     {
         QQ(A), QQ(PTR), QQ(MX), QQ(AAAA), QQ(ALL),
diff --git a/libc/netbsd/resolv/res_send.c b/libc/netbsd/resolv/res_send.c
index ceb2c77..d407ac8 100644
--- a/libc/netbsd/resolv/res_send.c
+++ b/libc/netbsd/resolv/res_send.c
@@ -119,7 +119,7 @@
 #  include <resolv_cache.h>
 #endif
 
-#include "logd.h"
+#include "libc_logging.h"
 
 #ifndef DE_CONST
 #define DE_CONST(c,v)   v = ((c) ? \
@@ -555,7 +555,7 @@
 				    ns);
 
 			if (DBG) {
-				__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
+				__libc_format_log(ANDROID_LOG_DEBUG, "libc",
 					"used send_vc %d\n", n);
 			}
 
@@ -567,15 +567,13 @@
 		} else {
 			/* Use datagrams. */
 			if (DBG) {
-				__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
-					"using send_dg\n");
+				__libc_format_log(ANDROID_LOG_DEBUG, "libc", "using send_dg\n");
 			}
 
 			n = send_dg(statp, buf, buflen, ans, anssiz, &terrno,
 				    ns, &v_circuit, &gotsomewhere);
 			if (DBG) {
-				__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
-					"used send_dg %d\n",n);
+				__libc_format_log(ANDROID_LOG_DEBUG, "libc", "used send_dg %d\n",n);
 			}
 
 			if (n < 0)
@@ -583,7 +581,7 @@
 			if (n == 0)
 				goto next_ns;
 			if (DBG) {
-				__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
+				__libc_format_log(ANDROID_LOG_DEBUG, "libc",
 					"time=%d, %d\n",time(NULL), time(NULL)%2);
 			}
 			if (v_circuit)
@@ -728,8 +726,7 @@
 		timeout = 1;
 	}
 	if (DBG) {
-		__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
-			"using timeout of %d sec\n", timeout);
+		__libc_format_log(ANDROID_LOG_DEBUG, "libc", "using timeout of %d sec\n", timeout);
 	}
 
 	return timeout;
@@ -751,7 +748,7 @@
 	void *tmp;
 
 	if (DBG) {
-		__libc_android_log_print(ANDROID_LOG_DEBUG, "libc", "using send_vc\n");
+		__libc_format_log(ANDROID_LOG_DEBUG, "libc", "using send_vc\n");
 	}
 
 	nsap = get_nsaddr(statp, (size_t)ns);
@@ -952,8 +949,7 @@
 		timeout = evConsTime((long)sec, 0L);
 		finish = evAddTime(now, timeout);
 		if (DBG) {
-			__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
-				"  %d send_vc\n", sock);
+			__libc_format_log(ANDROID_LOG_DEBUG, "libc", "  %d send_vc\n", sock);
 		}
 
 		res = retrying_select(sock, &rset, &wset, &finish);
@@ -964,7 +960,7 @@
 done:
 	fcntl(sock, F_SETFL, origflags);
 	if (DBG) {
-		__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
+		__libc_format_log(ANDROID_LOG_DEBUG, "libc",
 			"  %d connect_with_timeout returning %s\n", sock, res);
 	}
 	return res;
@@ -980,7 +976,7 @@
 
 retry:
 	if (DBG) {
-		__libc_android_log_print(ANDROID_LOG_DEBUG, "libc", "  %d retying_select\n", sock);
+		__libc_format_log(ANDROID_LOG_DEBUG, "libc", "  %d retying_select\n", sock);
 	}
 
 	now = evNowTime();
@@ -1000,7 +996,7 @@
 	n = pselect(sock + 1, readset, writeset, NULL, &timeout, NULL);
 	if (n == 0) {
 		if (DBG) {
-			__libc_android_log_print(ANDROID_LOG_DEBUG, " libc",
+			__libc_format_log(ANDROID_LOG_DEBUG, " libc",
 				"  %d retrying_select timeout\n", sock);
 		}
 		errno = ETIMEDOUT;
@@ -1010,7 +1006,7 @@
 		if (errno == EINTR)
 			goto retry;
 		if (DBG) {
-			__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
+			__libc_format_log(ANDROID_LOG_DEBUG, "libc",
 				"  %d retrying_select got error %d\n",sock, n);
 		}
 		return n;
@@ -1020,7 +1016,7 @@
 		if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &error, &len) < 0 || error) {
 			errno = error;
 			if (DBG) {
-				__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
+				__libc_format_log(ANDROID_LOG_DEBUG, "libc",
 					"  %d retrying_select dot error2 %d\n", sock, errno);
 			}
 
@@ -1028,7 +1024,7 @@
 		}
 	}
 	if (DBG) {
-		__libc_android_log_print(ANDROID_LOG_DEBUG, "libc",
+		__libc_format_log(ANDROID_LOG_DEBUG, "libc",
 			"  %d retrying_select returning %d for %d\n",sock, n);
 	}
 
diff --git a/libc/netbsd/resolv/res_state.c b/libc/netbsd/resolv/res_state.c
index efaa519..32ffdca 100644
--- a/libc/netbsd/resolv/res_state.c
+++ b/libc/netbsd/resolv/res_state.c
@@ -42,9 +42,9 @@
 #define DEBUG 0
 
 #if DEBUG
-#  include <logd.h>
+#  include "libc_logging.h"
 #  include <unistd.h>  /* for gettid() */
-#  define D(...)  __libc_android_log_print(ANDROID_LOG_DEBUG,"libc", __VA_ARGS__)
+#  define D(...) __libc_format_log(ANDROID_LOG_DEBUG,"libc", __VA_ARGS__)
 #else
 #  define D(...)  do{}while(0)
 #endif
diff --git a/libc/private/arpa_nameser.h b/libc/private/arpa_nameser.h
index 438dc04..81195b5 100644
--- a/libc/private/arpa_nameser.h
+++ b/libc/private/arpa_nameser.h
@@ -567,9 +567,8 @@
 #endif
 
 #if 0
-#  include <logd.h>
-#  define  XLOG(...)   \
-    __libc_android_log_print(ANDROID_LOG_DEBUG,"libc",__VA_ARGS__)
+#  include "libc_logging.h"
+#  define XLOG(...)  __libc_format_log(ANDROID_LOG_DEBUG,"libc",__VA_ARGS__)
 #else
 #define  XLOG(...)   do {} while (0)
 #endif
diff --git a/libc/private/bionic_tls.h b/libc/private/bionic_tls.h
index dd6b932..56a0ac2 100644
--- a/libc/private/bionic_tls.h
+++ b/libc/private/bionic_tls.h
@@ -114,7 +114,7 @@
 
 #if defined(__cplusplus)
 struct KernelArgumentBlock;
-extern void __libc_init_tls(KernelArgumentBlock& args);
+extern __LIBC_HIDDEN__ void __libc_init_tls(KernelArgumentBlock& args);
 #endif
 
 #endif /* _SYS_TLS_H */
diff --git a/libc/private/debug_format.h b/libc/private/libc_logging.h
similarity index 64%
rename from libc/private/debug_format.h
rename to libc/private/libc_logging.h
index 0bc1148..4c9dc21 100644
--- a/libc/private/debug_format.h
+++ b/libc/private/libc_logging.h
@@ -26,17 +26,51 @@
  * SUCH DAMAGE.
  */
 
-#ifndef _DEBUG_FORMAT_H
-#define _DEBUG_FORMAT_H
+#ifndef _LIBC_LOGGING_H
+#define _LIBC_LOGGING_H
 
 #include <sys/cdefs.h>
 #include <stdarg.h>
 #include <stddef.h>
+#include <stdint.h>
 
 __BEGIN_DECLS
 
+enum {
+  BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW = 80100,
+  BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW = 80105,
+  BIONIC_EVENT_MEMMOVE_BUFFER_OVERFLOW = 80110,
+  BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW = 80115,
+  BIONIC_EVENT_STRNCPY_BUFFER_OVERFLOW = 80120,
+  BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW = 80125,
+  BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW = 80130,
+
+  BIONIC_EVENT_STRCAT_INTEGER_OVERFLOW = 80200,
+  BIONIC_EVENT_STRNCAT_INTEGER_OVERFLOW = 80205,
+
+  BIONIC_EVENT_RESOLVER_OLD_RESPONSE = 80300,
+  BIONIC_EVENT_RESOLVER_WRONG_SERVER = 80305,
+  BIONIC_EVENT_RESOLVER_WRONG_QUERY = 80310,
+};
+
+enum {
+  ANDROID_LOG_UNKNOWN = 0,
+  ANDROID_LOG_DEFAULT,    /* only for SetMinPriority() */
+
+  ANDROID_LOG_VERBOSE,
+  ANDROID_LOG_DEBUG,
+  ANDROID_LOG_INFO,
+  ANDROID_LOG_WARN,
+  ANDROID_LOG_ERROR,
+  ANDROID_LOG_FATAL,
+
+  ANDROID_LOG_SILENT,     /* only for SetMinPriority(); must be last */
+};
+
+//
 // Formatting routines for the C library's internal debugging.
 // Unlike the usual alternatives, these don't allocate.
+//
 
 __LIBC_HIDDEN__ int __libc_format_buffer(char* buffer, size_t buffer_size, const char* format, ...)
     __attribute__((__format__(printf, 3, 4)));
@@ -50,6 +84,15 @@
 __LIBC_HIDDEN__ int __libc_format_log_va_list(int priority, const char* tag, const char* format,
                                               va_list ap);
 
+//
+// Event logging.
+//
+
+__LIBC_HIDDEN__ void __libc_android_log_event_int(int32_t tag, int value);
+__LIBC_HIDDEN__ void __libc_android_log_event_uid(int32_t tag);
+
+__LIBC_HIDDEN__ __noreturn void __fortify_chk_fail(const char* msg, uint32_t event_tag);
+
 __END_DECLS
 
-#endif /* _DEBUG_FORMAT_H */
+#endif
diff --git a/libc/private/logd.h b/libc/private/logd.h
deleted file mode 100644
index a2828ec..0000000
--- a/libc/private/logd.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#ifndef _ANDROID_BIONIC_LOGD_H
-#define _ANDROID_BIONIC_LOGD_H
-
-#include <stdarg.h>
-#include <stdint.h>
-
-#define BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW 80100
-#define BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW 80105
-#define BIONIC_EVENT_MEMMOVE_BUFFER_OVERFLOW 80110
-#define BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW 80115
-#define BIONIC_EVENT_STRNCPY_BUFFER_OVERFLOW 80120
-#define BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW 80125
-#define BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW 80130
-
-#define BIONIC_EVENT_STRCAT_INTEGER_OVERFLOW 80200
-#define BIONIC_EVENT_STRNCAT_INTEGER_OVERFLOW 80205
-
-#define BIONIC_EVENT_RESOLVER_OLD_RESPONSE 80300
-#define BIONIC_EVENT_RESOLVER_WRONG_SERVER 80305
-#define BIONIC_EVENT_RESOLVER_WRONG_QUERY 80310
-
-enum  {
-    ANDROID_LOG_UNKNOWN = 0,
-    ANDROID_LOG_DEFAULT,    /* only for SetMinPriority() */
-
-    ANDROID_LOG_VERBOSE,
-    ANDROID_LOG_DEBUG,
-    ANDROID_LOG_INFO,
-    ANDROID_LOG_WARN,
-    ANDROID_LOG_ERROR,
-    ANDROID_LOG_FATAL,
-
-    ANDROID_LOG_SILENT,     /* only for SetMinPriority(); must be last */
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int __libc_android_log_write(int prio, const char* tag, const char* buffer);
-int __libc_android_log_print(int prio, const char *tag, const char *fmt, ...);
-int __libc_android_log_vprint(int prio, const char *tag, const char *fmt, va_list ap);
-
-void __libc_android_log_event_int(int32_t tag, int value);
-void __libc_android_log_event_uid(int32_t tag);
-
-__noreturn extern void __fortify_chk_fail(const char *, uint32_t);
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif /* _ANDROID_BIONIC_LOGD_H */
diff --git a/libc/string/strchr.c b/libc/string/strchr.c
index 564ea80..29acca5 100644
--- a/libc/string/strchr.c
+++ b/libc/string/strchr.c
@@ -29,7 +29,7 @@
  */
 
 #include <string.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 char *
 __strchr_chk(const char *p, int ch, size_t s_len)
@@ -47,5 +47,5 @@
 
 char *
 strchr(const char *p, int ch) {
-    return __strchr_chk(p, ch, (size_t) -1);
+    return __strchr_chk(p, ch, __BIONIC_FORTIFY_UNKNOWN_SIZE);
 }
diff --git a/libc/string/strrchr.c b/libc/string/strrchr.c
index 5d0415e..e709d49 100644
--- a/libc/string/strrchr.c
+++ b/libc/string/strrchr.c
@@ -29,7 +29,7 @@
  */
 
 #include <string.h>
-#include <private/logd.h>
+#include "libc_logging.h"
 
 char *
 __strrchr_chk(const char *p, int ch, size_t s_len)
@@ -50,5 +50,5 @@
 char *
 strrchr(const char *p, int ch)
 {
-	return __strrchr_chk(p, ch, (size_t) -1);
+	return __strrchr_chk(p, ch, __BIONIC_FORTIFY_UNKNOWN_SIZE);
 }
diff --git a/libc/tools/genserv.py b/libc/tools/genserv.py
index e37d28f..84a139d 100755
--- a/libc/tools/genserv.py
+++ b/libc/tools/genserv.py
@@ -5,7 +5,7 @@
 
 def usage():
     print """\
-  usage:  genserv < /etc/services > netbsd/net/services.h
+  usage:  genserv < /etc/services > libc/netbsd/net/services.h
 
   this program is used to generate the hard-coded internet service list for the
   Bionic C library.
@@ -72,5 +72,3 @@
     line += str(s)+"\\\n"
 line += '\\0";\n'
 print line
-
-
diff --git a/libc/tools/gensyscalls.py b/libc/tools/gensyscalls.py
index 5e519de..ed1b3dc 100755
--- a/libc/tools/gensyscalls.py
+++ b/libc/tools/gensyscalls.py
@@ -46,8 +46,9 @@
 #
 
 x86_header = """/* autogenerated by gensyscalls.py */
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
 
 ENTRY(%(fname)s)
 """
@@ -56,7 +57,7 @@
 
 x86_call = """    movl    $%(idname)s, %%eax
     int     $0x80
-    cmpl    $-129, %%eax
+    cmpl    $-MAX_ERRNO, %%eax
     jb      1f
     negl    %%eax
     pushl   %%eax
@@ -75,8 +76,9 @@
 #
 
 arm_header = """/* autogenerated by gensyscalls.py */
+#include <asm/unistd.h>
+#include <linux/err.h>
 #include <machine/asm.h>
-#include <sys/linux-syscalls.h>
 
 ENTRY(%(fname)s)
 """
@@ -86,9 +88,10 @@
     ldr     r7, =%(idname)s
     swi     #0
     mov     r7, ip
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(%(fname)s)
 """
 
@@ -100,9 +103,10 @@
     ldr     r7, =%(idname)s
     swi     #0
     ldmfd   sp!, {r4, r5, r6, r7}
-    movs    r0, r0
-    bxpl    lr
-    b       __set_syscall_errno
+    cmn     r0, #(MAX_ERRNO + 1)
+    bxls    lr
+    neg     r0, r0
+    b       __set_errno
 END(%(fname)s)
 """
 
@@ -111,7 +115,7 @@
 #
 
 mips_call = """/* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
+#include <asm/unistd.h>
     .text
     .globl %(fname)s
     .align 4
@@ -187,6 +191,14 @@
             count += 1
     return count
 
+# This lets us support regular system calls like __NR_write and also weird
+# ones like __ARM_NR_cacheflush, where the NR doesn't come at the start.
+def make__NR_name(name):
+    if name.startswith("__"):
+        return name
+    else:
+        return "__NR_%s" % (name)
+
 class State:
     def __init__(self):
         self.old_stubs = []
@@ -282,82 +294,56 @@
 
             if t["common"] >= 0 or t["armid"] >= 0:
                 num_regs = count_arm_param_registers(syscall_params)
-                t["asm-arm"] = self.arm_eabi_genstub(syscall_func,num_regs,"__NR_"+syscall_name)
+                t["asm-arm"] = self.arm_eabi_genstub(syscall_func, num_regs, make__NR_name(syscall_name))
 
             if t["common"] >= 0 or t["x86id"] >= 0:
                 num_regs = count_generic_param_registers(syscall_params)
                 if t["cid"] >= 0:
-                    t["asm-x86"] = self.x86_genstub_cid(syscall_func, num_regs, "__NR_"+syscall_name, t["cid"])
+                    t["asm-x86"] = self.x86_genstub_cid(syscall_func, num_regs, make__NR_name(syscall_name), t["cid"])
                 else:
-                    t["asm-x86"] = self.x86_genstub(syscall_func, num_regs, "__NR_"+syscall_name)
+                    t["asm-x86"] = self.x86_genstub(syscall_func, num_regs, make__NR_name(syscall_name))
             elif t["cid"] >= 0:
                 E("cid for dispatch syscalls is only supported for x86 in "
                   "'%s'" % syscall_name)
                 return
 
             if t["common"] >= 0 or t["mipsid"] >= 0:
-                t["asm-mips"] = self.mips_genstub(syscall_func,"__NR_"+syscall_name)
+                t["asm-mips"] = self.mips_genstub(syscall_func, make__NR_name(syscall_name))
 
 
-    def gen_NR_syscall(self,fp,name,id):
-        fp.write( "#define __NR_%-25s    (__NR_SYSCALL_BASE + %d)\n" % (name,id) )
+    # Scan a Linux kernel asm/unistd.h file containing __NR_* constants
+    # and write out equivalent SYS_* constants for glibc source compatibility.
+    def scan_linux_unistd_h(self, fp, path):
+        pattern = re.compile(r'^#define __NR_([a-z]\S+) .*')
+        syscalls = set() # MIPS defines everything three times; work around that.
+        for line in open(path):
+            m = re.search(pattern, line)
+            if m:
+                syscalls.add(m.group(1))
+        for syscall in sorted(syscalls):
+            fp.write("#define SYS_%s %s\n" % (syscall, make__NR_name(syscall)))
 
-    # now dump the content of linux-syscalls.h
-    def gen_linux_syscalls_h(self):
-        path = "include/sys/linux-syscalls.h"
-        D( "generating "+path )
-        fp = create_file( path )
-        fp.write( "/* auto-generated by gensyscalls.py, do not touch */\n" )
-        fp.write( "#ifndef _BIONIC_LINUX_SYSCALLS_H_\n" )
-        fp.write( "#define _BIONIC_LINUX_SYSCALLS_H_\n\n" )
-        fp.write( "#if !defined __ASM_ARM_UNISTD_H && !defined __ASM_I386_UNISTD_H && !defined __ASM_MIPS_UNISTD_H\n" )
-        fp.write( "#if defined __arm__ && !defined __ARM_EABI__ && !defined __thumb__\n" )
-        fp.write( "  #  define __NR_SYSCALL_BASE 0x900000\n" )
-        fp.write( "#elif defined(__mips__)\n" )
-        fp.write( "  #  define __NR_SYSCALL_BASE 4000\n" )
-        fp.write( "#else\n" )
-        fp.write( "  #  define __NR_SYSCALL_BASE 0\n" )
-        fp.write( "#endif\n\n" )
 
-        # first, all common syscalls
-        for sc in sorted(self.syscalls,key=lambda x:x["common"]):
-            sc_id  = sc["common"]
-            sc_name = sc["name"]
-            if sc_id >= 0:
-                self.gen_NR_syscall( fp, sc_name, sc_id )
+    def gen_glibc_syscalls_h(self):
+        # TODO: generate a separate file for each architecture, like glibc's bits/syscall.h.
+        glibc_syscalls_h_path = "include/sys/glibc-syscalls.h"
+        D("generating " + glibc_syscalls_h_path)
+        glibc_fp = create_file(glibc_syscalls_h_path)
+        glibc_fp.write("/* Auto-generated by gensyscalls.py; do not edit. */\n")
+        glibc_fp.write("#ifndef _BIONIC_GLIBC_SYSCALLS_H_\n")
+        glibc_fp.write("#define _BIONIC_GLIBC_SYSCALLS_H_\n")
 
-        # now, all arm-specific syscalls
-        fp.write( "\n#ifdef __arm__\n" );
-        for sc in self.syscalls:
-            sc_id  = sc["armid"]
-            sc_name = sc["name"]
-            if sc_id >= 0:
-                self.gen_NR_syscall( fp, sc_name, sc_id )
-        fp.write( "#endif\n" );
+        glibc_fp.write("#if defined(__arm__)\n")
+        self.scan_linux_unistd_h(glibc_fp, "libc/kernel/arch-arm/asm/unistd.h")
+        glibc_fp.write("#elif defined(__mips__)\n")
+        self.scan_linux_unistd_h(glibc_fp, "libc/kernel/arch-mips/asm/unistd.h")
+        glibc_fp.write("#elif defined(__i386__)\n")
+        self.scan_linux_unistd_h(glibc_fp, "libc/kernel/arch-x86/asm/unistd_32.h")
+        glibc_fp.write("#endif\n")
 
-        gen_syscalls = {}
-        # finally, all i386-specific syscalls
-        fp.write( "\n#ifdef __i386__\n" );
-        for sc in sorted(self.syscalls,key=lambda x:x["x86id"]):
-            sc_id  = sc["x86id"]
-            sc_name = sc["name"]
-            if sc_id >= 0 and sc_name not in gen_syscalls:
-                self.gen_NR_syscall( fp, sc_name, sc_id )
-                gen_syscalls[sc_name] = True
-        fp.write( "#endif\n" );
-
-        # all mips-specific syscalls
-        fp.write( "\n#ifdef __mips__\n" );
-        for sc in sorted(self.syscalls,key=lambda x:x["mipsid"]):
-            sc_id = sc["mipsid"]
-            if sc_id >= 0:
-                self.gen_NR_syscall( fp, sc["name"], sc_id )
-        fp.write( "#endif\n" );
-
-        fp.write( "\n#endif\n" )
-        fp.write( "\n#endif /* _BIONIC_LINUX_SYSCALLS_H_ */\n" );
-        fp.close()
-        self.other_files.append( path )
+        glibc_fp.write("#endif /* _BIONIC_GLIBC_SYSCALLS_H_ */\n")
+        glibc_fp.close()
+        self.other_files.append(glibc_syscalls_h_path)
 
 
     # now dump the contents of syscalls.mk
@@ -428,7 +414,7 @@
 
         D( "re-generating stubs and support files" )
 
-        self.gen_linux_syscalls_h()
+        self.gen_glibc_syscalls_h()
         for arch in all_archs:
             self.gen_arch_syscalls_mk(arch)
         self.gen_syscall_stubs()
diff --git a/libc/tools/zoneinfo/ZoneCompactor.java b/libc/tools/zoneinfo/ZoneCompactor.java
index 8a1a628..f47afd1 100644
--- a/libc/tools/zoneinfo/ZoneCompactor.java
+++ b/libc/tools/zoneinfo/ZoneCompactor.java
@@ -198,6 +198,8 @@
     // Write the data.
     f.write(allData.toByteArray());
 
+    int zonetab_offset = (int) f.getFilePointer();
+
     // Copy the zone.tab.
     reader = new BufferedReader(new FileReader(zoneTabFile));
     while ((s = reader.readLine()) != null) {
@@ -208,8 +210,6 @@
     }
     reader.close();
 
-    int zonetab_offset = (int) f.getFilePointer();
-
     // Go back and fix up the offsets in the header.
     f.seek(index_offset_offset);
     f.writeInt(index_offset);
diff --git a/libc/tzcode/localtime.c b/libc/tzcode/localtime.c
index 447907e..8a54e81 100644
--- a/libc/tzcode/localtime.c
+++ b/libc/tzcode/localtime.c
@@ -404,10 +404,7 @@
 }
 
 static int
-tzload(name, sp, doextend)
-register const char *       name;
-register struct state * const   sp;
-register const int      doextend;
+tzload(const char* name, struct state* const sp, const int doextend)
 {
     register const char *       p;
     register int            i;
@@ -2068,32 +2065,55 @@
 }
 
 // BEGIN android-added
-time_t
-mktime_tz(tmp, tz)
-struct tm * const tmp;
-char const * tz;
-{
-    struct state st;
-    if (tzload(tz, &st, TRUE) != 0) {
-        // TODO: not sure what's best here, but for now, we fall back to gmt.
-        gmtload(&st);
-    }
-    return time1(tmp, localsub, 0L, &st);
+
+// Caches the most recent timezone (http://b/8270865).
+static int __bionic_tzload_cached(const char* name, struct state* const sp, const int doextend) {
+  _tzLock();
+
+  // Our single-item cache.
+  static char* gCachedTimeZoneName;
+  static struct state gCachedTimeZone;
+
+  // Do we already have this timezone cached?
+  if (gCachedTimeZoneName != NULL && strcmp(name, gCachedTimeZoneName) == 0) {
+    *sp = gCachedTimeZone;
+    _tzUnlock();
+    return 0;
+  }
+
+  // Can we load it?
+  int rc = tzload(name, sp, doextend);
+  if (rc == 0) {
+    // Update the cache.
+    free(gCachedTimeZoneName);
+    gCachedTimeZoneName = strdup(name);
+    gCachedTimeZone = *sp;
+  }
+
+  _tzUnlock();
+  return rc;
 }
 
-void
-localtime_tz(timep, tmp, tz)
-const time_t * const timep;
-struct tm * tmp;
-const char* tz;
-{
-    struct state st;
-    if (tzload(tz, &st, TRUE) != 0) {
-        // TODO: not sure what's best here, but for now, we fall back to gmt.
-        gmtload(&st);
-    }
-    localsub(timep, 0L, tmp, &st);
+// Non-standard API: mktime(3) but with an explicit timezone parameter.
+time_t mktime_tz(struct tm* const tmp, const char* tz) {
+  struct state st;
+  if (__bionic_tzload_cached(tz, &st, TRUE) != 0) {
+    // TODO: not sure what's best here, but for now, we fall back to gmt.
+    gmtload(&st);
+  }
+  return time1(tmp, localsub, 0L, &st);
 }
+
+// Non-standard API: localtime(3) but with an explicit timezone parameter.
+void localtime_tz(const time_t* const timep, struct tm* tmp, const char* tz) {
+  struct state st;
+  if (__bionic_tzload_cached(tz, &st, TRUE) != 0) {
+    // TODO: not sure what's best here, but for now, we fall back to gmt.
+    gmtload(&st);
+  }
+  localsub(timep, 0L, tmp, &st);
+}
+
 // END android-added
 
 #ifdef STD_INSPIRED
@@ -2285,7 +2305,13 @@
 
   static const size_t NAME_LENGTH = 40;
   unsigned char buf[NAME_LENGTH + 3 * sizeof(int32_t)];
-  while (TEMP_FAILURE_RETRY(read(fd, buf, sizeof(buf))) == (ssize_t) sizeof(buf)) {
+
+  size_t id_count = (ntohl(header.data_offset) - ntohl(header.index_offset)) / sizeof(buf);
+  for (size_t i = 0; i < id_count; ++i) {
+    if (TEMP_FAILURE_RETRY(read(fd, buf, sizeof(buf))) != (ssize_t) sizeof(buf)) {
+      break;
+    }
+
     char this_id[NAME_LENGTH + 1];
     memcpy(this_id, buf, NAME_LENGTH);
     this_id[NAME_LENGTH] = '\0';
diff --git a/libc/unistd/popen.c b/libc/unistd/popen.c
deleted file mode 100644
index c2355c1..0000000
--- a/libc/unistd/popen.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/*	$OpenBSD: popen.c,v 1.17 2005/08/08 08:05:34 espie Exp $ */
-/*
- * Copyright (c) 1988, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software written by Ken Arnold and
- * published in UNIX Review, Vol. 6, No. 8.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/param.h>
-#include <sys/wait.h>
-
-#include <signal.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <paths.h>
-
-static struct pid {
-	struct pid *next;
-	FILE *fp;
-	pid_t pid;
-} *pidlist;
-
-extern char **environ;
-
-FILE *
-popen(const char *program, const char *type)
-{
-	struct pid * volatile cur;
-	FILE *iop;
-	int pdes[2];
-	pid_t pid;
-	char *argp[] = {"sh", "-c", NULL, NULL};
-
-	if ((*type != 'r' && *type != 'w') || type[1] != '\0') {
-		errno = EINVAL;
-		return (NULL);
-	}
-
-	if ((cur = malloc(sizeof(struct pid))) == NULL)
-		return (NULL);
-
-	if (pipe(pdes) < 0) {
-		free(cur);
-		return (NULL);
-	}
-
-	switch (pid = fork()) {
-	case -1:			/* Error. */
-		(void)close(pdes[0]);
-		(void)close(pdes[1]);
-		free(cur);
-		return (NULL);
-		/* NOTREACHED */
-	case 0:				/* Child. */
-	    {
-		struct pid *pcur;
-		/*
-		 * We fork()'d, we got our own copy of the list, no
-		 * contention.
-		 */
-		for (pcur = pidlist; pcur; pcur = pcur->next)
-			close(fileno(pcur->fp));
-
-		if (*type == 'r') {
-			(void) close(pdes[0]);
-			if (pdes[1] != STDOUT_FILENO) {
-				(void)dup2(pdes[1], STDOUT_FILENO);
-				(void)close(pdes[1]);
-			}
-		} else {
-			(void)close(pdes[1]);
-			if (pdes[0] != STDIN_FILENO) {
-				(void)dup2(pdes[0], STDIN_FILENO);
-				(void)close(pdes[0]);
-			}
-		}
-		argp[2] = (char *)program;
-		execve(_PATH_BSHELL, argp, environ);
-		_exit(127);
-		/* NOTREACHED */
-	    }
-	}
-
-	/* Parent; assume fdopen can't fail. */
-	if (*type == 'r') {
-		iop = fdopen(pdes[0], type);
-		(void)close(pdes[1]);
-	} else {
-		iop = fdopen(pdes[1], type);
-		(void)close(pdes[0]);
-	}
-
-	/* Link into list of file descriptors. */
-	cur->fp = iop;
-	cur->pid =  pid;
-	cur->next = pidlist;
-	pidlist = cur;
-
-	return (iop);
-}
-
-/*
- * pclose --
- *	Pclose returns -1 if stream is not associated with a `popened' command,
- *	if already `pclosed', or waitpid returns an error.
- */
-int
-pclose(FILE *iop)
-{
-	struct pid *cur, *last;
-	int pstat;
-	pid_t pid;
-
-	/* Find the appropriate file pointer. */
-	for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next)
-		if (cur->fp == iop)
-			break;
-
-	if (cur == NULL)
-		return (-1);
-
-	(void)fclose(iop);
-
-	do {
-		pid = waitpid(cur->pid, &pstat, 0);
-	} while (pid == -1 && errno == EINTR);
-
-	/* Remove the entry from the linked list. */
-	if (last == NULL)
-		pidlist = cur->next;
-	else
-		last->next = cur->next;
-	free(cur);
-
-	return (pid == -1 ? -1 : pstat);
-}
diff --git a/libc/upstream-freebsd/README.txt b/libc/upstream-freebsd/README.txt
new file mode 100644
index 0000000..fbfc04a
--- /dev/null
+++ b/libc/upstream-freebsd/README.txt
@@ -0,0 +1,5 @@
+This directory contains upstream FreeBSD source. You should not edit these
+files directly. Make fixes upstream and then pull down the new version of
+the file.
+
+TODO: write a script to make this process automated.
diff --git a/libc/upstream-netbsd/env.h b/libc/upstream-netbsd/env.h
new file mode 100644
index 0000000..8f99f9d
--- /dev/null
+++ b/libc/upstream-netbsd/env.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BIONIC_NETBSD_ENV_H_included
+#define _BIONIC_NETBSD_ENV_H_included
+
+/* Placeholder. */
+
+#endif
diff --git a/libc/upstream-netbsd/libc/gen/popen.c b/libc/upstream-netbsd/libc/gen/popen.c
new file mode 100644
index 0000000..593e346
--- /dev/null
+++ b/libc/upstream-netbsd/libc/gen/popen.c
@@ -0,0 +1,227 @@
+/*	$NetBSD: popen.c,v 1.32 2012/06/25 22:32:43 abs Exp $	*/
+
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software written by Ken Arnold and
+ * published in UNIX Review, Vol. 6, No. 8.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)popen.c	8.3 (Berkeley) 5/3/95";
+#else
+__RCSID("$NetBSD: popen.c,v 1.32 2012/06/25 22:32:43 abs Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#include <sys/param.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <paths.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "env.h"
+#include "reentrant.h"
+
+#ifdef __weak_alias
+__weak_alias(popen,_popen)
+__weak_alias(pclose,_pclose)
+#endif
+
+static struct pid {
+	struct pid *next;
+	FILE *fp;
+#ifdef _REENTRANT
+	int fd;
+#endif
+	pid_t pid;
+} *pidlist; 
+	
+#ifdef _REENTRANT
+static rwlock_t pidlist_lock = RWLOCK_INITIALIZER;
+#endif
+
+FILE *
+popen(const char *command, const char *type)
+{
+	struct pid *cur, *old;
+	FILE *iop;
+	const char * volatile xtype = type;
+	int pdes[2], pid, serrno;
+	volatile int twoway;
+	int flags;
+
+	_DIAGASSERT(command != NULL);
+	_DIAGASSERT(xtype != NULL);
+
+	flags = strchr(xtype, 'e') ? O_CLOEXEC : 0;
+	if (strchr(xtype, '+')) {
+		int stype = flags ? (SOCK_STREAM | SOCK_CLOEXEC) : SOCK_STREAM;
+		twoway = 1;
+		xtype = "r+";
+		if (socketpair(AF_LOCAL, stype, 0, pdes) < 0)
+			return NULL;
+	} else  {
+		twoway = 0;
+		xtype = strrchr(xtype, 'r') ? "r" : "w";
+		if (pipe2(pdes, flags) == -1)
+			return NULL;
+	}
+
+	if ((cur = malloc(sizeof(struct pid))) == NULL) {
+		(void)close(pdes[0]);
+		(void)close(pdes[1]);
+		errno = ENOMEM;
+		return (NULL);
+	}
+
+	(void)rwlock_rdlock(&pidlist_lock);
+	(void)__readlockenv();
+	switch (pid = vfork()) {
+	case -1:			/* Error. */
+		serrno = errno;
+		(void)__unlockenv();
+		(void)rwlock_unlock(&pidlist_lock);
+		free(cur);
+		(void)close(pdes[0]);
+		(void)close(pdes[1]);
+		errno = serrno;
+		return (NULL);
+		/* NOTREACHED */
+	case 0:				/* Child. */
+		/* POSIX.2 B.3.2.2 "popen() shall ensure that any streams
+		   from previous popen() calls that remain open in the 
+		   parent process are closed in the new child process. */
+		for (old = pidlist; old; old = old->next)
+#ifdef _REENTRANT
+			close(old->fd); /* don't allow a flush */
+#else
+			close(fileno(old->fp)); /* don't allow a flush */
+#endif
+
+		if (*xtype == 'r') {
+			(void)close(pdes[0]);
+			if (pdes[1] != STDOUT_FILENO) {
+				(void)dup2(pdes[1], STDOUT_FILENO);
+				(void)close(pdes[1]);
+			}
+			if (twoway)
+				(void)dup2(STDOUT_FILENO, STDIN_FILENO);
+		} else {
+			(void)close(pdes[1]);
+			if (pdes[0] != STDIN_FILENO) {
+				(void)dup2(pdes[0], STDIN_FILENO);
+				(void)close(pdes[0]);
+			}
+		}
+
+		execl(_PATH_BSHELL, "sh", "-c", command, NULL);
+		_exit(127);
+		/* NOTREACHED */
+	}
+	(void)__unlockenv();
+
+	/* Parent; assume fdopen can't fail. */
+	if (*xtype == 'r') {
+		iop = fdopen(pdes[0], xtype);
+#ifdef _REENTRANT
+		cur->fd = pdes[0];
+#endif
+		(void)close(pdes[1]);
+	} else {
+		iop = fdopen(pdes[1], xtype);
+#ifdef _REENTRANT
+		cur->fd = pdes[1];
+#endif
+		(void)close(pdes[0]);
+	}
+
+	/* Link into list of file descriptors. */
+	cur->fp = iop;
+	cur->pid =  pid;
+	cur->next = pidlist;
+	pidlist = cur;
+	(void)rwlock_unlock(&pidlist_lock);
+
+	return (iop);
+}
+
+/*
+ * pclose --
+ *	Pclose returns -1 if stream is not associated with a `popened' command,
+ *	if already `pclosed', or waitpid returns an error.
+ */
+int
+pclose(FILE *iop)
+{
+	struct pid *cur, *last;
+	int pstat;
+	pid_t pid;
+
+	_DIAGASSERT(iop != NULL);
+
+	rwlock_wrlock(&pidlist_lock);
+
+	/* Find the appropriate file pointer. */
+	for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next)
+		if (cur->fp == iop)
+			break;
+	if (cur == NULL) {
+		(void)rwlock_unlock(&pidlist_lock);
+		return (-1);
+	}
+
+	(void)fclose(iop);
+
+	/* Remove the entry from the linked list. */
+	if (last == NULL)
+		pidlist = cur->next;
+	else
+		last->next = cur->next;
+
+	(void)rwlock_unlock(&pidlist_lock);
+
+	do {
+		pid = waitpid(cur->pid, &pstat, 0);
+	} while (pid == -1 && errno == EINTR);
+
+	free(cur);
+
+	return (pid == -1 ? -1 : pstat);
+}
diff --git a/libc/upstream-netbsd/netbsd-compat.h b/libc/upstream-netbsd/netbsd-compat.h
index 3833c1d..e33885e 100644
--- a/libc/upstream-netbsd/netbsd-compat.h
+++ b/libc/upstream-netbsd/netbsd-compat.h
@@ -24,4 +24,13 @@
 // TODO: update our <sys/cdefs.h> to support this properly.
 #define __type_fit(t, a) (0 == 0)
 
+// TODO: our 2.6 emulator kernels don't support SOCK_CLOEXEC yet, so we have to do without.
+#define SOCK_CLOEXEC 0
+
+#define _GNU_SOURCE
+
+// TODO: we don't yet have thread-safe environment variables.
+#define __readlockenv() 0
+#define __unlockenv() 0
+
 #endif
diff --git a/libc/upstream-netbsd/reentrant.h b/libc/upstream-netbsd/reentrant.h
index a4381d4..e2945da 100644
--- a/libc/upstream-netbsd/reentrant.h
+++ b/libc/upstream-netbsd/reentrant.h
@@ -17,9 +17,22 @@
 #ifndef _BIONIC_NETBSD_REENTRANT_H_included
 #define _BIONIC_NETBSD_REENTRANT_H_included
 
+#define _REENTRANT
+
 #include <pthread.h>
 #include <signal.h>
 
-// Placeholder.
+//
+// Map NetBSD libc internal locking to pthread locking.
+//
+
+#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+#define mutex_t pthread_mutex_t
+
+#define RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER
+#define rwlock_t pthread_rwlock_t
+#define rwlock_rdlock pthread_rwlock_rdlock
+#define rwlock_unlock pthread_rwlock_unlock
+#define rwlock_wrlock pthread_rwlock_wrlock
 
 #endif
diff --git a/libc/zoneinfo/tzdata b/libc/zoneinfo/tzdata
index bd59e05..4cd1450 100644
--- a/libc/zoneinfo/tzdata
+++ b/libc/zoneinfo/tzdata
Binary files differ
diff --git a/libdl/dltest.c b/libdl/dltest.c
old mode 100755
new mode 100644
diff --git a/libm/NOTICE b/libm/NOTICE
index 06a100c..d6d0ad9 100644
--- a/libm/NOTICE
+++ b/libm/NOTICE
@@ -225,96 +225,6 @@
 
 -------------------------------------------------------------------
 
-Copyright (c) 1993,94 Winning Strategies, Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
-   must display the following acknowledgement:
-     This product includes software developed by Winning Strategies, Inc.
-4. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 1993,94 Winning Strategies, Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
-   must display the following acknowledgement:
-     This product includes software developed by Winning Strategies, Inc.
-4. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
-Copyright (c) 1994 Winning Strategies, Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
-   must display the following acknowledgement:
-     This product includes software developed by Winning Strategies, Inc.
-4. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
 Copyright (c) 2001-2011 The FreeBSD Project.
 All rights reserved.
 
diff --git a/libstdc++/src/pure_virtual.cpp b/libstdc++/src/pure_virtual.cpp
index affb80f..6b5e328 100644
--- a/libstdc++/src/pure_virtual.cpp
+++ b/libstdc++/src/pure_virtual.cpp
@@ -2,7 +2,7 @@
 #include <assert.h>
 
 extern "C" void __cxa_pure_virtual() {
-  // We can't call __libc_android_log_write from libstdc++ because it's private, so cheat.
+  // We can't call __libc_format_log from libstdc++ because it's hidden and in libc, so cheat.
   assert(!"Pure virtual function called. Are you calling virtual methods from a destructor?");
   /* NOTREACHED */
 }
diff --git a/linker/README.TXT b/linker/README.TXT
deleted file mode 100644
index e75823e..0000000
--- a/linker/README.TXT
+++ /dev/null
@@ -1,89 +0,0 @@
-Android Dynamic Linker Design Notes
-===================================
-
-Introduction:
--------------
-
-This document provides several notes related to the design of the Android
-dynamic linker.
-
-
-Initialization and Termination functions:
------------------------------------------
-
-The Unix Sys V Binary Interface standard states that an
-executable can have the following entries in its .dynamic
-section:
-
-  DT_INIT
-      Points to the address of an initialization function
-      that must be called when the file is loaded.
-
-  DT_INIT_ARRAY
-      Points to an array of function addresses that must be
-      called, in-order, to perform initialization. Some of
-      the entries in the array can be 0 or -1, and should
-      be ignored.
-
-      Note: this is generally stored in a .init_array section
-
-  DT_INIT_ARRAYSZ
-      The size of the DT_INITARRAY, if any
-
-  DT_FINI
-      Points to the address of a finalization function which
-      must be called when the file is unloaded or the process
-      terminated.
-
-  DT_FINI_ARRAY
-      Same as DT_INITARRAY but for finalizers. Note that the
-      functions must be called in reverse-order though
-
-      Note: this is generally stored in a .fini_array section
-
-  DT_FINI_ARRAYSZ
-      Size of FT_FINIARRAY
-
-  DT_PREINIT_ARRAY
-      An array similar to DT_INIT_ARRAY which must *only* be
-      present in executables, not shared libraries, which contains
-      a list of functions that need to be called before any other
-      initialization function (i.e. DT_INIT and/or DT_INIT_ARRAY)
-      in the executable or any of its libraries.
-
-      Note: this is generally stored in a .preinit_array section
-
-  DT_PREINIT_ARRAYSZ
-      The size of DT_PREINIT_ARRAY
-
-If both a DT_INIT and DT_INITARRAY entry are present, the DT_INIT
-function must be called before the DT_INITARRAY functions.
-
-Consequently, the DT_FINIARRAY must be parsed in reverse order before
-the DT_FINI function, if both are available.
-
-Note that the implementation of static C++ constructors is very
-much processor dependent, and may use different ELF sections.
-
-On the ARM (see "C++ ABI for ARM" document), the static constructors
-must be called explicitly from the DT_INIT_ARRAY, and each one of them
-shall register a destructor by calling the special __eabi_atexit()
-function (provided by the C library). The DT_FINI_ARRAY is not used
-by static C++ destructors.
-
-On x86, the lists of constructors and destructors are placed in special
-sections named ".ctors" and ".dtors", and the DT_INIT / DT_FINI functions
-are in charge of calling them explicitly.
-
-
-Debugging:
-----------
-
-You can increase the verbosity of debug traces by defining the LD_DEBUG
-environment variable to a numeric value from 0 to 2 (corresponding to
-INFO, TRACE, and DEBUG calls in the source). This will only
-affect new processes being launched.
-
-By default, traces are sent to logcat, with the "linker" tag. You can
-change this to go to stdout instead by setting the definition of
-LINKER_DEBUG_TO_LOG to 0 in "linker_debug.h".
diff --git a/linker/arch/x86/begin.c b/linker/arch/x86/begin.c
old mode 100755
new mode 100644
diff --git a/linker/debugger.cpp b/linker/debugger.cpp
index 586cd2f..6fddb1c 100644
--- a/linker/debugger.cpp
+++ b/linker/debugger.cpp
@@ -37,9 +37,6 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 
-#include <private/debug_format.h>
-#include <private/logd.h>
-
 extern "C" int tgkill(int tgid, int tid, int sig);
 
 #define DEBUGGER_SOCKET_NAME "android:debuggerd"
@@ -157,15 +154,15 @@
     sigemptyset(&newact.sa_mask);
 
     if (sigaction(signum, &newact, &oldact) < 0) {
-        __libc_android_log_write(ANDROID_LOG_FATAL, "libc",
-            "Failed testing for SA_SIGINFO");
-        return 0;
+      __libc_format_log(ANDROID_LOG_FATAL, "libc", "Failed testing for SA_SIGINFO: %s",
+                        strerror(errno));
+      return 0;
     }
     bool ret = (oldact.sa_flags & SA_SIGINFO) != 0;
 
-    if (sigaction(signum, &oldact, NULL) < 0) {
-        __libc_android_log_write(ANDROID_LOG_FATAL, "libc",
-            "Restore failed in test for SA_SIGINFO");
+    if (sigaction(signum, &oldact, NULL) == -1) {
+      __libc_format_log(ANDROID_LOG_FATAL, "libc", "Restore failed in test for SA_SIGINFO: %s",
+                        strerror(errno));
     }
     return ret;
 }
diff --git a/linker/dlfcn.cpp b/linker/dlfcn.cpp
index 0b38ec4..638164d 100644
--- a/linker/dlfcn.cpp
+++ b/linker/dlfcn.cpp
@@ -215,7 +215,7 @@
 
     phdr: 0, phnum: 0,
     entry: 0, base: 0, size: 0,
-    unused: 0, dynamic: 0, unused2: 0, unused3: 0,
+    unused1: 0, dynamic: 0, unused2: 0, unused3: 0,
     next: 0,
 
     flags: FLAG_LINKED,
@@ -238,7 +238,7 @@
     mips_symtabno: 0, mips_local_gotno: 0, mips_gotsym: 0,
 #endif
 
-    refcount: 0,
+    ref_count: 0,
     { l_addr: 0, l_name: 0, l_ld: 0, l_next: 0, l_prev: 0, },
     constructors_called: false,
     load_bias: 0,
diff --git a/linker/linker.cpp b/linker/linker.cpp
old mode 100755
new mode 100644
index b275953..3afd314
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -42,7 +42,6 @@
 // Private C library headers.
 #include <private/bionic_tls.h>
 #include <private/KernelArgumentBlock.h>
-#include <private/logd.h>
 #include <private/ScopedPthreadMutexLocker.h>
 
 #include "linker.h"
@@ -141,13 +140,13 @@
 
 // You shouldn't try to call memory-allocating functions in the dynamic linker.
 // Guard against the most obvious ones.
-#define DISALLOW_ALLOCATION(return_type, name, ...)                             \
-    return_type name __VA_ARGS__                                                \
-    {                                                                           \
+#define DISALLOW_ALLOCATION(return_type, name, ...) \
+    return_type name __VA_ARGS__ \
+    { \
         const char* msg = "ERROR: " #name " called from the dynamic linker!\n"; \
-         __libc_android_log_write(ANDROID_LOG_FATAL, "linker", msg);            \
-        write(2, msg, strlen(msg));                                             \
-        abort();                                                                \
+        __libc_format_log(ANDROID_LOG_FATAL, "linker", "%s", msg); \
+        write(2, msg, strlen(msg)); \
+        abort(); \
     }
 #define UNUSED __attribute__((unused))
 DISALLOW_ALLOCATION(void*, malloc, (size_t u UNUSED));
@@ -174,13 +173,13 @@
 
 static r_debug _r_debug = {1, NULL, &rtld_db_dlactivity,
                                   RT_CONSISTENT, 0};
-static link_map* r_debug_tail = 0;
+static link_map_t* r_debug_tail = 0;
 
 static pthread_mutex_t gDebugMutex = PTHREAD_MUTEX_INITIALIZER;
 
 static void insert_soinfo_into_debug_map(soinfo * info) {
     // Copy the necessary fields into the debug structure.
-    link_map* map = &(info->linkmap);
+    link_map_t* map = &(info->link_map);
     map->l_addr = info->base;
     map->l_name = (char*) info->name;
     map->l_ld = (uintptr_t)info->dynamic;
@@ -203,7 +202,7 @@
 }
 
 static void remove_soinfo_from_debug_map(soinfo* info) {
-    link_map* map = &(info->linkmap);
+    link_map_t* map = &(info->link_map);
 
     if (r_debug_tail == map) {
         r_debug_tail = map->l_prev;
@@ -315,7 +314,7 @@
   sonext->next = si;
   sonext = si;
 
-  TRACE("name %s: allocated soinfo @ %p\n", name, si);
+  TRACE("name %s: allocated soinfo @ %p", name, si);
   return si;
 }
 
@@ -327,7 +326,7 @@
 
     soinfo *prev = NULL, *trav;
 
-    TRACE("name %s: freeing soinfo @ %p\n", si->name, si);
+    TRACE("name %s: freeing soinfo @ %p", si->name, si);
 
     for (trav = solist; trav != NULL; trav = trav->next) {
         if (trav == si)
@@ -425,8 +424,8 @@
     int rv = 0;
     for (soinfo* si = solist; si != NULL; si = si->next) {
         dl_phdr_info dl_info;
-        dl_info.dlpi_addr = si->linkmap.l_addr;
-        dl_info.dlpi_name = si->linkmap.l_name;
+        dl_info.dlpi_addr = si->link_map.l_addr;
+        dl_info.dlpi_name = si->link_map.l_name;
         dl_info.dlpi_phdr = si->phdr;
         dl_info.dlpi_phnum = si->phnum;
         rv = cb(&dl_info, sizeof(dl_phdr_info), data);
@@ -445,7 +444,7 @@
     const char* strtab = si->strtab;
     unsigned n;
 
-    TRACE_TYPE(LOOKUP, "SEARCH %s in %s@0x%08x %08x %d\n",
+    TRACE_TYPE(LOOKUP, "SEARCH %s in %s@0x%08x %08x %d",
                name, si->name, si->base, hash, hash % si->nbucket);
     n = hash % si->nbucket;
 
@@ -461,7 +460,7 @@
                 continue;
             }
 
-            TRACE_TYPE(LOOKUP, "FOUND %s in %s (%08x) %d\n",
+            TRACE_TYPE(LOOKUP, "FOUND %s in %s (%08x) %d",
                        name, si->name, s->st_value, s->st_size);
             return s;
         }
@@ -510,7 +509,7 @@
              */
 
             if (!si->has_DT_SYMBOLIC) {
-                DEBUG("%s: looking up %s in executable %s\n",
+                DEBUG("%s: looking up %s in executable %s",
                       si->name, name, somain->name);
                 s = soinfo_elf_lookup(somain, elf_hash, name);
                 if (s != NULL) {
@@ -541,7 +540,7 @@
              */
 
             if (si->has_DT_SYMBOLIC) {
-                DEBUG("%s: looking up %s in executable %s after local scope\n",
+                DEBUG("%s: looking up %s in executable %s after local scope",
                       si->name, name, somain->name);
                 s = soinfo_elf_lookup(somain, elf_hash, name);
                 if (s != NULL) {
@@ -562,7 +561,7 @@
     }
 
     for (int i = 0; needed[i] != NULL; i++) {
-        DEBUG("%s: looking up %s in %s\n",
+        DEBUG("%s: looking up %s in %s",
               si->name, name, needed[i]->name);
         s = soinfo_elf_lookup(needed[i], elf_hash, name);
         if (s != NULL) {
@@ -574,7 +573,7 @@
 done:
     if (s != NULL) {
         TRACE_TYPE(LOOKUP, "si %s sym %s s->st_value = 0x%08x, "
-                   "found in %s, base = 0x%08x, load bias = 0x%08x\n",
+                   "found in %s, base = 0x%08x, load bias = 0x%08x",
                    si->name, name, s->st_value,
                    (*lsi)->name, (*lsi)->base, (*lsi)->load_bias);
         return s;
@@ -619,39 +618,38 @@
   }
 
   if (s != NULL) {
-    TRACE_TYPE(LOOKUP, "%s s->st_value = 0x%08x, found->base = 0x%08x\n",
+    TRACE_TYPE(LOOKUP, "%s s->st_value = 0x%08x, found->base = 0x%08x",
                name, s->st_value, (*found)->base);
   }
 
   return s;
 }
 
-soinfo* find_containing_library(const void* addr) {
-    for (soinfo* si = solist; si != NULL; si = si->next) {
-        if ((unsigned)addr >= si->base && (unsigned)addr - si->base < si->size) {
-            return si;
-        }
+soinfo* find_containing_library(const void* p) {
+  Elf32_Addr address = reinterpret_cast<Elf32_Addr>(p);
+  for (soinfo* si = solist; si != NULL; si = si->next) {
+    if (address >= si->base && address - si->base < si->size) {
+      return si;
     }
-    return NULL;
+  }
+  return NULL;
 }
 
 Elf32_Sym* dladdr_find_symbol(soinfo* si, const void* addr) {
-    unsigned int i;
-    unsigned soaddr = (unsigned)addr - si->base;
+  Elf32_Addr soaddr = reinterpret_cast<Elf32_Addr>(addr) - si->base;
 
-    /* Search the library's symbol table for any defined symbol which
-     * contains this address */
-    for (i=0; i<si->nchain; i++) {
-        Elf32_Sym *sym = &si->symtab[i];
-
-        if (sym->st_shndx != SHN_UNDEF &&
-           soaddr >= sym->st_value &&
-           soaddr < sym->st_value + sym->st_size) {
-            return sym;
-        }
+  // Search the library's symbol table for any defined symbol which
+  // contains this address.
+  for (size_t i = 0; i < si->nchain; ++i) {
+    Elf32_Sym* sym = &si->symtab[i];
+    if (sym->st_shndx != SHN_UNDEF &&
+        soaddr >= sym->st_value &&
+        soaddr < sym->st_value + sym->st_size) {
+      return sym;
     }
+  }
 
-    return NULL;
+  return NULL;
 }
 
 #if 0
@@ -659,7 +657,7 @@
 {
     Elf32_Sym* s = si->symtab;
     for (unsigned n = 0; n < si->nchain; n++) {
-        TRACE("%04d> %08x: %02x %04x %08x %08x %s\n", n, s,
+        TRACE("%04d> %08x: %02x %04x %08x %08x %s", n, s,
                s->st_info, s->st_shndx, s->st_value, s->st_size,
                si->strtab + s->st_name);
         s++;
@@ -672,7 +670,7 @@
   for (size_t i = 0; paths[i] != NULL; ++i) {
     int n = __libc_format_buffer(buf, sizeof(buf), "%s/%s", paths[i], name);
     if (n < 0 || n >= static_cast<int>(sizeof(buf))) {
-      PRINT("Warning: ignoring very long library path: %s/%s\n", paths[i], name);
+      PRINT("Warning: ignoring very long library path: %s/%s", paths[i], name);
       continue;
     }
     int fd = TEMP_FAILURE_RETRY(open(buf, O_RDONLY | O_CLOEXEC));
@@ -684,7 +682,7 @@
 }
 
 static int open_library(const char* name) {
-  TRACE("[ opening %s ]\n", name);
+  TRACE("[ opening %s ]", name);
 
   // If the name contains a slash, we should attempt to open it directly and not search the paths.
   if (strchr(name, '/') != NULL) {
@@ -766,7 +764,7 @@
     return NULL;
   }
 
-  TRACE("[ '%s' has not been loaded yet.  Locating...]\n", name);
+  TRACE("[ '%s' has not been loaded yet.  Locating...]", name);
   si = load_library(name);
   if (si == NULL) {
     return NULL;
@@ -774,7 +772,7 @@
 
   // At this point we know that whatever is loaded @ base is a valid ELF
   // shared library whose segments are properly mapped in.
-  TRACE("[ init_library base=0x%08x sz=0x%08x name='%s') ]\n",
+  TRACE("[ init_library base=0x%08x sz=0x%08x name='%s' ]",
         si->base, si->size, si->name);
 
   if (!soinfo_link_image(si)) {
@@ -789,22 +787,22 @@
 static soinfo* find_library(const char* name) {
   soinfo* si = find_library_internal(name);
   if (si != NULL) {
-    si->refcount++;
+    si->ref_count++;
   }
   return si;
 }
 
 static int soinfo_unload(soinfo* si) {
-  if (si->refcount == 1) {
-    TRACE("unloading '%s'\n", si->name);
+  if (si->ref_count == 1) {
+    TRACE("unloading '%s'", si->name);
     si->CallDestructors();
 
-    for (Elf32_Dyn* d = si->dynamic; d->d_tag != DT_NEEDED; ++d) {
+    for (Elf32_Dyn* d = si->dynamic; d->d_tag != DT_NULL; ++d) {
       if (d->d_tag == DT_NEEDED) {
         const char* library_name = si->strtab + d->d_un.d_val;
         soinfo* lsi = find_loaded_library(library_name);
         if (lsi != NULL) {
-          TRACE("%s needs to unload %s\n", si->name, lsi->name);
+          TRACE("%s needs to unload %s", si->name, lsi->name);
           soinfo_unload(lsi);
         } else {
           // TODO: should we return -1 in this case?
@@ -816,10 +814,10 @@
     munmap(reinterpret_cast<void*>(si->base), si->size);
     notify_gdb_of_unload(si);
     soinfo_free(si);
-    si->refcount = 0;
+    si->ref_count = 0;
   } else {
-    si->refcount--;
-    TRACE("not unloading '%s', decrementing refcount to %d\n", si->name, si->refcount);
+    si->ref_count--;
+    TRACE("not unloading '%s', decrementing ref_count to %d", si->name, si->ref_count);
   }
   return 0;
 }
@@ -867,11 +865,11 @@
     for (size_t idx = 0; idx < count; ++idx, ++rel) {
         unsigned type = ELF32_R_TYPE(rel->r_info);
         unsigned sym = ELF32_R_SYM(rel->r_info);
-        unsigned reloc = (unsigned)(rel->r_offset + si->load_bias);
-        unsigned sym_addr = 0;
+        Elf32_Addr reloc = static_cast<Elf32_Addr>(rel->r_offset + si->load_bias);
+        Elf32_Addr sym_addr = 0;
         char* sym_name = NULL;
 
-        DEBUG("Processing '%s' relocation at index %d\n", si->name, idx);
+        DEBUG("Processing '%s' relocation at index %d", si->name, idx);
         if (type == 0) { // R_*_NONE
             continue;
         }
@@ -943,7 +941,7 @@
                     return -1;
                 }
 #endif
-                sym_addr = (unsigned)(s->st_value + lsi->load_bias);
+                sym_addr = static_cast<Elf32_Addr>(s->st_value + lsi->load_bias);
             }
             count_relocation(kRelocSymbol);
         } else {
@@ -958,51 +956,51 @@
         case R_ARM_JUMP_SLOT:
             count_relocation(kRelocAbsolute);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "RELO JMP_SLOT %08x <- %08x %s\n", reloc, sym_addr, sym_name);
-            *((unsigned*)reloc) = sym_addr;
+            TRACE_TYPE(RELO, "RELO JMP_SLOT %08x <- %08x %s", reloc, sym_addr, sym_name);
+            *reinterpret_cast<Elf32_Addr*>(reloc) = sym_addr;
             break;
         case R_ARM_GLOB_DAT:
             count_relocation(kRelocAbsolute);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "RELO GLOB_DAT %08x <- %08x %s\n", reloc, sym_addr, sym_name);
-            *((unsigned*)reloc) = sym_addr;
+            TRACE_TYPE(RELO, "RELO GLOB_DAT %08x <- %08x %s", reloc, sym_addr, sym_name);
+            *reinterpret_cast<Elf32_Addr*>(reloc) = sym_addr;
             break;
         case R_ARM_ABS32:
             count_relocation(kRelocAbsolute);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "RELO ABS %08x <- %08x %s\n", reloc, sym_addr, sym_name);
-            *((unsigned*)reloc) += sym_addr;
+            TRACE_TYPE(RELO, "RELO ABS %08x <- %08x %s", reloc, sym_addr, sym_name);
+            *reinterpret_cast<Elf32_Addr*>(reloc) += sym_addr;
             break;
         case R_ARM_REL32:
             count_relocation(kRelocRelative);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "RELO REL32 %08x <- %08x - %08x %s\n",
+            TRACE_TYPE(RELO, "RELO REL32 %08x <- %08x - %08x %s",
                        reloc, sym_addr, rel->r_offset, sym_name);
-            *((unsigned*)reloc) += sym_addr - rel->r_offset;
+            *reinterpret_cast<Elf32_Addr*>(reloc) += sym_addr - rel->r_offset;
             break;
 #elif defined(ANDROID_X86_LINKER)
         case R_386_JMP_SLOT:
             count_relocation(kRelocAbsolute);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "RELO JMP_SLOT %08x <- %08x %s\n", reloc, sym_addr, sym_name);
-            *((unsigned*)reloc) = sym_addr;
+            TRACE_TYPE(RELO, "RELO JMP_SLOT %08x <- %08x %s", reloc, sym_addr, sym_name);
+            *reinterpret_cast<Elf32_Addr*>(reloc) = sym_addr;
             break;
         case R_386_GLOB_DAT:
             count_relocation(kRelocAbsolute);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "RELO GLOB_DAT %08x <- %08x %s\n", reloc, sym_addr, sym_name);
-            *((unsigned*)reloc) = sym_addr;
+            TRACE_TYPE(RELO, "RELO GLOB_DAT %08x <- %08x %s", reloc, sym_addr, sym_name);
+            *reinterpret_cast<Elf32_Addr*>(reloc) = sym_addr;
             break;
 #elif defined(ANDROID_MIPS_LINKER)
     case R_MIPS_REL32:
             count_relocation(kRelocAbsolute);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "RELO REL32 %08x <- %08x %s\n",
+            TRACE_TYPE(RELO, "RELO REL32 %08x <- %08x %s",
                        reloc, sym_addr, (sym_name) ? sym_name : "*SECTIONHDR*");
             if (s) {
-                *((unsigned*)reloc) += sym_addr;
+                *reinterpret_cast<Elf32_Addr*>(reloc) += sym_addr;
             } else {
-                *((unsigned*)reloc) += si->base;
+                *reinterpret_cast<Elf32_Addr*>(reloc) += si->base;
             }
             break;
 #endif /* ANDROID_*_LINKER */
@@ -1018,8 +1016,8 @@
                 DL_ERR("odd RELATIVE form...");
                 return -1;
             }
-            TRACE_TYPE(RELO, "RELO RELATIVE %08x <- +%08x\n", reloc, si->base);
-            *((unsigned*)reloc) += si->base;
+            TRACE_TYPE(RELO, "RELO RELATIVE %08x <- +%08x", reloc, si->base);
+            *reinterpret_cast<Elf32_Addr*>(reloc) += si->base;
             break;
 
 #if defined(ANDROID_X86_LINKER)
@@ -1027,16 +1025,16 @@
             count_relocation(kRelocRelative);
             MARK(rel->r_offset);
 
-            TRACE_TYPE(RELO, "RELO R_386_32 %08x <- +%08x %s\n", reloc, sym_addr, sym_name);
-            *((unsigned *)reloc) += (unsigned)sym_addr;
+            TRACE_TYPE(RELO, "RELO R_386_32 %08x <- +%08x %s", reloc, sym_addr, sym_name);
+            *reinterpret_cast<Elf32_Addr*>(reloc) += sym_addr;
             break;
 
         case R_386_PC32:
             count_relocation(kRelocRelative);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "RELO R_386_PC32 %08x <- +%08x (%08x - %08x) %s\n",
+            TRACE_TYPE(RELO, "RELO R_386_PC32 %08x <- +%08x (%08x - %08x) %s",
                        reloc, (sym_addr - reloc), sym_addr, reloc, sym_name);
-            *((unsigned *)reloc) += (unsigned)(sym_addr - reloc);
+            *reinterpret_cast<Elf32_Addr*>(reloc) += (sym_addr - reloc);
             break;
 #endif /* ANDROID_X86_LINKER */
 
@@ -1059,7 +1057,7 @@
             }
             count_relocation(kRelocCopy);
             MARK(rel->r_offset);
-            TRACE_TYPE(RELO, "RELO %08x <- %d @ %08x %s\n", reloc, s->st_size, sym_addr, sym_name);
+            TRACE_TYPE(RELO, "RELO %08x <- %d @ %08x %s", reloc, s->st_size, sym_addr, sym_name);
             if (reloc == sym_addr) {
                 Elf32_Sym *src = soinfo_do_lookup(NULL, sym_name, &lsi, needed);
 
@@ -1177,37 +1175,33 @@
  *
  *   DT_FINI_ARRAY must be parsed in reverse order.
  */
-void soinfo::CallArray(const char* array_name UNUSED, unsigned* array, int count, bool reverse) {
-  if (array == NULL) {
+void soinfo::CallArray(const char* array_name UNUSED, linker_function_t* functions, size_t count, bool reverse) {
+  if (functions == NULL) {
     return;
   }
 
-  int step = 1;
-  if (reverse) {
-    array += (count-1);
-    step = -1;
+  TRACE("[ Calling %s (size %d) @ %p for '%s' ]", array_name, count, functions, name);
+
+  int begin = reverse ? (count - 1) : 0;
+  int end = reverse ? -1 : count;
+  int step = reverse ? -1 : 1;
+
+  for (int i = begin; i != end; i += step) {
+    TRACE("[ %s[%d] == %p ]", array_name, i, functions[i]);
+    CallFunction("function", functions[i]);
   }
 
-  TRACE("[ Calling %s @ %p [%d] for '%s' ]\n", array_name, array, count, name);
-
-  for (int n = count; n > 0; n--) {
-    TRACE("[ Looking at %s[%d] *%p == 0x%08x ]\n", array_name, n, array, *array);
-    void (*func)() = (void (*)()) *array;
-    array += step;
-    CallFunction("function", func);
-  }
-
-  TRACE("[ Done calling %s for '%s' ]\n", array_name, name);
+  TRACE("[ Done calling %s for '%s' ]", array_name, name);
 }
 
-void soinfo::CallFunction(const char* function_name UNUSED, void (*function)()) {
+void soinfo::CallFunction(const char* function_name UNUSED, linker_function_t function) {
   if (function == NULL || reinterpret_cast<uintptr_t>(function) == static_cast<uintptr_t>(-1)) {
     return;
   }
 
-  TRACE("[ Calling %s @ %p for '%s' ]\n", function_name, function, name);
+  TRACE("[ Calling %s @ %p for '%s' ]", function_name, function, name);
   function();
-  TRACE("[ Done calling %s for '%s' ]\n", function_name, name);
+  TRACE("[ Done calling %s @ %p for '%s' ]", function_name, function, name);
 
   // The function may have called dlopen(3) or dlclose(3), so we need to ensure our data structures
   // are still writable. This happens with our debug malloc (see http://b/7941716).
@@ -1274,7 +1268,7 @@
         DL_ERR("cannot open /dev/null: %s", strerror(errno));
         return -1;
     }
-    TRACE("[ Opened /dev/null file-descriptor=%d]\n", dev_null);
+    TRACE("[ Opened /dev/null file-descriptor=%d]", dev_null);
 
     /* If any of the stdio file descriptors is valid and not associated
        with /dev/null, dup /dev/null to it.  */
@@ -1284,7 +1278,7 @@
             continue;
         }
 
-        TRACE("[ Nullifying stdio file descriptor %d]\n", i);
+        TRACE("[ Nullifying stdio file descriptor %d]", i);
         status = TEMP_FAILURE_RETRY(fcntl(i, F_GETFL));
 
         /* If file is opened, we are good. */
@@ -1313,7 +1307,7 @@
 
     /* If /dev/null is not one of the stdio file descriptors, close it. */
     if (dev_null > 2) {
-        TRACE("[ Closing /dev/null file-descriptor=%d]\n", dev_null);
+        TRACE("[ Closing /dev/null file-descriptor=%d]", dev_null);
         status = TEMP_FAILURE_RETRY(close(dev_null));
         if (status == -1) {
             DL_ERR("close failed: %s", strerror(errno));
@@ -1333,8 +1327,8 @@
 
     /* We can't debug anything until the linker is relocated */
     if (!relocating_linker) {
-        INFO("[ linking %s ]\n", si->name);
-        DEBUG("si->base = 0x%08x si->flags = 0x%08x\n", si->base, si->flags);
+        INFO("[ linking %s ]", si->name);
+        DEBUG("si->base = 0x%08x si->flags = 0x%08x", si->base, si->flags);
     }
 
     /* Extract dynamic section */
@@ -1349,7 +1343,7 @@
         return false;
     } else {
         if (!relocating_linker) {
-            DEBUG("dynamic = %p\n", si->dynamic);
+            DEBUG("dynamic = %p", si->dynamic);
         }
     }
 
@@ -1361,7 +1355,7 @@
     /* extract useful information from dynamic section */
     uint32_t needed_count = 0;
     for (Elf32_Dyn* d = si->dynamic; d->d_tag != DT_NULL; ++d) {
-        DEBUG("d = %p, d[0](tag) = 0x%08x d[1](val) = 0x%08x\n", d, d->d_tag, d->d_un.d_val);
+        DEBUG("d = %p, d[0](tag) = 0x%08x d[1](val) = 0x%08x", d, d->d_tag, d->d_un.d_val);
         switch(d->d_tag){
         case DT_HASH:
             si->nbucket = ((unsigned *) (base + d->d_un.d_ptr))[0];
@@ -1408,30 +1402,30 @@
             DL_ERR("unsupported DT_RELA in \"%s\"", si->name);
             return false;
         case DT_INIT:
-            si->init_func = (void (*)(void))(base + d->d_un.d_ptr);
-            DEBUG("%s constructors (init func) found at %p\n", si->name, si->init_func);
+            si->init_func = reinterpret_cast<linker_function_t>(base + d->d_un.d_ptr);
+            DEBUG("%s constructors (init func) found at %p", si->name, si->init_func);
             break;
         case DT_FINI:
-            si->fini_func = (void (*)(void))(base + d->d_un.d_ptr);
-            DEBUG("%s destructors (fini func) found at %p\n", si->name, si->fini_func);
+            si->fini_func = reinterpret_cast<linker_function_t>(base + d->d_un.d_ptr);
+            DEBUG("%s destructors (fini func) found at %p", si->name, si->fini_func);
             break;
         case DT_INIT_ARRAY:
-            si->init_array = (unsigned *)(base + d->d_un.d_ptr);
-            DEBUG("%s constructors (init_array) found at %p\n", si->name, si->init_array);
+            si->init_array = reinterpret_cast<linker_function_t*>(base + d->d_un.d_ptr);
+            DEBUG("%s constructors (init_array) found at %p", si->name, si->init_array);
             break;
         case DT_INIT_ARRAYSZ:
             si->init_array_count = ((unsigned)d->d_un.d_val) / sizeof(Elf32_Addr);
             break;
         case DT_FINI_ARRAY:
-            si->fini_array = (unsigned *)(base + d->d_un.d_ptr);
-            DEBUG("%s destructors (fini_array) found at %p\n", si->name, si->fini_array);
+            si->fini_array = reinterpret_cast<linker_function_t*>(base + d->d_un.d_ptr);
+            DEBUG("%s destructors (fini_array) found at %p", si->name, si->fini_array);
             break;
         case DT_FINI_ARRAYSZ:
             si->fini_array_count = ((unsigned)d->d_un.d_val) / sizeof(Elf32_Addr);
             break;
         case DT_PREINIT_ARRAY:
-            si->preinit_array = (unsigned *)(base + d->d_un.d_ptr);
-            DEBUG("%s constructors (preinit_array) found at %p\n", si->name, si->preinit_array);
+            si->preinit_array = reinterpret_cast<linker_function_t*>(base + d->d_un.d_ptr);
+            DEBUG("%s constructors (preinit_array) found at %p", si->name, si->preinit_array);
             break;
         case DT_PREINIT_ARRAYSZ:
             si->preinit_array_count = ((unsigned)d->d_un.d_val) / sizeof(Elf32_Addr);
@@ -1487,13 +1481,13 @@
             break;
 
         default:
-            DEBUG("Unused DT entry: type 0x%08x arg 0x%08x\n", d->d_tag, d->d_un.d_val);
+            DEBUG("Unused DT entry: type 0x%08x arg 0x%08x", d->d_tag, d->d_un.d_val);
             break;
 #endif
         }
     }
 
-    DEBUG("si->base = 0x%08x, si->strtab = %p, si->symtab = %p\n",
+    DEBUG("si->base = 0x%08x, si->strtab = %p, si->symtab = %p",
           si->base, si->strtab, si->symtab);
 
     // Sanity checks.
@@ -1535,7 +1529,7 @@
     for (Elf32_Dyn* d = si->dynamic; d->d_tag != DT_NULL; ++d) {
         if (d->d_tag == DT_NEEDED) {
             const char* library_name = si->strtab + d->d_un.d_val;
-            DEBUG("%s needs %s\n", si->name, library_name);
+            DEBUG("%s needs %s", si->name, library_name);
             soinfo* lsi = find_library(library_name);
             if (lsi == NULL) {
                 strlcpy(tmp_err_buf, linker_get_error_buffer(), sizeof(tmp_err_buf));
@@ -1562,13 +1556,13 @@
     }
 
     if (si->plt_rel != NULL) {
-        DEBUG("[ relocating %s plt ]\n", si->name );
+        DEBUG("[ relocating %s plt ]", si->name );
         if (soinfo_relocate(si, si->plt_rel, si->plt_rel_count, needed)) {
             return false;
         }
     }
     if (si->rel != NULL) {
-        DEBUG("[ relocating %s ]\n", si->name );
+        DEBUG("[ relocating %s ]", si->name );
         if (soinfo_relocate(si, si->rel, si->rel_count, needed)) {
             return false;
         }
@@ -1581,7 +1575,7 @@
 #endif
 
     si->flags |= FLAG_LINKED;
-    DEBUG("[ finished linking %s ]\n", si->name);
+    DEBUG("[ finished linking %s ]", si->name);
 
     if (si->has_text_relocations) {
         /* All relocations are done, we can protect our segments back to
@@ -1614,7 +1608,7 @@
  * fixed it's own GOT. It is safe to make references to externs
  * and other non-local data at this point.
  */
-static unsigned __linker_init_post_relocation(KernelArgumentBlock& args, unsigned linker_base) {
+static Elf32_Addr __linker_init_post_relocation(KernelArgumentBlock& args, Elf32_Addr linker_base) {
     /* NOTE: we store the args pointer on a special location
      *       of the temporary TLS area in order to pass it to
      *       the C Library's runtime initializer.
@@ -1650,7 +1644,7 @@
       ldpreload_env = linker_env_get("LD_PRELOAD");
     }
 
-    INFO("[ android linker & debugger ]\n");
+    INFO("[ android linker & debugger ]");
 
     soinfo* si = soinfo_alloc(args.argv[0]);
     if (si == NULL) {
@@ -1659,7 +1653,7 @@
 
     /* bootstrap the link map, the main exe always needs to be first */
     si->flags |= FLAG_EXE;
-    link_map* map = &(si->linkmap);
+    link_map_t* map = &(si->link_map);
 
     map->l_addr = 0;
     map->l_name = args.argv[0];
@@ -1707,7 +1701,7 @@
     si->base = 0;
     si->size = phdr_table_get_load_size(si->phdr, si->phnum);
     si->load_bias = 0;
-    for (int i = 0; i < si->phnum; ++i) {
+    for (size_t i = 0; i < si->phnum; ++i) {
       if (si->phdr[i].p_type == PT_PHDR) {
         si->load_bias = reinterpret_cast<Elf32_Addr>(si->phdr) - si->phdr[i].p_vaddr;
         si->base = reinterpret_cast<Elf32_Addr>(si->phdr) - si->phdr[i].p_offset;
@@ -1715,7 +1709,7 @@
       }
     }
     si->dynamic = NULL;
-    si->refcount = 1;
+    si->ref_count = 1;
 
     // Use LD_LIBRARY_PATH and LD_PRELOAD (but only if we aren't setuid/setgid).
     parse_LD_LIBRARY_PATH(ldpath_env);
@@ -1744,13 +1738,13 @@
 
 #if TIMING
     gettimeofday(&t1,NULL);
-    PRINT("LINKER TIME: %s: %d microseconds\n", args.argv[0], (int) (
+    PRINT("LINKER TIME: %s: %d microseconds", args.argv[0], (int) (
                (((long long)t1.tv_sec * 1000000LL) + (long long)t1.tv_usec) -
                (((long long)t0.tv_sec * 1000000LL) + (long long)t0.tv_usec)
                ));
 #endif
 #if STATS
-    PRINT("RELO STATS: %s: %d abs, %d rel, %d copy, %d symbol\n", args.argv[0],
+    PRINT("RELO STATS: %s: %d abs, %d rel, %d copy, %d symbol", args.argv[0],
            linker_stats.count[kRelocAbsolute],
            linker_stats.count[kRelocRelative],
            linker_stats.count[kRelocCopy],
@@ -1772,7 +1766,7 @@
                 }
             }
         }
-        PRINT("PAGES MODIFIED: %s: %d (%dKB)\n", args.argv[0], count, count * 4);
+        PRINT("PAGES MODIFIED: %s: %d (%dKB)", args.argv[0], count, count * 4);
     }
 #endif
 
@@ -1780,7 +1774,7 @@
     fflush(stdout);
 #endif
 
-    TRACE("[ Ready to execute '%s' @ 0x%08x ]\n", si->name, si->entry);
+    TRACE("[ Ready to execute '%s' @ 0x%08x ]", si->name, si->entry);
     return si->entry;
 }
 
@@ -1794,20 +1788,17 @@
  *    load bias, i.e. add the value of any p_vaddr in the file to get
  *    the corresponding address in memory.
  */
-static Elf32_Addr
-get_elf_exec_load_bias(const Elf32_Ehdr* elf)
-{
-    Elf32_Addr        offset     = elf->e_phoff;
-    const Elf32_Phdr* phdr_table = (const Elf32_Phdr*)((char*)elf + offset);
-    const Elf32_Phdr* phdr_end   = phdr_table + elf->e_phnum;
-    const Elf32_Phdr* phdr;
+static Elf32_Addr get_elf_exec_load_bias(const Elf32_Ehdr* elf) {
+  Elf32_Addr        offset     = elf->e_phoff;
+  const Elf32_Phdr* phdr_table = (const Elf32_Phdr*)((char*)elf + offset);
+  const Elf32_Phdr* phdr_end   = phdr_table + elf->e_phnum;
 
-    for (phdr = phdr_table; phdr < phdr_end; phdr++) {
-        if (phdr->p_type == PT_LOAD) {
-            return (Elf32_Addr)elf + phdr->p_offset - phdr->p_vaddr;
-        }
+  for (const Elf32_Phdr* phdr = phdr_table; phdr < phdr_end; phdr++) {
+    if (phdr->p_type == PT_LOAD) {
+      return reinterpret_cast<Elf32_Addr>(elf) + phdr->p_offset - phdr->p_vaddr;
     }
-    return 0;
+  }
+  return 0;
 }
 
 /*
@@ -1819,10 +1810,10 @@
  * relocations, any attempt to reference an extern variable, extern
  * function, or other GOT reference will generate a segfault.
  */
-extern "C" unsigned __linker_init(void* raw_args) {
+extern "C" Elf32_Addr __linker_init(void* raw_args) {
   KernelArgumentBlock args(raw_args);
 
-  unsigned linker_addr = args.getauxval(AT_BASE);
+  Elf32_Addr linker_addr = args.getauxval(AT_BASE);
 
   Elf32_Ehdr *elf_hdr = (Elf32_Ehdr*) linker_addr;
   Elf32_Phdr *phdr = (Elf32_Phdr*)((unsigned char*) linker_addr + elf_hdr->e_phoff);
@@ -1850,7 +1841,7 @@
 
   // We have successfully fixed our own relocations. It's safe to run
   // the main part of the linker now.
-  unsigned start_address = __linker_init_post_relocation(args, linker_addr);
+  Elf32_Addr start_address = __linker_init_post_relocation(args, linker_addr);
 
   set_soinfo_pool_protection(PROT_READ);
 
diff --git a/linker/linker.h b/linker/linker.h
index cef6905..6196bec 100644
--- a/linker/linker.h
+++ b/linker/linker.h
@@ -36,7 +36,7 @@
 
 #include <link.h>
 
-#include <private/debug_format.h>
+#include "private/libc_logging.h"
 
 #define DL_ERR(fmt, x...) \
     do { \
@@ -57,12 +57,12 @@
 
 // Magic shared structures that GDB knows about.
 
-struct link_map {
+struct link_map_t {
   uintptr_t l_addr;
   char*  l_name;
   uintptr_t l_ld;
-  struct link_map* l_next;
-  struct link_map* l_prev;
+  link_map_t* l_next;
+  link_map_t* l_prev;
 };
 
 // Values for r_debug->state
@@ -74,7 +74,7 @@
 
 struct r_debug {
   int32_t r_version;
-  struct link_map* r_map;
+  link_map_t* r_map;
   void (*r_brk)(void);
   int32_t r_state;
   uintptr_t r_ldbase;
@@ -86,20 +86,23 @@
 
 #define SOINFO_NAME_LEN 128
 
+typedef void (*linker_function_t)();
+
 struct soinfo {
+ public:
   char name[SOINFO_NAME_LEN];
   const Elf32_Phdr* phdr;
-  int phnum;
-  unsigned entry;
-  unsigned base;
+  size_t phnum;
+  Elf32_Addr entry;
+  Elf32_Addr base;
   unsigned size;
 
-  int unused;  // DO NOT USE, maintained for compatibility.
+  uint32_t unused1;  // DO NOT USE, maintained for compatibility.
 
   Elf32_Dyn* dynamic;
 
-  unsigned unused2; // DO NOT USE, maintained for compatibility
-  unsigned unused3; // DO NOT USE, maintained for compatibility
+  uint32_t unused2; // DO NOT USE, maintained for compatibility
+  uint32_t unused3; // DO NOT USE, maintained for compatibility
 
   soinfo* next;
   unsigned flags;
@@ -107,42 +110,42 @@
   const char* strtab;
   Elf32_Sym* symtab;
 
-  unsigned nbucket;
-  unsigned nchain;
+  size_t nbucket;
+  size_t nchain;
   unsigned* bucket;
   unsigned* chain;
 
   unsigned* plt_got;
 
   Elf32_Rel* plt_rel;
-  unsigned plt_rel_count;
+  size_t plt_rel_count;
 
   Elf32_Rel* rel;
-  unsigned rel_count;
+  size_t rel_count;
 
-  unsigned* preinit_array;
-  unsigned preinit_array_count;
+  linker_function_t* preinit_array;
+  size_t preinit_array_count;
 
-  unsigned* init_array;
-  unsigned init_array_count;
-  unsigned* fini_array;
-  unsigned fini_array_count;
+  linker_function_t* init_array;
+  size_t init_array_count;
+  linker_function_t* fini_array;
+  size_t fini_array_count;
 
-  void (*init_func)();
-  void (*fini_func)();
+  linker_function_t init_func;
+  linker_function_t fini_func;
 
 #if defined(ANDROID_ARM_LINKER)
   // ARM EABI section used for stack unwinding.
   unsigned* ARM_exidx;
-  unsigned ARM_exidx_count;
+  size_t ARM_exidx_count;
 #elif defined(ANDROID_MIPS_LINKER)
   unsigned mips_symtabno;
   unsigned mips_local_gotno;
   unsigned mips_gotsym;
 #endif
 
-  unsigned refcount;
-  struct link_map linkmap;
+  size_t ref_count;
+  link_map_t link_map;
 
   bool constructors_called;
 
@@ -158,8 +161,8 @@
   void CallPreInitConstructors();
 
  private:
-  void CallArray(const char* array_name, unsigned* array, int count, bool reverse);
-  void CallFunction(const char* function_name, void (*function)());
+  void CallArray(const char* array_name, linker_function_t* functions, size_t count, bool reverse);
+  void CallFunction(const char* function_name, linker_function_t function);
 };
 
 extern soinfo libdl_info;
diff --git a/linker/linker_debug.h b/linker/linker_debug.h
index bf9ef92..7d24853 100644
--- a/linker/linker_debug.h
+++ b/linker/linker_debug.h
@@ -31,10 +31,16 @@
 
 #include <stdio.h>
 
-/* set LINKER_DEBUG_TO_LOG to 1 to send the logs to logcat,
- * or 0 to use stdout instead.
- */
+// You can increase the verbosity of debug traces by defining the LD_DEBUG
+// environment variable to a numeric value from 0 to 2 (corresponding to
+// INFO, TRACE, and DEBUG calls in the source). This will only
+// affect new processes being launched.
+
+// By default, traces are sent to logcat, with the "linker" tag. You can
+// change this to go to stdout instead by setting the definition of
+// LINKER_DEBUG_TO_LOG to 0.
 #define LINKER_DEBUG_TO_LOG  1
+
 #define TRACE_DEBUG          1
 #define DO_TRACE_LOOKUP      1
 #define DO_TRACE_RELO        1
@@ -52,19 +58,19 @@
 
 /*********************************************************************/
 
-#include <private/debug_format.h>
+#include "private/libc_logging.h"
 
 __LIBC_HIDDEN__ extern int gLdDebugVerbosity;
 
 #if LINKER_DEBUG_TO_LOG
-#define _PRINTVF(v,x...)                                        \
-    do {                                                          \
-        if (gLdDebugVerbosity > (v)) __libc_format_log(5-(v),"linker",x);  \
+#define _PRINTVF(v,x...) \
+    do { \
+      if (gLdDebugVerbosity > (v)) __libc_format_log(5-(v),"linker",x); \
     } while (0)
 #else /* !LINKER_DEBUG_TO_LOG */
-#define _PRINTVF(v,x...)                           \
-    do {                                             \
-        if (gLdDebugVerbosity > (v)) __libc_format_fd(1, x);  \
+#define _PRINTVF(v,x...) \
+    do { \
+      if (gLdDebugVerbosity > (v)) { __libc_format_fd(1, x); write(1, "\n", 1); } \
     } while (0)
 #endif /* !LINKER_DEBUG_TO_LOG */
 
diff --git a/tests/Android.mk b/tests/Android.mk
index 1e4ef59..491b13c 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -32,6 +32,7 @@
     benchmark_main.cpp \
     math_benchmark.cpp \
     string_benchmark.cpp \
+    time_benchmark.cpp \
 
 # Build benchmarks for the device (with bionic's .so). Run with:
 #   adb shell bionic-benchmarks
@@ -56,11 +57,11 @@
     -fno-builtin \
 
 test_src_files = \
-    debug_format_test.cpp \
     dirent_test.cpp \
     fenv_test.cpp \
     getauxval_test.cpp \
     getcwd_test.cpp \
+    libc_logging_test.cpp \
     libgen_test.cpp \
     math_test.cpp \
     netdb_test.cpp \
@@ -73,6 +74,7 @@
     string_test.cpp \
     strings_test.cpp \
     stubs_test.cpp \
+    time_test.cpp \
     unistd_test.cpp \
 
 test_dynamic_ldflags = -Wl,--export-dynamic -Wl,-u,DlSymTestFunction
diff --git a/tests/debug_format_test.cpp b/tests/libc_logging_test.cpp
similarity index 93%
rename from tests/debug_format_test.cpp
rename to tests/libc_logging_test.cpp
index 8419e4a..d9c615e 100644
--- a/tests/debug_format_test.cpp
+++ b/tests/libc_logging_test.cpp
@@ -18,11 +18,11 @@
 
 #if defined(__BIONIC__)
 
-#include "../libc/bionic/debug_format.cpp"
+#include "../libc/bionic/libc_logging.cpp"
 
 extern int __libc_format_buffer(char* buffer, size_t buffer_size, const char* format, ...);
 
-TEST(debug_format, smoke) {
+TEST(libc_logging, smoke) {
   char buf[BUFSIZ];
 
   __libc_format_buffer(buf, sizeof(buf), "a");
@@ -106,37 +106,37 @@
   EXPECT_STREQ("a68719476736,6,7,8z", buf);
 }
 
-TEST(debug_format, d_INT_MAX) {
+TEST(libc_logging, d_INT_MAX) {
   char buf[BUFSIZ];
   __libc_format_buffer(buf, sizeof(buf), "%d", INT_MAX);
   EXPECT_STREQ("2147483647", buf);
 }
 
-TEST(debug_format, d_INT_MIN) {
+TEST(libc_logging, d_INT_MIN) {
   char buf[BUFSIZ];
   __libc_format_buffer(buf, sizeof(buf), "%d", INT_MIN);
   EXPECT_STREQ("-2147483648", buf);
 }
 
-TEST(debug_format, ld_LONG_MAX) {
+TEST(libc_logging, ld_LONG_MAX) {
   char buf[BUFSIZ];
   __libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MAX);
   EXPECT_STREQ("2147483647", buf);
 }
 
-TEST(debug_format, ld_LONG_MIN) {
+TEST(libc_logging, ld_LONG_MIN) {
   char buf[BUFSIZ];
   __libc_format_buffer(buf, sizeof(buf), "%ld", LONG_MIN);
   EXPECT_STREQ("-2147483648", buf);
 }
 
-TEST(debug_format, lld_LLONG_MAX) {
+TEST(libc_logging, lld_LLONG_MAX) {
   char buf[BUFSIZ];
   __libc_format_buffer(buf, sizeof(buf), "%lld", LLONG_MAX);
   EXPECT_STREQ("9223372036854775807", buf);
 }
 
-TEST(debug_format, lld_LLONG_MIN) {
+TEST(libc_logging, lld_LLONG_MIN) {
   char buf[BUFSIZ];
   __libc_format_buffer(buf, sizeof(buf), "%lld", LLONG_MIN);
   EXPECT_STREQ("-9223372036854775808", buf);
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp
index 98bc4e5..a86cadc 100644
--- a/tests/pthread_test.cpp
+++ b/tests/pthread_test.cpp
@@ -239,7 +239,7 @@
   MakeDeadThread(dead_thread);
 
   // Call pthread_setname_np after thread has already exited.
-  ASSERT_EQ(ENOENT, pthread_setname_np(dead_thread, "short 3"));
+  ASSERT_EQ(ESRCH, pthread_setname_np(dead_thread, "short 3"));
 }
 #endif
 
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 196c725..4b5a1f9 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -171,17 +171,25 @@
 }
 
 TEST(stdio, printf_ssize_t) {
-#if __BIONIC__
   // http://b/8253769
-  ASSERT_EQ(sizeof(__kernel_ssize_t), sizeof(long int));
   ASSERT_EQ(sizeof(ssize_t), sizeof(long int));
-#else
-  // TODO: add a .c file so we can test this for bionic --- our C ssize_t is fine.
-  // For our 32-bit C++ ABI, we have a ssize_t definition that confuses GCC into saying:
+  ASSERT_EQ(sizeof(ssize_t), sizeof(size_t));
+  // For our 32-bit ABI, we had a ssize_t definition that confuses GCC into saying:
   // error: format '%zd' expects argument of type 'signed size_t',
   //     but argument 4 has type 'ssize_t {aka long int}' [-Werror=format]
   ssize_t v = 1;
   char buf[32];
   snprintf(buf, sizeof(buf), "%zd", v);
-#endif
+}
+
+TEST(stdio, popen) {
+  FILE* fp = popen("cat /proc/version", "r");
+  ASSERT_TRUE(fp != NULL);
+
+  char buf[16];
+  char* s = fgets(buf, sizeof(buf), fp);
+  buf[13] = '\0';
+  ASSERT_STREQ("Linux version", s);
+
+  ASSERT_EQ(0, pclose(fp));
 }
diff --git a/tests/time_benchmark.cpp b/tests/time_benchmark.cpp
new file mode 100644
index 0000000..75132e5
--- /dev/null
+++ b/tests/time_benchmark.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "benchmark.h"
+
+#include <time.h>
+
+#if defined(__BIONIC__)
+
+// Used by the horrible android.text.format.Time class, which is used by Calendar. http://b/8270865.
+extern "C" void localtime_tz(const time_t* const timep, struct tm* tmp, const char* tz);
+
+static void BM_time_localtime_tz(int iters) {
+  StartBenchmarkTiming();
+
+  time_t now(time(NULL));
+  tm broken_down_time;
+  for (int i = 0; i < iters; ++i) {
+    localtime_tz(&now, &broken_down_time, "Europe/Berlin");
+  }
+
+  StopBenchmarkTiming();
+}
+BENCHMARK(BM_time_localtime_tz);
+#endif
diff --git a/tests/time_test.cpp b/tests/time_test.cpp
new file mode 100644
index 0000000..9a5a706
--- /dev/null
+++ b/tests/time_test.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <sys/cdefs.h>
+#include <features.h>
+#include <gtest/gtest.h>
+
+#include <time.h>
+
+#ifdef __BIONIC__ // mktime_tz is a bionic extension.
+#include <libc/private/bionic_time.h>
+TEST(time, mktime_tz) {
+  struct tm epoch;
+  memset(&epoch, 0, sizeof(tm));
+  epoch.tm_year = 1970 - 1900;
+  epoch.tm_mon = 1;
+  epoch.tm_mday = 1;
+
+  // Alphabetically first. Coincidentally equivalent to UTC.
+  ASSERT_EQ(2678400, mktime_tz(&epoch, "Africa/Abidjan"));
+
+  // Alphabetically last. Coincidentally equivalent to UTC.
+  ASSERT_EQ(2678400, mktime_tz(&epoch, "Zulu"));
+
+  // Somewhere in the middle, not UTC.
+  ASSERT_EQ(2707200, mktime_tz(&epoch, "America/Los_Angeles"));
+
+  // Missing. Falls back to UTC.
+  ASSERT_EQ(2678400, mktime_tz(&epoch, "PST"));
+}
+#endif