On Sat, Jan 22, 2022 at 10:44 AM Warner Losh <i...@bsdimp.com> wrote:
>
>
>
> On Fri, Jan 14, 2022 at 4:14 AM Peter Maydell <peter.mayd...@linaro.org> 
> wrote:
>>
>> On Sun, 9 Jan 2022 at 16:53, Warner Losh <i...@bsdimp.com> wrote:
>> >
>> > target_sigemptyset: resets a set to having no bits set
>> > qemu_sigorset:      computes the or of two sets
>> > target_sigaddset:   adds a signal to a set
>> > target_sigismember: returns true when signal is a member
>> > host_to_target_sigset_internal: convert host sigset to target
>> > host_to_target_sigset: convert host sigset to target
>> > target_to_host_sigset_internal: convert target sigset to host
>> > target_to_host_sigset: convert target sigset to host
>> >
>> > Signed-off-by: Stacey Son <s...@freebsd.org>
>> > Signed-off-by: Kyle Evans <kev...@freebsd.org>
>> > Signed-off-by: Warner Losh <i...@bsdimp.com>
>> > ---
>> >  bsd-user/qemu.h   |  3 ++
>> >  bsd-user/signal.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++
>> >  2 files changed, 92 insertions(+)
>> >
>> > diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
>> > index e12617f5d69..e8c417c7c33 100644
>> > --- a/bsd-user/qemu.h
>> > +++ b/bsd-user/qemu.h
>> > @@ -223,7 +223,10 @@ void queue_signal(CPUArchState *env, int sig, 
>> > target_siginfo_t *info);
>> >  abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, 
>> > abi_ulong sp);
>> >  int target_to_host_signal(int sig);
>> >  int host_to_target_signal(int sig);
>> > +void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
>> > +void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
>> >  void QEMU_NORETURN force_sig(int target_sig);
>> > +int qemu_sigorset(sigset_t *dest, const sigset_t *left, const sigset_t 
>> > *right);
>> >
>> >  /* mmap.c */
>> >  int target_mprotect(abi_ulong start, abi_ulong len, int prot);
>> > diff --git a/bsd-user/signal.c b/bsd-user/signal.c
>> > index 93c3b3c5033..8dadc9a39a7 100644
>> > --- a/bsd-user/signal.c
>> > +++ b/bsd-user/signal.c
>> > @@ -32,6 +32,9 @@
>> >
>> >  static struct target_sigaction sigact_table[TARGET_NSIG];
>> >  static void host_signal_handler(int host_sig, siginfo_t *info, void *puc);
>> > +static void target_to_host_sigset_internal(sigset_t *d,
>> > +        const target_sigset_t *s);
>> > +
>> >
>> >  int host_to_target_signal(int sig)
>> >  {
>> > @@ -43,6 +46,44 @@ int target_to_host_signal(int sig)
>> >      return sig;
>> >  }
>> >
>> > +static inline void target_sigemptyset(target_sigset_t *set)
>> > +{
>> > +    memset(set, 0, sizeof(*set));
>> > +}
>> > +
>> > +#include <signal.h>
>>
>> Don't include system headers halfway through the file like this,
>> please : put the #include at the top of the file with the others.
>
>
> Yea, this isn't even needed, so I just removed it.
>
>>
>> > +
>> > +int
>> > +qemu_sigorset(sigset_t *dest, const sigset_t *left, const sigset_t *right)
>> > +{
>> > +    sigset_t work;
>> > +    int i;
>> > +
>> > +    sigemptyset(&work);
>> > +    for (i = 1; i < NSIG; ++i) {
>> > +        if (sigismember(left, i) || sigismember(right, i)) {
>> > +            sigaddset(&work, i);
>> > +        }
>> > +    }
>> > +
>> > +    *dest = work;
>> > +    return 0;
>> > +}
>>
>> FreeBSD's manpage says it has a native sigorset() --
>> https://www.freebsd.org/cgi/man.cgi?query=sigemptyset&sektion=3&apropos=0&manpath=freebsd
>> can you just use that ?
>
>
> Yes.
>

For some added context, I added sigorset() to libc after 11.3/12.1 in
response to bsd-user using it, then forgot to remove the transition
aide after they went EoL.

Thanks,

Kyle Evans

Reply via email to