Remove dependencies on obsolete __ARCH_WANT_SYSCALL_NO_FLAGS syscalls.
(aarch64 kernels only have the newer system calls.)
Also expose the new functionality that's exposed by glibc in our header files.
Change-Id: I45d2d168a03f88723d1f7fbf634701006a4843c5
diff --git a/libc/Android.mk b/libc/Android.mk
index a37c9bc..1dcedca 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -215,6 +215,8 @@
bionic/chmod.cpp \
bionic/chown.cpp \
bionic/dirent.cpp \
+ bionic/dup2.cpp \
+ bionic/epoll_create.cpp \
bionic/__errno.cpp \
bionic/eventfd_read.cpp \
bionic/eventfd_write.cpp \
@@ -222,6 +224,7 @@
bionic/futimens.cpp \
bionic/getauxval.cpp \
bionic/getcwd.cpp \
+ bionic/inotify_init.cpp \
bionic/lchown.cpp \
bionic/libc_init_common.cpp \
bionic/libc_logging.cpp \
@@ -232,6 +235,7 @@
bionic/mkfifo.cpp \
bionic/mknod.cpp \
bionic/open.cpp \
+ bionic/pipe.cpp \
bionic/pthread_attr.cpp \
bionic/pthread_detach.cpp \
bionic/pthread_equal.cpp \
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index 504f190..2caacf6 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -124,9 +124,8 @@
int flock(int, int) all
int fchmod(int, mode_t) all
int dup(int) all
-int pipe(int*) arm,x86,x86_64
int pipe2(int*, int) all
-int dup2(int, int) all
+int dup3(int, int, int) all
int select:_newselect(int, struct fd_set*, struct fd_set*, struct fd_set*, struct timeval*) arm,x86,mips
int select(int, struct fd_set*, struct fd_set*, struct fd_set*, struct timeval*) x86_64
int getdents:getdents64(unsigned int, struct dirent*, unsigned int) all
@@ -290,22 +289,20 @@
int personality(unsigned long) all
long perf_event_open(struct perf_event_attr* attr_uptr, pid_t pid, int cpu, int group_fd, unsigned long flags) all
-# futex
-int futex(void*, int, int, void*, void*, int) all
+int epoll_create1(int) all
+int epoll_ctl(int, int op, int, struct epoll_event*) all
+int epoll_wait(int, struct epoll_event*, int, int) all
-# epoll
-int epoll_create(int size) all
-int epoll_ctl(int epfd, int op, int fd, struct epoll_event* event) all
-int epoll_wait(int epfd, struct epoll_event* events, int max, int timeout) all
+int eventfd:eventfd2(unsigned int, int) all
-int inotify_init(void) all
-int inotify_add_watch(int, const char*, unsigned int) all
-int inotify_rm_watch(int, unsigned int) all
+int futex(void*, int, int, void*, void*, int) all
+
+int inotify_init1(int) all
+int inotify_add_watch(int, const char*, unsigned int) all
+int inotify_rm_watch(int, unsigned int) all
int poll(struct pollfd*, unsigned int, long) all
-int eventfd:eventfd2(unsigned int, int) all
-
# ARM-specific
int __set_tls:__ARM_NR_set_tls(void*) arm
int cacheflush:__ARM_NR_cacheflush(long start, long end, long flags) arm
diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk
index a59d064..959dfeb 100644
--- a/libc/arch-arm/syscalls.mk
+++ b/libc/arch-arm/syscalls.mk
@@ -50,8 +50,8 @@
syscall_src += arch-arm/syscalls/connect.S
syscall_src += arch-arm/syscalls/delete_module.S
syscall_src += arch-arm/syscalls/dup.S
-syscall_src += arch-arm/syscalls/dup2.S
-syscall_src += arch-arm/syscalls/epoll_create.S
+syscall_src += arch-arm/syscalls/dup3.S
+syscall_src += arch-arm/syscalls/epoll_create1.S
syscall_src += arch-arm/syscalls/epoll_ctl.S
syscall_src += arch-arm/syscalls/epoll_wait.S
syscall_src += arch-arm/syscalls/eventfd.S
@@ -97,7 +97,7 @@
syscall_src += arch-arm/syscalls/getxattr.S
syscall_src += arch-arm/syscalls/init_module.S
syscall_src += arch-arm/syscalls/inotify_add_watch.S
-syscall_src += arch-arm/syscalls/inotify_init.S
+syscall_src += arch-arm/syscalls/inotify_init1.S
syscall_src += arch-arm/syscalls/inotify_rm_watch.S
syscall_src += arch-arm/syscalls/ioprio_get.S
syscall_src += arch-arm/syscalls/ioprio_set.S
@@ -127,7 +127,6 @@
syscall_src += arch-arm/syscalls/pause.S
syscall_src += arch-arm/syscalls/perf_event_open.S
syscall_src += arch-arm/syscalls/personality.S
-syscall_src += arch-arm/syscalls/pipe.S
syscall_src += arch-arm/syscalls/pipe2.S
syscall_src += arch-arm/syscalls/poll.S
syscall_src += arch-arm/syscalls/prctl.S
diff --git a/libc/arch-arm/syscalls/dup2.S b/libc/arch-arm/syscalls/dup3.S
similarity index 84%
rename from libc/arch-arm/syscalls/dup2.S
rename to libc/arch-arm/syscalls/dup3.S
index a51df1f..ad21254 100644
--- a/libc/arch-arm/syscalls/dup2.S
+++ b/libc/arch-arm/syscalls/dup3.S
@@ -4,13 +4,13 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(dup2)
+ENTRY(dup3)
mov ip, r7
- ldr r7, =__NR_dup2
+ ldr r7, =__NR_dup3
swi #0
mov r7, ip
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno
-END(dup2)
+END(dup3)
diff --git a/libc/arch-arm/syscalls/epoll_create.S b/libc/arch-arm/syscalls/epoll_create.S
deleted file mode 100644
index d883382..0000000
--- a/libc/arch-arm/syscalls/epoll_create.S
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(epoll_create)
- mov ip, r7
- ldr r7, =__NR_epoll_create
- swi #0
- mov r7, ip
- cmn r0, #(MAX_ERRNO + 1)
- bxls lr
- neg r0, r0
- b __set_errno
-END(epoll_create)
diff --git a/libc/arch-arm/syscalls/dup2.S b/libc/arch-arm/syscalls/epoll_create1.S
similarity index 77%
copy from libc/arch-arm/syscalls/dup2.S
copy to libc/arch-arm/syscalls/epoll_create1.S
index a51df1f..9571551 100644
--- a/libc/arch-arm/syscalls/dup2.S
+++ b/libc/arch-arm/syscalls/epoll_create1.S
@@ -4,13 +4,13 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(dup2)
+ENTRY(epoll_create1)
mov ip, r7
- ldr r7, =__NR_dup2
+ ldr r7, =__NR_epoll_create1
swi #0
mov r7, ip
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno
-END(dup2)
+END(epoll_create1)
diff --git a/libc/arch-arm/syscalls/inotify_init.S b/libc/arch-arm/syscalls/inotify_init.S
deleted file mode 100644
index c48f1ff..0000000
--- a/libc/arch-arm/syscalls/inotify_init.S
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(inotify_init)
- mov ip, r7
- ldr r7, =__NR_inotify_init
- swi #0
- mov r7, ip
- cmn r0, #(MAX_ERRNO + 1)
- bxls lr
- neg r0, r0
- b __set_errno
-END(inotify_init)
diff --git a/libc/arch-arm/syscalls/dup2.S b/libc/arch-arm/syscalls/inotify_init1.S
similarity index 77%
copy from libc/arch-arm/syscalls/dup2.S
copy to libc/arch-arm/syscalls/inotify_init1.S
index a51df1f..2959577 100644
--- a/libc/arch-arm/syscalls/dup2.S
+++ b/libc/arch-arm/syscalls/inotify_init1.S
@@ -4,13 +4,13 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(dup2)
+ENTRY(inotify_init1)
mov ip, r7
- ldr r7, =__NR_dup2
+ ldr r7, =__NR_inotify_init1
swi #0
mov r7, ip
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno
-END(dup2)
+END(inotify_init1)
diff --git a/libc/arch-arm/syscalls/pipe.S b/libc/arch-arm/syscalls/pipe.S
deleted file mode 100644
index e7254b7..0000000
--- a/libc/arch-arm/syscalls/pipe.S
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(pipe)
- mov ip, r7
- ldr r7, =__NR_pipe
- swi #0
- mov r7, ip
- cmn r0, #(MAX_ERRNO + 1)
- bxls lr
- neg r0, r0
- b __set_errno
-END(pipe)
diff --git a/libc/arch-mips/syscalls.mk b/libc/arch-mips/syscalls.mk
index 621dbac..34361fe 100644
--- a/libc/arch-mips/syscalls.mk
+++ b/libc/arch-mips/syscalls.mk
@@ -51,8 +51,8 @@
syscall_src += arch-mips/syscalls/connect.S
syscall_src += arch-mips/syscalls/delete_module.S
syscall_src += arch-mips/syscalls/dup.S
-syscall_src += arch-mips/syscalls/dup2.S
-syscall_src += arch-mips/syscalls/epoll_create.S
+syscall_src += arch-mips/syscalls/dup3.S
+syscall_src += arch-mips/syscalls/epoll_create1.S
syscall_src += arch-mips/syscalls/epoll_ctl.S
syscall_src += arch-mips/syscalls/epoll_wait.S
syscall_src += arch-mips/syscalls/eventfd.S
@@ -98,7 +98,7 @@
syscall_src += arch-mips/syscalls/getxattr.S
syscall_src += arch-mips/syscalls/init_module.S
syscall_src += arch-mips/syscalls/inotify_add_watch.S
-syscall_src += arch-mips/syscalls/inotify_init.S
+syscall_src += arch-mips/syscalls/inotify_init1.S
syscall_src += arch-mips/syscalls/inotify_rm_watch.S
syscall_src += arch-mips/syscalls/ioprio_get.S
syscall_src += arch-mips/syscalls/ioprio_set.S
diff --git a/libc/arch-mips/syscalls/dup2.S b/libc/arch-mips/syscalls/dup3.S
similarity index 78%
rename from libc/arch-mips/syscalls/dup2.S
rename to libc/arch-mips/syscalls/dup3.S
index c35725e..6a3752c 100644
--- a/libc/arch-mips/syscalls/dup2.S
+++ b/libc/arch-mips/syscalls/dup3.S
@@ -2,14 +2,14 @@
#include <asm/unistd.h>
.text
- .globl dup2
+ .globl dup3
.align 4
- .ent dup2
+ .ent dup3
-dup2:
+dup3:
.set noreorder
.cpload $t9
- li $v0, __NR_dup2
+ li $v0, __NR_dup3
syscall
bnez $a3, 1f
move $a0, $v0
@@ -20,4 +20,4 @@
j $t9
nop
.set reorder
- .end dup2
+ .end dup3
diff --git a/libc/arch-mips/syscalls/epoll_create.S b/libc/arch-mips/syscalls/epoll_create.S
deleted file mode 100644
index 6f2832f..0000000
--- a/libc/arch-mips/syscalls/epoll_create.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
- .text
- .globl epoll_create
- .align 4
- .ent epoll_create
-
-epoll_create:
- .set noreorder
- .cpload $t9
- li $v0, __NR_epoll_create
- syscall
- bnez $a3, 1f
- move $a0, $v0
- j $ra
- nop
-1:
- la $t9,__set_errno
- j $t9
- nop
- .set reorder
- .end epoll_create
diff --git a/libc/arch-mips/syscalls/dup2.S b/libc/arch-mips/syscalls/epoll_create1.S
similarity index 68%
copy from libc/arch-mips/syscalls/dup2.S
copy to libc/arch-mips/syscalls/epoll_create1.S
index c35725e..0abaeda 100644
--- a/libc/arch-mips/syscalls/dup2.S
+++ b/libc/arch-mips/syscalls/epoll_create1.S
@@ -2,14 +2,14 @@
#include <asm/unistd.h>
.text
- .globl dup2
+ .globl epoll_create1
.align 4
- .ent dup2
+ .ent epoll_create1
-dup2:
+epoll_create1:
.set noreorder
.cpload $t9
- li $v0, __NR_dup2
+ li $v0, __NR_epoll_create1
syscall
bnez $a3, 1f
move $a0, $v0
@@ -20,4 +20,4 @@
j $t9
nop
.set reorder
- .end dup2
+ .end epoll_create1
diff --git a/libc/arch-mips/syscalls/inotify_init.S b/libc/arch-mips/syscalls/inotify_init.S
deleted file mode 100644
index 6a745fc..0000000
--- a/libc/arch-mips/syscalls/inotify_init.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
- .text
- .globl inotify_init
- .align 4
- .ent inotify_init
-
-inotify_init:
- .set noreorder
- .cpload $t9
- li $v0, __NR_inotify_init
- syscall
- bnez $a3, 1f
- move $a0, $v0
- j $ra
- nop
-1:
- la $t9,__set_errno
- j $t9
- nop
- .set reorder
- .end inotify_init
diff --git a/libc/arch-mips/syscalls/dup2.S b/libc/arch-mips/syscalls/inotify_init1.S
similarity index 68%
copy from libc/arch-mips/syscalls/dup2.S
copy to libc/arch-mips/syscalls/inotify_init1.S
index c35725e..c3fcf48 100644
--- a/libc/arch-mips/syscalls/dup2.S
+++ b/libc/arch-mips/syscalls/inotify_init1.S
@@ -2,14 +2,14 @@
#include <asm/unistd.h>
.text
- .globl dup2
+ .globl inotify_init1
.align 4
- .ent dup2
+ .ent inotify_init1
-dup2:
+inotify_init1:
.set noreorder
.cpload $t9
- li $v0, __NR_dup2
+ li $v0, __NR_inotify_init1
syscall
bnez $a3, 1f
move $a0, $v0
@@ -20,4 +20,4 @@
j $t9
nop
.set reorder
- .end dup2
+ .end inotify_init1
diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk
index 5d1edaa..471dbb9 100644
--- a/libc/arch-x86/syscalls.mk
+++ b/libc/arch-x86/syscalls.mk
@@ -50,8 +50,8 @@
syscall_src += arch-x86/syscalls/connect.S
syscall_src += arch-x86/syscalls/delete_module.S
syscall_src += arch-x86/syscalls/dup.S
-syscall_src += arch-x86/syscalls/dup2.S
-syscall_src += arch-x86/syscalls/epoll_create.S
+syscall_src += arch-x86/syscalls/dup3.S
+syscall_src += arch-x86/syscalls/epoll_create1.S
syscall_src += arch-x86/syscalls/epoll_ctl.S
syscall_src += arch-x86/syscalls/epoll_wait.S
syscall_src += arch-x86/syscalls/eventfd.S
@@ -97,7 +97,7 @@
syscall_src += arch-x86/syscalls/getxattr.S
syscall_src += arch-x86/syscalls/init_module.S
syscall_src += arch-x86/syscalls/inotify_add_watch.S
-syscall_src += arch-x86/syscalls/inotify_init.S
+syscall_src += arch-x86/syscalls/inotify_init1.S
syscall_src += arch-x86/syscalls/inotify_rm_watch.S
syscall_src += arch-x86/syscalls/ioprio_get.S
syscall_src += arch-x86/syscalls/ioprio_set.S
@@ -128,7 +128,6 @@
syscall_src += arch-x86/syscalls/pause.S
syscall_src += arch-x86/syscalls/perf_event_open.S
syscall_src += arch-x86/syscalls/personality.S
-syscall_src += arch-x86/syscalls/pipe.S
syscall_src += arch-x86/syscalls/pipe2.S
syscall_src += arch-x86/syscalls/poll.S
syscall_src += arch-x86/syscalls/prctl.S
diff --git a/libc/arch-x86/syscalls/dup2.S b/libc/arch-x86/syscalls/dup3.S
similarity index 68%
rename from libc/arch-x86/syscalls/dup2.S
rename to libc/arch-x86/syscalls/dup3.S
index fee18f3..19522f0 100644
--- a/libc/arch-x86/syscalls/dup2.S
+++ b/libc/arch-x86/syscalls/dup3.S
@@ -4,12 +4,14 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(dup2)
+ENTRY(dup3)
pushl %ebx
pushl %ecx
- mov 12(%esp), %ebx
- mov 16(%esp), %ecx
- movl $__NR_dup2, %eax
+ pushl %edx
+ mov 16(%esp), %ebx
+ mov 20(%esp), %ecx
+ mov 24(%esp), %edx
+ movl $__NR_dup3, %eax
int $0x80
cmpl $-MAX_ERRNO, %eax
jb 1f
@@ -19,7 +21,8 @@
addl $4, %esp
orl $-1, %eax
1:
+ popl %edx
popl %ecx
popl %ebx
ret
-END(dup2)
+END(dup3)
diff --git a/libc/arch-x86/syscalls/epoll_create.S b/libc/arch-x86/syscalls/epoll_create.S
deleted file mode 100644
index 6c0c315..0000000
--- a/libc/arch-x86/syscalls/epoll_create.S
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(epoll_create)
- pushl %ebx
- mov 8(%esp), %ebx
- movl $__NR_epoll_create, %eax
- int $0x80
- cmpl $-MAX_ERRNO, %eax
- jb 1f
- negl %eax
- pushl %eax
- call __set_errno
- addl $4, %esp
- orl $-1, %eax
-1:
- popl %ebx
- ret
-END(epoll_create)
diff --git a/libc/arch-x86/syscalls/pipe.S b/libc/arch-x86/syscalls/epoll_create1.S
similarity index 81%
copy from libc/arch-x86/syscalls/pipe.S
copy to libc/arch-x86/syscalls/epoll_create1.S
index 1d07efc..53e807b 100644
--- a/libc/arch-x86/syscalls/pipe.S
+++ b/libc/arch-x86/syscalls/epoll_create1.S
@@ -4,10 +4,10 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(pipe)
+ENTRY(epoll_create1)
pushl %ebx
mov 8(%esp), %ebx
- movl $__NR_pipe, %eax
+ movl $__NR_epoll_create1, %eax
int $0x80
cmpl $-MAX_ERRNO, %eax
jb 1f
@@ -19,4 +19,4 @@
1:
popl %ebx
ret
-END(pipe)
+END(epoll_create1)
diff --git a/libc/arch-x86/syscalls/inotify_init.S b/libc/arch-x86/syscalls/inotify_init.S
deleted file mode 100644
index 21bdfa8..0000000
--- a/libc/arch-x86/syscalls/inotify_init.S
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(inotify_init)
- pushl %ebx
- mov 8(%esp), %ebx
- movl $__NR_inotify_init, %eax
- int $0x80
- cmpl $-MAX_ERRNO, %eax
- jb 1f
- negl %eax
- pushl %eax
- call __set_errno
- addl $4, %esp
- orl $-1, %eax
-1:
- popl %ebx
- ret
-END(inotify_init)
diff --git a/libc/arch-x86/syscalls/pipe.S b/libc/arch-x86/syscalls/inotify_init1.S
similarity index 81%
rename from libc/arch-x86/syscalls/pipe.S
rename to libc/arch-x86/syscalls/inotify_init1.S
index 1d07efc..5ea3b8e 100644
--- a/libc/arch-x86/syscalls/pipe.S
+++ b/libc/arch-x86/syscalls/inotify_init1.S
@@ -4,10 +4,10 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(pipe)
+ENTRY(inotify_init1)
pushl %ebx
mov 8(%esp), %ebx
- movl $__NR_pipe, %eax
+ movl $__NR_inotify_init1, %eax
int $0x80
cmpl $-MAX_ERRNO, %eax
jb 1f
@@ -19,4 +19,4 @@
1:
popl %ebx
ret
-END(pipe)
+END(inotify_init1)
diff --git a/libc/arch-x86_64/syscalls.mk b/libc/arch-x86_64/syscalls.mk
index 803b700..44ef729 100644
--- a/libc/arch-x86_64/syscalls.mk
+++ b/libc/arch-x86_64/syscalls.mk
@@ -41,8 +41,8 @@
syscall_src += arch-x86_64/syscalls/connect.S
syscall_src += arch-x86_64/syscalls/delete_module.S
syscall_src += arch-x86_64/syscalls/dup.S
-syscall_src += arch-x86_64/syscalls/dup2.S
-syscall_src += arch-x86_64/syscalls/epoll_create.S
+syscall_src += arch-x86_64/syscalls/dup3.S
+syscall_src += arch-x86_64/syscalls/epoll_create1.S
syscall_src += arch-x86_64/syscalls/epoll_ctl.S
syscall_src += arch-x86_64/syscalls/epoll_wait.S
syscall_src += arch-x86_64/syscalls/eventfd.S
@@ -89,7 +89,7 @@
syscall_src += arch-x86_64/syscalls/getxattr.S
syscall_src += arch-x86_64/syscalls/init_module.S
syscall_src += arch-x86_64/syscalls/inotify_add_watch.S
-syscall_src += arch-x86_64/syscalls/inotify_init.S
+syscall_src += arch-x86_64/syscalls/inotify_init1.S
syscall_src += arch-x86_64/syscalls/inotify_rm_watch.S
syscall_src += arch-x86_64/syscalls/ioprio_get.S
syscall_src += arch-x86_64/syscalls/ioprio_set.S
@@ -121,7 +121,6 @@
syscall_src += arch-x86_64/syscalls/pause.S
syscall_src += arch-x86_64/syscalls/perf_event_open.S
syscall_src += arch-x86_64/syscalls/personality.S
-syscall_src += arch-x86_64/syscalls/pipe.S
syscall_src += arch-x86_64/syscalls/pipe2.S
syscall_src += arch-x86_64/syscalls/poll.S
syscall_src += arch-x86_64/syscalls/prctl.S
diff --git a/libc/arch-x86_64/syscalls/dup2.S b/libc/arch-x86_64/syscalls/dup3.S
similarity index 84%
rename from libc/arch-x86_64/syscalls/dup2.S
rename to libc/arch-x86_64/syscalls/dup3.S
index e183e30..5878390 100644
--- a/libc/arch-x86_64/syscalls/dup2.S
+++ b/libc/arch-x86_64/syscalls/dup3.S
@@ -4,8 +4,8 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(dup2)
- movl $__NR_dup2, %eax
+ENTRY(dup3)
+ movl $__NR_dup3, %eax
syscall
cmpq $-MAX_ERRNO, %rax
jb 1f
@@ -15,4 +15,4 @@
orq $-1, %rax
1:
ret
-END(dup2)
+END(dup3)
diff --git a/libc/arch-x86_64/syscalls/epoll_create.S b/libc/arch-x86_64/syscalls/epoll_create.S
deleted file mode 100644
index 7fbfd2b..0000000
--- a/libc/arch-x86_64/syscalls/epoll_create.S
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(epoll_create)
- movl $__NR_epoll_create, %eax
- syscall
- cmpq $-MAX_ERRNO, %rax
- jb 1f
- negl %eax
- movl %eax, %edi
- call __set_errno
- orq $-1, %rax
-1:
- ret
-END(epoll_create)
diff --git a/libc/arch-x86_64/syscalls/dup2.S b/libc/arch-x86_64/syscalls/epoll_create1.S
similarity index 77%
copy from libc/arch-x86_64/syscalls/dup2.S
copy to libc/arch-x86_64/syscalls/epoll_create1.S
index e183e30..7de8496 100644
--- a/libc/arch-x86_64/syscalls/dup2.S
+++ b/libc/arch-x86_64/syscalls/epoll_create1.S
@@ -4,8 +4,8 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(dup2)
- movl $__NR_dup2, %eax
+ENTRY(epoll_create1)
+ movl $__NR_epoll_create1, %eax
syscall
cmpq $-MAX_ERRNO, %rax
jb 1f
@@ -15,4 +15,4 @@
orq $-1, %rax
1:
ret
-END(dup2)
+END(epoll_create1)
diff --git a/libc/arch-x86_64/syscalls/inotify_init.S b/libc/arch-x86_64/syscalls/inotify_init.S
deleted file mode 100644
index e456739..0000000
--- a/libc/arch-x86_64/syscalls/inotify_init.S
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(inotify_init)
- movl $__NR_inotify_init, %eax
- syscall
- cmpq $-MAX_ERRNO, %rax
- jb 1f
- negl %eax
- movl %eax, %edi
- call __set_errno
- orq $-1, %rax
-1:
- ret
-END(inotify_init)
diff --git a/libc/arch-x86_64/syscalls/dup2.S b/libc/arch-x86_64/syscalls/inotify_init1.S
similarity index 77%
copy from libc/arch-x86_64/syscalls/dup2.S
copy to libc/arch-x86_64/syscalls/inotify_init1.S
index e183e30..86a6d5f 100644
--- a/libc/arch-x86_64/syscalls/dup2.S
+++ b/libc/arch-x86_64/syscalls/inotify_init1.S
@@ -4,8 +4,8 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(dup2)
- movl $__NR_dup2, %eax
+ENTRY(inotify_init1)
+ movl $__NR_inotify_init1, %eax
syscall
cmpq $-MAX_ERRNO, %rax
jb 1f
@@ -15,4 +15,4 @@
orq $-1, %rax
1:
ret
-END(dup2)
+END(inotify_init1)
diff --git a/libc/arch-x86_64/syscalls/pipe.S b/libc/arch-x86_64/syscalls/pipe.S
deleted file mode 100644
index e06932b..0000000
--- a/libc/arch-x86_64/syscalls/pipe.S
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(pipe)
- movl $__NR_pipe, %eax
- syscall
- cmpq $-MAX_ERRNO, %rax
- jb 1f
- negl %eax
- movl %eax, %edi
- call __set_errno
- orq $-1, %rax
-1:
- ret
-END(pipe)
diff --git a/libc/bionic/dup2.cpp b/libc/bionic/dup2.cpp
new file mode 100644
index 0000000..0b8632b
--- /dev/null
+++ b/libc/bionic/dup2.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+
+int dup2(int old_fd, int new_fd) {
+ return dup3(old_fd, new_fd, 0);
+}
diff --git a/libc/bionic/epoll_create.cpp b/libc/bionic/epoll_create.cpp
new file mode 100644
index 0000000..1dfafa8
--- /dev/null
+++ b/libc/bionic/epoll_create.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/epoll.h>
+
+int epoll_create(int /*obsolete_size*/) {
+ return epoll_create1(0);
+}
diff --git a/libc/bionic/inotify_init.cpp b/libc/bionic/inotify_init.cpp
new file mode 100644
index 0000000..b045984
--- /dev/null
+++ b/libc/bionic/inotify_init.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/inotify.h>
+
+int inotify_init() {
+ return inotify_init1(0);
+}
diff --git a/libc/bionic/pipe.cpp b/libc/bionic/pipe.cpp
new file mode 100644
index 0000000..a81afe8
--- /dev/null
+++ b/libc/bionic/pipe.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+
+int pipe(int pipefd[2]) {
+ return pipe2(pipefd, 0);
+}
diff --git a/libc/include/sys/epoll.h b/libc/include/sys/epoll.h
index 38739aa..625f4c2 100644
--- a/libc/include/sys/epoll.h
+++ b/libc/include/sys/epoll.h
@@ -29,6 +29,7 @@
#define _SYS_EPOLL_H_
#include <sys/cdefs.h>
+#include <asm/fcntl.h> /* For O_CLOEXEC. */
__BEGIN_DECLS
@@ -51,7 +52,9 @@
#define EPOLL_CTL_DEL 2
#define EPOLL_CTL_MOD 3
-typedef union epoll_data
+#define EPOLL_CLOEXEC O_CLOEXEC
+
+typedef union epoll_data
{
void *ptr;
int fd;
@@ -59,17 +62,17 @@
unsigned long long u64;
} epoll_data_t;
-struct epoll_event
+struct epoll_event
{
unsigned int events;
epoll_data_t data;
};
int epoll_create(int size);
+int epoll_create1(int flags);
int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event);
int epoll_wait(int epfd, struct epoll_event *events, int max, int timeout);
__END_DECLS
#endif /* _SYS_EPOLL_H_ */
-
diff --git a/libc/include/sys/eventfd.h b/libc/include/sys/eventfd.h
index ec84e27..4c8da0c 100644
--- a/libc/include/sys/eventfd.h
+++ b/libc/include/sys/eventfd.h
@@ -25,6 +25,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
#ifndef _SYS_EVENTFD_H
#define _SYS_EVENTFD_H
diff --git a/libc/include/sys/inotify.h b/libc/include/sys/inotify.h
index 33f9e74..a88cdee 100644
--- a/libc/include/sys/inotify.h
+++ b/libc/include/sys/inotify.h
@@ -29,14 +29,19 @@
#define _SYS_INOTIFY_H_
#include <sys/cdefs.h>
-#include <sys/types.h>
+#include <stdint.h>
#include <linux/inotify.h>
+#include <asm/fcntl.h> /* For O_CLOEXEC and O_NONBLOCK. */
__BEGIN_DECLS
+#define IN_CLOEXEC O_CLOEXEC
+#define IN_NONBLOCK O_NONBLOCK
+
extern int inotify_init(void);
-extern int inotify_add_watch(int, const char *, __u32);
-extern int inotify_rm_watch(int, __u32);
+extern int inotify_init1(int);
+extern int inotify_add_watch(int, const char*, uint32_t);
+extern int inotify_rm_watch(int, uint32_t);
__END_DECLS
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index 509ee5c..91b0d8d 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -114,7 +114,7 @@
extern int fchdir(int);
extern int rmdir(const char *);
extern int pipe(int *);
-#ifdef _GNU_SOURCE /* GLibc compatibility */
+#ifdef _GNU_SOURCE
extern int pipe2(int *, int);
#endif
extern int chroot(const char *);
@@ -145,6 +145,9 @@
extern int dup(int);
extern int dup2(int, int);
+#ifdef _GNU_SOURCE
+extern int dup3(int, int, int);
+#endif
extern int fcntl(int, int, ...);
extern int ioctl(int, int, ...);
extern int flock(int, int);