mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK+Kernel: Implement and use EnumBits has_any_flag()
This duplicates the old functionality of has_flag and will return true when any flags present in the mask are also in the value.
This commit is contained in:
parent
371911b1b5
commit
9715311837
Notes:
sideshowbarker
2024-07-18 08:56:48 +09:00
Author: https://github.com/timmot Commit: https://github.com/SerenityOS/serenity/commit/97153118374 Pull-request: https://github.com/SerenityOS/serenity/pull/8724 Reviewed-by: https://github.com/bgianfo ✅ Reviewed-by: https://github.com/kleinesfilmroellchen ✅
3 changed files with 9 additions and 3 deletions
|
@ -78,4 +78,10 @@
|
|||
{ \
|
||||
using Type = UnderlyingType<Enum>; \
|
||||
return static_cast<Type>(value & mask) == static_cast<Type>(mask); \
|
||||
} \
|
||||
\
|
||||
Prefix constexpr bool has_any_flag(Enum value, Enum mask) \
|
||||
{ \
|
||||
using Type = UnderlyingType<Enum>; \
|
||||
return static_cast<Type>(value & mask) != 0; \
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ Thread::FileBlocker::BlockFlags FileDescription::should_unblock(Thread::FileBloc
|
|||
unblock_flags |= BlockFlags::Write;
|
||||
// TODO: Implement Thread::FileBlocker::BlockFlags::Exception
|
||||
|
||||
if (has_flag(block_flags, BlockFlags::SocketFlags)) {
|
||||
if (has_any_flag(block_flags, BlockFlags::SocketFlags)) {
|
||||
auto* sock = socket();
|
||||
VERIFY(sock);
|
||||
if (has_flag(block_flags, BlockFlags::Accept) && sock->can_accept())
|
||||
|
|
|
@ -112,7 +112,7 @@ KResultOr<FlatPtr> Process::sys$select(Userspace<const Syscall::SC_select_params
|
|||
FD_SET(selected_fds[i], &fds_write);
|
||||
marked_fd_count++;
|
||||
}
|
||||
if (params.exceptfds && has_flag(fd_entry.unblocked_flags, BlockFlags::Exception)) {
|
||||
if (params.exceptfds && has_any_flag(fd_entry.unblocked_flags, BlockFlags::Exception)) {
|
||||
FD_SET(selected_fds[i], &fds_except);
|
||||
marked_fd_count++;
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ KResultOr<FlatPtr> Process::sys$poll(Userspace<const Syscall::SC_poll_params*> u
|
|||
if (fds_entry.unblocked_flags == BlockFlags::None)
|
||||
continue;
|
||||
|
||||
if (has_flag(fds_entry.unblocked_flags, BlockFlags::Exception)) {
|
||||
if (has_any_flag(fds_entry.unblocked_flags, BlockFlags::Exception)) {
|
||||
if (has_flag(fds_entry.unblocked_flags, BlockFlags::ReadHangUp))
|
||||
pfd.revents |= POLLRDHUP;
|
||||
if (has_flag(fds_entry.unblocked_flags, BlockFlags::WriteError))
|
||||
|
|
Loading…
Reference in a new issue