[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 16/30] bsd-user/signal.c: host_to_target_siginfo_noswap
|
From: |
Peter Maydell |
|
Subject: |
Re: [PATCH 16/30] bsd-user/signal.c: host_to_target_siginfo_noswap |
|
Date: |
Thu, 13 Jan 2022 19:43:48 +0000 |
On Sun, 9 Jan 2022 at 16:41, Warner Losh <imp@bsdimp.com> wrote:
>
> Implement conversion of host to target siginfo.
>
> Signed-off-by: Stacey Son <sson@FreeBSD.org>
> Signed-off-by: Kyle Evans <kevans@freebsd.org>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
> bsd-user/signal.c | 37 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/bsd-user/signal.c b/bsd-user/signal.c
> index 7168d851be8..3fe8b2d9898 100644
> --- a/bsd-user/signal.c
> +++ b/bsd-user/signal.c
> @@ -43,6 +43,43 @@ int target_to_host_signal(int sig)
> return sig;
> }
>
> +/* Siginfo conversion. */
> +static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo,
> + const siginfo_t *info)
> +{
> + int sig, code;
> +
> + sig = host_to_target_signal(info->si_signo);
> + /* XXX should have host_to_target_si_code() */
> + code = tswap32(info->si_code);
> + tinfo->si_signo = sig;
> + tinfo->si_errno = info->si_errno;
> + tinfo->si_code = info->si_code;
> + tinfo->si_pid = info->si_pid;
> + tinfo->si_uid = info->si_uid;
> + tinfo->si_status = info->si_status;
> + tinfo->si_addr = (abi_ulong)(unsigned long)info->si_addr;
> + /* si_value is opaque to kernel */
> + tinfo->si_value.sival_ptr =
> + (abi_ulong)(unsigned long)info->si_value.sival_ptr;
> + if (SIGILL == sig || SIGFPE == sig || SIGSEGV == sig || SIGBUS == sig ||
Don't use yoda-conditions, please. sig == SIGILL, etc.
> + SIGTRAP == sig) {
> + tinfo->_reason._fault._trapno = info->_reason._fault._trapno;
> + }
> +#ifdef SIGPOLL
> + if (SIGPOLL == sig) {
> + tinfo->_reason._poll._band = info->_reason._poll._band;
> + }
> +#endif
> + if (SI_TIMER == code) {
> + int timerid;
> +
> + timerid = info->_reason._timer._timerid;
> + tinfo->_reason._timer._timerid = timerid;
> + tinfo->_reason._timer._overrun = info->_reason._timer._overrun;
> + }
> +}
I think this will only compile on FreeBSD (the other BSDs having
notably different target_siginfo_t structs); I guess we're OK
with that ?
I also commented on the general setup linux-user has for this
function back in patch 2; I'll let you figure out whether what
you have here is the right thing for BSD.
-- PMM
- Re: [PATCH 28/30] bsd-user/signal.c: implement do_sigreturn, (continued)
- [PATCH 29/30] bsd-user/signal.c: implement do_sigaction, Warner Losh, 2022/01/09
- [PATCH 27/30] bsd-user/signal.c: process_pending_signals, Warner Losh, 2022/01/09
- [PATCH 30/30] bsd-user/signal.c: do_sigaltstack, Warner Losh, 2022/01/09
- [PATCH 16/30] bsd-user/signal.c: host_to_target_siginfo_noswap, Warner Losh, 2022/01/09
- Re: [PATCH 16/30] bsd-user/signal.c: host_to_target_siginfo_noswap,
Peter Maydell <=
- Re: [PATCH 16/30] bsd-user/signal.c: host_to_target_siginfo_noswap, Richard Henderson, 2022/01/23