mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 22:41:25 +12:00
Remove ceil2/floor2 from types.h
This commit is contained in:
parent
dff4392c10
commit
666a18f5e5
2 changed files with 2 additions and 34 deletions
|
@ -890,34 +890,3 @@ inline void busy_wait(std::size_t cycles = 3000)
|
|||
const u64 s = __rdtsc();
|
||||
do _mm_pause(); while (__rdtsc() - s < cycles);
|
||||
}
|
||||
|
||||
// TODO: Remove when moving to c++20
|
||||
template <typename T>
|
||||
inline constexpr uintmax_t floor2(T value)
|
||||
{
|
||||
value >>= 1;
|
||||
|
||||
for (uintmax_t i = 0;; i++, value >>= 1)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline constexpr uintmax_t ceil2(T value)
|
||||
{
|
||||
const uintmax_t ispow2 = value & (value - 1); // if power of 2 the result is 0
|
||||
|
||||
value >>= 1;
|
||||
|
||||
for (uintmax_t i = 0;; i++, value >>= 1)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return i + std::min<uintmax_t>(ispow2, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue