diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/bit_util.h | 6 | ||||
| -rw-r--r-- | src/common/fiber.cpp | 5 | ||||
| -rw-r--r-- | src/common/input.h | 7 |
3 files changed, 17 insertions, 1 deletions
diff --git a/src/common/bit_util.h b/src/common/bit_util.h index eef8c1c5a..f50d3308a 100644 --- a/src/common/bit_util.h +++ b/src/common/bit_util.h | |||
| @@ -46,6 +46,12 @@ template <typename T> | |||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | template <typename T> | 48 | template <typename T> |
| 49 | requires std::is_unsigned_v<T> | ||
| 50 | [[nodiscard]] constexpr bool IsPow2(T value) { | ||
| 51 | return std::has_single_bit(value); | ||
| 52 | } | ||
| 53 | |||
| 54 | template <typename T> | ||
| 49 | requires std::is_integral_v<T> | 55 | requires std::is_integral_v<T> |
| 50 | [[nodiscard]] T NextPow2(T value) { | 56 | [[nodiscard]] T NextPow2(T value) { |
| 51 | return static_cast<T>(1ULL << ((8U * sizeof(T)) - std::countl_zero(value - 1U))); | 57 | return static_cast<T>(1ULL << ((8U * sizeof(T)) - std::countl_zero(value - 1U))); |
diff --git a/src/common/fiber.cpp b/src/common/fiber.cpp index 62010d762..81b212e4b 100644 --- a/src/common/fiber.cpp +++ b/src/common/fiber.cpp | |||
| @@ -124,7 +124,10 @@ void Fiber::YieldTo(std::weak_ptr<Fiber> weak_from, Fiber& to) { | |||
| 124 | 124 | ||
| 125 | // "from" might no longer be valid if the thread was killed | 125 | // "from" might no longer be valid if the thread was killed |
| 126 | if (auto from = weak_from.lock()) { | 126 | if (auto from = weak_from.lock()) { |
| 127 | ASSERT(from->impl->previous_fiber != nullptr); | 127 | if (from->impl->previous_fiber == nullptr) { |
| 128 | ASSERT_MSG(false, "previous_fiber is nullptr!"); | ||
| 129 | return; | ||
| 130 | } | ||
| 128 | from->impl->previous_fiber->impl->context = transfer.fctx; | 131 | from->impl->previous_fiber->impl->context = transfer.fctx; |
| 129 | from->impl->previous_fiber->impl->guard.unlock(); | 132 | from->impl->previous_fiber->impl->guard.unlock(); |
| 130 | from->impl->previous_fiber.reset(); | 133 | from->impl->previous_fiber.reset(); |
diff --git a/src/common/input.h b/src/common/input.h index f775a4c01..f4f9eb30a 100644 --- a/src/common/input.h +++ b/src/common/input.h | |||
| @@ -209,6 +209,13 @@ enum class ButtonNames { | |||
| 209 | Triangle, | 209 | Triangle, |
| 210 | Share, | 210 | Share, |
| 211 | Options, | 211 | Options, |
| 212 | |||
| 213 | // Mouse buttons | ||
| 214 | ButtonMouseWheel, | ||
| 215 | ButtonBackward, | ||
| 216 | ButtonForward, | ||
| 217 | ButtonTask, | ||
| 218 | ButtonExtra, | ||
| 212 | }; | 219 | }; |
| 213 | 220 | ||
| 214 | // Callback data consisting of an input type and the equivalent data status | 221 | // Callback data consisting of an input type and the equivalent data status |