From 9973a564222b842eb7497fd6e659fe8c8c49e2b3 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Mon, 27 Sep 2010 17:30:33 +0200 Subject: [PATCH] libc: Add missing waitid() implementation. Change-Id: I312ee608dbf9249e4886a10d45d13e3cda8a9042 --- libc/SYSCALLS.TXT | 2 +- libc/arch-arm/syscalls.mk | 2 +- libc/arch-arm/syscalls/{waitid.S => __waitid.S} | 6 +++--- libc/arch-sh/syscalls.mk | 2 +- libc/arch-sh/syscalls/{waitid.S => __waitid.S} | 6 +++--- libc/arch-x86/syscalls.mk | 2 +- libc/arch-x86/syscalls/{waitid.S => __waitid.S} | 6 +++--- libc/include/sys/linux-unistd.h | 2 +- libc/include/sys/wait.h | 9 +++++++++ libc/unistd/wait.c | 7 +++++++ 10 files changed, 30 insertions(+), 14 deletions(-) rename libc/arch-arm/syscalls/{waitid.S => __waitid.S} (86%) rename libc/arch-sh/syscalls/{waitid.S => __waitid.S} (90%) rename libc/arch-x86/syscalls/{waitid.S => __waitid.S} (90%) diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT index baac5d02f..935639e07 100644 --- a/libc/SYSCALLS.TXT +++ b/libc/SYSCALLS.TXT @@ -33,7 +33,7 @@ void _exit:exit_group (int) 248,252 void _exit_thread:exit (int) 1 pid_t __fork:fork (void) 2 pid_t _waitpid:waitpid (pid_t, int*, int, struct rusage*) -1,7 -int waitid(int, pid_t, struct siginfo_t*, int,void*) 280,284 +int __waitid:waitid(int, pid_t, struct siginfo_t*, int,void*) 280,284 # NOTE: this system call is never called directly, but we list it there # to have __NR_clone properly defined. diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk index f1d8fb16e..c364d1cf1 100644 --- a/libc/arch-arm/syscalls.mk +++ b/libc/arch-arm/syscalls.mk @@ -3,7 +3,7 @@ syscall_src := syscall_src += arch-arm/syscalls/_exit.S syscall_src += arch-arm/syscalls/_exit_thread.S syscall_src += arch-arm/syscalls/__fork.S -syscall_src += arch-arm/syscalls/waitid.S +syscall_src += arch-arm/syscalls/__waitid.S syscall_src += arch-arm/syscalls/__sys_clone.S syscall_src += arch-arm/syscalls/execve.S syscall_src += arch-arm/syscalls/__setuid.S diff --git a/libc/arch-arm/syscalls/waitid.S b/libc/arch-arm/syscalls/__waitid.S similarity index 86% rename from libc/arch-arm/syscalls/waitid.S rename to libc/arch-arm/syscalls/__waitid.S index 4134e535f..fdd0da31d 100644 --- a/libc/arch-arm/syscalls/waitid.S +++ b/libc/arch-arm/syscalls/__waitid.S @@ -2,12 +2,12 @@ #include .text - .type waitid, #function - .globl waitid + .type __waitid, #function + .globl __waitid .align 4 .fnstart -waitid: +__waitid: mov ip, sp .save {r4, r5, r6, r7} stmfd sp!, {r4, r5, r6, r7} diff --git a/libc/arch-sh/syscalls.mk b/libc/arch-sh/syscalls.mk index 3e2274fb3..47b5a1ec6 100644 --- a/libc/arch-sh/syscalls.mk +++ b/libc/arch-sh/syscalls.mk @@ -4,7 +4,7 @@ syscall_src += arch-sh/syscalls/_exit.S syscall_src += arch-sh/syscalls/_exit_thread.S syscall_src += arch-sh/syscalls/__fork.S syscall_src += arch-sh/syscalls/_waitpid.S -syscall_src += arch-sh/syscalls/waitid.S +syscall_src += arch-sh/syscalls/__waitid.S syscall_src += arch-sh/syscalls/__sys_clone.S syscall_src += arch-sh/syscalls/execve.S syscall_src += arch-sh/syscalls/__setuid.S diff --git a/libc/arch-sh/syscalls/waitid.S b/libc/arch-sh/syscalls/__waitid.S similarity index 90% rename from libc/arch-sh/syscalls/waitid.S rename to libc/arch-sh/syscalls/__waitid.S index 1f0432d14..1f58de08f 100644 --- a/libc/arch-sh/syscalls/waitid.S +++ b/libc/arch-sh/syscalls/__waitid.S @@ -2,11 +2,11 @@ #include .text - .type waitid, @function - .globl waitid + .type __waitid, @function + .globl __waitid .align 4 -waitid: +__waitid: /* get ready for additonal arg */ mov.l @r15, r0 diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk index f0d7a31aa..133f286b8 100644 --- a/libc/arch-x86/syscalls.mk +++ b/libc/arch-x86/syscalls.mk @@ -4,7 +4,7 @@ syscall_src += arch-x86/syscalls/_exit.S syscall_src += arch-x86/syscalls/_exit_thread.S syscall_src += arch-x86/syscalls/__fork.S syscall_src += arch-x86/syscalls/_waitpid.S -syscall_src += arch-x86/syscalls/waitid.S +syscall_src += arch-x86/syscalls/__waitid.S syscall_src += arch-x86/syscalls/__sys_clone.S syscall_src += arch-x86/syscalls/execve.S syscall_src += arch-x86/syscalls/__setuid.S diff --git a/libc/arch-x86/syscalls/waitid.S b/libc/arch-x86/syscalls/__waitid.S similarity index 90% rename from libc/arch-x86/syscalls/waitid.S rename to libc/arch-x86/syscalls/__waitid.S index 9a5328bb5..4dd8c11b5 100644 --- a/libc/arch-x86/syscalls/waitid.S +++ b/libc/arch-x86/syscalls/__waitid.S @@ -2,11 +2,11 @@ #include .text - .type waitid, @function - .globl waitid + .type __waitid, @function + .globl __waitid .align 4 -waitid: +__waitid: pushl %ebx pushl %ecx pushl %edx diff --git a/libc/include/sys/linux-unistd.h b/libc/include/sys/linux-unistd.h index 5e9c2f0f3..a1905b3c7 100644 --- a/libc/include/sys/linux-unistd.h +++ b/libc/include/sys/linux-unistd.h @@ -9,7 +9,7 @@ void _exit (int); void _exit_thread (int); pid_t __fork (void); pid_t _waitpid (pid_t, int*, int, struct rusage*); -int waitid (int, pid_t, struct siginfo_t*, int,void*); +int __waitid (int, pid_t, struct siginfo_t*, int,void*); pid_t __sys_clone (int, void*, int*, void*, int*); int execve (const char*, char* const*, char* const*); int __setuid (uid_t); diff --git a/libc/include/sys/wait.h b/libc/include/sys/wait.h index 8ba1837fe..573e22004 100644 --- a/libc/include/sys/wait.h +++ b/libc/include/sys/wait.h @@ -32,6 +32,7 @@ #include #include #include +#include __BEGIN_DECLS @@ -49,6 +50,14 @@ extern pid_t waitpid(pid_t, int *, int); extern pid_t wait3(int *, int, struct rusage *); extern pid_t wait4(pid_t, int *, int, struct rusage *); +/* Posix states that idtype_t should be an enumeration type, but + * the kernel headers define P_ALL, P_PID and P_PGID as constant macros + * instead. + */ +typedef int idtype_t; + +extern int waidit(idtype_t which, id_t id, siginfo_t *info, int options); + __END_DECLS #endif /* _SYS_WAIT_H_ */ diff --git a/libc/unistd/wait.c b/libc/unistd/wait.c index d17241909..f1db086db 100644 --- a/libc/unistd/wait.c +++ b/libc/unistd/wait.c @@ -29,6 +29,7 @@ #include extern pid_t __wait4 (pid_t pid, int *status, int options, struct rusage *rusage); +extern int __waitid(idtype_t which, id_t id, siginfo_t *info, int options, struct rusage *ru); pid_t wait( int* status ) { @@ -44,3 +45,9 @@ pid_t waitpid(pid_t pid, int* status, int options) { return __wait4( pid, status, options, NULL ); } + +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 */ + return __waitid(which, id, info, options, NULL); +}