Files
P3DS-test/third_party/teakra/src/bit.h
wheremyfoodat 78002be334 Vendor Teakra, make emulator own DSP RAM and add DSP RAM to fastmem (#806)
* DSP: Own DSP RAM and add it to fastmem

* Vendor Teakra

* Add MacOS support to fastmem

* Fix MacOS fastmem paths

* Fix iOS build
2025-08-22 02:12:21 +03:00

27 lines
597 B
C++

#pragma once
#include <limits>
#include <type_traits>
#ifdef _MSC_VER
#include <intrin.h>
#endif
namespace std20 {
// A simple (and not very correct) implementation of C++20's std::log2p1
template <class T>
constexpr T log2p1(T x) noexcept {
static_assert(std::is_integral_v<T> && std::is_unsigned_v<T>);
if (x == 0)
return 0;
#ifdef _MSC_VER
unsigned long index = 0;
_BitScanReverse64(&index, x);
return static_cast<T>(index) + 1;
#else
return static_cast<T>(std::numeric_limits<unsigned long long>::digits - __builtin_clzll(x));
#endif
}
} // namespace std20