diff options
| author | 2022-03-09 15:34:42 -0800 | |
|---|---|---|
| committer | 2022-03-09 15:34:42 -0800 | |
| commit | 9a97ef46478c999fc1220f0963847667dae795ce (patch) | |
| tree | 8367047d071fae6c273faf0e6a61120e6c087f05 /src/common/bit_util.h | |
| parent | Merge pull request #7975 from bunnei/ldr-fix (diff) | |
| parent | cpu_detect: Add missing `lzcnt` detection (diff) | |
| download | yuzu-9a97ef46478c999fc1220f0963847667dae795ce.tar.gz yuzu-9a97ef46478c999fc1220f0963847667dae795ce.tar.xz yuzu-9a97ef46478c999fc1220f0963847667dae795ce.zip | |
Merge pull request #7936 from Wunkolo/cpu_detect
cpu_detect: Refactor detection of processor features
Diffstat (limited to 'src/common/bit_util.h')
| -rw-r--r-- | src/common/bit_util.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/common/bit_util.h b/src/common/bit_util.h index f50d3308a..f37538e06 100644 --- a/src/common/bit_util.h +++ b/src/common/bit_util.h | |||
| @@ -57,4 +57,11 @@ requires std::is_integral_v<T> | |||
| 57 | 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))); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | template <size_t bit_index, typename T> | ||
| 61 | requires std::is_integral_v<T> | ||
| 62 | [[nodiscard]] constexpr bool Bit(const T value) { | ||
| 63 | static_assert(bit_index < BitSize<T>(), "bit_index must be smaller than size of T"); | ||
| 64 | return ((value >> bit_index) & T(1)) == T(1); | ||
| 65 | } | ||
| 66 | |||
| 60 | } // namespace Common | 67 | } // namespace Common |