From 3445f2f9f244d28847011b406ff49c43ae88834a Mon Sep 17 00:00:00 2001 From: dchagin Date: Sun, 24 May 2015 15:00:27 +0000 Subject: [PATCH] Add a function for converting wait options. Differential Revision: https://reviews.freebsd.org/D1045 Reviewed by: trasz --- sys/compat/linux/linux_misc.c | 19 +++++++++++++++++++ sys/compat/linux/linux_misc.h | 13 ++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index df0c449a219b..e3b619c50cda 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -2008,3 +2008,22 @@ linux_tdfind(struct thread *td, lwpid_t tid, pid_t pid) return (tdt); } + +void +linux_to_bsd_waitopts(int options, int *bsdopts) +{ + + if (options & LINUX_WNOHANG) + *bsdopts |= WNOHANG; + if (options & LINUX_WUNTRACED) + *bsdopts |= WUNTRACED; + if (options & LINUX_WEXITED) + *bsdopts |= WEXITED; + if (options & LINUX_WCONTINUED) + *bsdopts |= WCONTINUED; + if (options & LINUX_WNOWAIT) + *bsdopts |= WNOWAIT; + + if (options & __WCLONE) + *bsdopts |= WLINUXCLONE; +} diff --git a/sys/compat/linux/linux_misc.h b/sys/compat/linux/linux_misc.h index e86afcd88213..be2da813f856 100644 --- a/sys/compat/linux/linux_misc.h +++ b/sys/compat/linux/linux_misc.h @@ -113,10 +113,21 @@ struct l_new_utsname { extern int stclohz; -#define __WCLONE 0x80000000 +#define LINUX_WNOHANG 0x00000001 +#define LINUX_WUNTRACED 0x00000002 +#define LINUX_WSTOPPED LINUX_WUNTRACED +#define LINUX_WEXITED 0x00000004 +#define LINUX_WCONTINUED 0x00000008 +#define LINUX_WNOWAIT 0x01000000 + + +#define __WNOTHREAD 0x20000000 +#define __WALL 0x40000000 +#define __WCLONE 0x80000000 int linux_common_wait(struct thread *td, int pid, int *status, int options, struct rusage *ru); +void linux_to_bsd_waitopts(int options, int *bsdopts); int linux_set_upcall_kse(struct thread *td, register_t stack); int linux_set_cloned_tls(struct thread *td, void *desc); struct thread *linux_tdfind(struct thread *, lwpid_t, pid_t);