diff options
author | Salvatore Cro <salvatore.cro@st.com> | 2010-09-09 16:01:04 +0200 |
---|---|---|
committer | Carmelo Amoroso <carmelo.amoroso@st.com> | 2010-09-15 12:38:42 +0200 |
commit | 4b88e6e858b55def2ef0392278ddf81835f2ac45 (patch) | |
tree | e97e06b8eb18ef18f86e598ccec879405bdcee53 /libc/sysdeps/linux/common/waitid.c | |
parent | 37eb913ed8c4798b736e678f4dbd9f4a91a68f74 (diff) |
libc: Fix cancellation handling in some C functions
According to POSIX.1-2008 standard, the following syscalls shall be
cancellation points : waitid, sleep, fdatasync, ppoll.
Further, if generic syscall is not available and stubs are
configured, provide the stub implementation for function.
Signed-off-by: Salvatore Cro <salvatore.cro@st.com>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libc/sysdeps/linux/common/waitid.c')
-rw-r--r-- | libc/sysdeps/linux/common/waitid.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/libc/sysdeps/linux/common/waitid.c b/libc/sysdeps/linux/common/waitid.c index af55c914a..c8115f9a5 100644 --- a/libc/sysdeps/linux/common/waitid.c +++ b/libc/sysdeps/linux/common/waitid.c @@ -14,20 +14,37 @@ # include <sys/syscall.h> # ifdef __NR_waitid + +# ifdef __UCLIBC_HAS_THREADS_NATIVE__ +# include <sysdep-cancel.h> +# else +# define SINGLE_THREAD_P 1 +# endif + /* The waitid() POSIX interface takes 4 arguments, but the kernel function * actually takes 5. The fifth is a pointer to struct rusage. Make sure * we pass NULL rather than letting whatever was in the register bleed up. */ #define __NR_waitid5 __NR_waitid -static _syscall5(int, waitid5, idtype_t, idtype, id_t, id, siginfo_t*, infop, +static __always_inline +_syscall5(int, waitid5, idtype_t, idtype, id_t, id, siginfo_t*, infop, int, options, struct rusage*, ru) # endif int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options) { # ifdef __NR_waitid - return waitid5(idtype, id, infop, options, NULL); -# else + if (SINGLE_THREAD_P) + return waitid5(idtype, id, infop, options, NULL); + +# ifdef __UCLIBC_HAS_THREADS_NATIVE__ + int oldtype = LIBC_CANCEL_ASYNC (); + int result = waitid5(idtype, id, infop, options, NULL); + LIBC_CANCEL_RESET (oldtype); + return result; +# endif + +# elif defined __NR_waitpid switch (idtype) { case P_PID: if (id <= 0) @@ -56,7 +73,9 @@ int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options) if (infop->si_pid < 0) return infop->si_pid; return 0; +# else + __set_errno(ENOSYS); + return -1; # endif } - #endif |