diff options
author | davidxu <davidxu@FreeBSD.org> | 2006-10-05 01:56:11 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2006-10-05 01:56:11 +0000 |
commit | 0fa66af83d7752ee96c7e9f5e372d31f89e496f3 (patch) | |
tree | 9fda0bb64da7a7e4f4dbd5cce476614524ce6c08 /sys/compat/freebsd32 | |
parent | 4503c0ed680d09ab549039827e23db4cecc4795d (diff) | |
download | FreeBSD-src-0fa66af83d7752ee96c7e9f5e372d31f89e496f3.zip FreeBSD-src-0fa66af83d7752ee96c7e9f5e372d31f89e496f3.tar.gz |
Move some declaration of 32-bit signal structures into file
freebsd32-signal.h, implement sigtimedwait and sigwaitinfo system calls.
Diffstat (limited to 'sys/compat/freebsd32')
-rw-r--r-- | sys/compat/freebsd32/freebsd32_misc.c | 90 | ||||
-rw-r--r-- | sys/compat/freebsd32/syscalls.master | 9 |
2 files changed, 89 insertions, 10 deletions
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index 461e8c0..41cb789 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -88,6 +88,7 @@ __FBSDID("$FreeBSD$"); #include <compat/freebsd32/freebsd32_util.h> #include <compat/freebsd32/freebsd32.h> +#include <compat/freebsd32/freebsd32_signal.h> #include <compat/freebsd32/freebsd32_proto.h> CTASSERT(sizeof(struct timeval32) == 8); @@ -192,12 +193,6 @@ freebsd4_freebsd32_getfsstat(struct thread *td, struct freebsd4_freebsd32_getfss } #endif -struct sigaltstack32 { - u_int32_t ss_sp; - u_int32_t ss_size; - int ss_flags; -}; - CTASSERT(sizeof(struct sigaltstack32) == 12); int @@ -2178,6 +2173,89 @@ freebsd32_thr_suspend(struct thread *td, struct freebsd32_thr_suspend_args *uap) return (kern_thr_suspend(td, tsp)); } +void +siginfo_to_siginfo32(siginfo_t *src, struct siginfo32 *dst) +{ + bzero(dst, sizeof(*dst)); + dst->si_signo = src->si_signo; + dst->si_errno = src->si_errno; + dst->si_code = src->si_code; + dst->si_pid = src->si_pid; + dst->si_uid = src->si_uid; + dst->si_status = src->si_status; + dst->si_addr = dst->si_addr; + dst->si_value.sigval_int = src->si_value.sival_int; + dst->si_timerid = src->si_timerid; + dst->si_overrun = src->si_overrun; +} + +int +freebsd32_sigtimedwait(struct thread *td, struct freebsd32_sigtimedwait_args *uap) +{ + struct timespec32 ts32; + struct timespec ts; + struct timespec *timeout; + sigset_t set; + ksiginfo_t ksi; + struct siginfo32 si32; + int error; + + if (uap->timeout) { + error = copyin(uap->timeout, &ts32, sizeof(ts32)); + if (error) + return (error); + ts.tv_sec = ts32.tv_sec; + ts.tv_nsec = ts32.tv_nsec; + timeout = &ts; + } else + timeout = NULL; + + error = copyin(uap->set, &set, sizeof(set)); + if (error) + return (error); + + error = kern_sigtimedwait(td, set, &ksi, timeout); + if (error) + return (error); + + if (uap->info) { + siginfo_to_siginfo32(&ksi.ksi_info, &si32); + error = copyout(&si32, uap->info, sizeof(struct siginfo32)); + } + + if (error == 0) + td->td_retval[0] = ksi.ksi_signo; + return (error); +} + +/* + * MPSAFE + */ +int +freebsd32_sigwaitinfo(struct thread *td, struct freebsd32_sigwaitinfo_args *uap) +{ + ksiginfo_t ksi; + struct siginfo32 si32; + sigset_t set; + int error; + + error = copyin(uap->set, &set, sizeof(set)); + if (error) + return (error); + + error = kern_sigtimedwait(td, set, &ksi, NULL); + if (error) + return (error); + + if (uap->info) { + siginfo_to_siginfo32(&ksi.ksi_info, &si32); + error = copyout(&si32, uap->info, sizeof(struct siginfo32)); + } + if (error == 0) + td->td_retval[0] = ksi.ksi_signo; + return (error); +} + #if 0 int diff --git a/sys/compat/freebsd32/syscalls.master b/sys/compat/freebsd32/syscalls.master index ceed358..5cfd0c8 100644 --- a/sys/compat/freebsd32/syscalls.master +++ b/sys/compat/freebsd32/syscalls.master @@ -578,10 +578,11 @@ 343 AUE_SIGPENDING NOPROTO { int sigpending(sigset_t *set); } 344 AUE_SIGRETURN COMPAT4 { int freebsd32_sigreturn( \ const struct freebsd4_freebsd32_ucontext *sigcntxp); } -; XXX implement -345 AUE_SIGWAIT UNIMPL sigtimedwait -; XXX implement -346 AUE_NULL UNIMPL sigwaitinfo +345 AUE_SIGWAIT STD { int freebsd32_sigtimedwait(const sigset_t *set, \ + siginfo_t *info, \ + const struct timespec *timeout); } +346 AUE_NULL STD { int freebsd32_sigwaitinfo(const sigset_t *set, \ + siginfo_t *info); } 347 AUE_NULL NOPROTO { int __acl_get_file(const char *path, \ acl_type_t type, struct acl *aclp); } 348 AUE_NULL NOPROTO { int __acl_set_file(const char *path, \ |