Merge "Update if.h, if_vlan,h and add in_route.h"
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index f66ff40..c5b78f5 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -260,3 +260,5 @@
 # ARM-specific ARM_NR_BASE == 0x0f0000 == 983040
 int     __set_tls:ARM_set_tls(void*)                                 983045,-1
 int     cacheflush:ARM_cacheflush(long start, long end, long flags)  983042,-1
+
+int     eventfd(int count, int flags) 351,323
diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk
index c466166..3d1c2ac 100644
--- a/libc/arch-arm/syscalls.mk
+++ b/libc/arch-arm/syscalls.mk
@@ -172,3 +172,4 @@
 syscall_src += arch-arm/syscalls/poll.S
 syscall_src += arch-arm/syscalls/__set_tls.S
 syscall_src += arch-arm/syscalls/cacheflush.S
+syscall_src += arch-arm/syscalls/eventfd.S
diff --git a/libc/arch-arm/syscalls/eventfd.S b/libc/arch-arm/syscalls/eventfd.S
new file mode 100644
index 0000000..fb0912f
--- /dev/null
+++ b/libc/arch-arm/syscalls/eventfd.S
@@ -0,0 +1,19 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+    .text
+    .type eventfd, #function
+    .globl eventfd
+    .align 4
+    .fnstart
+
+eventfd:
+    .save   {r4, r7}
+    stmfd   sp!, {r4, r7}
+    ldr     r7, =__NR_eventfd
+    swi     #0
+    ldmfd   sp!, {r4, r7}
+    movs    r0, r0
+    bxpl    lr
+    b       __set_syscall_errno
+    .fnend
diff --git a/libc/bionic/pthread.c b/libc/bionic/pthread.c
index b28cd9f..dd8d758 100644
--- a/libc/bionic/pthread.c
+++ b/libc/bionic/pthread.c
@@ -196,6 +196,9 @@
 
     // Wait for our creating thread to release us. This lets it have time to
     // notify gdb about this thread before it starts doing anything.
+    //
+    // This also provides the memory barrier needed to ensure that all memory
+    // accesses previously made by the creating thread are visible to us.
     pthread_mutex_t * start_mutex = (pthread_mutex_t *)&tls[TLS_SLOT_SELF];
     pthread_mutex_lock(start_mutex);
     pthread_mutex_destroy(start_mutex);
@@ -264,7 +267,7 @@
 }
 
 /*
- * Create a new thread. The thread's stack is layed out like so:
+ * Create a new thread. The thread's stack is laid out like so:
  *
  * +---------------------------+
  * |     pthread_internal_t    |
@@ -334,6 +337,10 @@
 
     // Create a mutex for the thread in TLS_SLOT_SELF to wait on once it starts so we can keep
     // it from doing anything until after we notify the debugger about it
+    //
+    // This also provides the memory barrier we need to ensure that all
+    // memory accesses previously performed by this thread are visible to
+    // the new thread.
     start_mutex = (pthread_mutex_t *) &tls[TLS_SLOT_SELF];
     pthread_mutex_init(start_mutex, NULL);
     pthread_mutex_lock(start_mutex);
@@ -1421,6 +1428,18 @@
             break;
     }
 
+    /*
+     * Ensure that all memory accesses previously made by this thread are
+     * visible to the woken thread(s).  On the other side, the "wait"
+     * code will issue any necessary barriers when locking the mutex.
+     *
+     * This may not strictly be necessary -- if the caller follows
+     * recommended practice and holds the mutex before signaling the cond
+     * var, the mutex ops will provide correct semantics.  If they don't
+     * hold the mutex, they're subject to race conditions anyway.
+     */
+    ANDROID_MEMBAR_FULL();
+
     __futex_wake_ex(&cond->value, COND_IS_SHARED(cond), counter);
     return 0;
 }
diff --git a/libc/include/sys/eventfd.h b/libc/include/sys/eventfd.h
new file mode 100644
index 0000000..0e142fd
--- /dev/null
+++ b/libc/include/sys/eventfd.h
@@ -0,0 +1,14 @@
+#ifndef _SYS_EVENTFD_H_
+#define _SYS_EVENTFD_H_
+
+#include <sys/cdefs.h>
+#include <asm/unistd.h>
+#include <asm/termbits.h>
+
+__BEGIN_DECLS
+
+extern int eventfd(int count, int flags);
+
+__END_DECLS
+
+#endif /*  _SYS_EVENTFD_H_ */
diff --git a/libc/include/sys/linux-syscalls.h b/libc/include/sys/linux-syscalls.h
index 9e2aa2f..8239948 100644
--- a/libc/include/sys/linux-syscalls.h
+++ b/libc/include/sys/linux-syscalls.h
@@ -182,6 +182,7 @@
 #define __NR_inotify_rm_watch             (__NR_SYSCALL_BASE + 318)
 #define __NR_ARM_set_tls                  (__NR_SYSCALL_BASE + 983045)
 #define __NR_ARM_cacheflush               (__NR_SYSCALL_BASE + 983042)
+#define __NR_eventfd                      (__NR_SYSCALL_BASE + 351)
 #endif
 
 #ifdef __i386__
@@ -222,6 +223,7 @@
 #define __NR_inotify_init                 (__NR_SYSCALL_BASE + 291)
 #define __NR_inotify_add_watch            (__NR_SYSCALL_BASE + 292)
 #define __NR_inotify_rm_watch             (__NR_SYSCALL_BASE + 293)
+#define __NR_eventfd                      (__NR_SYSCALL_BASE + 323)
 #endif
 
 #if defined(__SH3__) || defined(__SH4__) 
@@ -278,6 +280,7 @@
 #define __NR_inotify_init                 (__NR_SYSCALL_BASE + 290)
 #define __NR_inotify_add_watch            (__NR_SYSCALL_BASE + 291)
 #define __NR_inotify_rm_watch             (__NR_SYSCALL_BASE + 292)
+#define __NR_eventfd                      (__NR_SYSCALL_BASE + 323)
 #endif
 
 #endif
diff --git a/libc/include/sys/linux-unistd.h b/libc/include/sys/linux-unistd.h
index a439e0f..457cb4d 100644
--- a/libc/include/sys/linux-unistd.h
+++ b/libc/include/sys/linux-unistd.h
@@ -202,6 +202,7 @@
 int              poll (struct pollfd *, unsigned int, long);
 int              __set_tls (void*);
 int              cacheflush (long start, long end, long flags);
+int              eventfd (int count, int flags);
 #ifdef __cplusplus
 }
 #endif