Remove dependencies on obsolete __ARCH_WANT_SYSCALL_DEPRECATED system calls.
(aarch64 kernels don't have these system calls.)
Change-Id: I6f64075aa412f71520f2df71c3d69b647f91c1ca
diff --git a/libc/Android.mk b/libc/Android.mk
index 1dcedca..ee09087 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -107,7 +107,6 @@
bionic/pathconf.c \
bionic/perror.c \
bionic/pread.c \
- bionic/pselect.c \
bionic/ptsname.c \
bionic/ptsname_r.c \
bionic/pututline.c \
@@ -211,12 +210,15 @@
bionic/abort.cpp \
bionic/access.cpp \
bionic/assert.cpp \
+ bionic/bionic_time_conversions.cpp \
bionic/brk.cpp \
bionic/chmod.cpp \
bionic/chown.cpp \
bionic/dirent.cpp \
bionic/dup2.cpp \
bionic/epoll_create.cpp \
+ bionic/epoll_wait.cpp \
+ bionic/epoll_pwait.cpp \
bionic/__errno.cpp \
bionic/eventfd_read.cpp \
bionic/eventfd_write.cpp \
@@ -235,7 +237,9 @@
bionic/mkfifo.cpp \
bionic/mknod.cpp \
bionic/open.cpp \
+ bionic/pause.cpp \
bionic/pipe.cpp \
+ bionic/poll.cpp \
bionic/pthread_attr.cpp \
bionic/pthread_detach.cpp \
bionic/pthread_equal.cpp \
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index 2caacf6..8dc2b8a 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -27,14 +27,9 @@
# process management
void _exit:exit_group(int) all
void _exit_thread:exit(int) all
-pid_t __fork:fork(void) all
-pid_t wait4(pid_t pid, int* status, int options, struct rusage* rusage) all
-# NOTE: these stubs are unused.
-pid_t __sys_clone:clone(int, void*, int*, void*, int*) all
-pid_t _waitpid:waitpid(pid_t, int*, int, struct rusage*) mips,x86
-int __waitid:waitid(int, pid_t, struct siginfo_t*, int, void*) all
-int __open:open(const char*, int, mode_t) arm,mips,x86
+pid_t wait4(pid_t, int*, int, struct rusage*) all
+int __waitid:waitid(int, pid_t, struct siginfo_t*, int, void*) all
int execve(const char*, char* const*, char* const*) all
@@ -126,8 +121,6 @@
int dup(int) all
int pipe2(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
int fsync(int) all
int fdatasync(int) all
@@ -197,7 +190,6 @@
int swapoff(const char*) all
# time
-int pause() all
int gettimeofday(struct timeval*, struct timezone*) all
int settimeofday(const struct timeval*, const struct timezone*) all
clock_t times(struct tms*) all
@@ -289,9 +281,11 @@
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
+pid_t __clone:clone(int, void*, int*, 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
+int __epoll_pwait:epoll_pwait(int, struct epoll_event*, int, int, const sigset_t*, size_t) all
int eventfd:eventfd2(unsigned int, int) all
@@ -301,7 +295,8 @@
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 __pselect6:pselect6(int, fd_set*, fd_set*, fd_set*, timespec*, void*) all
+int __ppoll:ppoll(pollfd*, unsigned int, timespec*, const sigset_t*, size_t) all
# ARM-specific
int __set_tls:__ARM_NR_set_tls(void*) arm
diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk
index 959dfeb..e8b6759 100644
--- a/libc/arch-arm/syscalls.mk
+++ b/libc/arch-arm/syscalls.mk
@@ -1,9 +1,10 @@
# Generated by gensyscalls.py. Do not edit.
syscall_src :=
syscall_src += arch-arm/syscalls/__brk.S
+syscall_src += arch-arm/syscalls/__clone.S
+syscall_src += arch-arm/syscalls/__epoll_pwait.S
syscall_src += arch-arm/syscalls/__fcntl.S
syscall_src += arch-arm/syscalls/__fcntl64.S
-syscall_src += arch-arm/syscalls/__fork.S
syscall_src += arch-arm/syscalls/__fstatfs64.S
syscall_src += arch-arm/syscalls/__getcpu.S
syscall_src += arch-arm/syscalls/__getcwd.S
@@ -11,8 +12,9 @@
syscall_src += arch-arm/syscalls/__ioctl.S
syscall_src += arch-arm/syscalls/__llseek.S
syscall_src += arch-arm/syscalls/__mmap2.S
-syscall_src += arch-arm/syscalls/__open.S
syscall_src += arch-arm/syscalls/__openat.S
+syscall_src += arch-arm/syscalls/__ppoll.S
+syscall_src += arch-arm/syscalls/__pselect6.S
syscall_src += arch-arm/syscalls/__ptrace.S
syscall_src += arch-arm/syscalls/__reboot.S
syscall_src += arch-arm/syscalls/__rt_sigaction.S
@@ -24,7 +26,6 @@
syscall_src += arch-arm/syscalls/__set_tls.S
syscall_src += arch-arm/syscalls/__sigaction.S
syscall_src += arch-arm/syscalls/__statfs64.S
-syscall_src += arch-arm/syscalls/__sys_clone.S
syscall_src += arch-arm/syscalls/__syslog.S
syscall_src += arch-arm/syscalls/__timer_create.S
syscall_src += arch-arm/syscalls/__timer_delete.S
@@ -53,7 +54,6 @@
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
syscall_src += arch-arm/syscalls/execve.S
syscall_src += arch-arm/syscalls/faccessat.S
@@ -124,11 +124,9 @@
syscall_src += arch-arm/syscalls/munlockall.S
syscall_src += arch-arm/syscalls/munmap.S
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/pipe2.S
-syscall_src += arch-arm/syscalls/poll.S
syscall_src += arch-arm/syscalls/prctl.S
syscall_src += arch-arm/syscalls/pread64.S
syscall_src += arch-arm/syscalls/pwrite64.S
@@ -149,7 +147,6 @@
syscall_src += arch-arm/syscalls/sched_setparam.S
syscall_src += arch-arm/syscalls/sched_setscheduler.S
syscall_src += arch-arm/syscalls/sched_yield.S
-syscall_src += arch-arm/syscalls/select.S
syscall_src += arch-arm/syscalls/sendfile.S
syscall_src += arch-arm/syscalls/sendfile64.S
syscall_src += arch-arm/syscalls/sendmsg.S
diff --git a/libc/arch-arm/syscalls/__sys_clone.S b/libc/arch-arm/syscalls/__clone.S
similarity index 91%
rename from libc/arch-arm/syscalls/__sys_clone.S
rename to libc/arch-arm/syscalls/__clone.S
index d6b20f2..b7ff23b 100644
--- a/libc/arch-arm/syscalls/__sys_clone.S
+++ b/libc/arch-arm/syscalls/__clone.S
@@ -4,7 +4,7 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(__sys_clone)
+ENTRY(__clone)
mov ip, sp
.save {r4, r5, r6, r7}
stmfd sp!, {r4, r5, r6, r7}
@@ -16,4 +16,4 @@
bxls lr
neg r0, r0
b __set_errno
-END(__sys_clone)
+END(__clone)
diff --git a/libc/arch-arm/syscalls/__sys_clone.S b/libc/arch-arm/syscalls/__epoll_pwait.S
similarity index 83%
copy from libc/arch-arm/syscalls/__sys_clone.S
copy to libc/arch-arm/syscalls/__epoll_pwait.S
index d6b20f2..5eb3dab 100644
--- a/libc/arch-arm/syscalls/__sys_clone.S
+++ b/libc/arch-arm/syscalls/__epoll_pwait.S
@@ -4,16 +4,16 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(__sys_clone)
+ENTRY(__epoll_pwait)
mov ip, sp
.save {r4, r5, r6, r7}
stmfd sp!, {r4, r5, r6, r7}
ldmfd ip, {r4, r5, r6}
- ldr r7, =__NR_clone
+ ldr r7, =__NR_epoll_pwait
swi #0
ldmfd sp!, {r4, r5, r6, r7}
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno
-END(__sys_clone)
+END(__epoll_pwait)
diff --git a/libc/arch-arm/syscalls/__fork.S b/libc/arch-arm/syscalls/__fork.S
deleted file mode 100644
index 99d795d..0000000
--- a/libc/arch-arm/syscalls/__fork.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(__fork)
- mov ip, r7
- ldr r7, =__NR_fork
- swi #0
- mov r7, ip
- cmn r0, #(MAX_ERRNO + 1)
- bxls lr
- neg r0, r0
- b __set_errno
-END(__fork)
diff --git a/libc/arch-arm/syscalls/__open.S b/libc/arch-arm/syscalls/__open.S
deleted file mode 100644
index 20469df..0000000
--- a/libc/arch-arm/syscalls/__open.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(__open)
- mov ip, r7
- ldr r7, =__NR_open
- swi #0
- mov r7, ip
- cmn r0, #(MAX_ERRNO + 1)
- bxls lr
- neg r0, r0
- b __set_errno
-END(__open)
diff --git a/libc/arch-arm/syscalls/select.S b/libc/arch-arm/syscalls/__ppoll.S
similarity index 86%
rename from libc/arch-arm/syscalls/select.S
rename to libc/arch-arm/syscalls/__ppoll.S
index 26ded74..7b833ac 100644
--- a/libc/arch-arm/syscalls/select.S
+++ b/libc/arch-arm/syscalls/__ppoll.S
@@ -4,16 +4,16 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(select)
+ENTRY(__ppoll)
mov ip, sp
.save {r4, r5, r6, r7}
stmfd sp!, {r4, r5, r6, r7}
ldmfd ip, {r4, r5, r6}
- ldr r7, =__NR__newselect
+ ldr r7, =__NR_ppoll
swi #0
ldmfd sp!, {r4, r5, r6, r7}
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno
-END(select)
+END(__ppoll)
diff --git a/libc/arch-arm/syscalls/__sys_clone.S b/libc/arch-arm/syscalls/__pselect6.S
similarity index 84%
copy from libc/arch-arm/syscalls/__sys_clone.S
copy to libc/arch-arm/syscalls/__pselect6.S
index d6b20f2..44e22ee 100644
--- a/libc/arch-arm/syscalls/__sys_clone.S
+++ b/libc/arch-arm/syscalls/__pselect6.S
@@ -4,16 +4,16 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(__sys_clone)
+ENTRY(__pselect6)
mov ip, sp
.save {r4, r5, r6, r7}
stmfd sp!, {r4, r5, r6, r7}
ldmfd ip, {r4, r5, r6}
- ldr r7, =__NR_clone
+ ldr r7, =__NR_pselect6
swi #0
ldmfd sp!, {r4, r5, r6, r7}
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno
-END(__sys_clone)
+END(__pselect6)
diff --git a/libc/arch-arm/syscalls/epoll_wait.S b/libc/arch-arm/syscalls/epoll_wait.S
deleted file mode 100644
index b2b1fef..0000000
--- a/libc/arch-arm/syscalls/epoll_wait.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_wait)
- mov ip, r7
- ldr r7, =__NR_epoll_wait
- swi #0
- mov r7, ip
- cmn r0, #(MAX_ERRNO + 1)
- bxls lr
- neg r0, r0
- b __set_errno
-END(epoll_wait)
diff --git a/libc/arch-arm/syscalls/pause.S b/libc/arch-arm/syscalls/pause.S
deleted file mode 100644
index 3a4b384..0000000
--- a/libc/arch-arm/syscalls/pause.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(pause)
- mov ip, r7
- ldr r7, =__NR_pause
- swi #0
- mov r7, ip
- cmn r0, #(MAX_ERRNO + 1)
- bxls lr
- neg r0, r0
- b __set_errno
-END(pause)
diff --git a/libc/arch-arm/syscalls/poll.S b/libc/arch-arm/syscalls/poll.S
deleted file mode 100644
index 655aced..0000000
--- a/libc/arch-arm/syscalls/poll.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(poll)
- mov ip, r7
- ldr r7, =__NR_poll
- swi #0
- mov r7, ip
- cmn r0, #(MAX_ERRNO + 1)
- bxls lr
- neg r0, r0
- b __set_errno
-END(poll)
diff --git a/libc/arch-mips/syscalls.mk b/libc/arch-mips/syscalls.mk
index 34361fe..e1c106c 100644
--- a/libc/arch-mips/syscalls.mk
+++ b/libc/arch-mips/syscalls.mk
@@ -1,9 +1,10 @@
# Generated by gensyscalls.py. Do not edit.
syscall_src :=
syscall_src += arch-mips/syscalls/__brk.S
+syscall_src += arch-mips/syscalls/__clone.S
+syscall_src += arch-mips/syscalls/__epoll_pwait.S
syscall_src += arch-mips/syscalls/__fcntl.S
syscall_src += arch-mips/syscalls/__fcntl64.S
-syscall_src += arch-mips/syscalls/__fork.S
syscall_src += arch-mips/syscalls/__fstatfs64.S
syscall_src += arch-mips/syscalls/__getcpu.S
syscall_src += arch-mips/syscalls/__getcwd.S
@@ -11,8 +12,9 @@
syscall_src += arch-mips/syscalls/__ioctl.S
syscall_src += arch-mips/syscalls/__llseek.S
syscall_src += arch-mips/syscalls/__mmap2.S
-syscall_src += arch-mips/syscalls/__open.S
syscall_src += arch-mips/syscalls/__openat.S
+syscall_src += arch-mips/syscalls/__ppoll.S
+syscall_src += arch-mips/syscalls/__pselect6.S
syscall_src += arch-mips/syscalls/__ptrace.S
syscall_src += arch-mips/syscalls/__reboot.S
syscall_src += arch-mips/syscalls/__rt_sigaction.S
@@ -24,7 +26,6 @@
syscall_src += arch-mips/syscalls/__set_thread_area.S
syscall_src += arch-mips/syscalls/__sigaction.S
syscall_src += arch-mips/syscalls/__statfs64.S
-syscall_src += arch-mips/syscalls/__sys_clone.S
syscall_src += arch-mips/syscalls/__syslog.S
syscall_src += arch-mips/syscalls/__timer_create.S
syscall_src += arch-mips/syscalls/__timer_delete.S
@@ -35,7 +36,6 @@
syscall_src += arch-mips/syscalls/_exit.S
syscall_src += arch-mips/syscalls/_exit_thread.S
syscall_src += arch-mips/syscalls/_flush_cache.S
-syscall_src += arch-mips/syscalls/_waitpid.S
syscall_src += arch-mips/syscalls/accept.S
syscall_src += arch-mips/syscalls/acct.S
syscall_src += arch-mips/syscalls/bind.S
@@ -54,7 +54,6 @@
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
syscall_src += arch-mips/syscalls/execve.S
syscall_src += arch-mips/syscalls/faccessat.S
@@ -126,11 +125,9 @@
syscall_src += arch-mips/syscalls/munlockall.S
syscall_src += arch-mips/syscalls/munmap.S
syscall_src += arch-mips/syscalls/nanosleep.S
-syscall_src += arch-mips/syscalls/pause.S
syscall_src += arch-mips/syscalls/perf_event_open.S
syscall_src += arch-mips/syscalls/personality.S
syscall_src += arch-mips/syscalls/pipe2.S
-syscall_src += arch-mips/syscalls/poll.S
syscall_src += arch-mips/syscalls/prctl.S
syscall_src += arch-mips/syscalls/pread64.S
syscall_src += arch-mips/syscalls/pwrite64.S
@@ -151,7 +148,6 @@
syscall_src += arch-mips/syscalls/sched_setparam.S
syscall_src += arch-mips/syscalls/sched_setscheduler.S
syscall_src += arch-mips/syscalls/sched_yield.S
-syscall_src += arch-mips/syscalls/select.S
syscall_src += arch-mips/syscalls/sendfile.S
syscall_src += arch-mips/syscalls/sendfile64.S
syscall_src += arch-mips/syscalls/sendmsg.S
diff --git a/libc/arch-mips/syscalls/__sys_clone.S b/libc/arch-mips/syscalls/__clone.S
similarity index 78%
rename from libc/arch-mips/syscalls/__sys_clone.S
rename to libc/arch-mips/syscalls/__clone.S
index e8b9149..5ad1489 100644
--- a/libc/arch-mips/syscalls/__sys_clone.S
+++ b/libc/arch-mips/syscalls/__clone.S
@@ -2,11 +2,11 @@
#include <asm/unistd.h>
.text
- .globl __sys_clone
+ .globl __clone
.align 4
- .ent __sys_clone
+ .ent __clone
-__sys_clone:
+__clone:
.set noreorder
.cpload $t9
li $v0, __NR_clone
@@ -20,4 +20,4 @@
j $t9
nop
.set reorder
- .end __sys_clone
+ .end __clone
diff --git a/libc/arch-mips/syscalls/__open.S b/libc/arch-mips/syscalls/__epoll_pwait.S
similarity index 69%
copy from libc/arch-mips/syscalls/__open.S
copy to libc/arch-mips/syscalls/__epoll_pwait.S
index abd0465..0a5fdae 100644
--- a/libc/arch-mips/syscalls/__open.S
+++ b/libc/arch-mips/syscalls/__epoll_pwait.S
@@ -2,14 +2,14 @@
#include <asm/unistd.h>
.text
- .globl __open
+ .globl __epoll_pwait
.align 4
- .ent __open
+ .ent __epoll_pwait
-__open:
+__epoll_pwait:
.set noreorder
.cpload $t9
- li $v0, __NR_open
+ li $v0, __NR_epoll_pwait
syscall
bnez $a3, 1f
move $a0, $v0
@@ -20,4 +20,4 @@
j $t9
nop
.set reorder
- .end __open
+ .end __epoll_pwait
diff --git a/libc/arch-mips/syscalls/__fork.S b/libc/arch-mips/syscalls/__fork.S
deleted file mode 100644
index a6f6e2e..0000000
--- a/libc/arch-mips/syscalls/__fork.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
- .text
- .globl __fork
- .align 4
- .ent __fork
-
-__fork:
- .set noreorder
- .cpload $t9
- li $v0, __NR_fork
- syscall
- bnez $a3, 1f
- move $a0, $v0
- j $ra
- nop
-1:
- la $t9,__set_errno
- j $t9
- nop
- .set reorder
- .end __fork
diff --git a/libc/arch-mips/syscalls/__open.S b/libc/arch-mips/syscalls/__ppoll.S
similarity index 75%
rename from libc/arch-mips/syscalls/__open.S
rename to libc/arch-mips/syscalls/__ppoll.S
index abd0465..ef6d343 100644
--- a/libc/arch-mips/syscalls/__open.S
+++ b/libc/arch-mips/syscalls/__ppoll.S
@@ -2,14 +2,14 @@
#include <asm/unistd.h>
.text
- .globl __open
+ .globl __ppoll
.align 4
- .ent __open
+ .ent __ppoll
-__open:
+__ppoll:
.set noreorder
.cpload $t9
- li $v0, __NR_open
+ li $v0, __NR_ppoll
syscall
bnez $a3, 1f
move $a0, $v0
@@ -20,4 +20,4 @@
j $t9
nop
.set reorder
- .end __open
+ .end __ppoll
diff --git a/libc/arch-mips/syscalls/__open.S b/libc/arch-mips/syscalls/__pselect6.S
similarity index 71%
copy from libc/arch-mips/syscalls/__open.S
copy to libc/arch-mips/syscalls/__pselect6.S
index abd0465..26af92a 100644
--- a/libc/arch-mips/syscalls/__open.S
+++ b/libc/arch-mips/syscalls/__pselect6.S
@@ -2,14 +2,14 @@
#include <asm/unistd.h>
.text
- .globl __open
+ .globl __pselect6
.align 4
- .ent __open
+ .ent __pselect6
-__open:
+__pselect6:
.set noreorder
.cpload $t9
- li $v0, __NR_open
+ li $v0, __NR_pselect6
syscall
bnez $a3, 1f
move $a0, $v0
@@ -20,4 +20,4 @@
j $t9
nop
.set reorder
- .end __open
+ .end __pselect6
diff --git a/libc/arch-mips/syscalls/_waitpid.S b/libc/arch-mips/syscalls/_waitpid.S
deleted file mode 100644
index 6f4327d..0000000
--- a/libc/arch-mips/syscalls/_waitpid.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
- .text
- .globl _waitpid
- .align 4
- .ent _waitpid
-
-_waitpid:
- .set noreorder
- .cpload $t9
- li $v0, __NR_waitpid
- syscall
- bnez $a3, 1f
- move $a0, $v0
- j $ra
- nop
-1:
- la $t9,__set_errno
- j $t9
- nop
- .set reorder
- .end _waitpid
diff --git a/libc/arch-mips/syscalls/epoll_wait.S b/libc/arch-mips/syscalls/epoll_wait.S
deleted file mode 100644
index bbe7419..0000000
--- a/libc/arch-mips/syscalls/epoll_wait.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
- .text
- .globl epoll_wait
- .align 4
- .ent epoll_wait
-
-epoll_wait:
- .set noreorder
- .cpload $t9
- li $v0, __NR_epoll_wait
- syscall
- bnez $a3, 1f
- move $a0, $v0
- j $ra
- nop
-1:
- la $t9,__set_errno
- j $t9
- nop
- .set reorder
- .end epoll_wait
diff --git a/libc/arch-mips/syscalls/pause.S b/libc/arch-mips/syscalls/pause.S
deleted file mode 100644
index 4f0a2a3..0000000
--- a/libc/arch-mips/syscalls/pause.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
- .text
- .globl pause
- .align 4
- .ent pause
-
-pause:
- .set noreorder
- .cpload $t9
- li $v0, __NR_pause
- syscall
- bnez $a3, 1f
- move $a0, $v0
- j $ra
- nop
-1:
- la $t9,__set_errno
- j $t9
- nop
- .set reorder
- .end pause
diff --git a/libc/arch-mips/syscalls/poll.S b/libc/arch-mips/syscalls/poll.S
deleted file mode 100644
index 6a1ebf8..0000000
--- a/libc/arch-mips/syscalls/poll.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
- .text
- .globl poll
- .align 4
- .ent poll
-
-poll:
- .set noreorder
- .cpload $t9
- li $v0, __NR_poll
- syscall
- bnez $a3, 1f
- move $a0, $v0
- j $ra
- nop
-1:
- la $t9,__set_errno
- j $t9
- nop
- .set reorder
- .end poll
diff --git a/libc/arch-mips/syscalls/select.S b/libc/arch-mips/syscalls/select.S
deleted file mode 100644
index d7cfea7..0000000
--- a/libc/arch-mips/syscalls/select.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
- .text
- .globl select
- .align 4
- .ent select
-
-select:
- .set noreorder
- .cpload $t9
- li $v0, __NR__newselect
- syscall
- bnez $a3, 1f
- move $a0, $v0
- j $ra
- nop
-1:
- la $t9,__set_errno
- j $t9
- nop
- .set reorder
- .end select
diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk
index 471dbb9..3b8586b 100644
--- a/libc/arch-x86/syscalls.mk
+++ b/libc/arch-x86/syscalls.mk
@@ -1,9 +1,10 @@
# Generated by gensyscalls.py. Do not edit.
syscall_src :=
syscall_src += arch-x86/syscalls/__brk.S
+syscall_src += arch-x86/syscalls/__clone.S
+syscall_src += arch-x86/syscalls/__epoll_pwait.S
syscall_src += arch-x86/syscalls/__fcntl.S
syscall_src += arch-x86/syscalls/__fcntl64.S
-syscall_src += arch-x86/syscalls/__fork.S
syscall_src += arch-x86/syscalls/__fstatfs64.S
syscall_src += arch-x86/syscalls/__getcpu.S
syscall_src += arch-x86/syscalls/__getcwd.S
@@ -11,8 +12,9 @@
syscall_src += arch-x86/syscalls/__ioctl.S
syscall_src += arch-x86/syscalls/__llseek.S
syscall_src += arch-x86/syscalls/__mmap2.S
-syscall_src += arch-x86/syscalls/__open.S
syscall_src += arch-x86/syscalls/__openat.S
+syscall_src += arch-x86/syscalls/__ppoll.S
+syscall_src += arch-x86/syscalls/__pselect6.S
syscall_src += arch-x86/syscalls/__ptrace.S
syscall_src += arch-x86/syscalls/__reboot.S
syscall_src += arch-x86/syscalls/__rt_sigaction.S
@@ -24,7 +26,6 @@
syscall_src += arch-x86/syscalls/__set_thread_area.S
syscall_src += arch-x86/syscalls/__sigaction.S
syscall_src += arch-x86/syscalls/__statfs64.S
-syscall_src += arch-x86/syscalls/__sys_clone.S
syscall_src += arch-x86/syscalls/__syslog.S
syscall_src += arch-x86/syscalls/__timer_create.S
syscall_src += arch-x86/syscalls/__timer_delete.S
@@ -34,7 +35,6 @@
syscall_src += arch-x86/syscalls/__waitid.S
syscall_src += arch-x86/syscalls/_exit.S
syscall_src += arch-x86/syscalls/_exit_thread.S
-syscall_src += arch-x86/syscalls/_waitpid.S
syscall_src += arch-x86/syscalls/accept.S
syscall_src += arch-x86/syscalls/acct.S
syscall_src += arch-x86/syscalls/bind.S
@@ -53,7 +53,6 @@
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
syscall_src += arch-x86/syscalls/execve.S
syscall_src += arch-x86/syscalls/faccessat.S
@@ -125,11 +124,9 @@
syscall_src += arch-x86/syscalls/munlockall.S
syscall_src += arch-x86/syscalls/munmap.S
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/pipe2.S
-syscall_src += arch-x86/syscalls/poll.S
syscall_src += arch-x86/syscalls/prctl.S
syscall_src += arch-x86/syscalls/pread64.S
syscall_src += arch-x86/syscalls/pwrite64.S
@@ -150,7 +147,6 @@
syscall_src += arch-x86/syscalls/sched_setparam.S
syscall_src += arch-x86/syscalls/sched_setscheduler.S
syscall_src += arch-x86/syscalls/sched_yield.S
-syscall_src += arch-x86/syscalls/select.S
syscall_src += arch-x86/syscalls/sendfile.S
syscall_src += arch-x86/syscalls/sendfile64.S
syscall_src += arch-x86/syscalls/sendmsg.S
diff --git a/libc/arch-x86/syscalls/__sys_clone.S b/libc/arch-x86/syscalls/__clone.S
similarity index 94%
rename from libc/arch-x86/syscalls/__sys_clone.S
rename to libc/arch-x86/syscalls/__clone.S
index 3080a87..c2e8ed8 100644
--- a/libc/arch-x86/syscalls/__sys_clone.S
+++ b/libc/arch-x86/syscalls/__clone.S
@@ -4,7 +4,7 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(__sys_clone)
+ENTRY(__clone)
pushl %ebx
pushl %ecx
pushl %edx
@@ -31,4 +31,4 @@
popl %ecx
popl %ebx
ret
-END(__sys_clone)
+END(__clone)
diff --git a/libc/arch-x86/syscalls/select.S b/libc/arch-x86/syscalls/__epoll_pwait.S
similarity index 63%
copy from libc/arch-x86/syscalls/select.S
copy to libc/arch-x86/syscalls/__epoll_pwait.S
index a67ffa5..9dc07f6 100644
--- a/libc/arch-x86/syscalls/select.S
+++ b/libc/arch-x86/syscalls/__epoll_pwait.S
@@ -4,18 +4,20 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(select)
+ENTRY(__epoll_pwait)
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
- mov 24(%esp), %ebx
- mov 28(%esp), %ecx
- mov 32(%esp), %edx
- mov 36(%esp), %esi
- mov 40(%esp), %edi
- movl $__NR__newselect, %eax
+ pushl %ebp
+ mov 28(%esp), %ebx
+ mov 32(%esp), %ecx
+ mov 36(%esp), %edx
+ mov 40(%esp), %esi
+ mov 44(%esp), %edi
+ mov 48(%esp), %ebp
+ movl $__NR_epoll_pwait, %eax
int $0x80
cmpl $-MAX_ERRNO, %eax
jb 1f
@@ -25,10 +27,11 @@
addl $4, %esp
orl $-1, %eax
1:
+ popl %ebp
popl %edi
popl %esi
popl %edx
popl %ecx
popl %ebx
ret
-END(select)
+END(__epoll_pwait)
diff --git a/libc/arch-x86/syscalls/__fork.S b/libc/arch-x86/syscalls/__fork.S
deleted file mode 100644
index af737c7..0000000
--- a/libc/arch-x86/syscalls/__fork.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(__fork)
- pushl %ebx
- mov 8(%esp), %ebx
- movl $__NR_fork, %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(__fork)
diff --git a/libc/arch-x86/syscalls/__open.S b/libc/arch-x86/syscalls/__open.S
deleted file mode 100644
index be286d2..0000000
--- a/libc/arch-x86/syscalls/__open.S
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(__open)
- pushl %ebx
- pushl %ecx
- pushl %edx
- mov 16(%esp), %ebx
- mov 20(%esp), %ecx
- mov 24(%esp), %edx
- movl $__NR_open, %eax
- int $0x80
- cmpl $-MAX_ERRNO, %eax
- jb 1f
- negl %eax
- pushl %eax
- call __set_errno
- addl $4, %esp
- orl $-1, %eax
-1:
- popl %edx
- popl %ecx
- popl %ebx
- ret
-END(__open)
diff --git a/libc/arch-x86/syscalls/select.S b/libc/arch-x86/syscalls/__ppoll.S
similarity index 90%
rename from libc/arch-x86/syscalls/select.S
rename to libc/arch-x86/syscalls/__ppoll.S
index a67ffa5..6445fb5 100644
--- a/libc/arch-x86/syscalls/select.S
+++ b/libc/arch-x86/syscalls/__ppoll.S
@@ -4,7 +4,7 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(select)
+ENTRY(__ppoll)
pushl %ebx
pushl %ecx
pushl %edx
@@ -15,7 +15,7 @@
mov 32(%esp), %edx
mov 36(%esp), %esi
mov 40(%esp), %edi
- movl $__NR__newselect, %eax
+ movl $__NR_ppoll, %eax
int $0x80
cmpl $-MAX_ERRNO, %eax
jb 1f
@@ -31,4 +31,4 @@
popl %ecx
popl %ebx
ret
-END(select)
+END(__ppoll)
diff --git a/libc/arch-x86/syscalls/select.S b/libc/arch-x86/syscalls/__pselect6.S
similarity index 63%
copy from libc/arch-x86/syscalls/select.S
copy to libc/arch-x86/syscalls/__pselect6.S
index a67ffa5..8faa2da 100644
--- a/libc/arch-x86/syscalls/select.S
+++ b/libc/arch-x86/syscalls/__pselect6.S
@@ -4,18 +4,20 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(select)
+ENTRY(__pselect6)
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
- mov 24(%esp), %ebx
- mov 28(%esp), %ecx
- mov 32(%esp), %edx
- mov 36(%esp), %esi
- mov 40(%esp), %edi
- movl $__NR__newselect, %eax
+ pushl %ebp
+ mov 28(%esp), %ebx
+ mov 32(%esp), %ecx
+ mov 36(%esp), %edx
+ mov 40(%esp), %esi
+ mov 44(%esp), %edi
+ mov 48(%esp), %ebp
+ movl $__NR_pselect6, %eax
int $0x80
cmpl $-MAX_ERRNO, %eax
jb 1f
@@ -25,10 +27,11 @@
addl $4, %esp
orl $-1, %eax
1:
+ popl %ebp
popl %edi
popl %esi
popl %edx
popl %ecx
popl %ebx
ret
-END(select)
+END(__pselect6)
diff --git a/libc/arch-x86/syscalls/_waitpid.S b/libc/arch-x86/syscalls/_waitpid.S
deleted file mode 100644
index b83b986..0000000
--- a/libc/arch-x86/syscalls/_waitpid.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(_waitpid)
- pushl %ebx
- pushl %ecx
- pushl %edx
- pushl %esi
- mov 20(%esp), %ebx
- mov 24(%esp), %ecx
- mov 28(%esp), %edx
- mov 32(%esp), %esi
- movl $__NR_waitpid, %eax
- int $0x80
- cmpl $-MAX_ERRNO, %eax
- jb 1f
- negl %eax
- pushl %eax
- call __set_errno
- addl $4, %esp
- orl $-1, %eax
-1:
- popl %esi
- popl %edx
- popl %ecx
- popl %ebx
- ret
-END(_waitpid)
diff --git a/libc/arch-x86/syscalls/epoll_wait.S b/libc/arch-x86/syscalls/epoll_wait.S
deleted file mode 100644
index e0c7a6d..0000000
--- a/libc/arch-x86/syscalls/epoll_wait.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(epoll_wait)
- pushl %ebx
- pushl %ecx
- pushl %edx
- pushl %esi
- mov 20(%esp), %ebx
- mov 24(%esp), %ecx
- mov 28(%esp), %edx
- mov 32(%esp), %esi
- movl $__NR_epoll_wait, %eax
- int $0x80
- cmpl $-MAX_ERRNO, %eax
- jb 1f
- negl %eax
- pushl %eax
- call __set_errno
- addl $4, %esp
- orl $-1, %eax
-1:
- popl %esi
- popl %edx
- popl %ecx
- popl %ebx
- ret
-END(epoll_wait)
diff --git a/libc/arch-x86/syscalls/pause.S b/libc/arch-x86/syscalls/pause.S
deleted file mode 100644
index 3ce05d5..0000000
--- a/libc/arch-x86/syscalls/pause.S
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(pause)
- movl $__NR_pause, %eax
- int $0x80
- cmpl $-MAX_ERRNO, %eax
- jb 1f
- negl %eax
- pushl %eax
- call __set_errno
- addl $4, %esp
- orl $-1, %eax
-1:
- ret
-END(pause)
diff --git a/libc/arch-x86/syscalls/poll.S b/libc/arch-x86/syscalls/poll.S
deleted file mode 100644
index 273062a..0000000
--- a/libc/arch-x86/syscalls/poll.S
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(poll)
- pushl %ebx
- pushl %ecx
- pushl %edx
- mov 16(%esp), %ebx
- mov 20(%esp), %ecx
- mov 24(%esp), %edx
- movl $__NR_poll, %eax
- int $0x80
- cmpl $-MAX_ERRNO, %eax
- jb 1f
- negl %eax
- pushl %eax
- call __set_errno
- addl $4, %esp
- orl $-1, %eax
-1:
- popl %edx
- popl %ecx
- popl %ebx
- ret
-END(poll)
diff --git a/libc/arch-x86_64/syscalls.mk b/libc/arch-x86_64/syscalls.mk
index 44ef729..1ec3e09 100644
--- a/libc/arch-x86_64/syscalls.mk
+++ b/libc/arch-x86_64/syscalls.mk
@@ -2,12 +2,15 @@
syscall_src :=
syscall_src += arch-x86_64/syscalls/__arch_prctl.S
syscall_src += arch-x86_64/syscalls/__brk.S
-syscall_src += arch-x86_64/syscalls/__fork.S
+syscall_src += arch-x86_64/syscalls/__clone.S
+syscall_src += arch-x86_64/syscalls/__epoll_pwait.S
syscall_src += arch-x86_64/syscalls/__getcpu.S
syscall_src += arch-x86_64/syscalls/__getcwd.S
syscall_src += arch-x86_64/syscalls/__getpriority.S
syscall_src += arch-x86_64/syscalls/__ioctl.S
syscall_src += arch-x86_64/syscalls/__openat.S
+syscall_src += arch-x86_64/syscalls/__ppoll.S
+syscall_src += arch-x86_64/syscalls/__pselect6.S
syscall_src += arch-x86_64/syscalls/__ptrace.S
syscall_src += arch-x86_64/syscalls/__reboot.S
syscall_src += arch-x86_64/syscalls/__rt_sigaction.S
@@ -16,7 +19,6 @@
syscall_src += arch-x86_64/syscalls/__rt_sigsuspend.S
syscall_src += arch-x86_64/syscalls/__rt_sigtimedwait.S
syscall_src += arch-x86_64/syscalls/__sched_getaffinity.S
-syscall_src += arch-x86_64/syscalls/__sys_clone.S
syscall_src += arch-x86_64/syscalls/__syslog.S
syscall_src += arch-x86_64/syscalls/__timer_create.S
syscall_src += arch-x86_64/syscalls/__timer_delete.S
@@ -44,7 +46,6 @@
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
syscall_src += arch-x86_64/syscalls/execve.S
syscall_src += arch-x86_64/syscalls/faccessat.S
@@ -118,11 +119,9 @@
syscall_src += arch-x86_64/syscalls/munlockall.S
syscall_src += arch-x86_64/syscalls/munmap.S
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/pipe2.S
-syscall_src += arch-x86_64/syscalls/poll.S
syscall_src += arch-x86_64/syscalls/prctl.S
syscall_src += arch-x86_64/syscalls/pread64.S
syscall_src += arch-x86_64/syscalls/pwrite64.S
@@ -143,7 +142,6 @@
syscall_src += arch-x86_64/syscalls/sched_setparam.S
syscall_src += arch-x86_64/syscalls/sched_setscheduler.S
syscall_src += arch-x86_64/syscalls/sched_yield.S
-syscall_src += arch-x86_64/syscalls/select.S
syscall_src += arch-x86_64/syscalls/sendfile.S
syscall_src += arch-x86_64/syscalls/sendmsg.S
syscall_src += arch-x86_64/syscalls/sendto.S
diff --git a/libc/arch-x86_64/syscalls/__sys_clone.S b/libc/arch-x86_64/syscalls/__clone.S
similarity index 90%
rename from libc/arch-x86_64/syscalls/__sys_clone.S
rename to libc/arch-x86_64/syscalls/__clone.S
index 314440b..c10402a 100644
--- a/libc/arch-x86_64/syscalls/__sys_clone.S
+++ b/libc/arch-x86_64/syscalls/__clone.S
@@ -4,7 +4,7 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(__sys_clone)
+ENTRY(__clone)
movq %rcx, %r10
movl $__NR_clone, %eax
syscall
@@ -16,4 +16,4 @@
orq $-1, %rax
1:
ret
-END(__sys_clone)
+END(__clone)
diff --git a/libc/arch-x86_64/syscalls/select.S b/libc/arch-x86_64/syscalls/__epoll_pwait.S
similarity index 79%
copy from libc/arch-x86_64/syscalls/select.S
copy to libc/arch-x86_64/syscalls/__epoll_pwait.S
index 1cea5c6..98f3465 100644
--- a/libc/arch-x86_64/syscalls/select.S
+++ b/libc/arch-x86_64/syscalls/__epoll_pwait.S
@@ -4,9 +4,9 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(select)
+ENTRY(__epoll_pwait)
movq %rcx, %r10
- movl $__NR_select, %eax
+ movl $__NR_epoll_pwait, %eax
syscall
cmpq $-MAX_ERRNO, %rax
jb 1f
@@ -16,4 +16,4 @@
orq $-1, %rax
1:
ret
-END(select)
+END(__epoll_pwait)
diff --git a/libc/arch-x86_64/syscalls/__fork.S b/libc/arch-x86_64/syscalls/__fork.S
deleted file mode 100644
index dcadec3..0000000
--- a/libc/arch-x86_64/syscalls/__fork.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(__fork)
- movl $__NR_fork, %eax
- syscall
- cmpq $-MAX_ERRNO, %rax
- jb 1f
- negl %eax
- movl %eax, %edi
- call __set_errno
- orq $-1, %rax
-1:
- ret
-END(__fork)
diff --git a/libc/arch-x86_64/syscalls/select.S b/libc/arch-x86_64/syscalls/__ppoll.S
similarity index 83%
rename from libc/arch-x86_64/syscalls/select.S
rename to libc/arch-x86_64/syscalls/__ppoll.S
index 1cea5c6..c6c055b 100644
--- a/libc/arch-x86_64/syscalls/select.S
+++ b/libc/arch-x86_64/syscalls/__ppoll.S
@@ -4,9 +4,9 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(select)
+ENTRY(__ppoll)
movq %rcx, %r10
- movl $__NR_select, %eax
+ movl $__NR_ppoll, %eax
syscall
cmpq $-MAX_ERRNO, %rax
jb 1f
@@ -16,4 +16,4 @@
orq $-1, %rax
1:
ret
-END(select)
+END(__ppoll)
diff --git a/libc/arch-x86_64/syscalls/select.S b/libc/arch-x86_64/syscalls/__pselect6.S
similarity index 81%
copy from libc/arch-x86_64/syscalls/select.S
copy to libc/arch-x86_64/syscalls/__pselect6.S
index 1cea5c6..b0bb8ba 100644
--- a/libc/arch-x86_64/syscalls/select.S
+++ b/libc/arch-x86_64/syscalls/__pselect6.S
@@ -4,9 +4,9 @@
#include <linux/err.h>
#include <machine/asm.h>
-ENTRY(select)
+ENTRY(__pselect6)
movq %rcx, %r10
- movl $__NR_select, %eax
+ movl $__NR_pselect6, %eax
syscall
cmpq $-MAX_ERRNO, %rax
jb 1f
@@ -16,4 +16,4 @@
orq $-1, %rax
1:
ret
-END(select)
+END(__pselect6)
diff --git a/libc/arch-x86_64/syscalls/epoll_wait.S b/libc/arch-x86_64/syscalls/epoll_wait.S
deleted file mode 100644
index d3e6a6f..0000000
--- a/libc/arch-x86_64/syscalls/epoll_wait.S
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(epoll_wait)
- movq %rcx, %r10
- movl $__NR_epoll_wait, %eax
- syscall
- cmpq $-MAX_ERRNO, %rax
- jb 1f
- negl %eax
- movl %eax, %edi
- call __set_errno
- orq $-1, %rax
-1:
- ret
-END(epoll_wait)
diff --git a/libc/arch-x86_64/syscalls/pause.S b/libc/arch-x86_64/syscalls/pause.S
deleted file mode 100644
index 9f03327..0000000
--- a/libc/arch-x86_64/syscalls/pause.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(pause)
- movl $__NR_pause, %eax
- syscall
- cmpq $-MAX_ERRNO, %rax
- jb 1f
- negl %eax
- movl %eax, %edi
- call __set_errno
- orq $-1, %rax
-1:
- ret
-END(pause)
diff --git a/libc/arch-x86_64/syscalls/poll.S b/libc/arch-x86_64/syscalls/poll.S
deleted file mode 100644
index 48130c3..0000000
--- a/libc/arch-x86_64/syscalls/poll.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(poll)
- movl $__NR_poll, %eax
- syscall
- cmpq $-MAX_ERRNO, %rax
- jb 1f
- negl %eax
- movl %eax, %edi
- call __set_errno
- orq $-1, %rax
-1:
- ret
-END(poll)
diff --git a/libc/bionic/pselect.c b/libc/bionic/bionic_time_conversions.cpp
similarity index 60%
copy from libc/bionic/pselect.c
copy to libc/bionic/bionic_time_conversions.cpp
index 76ce2c0..7f3c026 100644
--- a/libc/bionic/pselect.c
+++ b/libc/bionic/bionic_time_conversions.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,27 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <sys/select.h>
-#include <signal.h>
-#include <pthread.h>
-int
-pselect(int n, fd_set* readfds, fd_set* writefds, fd_set* errfds,
- const struct timespec* timeout, const sigset_t* sigmask)
-{
- sigset_t oldmask;
- int result;
- struct timeval tv, *tv_timeout = NULL;
+#include "private/bionic_time_conversions.h"
- if (sigmask != NULL)
- pthread_sigmask( SIG_SETMASK, sigmask, &oldmask );
+bool timespec_from_timeval(timespec& ts, const timeval& tv) {
+ // Whole seconds can just be copied.
+ ts.tv_sec = tv.tv_sec;
- if (timeout != NULL) {
- tv_timeout = &tv;
- tv.tv_sec = timeout->tv_sec;
- tv.tv_usec = (timeout->tv_nsec + 999)/1000; // round up
- if (tv.tv_usec >= 1000000) {
- tv.tv_sec += 1;
- tv.tv_usec -= 1000000;
- }
- }
+ // But we might overflow when converting microseconds to nanoseconds.
+ if (tv.tv_usec >= 1000000 || tv.tv_usec < 0) {
+ return false;
+ }
+ ts.tv_nsec = tv.tv_usec * 1000;
+ return true;
+}
- result = select( n, readfds, writefds, errfds, tv_timeout );
+void timespec_from_ms(timespec& ts, const int ms) {
+ ts.tv_sec = ms / 1000;
+ ts.tv_nsec = (ms % 1000) * 1000000;
+}
- if (sigmask != NULL)
- pthread_sigmask( SIG_SETMASK, &oldmask, NULL );
-
- return result;
+void timeval_from_timespec(timeval& tv, const timespec& ts) {
+ tv.tv_sec = ts.tv_sec;
+ tv.tv_usec = ts.tv_nsec / 1000;
}
diff --git a/libc/bionic/pselect.c b/libc/bionic/epoll_pwait.cpp
similarity index 60%
rename from libc/bionic/pselect.c
rename to libc/bionic/epoll_pwait.cpp
index 76ce2c0..f3af93e 100644
--- a/libc/bionic/pselect.c
+++ b/libc/bionic/epoll_pwait.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,19 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <sys/select.h>
-#include <signal.h>
-#include <pthread.h>
-int
-pselect(int n, fd_set* readfds, fd_set* writefds, fd_set* errfds,
- const struct timespec* timeout, const sigset_t* sigmask)
-{
- sigset_t oldmask;
- int result;
- struct timeval tv, *tv_timeout = NULL;
+#include <sys/epoll.h>
- if (sigmask != NULL)
- pthread_sigmask( SIG_SETMASK, sigmask, &oldmask );
+#include "private/kernel_sigset_t.h"
- if (timeout != NULL) {
- tv_timeout = &tv;
- tv.tv_sec = timeout->tv_sec;
- tv.tv_usec = (timeout->tv_nsec + 999)/1000; // round up
- if (tv.tv_usec >= 1000000) {
- tv.tv_sec += 1;
- tv.tv_usec -= 1000000;
- }
- }
+extern "C" int __epoll_pwait(int, epoll_event*, int, int, const kernel_sigset_t*, size_t);
- result = select( n, readfds, writefds, errfds, tv_timeout );
-
- if (sigmask != NULL)
- pthread_sigmask( SIG_SETMASK, &oldmask, NULL );
-
- return result;
+int epoll_pwait(int fd, epoll_event* events, int max_events, int timeout, const sigset_t* ss) {
+ kernel_sigset_t kernel_ss;
+ kernel_sigset_t* kernel_ss_ptr = NULL;
+ if (ss != NULL) {
+ kernel_ss.set(ss);
+ kernel_ss_ptr = &kernel_ss;
+ }
+ return __epoll_pwait(fd, events, max_events, timeout, kernel_ss_ptr, sizeof(kernel_ss));
}
diff --git a/libc/bionic/pselect.c b/libc/bionic/epoll_wait.cpp
similarity index 60%
copy from libc/bionic/pselect.c
copy to libc/bionic/epoll_wait.cpp
index 76ce2c0..deb19da 100644
--- a/libc/bionic/pselect.c
+++ b/libc/bionic/epoll_wait.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,9 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <sys/select.h>
-#include <signal.h>
-#include <pthread.h>
-int
-pselect(int n, fd_set* readfds, fd_set* writefds, fd_set* errfds,
- const struct timespec* timeout, const sigset_t* sigmask)
-{
- sigset_t oldmask;
- int result;
- struct timeval tv, *tv_timeout = NULL;
+#include <sys/epoll.h>
- if (sigmask != NULL)
- pthread_sigmask( SIG_SETMASK, sigmask, &oldmask );
-
- if (timeout != NULL) {
- tv_timeout = &tv;
- tv.tv_sec = timeout->tv_sec;
- tv.tv_usec = (timeout->tv_nsec + 999)/1000; // round up
- if (tv.tv_usec >= 1000000) {
- tv.tv_sec += 1;
- tv.tv_usec -= 1000000;
- }
- }
-
- result = select( n, readfds, writefds, errfds, tv_timeout );
-
- if (sigmask != NULL)
- pthread_sigmask( SIG_SETMASK, &oldmask, NULL );
-
- return result;
+int epoll_wait(int fd, struct epoll_event* events, int max_events, int timeout) {
+ return epoll_pwait(fd, events, max_events, timeout, NULL);
}
diff --git a/libc/bionic/fork.cpp b/libc/bionic/fork.cpp
index a3bea20..339a0e8 100644
--- a/libc/bionic/fork.cpp
+++ b/libc/bionic/fork.cpp
@@ -31,7 +31,7 @@
#include "private/bionic_pthread.h"
-extern "C" int __fork();
+extern "C" int __clone(int, void*, int*, void*, int*);
int fork() {
// POSIX mandates that the timers of a fork child process be
@@ -41,7 +41,7 @@
__timer_table_start_stop(1);
__bionic_atfork_run_prepare();
- int result = __fork();
+ int result = __clone(SIGCHLD, NULL, NULL, NULL, NULL);
if (result != 0) { // Not a child process.
__timer_table_start_stop(0);
__bionic_atfork_run_parent();
diff --git a/libc/bionic/pselect.c b/libc/bionic/pause.cpp
similarity index 60%
copy from libc/bionic/pselect.c
copy to libc/bionic/pause.cpp
index 76ce2c0..94a16fb 100644
--- a/libc/bionic/pselect.c
+++ b/libc/bionic/pause.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,35 +25,18 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <sys/select.h>
-#include <signal.h>
-#include <pthread.h>
-int
-pselect(int n, fd_set* readfds, fd_set* writefds, fd_set* errfds,
- const struct timespec* timeout, const sigset_t* sigmask)
-{
- sigset_t oldmask;
- int result;
- struct timeval tv, *tv_timeout = NULL;
+#include <unistd.h>
- if (sigmask != NULL)
- pthread_sigmask( SIG_SETMASK, sigmask, &oldmask );
+#include "private/kernel_sigset_t.h"
- if (timeout != NULL) {
- tv_timeout = &tv;
- tv.tv_sec = timeout->tv_sec;
- tv.tv_usec = (timeout->tv_nsec + 999)/1000; // round up
- if (tv.tv_usec >= 1000000) {
- tv.tv_sec += 1;
- tv.tv_usec -= 1000000;
- }
- }
+extern "C" int __rt_sigprocmask(int, const kernel_sigset_t*, kernel_sigset_t*, size_t);
+extern "C" int __rt_sigsuspend(const kernel_sigset_t*, size_t);
- result = select( n, readfds, writefds, errfds, tv_timeout );
-
- if (sigmask != NULL)
- pthread_sigmask( SIG_SETMASK, &oldmask, NULL );
-
- return result;
+int pause() {
+ kernel_sigset_t mask;
+ if (__rt_sigprocmask(SIG_SETMASK, NULL, &mask, sizeof(mask)) == -1) {
+ return -1;
+ }
+ return __rt_sigsuspend(&mask, sizeof(mask));
}
diff --git a/libc/bionic/poll.cpp b/libc/bionic/poll.cpp
new file mode 100644
index 0000000..ebb318d
--- /dev/null
+++ b/libc/bionic/poll.cpp
@@ -0,0 +1,110 @@
+/*
+ * 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/poll.h>
+#include <sys/select.h>
+
+#include "private/bionic_time_conversions.h"
+#include "private/kernel_sigset_t.h"
+
+extern "C" int __ppoll(pollfd*, unsigned int, timespec*, const kernel_sigset_t*, size_t);
+extern "C" int __pselect6(int, fd_set*, fd_set*, fd_set*, timespec*, void*);
+
+int poll(pollfd* fds, nfds_t fd_count, int ms) {
+ timespec ts;
+ timespec* ts_ptr = NULL;
+ if (ms >= 0) {
+ timespec_from_ms(ts, ms);
+ ts_ptr = &ts;
+ }
+ return __ppoll(fds, fd_count, ts_ptr, NULL, 0);
+}
+
+int ppoll(pollfd* fds, nfds_t fd_count, const timespec* ts, const sigset_t* ss) {
+ timespec mutable_ts;
+ timespec* mutable_ts_ptr = NULL;
+ if (ts != NULL) {
+ mutable_ts = *ts;
+ mutable_ts_ptr = &mutable_ts;
+ }
+
+ kernel_sigset_t kernel_ss;
+ kernel_sigset_t* kernel_ss_ptr = NULL;
+ if (ss != NULL) {
+ kernel_ss.set(ss);
+ kernel_ss_ptr = &kernel_ss;
+ }
+
+ return __ppoll(fds, fd_count, mutable_ts_ptr, kernel_ss_ptr, sizeof(kernel_ss));
+}
+
+int select(int fd_count, fd_set* read_fds, fd_set* write_fds, fd_set* error_fds, timeval* tv) {
+ timespec ts;
+ timespec* ts_ptr = NULL;
+ if (tv != NULL) {
+ if (!timespec_from_timeval(ts, *tv)) {
+ errno = EINVAL;
+ return -1;
+ }
+ ts_ptr = &ts;
+ }
+ int result = __pselect6(fd_count, read_fds, write_fds, error_fds, ts_ptr, NULL);
+ if (tv != NULL) {
+ timeval_from_timespec(*tv, ts);
+ }
+ return result;
+}
+
+int pselect(int fd_count, fd_set* read_fds, fd_set* write_fds, fd_set* error_fds,
+ const timespec* ts, const sigset_t* ss) {
+ timespec mutable_ts;
+ timespec* mutable_ts_ptr = NULL;
+ if (ts != NULL) {
+ mutable_ts = *ts;
+ mutable_ts_ptr = &mutable_ts;
+ }
+
+ kernel_sigset_t kernel_ss;
+ kernel_sigset_t* kernel_ss_ptr = NULL;
+ if (ss != NULL) {
+ kernel_ss.set(ss);
+ kernel_ss_ptr = &kernel_ss;
+ }
+
+ // The Linux kernel only handles 6 arguments and this system call really needs 7,
+ // so the last argument is a void* pointing to:
+ struct pselect6_extra_data_t {
+ uintptr_t ss_addr;
+ size_t ss_len;
+ };
+ pselect6_extra_data_t extra_data;
+ extra_data.ss_addr = reinterpret_cast<uintptr_t>(kernel_ss_ptr);
+ extra_data.ss_len = sizeof(kernel_ss);
+
+ return __pselect6(fd_count, read_fds, write_fds, error_fds, mutable_ts_ptr, &extra_data);
+}
diff --git a/libc/bionic/pthread.c b/libc/bionic/pthread.c
index 7081445..4a4676a 100644
--- a/libc/bionic/pthread.c
+++ b/libc/bionic/pthread.c
@@ -1176,13 +1176,10 @@
int pthread_cond_timeout_np(pthread_cond_t *cond,
pthread_mutex_t * mutex,
- unsigned msecs)
+ unsigned ms)
{
struct timespec ts;
-
- ts.tv_sec = msecs / 1000;
- ts.tv_nsec = (msecs % 1000) * 1000000;
-
+ timespec_from_ms(ts, ms);
return __pthread_cond_timedwait_relative(cond, mutex, &ts);
}
diff --git a/libc/bionic/utimes.cpp b/libc/bionic/utimes.cpp
index 315765a..8950972 100644
--- a/libc/bionic/utimes.cpp
+++ b/libc/bionic/utimes.cpp
@@ -30,21 +30,13 @@
#include <sys/stat.h>
#include <sys/time.h>
+#include "private/bionic_time_conversions.h"
+
int utimes(const char* path, const timeval tv[2]) {
timespec ts[2];
-
- // Whole seconds can just be copied.
- ts[0].tv_sec = tv[0].tv_sec;
- ts[1].tv_sec = tv[1].tv_sec;
-
- // But we might overflow when converting microseconds to nanoseconds.
- if (tv[0].tv_usec >= 1000000 || tv[0].tv_usec < 0 ||
- tv[1].tv_usec >= 1000000 || tv[1].tv_usec < 0) {
+ if (!timespec_from_timeval(ts[0], tv[0]) || !timespec_from_timeval(ts[1], tv[1])) {
errno = EINVAL;
return -1;
}
- ts[0].tv_nsec = tv[0].tv_usec * 1000;
- ts[1].tv_nsec = tv[1].tv_usec * 1000;
-
return utimensat(AT_FDCWD, path, ts, 0);
}
diff --git a/libc/bionic/wait.cpp b/libc/bionic/wait.cpp
index 7dbcec2..27453bb 100644
--- a/libc/bionic/wait.cpp
+++ b/libc/bionic/wait.cpp
@@ -44,7 +44,7 @@
}
int waitid(idtype_t which, id_t id, siginfo_t* info, int options) {
- /* the system call takes an option struct rusage that we don't need */
+ // The system call takes an optional struct rusage that we don't need.
return __waitid(which, id, info, options, NULL);
}
diff --git a/libc/include/poll.h b/libc/include/poll.h
index 560be89..0199cab 100644
--- a/libc/include/poll.h
+++ b/libc/include/poll.h
@@ -25,18 +25,21 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
#ifndef _POLL_H_
#define _POLL_H_
#include <sys/cdefs.h>
#include <linux/poll.h>
+#include <signal.h> /* For sigset_t. */
+#include <time.h> /* For timespec. */
__BEGIN_DECLS
-typedef unsigned int nfds_t;
+typedef unsigned int nfds_t;
-/* POSIX specifies "int" for the timeout, Linux seems to use long... */
-extern int poll(struct pollfd *, nfds_t, long);
+extern int poll(struct pollfd*, nfds_t, int);
+extern int ppoll(struct pollfd*, nfds_t, const struct timespec*, const sigset_t*);
__END_DECLS
diff --git a/libc/include/sys/epoll.h b/libc/include/sys/epoll.h
index 1e207d8..c06a081 100644
--- a/libc/include/sys/epoll.h
+++ b/libc/include/sys/epoll.h
@@ -31,7 +31,8 @@
#include <sys/cdefs.h>
#include <sys/types.h>
-#include <asm/fcntl.h> /* For O_CLOEXEC. */
+#include <fcntl.h> /* For O_CLOEXEC. */
+#include <signal.h> /* For sigset_t. */
__BEGIN_DECLS
@@ -56,24 +57,23 @@
#define EPOLL_CLOEXEC O_CLOEXEC
-typedef union epoll_data
-{
- void *ptr;
- int fd;
- unsigned int u32;
- unsigned long long u64;
+typedef union epoll_data {
+ void* ptr;
+ int fd;
+ uint32_t u32;
+ uint64_t u64;
} epoll_data_t;
-struct epoll_event
-{
- unsigned int events;
- epoll_data_t data;
+struct epoll_event {
+ uint32_t 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);
+int epoll_create(int);
+int epoll_create1(int);
+int epoll_ctl(int, int, int, struct epoll_event*);
+int epoll_wait(int, struct epoll_event*, int, int);
+int epoll_pwait(int, struct epoll_event*, int, int, const sigset_t*);
__END_DECLS
diff --git a/libc/private/bionic_time_conversions.h b/libc/private/bionic_time_conversions.h
new file mode 100644
index 0000000..51f543f
--- /dev/null
+++ b/libc/private/bionic_time_conversions.h
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+#ifndef _BIONIC_TIME_CONVERSIONS_H
+#define _BIONIC_TIME_CONVERSIONS_H
+
+#include <time.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+__LIBC_HIDDEN__ bool timespec_from_timeval(timespec& ts, const timeval& tv);
+__LIBC_HIDDEN__ void timespec_from_ms(timespec& ts, const int ms);
+
+__LIBC_HIDDEN__ void timeval_from_timespec(timeval& tv, const timespec& ts);
+
+__END_DECLS
+
+#endif
diff --git a/libc/private/kernel_sigset_t.h b/libc/private/kernel_sigset_t.h
index 733a842..b2d6386 100644
--- a/libc/private/kernel_sigset_t.h
+++ b/libc/private/kernel_sigset_t.h
@@ -32,7 +32,7 @@
}
void clear() {
- memset(this, 0, sizeof(*this));
+ __builtin_memset(this, 0, sizeof(*this));
}
void set(const sigset_t* value) {
diff --git a/tests/Android.mk b/tests/Android.mk
index 5bcf996..f117480 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -81,6 +81,7 @@
string_test.cpp \
strings_test.cpp \
stubs_test.cpp \
+ sys_epoll_test.cpp \
sys_select_test.cpp \
sys_sendfile_test.cpp \
sys_stat_test.cpp \
diff --git a/tests/signal_test.cpp b/tests/signal_test.cpp
index 3070747..7705e2c 100644
--- a/tests/signal_test.cpp
+++ b/tests/signal_test.cpp
@@ -170,8 +170,6 @@
}
TEST(signal, sigsuspend_sigpending) {
- ScopedSignalHandler ssh(SIGALRM, SigSuspendTestHelper);
-
// Block SIGALRM.
sigset_t just_SIGALRM;
sigemptyset(&just_SIGALRM);
@@ -179,6 +177,8 @@
sigset_t original_set;
ASSERT_EQ(0, sigprocmask(SIG_BLOCK, &just_SIGALRM, &original_set));
+ ScopedSignalHandler ssh(SIGALRM, SigSuspendTestHelper);
+
// There should be no pending signals.
sigset_t pending;
sigemptyset(&pending);
@@ -208,7 +208,7 @@
ASSERT_EQ(1, gSigSuspendTestHelperCallCount);
// Restore the original set.
- assert(0 == sigprocmask(SIG_SETMASK, &original_set, NULL));
+ ASSERT_EQ(0, sigprocmask(SIG_SETMASK, &original_set, NULL));
}
static void EmptySignalHandler(int) {}
@@ -216,14 +216,15 @@
TEST(signal, sigaction) {
// See what's currently set for SIGALRM.
- struct sigaction sa;
- memset(&sa, 0, sizeof(sa));
- ASSERT_EQ(0, sigaction(SIGALRM, NULL, &sa));
- ASSERT_TRUE(sa.sa_handler == NULL);
- ASSERT_TRUE(sa.sa_sigaction == NULL);
- ASSERT_TRUE(sa.sa_flags == 0);
+ struct sigaction original_sa;
+ memset(&original_sa, 0, sizeof(original_sa));
+ ASSERT_EQ(0, sigaction(SIGALRM, NULL, &original_sa));
+ ASSERT_TRUE(original_sa.sa_handler == NULL);
+ ASSERT_TRUE(original_sa.sa_sigaction == NULL);
+ ASSERT_TRUE(original_sa.sa_flags == 0);
// Set a traditional sa_handler signal handler.
+ struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sigaddset(&sa.sa_mask, SIGALRM);
sa.sa_flags = SA_ONSTACK;
@@ -250,4 +251,7 @@
ASSERT_TRUE(sa.sa_sigaction == EmptySignalAction);
ASSERT_TRUE((void*) sa.sa_sigaction == (void*) sa.sa_handler);
ASSERT_TRUE(sa.sa_flags == (SA_ONSTACK | SA_SIGINFO));
+
+ // Put everything back how it was.
+ ASSERT_EQ(0, sigaction(SIGALRM, &original_sa, NULL));
}
diff --git a/tests/sys_epoll_test.cpp b/tests/sys_epoll_test.cpp
new file mode 100644
index 0000000..e4e047b
--- /dev/null
+++ b/tests/sys_epoll_test.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2013 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 <gtest/gtest.h>
+
+#include <errno.h>
+#include <sys/epoll.h>
+
+TEST(sys_epoll, smoke) {
+ int epoll_fd = epoll_create(1);
+ ASSERT_NE(-1, epoll_fd) << strerror(errno);
+ epoll_event events[1];
+
+ // Regular epoll_wait.
+ ASSERT_EQ(0, epoll_wait(epoll_fd, events, 1, 1));
+
+ // epoll_pwait without a sigset (which is equivalent to epoll_wait).
+ ASSERT_EQ(0, epoll_pwait(epoll_fd, events, 1, 1, NULL));
+
+ // epoll_pwait with a sigset.
+ sigset_t ss;
+ sigemptyset(&ss);
+ sigaddset(&ss, SIGPIPE);
+ ASSERT_EQ(0, epoll_pwait(epoll_fd, events, 1, 1, &ss));
+}
diff --git a/tests/sys_select_test.cpp b/tests/sys_select_test.cpp
index 36f01b3..57afc9b 100644
--- a/tests/sys_select_test.cpp
+++ b/tests/sys_select_test.cpp
@@ -41,3 +41,73 @@
EXPECT_FALSE(FD_ISSET(0, &fds));
EXPECT_FALSE(FD_ISSET(1, &fds));
}
+
+TEST(sys_select, select_smoke) {
+ fd_set r;
+ FD_ZERO(&r);
+ fd_set w;
+ FD_ZERO(&w);
+ fd_set e;
+ FD_ZERO(&e);
+
+ FD_SET(STDIN_FILENO, &r);
+ FD_SET(STDOUT_FILENO, &w);
+ FD_SET(STDERR_FILENO, &w);
+
+ int max = STDERR_FILENO + 1;
+
+ // Invalid max fd.
+ ASSERT_EQ(-1, select(-1, &r, &w, &e, NULL));
+ ASSERT_EQ(EINVAL, errno);
+
+ ASSERT_EQ(2, select(max, &r, &w, &e, NULL));
+
+ // Invalid timeout.
+ timeval tv;
+ tv.tv_sec = -1;
+ tv.tv_usec = 0;
+ ASSERT_EQ(-1, select(max, &r, &w, &e, &tv));
+ ASSERT_EQ(EINVAL, errno);
+
+ // Valid timeout...
+ tv.tv_sec = 1;
+ ASSERT_EQ(2, select(max, &r, &w, &e, &tv));
+ ASSERT_NE(0, tv.tv_usec); // ...which got updated.
+}
+
+TEST(sys_select, pselect_smoke) {
+ sigset_t ss;
+ sigemptyset(&ss);
+ sigaddset(&ss, SIGPIPE);
+
+ fd_set r;
+ FD_ZERO(&r);
+ fd_set w;
+ FD_ZERO(&w);
+ fd_set e;
+ FD_ZERO(&e);
+
+ FD_SET(STDIN_FILENO, &r);
+ FD_SET(STDOUT_FILENO, &w);
+ FD_SET(STDERR_FILENO, &w);
+
+ int max = STDERR_FILENO + 1;
+
+ // Invalid max fd.
+ ASSERT_EQ(-1, pselect(-1, &r, &w, &e, NULL, &ss));
+ ASSERT_EQ(EINVAL, errno);
+
+ ASSERT_EQ(2, pselect(max, &r, &w, &e, NULL, &ss));
+
+ // Invalid timeout.
+ timespec tv;
+ tv.tv_sec = -1;
+ tv.tv_nsec = 0;
+ ASSERT_EQ(-1, pselect(max, &r, &w, &e, &tv, &ss));
+ ASSERT_EQ(EINVAL, errno);
+
+ // Valid timeout...
+ tv.tv_sec = 1;
+ ASSERT_EQ(2, pselect(max, &r, &w, &e, &tv, &ss));
+ ASSERT_EQ(0, tv.tv_nsec); // ...which did _not_ get updated.
+}
diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp
index 3193083..7d0af7c 100644
--- a/tests/unistd_test.cpp
+++ b/tests/unistd_test.cpp
@@ -73,3 +73,16 @@
ASSERT_EQ(0, stat(tf.filename, &sb));
ASSERT_EQ(123, sb.st_size);
}
+
+static bool gPauseTestFlag = false;
+static void PauseTestSignalHandler(int) {
+ gPauseTestFlag = true;
+}
+
+TEST(unistd, pause) {
+ signal(SIGALRM, PauseTestSignalHandler);
+ alarm(1);
+ ASSERT_FALSE(gPauseTestFlag);
+ ASSERT_EQ(-1, pause());
+ ASSERT_TRUE(gPauseTestFlag);
+}