Merge "Add unshare() syscall."
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index 504a050..8f78e7f 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -1,6 +1,6 @@
 # this file is used to list all the syscalls that will be supported by
 # the Bionic C library. It is used to automatically generate the syscall
-# stubs, the list of syscall constants (__NR_xxxx) and the content of <linux/_unitsd.h>
+# stubs, the list of syscall constants (__NR_xxxx) and the content of <linux/_unistd.h>
 #
 # each non comment line has the following format:
 #
@@ -191,6 +191,7 @@
 int     removexattr(const char *, const char *) 235,235,233
 int     lremovexattr(const char *, const char *) 236,236,234
 int     __statfs64:statfs64(const char *, size_t, struct statfs *)  266,268,255
+long    unshare(unsigned long)  337,310,303
 
 # time
 int           pause ()                       29
diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk
index e635e68..b1c669d 100644
--- a/libc/arch-arm/syscalls.mk
+++ b/libc/arch-arm/syscalls.mk
@@ -121,6 +121,7 @@
 syscall_src += arch-arm/syscalls/removexattr.S
 syscall_src += arch-arm/syscalls/lremovexattr.S
 syscall_src += arch-arm/syscalls/__statfs64.S
+syscall_src += arch-arm/syscalls/unshare.S
 syscall_src += arch-arm/syscalls/pause.S
 syscall_src += arch-arm/syscalls/gettimeofday.S
 syscall_src += arch-arm/syscalls/settimeofday.S
diff --git a/libc/arch-arm/syscalls/unshare.S b/libc/arch-arm/syscalls/unshare.S
new file mode 100644
index 0000000..0a92b21
--- /dev/null
+++ b/libc/arch-arm/syscalls/unshare.S
@@ -0,0 +1,14 @@
+/* autogenerated by gensyscalls.py */
+#include <machine/asm.h>
+#include <sys/linux-syscalls.h>
+
+ENTRY(unshare)
+    .save   {r4, r7}
+    stmfd   sp!, {r4, r7}
+    ldr     r7, =__NR_unshare
+    swi     #0
+    ldmfd   sp!, {r4, r7}
+    movs    r0, r0
+    bxpl    lr
+    b       __set_syscall_errno
+END(unshare)
diff --git a/libc/arch-mips/syscalls.mk b/libc/arch-mips/syscalls.mk
index 8c0c4dc..6de0c8f 100644
--- a/libc/arch-mips/syscalls.mk
+++ b/libc/arch-mips/syscalls.mk
@@ -124,6 +124,7 @@
 syscall_src += arch-mips/syscalls/removexattr.S
 syscall_src += arch-mips/syscalls/lremovexattr.S
 syscall_src += arch-mips/syscalls/__statfs64.S
+syscall_src += arch-mips/syscalls/unshare.S
 syscall_src += arch-mips/syscalls/pause.S
 syscall_src += arch-mips/syscalls/gettimeofday.S
 syscall_src += arch-mips/syscalls/settimeofday.S
diff --git a/libc/arch-mips/syscalls/unshare.S b/libc/arch-mips/syscalls/unshare.S
new file mode 100644
index 0000000..11af354
--- /dev/null
+++ b/libc/arch-mips/syscalls/unshare.S
@@ -0,0 +1,22 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+    .text
+    .globl unshare
+    .align 4
+    .ent unshare
+
+unshare:
+    .set noreorder
+    .cpload $t9
+    li $v0, __NR_unshare
+    syscall
+    bnez $a3, 1f
+    move $a0, $v0
+    j $ra
+    nop
+1:
+    la $t9,__set_errno
+    j $t9
+    nop
+    .set reorder
+    .end unshare
diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk
index f1b7e76..2352221 100644
--- a/libc/arch-x86/syscalls.mk
+++ b/libc/arch-x86/syscalls.mk
@@ -125,6 +125,7 @@
 syscall_src += arch-x86/syscalls/removexattr.S
 syscall_src += arch-x86/syscalls/lremovexattr.S
 syscall_src += arch-x86/syscalls/__statfs64.S
+syscall_src += arch-x86/syscalls/unshare.S
 syscall_src += arch-x86/syscalls/pause.S
 syscall_src += arch-x86/syscalls/gettimeofday.S
 syscall_src += arch-x86/syscalls/settimeofday.S
diff --git a/libc/arch-x86/syscalls/unshare.S b/libc/arch-x86/syscalls/unshare.S
new file mode 100644
index 0000000..ef31a35
--- /dev/null
+++ b/libc/arch-x86/syscalls/unshare.S
@@ -0,0 +1,23 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+    .text
+    .type unshare, @function
+    .globl unshare
+    .align 4
+
+unshare:
+    pushl   %ebx
+    mov     8(%esp), %ebx
+    movl    $__NR_unshare, %eax
+    int     $0x80
+    cmpl    $-129, %eax
+    jb      1f
+    negl    %eax
+    pushl   %eax
+    call    __set_errno
+    addl    $4, %esp
+    orl     $-1, %eax
+1:
+    popl    %ebx
+    ret
diff --git a/libc/include/sys/linux-syscalls.h b/libc/include/sys/linux-syscalls.h
index c8a654c..c33dc9f 100644
--- a/libc/include/sys/linux-syscalls.h
+++ b/libc/include/sys/linux-syscalls.h
@@ -155,6 +155,7 @@
 #define __NR_removexattr                  (__NR_SYSCALL_BASE + 235)
 #define __NR_lremovexattr                 (__NR_SYSCALL_BASE + 236)
 #define __NR_statfs64                     (__NR_SYSCALL_BASE + 266)
+#define __NR_unshare                      (__NR_SYSCALL_BASE + 337)
 #define __NR_nanosleep                    (__NR_SYSCALL_BASE + 162)
 #define __NR_clock_gettime                (__NR_SYSCALL_BASE + 263)
 #define __NR_clock_settime                (__NR_SYSCALL_BASE + 262)
@@ -318,6 +319,7 @@
 #define __NR_renameat                     (__NR_SYSCALL_BASE + 302)
 #define __NR_fchmodat                     (__NR_SYSCALL_BASE + 306)
 #define __NR_faccessat                    (__NR_SYSCALL_BASE + 307)
+#define __NR_unshare                      (__NR_SYSCALL_BASE + 310)
 #define __NR_getcpu                       (__NR_SYSCALL_BASE + 318)
 #define __NR_utimensat                    (__NR_SYSCALL_BASE + 320)
 #define __NR_eventfd2                     (__NR_SYSCALL_BASE + 328)
@@ -444,6 +446,7 @@
 #define __NR_renameat                     (__NR_SYSCALL_BASE + 295)
 #define __NR_fchmodat                     (__NR_SYSCALL_BASE + 299)
 #define __NR_faccessat                    (__NR_SYSCALL_BASE + 300)
+#define __NR_unshare                      (__NR_SYSCALL_BASE + 303)
 #define __NR_getcpu                       (__NR_SYSCALL_BASE + 312)
 #define __NR_ioprio_set                   (__NR_SYSCALL_BASE + 314)
 #define __NR_ioprio_get                   (__NR_SYSCALL_BASE + 315)