HomeFreeBSD

signal: Add SIG_FOREACH and refactor issignal()

Description

signal: Add SIG_FOREACH and refactor issignal()

Add a SIG_FOREACH macro that can be used to iterate over a signal set.
This is a bit cleaner and more efficient than calling sig_ffs() in a
loop. The implementation is based on BIT_FOREACH_ISSET(), except
that the bitset limbs are always 32 bits wide, and signal sets are
1-indexed rather than 0-indexed like bitset(9) sets.

issignal() cannot really be modified to use SIG_FOREACH() directly.
Take this opportunity to split the function into two explicit loops.
I've always found this function hard to read and think that this change
is an improvement.

Remove sig_ffs(), nothing uses it now.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32473

Details

Provenance
markjAuthored on Oct 16 2021, 1:44 PM
Reviewer
kib
Differential Revision
D32473: signal: Add SIG_FOREACH and refactor issignal()
Parents
rGde8554295b47: cpuset(9): Add CPU_FOREACH_IS(SET|CLR) and modify consumers to use it
Branches
Unknown
Tags
Unknown