am b299039d: am e6e2ba1d: Merge "libc: <pthread.h>: Replace \'#if __cplusplus\' by \'#ifdef __cplusplus\'"

* commit 'b299039d060eb5f523c05e4f9b6934a6b897a54f':
  libc: <pthread.h>: Replace '#if __cplusplus' by '#ifdef __cplusplus'
diff --git a/libc/Android.mk b/libc/Android.mk
index d940753..647739e 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -269,6 +269,7 @@
 	bionic/libc_init_common.c \
 	bionic/logd_write.c \
 	bionic/md5.c \
+	bionic/memmove_words.c \
 	bionic/pututline.c \
 	bionic/realpath.c \
 	bionic/sched_getaffinity.c \
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index 5653c3c..bd3e4d4 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -219,7 +219,7 @@
 int           recvmsg:socketcall:17(int, struct msghdr *, unsigned int)   -1,102,-1
 
 # sockets for sh.
-int           __socketcall:__socketcall(int, unsigned long*) -1,-1,102
+int           __socketcall:socketcall(int, unsigned long*) -1,-1,102
 
 # scheduler & real-time
 int sched_setscheduler(pid_t pid, int policy, const struct sched_param *param)  156
diff --git a/libc/arch-arm/bionic/_exit_with_stack_teardown.S b/libc/arch-arm/bionic/_exit_with_stack_teardown.S
index 89f6c90..c2d7758 100644
--- a/libc/arch-arm/bionic/_exit_with_stack_teardown.S
+++ b/libc/arch-arm/bionic/_exit_with_stack_teardown.S
@@ -26,15 +26,10 @@
  * SUCH DAMAGE.
  */
 #include <asm/unistd.h>
-
-.text
-.type _exit_with_stack_teardown, #function
-.globl _exit_with_stack_teardown
-.align 4
+#include <machine/asm.h>
 
 @ void _exit_with_stack_teardown(void * stackBase, int stackSize, int retCode)
-
-_exit_with_stack_teardown:
+ENTRY(_exit_with_stack_teardown)
 
 #if __ARM_EABI__
     mov     lr, r2
@@ -53,3 +48,4 @@
     @ exit() should never return, cause a crash if it does
     mov		r0, #0
     ldr		r0, [r0]
+END(_exit_with_stack_teardown)
diff --git a/libc/arch-arm/bionic/_setjmp.S b/libc/arch-arm/bionic/_setjmp.S
index 5626219..6b8aa50 100644
--- a/libc/arch-arm/bionic/_setjmp.S
+++ b/libc/arch-arm/bionic/_setjmp.S
@@ -70,6 +70,7 @@
 
         mov	r0, #0x00000000
         bx      lr
+END(_setjmp)
 
 .L_setjmp_magic:
 	.word	_JB_MAGIC__SETJMP
@@ -109,3 +110,4 @@
 	bl	PIC_SYM(_C_LABEL(longjmperror), PLT)
 	bl	PIC_SYM(_C_LABEL(abort), PLT)
 	b	. - 8		/* Cannot get here */
+END(_longjmp)
diff --git a/libc/arch-arm/bionic/atomics_arm.S b/libc/arch-arm/bionic/atomics_arm.S
index d94f6b1..4d9cbcf 100644
--- a/libc/arch-arm/bionic/atomics_arm.S
+++ b/libc/arch-arm/bionic/atomics_arm.S
@@ -26,17 +26,9 @@
  * SUCH DAMAGE.
  */
 #include <sys/linux-syscalls.h>
+#include <machine/asm.h>
 #include <machine/cpu-features.h>
 
-.global __atomic_cmpxchg
-.type __atomic_cmpxchg, %function
-.global __atomic_swap
-.type __atomic_swap, %function
-.global __atomic_dec
-.type __atomic_dec, %function
-.global __atomic_inc
-.type __atomic_inc, %function
-
 #define FUTEX_WAIT 0
 #define FUTEX_WAKE 1
 
@@ -48,8 +40,7 @@
  */
 
 /* r0(addr) -> r0(old) */
-__atomic_dec:
-    .fnstart
+ENTRY(__atomic_dec)
     mov     r1, r0                      @ copy addr so we don't clobber it
 1:  ldrex   r0, [r1]                    @ load current value into r0
     sub     r2, r0, #1                  @ generate new value into r2
@@ -57,11 +48,10 @@
     cmp     r3, #0                      @ success?
     bxeq    lr                          @ yes, return
     b       1b                          @ no, retry
-    .fnend
+END(__atomic_dec)
 
 /* r0(addr) -> r0(old) */
-__atomic_inc:
-    .fnstart
+ENTRY(__atomic_inc)
     mov     r1, r0
 1:  ldrex   r0, [r1]
     add     r2, r0, #1
@@ -69,11 +59,10 @@
     cmp     r3, #0
     bxeq    lr
     b       1b
-    .fnend
+END(__atomic_inc)
 
 /* r0(old) r1(new) r2(addr) -> r0(zero_if_succeeded) */
-__atomic_cmpxchg:
-    .fnstart
+ENTRY(__atomic_cmpxchg)
 1:  mov     ip, #2                      @ ip=2 means "new != old"
     ldrex   r3, [r2]                    @ load current value into r3
     teq     r0, r3                      @ new == old?
@@ -82,18 +71,17 @@
     beq     1b                          @ yes, retry
     mov     r0, ip                      @ return 0 on success, 2 on failure
     bx      lr
-    .fnend
+END(__atomic_cmpxchg)
 
 /* r0(new) r1(addr) -> r0(old) */
-__atomic_swap:
-    .fnstart
+ENTRY(__atomic_swap)
 1:  ldrex   r2, [r1]
     strex   r3, r0, [r1]
     teq     r3, #0
     bne     1b
     mov     r0, r2
     bx      lr
-    .fnend
+END(__atomic_swap)
 
 #else /*not defined __ARM_HAVE_LDREX_STREX*/
 /*
@@ -107,8 +95,7 @@
     .equ    kernel_atomic_base, 0xFFFF0FFF
 
 /* r0(addr) -> r0(old) */
-__atomic_dec:
-    .fnstart
+ENTRY(__atomic_dec)
     .save {r4, lr}
     stmdb   sp!, {r4, lr}
     mov     r2, r0
@@ -122,11 +109,10 @@
     add     r0, r1, #1
     ldmia   sp!, {r4, lr}
     bx      lr
-    .fnend
+END(__atomic_dec)
 
 /* r0(addr) -> r0(old) */
-__atomic_inc:
-    .fnstart
+ENTRY(__atomic_inc)
     .save {r4, lr}
     stmdb   sp!, {r4, lr}
     mov     r2, r0
@@ -140,11 +126,10 @@
     sub     r0, r1, #1
     ldmia   sp!, {r4, lr}
     bx      lr
-    .fnend
+END(__atomic_inc)
 
 /* r0(old) r1(new) r2(addr) -> r0(zero_if_succeeded) */
-__atomic_cmpxchg:
-    .fnstart
+ENTRY(__atomic_cmpxchg)
     .save {r4, lr}
     stmdb   sp!, {r4, lr}
     mov     r4, r0          /* r4 = save oldvalue */
@@ -160,14 +145,13 @@
 2: @ atomic_cmpxchg
     ldmia   sp!, {r4, lr}
     bx      lr
-    .fnend
+END(__atomic_cmpxchg)
 
 /* r0(new) r1(addr) -> r0(old) */
-__atomic_swap:
-    .fnstart
+ENTRY(__atomic_swap)
     swp     r0, r0, [r1]
     bx      lr
-    .fnend
+END(__atomic_swap)
 
 #endif /*not defined __ARM_HAVE_LDREX_STREX*/
 
@@ -191,18 +175,16 @@
 
 #if __ARM_EABI__
 
-__futex_syscall3:
-    .fnstart
+ENTRY(__futex_syscall3)
     stmdb   sp!, {r4, r7}
     .save   {r4, r7}
     ldr     r7, =__NR_futex
     swi     #0
     ldmia   sp!, {r4, r7}
     bx      lr
-    .fnend
+END(__futex_syscall3)
 
-__futex_wait:
-    .fnstart
+ENTRY(__futex_wait)
     stmdb   sp!, {r4, r7}
     .save   {r4, r7}
     mov     r3, r2
@@ -212,10 +194,9 @@
     swi     #0
     ldmia   sp!, {r4, r7}
     bx      lr
-    .fnend
+END(__futex_wait)
 
-__futex_wake:
-    .fnstart
+ENTRY(__futex_wake)
     .save   {r4, r7}
     stmdb   sp!, {r4, r7}
     mov     r2, r1
@@ -224,28 +205,32 @@
     swi     #0
     ldmia   sp!, {r4, r7}
     bx      lr
-    .fnend
+END(__futex_wake)
 
 #else
 
-__futex_syscall3:
+ENTRY(__futex_syscall3)
     swi     #__NR_futex
     bx      lr
+END(__futex_syscall3)
 
-__futex_wait:
+ENTRY(__futex_wait)
     mov     r3, r2
     mov     r2, r1
     mov     r1, #FUTEX_WAIT
     swi     #__NR_futex
     bx      lr
+END(__futex_wait)
 
-__futex_wake:
+ENTRY(__futex_wake)
     mov     r2, r1
     mov     r1, #FUTEX_WAKE
     swi     #__NR_futex
     bx      lr
+END(__futex_wake)
 
 #endif
 
-__futex_syscall4:
+ENTRY(__futex_syscall4)
     b __futex_syscall3
+END(__futex_syscall4)
diff --git a/libc/arch-arm/bionic/clone.S b/libc/arch-arm/bionic/clone.S
index 9c25053..a95d2d6 100644
--- a/libc/arch-arm/bionic/clone.S
+++ b/libc/arch-arm/bionic/clone.S
@@ -26,14 +26,9 @@
  * SUCH DAMAGE.
  */
 #include <sys/linux-syscalls.h>
+#include <machine/asm.h>
 
-    .text
-    .type __pthread_clone, #function
-    .global __pthread_clone
-    .align 4
-    .fnstart
-
-__pthread_clone:
+ENTRY(__pthread_clone)
     @ insert the args onto the new stack
     str     r0, [r1, #-4]
     str     r3, [r1, #-8]
@@ -73,7 +68,7 @@
 __error:
     mov     r0, #-1
     bx      lr
-    .fnend
+END(__pthread_clone)
 
 
     #
@@ -88,12 +83,8 @@
     #       at the end of the parameter list makes the
     #       implementation much simpler.
     #
-    .type __bionic_clone, #function
-    .globl __bionic_clone
-    .align 4
-    .fnstart
 
-__bionic_clone:
+ENTRY(__bionic_clone)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
 
@@ -124,5 +115,4 @@
     ldr    r0, [sp, #-4]
     ldr    r1, [sp, #-8]
     b      __bionic_clone_entry
-
-    .fnend
+END(__bionic_clone)
diff --git a/libc/arch-arm/bionic/ffs.S b/libc/arch-arm/bionic/ffs.S
index f11141c..c59091f 100644
--- a/libc/arch-arm/bionic/ffs.S
+++ b/libc/arch-arm/bionic/ffs.S
@@ -29,6 +29,7 @@
  */
 
 #include <machine/asm.h>
+#include <machine/cpu-features.h>
 
 /*
  * ffs - find first set bit, this algorithm isolates the first set
@@ -36,8 +37,8 @@
  * 6 bits as an index into the table.  This algorithm should be a win
  * over the checking each bit in turn as per the C compiled version.
  *
- * under ARMv5 there's an instruction called CLZ (count leading Zero's) that
- * could be used
+ * Some newer ARM architectures have an instruction named
+ * CLZ (count leading Zero's) that is used
  *
  * This is the ffs algorithm devised by d.seal and posted to comp.sys.arm on
  * 16 Feb 1994.
@@ -47,7 +48,7 @@
 	/* Standard trick to isolate bottom bit in r0 or 0 if r0 = 0 on entry */
  	rsb     r1, r0, #0
  	ands    r0, r0, r1
-#ifndef __ARM_ARCH_5__
+#ifndef __ARM_HAVE_CLZ
 	/*
 	 * now r0 has at most one set bit, call this X
 	 * if X = 0, all further instructions are skipped
@@ -61,6 +62,7 @@
 	ldrneb  r0, [ r2, r0, lsr #26 ]
 
 	bx		lr
+END(ffs)
 
 .text;
 .type .L_ffs_table, _ASM_TYPE_OBJECT;
@@ -74,9 +76,10 @@
 	.byte	10,  0,  0, 25,  0,  0, 21, 27  /* 40-47 */
 	.byte	31,  0,  0,  0,  0, 24,  0, 20  /* 48-55 */
 	.byte   30,  0, 23, 19, 29, 18, 17,  0  /* 56-63 */
-#else
+#else /* !defined(__ARM_HAVE_CLZ) */
 	clzne	r0, r0
 	rsbne	r0, r0, #32
 	bx		lr
-#endif
+END(ffs)
+#endif /* !defined(__ARM_HAVE_CLZ) */
 
diff --git a/libc/arch-arm/bionic/kill.S b/libc/arch-arm/bionic/kill.S
index 2954091..33dfc2b 100644
--- a/libc/arch-arm/bionic/kill.S
+++ b/libc/arch-arm/bionic/kill.S
@@ -33,17 +33,13 @@
    of a corrupted malloc heap).
 */
 #include <sys/linux-syscalls.h>
+#include <machine/asm.h>
 
 #ifndef __NR_kill
 #define __NR_kill   37
 #endif
 
-    .text
-    .type kill, #function
-    .globl kill
-    .align 4
-
-kill:
+ENTRY(kill)
     stmfd   sp!, {r4-r7, ip, lr}
     ldr     r7, =__NR_kill
     swi     #0
@@ -51,3 +47,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
+END(kill)
diff --git a/libc/arch-arm/bionic/memcmp.S b/libc/arch-arm/bionic/memcmp.S
index 67dcddc..c872a51 100644
--- a/libc/arch-arm/bionic/memcmp.S
+++ b/libc/arch-arm/bionic/memcmp.S
@@ -27,12 +27,7 @@
  */
 
 #include <machine/cpu-features.h>
-
-    .text
-
-    .global memcmp
-    .type memcmp, %function
-    .align 4
+#include <machine/asm.h>
 
 /*
  * Optimized memcmp() for ARM9.
@@ -43,8 +38,7 @@
  * (2) The loads are scheduled in a way they won't stall
  */
 
-memcmp:
-        .fnstart
+ENTRY(memcmp)
         PLD         (r0, #0)
         PLD         (r1, #0)
 
@@ -176,7 +170,7 @@
 9:      /* restore registers and return */
         ldmfd       sp!, {r4, lr}
         bx          lr
-        .fnend
+END(memcmp)
 
 
 
diff --git a/libc/arch-arm/bionic/memcmp16.S b/libc/arch-arm/bionic/memcmp16.S
index f398588..99c9b88 100644
--- a/libc/arch-arm/bionic/memcmp16.S
+++ b/libc/arch-arm/bionic/memcmp16.S
@@ -27,12 +27,7 @@
  */
 
 #include <machine/cpu-features.h>
-
-    .text
-
-    .global __memcmp16
-    .type __memcmp16, %function
-    .align 4
+#include <machine/asm.h>
 
 /*
  * Optimized memcmp16() for ARM9.
@@ -43,8 +38,7 @@
  * (2) The loads are scheduled in a way they won't stall
  */
 
-__memcmp16:
-        .fnstart
+ENTRY(__memcmp16)
         PLD         (r0, #0)
         PLD         (r1, #0)
 
@@ -95,8 +89,6 @@
         /* restore registers and return */
         ldmnefd     sp!, {r4, lr}
         bxne        lr
-        .fnend
-
 
 
 0:      /* here the first pointer is aligned, and we have at least 3 words
@@ -237,3 +229,4 @@
 7:      /* fix up the 2 pointers and fallthrough... */
         sub         r1, r1, #2
         b           2b
+END(__memcmp16)
diff --git a/libc/arch-arm/bionic/memcpy.S b/libc/arch-arm/bionic/memcpy.S
index ba55996..04ba848 100644
--- a/libc/arch-arm/bionic/memcpy.S
+++ b/libc/arch-arm/bionic/memcpy.S
@@ -27,6 +27,7 @@
  */
 
 #include <machine/cpu-features.h>
+#include <machine/asm.h>
 
 #if defined(__ARM_NEON__)
 
@@ -143,18 +144,12 @@
 
         ldmfd       sp!, {r0, lr}
         bx          lr
-        .fnend
+END(memcpy)
 
 
 #else   /* __ARM_ARCH__ < 7 */
 
 
-	.text
-
-    .global memcpy
-    .type memcpy, %function
-    .align 4
-
 		/*
 		 * Optimized memcpy() for ARM.
          *
@@ -162,12 +157,11 @@
 		 * so we have to preserve R0.
 		 */
 
-memcpy:
+ENTRY(memcpy)
 		/* The stack must always be 64-bits aligned to be compliant with the
 		 * ARM ABI. Since we have to save R0, we might as well save R4
 		 * which we can use for better pipelining of the reads below
 		 */
-        .fnstart
         .save       {r0, r4, lr}
         stmfd       sp!, {r0, r4, lr}
         /* Making room for r5-r11 which will be spilled later */
@@ -504,7 +498,7 @@
         add         sp,  sp, #28
 		ldmfd		sp!, {r0, r4, lr}
 		bx			lr
-        .fnend
+END(memcpy)
 
 
 #endif    /* __ARM_ARCH__ < 7 */
diff --git a/libc/arch-arm/bionic/memset.S b/libc/arch-arm/bionic/memset.S
index 93abe15..273b9e3 100644
--- a/libc/arch-arm/bionic/memset.S
+++ b/libc/arch-arm/bionic/memset.S
@@ -25,15 +25,8 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-	.text
 
-    .global memset
-    .type memset, %function
-
-    .global bzero
-    .type bzero, %function
-
-    .align
+#include <machine/asm.h>
 	
 		/*
 		 * Optimized memset() for ARM.
@@ -41,15 +34,15 @@
          * memset() returns its first argument.
 		 */
 	
-bzero:
+ENTRY(bzero)
         mov     r2, r1
         mov     r1, #0
+END(bzero)
 
-memset:	
+ENTRY(memset)
 		/* compute the offset to align the destination
 		 * offset = (4-(src&3))&3 = -src & 3
 		 */
-        .fnstart
         .save       {r0, r4-r7, lr}
 		stmfd		sp!, {r0, r4-r7, lr}
 		rsb			r3, r0, #0
@@ -113,5 +106,4 @@
 		strcsb		r1, [r0]
         ldmfd		sp!, {r0, r4-r7, lr}
         bx          lr
-        .fnend
-    
+END(memset)
diff --git a/libc/arch-arm/bionic/setjmp.S b/libc/arch-arm/bionic/setjmp.S
index 59aff66..996e55e 100644
--- a/libc/arch-arm/bionic/setjmp.S
+++ b/libc/arch-arm/bionic/setjmp.S
@@ -79,6 +79,7 @@
 
 	mov	r0, #0x00000000
 	bx      lr
+END(setjmp)
 
 .Lsetjmp_magic:
 	.word	_JB_MAGIC_SETJMP
@@ -138,3 +139,4 @@
 	bl	PIC_SYM(_C_LABEL(longjmperror), PLT)
 	bl	PIC_SYM(_C_LABEL(abort), PLT)
 	b	. - 8		/* Cannot get here */
+END(longjmp)
diff --git a/libc/arch-arm/bionic/sigsetjmp.S b/libc/arch-arm/bionic/sigsetjmp.S
index 50e6429..12311e5 100644
--- a/libc/arch-arm/bionic/sigsetjmp.S
+++ b/libc/arch-arm/bionic/sigsetjmp.S
@@ -33,6 +33,8 @@
  * SUCH DAMAGE.
  */
 
+#define _ALIGN_TEXT .align 0
+
 #include <machine/asm.h>
 #include <machine/setjmp.h>
 
@@ -50,6 +52,7 @@
 	teq	r1, #0
 	beq	PIC_SYM(_C_LABEL(_setjmp), PLT)
 	b	PIC_SYM(_C_LABEL(setjmp), PLT)
+END(sigsetjmp)
 
 .L_setjmp_magic:
 	.word	_JB_MAGIC__SETJMP
@@ -60,3 +63,4 @@
 	teq	r2, r3
 	beq	PIC_SYM(_C_LABEL(_longjmp), PLT)
 	b	PIC_SYM(_C_LABEL(longjmp), PLT)
+END(siglongjmp)
diff --git a/libc/arch-arm/bionic/strcpy.S b/libc/arch-arm/bionic/strcpy.S
index 70c353f..21dafda 100644
--- a/libc/arch-arm/bionic/strcpy.S
+++ b/libc/arch-arm/bionic/strcpy.S
@@ -30,15 +30,9 @@
  */
 
 #include <machine/cpu-features.h>
+#include <machine/asm.h>
 
-	.text
-
-	.global strcpy
-	.type strcpy, %function
-	.align 4
-
-strcpy:
-	.fnstart
+ENTRY(strcpy)
 	PLD(r1, #0)
 	eor	r2, r0, r1
 	mov	ip, r0
@@ -136,3 +130,4 @@
 	cmp	r2, #0
 	bne	4b
 	bx	lr
+END(strcpy)
diff --git a/libc/arch-arm/bionic/tkill.S b/libc/arch-arm/bionic/tkill.S
index 7b3301a..fdc5ed4 100644
--- a/libc/arch-arm/bionic/tkill.S
+++ b/libc/arch-arm/bionic/tkill.S
@@ -32,18 +32,15 @@
    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_tkill
 #define __NR_tkill  238
 #endif
 
-    .text
-    .type tkill, #function
-    .globl tkill
-    .align 4
-
-tkill:
+ENTRY(tkill)
     stmfd   sp!, {r4-r7, ip, lr}
     ldr     r7, =__NR_tkill
     swi     #0
@@ -51,3 +48,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
+END(tkill)
diff --git a/libc/arch-arm/include/machine/asm.h b/libc/arch-arm/include/machine/asm.h
index c7bd017..7b8f053 100644
--- a/libc/arch-arm/include/machine/asm.h
+++ b/libc/arch-arm/include/machine/asm.h
@@ -70,7 +70,13 @@
 #define _ASM_TYPE_FUNCTION	#function
 #define _ASM_TYPE_OBJECT	#object
 #define _ENTRY(x) \
-	.text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x:
+	.text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x: .fnstart
+
+#define _ASM_SIZE(x)	.size x, .-x;
+
+#define _END(x) \
+	.fnend; \
+	_ASM_SIZE(x)
 
 #ifdef GPROF
 # ifdef __ELF__
@@ -86,8 +92,10 @@
 
 #define	ENTRY(y)	_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
 #define	ENTRY_NP(y)	_ENTRY(_C_LABEL(y))
+#define	END(y)		_END(_C_LABEL(y))
 #define	ASENTRY(y)	_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
 #define	ASENTRY_NP(y)	_ENTRY(_ASM_LABEL(y))
+#define	ASEND(y)	_END(_ASM_LABEL(y))
 
 #define	ASMSTR		.asciz
 
diff --git a/libc/arch-arm/syscalls/__brk.S b/libc/arch-arm/syscalls/__brk.S
index 99ad2e3..a0854a0 100644
--- a/libc/arch-arm/syscalls/__brk.S
+++ b/libc/arch-arm/syscalls/__brk.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __brk, #function
-    .globl __brk
-    .align 4
-    .fnstart
-
-__brk:
+ENTRY(__brk)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_brk
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__brk)
diff --git a/libc/arch-arm/syscalls/__fcntl.S b/libc/arch-arm/syscalls/__fcntl.S
index 1b7b92f..067ee9a 100644
--- a/libc/arch-arm/syscalls/__fcntl.S
+++ b/libc/arch-arm/syscalls/__fcntl.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __fcntl, #function
-    .globl __fcntl
-    .align 4
-    .fnstart
-
-__fcntl:
+ENTRY(__fcntl)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_fcntl
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__fcntl)
diff --git a/libc/arch-arm/syscalls/__fcntl64.S b/libc/arch-arm/syscalls/__fcntl64.S
index d1a6fc8..3d39567 100644
--- a/libc/arch-arm/syscalls/__fcntl64.S
+++ b/libc/arch-arm/syscalls/__fcntl64.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __fcntl64, #function
-    .globl __fcntl64
-    .align 4
-    .fnstart
-
-__fcntl64:
+ENTRY(__fcntl64)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_fcntl64
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__fcntl64)
diff --git a/libc/arch-arm/syscalls/__fork.S b/libc/arch-arm/syscalls/__fork.S
index fddd276..6cf08ad 100644
--- a/libc/arch-arm/syscalls/__fork.S
+++ b/libc/arch-arm/syscalls/__fork.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __fork, #function
-    .globl __fork
-    .align 4
-    .fnstart
-
-__fork:
+ENTRY(__fork)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_fork
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__fork)
diff --git a/libc/arch-arm/syscalls/__fstatfs64.S b/libc/arch-arm/syscalls/__fstatfs64.S
index 00b4e41..e8aa2f4 100644
--- a/libc/arch-arm/syscalls/__fstatfs64.S
+++ b/libc/arch-arm/syscalls/__fstatfs64.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __fstatfs64, #function
-    .globl __fstatfs64
-    .align 4
-    .fnstart
-
-__fstatfs64:
+ENTRY(__fstatfs64)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_fstatfs64
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__fstatfs64)
diff --git a/libc/arch-arm/syscalls/__getcpu.S b/libc/arch-arm/syscalls/__getcpu.S
index ed6927a..78271eb 100644
--- a/libc/arch-arm/syscalls/__getcpu.S
+++ b/libc/arch-arm/syscalls/__getcpu.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __getcpu, #function
-    .globl __getcpu
-    .align 4
-    .fnstart
-
-__getcpu:
+ENTRY(__getcpu)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getcpu
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__getcpu)
diff --git a/libc/arch-arm/syscalls/__getcwd.S b/libc/arch-arm/syscalls/__getcwd.S
index 6098d09..e09a484 100644
--- a/libc/arch-arm/syscalls/__getcwd.S
+++ b/libc/arch-arm/syscalls/__getcwd.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __getcwd, #function
-    .globl __getcwd
-    .align 4
-    .fnstart
-
-__getcwd:
+ENTRY(__getcwd)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getcwd
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__getcwd)
diff --git a/libc/arch-arm/syscalls/__getpriority.S b/libc/arch-arm/syscalls/__getpriority.S
index 2b652ef..30e335c 100644
--- a/libc/arch-arm/syscalls/__getpriority.S
+++ b/libc/arch-arm/syscalls/__getpriority.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __getpriority, #function
-    .globl __getpriority
-    .align 4
-    .fnstart
-
-__getpriority:
+ENTRY(__getpriority)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getpriority
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__getpriority)
diff --git a/libc/arch-arm/syscalls/__ioctl.S b/libc/arch-arm/syscalls/__ioctl.S
index 2fad231..554809f 100644
--- a/libc/arch-arm/syscalls/__ioctl.S
+++ b/libc/arch-arm/syscalls/__ioctl.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __ioctl, #function
-    .globl __ioctl
-    .align 4
-    .fnstart
-
-__ioctl:
+ENTRY(__ioctl)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_ioctl
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__ioctl)
diff --git a/libc/arch-arm/syscalls/__llseek.S b/libc/arch-arm/syscalls/__llseek.S
index 8325e2d..9893886 100644
--- a/libc/arch-arm/syscalls/__llseek.S
+++ b/libc/arch-arm/syscalls/__llseek.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __llseek, #function
-    .globl __llseek
-    .align 4
-    .fnstart
-
-__llseek:
+ENTRY(__llseek)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
     stmfd   sp!, {r4, r5, r6, r7}
@@ -18,4 +13,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__llseek)
diff --git a/libc/arch-arm/syscalls/__mmap2.S b/libc/arch-arm/syscalls/__mmap2.S
index d57020a..542b3e0 100644
--- a/libc/arch-arm/syscalls/__mmap2.S
+++ b/libc/arch-arm/syscalls/__mmap2.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __mmap2, #function
-    .globl __mmap2
-    .align 4
-    .fnstart
-
-__mmap2:
+ENTRY(__mmap2)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
     stmfd   sp!, {r4, r5, r6, r7}
@@ -18,4 +13,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__mmap2)
diff --git a/libc/arch-arm/syscalls/__open.S b/libc/arch-arm/syscalls/__open.S
index 7e3fb7a..be2f4bf 100644
--- a/libc/arch-arm/syscalls/__open.S
+++ b/libc/arch-arm/syscalls/__open.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __open, #function
-    .globl __open
-    .align 4
-    .fnstart
-
-__open:
+ENTRY(__open)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_open
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__open)
diff --git a/libc/arch-arm/syscalls/__openat.S b/libc/arch-arm/syscalls/__openat.S
index ae92b9d..4d91780 100644
--- a/libc/arch-arm/syscalls/__openat.S
+++ b/libc/arch-arm/syscalls/__openat.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __openat, #function
-    .globl __openat
-    .align 4
-    .fnstart
-
-__openat:
+ENTRY(__openat)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_openat
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__openat)
diff --git a/libc/arch-arm/syscalls/__ptrace.S b/libc/arch-arm/syscalls/__ptrace.S
index 329a5af..04e0a30 100644
--- a/libc/arch-arm/syscalls/__ptrace.S
+++ b/libc/arch-arm/syscalls/__ptrace.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __ptrace, #function
-    .globl __ptrace
-    .align 4
-    .fnstart
-
-__ptrace:
+ENTRY(__ptrace)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_ptrace
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__ptrace)
diff --git a/libc/arch-arm/syscalls/__reboot.S b/libc/arch-arm/syscalls/__reboot.S
index 770e9f8..e75df45 100644
--- a/libc/arch-arm/syscalls/__reboot.S
+++ b/libc/arch-arm/syscalls/__reboot.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __reboot, #function
-    .globl __reboot
-    .align 4
-    .fnstart
-
-__reboot:
+ENTRY(__reboot)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_reboot
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__reboot)
diff --git a/libc/arch-arm/syscalls/__rt_sigaction.S b/libc/arch-arm/syscalls/__rt_sigaction.S
index 29abd55..57a3149 100644
--- a/libc/arch-arm/syscalls/__rt_sigaction.S
+++ b/libc/arch-arm/syscalls/__rt_sigaction.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __rt_sigaction, #function
-    .globl __rt_sigaction
-    .align 4
-    .fnstart
-
-__rt_sigaction:
+ENTRY(__rt_sigaction)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_rt_sigaction
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__rt_sigaction)
diff --git a/libc/arch-arm/syscalls/__rt_sigprocmask.S b/libc/arch-arm/syscalls/__rt_sigprocmask.S
index c3acb54..8220825 100644
--- a/libc/arch-arm/syscalls/__rt_sigprocmask.S
+++ b/libc/arch-arm/syscalls/__rt_sigprocmask.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __rt_sigprocmask, #function
-    .globl __rt_sigprocmask
-    .align 4
-    .fnstart
-
-__rt_sigprocmask:
+ENTRY(__rt_sigprocmask)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_rt_sigprocmask
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__rt_sigprocmask)
diff --git a/libc/arch-arm/syscalls/__rt_sigtimedwait.S b/libc/arch-arm/syscalls/__rt_sigtimedwait.S
index 0fb1573..bce63ed 100644
--- a/libc/arch-arm/syscalls/__rt_sigtimedwait.S
+++ b/libc/arch-arm/syscalls/__rt_sigtimedwait.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __rt_sigtimedwait, #function
-    .globl __rt_sigtimedwait
-    .align 4
-    .fnstart
-
-__rt_sigtimedwait:
+ENTRY(__rt_sigtimedwait)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_rt_sigtimedwait
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__rt_sigtimedwait)
diff --git a/libc/arch-arm/syscalls/__sched_getaffinity.S b/libc/arch-arm/syscalls/__sched_getaffinity.S
index 71f2b1d..bdd4517 100644
--- a/libc/arch-arm/syscalls/__sched_getaffinity.S
+++ b/libc/arch-arm/syscalls/__sched_getaffinity.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __sched_getaffinity, #function
-    .globl __sched_getaffinity
-    .align 4
-    .fnstart
-
-__sched_getaffinity:
+ENTRY(__sched_getaffinity)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sched_getaffinity
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__sched_getaffinity)
diff --git a/libc/arch-arm/syscalls/__set_tls.S b/libc/arch-arm/syscalls/__set_tls.S
index f6a097f..cf5d6b6 100644
--- a/libc/arch-arm/syscalls/__set_tls.S
+++ b/libc/arch-arm/syscalls/__set_tls.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __set_tls, #function
-    .globl __set_tls
-    .align 4
-    .fnstart
-
-__set_tls:
+ENTRY(__set_tls)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_ARM_set_tls
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__set_tls)
diff --git a/libc/arch-arm/syscalls/__setresuid.S b/libc/arch-arm/syscalls/__setresuid.S
index 7710772..d5053ba 100644
--- a/libc/arch-arm/syscalls/__setresuid.S
+++ b/libc/arch-arm/syscalls/__setresuid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __setresuid, #function
-    .globl __setresuid
-    .align 4
-    .fnstart
-
-__setresuid:
+ENTRY(__setresuid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_setresuid32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__setresuid)
diff --git a/libc/arch-arm/syscalls/__setreuid.S b/libc/arch-arm/syscalls/__setreuid.S
index 0c68866..9cd51f6 100644
--- a/libc/arch-arm/syscalls/__setreuid.S
+++ b/libc/arch-arm/syscalls/__setreuid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __setreuid, #function
-    .globl __setreuid
-    .align 4
-    .fnstart
-
-__setreuid:
+ENTRY(__setreuid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_setreuid32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__setreuid)
diff --git a/libc/arch-arm/syscalls/__setuid.S b/libc/arch-arm/syscalls/__setuid.S
index efc6e56..88dc58e 100644
--- a/libc/arch-arm/syscalls/__setuid.S
+++ b/libc/arch-arm/syscalls/__setuid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __setuid, #function
-    .globl __setuid
-    .align 4
-    .fnstart
-
-__setuid:
+ENTRY(__setuid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_setuid32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__setuid)
diff --git a/libc/arch-arm/syscalls/__sigsuspend.S b/libc/arch-arm/syscalls/__sigsuspend.S
index 39416f1..1ececb7 100644
--- a/libc/arch-arm/syscalls/__sigsuspend.S
+++ b/libc/arch-arm/syscalls/__sigsuspend.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __sigsuspend, #function
-    .globl __sigsuspend
-    .align 4
-    .fnstart
-
-__sigsuspend:
+ENTRY(__sigsuspend)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sigsuspend
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__sigsuspend)
diff --git a/libc/arch-arm/syscalls/__statfs64.S b/libc/arch-arm/syscalls/__statfs64.S
index f602637..4afef71 100644
--- a/libc/arch-arm/syscalls/__statfs64.S
+++ b/libc/arch-arm/syscalls/__statfs64.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __statfs64, #function
-    .globl __statfs64
-    .align 4
-    .fnstart
-
-__statfs64:
+ENTRY(__statfs64)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_statfs64
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__statfs64)
diff --git a/libc/arch-arm/syscalls/__sys_clone.S b/libc/arch-arm/syscalls/__sys_clone.S
index 9fe2641..48046bc 100644
--- a/libc/arch-arm/syscalls/__sys_clone.S
+++ b/libc/arch-arm/syscalls/__sys_clone.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __sys_clone, #function
-    .globl __sys_clone
-    .align 4
-    .fnstart
-
-__sys_clone:
+ENTRY(__sys_clone)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
     stmfd   sp!, {r4, r5, r6, r7}
@@ -18,4 +13,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__sys_clone)
diff --git a/libc/arch-arm/syscalls/__syslog.S b/libc/arch-arm/syscalls/__syslog.S
index 3318d76..6dbe745 100644
--- a/libc/arch-arm/syscalls/__syslog.S
+++ b/libc/arch-arm/syscalls/__syslog.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __syslog, #function
-    .globl __syslog
-    .align 4
-    .fnstart
-
-__syslog:
+ENTRY(__syslog)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_syslog
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__syslog)
diff --git a/libc/arch-arm/syscalls/__timer_create.S b/libc/arch-arm/syscalls/__timer_create.S
index 5bc3966..c547137 100644
--- a/libc/arch-arm/syscalls/__timer_create.S
+++ b/libc/arch-arm/syscalls/__timer_create.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __timer_create, #function
-    .globl __timer_create
-    .align 4
-    .fnstart
-
-__timer_create:
+ENTRY(__timer_create)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_timer_create
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__timer_create)
diff --git a/libc/arch-arm/syscalls/__timer_delete.S b/libc/arch-arm/syscalls/__timer_delete.S
index 4ddee01..ca2e0a3 100644
--- a/libc/arch-arm/syscalls/__timer_delete.S
+++ b/libc/arch-arm/syscalls/__timer_delete.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __timer_delete, #function
-    .globl __timer_delete
-    .align 4
-    .fnstart
-
-__timer_delete:
+ENTRY(__timer_delete)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_timer_delete
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__timer_delete)
diff --git a/libc/arch-arm/syscalls/__timer_getoverrun.S b/libc/arch-arm/syscalls/__timer_getoverrun.S
index fb0c87d..b0f18e7 100644
--- a/libc/arch-arm/syscalls/__timer_getoverrun.S
+++ b/libc/arch-arm/syscalls/__timer_getoverrun.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __timer_getoverrun, #function
-    .globl __timer_getoverrun
-    .align 4
-    .fnstart
-
-__timer_getoverrun:
+ENTRY(__timer_getoverrun)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_timer_getoverrun
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__timer_getoverrun)
diff --git a/libc/arch-arm/syscalls/__timer_gettime.S b/libc/arch-arm/syscalls/__timer_gettime.S
index 9d6e446..c172602 100644
--- a/libc/arch-arm/syscalls/__timer_gettime.S
+++ b/libc/arch-arm/syscalls/__timer_gettime.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __timer_gettime, #function
-    .globl __timer_gettime
-    .align 4
-    .fnstart
-
-__timer_gettime:
+ENTRY(__timer_gettime)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_timer_gettime
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__timer_gettime)
diff --git a/libc/arch-arm/syscalls/__timer_settime.S b/libc/arch-arm/syscalls/__timer_settime.S
index a7be132..8220440 100644
--- a/libc/arch-arm/syscalls/__timer_settime.S
+++ b/libc/arch-arm/syscalls/__timer_settime.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __timer_settime, #function
-    .globl __timer_settime
-    .align 4
-    .fnstart
-
-__timer_settime:
+ENTRY(__timer_settime)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_timer_settime
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__timer_settime)
diff --git a/libc/arch-arm/syscalls/__wait4.S b/libc/arch-arm/syscalls/__wait4.S
index 9670177..fa34502 100644
--- a/libc/arch-arm/syscalls/__wait4.S
+++ b/libc/arch-arm/syscalls/__wait4.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __wait4, #function
-    .globl __wait4
-    .align 4
-    .fnstart
-
-__wait4:
+ENTRY(__wait4)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_wait4
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__wait4)
diff --git a/libc/arch-arm/syscalls/__waitid.S b/libc/arch-arm/syscalls/__waitid.S
index fdd0da3..9950e9c 100644
--- a/libc/arch-arm/syscalls/__waitid.S
+++ b/libc/arch-arm/syscalls/__waitid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type __waitid, #function
-    .globl __waitid
-    .align 4
-    .fnstart
-
-__waitid:
+ENTRY(__waitid)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
     stmfd   sp!, {r4, r5, r6, r7}
@@ -18,4 +13,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(__waitid)
diff --git a/libc/arch-arm/syscalls/_exit.S b/libc/arch-arm/syscalls/_exit.S
index e750ca3..77487b5 100644
--- a/libc/arch-arm/syscalls/_exit.S
+++ b/libc/arch-arm/syscalls/_exit.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type _exit, #function
-    .globl _exit
-    .align 4
-    .fnstart
-
-_exit:
+ENTRY(_exit)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_exit_group
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(_exit)
diff --git a/libc/arch-arm/syscalls/_exit_thread.S b/libc/arch-arm/syscalls/_exit_thread.S
index c6f868f..bd16ff1 100644
--- a/libc/arch-arm/syscalls/_exit_thread.S
+++ b/libc/arch-arm/syscalls/_exit_thread.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type _exit_thread, #function
-    .globl _exit_thread
-    .align 4
-    .fnstart
-
-_exit_thread:
+ENTRY(_exit_thread)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_exit
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(_exit_thread)
diff --git a/libc/arch-arm/syscalls/accept.S b/libc/arch-arm/syscalls/accept.S
index 6c32f24..0dcfb0c 100644
--- a/libc/arch-arm/syscalls/accept.S
+++ b/libc/arch-arm/syscalls/accept.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type accept, #function
-    .globl accept
-    .align 4
-    .fnstart
-
-accept:
+ENTRY(accept)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_accept
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(accept)
diff --git a/libc/arch-arm/syscalls/access.S b/libc/arch-arm/syscalls/access.S
index 3639106..cf585a3 100644
--- a/libc/arch-arm/syscalls/access.S
+++ b/libc/arch-arm/syscalls/access.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type access, #function
-    .globl access
-    .align 4
-    .fnstart
-
-access:
+ENTRY(access)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_access
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(access)
diff --git a/libc/arch-arm/syscalls/acct.S b/libc/arch-arm/syscalls/acct.S
index d7d8781..85346e4 100644
--- a/libc/arch-arm/syscalls/acct.S
+++ b/libc/arch-arm/syscalls/acct.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type acct, #function
-    .globl acct
-    .align 4
-    .fnstart
-
-acct:
+ENTRY(acct)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_acct
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(acct)
diff --git a/libc/arch-arm/syscalls/bind.S b/libc/arch-arm/syscalls/bind.S
index 66cc667..85d0471 100644
--- a/libc/arch-arm/syscalls/bind.S
+++ b/libc/arch-arm/syscalls/bind.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type bind, #function
-    .globl bind
-    .align 4
-    .fnstart
-
-bind:
+ENTRY(bind)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_bind
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(bind)
diff --git a/libc/arch-arm/syscalls/cacheflush.S b/libc/arch-arm/syscalls/cacheflush.S
index d7fba90..05b2411 100644
--- a/libc/arch-arm/syscalls/cacheflush.S
+++ b/libc/arch-arm/syscalls/cacheflush.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type cacheflush, #function
-    .globl cacheflush
-    .align 4
-    .fnstart
-
-cacheflush:
+ENTRY(cacheflush)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_ARM_cacheflush
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(cacheflush)
diff --git a/libc/arch-arm/syscalls/capget.S b/libc/arch-arm/syscalls/capget.S
index 92082a1..0f3ba31 100644
--- a/libc/arch-arm/syscalls/capget.S
+++ b/libc/arch-arm/syscalls/capget.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type capget, #function
-    .globl capget
-    .align 4
-    .fnstart
-
-capget:
+ENTRY(capget)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_capget
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(capget)
diff --git a/libc/arch-arm/syscalls/capset.S b/libc/arch-arm/syscalls/capset.S
index 8a169ed..2254db2 100644
--- a/libc/arch-arm/syscalls/capset.S
+++ b/libc/arch-arm/syscalls/capset.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type capset, #function
-    .globl capset
-    .align 4
-    .fnstart
-
-capset:
+ENTRY(capset)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_capset
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(capset)
diff --git a/libc/arch-arm/syscalls/chdir.S b/libc/arch-arm/syscalls/chdir.S
index ff4ec68..57d6b13 100644
--- a/libc/arch-arm/syscalls/chdir.S
+++ b/libc/arch-arm/syscalls/chdir.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type chdir, #function
-    .globl chdir
-    .align 4
-    .fnstart
-
-chdir:
+ENTRY(chdir)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_chdir
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(chdir)
diff --git a/libc/arch-arm/syscalls/chmod.S b/libc/arch-arm/syscalls/chmod.S
index 56e43c5..8909c6f 100644
--- a/libc/arch-arm/syscalls/chmod.S
+++ b/libc/arch-arm/syscalls/chmod.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type chmod, #function
-    .globl chmod
-    .align 4
-    .fnstart
-
-chmod:
+ENTRY(chmod)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_chmod
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(chmod)
diff --git a/libc/arch-arm/syscalls/chown.S b/libc/arch-arm/syscalls/chown.S
index 1d3032f..cbbd8a8 100644
--- a/libc/arch-arm/syscalls/chown.S
+++ b/libc/arch-arm/syscalls/chown.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type chown, #function
-    .globl chown
-    .align 4
-    .fnstart
-
-chown:
+ENTRY(chown)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_chown32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(chown)
diff --git a/libc/arch-arm/syscalls/chroot.S b/libc/arch-arm/syscalls/chroot.S
index c063d8b..a679172 100644
--- a/libc/arch-arm/syscalls/chroot.S
+++ b/libc/arch-arm/syscalls/chroot.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type chroot, #function
-    .globl chroot
-    .align 4
-    .fnstart
-
-chroot:
+ENTRY(chroot)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_chroot
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(chroot)
diff --git a/libc/arch-arm/syscalls/clock_getres.S b/libc/arch-arm/syscalls/clock_getres.S
index 6fdbe37..705f296 100644
--- a/libc/arch-arm/syscalls/clock_getres.S
+++ b/libc/arch-arm/syscalls/clock_getres.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type clock_getres, #function
-    .globl clock_getres
-    .align 4
-    .fnstart
-
-clock_getres:
+ENTRY(clock_getres)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_clock_getres
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(clock_getres)
diff --git a/libc/arch-arm/syscalls/clock_gettime.S b/libc/arch-arm/syscalls/clock_gettime.S
index 8941b23..a9ab41f 100644
--- a/libc/arch-arm/syscalls/clock_gettime.S
+++ b/libc/arch-arm/syscalls/clock_gettime.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type clock_gettime, #function
-    .globl clock_gettime
-    .align 4
-    .fnstart
-
-clock_gettime:
+ENTRY(clock_gettime)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_clock_gettime
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(clock_gettime)
diff --git a/libc/arch-arm/syscalls/clock_nanosleep.S b/libc/arch-arm/syscalls/clock_nanosleep.S
index 2c10151..f8e7f73 100644
--- a/libc/arch-arm/syscalls/clock_nanosleep.S
+++ b/libc/arch-arm/syscalls/clock_nanosleep.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type clock_nanosleep, #function
-    .globl clock_nanosleep
-    .align 4
-    .fnstart
-
-clock_nanosleep:
+ENTRY(clock_nanosleep)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_clock_nanosleep
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(clock_nanosleep)
diff --git a/libc/arch-arm/syscalls/clock_settime.S b/libc/arch-arm/syscalls/clock_settime.S
index 94614f2..a996441 100644
--- a/libc/arch-arm/syscalls/clock_settime.S
+++ b/libc/arch-arm/syscalls/clock_settime.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type clock_settime, #function
-    .globl clock_settime
-    .align 4
-    .fnstart
-
-clock_settime:
+ENTRY(clock_settime)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_clock_settime
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(clock_settime)
diff --git a/libc/arch-arm/syscalls/close.S b/libc/arch-arm/syscalls/close.S
index e54b100..36d78a4 100644
--- a/libc/arch-arm/syscalls/close.S
+++ b/libc/arch-arm/syscalls/close.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type close, #function
-    .globl close
-    .align 4
-    .fnstart
-
-close:
+ENTRY(close)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_close
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(close)
diff --git a/libc/arch-arm/syscalls/connect.S b/libc/arch-arm/syscalls/connect.S
index b05d6a2..ea14c17 100644
--- a/libc/arch-arm/syscalls/connect.S
+++ b/libc/arch-arm/syscalls/connect.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type connect, #function
-    .globl connect
-    .align 4
-    .fnstart
-
-connect:
+ENTRY(connect)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_connect
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(connect)
diff --git a/libc/arch-arm/syscalls/delete_module.S b/libc/arch-arm/syscalls/delete_module.S
index 69d5966..df8aae0 100644
--- a/libc/arch-arm/syscalls/delete_module.S
+++ b/libc/arch-arm/syscalls/delete_module.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type delete_module, #function
-    .globl delete_module
-    .align 4
-    .fnstart
-
-delete_module:
+ENTRY(delete_module)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_delete_module
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(delete_module)
diff --git a/libc/arch-arm/syscalls/dup.S b/libc/arch-arm/syscalls/dup.S
index 5a5d050..b0c1cda 100644
--- a/libc/arch-arm/syscalls/dup.S
+++ b/libc/arch-arm/syscalls/dup.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type dup, #function
-    .globl dup
-    .align 4
-    .fnstart
-
-dup:
+ENTRY(dup)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_dup
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(dup)
diff --git a/libc/arch-arm/syscalls/dup2.S b/libc/arch-arm/syscalls/dup2.S
index 1ced458..ed346d9 100644
--- a/libc/arch-arm/syscalls/dup2.S
+++ b/libc/arch-arm/syscalls/dup2.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type dup2, #function
-    .globl dup2
-    .align 4
-    .fnstart
-
-dup2:
+ENTRY(dup2)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_dup2
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(dup2)
diff --git a/libc/arch-arm/syscalls/epoll_create.S b/libc/arch-arm/syscalls/epoll_create.S
index 389d4ba..1aab606 100644
--- a/libc/arch-arm/syscalls/epoll_create.S
+++ b/libc/arch-arm/syscalls/epoll_create.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type epoll_create, #function
-    .globl epoll_create
-    .align 4
-    .fnstart
-
-epoll_create:
+ENTRY(epoll_create)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_epoll_create
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(epoll_create)
diff --git a/libc/arch-arm/syscalls/epoll_ctl.S b/libc/arch-arm/syscalls/epoll_ctl.S
index 906d80d..c0ecf06 100644
--- a/libc/arch-arm/syscalls/epoll_ctl.S
+++ b/libc/arch-arm/syscalls/epoll_ctl.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type epoll_ctl, #function
-    .globl epoll_ctl
-    .align 4
-    .fnstart
-
-epoll_ctl:
+ENTRY(epoll_ctl)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_epoll_ctl
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(epoll_ctl)
diff --git a/libc/arch-arm/syscalls/epoll_wait.S b/libc/arch-arm/syscalls/epoll_wait.S
index af74878..3535001 100644
--- a/libc/arch-arm/syscalls/epoll_wait.S
+++ b/libc/arch-arm/syscalls/epoll_wait.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type epoll_wait, #function
-    .globl epoll_wait
-    .align 4
-    .fnstart
-
-epoll_wait:
+ENTRY(epoll_wait)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_epoll_wait
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(epoll_wait)
diff --git a/libc/arch-arm/syscalls/eventfd.S b/libc/arch-arm/syscalls/eventfd.S
index 8d2cce9..857b6c0 100644
--- a/libc/arch-arm/syscalls/eventfd.S
+++ b/libc/arch-arm/syscalls/eventfd.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type eventfd, #function
-    .globl eventfd
-    .align 4
-    .fnstart
-
-eventfd:
+ENTRY(eventfd)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_eventfd2
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(eventfd)
diff --git a/libc/arch-arm/syscalls/execve.S b/libc/arch-arm/syscalls/execve.S
index 2309a1b..1a66167 100644
--- a/libc/arch-arm/syscalls/execve.S
+++ b/libc/arch-arm/syscalls/execve.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type execve, #function
-    .globl execve
-    .align 4
-    .fnstart
-
-execve:
+ENTRY(execve)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_execve
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(execve)
diff --git a/libc/arch-arm/syscalls/fchdir.S b/libc/arch-arm/syscalls/fchdir.S
index 441f3e2..7d80cf0 100644
--- a/libc/arch-arm/syscalls/fchdir.S
+++ b/libc/arch-arm/syscalls/fchdir.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fchdir, #function
-    .globl fchdir
-    .align 4
-    .fnstart
-
-fchdir:
+ENTRY(fchdir)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_fchdir
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(fchdir)
diff --git a/libc/arch-arm/syscalls/fchmod.S b/libc/arch-arm/syscalls/fchmod.S
index b5f1983..bc8e643 100644
--- a/libc/arch-arm/syscalls/fchmod.S
+++ b/libc/arch-arm/syscalls/fchmod.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fchmod, #function
-    .globl fchmod
-    .align 4
-    .fnstart
-
-fchmod:
+ENTRY(fchmod)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_fchmod
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(fchmod)
diff --git a/libc/arch-arm/syscalls/fchmodat.S b/libc/arch-arm/syscalls/fchmodat.S
index d6e3916..ac782e5 100644
--- a/libc/arch-arm/syscalls/fchmodat.S
+++ b/libc/arch-arm/syscalls/fchmodat.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fchmodat, #function
-    .globl fchmodat
-    .align 4
-    .fnstart
-
-fchmodat:
+ENTRY(fchmodat)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_fchmodat
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(fchmodat)
diff --git a/libc/arch-arm/syscalls/fchown.S b/libc/arch-arm/syscalls/fchown.S
index 7887296..22d7fd2 100644
--- a/libc/arch-arm/syscalls/fchown.S
+++ b/libc/arch-arm/syscalls/fchown.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fchown, #function
-    .globl fchown
-    .align 4
-    .fnstart
-
-fchown:
+ENTRY(fchown)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_fchown32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(fchown)
diff --git a/libc/arch-arm/syscalls/fchownat.S b/libc/arch-arm/syscalls/fchownat.S
index 2279d2c..1482832 100644
--- a/libc/arch-arm/syscalls/fchownat.S
+++ b/libc/arch-arm/syscalls/fchownat.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fchownat, #function
-    .globl fchownat
-    .align 4
-    .fnstart
-
-fchownat:
+ENTRY(fchownat)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
     stmfd   sp!, {r4, r5, r6, r7}
@@ -18,4 +13,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(fchownat)
diff --git a/libc/arch-arm/syscalls/fdatasync.S b/libc/arch-arm/syscalls/fdatasync.S
index 5981a80..d41e823 100644
--- a/libc/arch-arm/syscalls/fdatasync.S
+++ b/libc/arch-arm/syscalls/fdatasync.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fdatasync, #function
-    .globl fdatasync
-    .align 4
-    .fnstart
-
-fdatasync:
+ENTRY(fdatasync)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_fdatasync
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(fdatasync)
diff --git a/libc/arch-arm/syscalls/flock.S b/libc/arch-arm/syscalls/flock.S
index 22e391c..c0d2844 100644
--- a/libc/arch-arm/syscalls/flock.S
+++ b/libc/arch-arm/syscalls/flock.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type flock, #function
-    .globl flock
-    .align 4
-    .fnstart
-
-flock:
+ENTRY(flock)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_flock
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(flock)
diff --git a/libc/arch-arm/syscalls/fstat.S b/libc/arch-arm/syscalls/fstat.S
index ef1752f..e75649f 100644
--- a/libc/arch-arm/syscalls/fstat.S
+++ b/libc/arch-arm/syscalls/fstat.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fstat, #function
-    .globl fstat
-    .align 4
-    .fnstart
-
-fstat:
+ENTRY(fstat)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_fstat64
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(fstat)
diff --git a/libc/arch-arm/syscalls/fstatat.S b/libc/arch-arm/syscalls/fstatat.S
index a3dd74a..065ef9f 100644
--- a/libc/arch-arm/syscalls/fstatat.S
+++ b/libc/arch-arm/syscalls/fstatat.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fstatat, #function
-    .globl fstatat
-    .align 4
-    .fnstart
-
-fstatat:
+ENTRY(fstatat)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_fstatat64
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(fstatat)
diff --git a/libc/arch-arm/syscalls/fsync.S b/libc/arch-arm/syscalls/fsync.S
index 588dfa3..f0de9ca 100644
--- a/libc/arch-arm/syscalls/fsync.S
+++ b/libc/arch-arm/syscalls/fsync.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type fsync, #function
-    .globl fsync
-    .align 4
-    .fnstart
-
-fsync:
+ENTRY(fsync)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_fsync
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(fsync)
diff --git a/libc/arch-arm/syscalls/ftruncate.S b/libc/arch-arm/syscalls/ftruncate.S
index 2d60b41..2e4a308 100644
--- a/libc/arch-arm/syscalls/ftruncate.S
+++ b/libc/arch-arm/syscalls/ftruncate.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type ftruncate, #function
-    .globl ftruncate
-    .align 4
-    .fnstart
-
-ftruncate:
+ENTRY(ftruncate)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_ftruncate
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(ftruncate)
diff --git a/libc/arch-arm/syscalls/ftruncate64.S b/libc/arch-arm/syscalls/ftruncate64.S
index 37b4744..7c7b80b 100644
--- a/libc/arch-arm/syscalls/ftruncate64.S
+++ b/libc/arch-arm/syscalls/ftruncate64.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type ftruncate64, #function
-    .globl ftruncate64
-    .align 4
-    .fnstart
-
-ftruncate64:
+ENTRY(ftruncate64)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_ftruncate64
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(ftruncate64)
diff --git a/libc/arch-arm/syscalls/futex.S b/libc/arch-arm/syscalls/futex.S
index c2d4b7e..47219e3 100644
--- a/libc/arch-arm/syscalls/futex.S
+++ b/libc/arch-arm/syscalls/futex.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type futex, #function
-    .globl futex
-    .align 4
-    .fnstart
-
-futex:
+ENTRY(futex)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
     stmfd   sp!, {r4, r5, r6, r7}
@@ -18,4 +13,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(futex)
diff --git a/libc/arch-arm/syscalls/getdents.S b/libc/arch-arm/syscalls/getdents.S
index 312aa0d..82b6e4c 100644
--- a/libc/arch-arm/syscalls/getdents.S
+++ b/libc/arch-arm/syscalls/getdents.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getdents, #function
-    .globl getdents
-    .align 4
-    .fnstart
-
-getdents:
+ENTRY(getdents)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getdents64
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getdents)
diff --git a/libc/arch-arm/syscalls/getegid.S b/libc/arch-arm/syscalls/getegid.S
index 26723bf..27ea272 100644
--- a/libc/arch-arm/syscalls/getegid.S
+++ b/libc/arch-arm/syscalls/getegid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getegid, #function
-    .globl getegid
-    .align 4
-    .fnstart
-
-getegid:
+ENTRY(getegid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getegid32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getegid)
diff --git a/libc/arch-arm/syscalls/geteuid.S b/libc/arch-arm/syscalls/geteuid.S
index d86959f..d4c9cd1 100644
--- a/libc/arch-arm/syscalls/geteuid.S
+++ b/libc/arch-arm/syscalls/geteuid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type geteuid, #function
-    .globl geteuid
-    .align 4
-    .fnstart
-
-geteuid:
+ENTRY(geteuid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_geteuid32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(geteuid)
diff --git a/libc/arch-arm/syscalls/getgid.S b/libc/arch-arm/syscalls/getgid.S
index 1502fdf..9a40fe6 100644
--- a/libc/arch-arm/syscalls/getgid.S
+++ b/libc/arch-arm/syscalls/getgid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getgid, #function
-    .globl getgid
-    .align 4
-    .fnstart
-
-getgid:
+ENTRY(getgid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getgid32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getgid)
diff --git a/libc/arch-arm/syscalls/getgroups.S b/libc/arch-arm/syscalls/getgroups.S
index e68fe05..2995cc8 100644
--- a/libc/arch-arm/syscalls/getgroups.S
+++ b/libc/arch-arm/syscalls/getgroups.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getgroups, #function
-    .globl getgroups
-    .align 4
-    .fnstart
-
-getgroups:
+ENTRY(getgroups)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getgroups32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getgroups)
diff --git a/libc/arch-arm/syscalls/getitimer.S b/libc/arch-arm/syscalls/getitimer.S
index 404c2fc..a3f1423 100644
--- a/libc/arch-arm/syscalls/getitimer.S
+++ b/libc/arch-arm/syscalls/getitimer.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getitimer, #function
-    .globl getitimer
-    .align 4
-    .fnstart
-
-getitimer:
+ENTRY(getitimer)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getitimer
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getitimer)
diff --git a/libc/arch-arm/syscalls/getpeername.S b/libc/arch-arm/syscalls/getpeername.S
index f04ec32..f90c344 100644
--- a/libc/arch-arm/syscalls/getpeername.S
+++ b/libc/arch-arm/syscalls/getpeername.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getpeername, #function
-    .globl getpeername
-    .align 4
-    .fnstart
-
-getpeername:
+ENTRY(getpeername)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getpeername
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getpeername)
diff --git a/libc/arch-arm/syscalls/getpgid.S b/libc/arch-arm/syscalls/getpgid.S
index 9397458..0fc57a4 100644
--- a/libc/arch-arm/syscalls/getpgid.S
+++ b/libc/arch-arm/syscalls/getpgid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getpgid, #function
-    .globl getpgid
-    .align 4
-    .fnstart
-
-getpgid:
+ENTRY(getpgid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getpgid
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getpgid)
diff --git a/libc/arch-arm/syscalls/getpid.S b/libc/arch-arm/syscalls/getpid.S
index 1be793a..440ae9b 100644
--- a/libc/arch-arm/syscalls/getpid.S
+++ b/libc/arch-arm/syscalls/getpid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getpid, #function
-    .globl getpid
-    .align 4
-    .fnstart
-
-getpid:
+ENTRY(getpid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getpid
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getpid)
diff --git a/libc/arch-arm/syscalls/getppid.S b/libc/arch-arm/syscalls/getppid.S
index 14185b9..3eb1b86 100644
--- a/libc/arch-arm/syscalls/getppid.S
+++ b/libc/arch-arm/syscalls/getppid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getppid, #function
-    .globl getppid
-    .align 4
-    .fnstart
-
-getppid:
+ENTRY(getppid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getppid
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getppid)
diff --git a/libc/arch-arm/syscalls/getresgid.S b/libc/arch-arm/syscalls/getresgid.S
index 90c90df..a022341 100644
--- a/libc/arch-arm/syscalls/getresgid.S
+++ b/libc/arch-arm/syscalls/getresgid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getresgid, #function
-    .globl getresgid
-    .align 4
-    .fnstart
-
-getresgid:
+ENTRY(getresgid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getresgid32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getresgid)
diff --git a/libc/arch-arm/syscalls/getresuid.S b/libc/arch-arm/syscalls/getresuid.S
index e067ac0..23112a6 100644
--- a/libc/arch-arm/syscalls/getresuid.S
+++ b/libc/arch-arm/syscalls/getresuid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getresuid, #function
-    .globl getresuid
-    .align 4
-    .fnstart
-
-getresuid:
+ENTRY(getresuid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getresuid32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getresuid)
diff --git a/libc/arch-arm/syscalls/getrlimit.S b/libc/arch-arm/syscalls/getrlimit.S
index 79c1357..8b1c089 100644
--- a/libc/arch-arm/syscalls/getrlimit.S
+++ b/libc/arch-arm/syscalls/getrlimit.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getrlimit, #function
-    .globl getrlimit
-    .align 4
-    .fnstart
-
-getrlimit:
+ENTRY(getrlimit)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_ugetrlimit
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getrlimit)
diff --git a/libc/arch-arm/syscalls/getrusage.S b/libc/arch-arm/syscalls/getrusage.S
index 81db153..74fa20b 100644
--- a/libc/arch-arm/syscalls/getrusage.S
+++ b/libc/arch-arm/syscalls/getrusage.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getrusage, #function
-    .globl getrusage
-    .align 4
-    .fnstart
-
-getrusage:
+ENTRY(getrusage)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getrusage
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getrusage)
diff --git a/libc/arch-arm/syscalls/getsockname.S b/libc/arch-arm/syscalls/getsockname.S
index 2ae0876..99470e2 100644
--- a/libc/arch-arm/syscalls/getsockname.S
+++ b/libc/arch-arm/syscalls/getsockname.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getsockname, #function
-    .globl getsockname
-    .align 4
-    .fnstart
-
-getsockname:
+ENTRY(getsockname)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getsockname
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getsockname)
diff --git a/libc/arch-arm/syscalls/getsockopt.S b/libc/arch-arm/syscalls/getsockopt.S
index 76e1b11..d52f441 100644
--- a/libc/arch-arm/syscalls/getsockopt.S
+++ b/libc/arch-arm/syscalls/getsockopt.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getsockopt, #function
-    .globl getsockopt
-    .align 4
-    .fnstart
-
-getsockopt:
+ENTRY(getsockopt)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
     stmfd   sp!, {r4, r5, r6, r7}
@@ -18,4 +13,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getsockopt)
diff --git a/libc/arch-arm/syscalls/gettid.S b/libc/arch-arm/syscalls/gettid.S
index e5da45d..f5b15be 100644
--- a/libc/arch-arm/syscalls/gettid.S
+++ b/libc/arch-arm/syscalls/gettid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type gettid, #function
-    .globl gettid
-    .align 4
-    .fnstart
-
-gettid:
+ENTRY(gettid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_gettid
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(gettid)
diff --git a/libc/arch-arm/syscalls/gettimeofday.S b/libc/arch-arm/syscalls/gettimeofday.S
index ba759f2..9b47daf 100644
--- a/libc/arch-arm/syscalls/gettimeofday.S
+++ b/libc/arch-arm/syscalls/gettimeofday.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type gettimeofday, #function
-    .globl gettimeofday
-    .align 4
-    .fnstart
-
-gettimeofday:
+ENTRY(gettimeofday)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_gettimeofday
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(gettimeofday)
diff --git a/libc/arch-arm/syscalls/getuid.S b/libc/arch-arm/syscalls/getuid.S
index 68c3057..053dc31 100644
--- a/libc/arch-arm/syscalls/getuid.S
+++ b/libc/arch-arm/syscalls/getuid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type getuid, #function
-    .globl getuid
-    .align 4
-    .fnstart
-
-getuid:
+ENTRY(getuid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_getuid32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(getuid)
diff --git a/libc/arch-arm/syscalls/init_module.S b/libc/arch-arm/syscalls/init_module.S
index 4e9cd1f..73beb46 100644
--- a/libc/arch-arm/syscalls/init_module.S
+++ b/libc/arch-arm/syscalls/init_module.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type init_module, #function
-    .globl init_module
-    .align 4
-    .fnstart
-
-init_module:
+ENTRY(init_module)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_init_module
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(init_module)
diff --git a/libc/arch-arm/syscalls/inotify_add_watch.S b/libc/arch-arm/syscalls/inotify_add_watch.S
index 823f321..da4a296 100644
--- a/libc/arch-arm/syscalls/inotify_add_watch.S
+++ b/libc/arch-arm/syscalls/inotify_add_watch.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type inotify_add_watch, #function
-    .globl inotify_add_watch
-    .align 4
-    .fnstart
-
-inotify_add_watch:
+ENTRY(inotify_add_watch)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_inotify_add_watch
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(inotify_add_watch)
diff --git a/libc/arch-arm/syscalls/inotify_init.S b/libc/arch-arm/syscalls/inotify_init.S
index c612b83..bac124c 100644
--- a/libc/arch-arm/syscalls/inotify_init.S
+++ b/libc/arch-arm/syscalls/inotify_init.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type inotify_init, #function
-    .globl inotify_init
-    .align 4
-    .fnstart
-
-inotify_init:
+ENTRY(inotify_init)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_inotify_init
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(inotify_init)
diff --git a/libc/arch-arm/syscalls/inotify_rm_watch.S b/libc/arch-arm/syscalls/inotify_rm_watch.S
index 6c416d6..f576480 100644
--- a/libc/arch-arm/syscalls/inotify_rm_watch.S
+++ b/libc/arch-arm/syscalls/inotify_rm_watch.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type inotify_rm_watch, #function
-    .globl inotify_rm_watch
-    .align 4
-    .fnstart
-
-inotify_rm_watch:
+ENTRY(inotify_rm_watch)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_inotify_rm_watch
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(inotify_rm_watch)
diff --git a/libc/arch-arm/syscalls/ioprio_get.S b/libc/arch-arm/syscalls/ioprio_get.S
index d686e98..13739dc 100644
--- a/libc/arch-arm/syscalls/ioprio_get.S
+++ b/libc/arch-arm/syscalls/ioprio_get.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type ioprio_get, #function
-    .globl ioprio_get
-    .align 4
-    .fnstart
-
-ioprio_get:
+ENTRY(ioprio_get)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_ioprio_get
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(ioprio_get)
diff --git a/libc/arch-arm/syscalls/ioprio_set.S b/libc/arch-arm/syscalls/ioprio_set.S
index a812557..7e40ee5 100644
--- a/libc/arch-arm/syscalls/ioprio_set.S
+++ b/libc/arch-arm/syscalls/ioprio_set.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type ioprio_set, #function
-    .globl ioprio_set
-    .align 4
-    .fnstart
-
-ioprio_set:
+ENTRY(ioprio_set)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_ioprio_set
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(ioprio_set)
diff --git a/libc/arch-arm/syscalls/klogctl.S b/libc/arch-arm/syscalls/klogctl.S
index aee3474..5434b30 100644
--- a/libc/arch-arm/syscalls/klogctl.S
+++ b/libc/arch-arm/syscalls/klogctl.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type klogctl, #function
-    .globl klogctl
-    .align 4
-    .fnstart
-
-klogctl:
+ENTRY(klogctl)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_syslog
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(klogctl)
diff --git a/libc/arch-arm/syscalls/lchown.S b/libc/arch-arm/syscalls/lchown.S
index f8ee793..789e5af 100644
--- a/libc/arch-arm/syscalls/lchown.S
+++ b/libc/arch-arm/syscalls/lchown.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type lchown, #function
-    .globl lchown
-    .align 4
-    .fnstart
-
-lchown:
+ENTRY(lchown)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_lchown32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(lchown)
diff --git a/libc/arch-arm/syscalls/link.S b/libc/arch-arm/syscalls/link.S
index f368595..ccf0a1d 100644
--- a/libc/arch-arm/syscalls/link.S
+++ b/libc/arch-arm/syscalls/link.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type link, #function
-    .globl link
-    .align 4
-    .fnstart
-
-link:
+ENTRY(link)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_link
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(link)
diff --git a/libc/arch-arm/syscalls/listen.S b/libc/arch-arm/syscalls/listen.S
index d1a8a6e..bb7f7a4 100644
--- a/libc/arch-arm/syscalls/listen.S
+++ b/libc/arch-arm/syscalls/listen.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type listen, #function
-    .globl listen
-    .align 4
-    .fnstart
-
-listen:
+ENTRY(listen)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_listen
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(listen)
diff --git a/libc/arch-arm/syscalls/lseek.S b/libc/arch-arm/syscalls/lseek.S
index 47bf06a..2cd0853 100644
--- a/libc/arch-arm/syscalls/lseek.S
+++ b/libc/arch-arm/syscalls/lseek.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type lseek, #function
-    .globl lseek
-    .align 4
-    .fnstart
-
-lseek:
+ENTRY(lseek)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_lseek
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(lseek)
diff --git a/libc/arch-arm/syscalls/lstat.S b/libc/arch-arm/syscalls/lstat.S
index f19d12f..dbecefe 100644
--- a/libc/arch-arm/syscalls/lstat.S
+++ b/libc/arch-arm/syscalls/lstat.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type lstat, #function
-    .globl lstat
-    .align 4
-    .fnstart
-
-lstat:
+ENTRY(lstat)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_lstat64
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(lstat)
diff --git a/libc/arch-arm/syscalls/madvise.S b/libc/arch-arm/syscalls/madvise.S
index a992f46..024476f 100644
--- a/libc/arch-arm/syscalls/madvise.S
+++ b/libc/arch-arm/syscalls/madvise.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type madvise, #function
-    .globl madvise
-    .align 4
-    .fnstart
-
-madvise:
+ENTRY(madvise)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_madvise
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(madvise)
diff --git a/libc/arch-arm/syscalls/mincore.S b/libc/arch-arm/syscalls/mincore.S
index c2b5432..7a2a378 100644
--- a/libc/arch-arm/syscalls/mincore.S
+++ b/libc/arch-arm/syscalls/mincore.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mincore, #function
-    .globl mincore
-    .align 4
-    .fnstart
-
-mincore:
+ENTRY(mincore)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_mincore
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(mincore)
diff --git a/libc/arch-arm/syscalls/mkdir.S b/libc/arch-arm/syscalls/mkdir.S
index ec8372d..e51beab 100644
--- a/libc/arch-arm/syscalls/mkdir.S
+++ b/libc/arch-arm/syscalls/mkdir.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mkdir, #function
-    .globl mkdir
-    .align 4
-    .fnstart
-
-mkdir:
+ENTRY(mkdir)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_mkdir
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(mkdir)
diff --git a/libc/arch-arm/syscalls/mkdirat.S b/libc/arch-arm/syscalls/mkdirat.S
index e377c66..52f0be3 100644
--- a/libc/arch-arm/syscalls/mkdirat.S
+++ b/libc/arch-arm/syscalls/mkdirat.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mkdirat, #function
-    .globl mkdirat
-    .align 4
-    .fnstart
-
-mkdirat:
+ENTRY(mkdirat)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_mkdirat
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(mkdirat)
diff --git a/libc/arch-arm/syscalls/mknod.S b/libc/arch-arm/syscalls/mknod.S
index 0a8b6fa..ac6d976 100644
--- a/libc/arch-arm/syscalls/mknod.S
+++ b/libc/arch-arm/syscalls/mknod.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mknod, #function
-    .globl mknod
-    .align 4
-    .fnstart
-
-mknod:
+ENTRY(mknod)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_mknod
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(mknod)
diff --git a/libc/arch-arm/syscalls/mlock.S b/libc/arch-arm/syscalls/mlock.S
index 4eff70b..ad140d1 100644
--- a/libc/arch-arm/syscalls/mlock.S
+++ b/libc/arch-arm/syscalls/mlock.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mlock, #function
-    .globl mlock
-    .align 4
-    .fnstart
-
-mlock:
+ENTRY(mlock)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_mlock
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(mlock)
diff --git a/libc/arch-arm/syscalls/mount.S b/libc/arch-arm/syscalls/mount.S
index a2b9f1d..eb1624c 100644
--- a/libc/arch-arm/syscalls/mount.S
+++ b/libc/arch-arm/syscalls/mount.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mount, #function
-    .globl mount
-    .align 4
-    .fnstart
-
-mount:
+ENTRY(mount)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
     stmfd   sp!, {r4, r5, r6, r7}
@@ -18,4 +13,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(mount)
diff --git a/libc/arch-arm/syscalls/mprotect.S b/libc/arch-arm/syscalls/mprotect.S
index b10291e..39ae353 100644
--- a/libc/arch-arm/syscalls/mprotect.S
+++ b/libc/arch-arm/syscalls/mprotect.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mprotect, #function
-    .globl mprotect
-    .align 4
-    .fnstart
-
-mprotect:
+ENTRY(mprotect)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_mprotect
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(mprotect)
diff --git a/libc/arch-arm/syscalls/mremap.S b/libc/arch-arm/syscalls/mremap.S
index 397844a..918f3b7 100644
--- a/libc/arch-arm/syscalls/mremap.S
+++ b/libc/arch-arm/syscalls/mremap.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type mremap, #function
-    .globl mremap
-    .align 4
-    .fnstart
-
-mremap:
+ENTRY(mremap)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_mremap
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(mremap)
diff --git a/libc/arch-arm/syscalls/msync.S b/libc/arch-arm/syscalls/msync.S
index 7ac7cd2..2a5922c 100644
--- a/libc/arch-arm/syscalls/msync.S
+++ b/libc/arch-arm/syscalls/msync.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type msync, #function
-    .globl msync
-    .align 4
-    .fnstart
-
-msync:
+ENTRY(msync)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_msync
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(msync)
diff --git a/libc/arch-arm/syscalls/munlock.S b/libc/arch-arm/syscalls/munlock.S
index 21ee4d2..5a02aaf 100644
--- a/libc/arch-arm/syscalls/munlock.S
+++ b/libc/arch-arm/syscalls/munlock.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type munlock, #function
-    .globl munlock
-    .align 4
-    .fnstart
-
-munlock:
+ENTRY(munlock)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_munlock
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(munlock)
diff --git a/libc/arch-arm/syscalls/munmap.S b/libc/arch-arm/syscalls/munmap.S
index 7765b00..6bb8dd8 100644
--- a/libc/arch-arm/syscalls/munmap.S
+++ b/libc/arch-arm/syscalls/munmap.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type munmap, #function
-    .globl munmap
-    .align 4
-    .fnstart
-
-munmap:
+ENTRY(munmap)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_munmap
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(munmap)
diff --git a/libc/arch-arm/syscalls/nanosleep.S b/libc/arch-arm/syscalls/nanosleep.S
index 1f9b181..af36ced 100644
--- a/libc/arch-arm/syscalls/nanosleep.S
+++ b/libc/arch-arm/syscalls/nanosleep.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type nanosleep, #function
-    .globl nanosleep
-    .align 4
-    .fnstart
-
-nanosleep:
+ENTRY(nanosleep)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_nanosleep
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(nanosleep)
diff --git a/libc/arch-arm/syscalls/pause.S b/libc/arch-arm/syscalls/pause.S
index 3a16ec3..e64f4f3 100644
--- a/libc/arch-arm/syscalls/pause.S
+++ b/libc/arch-arm/syscalls/pause.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type pause, #function
-    .globl pause
-    .align 4
-    .fnstart
-
-pause:
+ENTRY(pause)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_pause
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(pause)
diff --git a/libc/arch-arm/syscalls/pipe.S b/libc/arch-arm/syscalls/pipe.S
index 4edc75e..3968703 100644
--- a/libc/arch-arm/syscalls/pipe.S
+++ b/libc/arch-arm/syscalls/pipe.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type pipe, #function
-    .globl pipe
-    .align 4
-    .fnstart
-
-pipe:
+ENTRY(pipe)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_pipe
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(pipe)
diff --git a/libc/arch-arm/syscalls/pipe2.S b/libc/arch-arm/syscalls/pipe2.S
index df77094..da2ecba 100644
--- a/libc/arch-arm/syscalls/pipe2.S
+++ b/libc/arch-arm/syscalls/pipe2.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type pipe2, #function
-    .globl pipe2
-    .align 4
-    .fnstart
-
-pipe2:
+ENTRY(pipe2)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_pipe2
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(pipe2)
diff --git a/libc/arch-arm/syscalls/poll.S b/libc/arch-arm/syscalls/poll.S
index 14b18e3..4d345ea 100644
--- a/libc/arch-arm/syscalls/poll.S
+++ b/libc/arch-arm/syscalls/poll.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type poll, #function
-    .globl poll
-    .align 4
-    .fnstart
-
-poll:
+ENTRY(poll)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_poll
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(poll)
diff --git a/libc/arch-arm/syscalls/prctl.S b/libc/arch-arm/syscalls/prctl.S
index 0dd417b..009dc54 100644
--- a/libc/arch-arm/syscalls/prctl.S
+++ b/libc/arch-arm/syscalls/prctl.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type prctl, #function
-    .globl prctl
-    .align 4
-    .fnstart
-
-prctl:
+ENTRY(prctl)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
     stmfd   sp!, {r4, r5, r6, r7}
@@ -18,4 +13,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(prctl)
diff --git a/libc/arch-arm/syscalls/pread64.S b/libc/arch-arm/syscalls/pread64.S
index a54084c..0090fd3 100644
--- a/libc/arch-arm/syscalls/pread64.S
+++ b/libc/arch-arm/syscalls/pread64.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type pread64, #function
-    .globl pread64
-    .align 4
-    .fnstart
-
-pread64:
+ENTRY(pread64)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
     stmfd   sp!, {r4, r5, r6, r7}
@@ -18,4 +13,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(pread64)
diff --git a/libc/arch-arm/syscalls/pwrite64.S b/libc/arch-arm/syscalls/pwrite64.S
index f9d56b2..444d78f 100644
--- a/libc/arch-arm/syscalls/pwrite64.S
+++ b/libc/arch-arm/syscalls/pwrite64.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type pwrite64, #function
-    .globl pwrite64
-    .align 4
-    .fnstart
-
-pwrite64:
+ENTRY(pwrite64)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
     stmfd   sp!, {r4, r5, r6, r7}
@@ -18,4 +13,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(pwrite64)
diff --git a/libc/arch-arm/syscalls/read.S b/libc/arch-arm/syscalls/read.S
index da9d81c..c062388 100644
--- a/libc/arch-arm/syscalls/read.S
+++ b/libc/arch-arm/syscalls/read.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type read, #function
-    .globl read
-    .align 4
-    .fnstart
-
-read:
+ENTRY(read)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_read
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(read)
diff --git a/libc/arch-arm/syscalls/readlink.S b/libc/arch-arm/syscalls/readlink.S
index eb8ae8b..7602e61 100644
--- a/libc/arch-arm/syscalls/readlink.S
+++ b/libc/arch-arm/syscalls/readlink.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type readlink, #function
-    .globl readlink
-    .align 4
-    .fnstart
-
-readlink:
+ENTRY(readlink)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_readlink
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(readlink)
diff --git a/libc/arch-arm/syscalls/readv.S b/libc/arch-arm/syscalls/readv.S
index 045648f..e717e61 100644
--- a/libc/arch-arm/syscalls/readv.S
+++ b/libc/arch-arm/syscalls/readv.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type readv, #function
-    .globl readv
-    .align 4
-    .fnstart
-
-readv:
+ENTRY(readv)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_readv
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(readv)
diff --git a/libc/arch-arm/syscalls/recvfrom.S b/libc/arch-arm/syscalls/recvfrom.S
index 344b60d..df6302f 100644
--- a/libc/arch-arm/syscalls/recvfrom.S
+++ b/libc/arch-arm/syscalls/recvfrom.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type recvfrom, #function
-    .globl recvfrom
-    .align 4
-    .fnstart
-
-recvfrom:
+ENTRY(recvfrom)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
     stmfd   sp!, {r4, r5, r6, r7}
@@ -18,4 +13,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(recvfrom)
diff --git a/libc/arch-arm/syscalls/recvmsg.S b/libc/arch-arm/syscalls/recvmsg.S
index 0b4b1be..5c168dc 100644
--- a/libc/arch-arm/syscalls/recvmsg.S
+++ b/libc/arch-arm/syscalls/recvmsg.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type recvmsg, #function
-    .globl recvmsg
-    .align 4
-    .fnstart
-
-recvmsg:
+ENTRY(recvmsg)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_recvmsg
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(recvmsg)
diff --git a/libc/arch-arm/syscalls/rename.S b/libc/arch-arm/syscalls/rename.S
index 89f23b4..930ddb6 100644
--- a/libc/arch-arm/syscalls/rename.S
+++ b/libc/arch-arm/syscalls/rename.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type rename, #function
-    .globl rename
-    .align 4
-    .fnstart
-
-rename:
+ENTRY(rename)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_rename
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(rename)
diff --git a/libc/arch-arm/syscalls/renameat.S b/libc/arch-arm/syscalls/renameat.S
index 1807de7..a13c4ee 100644
--- a/libc/arch-arm/syscalls/renameat.S
+++ b/libc/arch-arm/syscalls/renameat.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type renameat, #function
-    .globl renameat
-    .align 4
-    .fnstart
-
-renameat:
+ENTRY(renameat)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_renameat
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(renameat)
diff --git a/libc/arch-arm/syscalls/rmdir.S b/libc/arch-arm/syscalls/rmdir.S
index ac2f4b7..09a956f 100644
--- a/libc/arch-arm/syscalls/rmdir.S
+++ b/libc/arch-arm/syscalls/rmdir.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type rmdir, #function
-    .globl rmdir
-    .align 4
-    .fnstart
-
-rmdir:
+ENTRY(rmdir)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_rmdir
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+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 e94ec93..2dea3b7 100644
--- a/libc/arch-arm/syscalls/sched_get_priority_max.S
+++ b/libc/arch-arm/syscalls/sched_get_priority_max.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_get_priority_max, #function
-    .globl sched_get_priority_max
-    .align 4
-    .fnstart
-
-sched_get_priority_max:
+ENTRY(sched_get_priority_max)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sched_get_priority_max
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+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 e2ae87e..de8b878 100644
--- a/libc/arch-arm/syscalls/sched_get_priority_min.S
+++ b/libc/arch-arm/syscalls/sched_get_priority_min.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_get_priority_min, #function
-    .globl sched_get_priority_min
-    .align 4
-    .fnstart
-
-sched_get_priority_min:
+ENTRY(sched_get_priority_min)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sched_get_priority_min
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sched_get_priority_min)
diff --git a/libc/arch-arm/syscalls/sched_getparam.S b/libc/arch-arm/syscalls/sched_getparam.S
index d9adddc..6434217 100644
--- a/libc/arch-arm/syscalls/sched_getparam.S
+++ b/libc/arch-arm/syscalls/sched_getparam.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_getparam, #function
-    .globl sched_getparam
-    .align 4
-    .fnstart
-
-sched_getparam:
+ENTRY(sched_getparam)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sched_getparam
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sched_getparam)
diff --git a/libc/arch-arm/syscalls/sched_getscheduler.S b/libc/arch-arm/syscalls/sched_getscheduler.S
index 2a070c1..8e45ce6 100644
--- a/libc/arch-arm/syscalls/sched_getscheduler.S
+++ b/libc/arch-arm/syscalls/sched_getscheduler.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_getscheduler, #function
-    .globl sched_getscheduler
-    .align 4
-    .fnstart
-
-sched_getscheduler:
+ENTRY(sched_getscheduler)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sched_getscheduler
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+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 7438953..e88d26e 100644
--- a/libc/arch-arm/syscalls/sched_rr_get_interval.S
+++ b/libc/arch-arm/syscalls/sched_rr_get_interval.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_rr_get_interval, #function
-    .globl sched_rr_get_interval
-    .align 4
-    .fnstart
-
-sched_rr_get_interval:
+ENTRY(sched_rr_get_interval)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sched_rr_get_interval
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sched_rr_get_interval)
diff --git a/libc/arch-arm/syscalls/sched_setaffinity.S b/libc/arch-arm/syscalls/sched_setaffinity.S
index aedf8f3..b9dd299 100644
--- a/libc/arch-arm/syscalls/sched_setaffinity.S
+++ b/libc/arch-arm/syscalls/sched_setaffinity.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_setaffinity, #function
-    .globl sched_setaffinity
-    .align 4
-    .fnstart
-
-sched_setaffinity:
+ENTRY(sched_setaffinity)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sched_setaffinity
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sched_setaffinity)
diff --git a/libc/arch-arm/syscalls/sched_setparam.S b/libc/arch-arm/syscalls/sched_setparam.S
index 6f7f92d..73d6ab6 100644
--- a/libc/arch-arm/syscalls/sched_setparam.S
+++ b/libc/arch-arm/syscalls/sched_setparam.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_setparam, #function
-    .globl sched_setparam
-    .align 4
-    .fnstart
-
-sched_setparam:
+ENTRY(sched_setparam)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sched_setparam
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sched_setparam)
diff --git a/libc/arch-arm/syscalls/sched_setscheduler.S b/libc/arch-arm/syscalls/sched_setscheduler.S
index 11667c7..33c28ab 100644
--- a/libc/arch-arm/syscalls/sched_setscheduler.S
+++ b/libc/arch-arm/syscalls/sched_setscheduler.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_setscheduler, #function
-    .globl sched_setscheduler
-    .align 4
-    .fnstart
-
-sched_setscheduler:
+ENTRY(sched_setscheduler)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sched_setscheduler
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sched_setscheduler)
diff --git a/libc/arch-arm/syscalls/sched_yield.S b/libc/arch-arm/syscalls/sched_yield.S
index 6ff0141..71628b3 100644
--- a/libc/arch-arm/syscalls/sched_yield.S
+++ b/libc/arch-arm/syscalls/sched_yield.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sched_yield, #function
-    .globl sched_yield
-    .align 4
-    .fnstart
-
-sched_yield:
+ENTRY(sched_yield)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sched_yield
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sched_yield)
diff --git a/libc/arch-arm/syscalls/select.S b/libc/arch-arm/syscalls/select.S
index 0a0ce5d..edd77a3 100644
--- a/libc/arch-arm/syscalls/select.S
+++ b/libc/arch-arm/syscalls/select.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type select, #function
-    .globl select
-    .align 4
-    .fnstart
-
-select:
+ENTRY(select)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
     stmfd   sp!, {r4, r5, r6, r7}
@@ -18,4 +13,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(select)
diff --git a/libc/arch-arm/syscalls/sendfile.S b/libc/arch-arm/syscalls/sendfile.S
index 0a1da4f..2790b4b 100644
--- a/libc/arch-arm/syscalls/sendfile.S
+++ b/libc/arch-arm/syscalls/sendfile.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sendfile, #function
-    .globl sendfile
-    .align 4
-    .fnstart
-
-sendfile:
+ENTRY(sendfile)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sendfile
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sendfile)
diff --git a/libc/arch-arm/syscalls/sendmsg.S b/libc/arch-arm/syscalls/sendmsg.S
index eac2d67..99b5479 100644
--- a/libc/arch-arm/syscalls/sendmsg.S
+++ b/libc/arch-arm/syscalls/sendmsg.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sendmsg, #function
-    .globl sendmsg
-    .align 4
-    .fnstart
-
-sendmsg:
+ENTRY(sendmsg)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sendmsg
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sendmsg)
diff --git a/libc/arch-arm/syscalls/sendto.S b/libc/arch-arm/syscalls/sendto.S
index 744891c..302ba8a 100644
--- a/libc/arch-arm/syscalls/sendto.S
+++ b/libc/arch-arm/syscalls/sendto.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sendto, #function
-    .globl sendto
-    .align 4
-    .fnstart
-
-sendto:
+ENTRY(sendto)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
     stmfd   sp!, {r4, r5, r6, r7}
@@ -18,4 +13,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sendto)
diff --git a/libc/arch-arm/syscalls/setgid.S b/libc/arch-arm/syscalls/setgid.S
index fdd4ee6..f28687d 100644
--- a/libc/arch-arm/syscalls/setgid.S
+++ b/libc/arch-arm/syscalls/setgid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setgid, #function
-    .globl setgid
-    .align 4
-    .fnstart
-
-setgid:
+ENTRY(setgid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_setgid32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(setgid)
diff --git a/libc/arch-arm/syscalls/setgroups.S b/libc/arch-arm/syscalls/setgroups.S
index cba9dfb..d2c932f 100644
--- a/libc/arch-arm/syscalls/setgroups.S
+++ b/libc/arch-arm/syscalls/setgroups.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setgroups, #function
-    .globl setgroups
-    .align 4
-    .fnstart
-
-setgroups:
+ENTRY(setgroups)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_setgroups32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(setgroups)
diff --git a/libc/arch-arm/syscalls/setitimer.S b/libc/arch-arm/syscalls/setitimer.S
index b4ad56c..c6b5064 100644
--- a/libc/arch-arm/syscalls/setitimer.S
+++ b/libc/arch-arm/syscalls/setitimer.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setitimer, #function
-    .globl setitimer
-    .align 4
-    .fnstart
-
-setitimer:
+ENTRY(setitimer)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_setitimer
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(setitimer)
diff --git a/libc/arch-arm/syscalls/setpgid.S b/libc/arch-arm/syscalls/setpgid.S
index 0ec98c6..39e1e03 100644
--- a/libc/arch-arm/syscalls/setpgid.S
+++ b/libc/arch-arm/syscalls/setpgid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setpgid, #function
-    .globl setpgid
-    .align 4
-    .fnstart
-
-setpgid:
+ENTRY(setpgid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_setpgid
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(setpgid)
diff --git a/libc/arch-arm/syscalls/setpriority.S b/libc/arch-arm/syscalls/setpriority.S
index fa4110a..5cb84a8 100644
--- a/libc/arch-arm/syscalls/setpriority.S
+++ b/libc/arch-arm/syscalls/setpriority.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setpriority, #function
-    .globl setpriority
-    .align 4
-    .fnstart
-
-setpriority:
+ENTRY(setpriority)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_setpriority
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(setpriority)
diff --git a/libc/arch-arm/syscalls/setregid.S b/libc/arch-arm/syscalls/setregid.S
index 53d9420..bc79e9e 100644
--- a/libc/arch-arm/syscalls/setregid.S
+++ b/libc/arch-arm/syscalls/setregid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setregid, #function
-    .globl setregid
-    .align 4
-    .fnstart
-
-setregid:
+ENTRY(setregid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_setregid32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(setregid)
diff --git a/libc/arch-arm/syscalls/setresgid.S b/libc/arch-arm/syscalls/setresgid.S
index 0382913..711626e 100644
--- a/libc/arch-arm/syscalls/setresgid.S
+++ b/libc/arch-arm/syscalls/setresgid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setresgid, #function
-    .globl setresgid
-    .align 4
-    .fnstart
-
-setresgid:
+ENTRY(setresgid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_setresgid32
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(setresgid)
diff --git a/libc/arch-arm/syscalls/setrlimit.S b/libc/arch-arm/syscalls/setrlimit.S
index 0a5de48..0fe2467 100644
--- a/libc/arch-arm/syscalls/setrlimit.S
+++ b/libc/arch-arm/syscalls/setrlimit.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setrlimit, #function
-    .globl setrlimit
-    .align 4
-    .fnstart
-
-setrlimit:
+ENTRY(setrlimit)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_setrlimit
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(setrlimit)
diff --git a/libc/arch-arm/syscalls/setsid.S b/libc/arch-arm/syscalls/setsid.S
index e2b0615..f11b6fb 100644
--- a/libc/arch-arm/syscalls/setsid.S
+++ b/libc/arch-arm/syscalls/setsid.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setsid, #function
-    .globl setsid
-    .align 4
-    .fnstart
-
-setsid:
+ENTRY(setsid)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_setsid
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(setsid)
diff --git a/libc/arch-arm/syscalls/setsockopt.S b/libc/arch-arm/syscalls/setsockopt.S
index 01f104f..7ca91dd 100644
--- a/libc/arch-arm/syscalls/setsockopt.S
+++ b/libc/arch-arm/syscalls/setsockopt.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type setsockopt, #function
-    .globl setsockopt
-    .align 4
-    .fnstart
-
-setsockopt:
+ENTRY(setsockopt)
     mov     ip, sp
     .save   {r4, r5, r6, r7}
     stmfd   sp!, {r4, r5, r6, r7}
@@ -18,4 +13,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(setsockopt)
diff --git a/libc/arch-arm/syscalls/settimeofday.S b/libc/arch-arm/syscalls/settimeofday.S
index 6f79041..2741e05 100644
--- a/libc/arch-arm/syscalls/settimeofday.S
+++ b/libc/arch-arm/syscalls/settimeofday.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type settimeofday, #function
-    .globl settimeofday
-    .align 4
-    .fnstart
-
-settimeofday:
+ENTRY(settimeofday)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_settimeofday
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(settimeofday)
diff --git a/libc/arch-arm/syscalls/shutdown.S b/libc/arch-arm/syscalls/shutdown.S
index 5bec030..0802631 100644
--- a/libc/arch-arm/syscalls/shutdown.S
+++ b/libc/arch-arm/syscalls/shutdown.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type shutdown, #function
-    .globl shutdown
-    .align 4
-    .fnstart
-
-shutdown:
+ENTRY(shutdown)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_shutdown
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(shutdown)
diff --git a/libc/arch-arm/syscalls/sigaction.S b/libc/arch-arm/syscalls/sigaction.S
index 2696f1e..04a8b94 100644
--- a/libc/arch-arm/syscalls/sigaction.S
+++ b/libc/arch-arm/syscalls/sigaction.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sigaction, #function
-    .globl sigaction
-    .align 4
-    .fnstart
-
-sigaction:
+ENTRY(sigaction)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sigaction
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sigaction)
diff --git a/libc/arch-arm/syscalls/sigaltstack.S b/libc/arch-arm/syscalls/sigaltstack.S
index 3625d0b..b541a87 100644
--- a/libc/arch-arm/syscalls/sigaltstack.S
+++ b/libc/arch-arm/syscalls/sigaltstack.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sigaltstack, #function
-    .globl sigaltstack
-    .align 4
-    .fnstart
-
-sigaltstack:
+ENTRY(sigaltstack)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sigaltstack
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sigaltstack)
diff --git a/libc/arch-arm/syscalls/sigpending.S b/libc/arch-arm/syscalls/sigpending.S
index 58f565a..4c7d919 100644
--- a/libc/arch-arm/syscalls/sigpending.S
+++ b/libc/arch-arm/syscalls/sigpending.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sigpending, #function
-    .globl sigpending
-    .align 4
-    .fnstart
-
-sigpending:
+ENTRY(sigpending)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sigpending
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sigpending)
diff --git a/libc/arch-arm/syscalls/sigprocmask.S b/libc/arch-arm/syscalls/sigprocmask.S
index f157d76..7c59a6b 100644
--- a/libc/arch-arm/syscalls/sigprocmask.S
+++ b/libc/arch-arm/syscalls/sigprocmask.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sigprocmask, #function
-    .globl sigprocmask
-    .align 4
-    .fnstart
-
-sigprocmask:
+ENTRY(sigprocmask)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sigprocmask
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sigprocmask)
diff --git a/libc/arch-arm/syscalls/socket.S b/libc/arch-arm/syscalls/socket.S
index 93c9a53..e28d252 100644
--- a/libc/arch-arm/syscalls/socket.S
+++ b/libc/arch-arm/syscalls/socket.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type socket, #function
-    .globl socket
-    .align 4
-    .fnstart
-
-socket:
+ENTRY(socket)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_socket
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(socket)
diff --git a/libc/arch-arm/syscalls/socketpair.S b/libc/arch-arm/syscalls/socketpair.S
index 1bf07d6..e699000 100644
--- a/libc/arch-arm/syscalls/socketpair.S
+++ b/libc/arch-arm/syscalls/socketpair.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type socketpair, #function
-    .globl socketpair
-    .align 4
-    .fnstart
-
-socketpair:
+ENTRY(socketpair)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_socketpair
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(socketpair)
diff --git a/libc/arch-arm/syscalls/stat.S b/libc/arch-arm/syscalls/stat.S
index 46afcc5..a4669a6 100644
--- a/libc/arch-arm/syscalls/stat.S
+++ b/libc/arch-arm/syscalls/stat.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type stat, #function
-    .globl stat
-    .align 4
-    .fnstart
-
-stat:
+ENTRY(stat)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_stat64
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(stat)
diff --git a/libc/arch-arm/syscalls/symlink.S b/libc/arch-arm/syscalls/symlink.S
index 83b554e..14a753f 100644
--- a/libc/arch-arm/syscalls/symlink.S
+++ b/libc/arch-arm/syscalls/symlink.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type symlink, #function
-    .globl symlink
-    .align 4
-    .fnstart
-
-symlink:
+ENTRY(symlink)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_symlink
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(symlink)
diff --git a/libc/arch-arm/syscalls/sync.S b/libc/arch-arm/syscalls/sync.S
index 778d38e..68c0c0f 100644
--- a/libc/arch-arm/syscalls/sync.S
+++ b/libc/arch-arm/syscalls/sync.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sync, #function
-    .globl sync
-    .align 4
-    .fnstart
-
-sync:
+ENTRY(sync)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sync
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sync)
diff --git a/libc/arch-arm/syscalls/sysinfo.S b/libc/arch-arm/syscalls/sysinfo.S
index 197324d..2a2fb59 100644
--- a/libc/arch-arm/syscalls/sysinfo.S
+++ b/libc/arch-arm/syscalls/sysinfo.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type sysinfo, #function
-    .globl sysinfo
-    .align 4
-    .fnstart
-
-sysinfo:
+ENTRY(sysinfo)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_sysinfo
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(sysinfo)
diff --git a/libc/arch-arm/syscalls/times.S b/libc/arch-arm/syscalls/times.S
index c1ab0ce..aacb4ca 100644
--- a/libc/arch-arm/syscalls/times.S
+++ b/libc/arch-arm/syscalls/times.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type times, #function
-    .globl times
-    .align 4
-    .fnstart
-
-times:
+ENTRY(times)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_times
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(times)
diff --git a/libc/arch-arm/syscalls/truncate.S b/libc/arch-arm/syscalls/truncate.S
index 674c828..8c0b24f 100644
--- a/libc/arch-arm/syscalls/truncate.S
+++ b/libc/arch-arm/syscalls/truncate.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type truncate, #function
-    .globl truncate
-    .align 4
-    .fnstart
-
-truncate:
+ENTRY(truncate)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_truncate
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(truncate)
diff --git a/libc/arch-arm/syscalls/umask.S b/libc/arch-arm/syscalls/umask.S
index 6f18259..a7bc20b 100644
--- a/libc/arch-arm/syscalls/umask.S
+++ b/libc/arch-arm/syscalls/umask.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type umask, #function
-    .globl umask
-    .align 4
-    .fnstart
-
-umask:
+ENTRY(umask)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_umask
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(umask)
diff --git a/libc/arch-arm/syscalls/umount2.S b/libc/arch-arm/syscalls/umount2.S
index 659c3c0..04b28f4 100644
--- a/libc/arch-arm/syscalls/umount2.S
+++ b/libc/arch-arm/syscalls/umount2.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type umount2, #function
-    .globl umount2
-    .align 4
-    .fnstart
-
-umount2:
+ENTRY(umount2)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_umount2
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(umount2)
diff --git a/libc/arch-arm/syscalls/uname.S b/libc/arch-arm/syscalls/uname.S
index fda05e9..4a6f0f4 100644
--- a/libc/arch-arm/syscalls/uname.S
+++ b/libc/arch-arm/syscalls/uname.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type uname, #function
-    .globl uname
-    .align 4
-    .fnstart
-
-uname:
+ENTRY(uname)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_uname
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(uname)
diff --git a/libc/arch-arm/syscalls/unlink.S b/libc/arch-arm/syscalls/unlink.S
index 77ae9b7..87fa79e 100644
--- a/libc/arch-arm/syscalls/unlink.S
+++ b/libc/arch-arm/syscalls/unlink.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type unlink, #function
-    .globl unlink
-    .align 4
-    .fnstart
-
-unlink:
+ENTRY(unlink)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_unlink
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(unlink)
diff --git a/libc/arch-arm/syscalls/unlinkat.S b/libc/arch-arm/syscalls/unlinkat.S
index eb31e85..3beae6c 100644
--- a/libc/arch-arm/syscalls/unlinkat.S
+++ b/libc/arch-arm/syscalls/unlinkat.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type unlinkat, #function
-    .globl unlinkat
-    .align 4
-    .fnstart
-
-unlinkat:
+ENTRY(unlinkat)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_unlinkat
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(unlinkat)
diff --git a/libc/arch-arm/syscalls/utimes.S b/libc/arch-arm/syscalls/utimes.S
index 19fe8e2..a2d58a3 100644
--- a/libc/arch-arm/syscalls/utimes.S
+++ b/libc/arch-arm/syscalls/utimes.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type utimes, #function
-    .globl utimes
-    .align 4
-    .fnstart
-
-utimes:
+ENTRY(utimes)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_utimes
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(utimes)
diff --git a/libc/arch-arm/syscalls/vfork.S b/libc/arch-arm/syscalls/vfork.S
index e141761..3bd2668 100644
--- a/libc/arch-arm/syscalls/vfork.S
+++ b/libc/arch-arm/syscalls/vfork.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type vfork, #function
-    .globl vfork
-    .align 4
-    .fnstart
-
-vfork:
+ENTRY(vfork)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_vfork
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(vfork)
diff --git a/libc/arch-arm/syscalls/write.S b/libc/arch-arm/syscalls/write.S
index 06df33d..826e82c 100644
--- a/libc/arch-arm/syscalls/write.S
+++ b/libc/arch-arm/syscalls/write.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type write, #function
-    .globl write
-    .align 4
-    .fnstart
-
-write:
+ENTRY(write)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_write
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(write)
diff --git a/libc/arch-arm/syscalls/writev.S b/libc/arch-arm/syscalls/writev.S
index a6b04db..16a6df9 100644
--- a/libc/arch-arm/syscalls/writev.S
+++ b/libc/arch-arm/syscalls/writev.S
@@ -1,13 +1,8 @@
 /* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type writev, #function
-    .globl writev
-    .align 4
-    .fnstart
-
-writev:
+ENTRY(writev)
     .save   {r4, r7}
     stmfd   sp!, {r4, r7}
     ldr     r7, =__NR_writev
@@ -16,4 +11,4 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
+END(writev)
diff --git a/libc/arch-sh/syscalls/__socketcall.S b/libc/arch-sh/syscalls/__socketcall.S
index 864e9aa..7c705bb 100644
--- a/libc/arch-sh/syscalls/__socketcall.S
+++ b/libc/arch-sh/syscalls/__socketcall.S
@@ -14,7 +14,7 @@
 
     /* check return value */
     cmp/pz  r0
-    bt      __NR___socketcall_end
+    bt      __NR_socketcall_end
 
     /* keep error number */
     sts.l   pr, @-r15
@@ -23,10 +23,10 @@
     mov     r0, r4
     lds.l   @r15+, pr
 
-__NR___socketcall_end:
+__NR_socketcall_end:
     rts
     nop
 
     .align  2
-0:  .long   __NR___socketcall
+0:  .long   __NR_socketcall
 1:  .long   __set_syscall_errno
diff --git a/libc/bionic/md5.c b/libc/bionic/md5.c
index 087786f..1117c3b 100644
--- a/libc/bionic/md5.c
+++ b/libc/bionic/md5.c
@@ -237,7 +237,7 @@
 void
 MD5_Final (void *res, struct md5 *m)
 {
-  static unsigned char zeros[72];
+  unsigned char zeros[72];
   unsigned offset = (m->sz[0] / 8) % 64;
   unsigned int dstart = (120 - offset - 1) % 64 + 1;
 
diff --git a/libc/bionic/memmove_words.c b/libc/bionic/memmove_words.c
new file mode 100644
index 0000000..22058bc
--- /dev/null
+++ b/libc/bionic/memmove_words.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2011 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 <stdlib.h>
+#include <assert.h>
+
+/*
+ * Works like memmove(), except:
+ * - if all arguments are at least 32-bit aligned, we guarantee that we
+ *   will use operations that preserve atomicity of 32-bit values
+ * - if not, we guarantee atomicity of 16-bit values
+ *
+ * If all three arguments are not at least 16-bit aligned, the behavior
+ * of this function is undefined.  (We could remove this restriction by
+ * testing for unaligned values and punting to memmove(), but that's
+ * not currently useful.)
+ *
+ * TODO: add loop for 64-bit alignment
+ * TODO: use __builtin_prefetch
+ * TODO: write an ARM-optimized version
+ */
+void _memmove_words(void* dest, const void* src, size_t n)
+{
+    assert((((uintptr_t) dest | (uintptr_t) src | n) & 0x01) == 0);
+
+    char* d = (char*) dest;
+    const char* s = (const char*) src;
+    size_t copyCount;
+
+    /*
+     * If the source and destination pointers are the same, this is
+     * an expensive no-op.  Testing for an empty move now allows us
+     * to skip a check later.
+     */
+    if (n == 0 || d == s)
+        return;
+
+    /*
+     * Determine if the source and destination buffers will overlap if
+     * we copy data forward (i.e. *dest++ = *src++).
+     *
+     * It's okay if the destination buffer starts before the source and
+     * there is some overlap, because the reader is always ahead of the
+     * writer.
+     */
+    if (__builtin_expect((d < s) || ((size_t)(d - s) >= n), 1)) {
+        /*
+         * Copy forward.  We prefer 32-bit loads and stores even for 16-bit
+         * data, so sort that out.
+         */
+        if ((((uintptr_t) d | (uintptr_t) s) & 0x03) != 0) {
+            /*
+             * Not 32-bit aligned.  Two possibilities:
+             * (1) Congruent, we can align to 32-bit by copying one 16-bit val
+             * (2) Non-congruent, we can do one of:
+             *   a. copy whole buffer as a series of 16-bit values
+             *   b. load/store 32 bits, using shifts to ensure alignment
+             *   c. just copy the as 32-bit values and assume the CPU
+             *      will do a reasonable job
+             *
+             * We're currently using (a), which is suboptimal.
+             */
+            if ((((uintptr_t) d ^ (uintptr_t) s) & 0x03) != 0) {
+                copyCount = n;
+            } else {
+                copyCount = 2;
+            }
+            n -= copyCount;
+            copyCount /= sizeof(uint16_t);
+
+            while (copyCount--) {
+                *(uint16_t*)d = *(uint16_t*)s;
+                d += sizeof(uint16_t);
+                s += sizeof(uint16_t);
+            }
+        }
+
+        /*
+         * Copy 32-bit aligned words.
+         */
+        copyCount = n / sizeof(uint32_t);
+        while (copyCount--) {
+            *(uint32_t*)d = *(uint32_t*)s;
+            d += sizeof(uint32_t);
+            s += sizeof(uint32_t);
+        }
+
+        /*
+         * Check for leftovers.  Either we finished exactly, or we have
+         * one remaining 16-bit chunk.
+         */
+        if ((n & 0x02) != 0) {
+            *(uint16_t*)d = *(uint16_t*)s;
+        }
+    } else {
+        /*
+         * Copy backward, starting at the end.
+         */
+        d += n;
+        s += n;
+
+        if ((((uintptr_t) d | (uintptr_t) s) & 0x03) != 0) {
+            /* try for 32-bit alignment */
+            if ((((uintptr_t) d ^ (uintptr_t) s) & 0x03) != 0) {
+                copyCount = n;
+            } else {
+                copyCount = 2;
+            }
+            n -= copyCount;
+            copyCount /= sizeof(uint16_t);
+
+            while (copyCount--) {
+                d -= sizeof(uint16_t);
+                s -= sizeof(uint16_t);
+                *(uint16_t*)d = *(uint16_t*)s;
+            }
+        }
+
+        /* copy 32-bit aligned words */
+        copyCount = n / sizeof(uint32_t);
+        while (copyCount--) {
+            d -= sizeof(uint32_t);
+            s -= sizeof(uint32_t);
+            *(uint32_t*)d = *(uint32_t*)s;
+        }
+
+        /* copy leftovers */
+        if ((n & 0x02) != 0) {
+            d -= sizeof(uint16_t);
+            s -= sizeof(uint16_t);
+            *(uint16_t*)d = *(uint16_t*)s;
+        }
+    }
+}
diff --git a/libc/include/netinet/icmp6.h b/libc/include/netinet/icmp6.h
new file mode 100644
index 0000000..fbc8234
--- /dev/null
+++ b/libc/include/netinet/icmp6.h
@@ -0,0 +1,730 @@
+/*	$NetBSD: icmp6.h,v 1.40 2009/10/31 22:32:17 christos Exp $	*/
+/*	$KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $	*/
+
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE 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:
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. 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.
+ *
+ *	@(#)ip_icmp.h	8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_ICMP6_H_
+#define _NETINET_ICMP6_H_
+
+#define ICMPV6_PLD_MAXLEN	1232	/* IPV6_MMTU - sizeof(struct ip6_hdr)
+					   - sizeof(struct icmp6_hdr) */
+
+struct icmp6_hdr {
+	u_int8_t	icmp6_type;	/* type field */
+	u_int8_t	icmp6_code;	/* code field */
+	u_int16_t	icmp6_cksum;	/* checksum field */
+	union {
+		u_int32_t	icmp6_un_data32[1]; /* type-specific field */
+		u_int16_t	icmp6_un_data16[2]; /* type-specific field */
+		u_int8_t	icmp6_un_data8[4];  /* type-specific field */
+	} icmp6_dataun;
+} __packed;
+
+#define icmp6_data32	icmp6_dataun.icmp6_un_data32
+#define icmp6_data16	icmp6_dataun.icmp6_un_data16
+#define icmp6_data8	icmp6_dataun.icmp6_un_data8
+#define icmp6_pptr	icmp6_data32[0]		/* parameter prob */
+#define icmp6_mtu	icmp6_data32[0]		/* packet too big */
+#define icmp6_id	icmp6_data16[0]		/* echo request/reply */
+#define icmp6_seq	icmp6_data16[1]		/* echo request/reply */
+#define icmp6_maxdelay	icmp6_data16[0]		/* mcast group membership */
+
+#define ICMP6_DST_UNREACH		1	/* dest unreachable, codes: */
+#define ICMP6_PACKET_TOO_BIG		2	/* packet too big */
+#define ICMP6_TIME_EXCEEDED		3	/* time exceeded, code: */
+#define ICMP6_PARAM_PROB		4	/* ip6 header bad */
+
+#define ICMP6_ECHO_REQUEST		128	/* echo service */
+#define ICMP6_ECHO_REPLY		129	/* echo reply */
+#define MLD_LISTENER_QUERY		130 	/* multicast listener query */
+#define MLD_LISTENER_REPORT		131	/* multicast listener report */
+#define MLD_LISTENER_DONE		132	/* multicast listener done */
+
+/* RFC2292 decls */
+#define ICMP6_MEMBERSHIP_QUERY		130	/* group membership query */
+#define ICMP6_MEMBERSHIP_REPORT		131	/* group membership report */
+#define ICMP6_MEMBERSHIP_REDUCTION	132	/* group membership termination */
+
+#ifndef _KERNEL
+/* the followings are for backward compatibility to old KAME apps. */
+#define MLD6_LISTENER_QUERY	MLD_LISTENER_QUERY
+#define MLD6_LISTENER_REPORT	MLD_LISTENER_REPORT
+#define MLD6_LISTENER_DONE	MLD_LISTENER_DONE
+#endif
+
+#define ND_ROUTER_SOLICIT		133	/* router solicitation */
+#define ND_ROUTER_ADVERT		134	/* router advertisement */
+#define ND_NEIGHBOR_SOLICIT		135	/* neighbor solicitation */
+#define ND_NEIGHBOR_ADVERT		136	/* neighbor advertisement */
+#define ND_REDIRECT			137	/* redirect */
+
+#define ICMP6_ROUTER_RENUMBERING	138	/* router renumbering */
+
+#define ICMP6_WRUREQUEST		139	/* who are you request */
+#define ICMP6_WRUREPLY			140	/* who are you reply */
+#define ICMP6_FQDN_QUERY		139	/* FQDN query */
+#define ICMP6_FQDN_REPLY		140	/* FQDN reply */
+#define ICMP6_NI_QUERY			139	/* node information request */
+#define ICMP6_NI_REPLY			140	/* node information reply */
+
+/* The definitions below are experimental. TBA */
+#define MLD_MTRACE_RESP			200	/* mtrace response(to sender) */
+#define MLD_MTRACE			201	/* mtrace messages */
+
+#ifndef _KERNEL
+/* the followings are for backward compatibility to old KAME apps. */
+#define MLD6_MTRACE_RESP	MLD_MTRACE_RESP
+#define MLD6_MTRACE		MLD_MTRACE
+#endif
+
+#define ICMP6_MAXTYPE			201
+
+#define ICMP6_DST_UNREACH_NOROUTE	0	/* no route to destination */
+#define ICMP6_DST_UNREACH_ADMIN	 	1	/* administratively prohibited */
+#define ICMP6_DST_UNREACH_NOTNEIGHBOR	2	/* not a neighbor(obsolete) */
+#define ICMP6_DST_UNREACH_BEYONDSCOPE	2	/* beyond scope of source address */
+#define ICMP6_DST_UNREACH_ADDR		3	/* address unreachable */
+#define ICMP6_DST_UNREACH_NOPORT	4	/* port unreachable */
+
+#define ICMP6_TIME_EXCEED_TRANSIT 	0	/* ttl==0 in transit */
+#define ICMP6_TIME_EXCEED_REASSEMBLY	1	/* ttl==0 in reass */
+
+#define ICMP6_PARAMPROB_HEADER 	 	0	/* erroneous header field */
+#define ICMP6_PARAMPROB_NEXTHEADER	1	/* unrecognized next header */
+#define ICMP6_PARAMPROB_OPTION		2	/* unrecognized option */
+
+#define ICMP6_INFOMSG_MASK		0x80	/* all informational messages */
+
+#define ICMP6_NI_SUBJ_IPV6	0	/* Query Subject is an IPv6 address */
+#define ICMP6_NI_SUBJ_FQDN	1	/* Query Subject is a Domain name */
+#define ICMP6_NI_SUBJ_IPV4	2	/* Query Subject is an IPv4 address */
+
+#define ICMP6_NI_SUCCESS	0	/* node information successful reply */
+#define ICMP6_NI_REFUSED	1	/* node information request is refused */
+#define ICMP6_NI_UNKNOWN	2	/* unknown Qtype */
+
+#define ICMP6_ROUTER_RENUMBERING_COMMAND  0	/* rr command */
+#define ICMP6_ROUTER_RENUMBERING_RESULT   1	/* rr result */
+#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET   255	/* rr seq num reset */
+
+/* Used in kernel only */
+#define ND_REDIRECT_ONLINK	0	/* redirect to an on-link node */
+#define ND_REDIRECT_ROUTER	1	/* redirect to a better router */
+
+/*
+ * Multicast Listener Discovery
+ */
+struct mld_hdr {
+	struct icmp6_hdr	mld_icmp6_hdr;
+	struct in6_addr		mld_addr; /* multicast address */
+} __packed;
+
+/* definitions to provide backward compatibility to old KAME applications */
+#ifndef _KERNEL
+#define mld6_hdr	mld_hdr
+#define mld6_type	mld_type
+#define mld6_code	mld_code
+#define mld6_cksum	mld_cksum
+#define mld6_maxdelay	mld_maxdelay
+#define mld6_reserved	mld_reserved
+#define mld6_addr	mld_addr
+#endif
+
+/* shortcut macro definitions */
+#define mld_type	mld_icmp6_hdr.icmp6_type
+#define mld_code	mld_icmp6_hdr.icmp6_code
+#define mld_cksum	mld_icmp6_hdr.icmp6_cksum
+#define mld_maxdelay	mld_icmp6_hdr.icmp6_data16[0]
+#define mld_reserved	mld_icmp6_hdr.icmp6_data16[1]
+
+#define MLD_MINLEN			24
+
+/*
+ * Neighbor Discovery
+ */
+
+struct nd_router_solicit {	/* router solicitation */
+	struct icmp6_hdr 	nd_rs_hdr;
+	/* could be followed by options */
+} __packed;
+
+#define nd_rs_type	nd_rs_hdr.icmp6_type
+#define nd_rs_code	nd_rs_hdr.icmp6_code
+#define nd_rs_cksum	nd_rs_hdr.icmp6_cksum
+#define nd_rs_reserved	nd_rs_hdr.icmp6_data32[0]
+
+struct nd_router_advert {	/* router advertisement */
+	struct icmp6_hdr	nd_ra_hdr;
+	u_int32_t		nd_ra_reachable;	/* reachable time */
+	u_int32_t		nd_ra_retransmit;	/* retransmit timer */
+	/* could be followed by options */
+} __packed;
+
+#define nd_ra_type		nd_ra_hdr.icmp6_type
+#define nd_ra_code		nd_ra_hdr.icmp6_code
+#define nd_ra_cksum		nd_ra_hdr.icmp6_cksum
+#define nd_ra_curhoplimit	nd_ra_hdr.icmp6_data8[0]
+#define nd_ra_flags_reserved	nd_ra_hdr.icmp6_data8[1]
+#define ND_RA_FLAG_MANAGED	0x80
+#define ND_RA_FLAG_OTHER	0x40
+#define ND_RA_FLAG_HOME_AGENT	0x20
+
+/*
+ * Router preference values based on RFC4199.
+ */
+#define ND_RA_FLAG_RTPREF_MASK	0x18 /* 00011000 */
+
+#define ND_RA_FLAG_RTPREF_HIGH	0x08 /* 00001000 */
+#define ND_RA_FLAG_RTPREF_MEDIUM	0x00 /* 00000000 */
+#define ND_RA_FLAG_RTPREF_LOW	0x18 /* 00011000 */
+#define ND_RA_FLAG_RTPREF_RSV	0x10 /* 00010000 */
+
+#define nd_ra_router_lifetime	nd_ra_hdr.icmp6_data16[1]
+
+struct nd_neighbor_solicit {	/* neighbor solicitation */
+	struct icmp6_hdr	nd_ns_hdr;
+	struct in6_addr		nd_ns_target;	/*target address */
+	/* could be followed by options */
+} __packed;
+
+#define nd_ns_type		nd_ns_hdr.icmp6_type
+#define nd_ns_code		nd_ns_hdr.icmp6_code
+#define nd_ns_cksum		nd_ns_hdr.icmp6_cksum
+#define nd_ns_reserved		nd_ns_hdr.icmp6_data32[0]
+
+struct nd_neighbor_advert {	/* neighbor advertisement */
+	struct icmp6_hdr	nd_na_hdr;
+	struct in6_addr		nd_na_target;	/* target address */
+	/* could be followed by options */
+} __packed;
+
+#define nd_na_type		nd_na_hdr.icmp6_type
+#define nd_na_code		nd_na_hdr.icmp6_code
+#define nd_na_cksum		nd_na_hdr.icmp6_cksum
+#define nd_na_flags_reserved	nd_na_hdr.icmp6_data32[0]
+#if BYTE_ORDER == BIG_ENDIAN
+#define ND_NA_FLAG_ROUTER		0x80000000
+#define ND_NA_FLAG_SOLICITED		0x40000000
+#define ND_NA_FLAG_OVERRIDE		0x20000000
+#else
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define ND_NA_FLAG_ROUTER		0x80
+#define ND_NA_FLAG_SOLICITED		0x40
+#define ND_NA_FLAG_OVERRIDE		0x20
+#endif
+#endif
+
+struct nd_redirect {		/* redirect */
+	struct icmp6_hdr	nd_rd_hdr;
+	struct in6_addr		nd_rd_target;	/* target address */
+	struct in6_addr		nd_rd_dst;	/* destination address */
+	/* could be followed by options */
+} __packed;
+
+#define nd_rd_type		nd_rd_hdr.icmp6_type
+#define nd_rd_code		nd_rd_hdr.icmp6_code
+#define nd_rd_cksum		nd_rd_hdr.icmp6_cksum
+#define nd_rd_reserved		nd_rd_hdr.icmp6_data32[0]
+
+struct nd_opt_hdr {		/* Neighbor discovery option header */
+	u_int8_t	nd_opt_type;
+	u_int8_t	nd_opt_len;
+	/* followed by option specific data*/
+} __packed;
+
+#define ND_OPT_SOURCE_LINKADDR		1
+#define ND_OPT_TARGET_LINKADDR		2
+#define ND_OPT_PREFIX_INFORMATION	3
+#define ND_OPT_REDIRECTED_HEADER	4
+#define ND_OPT_MTU			5
+#define ND_OPT_ADVINTERVAL		7
+#define ND_OPT_HOMEAGENT_INFO		8
+#define ND_OPT_SOURCE_ADDRLIST		9
+#define ND_OPT_TARGET_ADDRLIST		10
+#define ND_OPT_RDNSS			25
+/* draft-ietf-ipngwg-router-preference, not officially assigned yet */
+#define ND_OPT_ROUTE_INFO		200
+/* draft-ietf-mobileip-hmipv6, not officially assigned yet */
+#define ND_OPT_MAP			201
+
+struct nd_opt_route_info {	/* route info */
+	u_int8_t	nd_opt_rti_type;
+	u_int8_t	nd_opt_rti_len;
+	u_int8_t	nd_opt_rti_prefixlen;
+	u_int8_t	nd_opt_rti_flags;
+	u_int32_t	nd_opt_rti_lifetime;
+	/* prefix follows */
+};
+
+struct nd_opt_prefix_info {	/* prefix information */
+	u_int8_t	nd_opt_pi_type;
+	u_int8_t	nd_opt_pi_len;
+	u_int8_t	nd_opt_pi_prefix_len;
+	u_int8_t	nd_opt_pi_flags_reserved;
+	u_int32_t	nd_opt_pi_valid_time;
+	u_int32_t	nd_opt_pi_preferred_time;
+	u_int32_t	nd_opt_pi_reserved2;
+	struct in6_addr	nd_opt_pi_prefix;
+} __packed;
+
+#define ND_OPT_PI_FLAG_ONLINK		0x80
+#define ND_OPT_PI_FLAG_AUTO		0x40
+
+struct nd_opt_rd_hdr {		/* redirected header */
+	u_int8_t	nd_opt_rh_type;
+	u_int8_t	nd_opt_rh_len;
+	u_int16_t	nd_opt_rh_reserved1;
+	u_int32_t	nd_opt_rh_reserved2;
+	/* followed by IP header and data */
+} __packed;
+
+struct nd_opt_mtu {		/* MTU option */
+	u_int8_t	nd_opt_mtu_type;
+	u_int8_t	nd_opt_mtu_len;
+	u_int16_t	nd_opt_mtu_reserved;
+	u_int32_t	nd_opt_mtu_mtu;
+} __packed;
+
+struct nd_opt_rdnss {		/* RDNSS option RFC 5006 */
+	u_int8_t	nd_opt_rdnss_type;
+	u_int8_t	nd_opt_rdnss_len;
+	u_int16_t	nd_opt_rdnss_reserved;
+	u_int32_t	nd_opt_rdnss_lifetime;
+	/* followed by list of IP prefixes */
+} __packed;
+
+/*
+ * icmp6 namelookup
+ */
+
+struct icmp6_namelookup {
+	struct icmp6_hdr 	icmp6_nl_hdr;
+	u_int8_t	icmp6_nl_nonce[8];
+	int32_t		icmp6_nl_ttl;
+#if 0
+	u_int8_t	icmp6_nl_len;
+	u_int8_t	icmp6_nl_name[3];
+#endif
+	/* could be followed by options */
+} __packed;
+
+/*
+ * icmp6 node information
+ */
+struct icmp6_nodeinfo {
+	struct icmp6_hdr icmp6_ni_hdr;
+	u_int8_t icmp6_ni_nonce[8];
+	/* could be followed by reply data */
+} __packed;
+
+#define ni_type		icmp6_ni_hdr.icmp6_type
+#define ni_code		icmp6_ni_hdr.icmp6_code
+#define ni_cksum	icmp6_ni_hdr.icmp6_cksum
+#define ni_qtype	icmp6_ni_hdr.icmp6_data16[0]
+#define ni_flags	icmp6_ni_hdr.icmp6_data16[1]
+
+#define NI_QTYPE_NOOP		0 /* NOOP  */
+#define NI_QTYPE_SUPTYPES	1 /* Supported Qtypes */
+#define NI_QTYPE_FQDN		2 /* FQDN (draft 04) */
+#define NI_QTYPE_DNSNAME	2 /* DNS Name */
+#define NI_QTYPE_NODEADDR	3 /* Node Addresses */
+#define NI_QTYPE_IPV4ADDR	4 /* IPv4 Addresses */
+
+#if BYTE_ORDER == BIG_ENDIAN
+#define NI_SUPTYPE_FLAG_COMPRESS	0x1
+#define NI_FQDN_FLAG_VALIDTTL		0x1
+#elif BYTE_ORDER == LITTLE_ENDIAN
+#define NI_SUPTYPE_FLAG_COMPRESS	0x0100
+#define NI_FQDN_FLAG_VALIDTTL		0x0100
+#endif
+
+#ifdef NAME_LOOKUPS_04
+#if BYTE_ORDER == BIG_ENDIAN
+#define NI_NODEADDR_FLAG_LINKLOCAL	0x1
+#define NI_NODEADDR_FLAG_SITELOCAL	0x2
+#define NI_NODEADDR_FLAG_GLOBAL		0x4
+#define NI_NODEADDR_FLAG_ALL		0x8
+#define NI_NODEADDR_FLAG_TRUNCATE	0x10
+#define NI_NODEADDR_FLAG_ANYCAST	0x20 /* just experimental. not in spec */
+#elif BYTE_ORDER == LITTLE_ENDIAN
+#define NI_NODEADDR_FLAG_LINKLOCAL	0x0100
+#define NI_NODEADDR_FLAG_SITELOCAL	0x0200
+#define NI_NODEADDR_FLAG_GLOBAL		0x0400
+#define NI_NODEADDR_FLAG_ALL		0x0800
+#define NI_NODEADDR_FLAG_TRUNCATE	0x1000
+#define NI_NODEADDR_FLAG_ANYCAST	0x2000 /* just experimental. not in spec */
+#endif
+#else  /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
+#if BYTE_ORDER == BIG_ENDIAN
+#define NI_NODEADDR_FLAG_TRUNCATE	0x1
+#define NI_NODEADDR_FLAG_ALL		0x2
+#define NI_NODEADDR_FLAG_COMPAT		0x4
+#define NI_NODEADDR_FLAG_LINKLOCAL	0x8
+#define NI_NODEADDR_FLAG_SITELOCAL	0x10
+#define NI_NODEADDR_FLAG_GLOBAL		0x20
+#define NI_NODEADDR_FLAG_ANYCAST	0x40 /* just experimental. not in spec */
+#elif BYTE_ORDER == LITTLE_ENDIAN
+#define NI_NODEADDR_FLAG_TRUNCATE	0x0100
+#define NI_NODEADDR_FLAG_ALL		0x0200
+#define NI_NODEADDR_FLAG_COMPAT		0x0400
+#define NI_NODEADDR_FLAG_LINKLOCAL	0x0800
+#define NI_NODEADDR_FLAG_SITELOCAL	0x1000
+#define NI_NODEADDR_FLAG_GLOBAL		0x2000
+#define NI_NODEADDR_FLAG_ANYCAST	0x4000 /* just experimental. not in spec */
+#endif
+#endif
+
+struct ni_reply_fqdn {
+	u_int32_t ni_fqdn_ttl;	/* TTL */
+	u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
+	u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
+} __packed;
+
+/*
+ * Router Renumbering. as router-renum-08.txt
+ */
+struct icmp6_router_renum {	/* router renumbering header */
+	struct icmp6_hdr	rr_hdr;
+	u_int8_t	rr_segnum;
+	u_int8_t	rr_flags;
+	u_int16_t	rr_maxdelay;
+	u_int32_t	rr_reserved;
+} __packed;
+
+#define ICMP6_RR_FLAGS_TEST		0x80
+#define ICMP6_RR_FLAGS_REQRESULT	0x40
+#define ICMP6_RR_FLAGS_FORCEAPPLY	0x20
+#define ICMP6_RR_FLAGS_SPECSITE		0x10
+#define ICMP6_RR_FLAGS_PREVDONE		0x08
+
+#define rr_type		rr_hdr.icmp6_type
+#define rr_code		rr_hdr.icmp6_code
+#define rr_cksum	rr_hdr.icmp6_cksum
+#define rr_seqnum 	rr_hdr.icmp6_data32[0]
+
+struct rr_pco_match {		/* match prefix part */
+	u_int8_t	rpm_code;
+	u_int8_t	rpm_len;
+	u_int8_t	rpm_ordinal;
+	u_int8_t	rpm_matchlen;
+	u_int8_t	rpm_minlen;
+	u_int8_t	rpm_maxlen;
+	u_int16_t	rpm_reserved;
+	struct	in6_addr	rpm_prefix;
+} __packed;
+
+#define RPM_PCO_ADD		1
+#define RPM_PCO_CHANGE		2
+#define RPM_PCO_SETGLOBAL	3
+#define RPM_PCO_MAX		4
+
+struct rr_pco_use {		/* use prefix part */
+	u_int8_t	rpu_uselen;
+	u_int8_t	rpu_keeplen;
+	u_int8_t	rpu_ramask;
+	u_int8_t	rpu_raflags;
+	u_int32_t	rpu_vltime;
+	u_int32_t	rpu_pltime;
+	u_int32_t	rpu_flags;
+	struct	in6_addr rpu_prefix;
+} __packed;
+#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK	0x80
+#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO	0x40
+
+#if BYTE_ORDER == BIG_ENDIAN
+#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME     0x80000000
+#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME     0x40000000
+#elif BYTE_ORDER == LITTLE_ENDIAN
+#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME     0x80
+#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME     0x40
+#endif
+
+struct rr_result {		/* router renumbering result message */
+	u_int16_t	rrr_flags;
+	u_int8_t	rrr_ordinal;
+	u_int8_t	rrr_matchedlen;
+	u_int32_t	rrr_ifid;
+	struct	in6_addr rrr_prefix;
+} __packed;
+#if BYTE_ORDER == BIG_ENDIAN
+#define ICMP6_RR_RESULT_FLAGS_OOB		0x0002
+#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN		0x0001
+#elif BYTE_ORDER == LITTLE_ENDIAN
+#define ICMP6_RR_RESULT_FLAGS_OOB		0x0200
+#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN		0x0100
+#endif
+
+/*
+ * icmp6 filter structures.
+ */
+
+struct icmp6_filter {
+	u_int32_t icmp6_filt[8];
+};
+
+#define	ICMP6_FILTER_SETPASSALL(filterp) \
+	(void)memset(filterp, 0xff, sizeof(struct icmp6_filter))
+#define	ICMP6_FILTER_SETBLOCKALL(filterp) \
+	(void)memset(filterp, 0x00, sizeof(struct icmp6_filter))
+#define	ICMP6_FILTER_SETPASS(type, filterp) \
+	(((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
+#define	ICMP6_FILTER_SETBLOCK(type, filterp) \
+	(((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
+#define	ICMP6_FILTER_WILLPASS(type, filterp) \
+	((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
+#define	ICMP6_FILTER_WILLBLOCK(type, filterp) \
+	((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
+
+/*
+ * Variables related to this implementation
+ * of the internet control message protocol version 6.
+ */
+
+/*
+ * IPv6 ICMP statistics.
+ * Each counter is an unsigned 64-bit value.
+ */
+#define	ICMP6_STAT_ERROR	0	/* # of calls to icmp6_error */
+#define	ICMP6_STAT_CANTERROR	1	/* no error (old was icmp) */
+#define	ICMP6_STAT_TOOFREQ	2	/* no error (rate limitation) */
+#define	ICMP6_STAT_OUTHIST	3	/* # of output messages */
+		/* space for 256 counters */
+#define	ICMP6_STAT_BADCODE	259	/* icmp6_code out of range */
+#define	ICMP6_STAT_TOOSHORT	260	/* packet < sizeof(struct icmp6_hdr) */
+#define	ICMP6_STAT_CHECKSUM	261	/* bad checksum */
+#define	ICMP6_STAT_BADLEN	262	/* calculated bound mismatch */
+	/*
+	 * number of responses; this member is inherited from the netinet code,
+	 * but for netinet6 code, it is already available in outhist[].
+	 */
+#define	ICMP6_STAT_REFLECT	263
+#define	ICMP6_STAT_INHIST	264	/* # of input messages */
+		/* space for 256 counters */
+#define	ICMP6_STAT_ND_TOOMANYOPT 520	/* too many ND options */
+#define	ICMP6_STAT_OUTERRHIST	521
+		/* space for 13 counters */
+#define	ICMP6_STAT_PMTUCHG	534	/* path MTU changes */
+#define	ICMP6_STAT_ND_BADOPT	535	/* bad ND options */
+#define	ICMP6_STAT_BADNS	536	/* bad neighbor solicititation */
+#define	ICMP6_STAT_BADNA	537	/* bad neighbor advertisement */
+#define	ICMP6_STAT_BADRS	538	/* bad router solicitiation */
+#define	ICMP6_STAT_BADRA	539	/* bad router advertisement */
+#define	ICMP6_STAT_BADREDIRECT	540	/* bad redirect message */
+
+#define	ICMP6_NSTATS		541
+
+#define	ICMP6_ERRSTAT_DST_UNREACH_NOROUTE	0
+#define	ICMP6_ERRSTAT_DST_UNREACH_ADMIN		1
+#define	ICMP6_ERRSTAT_DST_UNREACH_BEYONDSCOPE	2
+#define	ICMP6_ERRSTAT_DST_UNREACH_ADDR		3
+#define	ICMP6_ERRSTAT_DST_UNREACH_NOPORT	4
+#define	ICMP6_ERRSTAT_PACKET_TOO_BIG		5
+#define	ICMP6_ERRSTAT_TIME_EXCEED_TRANSIT	6
+#define	ICMP6_ERRSTAT_TIME_EXCEED_REASSEMBLY	7
+#define	ICMP6_ERRSTAT_PARAMPROB_HEADER		8
+#define	ICMP6_ERRSTAT_PARAMPROB_NEXTHEADER	9
+#define	ICMP6_ERRSTAT_PARAMPROB_OPTION		10
+#define	ICMP6_ERRSTAT_REDIRECT			11
+#define	ICMP6_ERRSTAT_UNKNOWN			12
+
+/*
+ * Names for ICMP sysctl objects
+ */
+#define ICMPV6CTL_STATS		1
+#define ICMPV6CTL_REDIRACCEPT	2	/* accept/process redirects */
+#define ICMPV6CTL_REDIRTIMEOUT	3	/* redirect cache time */
+#if 0	/*obsoleted*/
+#define ICMPV6CTL_ERRRATELIMIT	5	/* ICMPv6 error rate limitation */
+#endif
+#define ICMPV6CTL_ND6_PRUNE	6
+#define ICMPV6CTL_ND6_DELAY	8
+#define ICMPV6CTL_ND6_UMAXTRIES	9
+#define ICMPV6CTL_ND6_MMAXTRIES		10
+#define ICMPV6CTL_ND6_USELOOPBACK	11
+/*#define ICMPV6CTL_ND6_PROXYALL	12	obsoleted, do not reuse here */
+#define ICMPV6CTL_NODEINFO	13
+#define ICMPV6CTL_ERRPPSLIMIT	14	/* ICMPv6 error pps limitation */
+#define ICMPV6CTL_ND6_MAXNUDHINT	15
+#define ICMPV6CTL_MTUDISC_HIWAT	16
+#define ICMPV6CTL_MTUDISC_LOWAT	17
+#define ICMPV6CTL_ND6_DEBUG	18
+#define ICMPV6CTL_ND6_DRLIST	19
+#define ICMPV6CTL_ND6_PRLIST	20
+#define	ICMPV6CTL_ND6_MAXQLEN	24
+#define ICMPV6CTL_MAXID		25
+
+#define ICMPV6CTL_NAMES { \
+	{ 0, 0 }, \
+	{ 0, 0 }, \
+	{ "rediraccept", CTLTYPE_INT }, \
+	{ "redirtimeout", CTLTYPE_INT }, \
+	{ 0, 0 }, \
+	{ 0, 0 }, \
+	{ "nd6_prune", CTLTYPE_INT }, \
+	{ 0, 0 }, \
+	{ "nd6_delay", CTLTYPE_INT }, \
+	{ "nd6_umaxtries", CTLTYPE_INT }, \
+	{ "nd6_mmaxtries", CTLTYPE_INT }, \
+	{ "nd6_useloopback", CTLTYPE_INT }, \
+	{ 0, 0 }, \
+	{ "nodeinfo", CTLTYPE_INT }, \
+	{ "errppslimit", CTLTYPE_INT }, \
+	{ "nd6_maxnudhint", CTLTYPE_INT }, \
+	{ "mtudisc_hiwat", CTLTYPE_INT }, \
+	{ "mtudisc_lowat", CTLTYPE_INT }, \
+	{ "nd6_debug", CTLTYPE_INT }, \
+	{ 0, 0 }, \
+	{ 0, 0 }, \
+	{ 0, 0 }, \
+	{ 0, 0 }, \
+	{ 0, 0 }, \
+	{ "nd6_maxqueuelen", CTLTYPE_INT }, \
+}
+
+#define RTF_PROBEMTU	RTF_PROTO1
+
+#ifdef _KERNEL
+struct	rtentry;
+struct	rttimer;
+struct	in6_multi;
+
+void	icmp6_init(void);
+void	icmp6_paramerror(struct mbuf *, int);
+void	icmp6_error(struct mbuf *, int, int, int);
+void	icmp6_error2(struct mbuf *, int, int, int, struct ifnet *);
+int	icmp6_input(struct mbuf **, int *, int);
+void	icmp6_fasttimo(void);
+void	icmp6_reflect(struct mbuf *, size_t);
+void	icmp6_prepare(struct mbuf *);
+void	icmp6_redirect_input(struct mbuf *, int);
+void	icmp6_redirect_output(struct mbuf *, struct rtentry *);
+int	icmp6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
+
+void	icmp6_statinc(u_int);
+
+struct	ip6ctlparam;
+void	icmp6_mtudisc_update(struct ip6ctlparam *, int);
+void	icmp6_mtudisc_callback_register(void (*)(struct in6_addr *));
+
+/* XXX: is this the right place for these macros? */
+#define icmp6_ifstat_inc(ifp, tag) \
+do {								\
+	if (ifp)						\
+		((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat->tag++; \
+} while (/*CONSTCOND*/ 0)
+
+#define icmp6_ifoutstat_inc(ifp, type, code) \
+do { \
+		icmp6_ifstat_inc(ifp, ifs6_out_msg); \
+		switch(type) { \
+		 case ICMP6_DST_UNREACH: \
+			 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
+			 if (code == ICMP6_DST_UNREACH_ADMIN) \
+				 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
+			 break; \
+		 case ICMP6_PACKET_TOO_BIG: \
+			 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
+			 break; \
+		 case ICMP6_TIME_EXCEEDED: \
+			 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
+			 break; \
+		 case ICMP6_PARAM_PROB: \
+			 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
+			 break; \
+		 case ICMP6_ECHO_REQUEST: \
+			 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
+			 break; \
+		 case ICMP6_ECHO_REPLY: \
+			 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
+			 break; \
+		 case MLD_LISTENER_QUERY: \
+			 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
+			 break; \
+		 case MLD_LISTENER_REPORT: \
+			 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
+			 break; \
+		 case MLD_LISTENER_DONE: \
+			 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
+			 break; \
+		 case ND_ROUTER_SOLICIT: \
+			 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
+			 break; \
+		 case ND_ROUTER_ADVERT: \
+			 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
+			 break; \
+		 case ND_NEIGHBOR_SOLICIT: \
+			 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
+			 break; \
+		 case ND_NEIGHBOR_ADVERT: \
+			 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
+			 break; \
+		 case ND_REDIRECT: \
+			 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
+			 break; \
+		} \
+} while (/*CONSTCOND*/ 0)
+
+extern int	icmp6_rediraccept;	/* accept/process redirects */
+extern int	icmp6_redirtimeout;	/* cache time for redirect routes */
+#endif /* _KERNEL */
+
+#endif /* !_NETINET_ICMP6_H_ */
diff --git a/libc/include/netinet/in.h b/libc/include/netinet/in.h
index 7a4b6c7..01bf58e 100644
--- a/libc/include/netinet/in.h
+++ b/libc/include/netinet/in.h
@@ -32,6 +32,7 @@
 #include <linux/socket.h>
 #include <linux/in.h>
 #include <linux/in6.h>
+#include <linux/ipv6.h>
 #include <netinet/in6.h>
 
 __BEGIN_DECLS
diff --git a/libc/include/netinet/in6.h b/libc/include/netinet/in6.h
index 580a510..7f3286a 100644
--- a/libc/include/netinet/in6.h
+++ b/libc/include/netinet/in6.h
@@ -103,6 +103,7 @@
 #define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
 
 #define IN6ADDR_ANY_INIT {{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}}
+#define IN6ADDR_LOOPBACK_INIT {{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}}}
 
 #define ipv6mr_interface ipv6mr_ifindex
 
diff --git a/libc/include/netinet/ip6.h b/libc/include/netinet/ip6.h
new file mode 100644
index 0000000..aa816c2
--- /dev/null
+++ b/libc/include/netinet/ip6.h
@@ -0,0 +1,319 @@
+/*	$NetBSD: ip6.h,v 1.23 2007/12/25 18:33:46 perry Exp $	*/
+/*	$KAME: ip6.h,v 1.45 2003/06/05 04:46:38 keiichi Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE 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:
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. 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.
+ *
+ *	@(#)ip.h	8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_IP6_H_
+#define _NETINET_IP6_H_
+
+/*
+ * Definition for internet protocol version 6.
+ * RFC 2460
+ */
+
+struct ip6_hdr {
+	union {
+		struct ip6_hdrctl {
+			u_int32_t ip6_un1_flow;	/* 20 bits of flow-ID */
+			u_int16_t ip6_un1_plen;	/* payload length */
+			u_int8_t  ip6_un1_nxt;	/* next header */
+			u_int8_t  ip6_un1_hlim;	/* hop limit */
+		} ip6_un1;
+		u_int8_t ip6_un2_vfc;	/* 4 bits version, top 4 bits class */
+	} ip6_ctlun;
+	struct in6_addr ip6_src;	/* source address */
+	struct in6_addr ip6_dst;	/* destination address */
+} __packed;
+
+#define ip6_vfc		ip6_ctlun.ip6_un2_vfc
+#define ip6_flow	ip6_ctlun.ip6_un1.ip6_un1_flow
+#define ip6_plen	ip6_ctlun.ip6_un1.ip6_un1_plen
+#define ip6_nxt		ip6_ctlun.ip6_un1.ip6_un1_nxt
+#define ip6_hlim	ip6_ctlun.ip6_un1.ip6_un1_hlim
+#define ip6_hops	ip6_ctlun.ip6_un1.ip6_un1_hlim
+
+#define IPV6_VERSION		0x60
+#define IPV6_VERSION_MASK	0xf0
+
+#if BYTE_ORDER == BIG_ENDIAN
+#define IPV6_FLOWINFO_MASK	0x0fffffff	/* flow info (28 bits) */
+#define IPV6_FLOWLABEL_MASK	0x000fffff	/* flow label (20 bits) */
+#else
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define IPV6_FLOWINFO_MASK	0xffffff0f	/* flow info (28 bits) */
+#define IPV6_FLOWLABEL_MASK	0xffff0f00	/* flow label (20 bits) */
+#endif /* LITTLE_ENDIAN */
+#endif
+#if 1
+/* ECN bits proposed by Sally Floyd */
+#define IP6TOS_CE		0x01	/* congestion experienced */
+#define IP6TOS_ECT		0x02	/* ECN-capable transport */
+#endif
+
+#ifdef _KERNEL
+/*
+ * for IPv6 pseudo header checksum
+ * XXX nonstandard
+ */
+struct ip6_hdr_pseudo {
+	struct in6_addr ip6ph_src;
+	struct in6_addr ip6ph_dst;
+	u_int32_t	ip6ph_len;
+	u_int8_t	ip6ph_zero[3];
+	u_int8_t	ip6ph_nxt;
+} __packed;
+#endif
+
+/*
+ * Extension Headers
+ */
+
+struct	ip6_ext {
+	u_int8_t ip6e_nxt;
+	u_int8_t ip6e_len;
+} __packed;
+
+/* Hop-by-Hop options header */
+/* XXX should we pad it to force alignment on an 8-byte boundary? */
+struct ip6_hbh {
+	u_int8_t ip6h_nxt;	/* next header */
+	u_int8_t ip6h_len;	/* length in units of 8 octets */
+	/* followed by options */
+} __packed;
+
+/* Destination options header */
+/* XXX should we pad it to force alignment on an 8-byte boundary? */
+struct ip6_dest {
+	u_int8_t ip6d_nxt;	/* next header */
+	u_int8_t ip6d_len;	/* length in units of 8 octets */
+	/* followed by options */
+} __packed;
+
+/* Option types and related macros */
+#define IP6OPT_PAD1		0x00	/* 00 0 00000 */
+#define IP6OPT_PADN		0x01	/* 00 0 00001 */
+#define IP6OPT_JUMBO		0xC2	/* 11 0 00010 = 194 */
+#define IP6OPT_NSAP_ADDR	0xC3	/* 11 0 00011 */
+#define IP6OPT_TUNNEL_LIMIT	0x04	/* 00 0 00100 */
+#define IP6OPT_RTALERT		0x05	/* 00 0 00101 (KAME definition) */
+#define IP6OPT_ROUTER_ALERT	0x05	/* (RFC3542 def, recommended) */
+
+#define IP6OPT_RTALERT_LEN	4
+#define IP6OPT_RTALERT_MLD	0	/* Datagram contains an MLD message */
+#define IP6OPT_RTALERT_RSVP	1	/* Datagram contains an RSVP message */
+#define IP6OPT_RTALERT_ACTNET	2 	/* contains an Active Networks msg */
+#define IP6OPT_MINLEN		2
+
+#define IP6OPT_TYPE(o)		((o) & 0xC0)
+#define IP6OPT_TYPE_SKIP	0x00
+#define IP6OPT_TYPE_DISCARD	0x40
+#define IP6OPT_TYPE_FORCEICMP	0x80
+#define IP6OPT_TYPE_ICMP	0xC0
+
+#define IP6OPT_MUTABLE		0x20
+
+/* IPv6 options: common part */
+struct ip6_opt {
+	u_int8_t ip6o_type;
+	u_int8_t ip6o_len;
+} __packed;
+
+/* Jumbo Payload Option */
+struct ip6_opt_jumbo {
+	u_int8_t ip6oj_type;
+	u_int8_t ip6oj_len;
+	u_int8_t ip6oj_jumbo_len[4];
+} __packed;
+#define IP6OPT_JUMBO_LEN 6
+
+/* NSAP Address Option */
+struct ip6_opt_nsap {
+	u_int8_t ip6on_type;
+	u_int8_t ip6on_len;
+	u_int8_t ip6on_src_nsap_len;
+	u_int8_t ip6on_dst_nsap_len;
+	/* followed by source NSAP */
+	/* followed by destination NSAP */
+} __packed;
+
+/* Tunnel Limit Option */
+struct ip6_opt_tunnel {
+	u_int8_t ip6ot_type;
+	u_int8_t ip6ot_len;
+	u_int8_t ip6ot_encap_limit;
+} __packed;
+
+/* Router Alert Option */
+struct ip6_opt_router {
+	u_int8_t ip6or_type;
+	u_int8_t ip6or_len;
+	u_int8_t ip6or_value[2];
+} __packed;
+/* Router alert values (in network byte order) */
+#if BYTE_ORDER == BIG_ENDIAN
+#define IP6_ALERT_MLD	0x0000
+#define IP6_ALERT_RSVP	0x0001
+#define IP6_ALERT_AN	0x0002
+#else
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define IP6_ALERT_MLD	0x0000
+#define IP6_ALERT_RSVP	0x0100
+#define IP6_ALERT_AN	0x0200
+#endif /* LITTLE_ENDIAN */
+#endif
+
+/* Routing header */
+struct ip6_rthdr {
+	u_int8_t  ip6r_nxt;	/* next header */
+	u_int8_t  ip6r_len;	/* length in units of 8 octets */
+	u_int8_t  ip6r_type;	/* routing type */
+	u_int8_t  ip6r_segleft;	/* segments left */
+	/* followed by routing type specific data */
+} __packed;
+
+/* Type 0 Routing header */
+struct ip6_rthdr0 {
+	u_int8_t  ip6r0_nxt;		/* next header */
+	u_int8_t  ip6r0_len;		/* length in units of 8 octets */
+	u_int8_t  ip6r0_type;		/* always zero */
+	u_int8_t  ip6r0_segleft;	/* segments left */
+	u_int32_t ip6r0_reserved;	/* reserved field */
+} __packed;
+
+/* Fragment header */
+struct ip6_frag {
+	u_int8_t  ip6f_nxt;		/* next header */
+	u_int8_t  ip6f_reserved;	/* reserved field */
+	u_int16_t ip6f_offlg;		/* offset, reserved, and flag */
+	u_int32_t ip6f_ident;		/* identification */
+} __packed;
+
+#if BYTE_ORDER == BIG_ENDIAN
+#define IP6F_OFF_MASK		0xfff8	/* mask out offset from _offlg */
+#define IP6F_RESERVED_MASK	0x0006	/* reserved bits in ip6f_offlg */
+#define IP6F_MORE_FRAG		0x0001	/* more-fragments flag */
+#else /* BYTE_ORDER == LITTLE_ENDIAN */
+#define IP6F_OFF_MASK		0xf8ff	/* mask out offset from _offlg */
+#define IP6F_RESERVED_MASK	0x0600	/* reserved bits in ip6f_offlg */
+#define IP6F_MORE_FRAG		0x0100	/* more-fragments flag */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+
+/*
+ * Internet implementation parameters.
+ */
+#define IPV6_MAXHLIM	255	/* maximum hoplimit */
+#define IPV6_DEFHLIM	64	/* default hlim */
+#define IPV6_FRAGTTL	120	/* ttl for fragment packets, in slowtimo tick */
+#define IPV6_HLIMDEC	1	/* subtracted when forwarding */
+
+#define IPV6_MMTU	1280	/* minimal MTU and reassembly. 1024 + 256 */
+#define IPV6_MAXPACKET	65535	/* ip6 max packet size without Jumbo payload*/
+
+#ifdef _KERNEL
+/*
+ * IP6_EXTHDR_GET ensures that intermediate protocol header (from "off" to
+ * "len") is located in single mbuf, on contiguous memory region.
+ * The pointer to the region will be returned to pointer variable "val",
+ * with type "typ".
+ * IP6_EXTHDR_GET0 does the same, except that it aligns the structure at the
+ * very top of mbuf.  GET0 is likely to make memory copy than GET.
+ *
+ * XXX we're now testing this, needs m_pulldown()
+ */
+#define IP6_EXTHDR_GET(val, typ, m, off, len) \
+do {									\
+	struct mbuf *_t;						\
+	int _tmp;							\
+	if ((m)->m_len >= (off) + (len))				\
+		(val) = (typ)(mtod((m), char *) + (off));		\
+	else {								\
+		_t = m_pulldown((m), (off), (len), &_tmp);		\
+		if (_t) {						\
+			if (_t->m_len < _tmp + (len))			\
+				panic("m_pulldown malfunction");	\
+			(val) = (typ)(mtod(_t, char *) + _tmp);	\
+		} else {						\
+			(val) = (typ)NULL;				\
+			(m) = NULL;					\
+		}							\
+	}								\
+} while (/*CONSTCOND*/ 0)
+
+#define IP6_EXTHDR_GET0(val, typ, m, off, len) \
+do {									\
+	struct mbuf *_t;						\
+	if ((off) == 0 && (m)->m_len >= len)				\
+		(val) = (typ)mtod((m), void *);			\
+	else {								\
+		_t = m_pulldown((m), (off), (len), NULL);		\
+		if (_t) {						\
+			if (_t->m_len < (len))				\
+				panic("m_pulldown malfunction");	\
+			(val) = (typ)mtod(_t, void *);			\
+		} else {						\
+			(val) = (typ)NULL;				\
+			(m) = NULL;					\
+		}							\
+	}								\
+} while (/*CONSTCOND*/ 0)
+#endif /*_KERNEL*/
+
+#endif /* !_NETINET_IP6_H_ */
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index c38ed5a..4006882 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -170,6 +170,7 @@
 #define	__SOFF	0x1000		/* set iff _offset is in fact correct */
 #define	__SMOD	0x2000		/* true => fgetln modified _p text */
 #define	__SALC	0x4000		/* allocate string space dynamically */
+#define	__SIGN	0x8000		/* ignore this file in _fwalk */
 
 /*
  * The following three definitions are for ANSI C, which took them
@@ -406,38 +407,43 @@
 #define	__sclearerr(p)	((void)((p)->_flags &= ~(__SERR|__SEOF)))
 #define	__sfileno(p)	((p)->_file)
 
-#define	feof(p)		__sfeof(p)
-#define	ferror(p)	__sferror(p)
+extern	int __isthreaded;
 
-#ifndef _POSIX_THREADS
-#define	clearerr(p)	__sclearerr(p)
-#endif
+#define	feof(p)		(!__isthreaded ? __sfeof(p) : (feof)(p))
+#define	ferror(p)	(!__isthreaded ? __sferror(p) : (ferror)(p))
+#define	clearerr(p)	(!__isthreaded ? __sclearerr(p) : (clearerr)(p))
 
 #if __POSIX_VISIBLE
-#define	fileno(p)	__sfileno(p)
+#define	fileno(p)	(!__isthreaded ? __sfileno(p) : (fileno)(p))
 #endif
 
+#define	getc(fp)	(!__isthreaded ? __sgetc(fp) : (getc)(fp))
+
+#if __BSD_VISIBLE
+/*
+ * The macro implementations of putc and putc_unlocked are not
+ * fully POSIX compliant; they do not set errno on failure
+ */
+#define putc(x, fp)	(!__isthreaded ? __sputc(x, fp) : (putc)(x, fp))
+#endif /* __BSD_VISIBLE */
+
 #ifndef lint
-#ifndef _POSIX_THREADS
-#define	getc(fp)	__sgetc(fp)
-#endif /* _POSIX_THREADS */
+#if __POSIX_VISIBLE >= 199506
 #define	getc_unlocked(fp)	__sgetc(fp)
 /*
  * The macro implementations of putc and putc_unlocked are not
  * fully POSIX compliant; they do not set errno on failure
  */
 #if __BSD_VISIBLE
-#ifndef _POSIX_THREADS
-#define putc(x, fp)	__sputc(x, fp)
-#endif /* _POSIX_THREADS */
 #define putc_unlocked(x, fp)	__sputc(x, fp)
 #endif /* __BSD_VISIBLE */
+#endif /* __POSIX_VISIBLE >= 199506 */
 #endif /* lint */
 
 #define	getchar()	getc(stdin)
 #define	putchar(x)	putc(x, stdout)
-#define getchar_unlocked()	getc_unlocked(stdin)
-#define putchar_unlocked(c)	putc_unlocked(c, stdout)
+#define	getchar_unlocked()	getc_unlocked(stdin)
+#define	putchar_unlocked(c)	putc_unlocked(c, stdout)
 
 #ifdef _GNU_SOURCE
 /*
diff --git a/libc/include/sys/linux-syscalls.h b/libc/include/sys/linux-syscalls.h
index cb4d5e5..5b8e2b4 100644
--- a/libc/include/sys/linux-syscalls.h
+++ b/libc/include/sys/linux-syscalls.h
@@ -280,7 +280,7 @@
 #define __NR_socketcall                   (__NR_SYSCALL_BASE + 102)
 #define __NR_socketcall                   (__NR_SYSCALL_BASE + 102)
 #define __NR_socketcall                   (__NR_SYSCALL_BASE + 102)
-#define __NR___socketcall                 (__NR_SYSCALL_BASE + 102)
+#define __NR_socketcall                   (__NR_SYSCALL_BASE + 102)
 #define __NR_getcpu                       (__NR_SYSCALL_BASE + 318)
 #define __NR_ioprio_set                   (__NR_SYSCALL_BASE + 288)
 #define __NR_ioprio_get                   (__NR_SYSCALL_BASE + 289)
diff --git a/libc/kernel/arch-arm/asm/ptrace.h b/libc/kernel/arch-arm/asm/ptrace.h
index 3faf738..a04eec3 100644
--- a/libc/kernel/arch-arm/asm/ptrace.h
+++ b/libc/kernel/arch-arm/asm/ptrace.h
@@ -64,12 +64,7 @@
 #ifndef __ASSEMBLY__
 
 struct pt_regs {
-  long uregs[18];
-};
-
-struct user_vfp {
-  unsigned long long fpregs[32];
-  unsigned long fpscr;
+ long uregs[18];
 };
 
 #define ARM_cpsr uregs[16]
diff --git a/libc/kernel/arch-arm/asm/user.h b/libc/kernel/arch-arm/asm/user.h
index 5f25850..d0baecd 100644
--- a/libc/kernel/arch-arm/asm/user.h
+++ b/libc/kernel/arch-arm/asm/user.h
@@ -58,4 +58,15 @@
 #define HOST_TEXT_START_ADDR (u.start_code)
 #define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
 
+struct user_vfp {
+ unsigned long long fpregs[32];
+ unsigned long fpscr;
+};
+
+struct user_vfp_exc {
+ unsigned long fpexc;
+ unsigned long fpinst;
+ unsigned long fpinst2;
+};
+
 #endif
diff --git a/libc/kernel/common/linux/icmpv6.h b/libc/kernel/common/linux/icmpv6.h
new file mode 100644
index 0000000..d1be8cd
--- /dev/null
+++ b/libc/kernel/common/linux/icmpv6.h
@@ -0,0 +1,152 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _LINUX_ICMPV6_H
+#define _LINUX_ICMPV6_H
+
+#include <linux/types.h>
+#include <asm/byteorder.h>
+
+struct icmp6hdr {
+
+ __u8 icmp6_type;
+ __u8 icmp6_code;
+ __sum16 icmp6_cksum;
+
+ union {
+ __be32 un_data32[1];
+ __be16 un_data16[2];
+ __u8 un_data8[4];
+
+ struct icmpv6_echo {
+ __be16 identifier;
+ __be16 sequence;
+ } u_echo;
+
+ struct icmpv6_nd_advt {
+#ifdef __LITTLE_ENDIAN_BITFIELD
+ __u32 reserved:5,
+ override:1,
+ solicited:1,
+ router:1,
+ reserved2:24;
+#elif defined(__BIG_ENDIAN_BITFIELD)
+ __u32 router:1,
+ solicited:1,
+ override:1,
+ reserved:29;
+#else
+#error "Please fix <asm/byteorder.h>"
+#endif
+ } u_nd_advt;
+
+ struct icmpv6_nd_ra {
+ __u8 hop_limit;
+#ifdef __LITTLE_ENDIAN_BITFIELD
+ __u8 reserved:3,
+ router_pref:2,
+ home_agent:1,
+ other:1,
+ managed:1;
+
+#elif defined(__BIG_ENDIAN_BITFIELD)
+ __u8 managed:1,
+ other:1,
+ home_agent:1,
+ router_pref:2,
+ reserved:3;
+#else
+#error "Please fix <asm/byteorder.h>"
+#endif
+ __be16 rt_lifetime;
+ } u_nd_ra;
+
+ } icmp6_dataun;
+
+#define icmp6_identifier icmp6_dataun.u_echo.identifier
+#define icmp6_sequence icmp6_dataun.u_echo.sequence
+#define icmp6_pointer icmp6_dataun.un_data32[0]
+#define icmp6_mtu icmp6_dataun.un_data32[0]
+#define icmp6_unused icmp6_dataun.un_data32[0]
+#define icmp6_maxdelay icmp6_dataun.un_data16[0]
+#define icmp6_router icmp6_dataun.u_nd_advt.router
+#define icmp6_solicited icmp6_dataun.u_nd_advt.solicited
+#define icmp6_override icmp6_dataun.u_nd_advt.override
+#define icmp6_ndiscreserved icmp6_dataun.u_nd_advt.reserved
+#define icmp6_hop_limit icmp6_dataun.u_nd_ra.hop_limit
+#define icmp6_addrconf_managed icmp6_dataun.u_nd_ra.managed
+#define icmp6_addrconf_other icmp6_dataun.u_nd_ra.other
+#define icmp6_rt_lifetime icmp6_dataun.u_nd_ra.rt_lifetime
+#define icmp6_router_pref icmp6_dataun.u_nd_ra.router_pref
+};
+
+#define ICMPV6_ROUTER_PREF_LOW 0x3
+#define ICMPV6_ROUTER_PREF_MEDIUM 0x0
+#define ICMPV6_ROUTER_PREF_HIGH 0x1
+#define ICMPV6_ROUTER_PREF_INVALID 0x2
+
+#define ICMPV6_DEST_UNREACH 1
+#define ICMPV6_PKT_TOOBIG 2
+#define ICMPV6_TIME_EXCEED 3
+#define ICMPV6_PARAMPROB 4
+
+#define ICMPV6_INFOMSG_MASK 0x80
+
+#define ICMPV6_ECHO_REQUEST 128
+#define ICMPV6_ECHO_REPLY 129
+#define ICMPV6_MGM_QUERY 130
+#define ICMPV6_MGM_REPORT 131
+#define ICMPV6_MGM_REDUCTION 132
+
+#define ICMPV6_NI_QUERY 139
+#define ICMPV6_NI_REPLY 140
+
+#define ICMPV6_MLD2_REPORT 143
+
+#define ICMPV6_DHAAD_REQUEST 144
+#define ICMPV6_DHAAD_REPLY 145
+#define ICMPV6_MOBILE_PREFIX_SOL 146
+#define ICMPV6_MOBILE_PREFIX_ADV 147
+
+#define ICMPV6_NOROUTE 0
+#define ICMPV6_ADM_PROHIBITED 1
+#define ICMPV6_NOT_NEIGHBOUR 2
+#define ICMPV6_ADDR_UNREACH 3
+#define ICMPV6_PORT_UNREACH 4
+
+#define ICMPV6_EXC_HOPLIMIT 0
+#define ICMPV6_EXC_FRAGTIME 1
+
+#define ICMPV6_HDR_FIELD 0
+#define ICMPV6_UNK_NEXTHDR 1
+#define ICMPV6_UNK_OPTION 2
+
+#define ICMPV6_FILTER 1
+
+#define ICMPV6_FILTER_BLOCK 1
+#define ICMPV6_FILTER_PASS 2
+#define ICMPV6_FILTER_BLOCKOTHERS 3
+#define ICMPV6_FILTER_PASSONLY 4
+
+struct icmp6_filter {
+ __u32 data[8];
+};
+
+#define MLD2_MODE_IS_INCLUDE 1
+#define MLD2_MODE_IS_EXCLUDE 2
+#define MLD2_CHANGE_TO_INCLUDE 3
+#define MLD2_CHANGE_TO_EXCLUDE 4
+#define MLD2_ALLOW_NEW_SOURCES 5
+#define MLD2_BLOCK_OLD_SOURCES 6
+
+#define MLD2_ALL_MCR_INIT { { { 0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,0x16 } } }
+
+#endif
diff --git a/libc/kernel/common/linux/in6.h b/libc/kernel/common/linux/in6.h
index ceaeb7d..d148dfd 100644
--- a/libc/kernel/common/linux/in6.h
+++ b/libc/kernel/common/linux/in6.h
@@ -14,25 +14,21 @@
 
 #include <linux/types.h>
 
-struct in6_addr
-{
- union
- {
+struct in6_addr {
+ union {
  __u8 u6_addr8[16];
- __u16 u6_addr16[8];
- __u32 u6_addr32[4];
+ __be16 u6_addr16[8];
+ __be32 u6_addr32[4];
  } in6_u;
 #define s6_addr in6_u.u6_addr8
 #define s6_addr16 in6_u.u6_addr16
 #define s6_addr32 in6_u.u6_addr32
 };
 
-#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
-
 struct sockaddr_in6 {
  unsigned short int sin6_family;
- __u16 sin6_port;
- __u32 sin6_flowinfo;
+ __be16 sin6_port;
+ __be32 sin6_flowinfo;
  struct in6_addr sin6_addr;
  __u32 sin6_scope_id;
 };
@@ -46,10 +42,9 @@
 
 #define ipv6mr_acaddr ipv6mr_multiaddr
 
-struct in6_flowlabel_req
-{
+struct in6_flowlabel_req {
  struct in6_addr flr_dst;
- __u32 flr_label;
+ __be32 flr_label;
  __u8 flr_action;
  __u8 flr_share;
  __u16 flr_flags;
@@ -98,11 +93,13 @@
 #define IPPROTO_ICMPV6 58  
 #define IPPROTO_NONE 59  
 #define IPPROTO_DSTOPTS 60  
+#define IPPROTO_MH 135  
 
 #define IPV6_TLV_PAD0 0
 #define IPV6_TLV_PADN 1
 #define IPV6_TLV_ROUTERALERT 5
 #define IPV6_TLV_JUMBO 194
+#define IPV6_TLV_HAO 201  
 
 #define IPV6_ADDRFORM 1
 #define IPV6_2292PKTINFO 2
@@ -133,6 +130,7 @@
 #define IPV6_PMTUDISC_DONT 0
 #define IPV6_PMTUDISC_WANT 1
 #define IPV6_PMTUDISC_DO 2
+#define IPV6_PMTUDISC_PROBE 3
 
 #define IPV6_FLOWLABEL_MGR 32
 #define IPV6_FLOWINFO_SEND 33
@@ -151,8 +149,27 @@
 #define IPV6_RTHDR 57
 #define IPV6_RECVDSTOPTS 58
 #define IPV6_DSTOPTS 59
+#define IPV6_RECVPATHMTU 60
+#define IPV6_PATHMTU 61
+#define IPV6_DONTFRAG 62
 
 #define IPV6_RECVTCLASS 66
 #define IPV6_TCLASS 67
 
+#define IPV6_ADDR_PREFERENCES 72
+
+#define IPV6_PREFER_SRC_TMP 0x0001
+#define IPV6_PREFER_SRC_PUBLIC 0x0002
+#define IPV6_PREFER_SRC_PUBTMP_DEFAULT 0x0100
+#define IPV6_PREFER_SRC_COA 0x0004
+#define IPV6_PREFER_SRC_HOME 0x0400
+#define IPV6_PREFER_SRC_CGA 0x0008
+#define IPV6_PREFER_SRC_NONCGA 0x0800
+
+#define IPV6_MINHOPCOUNT 73
+
+#define IPV6_ORIGDSTADDR 74
+#define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR
+#define IPV6_TRANSPARENT 75
+
 #endif
diff --git a/libc/kernel/common/linux/ipv6.h b/libc/kernel/common/linux/ipv6.h
new file mode 100644
index 0000000..f4ee9a1
--- /dev/null
+++ b/libc/kernel/common/linux/ipv6.h
@@ -0,0 +1,133 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _IPV6_H
+#define _IPV6_H
+
+#include <linux/types.h>
+#include <linux/in6.h>
+#include <asm/byteorder.h>
+
+#define IPV6_MIN_MTU 1280
+
+struct in6_pktinfo {
+ struct in6_addr ipi6_addr;
+ int ipi6_ifindex;
+};
+
+struct ip6_mtuinfo {
+ struct sockaddr_in6 ip6m_addr;
+ __u32 ip6m_mtu;
+};
+
+struct in6_ifreq {
+ struct in6_addr ifr6_addr;
+ __u32 ifr6_prefixlen;
+ int ifr6_ifindex;
+};
+
+#define IPV6_SRCRT_STRICT 0x01  
+#define IPV6_SRCRT_TYPE_0 0  
+#define IPV6_SRCRT_TYPE_2 2  
+
+struct ipv6_rt_hdr {
+ __u8 nexthdr;
+ __u8 hdrlen;
+ __u8 type;
+ __u8 segments_left;
+
+};
+
+struct ipv6_opt_hdr {
+ __u8 nexthdr;
+ __u8 hdrlen;
+
+} __attribute__((packed));
+
+#define ipv6_destopt_hdr ipv6_opt_hdr
+#define ipv6_hopopt_hdr ipv6_opt_hdr
+
+struct rt0_hdr {
+ struct ipv6_rt_hdr rt_hdr;
+ __u32 reserved;
+ struct in6_addr addr[0];
+
+#define rt0_type rt_hdr.type
+};
+
+struct rt2_hdr {
+ struct ipv6_rt_hdr rt_hdr;
+ __u32 reserved;
+ struct in6_addr addr;
+
+#define rt2_type rt_hdr.type
+};
+
+struct ipv6_destopt_hao {
+ __u8 type;
+ __u8 length;
+ struct in6_addr addr;
+} __attribute__((packed));
+
+struct ipv6hdr {
+#ifdef __LITTLE_ENDIAN_BITFIELD
+ __u8 priority:4,
+ version:4;
+#elif defined(__BIG_ENDIAN_BITFIELD)
+ __u8 version:4,
+ priority:4;
+#else
+#error "Please fix <asm/byteorder.h>"
+#endif
+ __u8 flow_lbl[3];
+
+ __be16 payload_len;
+ __u8 nexthdr;
+ __u8 hop_limit;
+
+ struct in6_addr saddr;
+ struct in6_addr daddr;
+};
+
+enum {
+ DEVCONF_FORWARDING = 0,
+ DEVCONF_HOPLIMIT,
+ DEVCONF_MTU6,
+ DEVCONF_ACCEPT_RA,
+ DEVCONF_ACCEPT_REDIRECTS,
+ DEVCONF_AUTOCONF,
+ DEVCONF_DAD_TRANSMITS,
+ DEVCONF_RTR_SOLICITS,
+ DEVCONF_RTR_SOLICIT_INTERVAL,
+ DEVCONF_RTR_SOLICIT_DELAY,
+ DEVCONF_USE_TEMPADDR,
+ DEVCONF_TEMP_VALID_LFT,
+ DEVCONF_TEMP_PREFERED_LFT,
+ DEVCONF_REGEN_MAX_RETRY,
+ DEVCONF_MAX_DESYNC_FACTOR,
+ DEVCONF_MAX_ADDRESSES,
+ DEVCONF_FORCE_MLD_VERSION,
+ DEVCONF_ACCEPT_RA_DEFRTR,
+ DEVCONF_ACCEPT_RA_PINFO,
+ DEVCONF_ACCEPT_RA_RTR_PREF,
+ DEVCONF_RTR_PROBE_INTERVAL,
+ DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN,
+ DEVCONF_PROXY_NDP,
+ DEVCONF_OPTIMISTIC_DAD,
+ DEVCONF_ACCEPT_SOURCE_ROUTE,
+ DEVCONF_MC_FORWARDING,
+ DEVCONF_DISABLE_IPV6,
+ DEVCONF_ACCEPT_DAD,
+ DEVCONF_FORCE_TLLAO,
+ DEVCONF_MAX
+};
+
+#endif
diff --git a/libc/kernel/common/linux/mroute6.h b/libc/kernel/common/linux/mroute6.h
new file mode 100644
index 0000000..2b151b9
--- /dev/null
+++ b/libc/kernel/common/linux/mroute6.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __LINUX_MROUTE6_H
+#define __LINUX_MROUTE6_H
+
+#include <linux/types.h>
+#include <linux/sockios.h>
+
+#define MRT6_BASE 200
+#define MRT6_INIT (MRT6_BASE)  
+#define MRT6_DONE (MRT6_BASE+1)  
+#define MRT6_ADD_MIF (MRT6_BASE+2)  
+#define MRT6_DEL_MIF (MRT6_BASE+3)  
+#define MRT6_ADD_MFC (MRT6_BASE+4)  
+#define MRT6_DEL_MFC (MRT6_BASE+5)  
+#define MRT6_VERSION (MRT6_BASE+6)  
+#define MRT6_ASSERT (MRT6_BASE+7)  
+#define MRT6_PIM (MRT6_BASE+8)  
+#define MRT6_TABLE (MRT6_BASE+9)  
+
+#define SIOCGETMIFCNT_IN6 SIOCPROTOPRIVATE  
+#define SIOCGETSGCNT_IN6 (SIOCPROTOPRIVATE+1)
+#define SIOCGETRPF (SIOCPROTOPRIVATE+2)
+
+#define MAXMIFS 32
+typedef unsigned long mifbitmap_t;
+typedef unsigned short mifi_t;
+#define ALL_MIFS ((mifi_t)(-1))
+
+#ifndef IF_SETSIZE
+#define IF_SETSIZE 256
+#endif
+
+typedef __u32 if_mask;
+#define NIFBITS (sizeof(if_mask) * 8)  
+
+#ifndef DIV_ROUND_UP
+#define DIV_ROUND_UP(x,y) (((x) + ((y) - 1)) / (y))
+#endif
+
+typedef struct if_set {
+ if_mask ifs_bits[DIV_ROUND_UP(IF_SETSIZE, NIFBITS)];
+} if_set;
+
+#define IF_SET(n, p) ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS)))
+#define IF_CLR(n, p) ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS)))
+#define IF_ISSET(n, p) ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS)))
+#define IF_COPY(f, t) bcopy(f, t, sizeof(*(f)))
+#define IF_ZERO(p) bzero(p, sizeof(*(p)))
+
+struct mif6ctl {
+ mifi_t mif6c_mifi;
+ unsigned char mif6c_flags;
+ unsigned char vifc_threshold;
+ __u16 mif6c_pifi;
+ unsigned int vifc_rate_limit;
+};
+
+#define MIFF_REGISTER 0x1  
+
+struct mf6cctl {
+ struct sockaddr_in6 mf6cc_origin;
+ struct sockaddr_in6 mf6cc_mcastgrp;
+ mifi_t mf6cc_parent;
+ struct if_set mf6cc_ifset;
+};
+
+struct sioc_sg_req6 {
+ struct sockaddr_in6 src;
+ struct sockaddr_in6 grp;
+ unsigned long pktcnt;
+ unsigned long bytecnt;
+ unsigned long wrong_if;
+};
+
+struct sioc_mif_req6 {
+ mifi_t mifi;
+ unsigned long icount;
+ unsigned long ocount;
+ unsigned long ibytes;
+ unsigned long obytes;
+};
+
+struct mrt6msg {
+#define MRT6MSG_NOCACHE 1
+#define MRT6MSG_WRONGMIF 2
+#define MRT6MSG_WHOLEPKT 3  
+ __u8 im6_mbz;
+ __u8 im6_msgtype;
+ __u16 im6_mif;
+ __u32 im6_pad;
+ struct in6_addr im6_src, im6_dst;
+};
+
+#endif
diff --git a/libc/kernel/common/linux/netfilter_ipv6.h b/libc/kernel/common/linux/netfilter_ipv6.h
index 0d68cd9..ce2f12c 100644
--- a/libc/kernel/common/linux/netfilter_ipv6.h
+++ b/libc/kernel/common/linux/netfilter_ipv6.h
@@ -52,13 +52,13 @@
 enum nf_ip6_hook_priorities {
  NF_IP6_PRI_FIRST = INT_MIN,
  NF_IP6_PRI_CONNTRACK_DEFRAG = -400,
+ NF_IP6_PRI_RAW = -300,
  NF_IP6_PRI_SELINUX_FIRST = -225,
  NF_IP6_PRI_CONNTRACK = -200,
- NF_IP6_PRI_BRIDGE_SABOTAGE_FORWARD = -175,
  NF_IP6_PRI_MANGLE = -150,
  NF_IP6_PRI_NAT_DST = -100,
- NF_IP6_PRI_BRIDGE_SABOTAGE_LOCAL_OUT = -50,
  NF_IP6_PRI_FILTER = 0,
+ NF_IP6_PRI_SECURITY = 50,
  NF_IP6_PRI_NAT_SRC = 100,
  NF_IP6_PRI_SELINUX_LAST = 225,
  NF_IP6_PRI_LAST = INT_MAX,
diff --git a/libc/kernel/common/linux/nvhdcp.h b/libc/kernel/common/linux/nvhdcp.h
new file mode 100644
index 0000000..d21ea55
--- /dev/null
+++ b/libc/kernel/common/linux/nvhdcp.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _LINUX_NVHDCP_H_
+#define _LINUX_NVHDCP_H_
+#include <linux/fb.h>
+#include <linux/types.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <asm/ioctl.h>
+#define TEGRA_NVHDCP_MAX_DEVS 127
+#define TEGRA_NVHDCP_FLAG_AN 0x0001
+#define TEGRA_NVHDCP_FLAG_AKSV 0x0002
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TEGRA_NVHDCP_FLAG_BKSV 0x0004
+#define TEGRA_NVHDCP_FLAG_BSTATUS 0x0008  
+#define TEGRA_NVHDCP_FLAG_CN 0x0010  
+#define TEGRA_NVHDCP_FLAG_CKSV 0x0020  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TEGRA_NVHDCP_FLAG_DKSV 0x0040  
+#define TEGRA_NVHDCP_FLAG_KP 0x0080  
+#define TEGRA_NVHDCP_FLAG_S 0x0100  
+#define TEGRA_NVHDCP_FLAG_CS 0x0200  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TEGRA_NVHDCP_FLAG_V 0x0400
+#define TEGRA_NVHDCP_FLAG_MP 0x0800
+#define TEGRA_NVHDCP_FLAG_BKSVLIST 0x1000
+#define TEGRA_NVHDCP_RESULT_SUCCESS 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TEGRA_NVHDCP_RESULT_UNSUCCESSFUL 1
+#define TEGRA_NVHDCP_RESULT_PENDING 0x103
+#define TEGRA_NVHDCP_RESULT_LINK_FAILED 0xc0000013
+#define TEGRA_NVHDCP_RESULT_INVALID_PARAMETER 0xc000000d
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TEGRA_NVHDCP_RESULT_INVALID_PARAMETER_MIX 0xc0000030
+#define TEGRA_NVHDCP_RESULT_NO_MEMORY 0xc0000017
+struct tegra_nvhdcp_packet {
+ __u32 value_flags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u32 packet_results;
+ __u64 c_n;
+ __u64 c_ksv;
+ __u32 b_status;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u64 hdcp_status;
+ __u64 cs;
+ __u64 k_prime;
+ __u64 a_n;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u64 a_ksv;
+ __u64 b_ksv;
+ __u64 d_ksv;
+ __u8 v_prime[20];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __u64 m_prime;
+ __u32 num_bksv_list;
+ __u64 bksv_list[TEGRA_NVHDCP_MAX_DEVS];
+};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TEGRA_NVHDCP_POLICY_ON_DEMAND 0
+#define TEGRA_NVHDCP_POLICY_ALWAYS_ON 1
+#define TEGRAIO_NVHDCP_ON _IO('F', 0x70)
+#define TEGRAIO_NVHDCP_OFF _IO('F', 0x71)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define TEGRAIO_NVHDCP_SET_POLICY _IOW('F', 0x72, __u32)
+#define TEGRAIO_NVHDCP_READ_M _IOWR('F', 0x73, struct tegra_nvhdcp_packet)
+#define TEGRAIO_NVHDCP_READ_S _IOWR('F', 0x74, struct tegra_nvhdcp_packet)
+#define TEGRAIO_NVHDCP_RENEGOTIATE _IO('F', 0x75)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+
diff --git a/libc/kernel/common/linux/usb/f_accessory.h b/libc/kernel/common/linux/usb/f_accessory.h
index 84a8917..eaf8c4d 100644
--- a/libc/kernel/common/linux/usb/f_accessory.h
+++ b/libc/kernel/common/linux/usb/f_accessory.h
@@ -24,15 +24,18 @@
 #define USB_ACCESSORY_ADB_PRODUCT_ID 0x2D01
 #define ACCESSORY_STRING_MANUFACTURER 0
 #define ACCESSORY_STRING_MODEL 1
-#define ACCESSORY_STRING_TYPE 2
+#define ACCESSORY_STRING_DESCRIPTION 2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ACCESSORY_STRING_VERSION 3
+#define ACCESSORY_STRING_URI 4
+#define ACCESSORY_GET_PROTOCOL 51
 #define ACCESSORY_SEND_STRING 52
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ACCESSORY_START 53
 #define ACCESSORY_GET_STRING_MANUFACTURER _IOW('M', 1, char[256])
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ACCESSORY_GET_STRING_MODEL _IOW('M', 2, char[256])
-#define ACCESSORY_GET_STRING_TYPE _IOW('M', 3, char[256])
-#define ACCESSORY_GET_STRING_VERSION _IOW('M', 4, char[256])
-#endif
+#define ACCESSORY_GET_STRING_DESCRIPTION _IOW('M', 3, char[256])
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define ACCESSORY_GET_STRING_VERSION _IOW('M', 4, char[256])
+#define ACCESSORY_GET_STRING_URI _IOW('M', 5, char[256])
+#endif
diff --git a/libc/kernel/tools/clean_header.py b/libc/kernel/tools/clean_header.py
index dad9120..94b19ce 100755
--- a/libc/kernel/tools/clean_header.py
+++ b/libc/kernel/tools/clean_header.py
@@ -7,12 +7,12 @@
 
 noUpdate = 1
 
-def  cleanupFile( path ):
+def  cleanupFile( path, original_path=kernel_original_path ):
     """reads an original header and perform the cleanup operation on it
        this functions returns the destination path and the clean header
        as a single string"""
     # check the header path
-    src_path    = path
+    src_path = path
 
     if not os.path.exists(src_path):
         if noUpdate:
@@ -26,7 +26,6 @@
         sys.stderr.write( "warning: not a file: %s\n" % path )
         return None, None
 
-    original_path = kernel_original_path
     if os.path.commonprefix( [ src_path, original_path ] ) != original_path:
         if noUpdate:
             panic( "file is not in 'original' directory: %s\n" % path );
@@ -54,27 +53,27 @@
     else:
         dst_path = "common/" + src_path
 
-    dst_path = os.path.normpath( original_path + "/../" + dst_path )
+    dst_path = os.path.normpath( kernel_cleaned_path + "/" + dst_path )
 
     # now, let's parse the file
     #
-    list = cpp.BlockParser().parseFile(path)
-    if not list:
+    blocks = cpp.BlockParser().parseFile(path)
+    if not blocks:
         sys.stderr.write( "error: can't parse '%s'" % path )
         sys.exit(1)
 
 
-    list.optimizeMacros( kernel_known_macros )
-    list.optimizeIf01()
-    list.removeVarsAndFuncs( statics )
-    list.removeComments()
-    list.removeEmptyLines()
-    list.removeMacroDefines( kernel_ignored_macros )
-    list.insertDisclaimer( kernel.kernel_disclaimer )
-    list.replaceTokens( kernel_token_replacements )
+    blocks.optimizeMacros( kernel_known_macros )
+    blocks.optimizeIf01()
+    blocks.removeVarsAndFuncs( statics )
+    blocks.replaceTokens( kernel_token_replacements )
+    blocks.removeComments()
+    blocks.removeMacroDefines( kernel_ignored_macros )
+    blocks.removeWhiteSpace()
 
     out = StringOutput()
-    list.write(out)
+    out.write( kernel_disclaimer )
+    blocks.writeWithWarning(out, kernel_warning, 4)
     return dst_path, out.get()
 
 
@@ -92,12 +91,15 @@
                 if the content has changed. with this, you can pass more
                 than one file on the command-line
 
+            -k<path>  specify path of original kernel headers
+            -d<path>  specify path of cleaned kernel headers
+
         <header_path> must be in a subdirectory of 'original'
     """ % os.path.basename(sys.argv[0])
         sys.exit(1)
 
     try:
-        optlist, args = getopt.getopt( sys.argv[1:], 'uvk:' )
+        optlist, args = getopt.getopt( sys.argv[1:], 'uvk:d:' )
     except:
         # unrecognized option
         sys.stderr.write( "error: unrecognized option\n" )
@@ -111,6 +113,8 @@
             D_setlevel(1)
         elif opt == '-k':
             kernel_original_path = arg
+        elif opt == '-d':
+            kernel_cleaned_path = arg
 
     if len(args) == 0:
         usage()
@@ -143,9 +147,6 @@
         print "cleaning: %-*s -> %-*s (%s)" % ( 35, path, 35, dst_path, r )
 
 
-    if os.environ.has_key("ANDROID_PRODUCT_OUT"):
-        b.updateP4Files()
-    else:
-        b.updateFiles()
+    b.updateGitFiles()
 
     sys.exit(0)
diff --git a/libc/kernel/tools/cpp.py b/libc/kernel/tools/cpp.py
index 8828a5d..8e15a67 100644
--- a/libc/kernel/tools/cpp.py
+++ b/libc/kernel/tools/cpp.py
@@ -1529,7 +1529,7 @@
 
 class Block:
     """a class used to model a block of input source text. there are two block types:
-        - direcive blocks: contain the tokens of a single pre-processor directive (e.g. #if)
+        - directive blocks: contain the tokens of a single pre-processor directive (e.g. #if)
         - text blocks, contain the tokens of non-directive blocks
 
        the cpp parser class below will transform an input source file into a list of Block
@@ -1609,6 +1609,91 @@
         else:
             return None
 
+    def removeWhiteSpace(self):
+        # Remove trailing whitespace and empty lines
+        # All whitespace is also contracted to a single space
+        if self.directive != None:
+            return
+
+        tokens = []
+        line   = 0     # index of line start
+        space  = -1    # index of first space, or -1
+        ii = 0
+        nn = len(self.tokens)
+        while ii < nn:
+            tok = self.tokens[ii]
+
+            # If we find a space, record its position if this is the first
+            # one the line start or the previous character. Don't append
+            # anything to tokens array yet though.
+            if tok.id == tokSPACE:
+                if space < 0:
+                    space = ii
+                ii += 1
+                continue
+
+            # If this is a line space, ignore the spaces we found previously
+            # on the line, and remove empty lines.
+            if tok.id == tokLN:
+                old_line  = line
+                old_space = space
+                #print "N line=%d space=%d ii=%d" % (line, space, ii)
+                ii   += 1
+                line  = ii
+                space = -1
+                if old_space == old_line:  # line only contains spaces
+                    #print "-s"
+                    continue
+                if ii-1 == old_line:  # line is empty
+                    #print "-e"
+                    continue
+                tokens.append(tok)
+                continue
+
+            # Other token, append any space range if any, converting each
+            # one to a single space character, then append the token.
+            if space >= 0:
+                jj = space
+                space = -1
+                while jj < ii:
+                    tok2 = self.tokens[jj]
+                    tok2.value = " "
+                    tokens.append(tok2)
+                    jj += 1
+
+            tokens.append(tok)
+            ii += 1
+
+        self.tokens = tokens
+
+    def writeWithWarning(self,out,warning,left_count,repeat_count):
+        # removeWhiteSpace() will sometimes creates non-directive blocks
+        # without any tokens. These come from blocks that only contained
+        # empty lines and spaces. They should not be printed in the final
+        # output, and then should not be counted for this operation.
+        #
+        if not self.directive and self.tokens == []:
+            return left_count
+
+        if self.directive:
+            out.write(str(self) + "\n")
+            left_count -= 1
+            if left_count == 0:
+                out.write(warning)
+                left_count = repeat_count
+
+        else:
+            for tok in self.tokens:
+                out.write(str(tok))
+                if tok.id == tokLN:
+                    left_count -= 1
+                    if left_count == 0:
+                        out.write(warning)
+                        left_count = repeat_count
+
+        return left_count
+
+
     def __repr__(self):
         """generate the representation of a given block"""
         if self.directive:
@@ -1651,7 +1736,6 @@
 
         return result
 
-
 class BlockList:
     """a convenience class used to hold and process a list of blocks returned by
        the cpp parser"""
@@ -1694,6 +1778,10 @@
             if b.isIf():
                 b.expr.removePrefixed(prefix,names)
 
+    def removeWhiteSpace(self):
+        for b in self.blocks:
+            b.removeWhiteSpace()
+
     def optimizeAll(self,macros):
         self.optimizeMacros(macros)
         self.optimizeIf01()
@@ -1713,72 +1801,17 @@
     def write(self,out):
         out.write(str(self))
 
+    def writeWithWarning(self,out,warning,repeat_count):
+        left_count = repeat_count
+        for b in self.blocks:
+            left_count = b.writeWithWarning(out,warning,left_count,repeat_count)
+
     def removeComments(self):
         for b in self.blocks:
             for tok in b.tokens:
                 if tok.id == tokSPACE:
                     tok.value = " "
 
-    def removeEmptyLines(self):
-        # state = 1 => previous line was tokLN
-        # state = 0 => previous line was directive
-        state  = 1
-        for b in self.blocks:
-            if b.isDirective():
-                #print "$$$ directive %s" % str(b)
-                state = 0
-            else:
-                # a tokLN followed by spaces is replaced by a single tokLN
-                # several successive tokLN are replaced by a single one
-                #
-                dst   = []
-                src   = b.tokens
-                n     = len(src)
-                i     = 0
-                #print "$$$ parsing %s" % repr(src)
-                while i < n:
-                    # find final tokLN
-                    j = i
-                    while j < n and src[j].id != tokLN:
-                        j += 1
-
-                    if j >= n:
-                        # uhhh
-                        dst += src[i:]
-                        break
-
-                    if src[i].id == tokSPACE:
-                        k = i+1
-                        while src[k].id == tokSPACE:
-                            k += 1
-
-                        if k == j: # empty lines with spaces in it
-                            i = j  # remove the spaces
-
-                    if i == j:
-                        # an empty line
-                        if state == 1:
-                            i += 1   # remove it
-                        else:
-                            state = 1
-                            dst.append(src[i])
-                            i   += 1
-                    else:
-                        # this line is not empty, remove trailing spaces
-                        k = j
-                        while k > i and src[k-1].id == tokSPACE:
-                            k -= 1
-
-                        nn = i
-                        while nn < k:
-                            dst.append(src[nn])
-                            nn += 1
-                        dst.append(src[j])
-                        state = 0
-                        i = j+1
-
-                b.tokens = dst
-
     def removeVarsAndFuncs(self,knownStatics=set()):
         """remove all extern and static declarations corresponding
            to variable and function declarations. we only accept typedefs
@@ -1789,66 +1822,118 @@
            which is useful for optimized byteorder swap functions and
            stuff like that.
            """
-        # state = 1 => typedef/struct encountered
-        # state = 2 => vars or func declaration encountered, skipping until ";"
         # state = 0 => normal (i.e. LN + spaces)
+        # state = 1 => typedef/struct encountered, ends with ";"
+        # state = 2 => var declaration encountered, ends with ";"
+        # state = 3 => func declaration encountered, ends with "}"
         state      = 0
         depth      = 0
         blocks2    = []
+        skipTokens = False
         for b in self.blocks:
             if b.isDirective():
                 blocks2.append(b)
             else:
                 n     = len(b.tokens)
                 i     = 0
-                first = 0
-                if state == 2:
+                if skipTokens:
                     first = n
+                else:
+                    first = 0
                 while i < n:
                     tok = b.tokens[i]
-                    if state == 0:
-                        bad = 0
-                        if tok.id in [tokLN, tokSPACE]:
-                            pass
-                        elif tok.value in [ 'struct', 'typedef', 'enum', 'union', '__extension__' ]:
-                            state = 1
-                        else:
-                            if tok.value in [ 'static', 'extern', '__KINLINE' ]:
-                                j = i+1
-                                ident = ""
-                                while j < n and not (b.tokens[j].id in [ '(', ';' ]):
-                                    if b.tokens[j].id == tokIDENT:
-                                        ident = b.tokens[j].value
-                                    j += 1
-                                if j < n and ident in knownStatics:
-                                    # this is a known static, we're going to keep its
-                                    # definition in the final output
-                                    state = 1
-                                else:
-                                    #print "### skip static '%s'" % ident
-                                    pass
-
-                            if state == 0:
-                                if i > first:
-                                    #print "### intermediate from '%s': '%s'" % (tok.value, repr(b.tokens[first:i]))
-                                    blocks2.append( Block(b.tokens[first:i]) )
-                                state = 2
-                                first = n
-
-                    else:  # state > 0
-                        if tok.id == '{':
+                    tokid = tok.id
+                    # If we are not looking for the start of a new
+                    # type/var/func, then skip over tokens until
+                    # we find our terminator, managing the depth of
+                    # accolades as we go.
+                    if state > 0:
+                        terminator = False
+                        if tokid == '{':
                             depth += 1
-
-                        elif tok.id == '}':
+                        elif tokid == '}':
                             if depth > 0:
                                 depth -= 1
+                            if (depth == 0) and (state == 3):
+                                terminator = True
+                        elif tokid == ';' and depth == 0:
+                            terminator = True
 
-                        elif depth == 0 and tok.id == ';':
-                            if state == 2:
-                                first = i+1
+                        if terminator:
+                            # we found the terminator
                             state = 0
+                            if skipTokens:
+                                skipTokens = False
+                                first = i+1
 
-                    i += 1
+                        i = i+1
+                        continue
+
+                    # We are looking for the start of a new type/func/var
+                    # ignore whitespace
+                    if tokid in [tokLN, tokSPACE]:
+                        i = i+1
+                        continue
+
+                    # Is it a new type definition, then start recording it
+                    if tok.value in [ 'struct', 'typedef', 'enum', 'union', '__extension__' ]:
+                        #print "$$$ keep type declr" + repr(b.tokens[i:])
+                        state = 1
+                        i     = i+1
+                        continue
+
+                    # Is it a variable or function definition. If so, first
+                    # try to determine which type it is, and also extract
+                    # its name.
+                    #
+                    # We're going to parse the next tokens of the same block
+                    # until we find a semi-column or a left parenthesis.
+                    #
+                    # The semi-column corresponds to a variable definition,
+                    # the left-parenthesis to a function definition.
+                    #
+                    # We also assume that the var/func name is the last
+                    # identifier before the terminator.
+                    #
+                    j = i+1
+                    ident = ""
+                    while j < n:
+                        tokid = b.tokens[j].id
+                        if tokid == '(':  # a function declaration
+                            state = 3
+                            break
+                        elif tokid == ';': # a variable declaration
+                            state = 2
+                            break
+                        if tokid == tokIDENT:
+                            ident = b.tokens[j].value
+                        j += 1
+
+                    if j >= n:
+                        # This can only happen when the declaration
+                        # does not end on the current block (e.g. with
+                        # a directive mixed inside it.
+                        #
+                        # We will treat it as malformed because
+                        # it's very hard to recover from this case
+                        # without making our parser much more
+                        # complex.
+                        #
+                        #print "### skip unterminated static '%s'" % ident
+                        break
+
+                    if ident in knownStatics:
+                        #print "### keep var/func '%s': %s" % (ident,repr(b.tokens[i:j]))
+                        pass
+                    else:
+                        # We're going to skip the tokens for this declaration
+                        #print "### skip variable /func'%s': %s" % (ident,repr(b.tokens[i:j]))
+                        if i > first:
+                            blocks2.append( Block(b.tokens[first:i]))
+                        skipTokens = True
+                        first      = n
+
+                    i = i+1
 
                 if i > first:
                     #print "### final '%s'" % repr(b.tokens[first:i])
diff --git a/libc/kernel/tools/defaults.py b/libc/kernel/tools/defaults.py
index ca7e6bb..2bee4ec 100644
--- a/libc/kernel/tools/defaults.py
+++ b/libc/kernel/tools/defaults.py
@@ -16,7 +16,11 @@
 
 # path to the directory containing the original kernel headers
 #
-kernel_original_path = os.path.normpath( find_program_dir() + '/../original' )
+kernel_original_path = os.path.normpath( find_program_dir() + '/../../../../external/kernel-headers/original' )
+
+# path to the default location of the cleaned-up headers
+#
+kernel_cleaned_path = os.path.normpath( find_program_dir() + '/..' )
 
 # a special value that is used to indicate that a given macro is known to be
 # undefined during optimization
@@ -45,7 +49,7 @@
 
 # Replace tokens in the output according to this mapping
 kernel_token_replacements = {
-    {"asm": "__asm__"},
+    "asm": "__asm__",
     }
 
 # this is the set of known static inline functions that we want to keep
@@ -112,6 +116,18 @@
  ***   structures, and macros generated from the original header, and thus,
  ***   contains no copyrightable information.
  ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
  ****************************************************************************
  ****************************************************************************/
 """
+
+# This is the warning line that will be inserted every N-th line in the output
+kernel_warning = """\
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+"""
diff --git a/libc/kernel/tools/find_headers.py b/libc/kernel/tools/find_headers.py
index 8e72bb6..3d622a8 100755
--- a/libc/kernel/tools/find_headers.py
+++ b/libc/kernel/tools/find_headers.py
@@ -3,7 +3,7 @@
 # this program is used to find source code that includes linux kernel headers directly
 # (e.g. with #include <linux/...> or #include <asm/...>)
 #
-# then it lists
+# then it lists them on the standard output.
 
 import sys, cpp, glob, os, re, getopt, kernel
 from utils import *
@@ -12,20 +12,14 @@
 program_dir = find_program_dir()
 
 wanted_archs   = kernel_archs
-wanted_include = os.path.normpath(program_dir + '/../original')
-wanted_config  = os.path.normpath(program_dir + '/../original/config')
+wanted_config  = None
 
 def usage():
     print """\
-  usage:  find_headers.py [options] (file|directory|@listfile)+
+  usage:  find_headers.py [options] <kernel-root> (file|directory|@listfile)+
 
      options:
-        -d <include-dir>   specify alternate kernel headers
-                           'include' directory
-                           ('%s' by default)
-
-        -c <file>          specify alternate .config file
-                           ('%s' by default)
+        -c <file>          specify .config file (none by default)
 
         -a <archs>         used to specify an alternative list
                            of architectures to support
@@ -37,12 +31,12 @@
     by a set of source files or directories containing them. the search
     is recursive to find *all* required files.
 
-""" % ( wanted_include, wanted_config, string.join(kernel_archs,",") )
+""" % ( string.join(kernel_archs,",") )
     sys.exit(1)
 
 
 try:
-    optlist, args = getopt.getopt( sys.argv[1:], 'vc:d:a:' )
+    optlist, args = getopt.getopt( sys.argv[1:], 'vc:d:a:k:' )
 except:
     # unrecognized option
     print "error: unrecognized option"
@@ -51,8 +45,6 @@
 for opt, arg in optlist:
     if opt == '-a':
         wanted_archs = string.split(arg,',')
-    elif opt == '-d':
-        wanted_include = arg
     elif opt == '-c':
         wanted_config = arg
     elif opt == '-v':
@@ -62,10 +54,10 @@
     else:
         usage()
 
-if len(args) < 1:
+if len(args) < 2:
     usage()
 
-kernel_root = wanted_include
+kernel_root = args[0]
 if not os.path.exists(kernel_root):
     sys.stderr.write( "error: directory '%s' does not exist\n" % kernel_root )
     sys.exit(1)
@@ -74,26 +66,26 @@
     sys.stderr.write( "error: '%s' is not a directory\n" % kernel_root )
     sys.exit(1)
 
-if not os.path.isdir(kernel_root+"/linux"):
-    sys.stderr.write( "error: '%s' does not have a 'linux' directory\n" % kernel_root )
+if not os.path.isdir(kernel_root+"/include/linux"):
+    sys.stderr.write( "error: '%s' does not have an 'include/linux' directory\n" % kernel_root )
     sys.exit(1)
 
-if not os.path.exists(wanted_config):
-    sys.stderr.write( "error: file '%s' does not exist\n" % wanted_config )
-    sys.exit(1)
+if wanted_config:
+    if not os.path.exists(wanted_config):
+        sys.stderr.write( "error: file '%s' does not exist\n" % wanted_config )
+        sys.exit(1)
 
-if not os.path.isfile(wanted_config):
-    sys.stderr.write( "error: '%s' is not a file\n" % wanted_config )
-    sys.exit(1)
+    if not os.path.isfile(wanted_config):
+        sys.stderr.write( "error: '%s' is not a file\n" % wanted_config )
+        sys.exit(1)
 
 # find all architectures in the kernel tree
-re_asm_ = re.compile(r"asm-(\w+)")
 archs   = []
-for dir in os.listdir(kernel_root):
-    m = re_asm_.match(dir)
-    if m:
-        if verbose: print ">> found kernel arch '%s'" % m.group(1)
-        archs.append(m.group(1))
+for archdir in os.listdir(kernel_root+"/arch"):
+    if os.path.exists("%s/arch/%s/include/asm" % (kernel_root, archdir)):
+        if verbose:
+            print "Found arch '%s'" % archdir
+        archs.append(archdir)
 
 # if we're using the 'kernel_headers' directory, there is only asm/
 # and no other asm-<arch> directories (arm is assumed, which sucks)
@@ -126,6 +118,7 @@
 
 # helper function used to walk the user files
 def parse_file(path, parser):
+    #print "parse %s" % path
     parser.parseFile(path)
 
 
@@ -136,7 +129,8 @@
 # try to read the config file
 try:
     cparser = kernel.ConfigParser()
-    cparser.parseFile( wanted_config )
+    if wanted_config:
+        cparser.parseFile( wanted_config )
 except:
     sys.stderr.write( "error: can't parse '%s'" % wanted_config )
     sys.exit(1)
@@ -145,7 +139,8 @@
 
 # first, obtain the list of kernel files used by our clients
 fparser = kernel.HeaderScanner()
-walk_source_files( args, parse_file, fparser, excludes=["kernel_headers"] )
+dir_excludes=[".repo","external/kernel-headers","ndk","out","prebuilt","bionic/libc/kernel","development/ndk","external/qemu/distrib"]
+walk_source_files( args[1:], parse_file, fparser, excludes=["./"+f for f in dir_excludes] )
 headers = fparser.getHeaders()
 files   = fparser.getFiles()
 
@@ -170,6 +165,6 @@
     sys.exit(0)
 
 for h in sorted(headers):
-    print h
+    print "%s" % h
 
 sys.exit(0)
diff --git a/libc/kernel/tools/kernel.py b/libc/kernel/tools/kernel.py
index 9d9b5f0..c203985 100644
--- a/libc/kernel/tools/kernel.py
+++ b/libc/kernel/tools/kernel.py
@@ -55,8 +55,11 @@
     #    <asm-generic/*>
     #    <mtd/*>
     #
-    re_combined =\
-       re.compile(r"^.*<((%s)/[\d\w_\+\.\-/]*)>.*$" % string.join(kernel_dirs,"|") )
+    re_combined_str=\
+       r"^.*<((%s)/[\d\w_\+\.\-/]*)>.*$" % string.join(kernel_dirs,"|")
+
+    re_combined = re.compile(re_combined_str)
+
     # some kernel files choose to include files with relative paths (x86 32/64
     # dispatch for instance)
     re_rel_dir = re.compile(r'^.*"([\d\w_\+\.\-/]+)".*$')
diff --git a/libc/kernel/tools/update_all.py b/libc/kernel/tools/update_all.py
index d25dc0e..6a730a5 100755
--- a/libc/kernel/tools/update_all.py
+++ b/libc/kernel/tools/update_all.py
@@ -6,7 +6,7 @@
 
 def usage():
     print """\
-  usage: %(progname)s
+  usage: %(progname)s [kernel-original-path]
 
     this program is used to update all the auto-generated clean headers
     used by the Bionic C library. it assumes the following:
@@ -31,13 +31,19 @@
     sys.stderr.write( "error: unrecognized option\n" )
     usage()
 
-if len(optlist) > 0 or len(args) > 0:
+if len(optlist) > 0 or len(args) > 1:
     usage()
 
 progdir = find_program_dir()
-original_dir = os.path.normpath( progdir + "/../original" )
-if not os.path.isdir( original_dir ):
-    panic( "required directory does not exists: %s\n" % original_dir )
+
+if len(args) == 1:
+    original_dir = arg[0]
+    if not os.path.isdir(original_dir):
+        panic( "Not a directory: %s" % original_dir )
+else:
+    original_dir = kernel_original_path
+    if not os.path.isdir(original_dir):
+        panic( "Missing directory, please specify one through command-line: %s" % original_dir )
 
 # find all source files in 'original'
 #
@@ -57,29 +63,36 @@
 
 #print "OLD " + repr(b.old_files)
 
+oldlen = 120
 for path in sources:
-    dst_path, newdata = clean_header.cleanupFile(path)
+    dst_path, newdata = clean_header.cleanupFile(path, original_dir)
     if not dst_path:
         continue
 
     b.readFile( dst_path )
     r = b.editFile( dst_path, newdata )
     if r == 0:
-        r = "unchanged"
+        state = "unchanged"
     elif r == 1:
-        r = "edited"
+        state = "edited"
     else:
-        r = "added"
+        state = "added"
 
-    print "cleaning: %-*s -> %-*s (%s)" % ( 35, path, 35, dst_path, r )
+    str = "cleaning: %-*s -> %-*s (%s)" % ( 35, "<original>" + path[len(original_dir):], 35, dst_path, state )
+    if sys.stdout.isatty():
+        print "%-*s" % (oldlen,str),
+        if (r == 0):
+            print "\r",
+        else:
+            print "\n",
+            oldlen = 0
+    else:
+        print str
 
-# We don't use Perforce anymore, but just in case, define ANDROID_USE_P4
-# in your environment if you think you need it.
-usePerforce = os.environ.has_key("ANDROID_USE_P4")
+    oldlen = len(str)
 
-if usePerforce:
-    b.updateP4Files()
-else:
-    b.updateFiles()
+print "%-*s" % (oldlen,"Done!")
+
+b.updateGitFiles()
 
 sys.exit(0)
diff --git a/libc/kernel/tools/utils.py b/libc/kernel/tools/utils.py
index 763c7d2..f4cf540 100644
--- a/libc/kernel/tools/utils.py
+++ b/libc/kernel/tools/utils.py
@@ -231,6 +231,15 @@
 def walk_source_files(paths,callback,args,excludes=[]):
     """recursively walk a list of paths and files, only keeping the source files in directories"""
     for path in paths:
+        if len(path) > 0 and path[0] == '@':
+            # this is the name of another file, include it and parse it
+            path = path[1:]
+            if os.path.exists(path):
+                for line in open(path):
+                    if len(line) > 0 and line[-1] == '\n':
+                        line = line[:-1]
+                    walk_source_files([line],callback,args,excludes)
+            continue
         if not os.path.isdir(path):
             callback(path,args)
         else:
@@ -238,7 +247,7 @@
                 #print "w-- %s (ex: %s)" % (repr((root,dirs)), repr(excludes))
                 if len(excludes):
                     for d in dirs[:]:
-                        if d in excludes:
+                        if os.path.join(root,d) in excludes:
                             dirs.remove(d)
                 for f in files:
                     r, ext = os.path.splitext(f)
@@ -395,3 +404,19 @@
             D2("P4 DELETES: %s" % files)
             o = commands.getoutput( "p4 delete " + files )
             D2( o )
+
+    def updateGitFiles(self):
+        adds, deletes, edits = self.getChanges()
+
+        if adds:
+            for dst in sorted(adds):
+                self._writeFile(dst)
+            commands.getoutput("git add " + " ".join(adds))
+
+        if deletes:
+            commands.getoutput("git rm " + " ".join(deletes))
+
+        if edits:
+            for dst in sorted(edits):
+                self._writeFile(dst)
+            commands.getoutput("git add " + " ".join(edits))
diff --git a/libc/stdio/asprintf.c b/libc/stdio/asprintf.c
index 1257c7f..c3d8d61 100644
--- a/libc/stdio/asprintf.c
+++ b/libc/stdio/asprintf.c
@@ -38,7 +38,7 @@
 		goto err;
 	f._bf._size = f._w = 127;		/* Leave room for the NUL */
 	va_start(ap, fmt);
-	ret = vfprintf(&f, fmt, ap);
+	ret = __vfprintf(&f, fmt, ap);
 	va_end(ap);
 	if (ret == -1)
 		goto err;
diff --git a/libc/stdio/clrerr.c b/libc/stdio/clrerr.c
index 20f1994..cb6c4df 100644
--- a/libc/stdio/clrerr.c
+++ b/libc/stdio/clrerr.c
@@ -32,12 +32,13 @@
  */
 
 #include <stdio.h>
+#include "local.h"
 #undef	clearerr
 
 void
 clearerr(FILE *fp)
 {
-	flockfile(fp);
+	FLOCKFILE(fp);
 	__sclearerr(fp);
-	funlockfile(fp);
+	FUNLOCKFILE(fp);
 }
diff --git a/libc/stdio/fclose.c b/libc/stdio/fclose.c
index e94292b..8c3bac4 100644
--- a/libc/stdio/fclose.c
+++ b/libc/stdio/fclose.c
@@ -36,9 +36,6 @@
 #include <stdlib.h>
 #include "local.h"
 
-/* BIONIC: remove any file lock associated with a FILE* pointer */
-extern void __fremovelock(FILE *fp);
-
 int
 fclose(FILE *fp)
 {
@@ -48,6 +45,7 @@
 		errno = EBADF;
 		return (EOF);
 	}
+	FLOCKFILE(fp);
 	WCIO_FREE(fp);
 	r = fp->_flags & __SWR ? __sflush(fp) : 0;
 	if (fp->_close != NULL && (*fp->_close)(fp->_cookie) < 0)
@@ -58,8 +56,8 @@
 		FREEUB(fp);
 	if (HASLB(fp))
 		FREELB(fp);
-	fp->_flags = 0;		/* Release this FILE for reuse. */
 	fp->_r = fp->_w = 0;	/* Mess up if reaccessed. */
-	__fremovelock(fp);
+	fp->_flags = 0;		/* Release this FILE for reuse. */
+	FUNLOCKFILE(fp);
 	return (r);
 }
diff --git a/libc/stdio/feof.c b/libc/stdio/feof.c
index eb742da..0fa65b0 100644
--- a/libc/stdio/feof.c
+++ b/libc/stdio/feof.c
@@ -32,6 +32,7 @@
  */
 
 #include <stdio.h>
+#include "local.h"
 
 /*
  * A subroutine version of the macro feof.
@@ -41,5 +42,10 @@
 int
 feof(FILE *fp)
 {
-	return (__sfeof(fp));
+	int ret;
+
+	FLOCKFILE(fp);
+	ret = __sfeof(fp);
+	FUNLOCKFILE(fp);
+	return (ret);
 }
diff --git a/libc/stdio/fflush.c b/libc/stdio/fflush.c
index 3f72ad8..e69bdcc 100644
--- a/libc/stdio/fflush.c
+++ b/libc/stdio/fflush.c
@@ -39,14 +39,18 @@
 int
 fflush(FILE *fp)
 {
+	int r;
 
 	if (fp == NULL)
-		return (_fwalk(__sflush));
+		return (_fwalk(__sflush_locked));
+	FLOCKFILE(fp);
 	if ((fp->_flags & (__SWR | __SRW)) == 0) {
 		errno = EBADF;
-		return (EOF);
-	}
-	return (__sflush(fp));
+		r = EOF;
+	} else
+		r = __sflush(fp);
+	FUNLOCKFILE(fp);
+	return (r);
 }
 
 int
@@ -80,3 +84,14 @@
 	}
 	return (0);
 }
+
+int
+__sflush_locked(FILE *fp)
+{
+	int r;
+
+	FLOCKFILE(fp);
+	r = __sflush(fp);
+	FUNLOCKFILE(fp);
+	return (r);
+}
diff --git a/libc/stdio/fgetc.c b/libc/stdio/fgetc.c
index 53e2948..0a6d54e 100644
--- a/libc/stdio/fgetc.c
+++ b/libc/stdio/fgetc.c
@@ -36,5 +36,5 @@
 int
 fgetc(FILE *fp)
 {
-	return (__sgetc(fp));
+	return (getc(fp));
 }
diff --git a/libc/stdio/fgetln.c b/libc/stdio/fgetln.c
index 95a5b31..0947dd8 100644
--- a/libc/stdio/fgetln.c
+++ b/libc/stdio/fgetln.c
@@ -71,19 +71,18 @@
 fgetln(FILE *fp, size_t *lenp)
 {
 	unsigned char *p;
+	char *ret;
 	size_t len;
 	size_t off;
 
+	FLOCKFILE(fp);
+
 	/* make sure there is input */
-	if (fp->_r <= 0 && __srefill(fp)) {
-		*lenp = 0;
-		return (NULL);
-	}
+	if (fp->_r <= 0 && __srefill(fp))
+		goto error;
 
 	/* look for a newline in the input */
 	if ((p = memchr((void *)fp->_p, '\n', fp->_r)) != NULL) {
-		char *ret;
-
 		/*
 		 * Found one.  Flag buffer as modified to keep fseek from
 		 * `optimising' a backward seek, in case the user stomps on
@@ -95,6 +94,7 @@
 		fp->_flags |= __SMOD;
 		fp->_r -= len;
 		fp->_p = p;
+		FUNLOCKFILE(fp);
 		return (ret);
 	}
 
@@ -139,12 +139,15 @@
 		break;
 	}
 	*lenp = len;
+	ret = (char *)fp->_lb._base;
 #ifdef notdef
-	fp->_lb._base[len] = '\0';
+	ret[len] = '\0';
 #endif
-	return ((char *)fp->_lb._base);
+	FUNLOCKFILE(fp);
+	return (ret);
 
 error:
 	*lenp = 0;		/* ??? */
+	FUNLOCKFILE(fp);
 	return (NULL);		/* ??? */
 }
diff --git a/libc/stdio/fgets.c b/libc/stdio/fgets.c
index f26385d..311b7b2 100644
--- a/libc/stdio/fgets.c
+++ b/libc/stdio/fgets.c
@@ -51,6 +51,7 @@
 	if (n <= 0)		/* sanity check */
 		return (NULL);
 
+	FLOCKFILE(fp);
 	_SET_ORIENTATION(fp, -1);
 	s = buf;
 	n--;			/* leave space for NUL */
@@ -61,8 +62,10 @@
 		if (fp->_r <= 0) {
 			if (__srefill(fp)) {
 				/* EOF/error: stop with partial or no line */
-				if (s == buf)
+				if (s == buf) {
+					FUNLOCKFILE(fp);
 					return (NULL);
+                                }
 				break;
 			}
 		}
@@ -84,6 +87,7 @@
 			fp->_p = t;
 			(void)memcpy((void *)s, (void *)p, len);
 			s[len] = '\0';
+			FUNLOCKFILE(fp);
 			return (buf);
 		}
 		fp->_r -= len;
@@ -93,5 +97,6 @@
 		n -= len;
 	}
 	*s = '\0';
+	FUNLOCKFILE(fp);
 	return (buf);
 }
diff --git a/libc/stdio/fileno.c b/libc/stdio/fileno.c
index 0fd985b..cbefdeb 100644
--- a/libc/stdio/fileno.c
+++ b/libc/stdio/fileno.c
@@ -32,6 +32,7 @@
  */
 
 #include <stdio.h>
+#include "local.h"
 
 /*
  * A subroutine version of the macro fileno.
@@ -41,5 +42,10 @@
 int
 fileno(FILE *fp)
 {
-	return (__sfileno(fp));
+	int ret;
+
+	FLOCKFILE(fp);
+	ret = __sfileno(fp);
+	FUNLOCKFILE(fp);
+	return (ret);
 }
diff --git a/libc/stdio/findfp.c b/libc/stdio/findfp.c
index 1d0f9c5..a659c87 100644
--- a/libc/stdio/findfp.c
+++ b/libc/stdio/findfp.c
@@ -39,6 +39,7 @@
 #include <string.h>
 #include "local.h"
 #include "glue.h"
+#include "thread_private.h"
 
 int	__sdidinit;
 
@@ -54,6 +55,8 @@
 static FILE usual[FOPEN_MAX - 3];
 static struct __sfileext usualext[FOPEN_MAX - 3];
 static struct glue uglue = { 0, FOPEN_MAX - 3, usual };
+static struct glue *lastglue = &uglue;
+_THREAD_PRIVATE_MUTEX(__sfp_mutex);
 
 static struct __sfileext __sFext[3];
 FILE __sF[3] = {
@@ -104,16 +107,25 @@
 
 	if (!__sdidinit)
 		__sinit();
-	for (g = &__sglue;; g = g->next) {
+
+	_THREAD_PRIVATE_MUTEX_LOCK(__sfp_mutex);
+	for (g = &__sglue; g != NULL; g = g->next) {
 		for (fp = g->iobs, n = g->niobs; --n >= 0; fp++)
 			if (fp->_flags == 0)
 				goto found;
-		if (g->next == NULL && (g->next = moreglue(NDYNAMIC)) == NULL)
-			break;
 	}
-	return (NULL);
+
+	/* release lock while mallocing */
+	_THREAD_PRIVATE_MUTEX_UNLOCK(__sfp_mutex);
+	if ((g = moreglue(NDYNAMIC)) == NULL)
+		return (NULL);
+	_THREAD_PRIVATE_MUTEX_LOCK(__sfp_mutex);
+	lastglue->next = g;
+	lastglue = g;
+	fp = g->iobs;
 found:
 	fp->_flags = 1;		/* reserve this slot; caller sets real flags */
+	_THREAD_PRIVATE_MUTEX_UNLOCK(__sfp_mutex);
 	fp->_p = NULL;		/* no current pointer */
 	fp->_w = 0;		/* nothing to read or write */
 	fp->_r = 0;
@@ -144,8 +156,12 @@
 	n = getdtablesize() - FOPEN_MAX + 20;		/* 20 for slop. */
 	for (g = &__sglue; (n -= g->niobs) > 0 && g->next; g = g->next)
 		/* void */;
-	if (n > 0)
-		g->next = moreglue(n);
+	if (n > 0 && ((g = moreglue(n)) != NULL)) {
+		_THREAD_PRIVATE_MUTEX_LOCK(__sfp_mutex);
+		lastglue->next = g;
+		lastglue = g;
+		_THREAD_PRIVATE_MUTEX_UNLOCK(__sfp_mutex);
+	}
 }
 #endif
 
@@ -170,12 +186,18 @@
 void
 __sinit(void)
 {
+	_THREAD_PRIVATE_MUTEX(__sinit_mutex);
 	int i;
 
+	_THREAD_PRIVATE_MUTEX_LOCK(__sinit_mutex);
+	if (__sdidinit)
+		goto out;	/* bail out if caller lost the race */
 	for (i = 0; i < FOPEN_MAX - 3; i++) {
 		_FILEEXT_SETUP(usual+i, usualext+i);
 	}
 	/* make sure we clean up on exit */
 	__atexit_register_cleanup(_cleanup); /* conservative */
 	__sdidinit = 1;
+out:
+	_THREAD_PRIVATE_MUTEX_UNLOCK(__sinit_mutex);
 }
diff --git a/libc/stdio/fpurge.c b/libc/stdio/fpurge.c
index fa0213a..e04c4fe 100644
--- a/libc/stdio/fpurge.c
+++ b/libc/stdio/fpurge.c
@@ -43,7 +43,9 @@
 int
 fpurge(FILE *fp)
 {
+	FLOCKFILE(fp);
 	if (!fp->_flags) {
+		FUNLOCKFILE(fp);
 		errno = EBADF;
 		return(EOF);
 	}
@@ -54,5 +56,6 @@
 	fp->_p = fp->_bf._base;
 	fp->_r = 0;
 	fp->_w = fp->_flags & (__SLBF|__SNBF) ? 0 : fp->_bf._size;
+	FUNLOCKFILE(fp);
 	return (0);
 }
diff --git a/libc/stdio/fputc.c b/libc/stdio/fputc.c
index 2a6e7b7..90809e2 100644
--- a/libc/stdio/fputc.c
+++ b/libc/stdio/fputc.c
@@ -33,14 +33,9 @@
 
 #include <stdio.h>
 #include <errno.h>
-#include "local.h"
 
 int
 fputc(int c, FILE *fp)
 {
-	if (cantwrite(fp)) {
-		errno = EBADF;
-		return (EOF);
-	}
 	return (putc(c, fp));
 }
diff --git a/libc/stdio/fputs.c b/libc/stdio/fputs.c
index 7434ca8..c2462ba 100644
--- a/libc/stdio/fputs.c
+++ b/libc/stdio/fputs.c
@@ -44,11 +44,15 @@
 {
 	struct __suio uio;
 	struct __siov iov;
+	int ret;
 
 	iov.iov_base = (void *)s;
 	iov.iov_len = uio.uio_resid = strlen(s);
 	uio.uio_iov = &iov;
 	uio.uio_iovcnt = 1;
+	FLOCKFILE(fp);
 	_SET_ORIENTATION(fp, -1);
-	return (__sfvwrite(fp, &uio));
+	ret = __sfvwrite(fp, &uio);
+	FUNLOCKFILE(fp);
+	return (ret);
 }
diff --git a/libc/stdio/fread.c b/libc/stdio/fread.c
index 69c40b3..649db17 100644
--- a/libc/stdio/fread.c
+++ b/libc/stdio/fread.c
@@ -39,9 +39,8 @@
 static int
 lflush(FILE *fp)
 {
-
     if ((fp->_flags & (__SLBF|__SWR)) == (__SLBF|__SWR))
-        return (__sflush(fp));
+        return (__sflush_locked(fp));
     return (0);
 }
 
@@ -60,6 +59,7 @@
      */
     if ((resid = count * size) == 0)
         return (0);
+    FLOCKFILE(fp);
     if (fp->_r < 0)
         fp->_r = 0;
     total = resid;
@@ -79,20 +79,25 @@
         fp->_r = 0;     /* largely a convenience for callers */
 
         /* SysV does not make this test; take it out for compatibility */
-        if (fp->_flags & __SEOF)
+        if (fp->_flags & __SEOF) {
+            FUNLOCKFILE(fp);
             return (EOF);
+        }
 
         /* if not already reading, have to be reading and writing */
         if ((fp->_flags & __SRD) == 0) {
             if ((fp->_flags & __SRW) == 0) {
-                errno = EBADF;
                 fp->_flags |= __SERR;
+                FUNLOCKFILE(fp);
+                errno = EBADF;
                 return (EOF);
             }
             /* switch to reading */
             if (fp->_flags & __SWR) {
-                if (__sflush(fp))
+                if (__sflush(fp)) {
+                    FUNLOCKFILE(fp);
                     return (EOF);
+                }
                 fp->_flags &= ~__SWR;
                 fp->_w = 0;
                 fp->_lbfsize = 0;
@@ -116,8 +121,16 @@
          * standard.
          */
 
-        if (fp->_flags & (__SLBF|__SNBF))
+        if (fp->_flags & (__SLBF|__SNBF)) {
+            /* Ignore this file in _fwalk to deadlock. */
+            fp->_flags |= __SIGN;
             (void) _fwalk(lflush);
+            fp->_flags &= ~__SIGN;
+
+            /* Now flush this file without locking it. */
+            if ((fp->_flags & (__SLBF|__SWR)) == (__SLBF|__SWR))
+                __sflush(fp);
+        }
 
         while (resid > 0) {
             int   len = (*fp->_read)(fp->_cookie, p, resid );
@@ -128,11 +141,13 @@
                 else {
                     fp->_flags |= __SERR;
                 }
+                FUNLOCKFILE(fp);
                 return ((total - resid) / size);
             }
             p     += len;
             resid -= len;
         }
+        FUNLOCKFILE(fp);
         return (count);
     }
     else
@@ -146,6 +161,7 @@
             resid -= r;
             if (__srefill(fp)) {
                 /* no more input: return partial result */
+                FUNLOCKFILE(fp);
                 return ((total - resid) / size);
             }
         }
@@ -154,5 +170,6 @@
     (void)memcpy((void *)p, (void *)fp->_p, resid);
     fp->_r -= resid;
     fp->_p += resid;
+    FUNLOCKFILE(fp);
     return (count);
 }
diff --git a/libc/stdio/freopen.c b/libc/stdio/freopen.c
index 59b2228..da3a674 100644
--- a/libc/stdio/freopen.c
+++ b/libc/stdio/freopen.c
@@ -59,6 +59,8 @@
 	if (!__sdidinit)
 		__sinit();
 
+	FLOCKFILE(fp);
+
 	/*
 	 * There are actually programs that depend on being able to "freopen"
 	 * descriptors that weren't originally open.  Keep this from breaking.
@@ -120,6 +122,7 @@
 
 	if (f < 0) {			/* did not get it after all */
 		fp->_flags = 0;		/* set it free */
+		FUNLOCKFILE(fp);
 		errno = sverrno;	/* restore in case _close clobbered */
 		return (NULL);
 	}
@@ -154,5 +157,6 @@
 	 */
 	if (oflags & O_APPEND)
 		(void) __sseek((void *)fp, (fpos_t)0, SEEK_END);
+	FUNLOCKFILE(fp);
 	return (fp);
 }
diff --git a/libc/stdio/fseek.c b/libc/stdio/fseek.c
index 8581b62..38697f5 100644
--- a/libc/stdio/fseek.c
+++ b/libc/stdio/fseek.c
@@ -70,6 +70,7 @@
 	 * Change any SEEK_CUR to SEEK_SET, and check `whence' argument.
 	 * After this, whence is either SEEK_SET or SEEK_END.
 	 */
+	FLOCKFILE(fp);
 	switch (whence) {
 
 	case SEEK_CUR:
@@ -83,8 +84,10 @@
 			curoff = fp->_offset;
 		else {
 			curoff = (*seekfn)(fp->_cookie, (fpos_t)0, SEEK_CUR);
-			if (curoff == (fpos_t)-1)
+			if (curoff == (fpos_t)-1) {
+				FUNLOCKFILE(fp);
 				return (EOF);
+			}
 		}
 		if (fp->_flags & __SRD) {
 			curoff -= fp->_r;
@@ -105,6 +108,7 @@
 		break;
 
 	default:
+		FUNLOCKFILE(fp);
 		errno = EINVAL;
 		return (EOF);
 	}
@@ -189,6 +193,7 @@
 		if (HASUB(fp))
 			FREEUB(fp);
 		fp->_flags &= ~__SEOF;
+		FUNLOCKFILE(fp);
 		return (0);
 	}
 
@@ -215,6 +220,7 @@
 		fp->_p += n;
 		fp->_r -= n;
 	}
+	FUNLOCKFILE(fp);
 	return (0);
 
 	/*
@@ -224,6 +230,7 @@
 dumb:
 	if (__sflush(fp) ||
 	    (*seekfn)(fp->_cookie, (fpos_t)offset, whence) == POS_ERR) {
+		FUNLOCKFILE(fp);
 		return (EOF);
 	}
 	/* success: clear EOF indicator and discard ungetc() data */
@@ -233,6 +240,7 @@
 	fp->_r = 0;
 	/* fp->_w = 0; */	/* unnecessary (I think...) */
 	fp->_flags &= ~__SEOF;
+	FUNLOCKFILE(fp);
 	return (0);
 }
 
diff --git a/libc/stdio/ftell.c b/libc/stdio/ftell.c
index b7d449e..9f850ee 100644
--- a/libc/stdio/ftell.c
+++ b/libc/stdio/ftell.c
@@ -45,20 +45,22 @@
 
 	if (fp->_seek == NULL) {
 		errno = ESPIPE;			/* historic practice */
-		return ((off_t)-1);
+		pos = -1;
+                goto out;
 	}
 
 	/*
 	 * Find offset of underlying I/O object, then
 	 * adjust for buffered bytes.
 	 */
+        FLOCKFILE(fp);
 	__sflush(fp);		/* may adjust seek offset on append stream */
 	if (fp->_flags & __SOFF)
 		pos = fp->_offset;
 	else {
 		pos = (*fp->_seek)(fp->_cookie, (fpos_t)0, SEEK_CUR);
-		if (pos == -1L)
-			return (pos);
+		if (pos == -1)
+			goto out;
 	}
 	if (fp->_flags & __SRD) {
 		/*
@@ -77,6 +79,7 @@
 		 */
 		pos += fp->_p - fp->_bf._base;
 	}
+out:	FUNLOCKFILE(fp);
 	return (pos);
 }
 
diff --git a/libc/stdio/fvwrite.c b/libc/stdio/fvwrite.c
index 57a57e6..39d0604 100644
--- a/libc/stdio/fvwrite.c
+++ b/libc/stdio/fvwrite.c
@@ -48,7 +48,7 @@
 __sfvwrite(FILE *fp, struct __suio *uio)
 {
 	size_t len;
-	char *p;
+	const char *p;
 	struct __siov *iov;
 	int w, s;
 	char *nl;
diff --git a/libc/stdio/fvwrite.h b/libc/stdio/fvwrite.h
index 2344e42..96f65de 100644
--- a/libc/stdio/fvwrite.h
+++ b/libc/stdio/fvwrite.h
@@ -36,7 +36,7 @@
  * I/O descriptors for __sfvwrite().
  */
 struct __siov {
-	void	*iov_base;
+	const void	*iov_base;
 	size_t	iov_len;
 };
 struct __suio {
diff --git a/libc/stdio/fwalk.c b/libc/stdio/fwalk.c
index 5606cf1..b1df891 100644
--- a/libc/stdio/fwalk.c
+++ b/libc/stdio/fwalk.c
@@ -45,8 +45,9 @@
 
 	ret = 0;
 	for (g = &__sglue; g != NULL; g = g->next)
-		for (fp = g->iobs, n = g->niobs; --n >= 0; fp++)
-			if (fp->_flags != 0)
+		for (fp = g->iobs, n = g->niobs; --n >= 0; fp++) {
+			if ((fp->_flags != 0) && ((fp->_flags & __SIGN) == 0))
 				ret |= (*function)(fp);
+		}
 	return (ret);
 }
diff --git a/libc/stdio/fwrite.c b/libc/stdio/fwrite.c
index 8a508dc..a97313e 100644
--- a/libc/stdio/fwrite.c
+++ b/libc/stdio/fwrite.c
@@ -45,6 +45,7 @@
 	size_t n;
 	struct __suio uio;
 	struct __siov iov;
+	int ret;
 
 	iov.iov_base = (void *)buf;
 	uio.uio_resid = iov.iov_len = n = count * size;
@@ -56,7 +57,10 @@
 	 * skip the divide if this happens, since divides are
 	 * generally slow and since this occurs whenever size==0.
 	 */
-	if (__sfvwrite(fp, &uio) == 0)
+	FLOCKFILE(fp);
+	ret = __sfvwrite(fp, &uio);
+	FUNLOCKFILE(fp);
+	if (ret == 0)
 		return (count);
 	return ((n - uio.uio_resid) / size);
 }
diff --git a/libc/stdio/getc.c b/libc/stdio/getc.c
index cdd5722..16a5b1d 100644
--- a/libc/stdio/getc.c
+++ b/libc/stdio/getc.c
@@ -32,6 +32,7 @@
  */
 
 #include <stdio.h>
+#include "local.h"
 
 /*
  * A subroutine version of the macro getc_unlocked.
@@ -54,8 +55,8 @@
 {
 	int c;
 
-	flockfile(fp);
+	FLOCKFILE(fp);
 	c = __sgetc(fp);
-	funlockfile(fp);
+	FUNLOCKFILE(fp);
 	return (c);
 }
diff --git a/libc/stdio/gets.c b/libc/stdio/gets.c
index 004eb99..93e2edd 100644
--- a/libc/stdio/gets.c
+++ b/libc/stdio/gets.c
@@ -32,6 +32,7 @@
  */
 
 #include <stdio.h>
+#include "local.h"
 
 __warn_references(gets,
     "warning: gets() is very unsafe; consider using fgets()");
@@ -42,14 +43,17 @@
 	int c;
 	char *s;
 
-	for (s = buf; (c = getchar()) != '\n';)
+	FLOCKFILE(stdin);
+	for (s = buf; (c = getchar_unlocked()) != '\n';)
 		if (c == EOF)
-			if (s == buf)
+			if (s == buf) {
+				FUNLOCKFILE(stdin);
 				return (NULL);
-			else
+			} else
 				break;
 		else
 			*s++ = c;
 	*s = '\0';
+	FUNLOCKFILE(stdin);
 	return (buf);
 }
diff --git a/libc/stdio/local.h b/libc/stdio/local.h
index 3db1fc5..6b2111a 100644
--- a/libc/stdio/local.h
+++ b/libc/stdio/local.h
@@ -46,6 +46,7 @@
  */
 
 int	__sflush(FILE *);
+int	__sflush_locked(FILE *);
 FILE	*__sfp(void);
 int	__srefill(FILE *);
 int	__sread(void *, char *, int);
@@ -59,6 +60,7 @@
 int	_fwalk(int (*)(FILE *));
 int	__swsetup(FILE *);
 int	__sflags(const char *, int *);
+int	__vfprintf(FILE *, const char *, __va_list);
 
 extern void __atexit_register_cleanup(void (*)(void));
 extern int __sdidinit;
@@ -89,3 +91,6 @@
 	free((char *)(fp)->_lb._base); \
 	(fp)->_lb._base = NULL; \
 }
+
+#define FLOCKFILE(fp)   do { if (__isthreaded) flockfile(fp); } while (0)
+#define FUNLOCKFILE(fp) do { if (__isthreaded) funlockfile(fp); } while (0)
diff --git a/libc/stdio/putc.c b/libc/stdio/putc.c
index 9250215..2b05504 100644
--- a/libc/stdio/putc.c
+++ b/libc/stdio/putc.c
@@ -60,8 +60,8 @@
 {
 	int ret;
 
-	flockfile(fp);
+	FLOCKFILE(fp);
 	ret = putc_unlocked(c, fp);
-	funlockfile(fp);
+	FUNLOCKFILE(fp);
 	return (ret);
 }
diff --git a/libc/stdio/puts.c b/libc/stdio/puts.c
index c6ecc24..4603a3d 100644
--- a/libc/stdio/puts.c
+++ b/libc/stdio/puts.c
@@ -33,6 +33,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include "local.h"
 #include "fvwrite.h"
 
 /*
@@ -44,6 +45,7 @@
 	size_t c = strlen(s);
 	struct __suio uio;
 	struct __siov iov[2];
+	int ret;
 
 	iov[0].iov_base = (void *)s;
 	iov[0].iov_len = c;
@@ -52,5 +54,8 @@
 	uio.uio_resid = c + 1;
 	uio.uio_iov = &iov[0];
 	uio.uio_iovcnt = 2;
-	return (__sfvwrite(stdout, &uio) ? EOF : '\n');
+	FLOCKFILE(stdout);
+	ret = __sfvwrite(stdout, &uio);
+	FUNLOCKFILE(stdout);
+	return (ret ? EOF : '\n');
 }
diff --git a/libc/stdio/refill.c b/libc/stdio/refill.c
index 74b378e..7cb6b78 100644
--- a/libc/stdio/refill.c
+++ b/libc/stdio/refill.c
@@ -39,9 +39,8 @@
 static int
 lflush(FILE *fp)
 {
-
 	if ((fp->_flags & (__SLBF|__SWR)) == (__SLBF|__SWR))
-		return (__sflush(fp));
+		return (__sflush_locked(fp)); /* ignored... */
 	return (0);
 }
 
@@ -103,8 +102,16 @@
 	 * flush all line buffered output files, per the ANSI C
 	 * standard.
 	 */
-	if (fp->_flags & (__SLBF|__SNBF))
+	if (fp->_flags & (__SLBF|__SNBF)) {
+		/* Ignore this file in _fwalk to avoid potential deadlock. */
+		fp->_flags |= __SIGN;
 		(void) _fwalk(lflush);
+		fp->_flags &= ~__SIGN;
+
+		/* Now flush this file without locking it. */
+		if ((fp->_flags & (__SLBF|__SWR)) == (__SLBF|__SWR))
+		    __sflush(fp);
+	}
 	fp->_p = fp->_bf._base;
 	fp->_r = (*fp->_read)(fp->_cookie, (char *)fp->_p, fp->_bf._size);
 	fp->_flags &= ~__SMOD;	/* buffer contents are again pristine */
diff --git a/libc/stdio/setvbuf.c b/libc/stdio/setvbuf.c
index 9b92bf0..2fb76af 100644
--- a/libc/stdio/setvbuf.c
+++ b/libc/stdio/setvbuf.c
@@ -61,6 +61,7 @@
 	 * malloc()ed.  We also clear any eof condition, as if this were
 	 * a seek.
 	 */
+	FLOCKFILE(fp);
 	ret = 0;
 	(void)__sflush(fp);
 	if (HASUB(fp))
@@ -107,6 +108,7 @@
 			fp->_w = 0;
 			fp->_bf._base = fp->_p = fp->_nbuf;
 			fp->_bf._size = 1;
+			FUNLOCKFILE(fp);
 			return (ret);
 		}
 		flags |= __SMBF;
@@ -145,6 +147,7 @@
 		/* begin/continue reading, or stay in intermediate state */
 		fp->_w = 0;
 	}
+	FUNLOCKFILE(fp);
 	__atexit_register_cleanup(_cleanup);
 
 	return (ret);
diff --git a/libc/stdio/snprintf.c b/libc/stdio/snprintf.c
index 45ef7eb..5aa54be 100644
--- a/libc/stdio/snprintf.c
+++ b/libc/stdio/snprintf.c
@@ -60,7 +60,7 @@
 	f._bf._base = f._p = (unsigned char *)str;
 	f._bf._size = f._w = n - 1;
 	va_start(ap, fmt);
-	ret = vfprintf(&f, fmt, ap);
+	ret = __vfprintf(&f, fmt, ap);
 	va_end(ap);
 	*f._p = '\0';
 	return (ret);
diff --git a/libc/stdio/sprintf.c b/libc/stdio/sprintf.c
index 67f924b..3cf7952 100644
--- a/libc/stdio/sprintf.c
+++ b/libc/stdio/sprintf.c
@@ -56,7 +56,7 @@
 	f._bf._base = f._p = (unsigned char *)str;
 	f._bf._size = f._w = INT_MAX;
 	va_start(ap, fmt);
-	ret = vfprintf(&f, fmt, ap);
+	ret = __vfprintf(&f, fmt, ap);
 	va_end(ap);
 	*f._p = '\0';
 	return (ret);
diff --git a/libc/stdio/ungetc.c b/libc/stdio/ungetc.c
index fe05258..b493d21 100644
--- a/libc/stdio/ungetc.c
+++ b/libc/stdio/ungetc.c
@@ -82,17 +82,20 @@
 		return (EOF);
 	if (!__sdidinit)
 		__sinit();
+	FLOCKFILE(fp);
 	_SET_ORIENTATION(fp, -1);
 	if ((fp->_flags & __SRD) == 0) {
 		/*
 		 * Not already reading: no good unless reading-and-writing.
 		 * Otherwise, flush any current write stuff.
 		 */
-		if ((fp->_flags & __SRW) == 0)
+		if ((fp->_flags & __SRW) == 0) {
+error:			FUNLOCKFILE(fp);
 			return (EOF);
+		}
 		if (fp->_flags & __SWR) {
 			if (__sflush(fp))
-				return (EOF);
+				goto error;
 			fp->_flags &= ~__SWR;
 			fp->_w = 0;
 			fp->_lbfsize = 0;
@@ -107,9 +110,10 @@
 	 */
 	if (HASUB(fp)) {
 		if (fp->_r >= _UB(fp)._size && __submore(fp))
-			return (EOF);
+			goto error;
 		*--fp->_p = c;
-		fp->_r++;
+inc_ret:	fp->_r++;
+		FUNLOCKFILE(fp);
 		return (c);
 	}
 	fp->_flags &= ~__SEOF;
@@ -122,8 +126,7 @@
 	if (fp->_bf._base != NULL && fp->_p > fp->_bf._base &&
 	    fp->_p[-1] == c) {
 		fp->_p--;
-		fp->_r++;
-		return (c);
+		goto inc_ret;
 	}
 
 	/*
@@ -137,5 +140,6 @@
 	fp->_ubuf[sizeof(fp->_ubuf) - 1] = c;
 	fp->_p = &fp->_ubuf[sizeof(fp->_ubuf) - 1];
 	fp->_r = 1;
+	FUNLOCKFILE(fp);
 	return (c);
 }
diff --git a/libc/stdio/vasprintf.c b/libc/stdio/vasprintf.c
index 54c46b3..1630ccb 100644
--- a/libc/stdio/vasprintf.c
+++ b/libc/stdio/vasprintf.c
@@ -37,7 +37,7 @@
 	if (f._bf._base == NULL)
 		goto err;
 	f._bf._size = f._w = 127;		/* Leave room for the NUL */
-	ret = vfprintf(&f, fmt, ap);
+	ret = __vfprintf(&f, fmt, ap);
 	if (ret == -1)
 		goto err;
 	*f._p = '\0';
diff --git a/libc/stdio/vfprintf.c b/libc/stdio/vfprintf.c
index 2ce0361..dac8496 100644
--- a/libc/stdio/vfprintf.c
+++ b/libc/stdio/vfprintf.c
@@ -100,8 +100,8 @@
 	fake._lbfsize = 0;	/* not actually used, but Just In Case */
 
 	/* do the work, then copy any error status */
-	ret = vfprintf(&fake, fmt, ap);
-	if (ret >= 0 && fflush(&fake))
+	ret = __vfprintf(&fake, fmt, ap);
+	if (ret >= 0 && __sflush(&fake))
 		ret = EOF;
 	if (fake._flags & __SERR)
 		fp->_flags |= __SERR;
@@ -158,6 +158,17 @@
 int
 vfprintf(FILE *fp, const char *fmt0, __va_list ap)
 {
+	int ret;
+
+	FLOCKFILE(fp);
+	ret = __vfprintf(fp, fmt0, ap);
+	FUNLOCKFILE(fp);
+	return (ret);
+}
+
+int
+__vfprintf(FILE *fp, const char *fmt0, __va_list ap)
+{
 	char *fmt;	/* format string */
 	int ch;	/* character from fmt */
 	int n, m, n2;	/* handy integers (short term usage) */
@@ -203,9 +214,9 @@
 	 * below longer.
 	 */
 #define	PADSIZE	16		/* pad chunk size */
-	static char blanks[PADSIZE] =
+	static const char blanks[PADSIZE] =
 	 {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
-	static char zeroes[PADSIZE] =
+	static const char zeroes[PADSIZE] =
 	 {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
 
 	/*
@@ -1219,7 +1230,6 @@
 {
 	int mode, dsgn;
 	char *digits, *bp, *rve;
-	static  char  temp[64];
 
 	if (ch == 'f') {
 		mode = 3;		/* ndigits after the decimal point */
diff --git a/libc/stdio/vfscanf.c b/libc/stdio/vfscanf.c
index dbd0a8b..b16e3c7 100644
--- a/libc/stdio/vfscanf.c
+++ b/libc/stdio/vfscanf.c
@@ -117,6 +117,7 @@
 	static short basefix[17] =
 		{ 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
 
+	FLOCKFILE(fp);
 	_SET_ORIENTATION(fp, -1);
 
 	nassigned = 0;
@@ -124,8 +125,10 @@
 	base = 0;		/* XXX just to keep gcc happy */
 	for (;;) {
 		c = *fmt++;
-		if (c == 0)
+		if (c == 0) {
+			FUNLOCKFILE(fp);
 			return (nassigned);
+		}
 		if (isspace(c)) {
 			while ((fp->_r > 0 || __srefill(fp) == 0) &&
 			    isspace(*fp->_p))
@@ -292,6 +295,7 @@
 		 * Disgusting backwards compatibility hacks.	XXX
 		 */
 		case '\0':	/* compat */
+			FUNLOCKFILE(fp);
 			return (EOF);
 
 		default:	/* compat */
@@ -689,8 +693,10 @@
 		}
 	}
 input_failure:
-	return (nassigned ? nassigned : -1);
+	if (nassigned == 0)
+		nassigned = -1;
 match_failure:
+	FUNLOCKFILE(fp);
 	return (nassigned);
 }
 
diff --git a/libc/stdio/vsnprintf.c b/libc/stdio/vsnprintf.c
index e6dd009..ca30f94 100644
--- a/libc/stdio/vsnprintf.c
+++ b/libc/stdio/vsnprintf.c
@@ -58,7 +58,7 @@
 	f._flags = __SWR | __SSTR;
 	f._bf._base = f._p = (unsigned char *)str;
 	f._bf._size = f._w = n - 1;
-	ret = vfprintf(&f, fmt, ap);
+	ret = __vfprintf(&f, fmt, ap);
 	*f._p = '\0';
 	return (ret);
 }
diff --git a/libc/stdio/vsprintf.c b/libc/stdio/vsprintf.c
index 67a53a1..846ee8a 100644
--- a/libc/stdio/vsprintf.c
+++ b/libc/stdio/vsprintf.c
@@ -53,7 +53,7 @@
 	f._flags = __SWR | __SSTR;
 	f._bf._base = f._p = (unsigned char *)str;
 	f._bf._size = f._w = INT_MAX;
-	ret = vfprintf(&f, fmt, ap);
+	ret = __vfprintf(&f, fmt, ap);
 	*f._p = '\0';
 	return (ret);
 }
diff --git a/libc/stdio/wbuf.c b/libc/stdio/wbuf.c
index c757799..e09ac59 100644
--- a/libc/stdio/wbuf.c
+++ b/libc/stdio/wbuf.c
@@ -65,20 +65,20 @@
 	 * stuff c into the buffer.  If this causes the buffer to fill
 	 * completely, or if c is '\n' and the file is line buffered,
 	 * flush it (perhaps a second time).  The second flush will always
-	 * happen on unbuffered streams, where _bf._size==1; fflush()
+	 * happen on unbuffered streams, where _bf._size==1; __sflush()
 	 * guarantees that putc() will always call wbuf() by setting _w
 	 * to 0, so we need not do anything else.
 	 */
 	n = fp->_p - fp->_bf._base;
 	if (n >= fp->_bf._size) {
-		if (fflush(fp))
+		if (__sflush(fp))
 			return (EOF);
 		n = 0;
 	}
 	fp->_w--;
 	*fp->_p++ = c;
 	if (++n == fp->_bf._size || (fp->_flags & __SLBF && c == '\n'))
-		if (fflush(fp))
+		if (__sflush(fp))
 			return (EOF);
 	return (c);
 }
diff --git a/libc/stdlib/strtod.c b/libc/stdlib/strtod.c
index 2851506..ab637a1 100644
--- a/libc/stdlib/strtod.c
+++ b/libc/stdlib/strtod.c
@@ -754,6 +754,7 @@
 }
 
  static Bigint *p5s;
+ static pthread_mutex_t p5s_mutex = PTHREAD_MUTEX_INITIALIZER;
 
  static Bigint *
 pow5mult
@@ -775,11 +776,13 @@
 
 	if (!(k = (unsigned int) k >> 2))
 		return b;
+	mutex_lock(&p5s_mutex);
 	if (!(p5 = p5s)) {
 		/* first time */
 		p5 = i2b(625);
 		if (p5 == BIGINT_INVALID) {
 			Bfree(b);
+			mutex_unlock(&p5s_mutex);
 			return p5;
 		}
 		p5s = p5;
@@ -797,6 +800,7 @@
 			p51 = mult(p5,p5);
 			if (p51 == BIGINT_INVALID) {
 				Bfree(b);
+				mutex_unlock(&p5s_mutex);
 				return p51;
 			}
 			p5->next = p51;
@@ -804,6 +808,7 @@
 		}
 		p5 = p51;
 	}
+	mutex_unlock(&p5s_mutex);
 	return b;
 }
 
diff --git a/libc/tools/bionic_utils.py b/libc/tools/bionic_utils.py
index 17eef13..e7c8c2d 100644
--- a/libc/tools/bionic_utils.py
+++ b/libc/tools/bionic_utils.py
@@ -105,8 +105,29 @@
     else:
         return None
 
+def find_original_kernel_headers():
+    """try to find the directory containing the original kernel headers"""
+    bionic_root = find_bionic_root()
+    if not bionic_root:
+        D("Could not find Bionic root !!")
+        return None
+
+    path = os.path.normpath(bionic_root + "/../../external/kernel-headers/original")
+    if not os.path.isdir(path):
+        D("Could not find %s" % (path))
+        return None
+
+    return path
+
 def find_kernel_headers():
     """try to find the directory containing the kernel headers for this machine"""
+
+    # First try to find the original kernel headers.
+    ret = find_original_kernel_headers()
+    if ret:
+        D("found original kernel headers in: %s" % (ret))
+        return ret
+
     status, version = commands.getstatusoutput( "uname -r" )  # get Linux kernel version
     if status != 0:
         D("could not execute 'uname -r' command properly")
@@ -116,14 +137,39 @@
     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"))
+    path = "/usr/src/linux-headers-" + version + "/include"
+    D("probing %s for kernel headers" % (path))
     ret = os.path.isdir( path )
     if ret:
-        D("found kernel headers in: %s" % (path + "/include"))
+        D("found kernel headers in: %s" % (path))
         return path
     return None
 
+def find_arch_header(kernel_headers,arch,header):
+    # First, try in <root>/arch/<arm>/include/<header>
+    # corresponding to the location in the kernel source tree for
+    # certain architectures (e.g. arm).
+    path = "%s/arch/%s/include/asm/%s" % (kernel_headers, arch, header)
+    D("Probing for %s" % path)
+    if os.path.exists(path):
+        return path
+
+    # Try <root>/asm-<arch>/include/<header> corresponding to the location
+    # in the kernel source tree for other architectures (e.g. x86).
+    path = "%s/include/asm-%s/%s" % (kernel_headers, arch, header)
+    D("Probing for %s" % path)
+    if os.path.exists(path):
+        return path
+
+    # Otherwise, look under <root>/asm-<arch>/<header> corresponding
+    # the original kernel headers directory
+    path = "%s/asm-%s/%s" % (kernel_headers, arch, header)
+    D("Probing for %s" % path)
+    if os.path.exists(path):
+        return path
+
+
+    return None
 
 # parser for the SYSCALLS.TXT file
 #
@@ -212,7 +258,12 @@
                 E("invalid syscall number in '%s'" % line)
                 return
 
-        print str(syscall_id) + ':' + str(syscall_id2) + ':' + str(syscall_id3)
+		global verbose
+        if verbose >= 2:
+            if call_id < 0:
+                print "%s: %d,%d,%d" % (syscall_name, syscall_id, syscall_id2, syscall_id3)
+            else:
+                print "%s(%d): %d,%d,%d" % (syscall_name, call_id, syscall_id, syscall_id2, syscall_id3)
 
         t = { "id"     : syscall_id,
               "id2"    : syscall_id2,
diff --git a/libc/tools/checksyscalls.py b/libc/tools/checksyscalls.py
index 9edb390..f642e84 100755
--- a/libc/tools/checksyscalls.py
+++ b/libc/tools/checksyscalls.py
@@ -40,8 +40,8 @@
     if len(args) == 0:
         linux_root = find_kernel_headers()
         if linux_root == None:
-            print "could not locate this system kernel headers root directory, please"
-            print "specify one when calling this program, i.e. 'checksyscalls <headers-directory>'"
+            print "Could not locate original or system kernel headers root directory."
+            print "Please specify one when calling this program, i.e. 'checksyscalls <headers-directory>'"
             sys.exit(1)
         print "using the following kernel headers root: '%s'" % linux_root
     else:
@@ -112,62 +112,63 @@
 
 arm_dict = {}
 x86_dict = {}
+superh_dict = {}
 
-
-# remove trailing slash and '/include' from the linux_root, if any
+# remove trailing slash from the linux_root, if any
 if linux_root[-1] == '/':
     linux_root = linux_root[:-1]
 
-if len(linux_root) > 8 and linux_root[-8:] == '/include':
-    linux_root = linux_root[:-8]
-
-arm_unistd = linux_root + "/include/asm-arm/unistd.h"
-if not os.path.exists(arm_unistd):
-    print "WEIRD: could not locate the ARM unistd.h header file"
-    print "tried searching in '%s'" % arm_unistd
-    print "maybe using a different set of kernel headers might help"
+arm_unistd = find_arch_header(linux_root, "arm", "unistd.h")
+if not arm_unistd:
+    print "WEIRD: Could not locate the ARM unistd.h kernel header file,"
+    print "maybe using a different set of kernel headers might help."
     sys.exit(1)
 
 # on recent kernels, asm-i386 and asm-x64_64 have been merged into asm-x86
 # with two distinct unistd_32.h and unistd_64.h definition files.
 # take care of this here
 #
-x86_unistd = linux_root + "/include/asm-i386/unistd.h"
-if not os.path.exists(x86_unistd):
-    x86_unistd1 = x86_unistd
-    x86_unistd = linux_root + "/include/asm-x86/unistd_32.h"
-    if not os.path.exists(x86_unistd):
-        print "WEIRD: could not locate the i386/x86 unistd.h header file"
-        print "tried searching in '%s' and '%s'" % (x86_unistd1, x86_unistd)
-        print "maybe using a different set of kernel headers might help"
+x86_unistd = find_arch_header(linux_root, "i386", "unistd.h")
+if not x86_unistd:
+    x86_unistd = find_arch_header(linux_root, "x86", "unistd_32.h")
+    if not x86_unistd:
+        print "WEIRD: Could not locate the i386/x86 unistd.h header file,"
+        print "maybe using a different set of kernel headers might help."
         sys.exit(1)
 
-process_header( linux_root+"/include/asm-arm/unistd.h", arm_dict )
+superh_unistd = find_arch_header(linux_root, "sh", "unistd_32.h")
+if not superh_unistd:
+    print "WEIRD: Could not locate the SuperH unistd.h kernel header file,"
+    print "maybe using a different set of kernel headers might help."
+    sys.exit(1)
+
+process_header( arm_unistd, arm_dict )
 process_header( x86_unistd, x86_dict )
+process_header( superh_unistd, superh_dict )
 
 # now perform the comparison
 errors = 0
-for sc in syscalls:
-    sc_name = sc["name"]
-    sc_id   = sc["id"]
-    if sc_id >= 0:
-        if not arm_dict.has_key(sc_name):
-            print "arm syscall %s not defined !!" % sc_name
-            errors += 1
-        elif arm_dict[sc_name] != sc_id:
-            print "arm syscall %s should be %d instead of %d !!" % (sc_name, arm_dict[sc_name], sc_id)
-            errors += 1
 
-for sc in syscalls:
-    sc_name = sc["name"]
-    sc_id2  = sc["id2"]
-    if sc_id2 >= 0:
-        if not x86_dict.has_key(sc_name):
-            print "x86 syscall %s not defined !!" % sc_name
-            errors += 1
-        elif x86_dict[sc_name] != sc_id2:
-            print "x86 syscall %s should be %d instead of %d !!" % (sc_name, x86_dict[sc_name], sc_id2)
-            errors += 1
+def check_syscalls(archname, idname, arch_dict):
+    errors = 0
+    for sc in syscalls:
+        sc_name = sc["name"]
+        sc_id   = sc[idname]
+        if sc_id >= 0:
+            if not arch_dict.has_key(sc_name):
+                print "%s syscall %s not defined, should be %d !!" % (archname, sc_name, sc_id)
+                errors += 1
+            elif not arch_dict.has_key(sc_name):
+                print "%s syscall %s is not implemented!" % (archname, sc_name)
+                errors += 1
+            elif arch_dict[sc_name] != sc_id:
+                print "%s syscall %s should be %d instead of %d !!" % (archname, sc_name, arch_dict[sc_name], sc_id)
+                errors += 1
+    return errors
+
+errors += check_syscalls("arm", "id", arm_dict)
+errors += check_syscalls("x86", "id2", x86_dict)
+errors += check_syscalls("superh", "id3", superh_dict)
 
 if errors == 0:
     print "congratulations, everything's fine !!"
diff --git a/libc/tools/gensyscalls.py b/libc/tools/gensyscalls.py
index 0535e56..c188e04 100755
--- a/libc/tools/gensyscalls.py
+++ b/libc/tools/gensyscalls.py
@@ -79,15 +79,14 @@
 # ARM assembler templates for each syscall stub
 #
 arm_header = """/* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
 #include <sys/linux-syscalls.h>
 
-    .text
-    .type %(fname)s, #function
-    .globl %(fname)s
-    .align 4
-    .fnstart
+ENTRY(%(fname)s)
+"""
 
-%(fname)s:
+arm_footer = """\
+END(%(fname)s)
 """
 
 arm_call_default = arm_header + """\
@@ -95,8 +94,7 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
-"""
+""" + arm_footer
 
 arm_call_long = arm_header + """\
     .save   {r4, r5, lr}
@@ -108,8 +106,7 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
-"""
+""" + arm_footer
 
 arm_eabi_call_default = arm_header + """\
     .save   {r4, r7}
@@ -120,8 +117,7 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
-"""
+""" + arm_footer
 
 arm_eabi_call_long = arm_header + """\
     mov     ip, sp
@@ -134,8 +130,7 @@
     movs    r0, r0
     bxpl    lr
     b       __set_syscall_errno
-    .fnend
-"""
+""" + arm_footer
 
 # ARM thumb assembler templates for each syscall stub
 #
@@ -557,7 +552,7 @@
         for sc in self.syscalls:
             if sc.has_key("asm-arm") and 'arm' in all_archs:
                 fname = "arch-arm/syscalls/%s.S" % sc["func"]
-                D( ">>> generating "+fname )
+                D2( ">>> generating "+fname )
                 fp = create_file( fname )
                 fp.write(sc["asm-arm"])
                 fp.close()
@@ -565,7 +560,7 @@
 
             if sc.has_key("asm-thumb") and 'arm' in all_archs:
                 fname = "arch-arm/syscalls/%s.S" % sc["func"]
-                D( ">>> generating "+fname )
+                D2( ">>> generating "+fname )
                 fp = create_file( fname )
                 fp.write(sc["asm-thumb"])
                 fp.close()
@@ -573,7 +568,7 @@
 
             if sc.has_key("asm-x86") and 'x86' in all_archs:
                 fname = "arch-x86/syscalls/%s.S" % sc["func"]
-                D( ">>> generating "+fname )
+                D2( ">>> generating "+fname )
                 fp = create_file( fname )
                 fp.write(sc["asm-x86"])
                 fp.close()
@@ -581,7 +576,7 @@
 
             if sc.has_key("asm-sh"):
                 fname = "arch-sh/syscalls/%s.S" % sc["func"]
-                D( ">>> generating "+fname )
+                D2( ">>> generating "+fname )
                 fp = create_file( fname )
                 fp.write(sc["asm-sh"])
                 fp.close()
@@ -626,7 +621,7 @@
 
         for stub in self.new_stubs + self.other_files:
             if not os.path.exists( bionic_root + stub ):
-                # new file, P4 add it
+                # new file, git add it
                 D( "new file:     " + stub)
                 adds.append( bionic_root + stub )
                 shutil.copyfile( bionic_temp + stub, bionic_root + stub )
@@ -643,16 +638,21 @@
 
 
         if adds:
-            commands.getoutput("p4 add " + " ".join(adds))
+            commands.getoutput("git add " + " ".join(adds))
         if deletes:
-            commands.getoutput("p4 delete " + " ".join(deletes))
+            commands.getoutput("git rm " + " ".join(deletes))
         if edits:
-            commands.getoutput("p4 edit " +
-                               " ".join((bionic_root + file) for file in edits))
             for file in edits:
                 shutil.copyfile( bionic_temp + file, bionic_root + file )
+            commands.getoutput("git add " +
+                               " ".join((bionic_root + file) for file in edits))
 
-        D("ready to go !!")
+        commands.getoutput("git add %s%s" % (bionic_root,"SYSCALLS.TXT"))
+
+        if (not adds) and (not deletes) and (not edits):
+            D("no changes detected!")
+        else:
+            D("ready to go!!")
 
 D_setlevel(1)
 
diff --git a/libc/tools/zoneinfo/ZoneCompactor.java b/libc/tools/zoneinfo/ZoneCompactor.java
new file mode 100644
index 0000000..b657748
--- /dev/null
+++ b/libc/tools/zoneinfo/ZoneCompactor.java
@@ -0,0 +1,166 @@
+
+import java.io.*;
+import java.util.*;
+
+// usage: java ZoneCompiler <setup file> <top-level directory>
+//
+// Compile a set of tzfile-formatted files into a single file plus
+// an index file.
+//
+// The compilation is controlled by a setup file, which is provided as a
+// command-line argument.  The setup file has the form:
+//
+// Link <toName> <fromName>
+// ...
+// <zone filename>
+// ...
+//
+// Note that the links must be declared prior to the zone names.  A
+// zone name is a filename relative to the source directory such as
+// 'GMT', 'Africa/Dakar', or 'America/Argentina/Jujuy'.
+//
+// Use the 'zic' command-line tool to convert from flat files
+// (e.g., 'africa', 'northamerica') into a suitable source directory
+// hierarchy for this tool (e.g., 'data/Africa/Abidjan').
+//
+// Example:
+//     zic -d data tz2007h
+//     javac ZoneCompactor.java
+//     java ZoneCompactor setup data
+//     <produces zoneinfo.dat and zoneinfo.idx>
+
+public class ZoneCompactor {
+
+    // Zone name synonyms
+    Map<String,String> links = new HashMap<String,String>();
+
+    // File starting bytes by zone name
+    Map<String,Integer> starts = new HashMap<String,Integer>();
+
+    // File lengths by zone name
+    Map<String,Integer> lengths = new HashMap<String,Integer>();
+
+    // Raw GMT offsets by zone name
+    Map<String,Integer> offsets = new HashMap<String,Integer>();
+    int start = 0;
+
+    // Maximum number of characters in a zone name, including '\0' terminator
+    private static final int MAXNAME = 40;
+
+    // Concatenate the contents of 'inFile' onto 'out'
+    // and return the contents as a byte array.
+    private static byte[] copyFile(File inFile, OutputStream out)
+        throws Exception {
+        byte[] ret = new byte[0];
+
+        InputStream in = new FileInputStream(inFile);
+        byte[] buf = new byte[8192];
+        while (true) {
+            int nbytes = in.read(buf);
+            if (nbytes == -1) {
+                break;
+            }
+            out.write(buf, 0, nbytes);
+
+            byte[] nret = new byte[ret.length + nbytes];
+            System.arraycopy(ret, 0, nret, 0, ret.length);
+            System.arraycopy(buf, 0, nret, ret.length, nbytes);
+            ret = nret;
+        }
+        out.flush();
+        return ret;
+    }
+    
+    // Write a 32-bit integer in network byte order
+    private void writeInt(OutputStream os, int x) throws IOException {
+        os.write((x >> 24) & 0xff);
+        os.write((x >> 16) & 0xff);
+        os.write((x >>  8) & 0xff);
+        os.write( x        & 0xff);
+    }
+
+    public ZoneCompactor(String setupFilename, String dirName)
+        throws Exception {
+        File zoneInfoFile = new File("zoneinfo.dat");
+        zoneInfoFile.delete();
+        OutputStream zoneInfo = new FileOutputStream(zoneInfoFile);
+
+        BufferedReader rdr = new BufferedReader(new FileReader(setupFilename));
+    
+        String s;
+        while ((s = rdr.readLine()) != null) {
+            s = s.trim();
+            if (s.startsWith("Link")) {
+                StringTokenizer st = new StringTokenizer(s);
+                st.nextToken();
+                String to = st.nextToken();
+                String from = st.nextToken();
+                links.put(from, to);
+            } else {
+                String link = links.get(s);
+                if (link == null) {
+                    File f = new File(dirName, s);
+                    long length = f.length();
+                    starts.put(s, new Integer(start));
+                    lengths.put(s, new Integer((int)length));
+
+                    start += length;
+                    byte[] data = copyFile(f, zoneInfo);
+
+                    TimeZone tz = ZoneInfo.make(s, data);
+                    int gmtOffset = tz.getRawOffset();
+                    offsets.put(s, new Integer(gmtOffset));
+                }
+            }
+        }
+        zoneInfo.close();
+
+        // Fill in fields for links
+        Iterator<String> iter = links.keySet().iterator();
+        while (iter.hasNext()) {
+            String from = iter.next();
+            String to = links.get(from);
+
+            starts.put(from, starts.get(to));
+            lengths.put(from, lengths.get(to));
+            offsets.put(from, offsets.get(to));
+        }
+
+        File idxFile = new File("zoneinfo.idx");
+        idxFile.delete();
+        FileOutputStream idx = new FileOutputStream(idxFile);
+
+        ArrayList<String> l = new ArrayList<String>();
+        l.addAll(starts.keySet());
+        Collections.sort(l);
+        Iterator<String> ziter = l.iterator();
+        while (ziter.hasNext()) {
+            String zname = ziter.next();
+            if (zname.length() >= MAXNAME) {
+                System.err.println("Error - zone filename exceeds " +
+                                   (MAXNAME - 1) + " characters!");
+            }
+
+            byte[] znameBuf = new byte[MAXNAME];
+            for (int i = 0; i < zname.length(); i++) {
+                znameBuf[i] = (byte)zname.charAt(i);
+            }
+            idx.write(znameBuf);
+            writeInt(idx, starts.get(zname).intValue());
+            writeInt(idx, lengths.get(zname).intValue());
+            writeInt(idx, offsets.get(zname).intValue());
+        }
+        idx.close();
+
+        // System.out.println("maxLength = " + maxLength);
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (args.length != 2) {
+            System.err.println("usage: java ZoneCompactor <setup> <data dir>");
+            System.exit(0);
+        }
+        new ZoneCompactor(args[0], args[1]);
+    }
+
+}
diff --git a/libc/tools/zoneinfo/ZoneInfo.java b/libc/tools/zoneinfo/ZoneInfo.java
new file mode 100644
index 0000000..99507ae
--- /dev/null
+++ b/libc/tools/zoneinfo/ZoneInfo.java
@@ -0,0 +1,272 @@
+/*
+ * Copyright (C) 2007 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.
+ */
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.TimeZone;
+
+/**
+ * Copied from ZoneInfo and ZoneInfoDB in dalvik.
+ * {@hide}
+ */
+public class ZoneInfo extends TimeZone {
+
+    private static final long MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
+    private static final long MILLISECONDS_PER_400_YEARS =
+        MILLISECONDS_PER_DAY * (400 * 365 + 100 - 3);
+
+    private static final long UNIX_OFFSET = 62167219200000L;
+
+    private static final int[] NORMAL = new int[] {
+        0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334,
+    };
+
+    private static final int[] LEAP = new int[] {
+        0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335,
+    };
+
+    private static String nullName(byte[] data, int where, int off) {
+        if (off < 0)
+            return null;
+
+        int end = where + off;
+        while (end < data.length && data[end] != '\0')
+            end++;
+
+        return new String(data, where + off, end - (where + off));
+    }
+
+    public static ZoneInfo make(String name, byte[] data) {
+        int ntransition = read4(data, 32);
+        int ngmtoff = read4(data, 36);
+        int base = 44;
+
+        int[] transitions = new int[ntransition];
+        for (int i = 0; i < ntransition; i++)
+            transitions[i] = read4(data, base + 4 * i);
+        base += 4 * ntransition;
+
+        byte[] type = new byte[ntransition];
+        for (int i = 0; i < ntransition; i++)
+            type[i] = data[base + i];
+        base += ntransition;
+
+        int[] gmtoff = new int[ngmtoff];
+        byte[] isdst = new byte[ngmtoff];
+        byte[] abbrev = new byte[ngmtoff];
+        for (int i = 0; i < ngmtoff; i++) {
+            gmtoff[i] = read4(data, base + 6 * i);
+            isdst[i] = data[base + 6 * i + 4];
+            abbrev[i] = data[base + 6 * i + 5];
+        }
+
+        base += 6 * ngmtoff;
+
+        return new ZoneInfo(name, transitions, type, gmtoff, isdst, abbrev, data, base);
+    }
+
+    private static int read4(byte[] data, int off) {
+        return ((data[off    ] & 0xFF) << 24) |
+               ((data[off + 1] & 0xFF) << 16) |
+               ((data[off + 2] & 0xFF) <<  8) |
+               ((data[off + 3] & 0xFF) <<  0);
+    }
+
+    /*package*/ ZoneInfo(String name, int[] transitions, byte[] type,
+                     int[] gmtoff, byte[] isdst, byte[] abbrev,
+                     byte[] data, int abbrevoff) {
+        mTransitions = transitions;
+        mTypes = type;
+        mGmtOffs = gmtoff;
+        mIsDsts = isdst;
+        mUseDst = false;
+        setID(name);
+
+        // Find the latest GMT and non-GMT offsets for their abbreviations
+
+        int lastdst;
+        for (lastdst = mTransitions.length - 1; lastdst >= 0; lastdst--) {
+            if (mIsDsts[mTypes[lastdst] & 0xFF] != 0)
+                break;
+        }
+
+        int laststd;
+        for (laststd = mTransitions.length - 1; laststd >= 0; laststd--) {
+            if (mIsDsts[mTypes[laststd] & 0xFF] == 0)
+                break;
+        }
+
+        if (lastdst >= 0) {
+            mDaylightName = nullName(data, abbrevoff,
+                                     abbrev[mTypes[lastdst] & 0xFF]);
+        }
+        if (laststd >= 0) {
+            mStandardName = nullName(data, abbrevoff,
+                                     abbrev[mTypes[laststd] & 0xFF]);
+        }
+
+        // Use the latest non-DST offset if any as the raw offset
+
+        if (laststd < 0) {
+            laststd = 0;
+        }
+
+        if (laststd >= mTypes.length) {
+            mRawOffset = mGmtOffs[0];
+        } else {
+            mRawOffset = mGmtOffs[mTypes[laststd] & 0xFF];
+        }
+
+        // Subtract the raw offset from all offsets so it can be changed
+        // and affect them too.
+        // Find whether there exist any observances of DST.
+
+        for (int i = 0; i < mGmtOffs.length; i++) {
+            mGmtOffs[i] -= mRawOffset;
+
+            if (mIsDsts[i] != 0) {
+                mUseDst = true;
+            }
+        }
+
+        mRawOffset *= 1000;
+    }
+
+    @Override
+    public int getOffset(@SuppressWarnings("unused") int era,
+        int year, int month, int day,
+        @SuppressWarnings("unused") int dayOfWeek,
+        int millis) {
+        // XXX This assumes Gregorian always; Calendar switches from
+        // Julian to Gregorian in 1582.  What calendar system are the
+        // arguments supposed to come from?
+
+        long calc = (year / 400) * MILLISECONDS_PER_400_YEARS;
+        year %= 400;
+
+        calc += year * (365 * MILLISECONDS_PER_DAY);
+        calc += ((year + 3) / 4) * MILLISECONDS_PER_DAY;
+
+        if (year > 0)
+            calc -= ((year - 1) / 100) * MILLISECONDS_PER_DAY;
+
+        boolean isLeap = (year == 0 || (year % 4 == 0 && year % 100 != 0));
+        int[] mlen = isLeap ? LEAP : NORMAL;
+
+        calc += mlen[month] * MILLISECONDS_PER_DAY;
+        calc += (day - 1) * MILLISECONDS_PER_DAY;
+        calc += millis;
+
+        calc -= mRawOffset;
+        calc -= UNIX_OFFSET;
+
+        return getOffset(calc);
+    }
+
+    @Override
+    public int getOffset(long when) {
+        int unix = (int) (when / 1000);
+        int trans = Arrays.binarySearch(mTransitions, unix);
+
+        if (trans == ~0) {
+            return mGmtOffs[0] * 1000 + mRawOffset;
+        }
+        if (trans < 0) {
+            trans = ~trans - 1;
+        }
+
+        return mGmtOffs[mTypes[trans] & 0xFF] * 1000 + mRawOffset;
+    }
+
+    @Override
+    public int getRawOffset() {
+        return mRawOffset;
+    }
+
+    @Override
+    public void setRawOffset(int off) {
+        mRawOffset = off;
+    }
+
+    @Override
+    public boolean inDaylightTime(Date when) {
+        int unix = (int) (when.getTime() / 1000);
+        int trans = Arrays.binarySearch(mTransitions, unix);
+
+        if (trans == ~0) {
+            return mIsDsts[0] != 0;
+        }
+        if (trans < 0) {
+            trans = ~trans - 1;
+        }
+
+        return mIsDsts[mTypes[trans] & 0xFF] != 0;
+    }
+
+    @Override
+    public boolean useDaylightTime() {
+        return mUseDst;
+    }
+
+    private int mRawOffset;
+    private int[] mTransitions;
+    private int[] mGmtOffs;
+    private byte[] mTypes;
+    private byte[] mIsDsts;
+    private boolean mUseDst;
+    private String mDaylightName;
+    private String mStandardName;
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!(obj instanceof ZoneInfo)) {
+           return false;
+        }
+        ZoneInfo other = (ZoneInfo) obj;
+        return mUseDst == other.mUseDst
+                && (mDaylightName == null ? other.mDaylightName == null :
+                        mDaylightName.equals(other.mDaylightName))
+                && (mStandardName == null ? other.mStandardName == null :
+                        mStandardName.equals(other.mStandardName))
+                && mRawOffset == other.mRawOffset
+                // Arrays.equals returns true if both arrays are null
+                && Arrays.equals(mGmtOffs, other.mGmtOffs)
+                && Arrays.equals(mIsDsts, other.mIsDsts)
+                && Arrays.equals(mTypes, other.mTypes)
+                && Arrays.equals(mTransitions, other.mTransitions);
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((mDaylightName == null) ? 0 :
+                mDaylightName.hashCode());
+        result = prime * result + Arrays.hashCode(mGmtOffs);
+        result = prime * result + Arrays.hashCode(mIsDsts);
+        result = prime * result + mRawOffset;
+        result = prime * result + ((mStandardName == null) ? 0 :
+                mStandardName.hashCode());
+        result = prime * result + Arrays.hashCode(mTransitions);
+        result = prime * result + Arrays.hashCode(mTypes);
+        result = prime * result + (mUseDst ? 1231 : 1237);
+        return result;
+    }
+}
diff --git a/libc/tools/zoneinfo/generate b/libc/tools/zoneinfo/generate
new file mode 100755
index 0000000..5755e26
--- /dev/null
+++ b/libc/tools/zoneinfo/generate
@@ -0,0 +1,79 @@
+#!/bin/bash
+# Run with no arguments from any directory, with no special setup required.
+
+# Abort if any command returns an error exit status, or if an undefined
+# variable is used.
+set -e
+set -u
+
+echo "Looking for bionic..."
+bionic_dir=$(cd $(dirname $0)/../../.. && pwd)
+bionic_zoneinfo_dir=$bionic_dir/libc/zoneinfo
+bionic_zoneinfo_tools_dir=$bionic_dir/libc/tools/zoneinfo
+if [[ ! -d "$bionic_zoneinfo_dir" || ! -d "$bionic_zoneinfo_tools_dir" ]]; then
+  echo "Can't find bionic's zoneinfo directories!"
+  exit 1
+fi
+
+echo "Switching to temporary directory..."
+temp_dir=`mktemp -d`
+cd $temp_dir
+trap "rm -rf $temp_dir; exit" INT TERM EXIT
+
+# URL from "Sources for Time Zone and Daylight Saving Time Data"
+# http://www.twinsun.com/tz/tz-link.htm
+echo "Looking for new tzdata..."
+wget -N --no-verbose 'ftp://elsie.nci.nih.gov/pub/tzdata*.tar.gz'
+zoneinfo_version_file=$bionic_zoneinfo_dir/zoneinfo.version
+if [ -f "$zoneinfo_version_file" ]; then
+  current_version=tzdata`sed s/\n// < $zoneinfo_version_file`
+else
+  current_version=missing
+fi
+latest_archive=`ls -r -v tzdata*.tar.gz | head -n1`
+latest_version=`basename $latest_archive .tar.gz`
+if [ "$current_version" == "$latest_version" ]; then
+  echo "You already have the latest tzdata ($latest_version)!"
+  exit 1
+fi
+
+echo "Extracting $latest_version..."
+mkdir $latest_version
+tar -C $latest_version -zxf $latest_archive
+
+echo "Compiling $latest_version..."
+mkdir data
+for i in \
+    africa \
+    antarctica \
+    asia \
+    australasia \
+    etcetera \
+    europe \
+    factory \
+    northamerica \
+    solar87 \
+    solar88 \
+    solar89 \
+    southamerica
+do
+    zic -d data $latest_version/$i
+done
+
+echo "Compacting $latest_version..."
+(
+    cat $latest_version/* | grep '^Link' | awk '{print $1, $2, $3}'
+    (
+        cat $latest_version/* | grep '^Zone' | awk '{print $2}'
+        cat $latest_version/* | grep '^Link' | awk '{print $3}'
+    ) | LC_ALL="C" sort
+) | grep -v Riyadh8 > setup
+
+javac -d . \
+    $bionic_zoneinfo_tools_dir/ZoneCompactor.java \
+    $bionic_zoneinfo_tools_dir/ZoneInfo.java
+java ZoneCompactor setup data
+
+echo "Updating bionic to $latest_version..."
+mv zoneinfo.dat zoneinfo.idx $bionic_zoneinfo_dir
+echo $latest_version | sed 's/tzdata//' > $bionic_zoneinfo_dir/zoneinfo.version
diff --git a/libc/tzcode/strptime.c b/libc/tzcode/strptime.c
index 1f481c9..0567aa4 100644
--- a/libc/tzcode/strptime.c
+++ b/libc/tzcode/strptime.c
@@ -89,29 +89,31 @@
 #define _LEGAL_ALT(x)       { if (alt_format & ~(x)) return (0); }
 
 
+struct century_relyear {
+    int century;
+    int relyear;
+};
 static  int _conv_num(const unsigned char **, int *, int, int);
-static  unsigned char *_strptime(const unsigned char *, const char *, struct tm *, int);
+static  unsigned char *_strptime(const unsigned char *, const char *, struct tm *,
+        struct century_relyear *);
 
 
 char *
 strptime(const char *buf, const char *fmt, struct tm *tm)
 {
-    return (char*)(_strptime((const unsigned char*)buf, fmt, tm, 1));
+    struct century_relyear cr;
+    cr.century = TM_YEAR_BASE;
+    cr.relyear = -1;
+    return (char*)(_strptime((const unsigned char*)buf, fmt, tm, &cr));
 }
 
 static unsigned char *
-_strptime(const unsigned char *buf, const char *fmt, struct tm *tm, int initialize)
+_strptime(const unsigned char *buf, const char *fmt, struct tm *tm, struct century_relyear *cr)
 {
     unsigned char c;
     const unsigned char *bp;
     size_t len = 0;
     int alt_format, i;
-    static int century, relyear;
-
-    if (initialize) {
-        century = TM_YEAR_BASE;
-        relyear = -1;
-    }
 
     bp = (unsigned char *)buf;
     while ((c = *fmt) != '\0') {
@@ -158,43 +160,43 @@
          */
         case 'c':   /* Date and time, using the locale's format. */
             _LEGAL_ALT(_ALT_E);
-            if (!(bp = _strptime(bp, _ctloc(d_t_fmt), tm, 0)))
+            if (!(bp = _strptime(bp, _ctloc(d_t_fmt), tm, cr)))
                 return (NULL);
             break;
 
         case 'D':   /* The date as "%m/%d/%y". */
             _LEGAL_ALT(0);
-            if (!(bp = _strptime(bp, "%m/%d/%y", tm, 0)))
+            if (!(bp = _strptime(bp, "%m/%d/%y", tm, cr)))
                 return (NULL);
             break;
     
         case 'R':   /* The time as "%H:%M". */
             _LEGAL_ALT(0);
-            if (!(bp = _strptime(bp, "%H:%M", tm, 0)))
+            if (!(bp = _strptime(bp, "%H:%M", tm, cr)))
                 return (NULL);
             break;
 
         case 'r':   /* The time as "%I:%M:%S %p". */
             _LEGAL_ALT(0);
-            if (!(bp = _strptime(bp, "%I:%M:%S %p", tm, 0)))
+            if (!(bp = _strptime(bp, "%I:%M:%S %p", tm, cr)))
                 return (NULL);
             break;
 
         case 'T':   /* The time as "%H:%M:%S". */
             _LEGAL_ALT(0);
-            if (!(bp = _strptime(bp, "%H:%M:%S", tm, 0)))
+            if (!(bp = _strptime(bp, "%H:%M:%S", tm, cr)))
                 return (NULL);
             break;
 
         case 'X':   /* The time, using the locale's format. */
             _LEGAL_ALT(_ALT_E);
-            if (!(bp = _strptime(bp, _ctloc(t_fmt), tm, 0)))
+            if (!(bp = _strptime(bp, _ctloc(t_fmt), tm, cr)))
                 return (NULL);
             break;
 
         case 'x':   /* The date, using the locale's format. */
             _LEGAL_ALT(_ALT_E);
-            if (!(bp = _strptime(bp, _ctloc(d_fmt), tm, 0)))
+            if (!(bp = _strptime(bp, _ctloc(d_fmt), tm, cr)))
                 return (NULL);
             break;
 
@@ -253,7 +255,7 @@
             if (!(_conv_num(&bp, &i, 0, 99)))
                 return (NULL);
 
-            century = i * 100;
+            cr->century = i * 100;
             break;
 
         case 'd':   /* The day of month. */
@@ -359,13 +361,13 @@
             if (!(_conv_num(&bp, &i, 0, 9999)))
                 return (NULL);
 
-            relyear = -1;
+            cr->relyear = -1;
             tm->tm_year = i - TM_YEAR_BASE;
             break;
 
         case 'y':   /* The year within the century (2 digits). */
             _LEGAL_ALT(_ALT_E | _ALT_O);
-            if (!(_conv_num(&bp, &relyear, 0, 99)))
+            if (!(_conv_num(&bp, &cr->relyear, 0, 99)))
                 return (NULL);
             break;
 
@@ -391,14 +393,14 @@
      * We need to evaluate the two digit year spec (%y)
      * last as we can get a century spec (%C) at any time.
      */
-    if (relyear != -1) {
-        if (century == TM_YEAR_BASE) {
-            if (relyear <= 68)
-                tm->tm_year = relyear + 2000 - TM_YEAR_BASE;
+    if (cr->relyear != -1) {
+        if (cr->century == TM_YEAR_BASE) {
+            if (cr->relyear <= 68)
+                tm->tm_year = cr->relyear + 2000 - TM_YEAR_BASE;
             else
-                tm->tm_year = relyear + 1900 - TM_YEAR_BASE;
+                tm->tm_year = cr->relyear + 1900 - TM_YEAR_BASE;
         } else {
-            tm->tm_year = relyear + century - TM_YEAR_BASE;
+            tm->tm_year = cr->relyear + cr->century - TM_YEAR_BASE;
         }
     }
 
diff --git a/libc/unistd/time.c b/libc/unistd/time.c
index 13d7366..4b51675 100644
--- a/libc/unistd/time.c
+++ b/libc/unistd/time.c
@@ -42,21 +42,29 @@
 	return (tt.tv_sec);
 }
 
+// return monotonically increasing CPU time in ticks relative to unspecified epoch
+static inline clock_t clock_now(void)
+{
+	struct timespec tm;
+	clock_gettime( CLOCK_MONOTONIC, &tm);
+	return tm.tv_sec * CLOCKS_PER_SEC + (tm.tv_nsec * (CLOCKS_PER_SEC/1e9));
+}
 
+// initialized by the constructor below
+static clock_t clock_start;
+
+// called by dlopen when .so is loaded
+__attribute__((constructor)) static void clock_crt0(void)
+{
+	clock_start = clock_now();
+}
+
+// return elapsed CPU time in clock ticks, since start of program execution
+// (spec says epoch is undefined, but glibc uses crt0 as epoch)
 clock_t
 clock(void)
 {
-	struct timespec  tm;
-	static int       clock_inited;
-	static clock_t   clock_start;
-	clock_t          now;
-
-	clock_gettime( CLOCK_MONOTONIC, &tm);
-	now = tm.tv_sec * CLOCKS_PER_SEC + (tm.tv_nsec * (CLOCKS_PER_SEC/1e9));
-
-	if (!clock_inited) {
-		clock_start  = now;
-		clock_inited = 1;
-	}
-	return  now - clock_start;
+	// note that if we are executing in a different thread than crt0, then the
+	// pthread_create that made us had a memory barrier so clock_start is defined
+	return clock_now() - clock_start;
 }
diff --git a/libc/zoneinfo/MODULE_LICENSE_PUBLIC_DOMAIN b/libc/zoneinfo/MODULE_LICENSE_PUBLIC_DOMAIN
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libc/zoneinfo/MODULE_LICENSE_PUBLIC_DOMAIN
diff --git a/libc/zoneinfo/zoneinfo.dat b/libc/zoneinfo/zoneinfo.dat
index 27ca5d0..6b2bada 100644
--- a/libc/zoneinfo/zoneinfo.dat
+++ b/libc/zoneinfo/zoneinfo.dat
Binary files differ
diff --git a/libc/zoneinfo/zoneinfo.idx b/libc/zoneinfo/zoneinfo.idx
index 09bd15f..535251e 100644
--- a/libc/zoneinfo/zoneinfo.idx
+++ b/libc/zoneinfo/zoneinfo.idx
Binary files differ
diff --git a/libc/zoneinfo/zoneinfo.version b/libc/zoneinfo/zoneinfo.version
index 76dcafb..1bec5a4 100644
--- a/libc/zoneinfo/zoneinfo.version
+++ b/libc/zoneinfo/zoneinfo.version
@@ -1 +1 @@
-2010k
+2011b
diff --git a/linker/README.TXT b/linker/README.TXT
index 052a65b..a8efe35 100644
--- a/linker/README.TXT
+++ b/linker/README.TXT
@@ -77,7 +77,7 @@
       Same as DT_INITARRAY but for finalizers. Note that the
       functions must be called in reverse-order though
 
-      Note: this is generally stroed in a .fini_array section
+      Note: this is generally stored in a .fini_array section
 
   DT_FINI_ARRAYSZ
       Size of FT_FINIARRAY
@@ -88,7 +88,7 @@
       a list of functions that need to be called before any other
       initialization function (i.e. DT_INIT and/or DT_INIT_ARRAY)
 
-      Note: this is generally stroed in a .preinit_array section
+      Note: this is generally stored in a .preinit_array section
 
   DT_PREINIT_ARRAYSZ
       The size of DT_PREINIT_ARRAY
@@ -103,14 +103,14 @@
 much processor dependent, and may use different ELF sections.
 
 On the ARM (see "C++ ABI for ARM" document), the static constructors
-must be called explicitely from the DT_INIT_ARRAY, and each one of them
+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 explicitely.
+are in charge of calling them explicitly.
 
 
 Debugging:
@@ -140,4 +140,4 @@
 
 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"
+LINKER_DEBUG_TO_LOG to 0 in "linker_debug.h".
diff --git a/linker/linker.c b/linker/linker.c
index c4f54f7..5a9dccf 100644
--- a/linker/linker.c
+++ b/linker/linker.c
@@ -54,7 +54,7 @@
 #include "ba.h"
 
 #define ALLOW_SYMBOLS_FROM_MAIN 1
-#define SO_MAX 96
+#define SO_MAX 128
 
 /* Assume average path length of 64 and max 8 paths */
 #define LDPATH_BUFSIZE 512