mirror of
https://github.com/SerenityOS/serenity
synced 2026-04-25 17:15:42 +02:00
AK: Add volatile overloads to AK_ENUM_BITWISE_OPERATORS
These overloads return void, since GCC otherwise complains if you
ignore the return value:
implicit dereference will not access object of type
'volatile Kernel::PCI::Registers::Control' in statement [-Werror]
132 | registers->control |= Registers::Control::PERST_N;
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This commit is contained in:
@@ -58,6 +58,13 @@
|
||||
return lhs; \
|
||||
} \
|
||||
\
|
||||
Prefix inline void operator|=(Enum volatile& lhs, Enum rhs) \
|
||||
{ \
|
||||
using Type = UnderlyingType<Enum>; \
|
||||
lhs = static_cast<Enum>( \
|
||||
static_cast<Type>(lhs) | static_cast<Type>(rhs)); \
|
||||
} \
|
||||
\
|
||||
Prefix constexpr Enum& operator&=(Enum& lhs, Enum rhs) \
|
||||
{ \
|
||||
using Type = UnderlyingType<Enum>; \
|
||||
@@ -66,6 +73,13 @@
|
||||
return lhs; \
|
||||
} \
|
||||
\
|
||||
Prefix inline void operator&=(Enum volatile& lhs, Enum rhs) \
|
||||
{ \
|
||||
using Type = UnderlyingType<Enum>; \
|
||||
lhs = static_cast<Enum>( \
|
||||
static_cast<Type>(lhs) & static_cast<Type>(rhs)); \
|
||||
} \
|
||||
\
|
||||
Prefix constexpr Enum& operator^=(Enum& lhs, Enum rhs) \
|
||||
{ \
|
||||
using Type = UnderlyingType<Enum>; \
|
||||
@@ -74,6 +88,13 @@
|
||||
return lhs; \
|
||||
} \
|
||||
\
|
||||
Prefix inline void operator^=(Enum volatile& lhs, Enum rhs) \
|
||||
{ \
|
||||
using Type = UnderlyingType<Enum>; \
|
||||
lhs = static_cast<Enum>( \
|
||||
static_cast<Type>(lhs) ^ static_cast<Type>(rhs)); \
|
||||
} \
|
||||
\
|
||||
Prefix constexpr bool has_flag(Enum value, Enum mask) \
|
||||
{ \
|
||||
using Type = UnderlyingType<Enum>; \
|
||||
|
||||
Reference in New Issue
Block a user