From cac7b9d6ec1a09814bc028e2f768db732f018891 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 23 Oct 2013 09:48:29 -0700 Subject: [PATCH] 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 --- libc/Android.mk | 4 +++ libc/SYSCALLS.TXT | 23 ++++++------- libc/arch-arm/syscalls.mk | 7 ++-- libc/arch-arm/syscalls/{dup2.S => dup3.S} | 6 ++-- .../{epoll_create.S => epoll_create1.S} | 6 ++-- .../{inotify_init.S => inotify_init1.S} | 6 ++-- libc/arch-arm/syscalls/pipe.S | 16 --------- libc/arch-mips/syscalls.mk | 6 ++-- libc/arch-mips/syscalls/{dup2.S => dup3.S} | 10 +++--- .../{epoll_create.S => epoll_create1.S} | 10 +++--- .../{inotify_init.S => inotify_init1.S} | 10 +++--- libc/arch-x86/syscalls.mk | 7 ++-- libc/arch-x86/syscalls/{dup2.S => dup3.S} | 13 +++++--- .../{epoll_create.S => epoll_create1.S} | 6 ++-- .../{inotify_init.S => inotify_init1.S} | 6 ++-- libc/arch-x86/syscalls/pipe.S | 22 ------------- libc/arch-x86_64/syscalls.mk | 7 ++-- libc/arch-x86_64/syscalls/{dup2.S => dup3.S} | 6 ++-- .../{epoll_create.S => epoll_create1.S} | 6 ++-- .../{inotify_init.S => inotify_init1.S} | 6 ++-- libc/arch-x86_64/syscalls/pipe.S | 18 ---------- libc/bionic/dup2.cpp | 33 +++++++++++++++++++ libc/bionic/epoll_create.cpp | 33 +++++++++++++++++++ libc/bionic/inotify_init.cpp | 33 +++++++++++++++++++ libc/bionic/pipe.cpp | 33 +++++++++++++++++++ libc/include/sys/epoll.h | 9 +++-- libc/include/sys/eventfd.h | 1 + libc/include/sys/inotify.h | 11 +++++-- libc/include/unistd.h | 5 ++- 29 files changed, 224 insertions(+), 135 deletions(-) rename libc/arch-arm/syscalls/{dup2.S => dup3.S} (84%) rename libc/arch-arm/syscalls/{epoll_create.S => epoll_create1.S} (77%) rename libc/arch-arm/syscalls/{inotify_init.S => inotify_init1.S} (77%) delete mode 100644 libc/arch-arm/syscalls/pipe.S rename libc/arch-mips/syscalls/{dup2.S => dup3.S} (78%) rename libc/arch-mips/syscalls/{epoll_create.S => epoll_create1.S} (68%) rename libc/arch-mips/syscalls/{inotify_init.S => inotify_init1.S} (68%) rename libc/arch-x86/syscalls/{dup2.S => dup3.S} (68%) rename libc/arch-x86/syscalls/{epoll_create.S => epoll_create1.S} (82%) rename libc/arch-x86/syscalls/{inotify_init.S => inotify_init1.S} (82%) delete mode 100644 libc/arch-x86/syscalls/pipe.S rename libc/arch-x86_64/syscalls/{dup2.S => dup3.S} (84%) rename libc/arch-x86_64/syscalls/{epoll_create.S => epoll_create1.S} (77%) rename libc/arch-x86_64/syscalls/{inotify_init.S => inotify_init1.S} (77%) delete mode 100644 libc/arch-x86_64/syscalls/pipe.S create mode 100644 libc/bionic/dup2.cpp create mode 100644 libc/bionic/epoll_create.cpp create mode 100644 libc/bionic/inotify_init.cpp create mode 100644 libc/bionic/pipe.cpp diff --git a/libc/Android.mk b/libc/Android.mk index a37c9bcf1..1dcedca1c 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -215,6 +215,8 @@ libc_bionic_src_files := \ 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 @@ libc_bionic_src_files := \ 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 @@ libc_bionic_src_files := \ 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 504f190f8..2caacf61e 100644 --- a/libc/SYSCALLS.TXT +++ b/libc/SYSCALLS.TXT @@ -124,9 +124,8 @@ int fcntl(int, void*) x86_64 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 sysinfo(struct sysinfo*) all 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 a59d064a7..959dfeb78 100644 --- a/libc/arch-arm/syscalls.mk +++ b/libc/arch-arm/syscalls.mk @@ -50,8 +50,8 @@ syscall_src += arch-arm/syscalls/close.S 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/getuid.S 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/nanosleep.S 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 a51df1f35..ad212548f 100644 --- a/libc/arch-arm/syscalls/dup2.S +++ b/libc/arch-arm/syscalls/dup3.S @@ -4,13 +4,13 @@ #include #include -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_create1.S similarity index 77% rename from libc/arch-arm/syscalls/epoll_create.S rename to libc/arch-arm/syscalls/epoll_create1.S index d883382da..95715516f 100644 --- a/libc/arch-arm/syscalls/epoll_create.S +++ b/libc/arch-arm/syscalls/epoll_create1.S @@ -4,13 +4,13 @@ #include #include -ENTRY(epoll_create) +ENTRY(epoll_create1) mov ip, r7 - ldr r7, =__NR_epoll_create + ldr r7, =__NR_epoll_create1 swi #0 mov r7, ip cmn r0, #(MAX_ERRNO + 1) bxls lr neg r0, r0 b __set_errno -END(epoll_create) +END(epoll_create1) diff --git a/libc/arch-arm/syscalls/inotify_init.S b/libc/arch-arm/syscalls/inotify_init1.S similarity index 77% rename from libc/arch-arm/syscalls/inotify_init.S rename to libc/arch-arm/syscalls/inotify_init1.S index c48f1ff0a..29595773a 100644 --- a/libc/arch-arm/syscalls/inotify_init.S +++ b/libc/arch-arm/syscalls/inotify_init1.S @@ -4,13 +4,13 @@ #include #include -ENTRY(inotify_init) +ENTRY(inotify_init1) mov ip, r7 - ldr r7, =__NR_inotify_init + ldr r7, =__NR_inotify_init1 swi #0 mov r7, ip cmn r0, #(MAX_ERRNO + 1) bxls lr neg r0, r0 b __set_errno -END(inotify_init) +END(inotify_init1) diff --git a/libc/arch-arm/syscalls/pipe.S b/libc/arch-arm/syscalls/pipe.S deleted file mode 100644 index e7254b7e6..000000000 --- a/libc/arch-arm/syscalls/pipe.S +++ /dev/null @@ -1,16 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -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 621dbacfb..34361fedb 100644 --- a/libc/arch-mips/syscalls.mk +++ b/libc/arch-mips/syscalls.mk @@ -51,8 +51,8 @@ syscall_src += arch-mips/syscalls/close.S 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/getuid.S 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 c35725e61..6a3752cd1 100644 --- a/libc/arch-mips/syscalls/dup2.S +++ b/libc/arch-mips/syscalls/dup3.S @@ -2,14 +2,14 @@ #include .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 @@ dup2: 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_create1.S similarity index 68% rename from libc/arch-mips/syscalls/epoll_create.S rename to libc/arch-mips/syscalls/epoll_create1.S index 6f2832f62..0abaeda34 100644 --- a/libc/arch-mips/syscalls/epoll_create.S +++ b/libc/arch-mips/syscalls/epoll_create1.S @@ -2,14 +2,14 @@ #include .text - .globl epoll_create + .globl epoll_create1 .align 4 - .ent epoll_create + .ent epoll_create1 -epoll_create: +epoll_create1: .set noreorder .cpload $t9 - li $v0, __NR_epoll_create + li $v0, __NR_epoll_create1 syscall bnez $a3, 1f move $a0, $v0 @@ -20,4 +20,4 @@ epoll_create: j $t9 nop .set reorder - .end epoll_create + .end epoll_create1 diff --git a/libc/arch-mips/syscalls/inotify_init.S b/libc/arch-mips/syscalls/inotify_init1.S similarity index 68% rename from libc/arch-mips/syscalls/inotify_init.S rename to libc/arch-mips/syscalls/inotify_init1.S index 6a745fc64..c3fcf4899 100644 --- a/libc/arch-mips/syscalls/inotify_init.S +++ b/libc/arch-mips/syscalls/inotify_init1.S @@ -2,14 +2,14 @@ #include .text - .globl inotify_init + .globl inotify_init1 .align 4 - .ent inotify_init + .ent inotify_init1 -inotify_init: +inotify_init1: .set noreorder .cpload $t9 - li $v0, __NR_inotify_init + li $v0, __NR_inotify_init1 syscall bnez $a3, 1f move $a0, $v0 @@ -20,4 +20,4 @@ inotify_init: j $t9 nop .set reorder - .end inotify_init + .end inotify_init1 diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk index 5d1edaad7..471dbb973 100644 --- a/libc/arch-x86/syscalls.mk +++ b/libc/arch-x86/syscalls.mk @@ -50,8 +50,8 @@ syscall_src += arch-x86/syscalls/close.S 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/getuid.S 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/nanosleep.S 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 fee18f31a..19522f04c 100644 --- a/libc/arch-x86/syscalls/dup2.S +++ b/libc/arch-x86/syscalls/dup3.S @@ -4,12 +4,14 @@ #include #include -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 @@ ENTRY(dup2) 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_create1.S similarity index 82% rename from libc/arch-x86/syscalls/epoll_create.S rename to libc/arch-x86/syscalls/epoll_create1.S index 6c0c31506..53e807b88 100644 --- a/libc/arch-x86/syscalls/epoll_create.S +++ b/libc/arch-x86/syscalls/epoll_create1.S @@ -4,10 +4,10 @@ #include #include -ENTRY(epoll_create) +ENTRY(epoll_create1) pushl %ebx mov 8(%esp), %ebx - movl $__NR_epoll_create, %eax + movl $__NR_epoll_create1, %eax int $0x80 cmpl $-MAX_ERRNO, %eax jb 1f @@ -19,4 +19,4 @@ ENTRY(epoll_create) 1: popl %ebx ret -END(epoll_create) +END(epoll_create1) diff --git a/libc/arch-x86/syscalls/inotify_init.S b/libc/arch-x86/syscalls/inotify_init1.S similarity index 82% rename from libc/arch-x86/syscalls/inotify_init.S rename to libc/arch-x86/syscalls/inotify_init1.S index 21bdfa829..5ea3b8e68 100644 --- a/libc/arch-x86/syscalls/inotify_init.S +++ b/libc/arch-x86/syscalls/inotify_init1.S @@ -4,10 +4,10 @@ #include #include -ENTRY(inotify_init) +ENTRY(inotify_init1) pushl %ebx mov 8(%esp), %ebx - movl $__NR_inotify_init, %eax + movl $__NR_inotify_init1, %eax int $0x80 cmpl $-MAX_ERRNO, %eax jb 1f @@ -19,4 +19,4 @@ ENTRY(inotify_init) 1: popl %ebx ret -END(inotify_init) +END(inotify_init1) diff --git a/libc/arch-x86/syscalls/pipe.S b/libc/arch-x86/syscalls/pipe.S deleted file mode 100644 index 1d07efc4e..000000000 --- a/libc/arch-x86/syscalls/pipe.S +++ /dev/null @@ -1,22 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -ENTRY(pipe) - pushl %ebx - mov 8(%esp), %ebx - movl $__NR_pipe, %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(pipe) diff --git a/libc/arch-x86_64/syscalls.mk b/libc/arch-x86_64/syscalls.mk index 803b700a5..44ef7299a 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/close.S 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/getuid.S 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/nanosleep.S 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 e183e3031..58783903f 100644 --- a/libc/arch-x86_64/syscalls/dup2.S +++ b/libc/arch-x86_64/syscalls/dup3.S @@ -4,8 +4,8 @@ #include #include -ENTRY(dup2) - movl $__NR_dup2, %eax +ENTRY(dup3) + movl $__NR_dup3, %eax syscall cmpq $-MAX_ERRNO, %rax jb 1f @@ -15,4 +15,4 @@ ENTRY(dup2) 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_create1.S similarity index 77% rename from libc/arch-x86_64/syscalls/epoll_create.S rename to libc/arch-x86_64/syscalls/epoll_create1.S index 7fbfd2b78..7de84961b 100644 --- a/libc/arch-x86_64/syscalls/epoll_create.S +++ b/libc/arch-x86_64/syscalls/epoll_create1.S @@ -4,8 +4,8 @@ #include #include -ENTRY(epoll_create) - movl $__NR_epoll_create, %eax +ENTRY(epoll_create1) + movl $__NR_epoll_create1, %eax syscall cmpq $-MAX_ERRNO, %rax jb 1f @@ -15,4 +15,4 @@ ENTRY(epoll_create) orq $-1, %rax 1: ret -END(epoll_create) +END(epoll_create1) diff --git a/libc/arch-x86_64/syscalls/inotify_init.S b/libc/arch-x86_64/syscalls/inotify_init1.S similarity index 77% rename from libc/arch-x86_64/syscalls/inotify_init.S rename to libc/arch-x86_64/syscalls/inotify_init1.S index e456739b0..86a6d5f10 100644 --- a/libc/arch-x86_64/syscalls/inotify_init.S +++ b/libc/arch-x86_64/syscalls/inotify_init1.S @@ -4,8 +4,8 @@ #include #include -ENTRY(inotify_init) - movl $__NR_inotify_init, %eax +ENTRY(inotify_init1) + movl $__NR_inotify_init1, %eax syscall cmpq $-MAX_ERRNO, %rax jb 1f @@ -15,4 +15,4 @@ ENTRY(inotify_init) orq $-1, %rax 1: ret -END(inotify_init) +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 e06932be9..000000000 --- a/libc/arch-x86_64/syscalls/pipe.S +++ /dev/null @@ -1,18 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include -#include -#include - -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 000000000..0b8632bee --- /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 + +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 000000000..1dfafa839 --- /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 + +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 000000000..b045984c6 --- /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 + +int inotify_init() { + return inotify_init1(0); +} diff --git a/libc/bionic/pipe.cpp b/libc/bionic/pipe.cpp new file mode 100644 index 000000000..a81afe8e0 --- /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 + +int pipe(int pipefd[2]) { + return pipe2(pipefd, 0); +} diff --git a/libc/include/sys/epoll.h b/libc/include/sys/epoll.h index 38739aa13..625f4c20e 100644 --- a/libc/include/sys/epoll.h +++ b/libc/include/sys/epoll.h @@ -29,6 +29,7 @@ #define _SYS_EPOLL_H_ #include +#include /* For O_CLOEXEC. */ __BEGIN_DECLS @@ -51,7 +52,9 @@ __BEGIN_DECLS #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 @@ typedef union epoll_data 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 ec84e27b7..4c8da0c47 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 33f9e7422..a88cdee48 100644 --- a/libc/include/sys/inotify.h +++ b/libc/include/sys/inotify.h @@ -29,14 +29,19 @@ #define _SYS_INOTIFY_H_ #include -#include +#include #include +#include /* 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 509ee5ceb..91b0d8d45 100644 --- a/libc/include/unistd.h +++ b/libc/include/unistd.h @@ -114,7 +114,7 @@ extern int chdir(const char *); 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 ssize_t pwrite64(int, const void *, size_t, off64_t); 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);