mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-28 00:00:35 +01:00
It is not an external component, and it makes paths needlessly long. Ryan seemed amenable to this when we discussed on IRC earlier. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
28 lines
725 B
C++
28 lines
725 B
C++
#pragma once
|
|
|
|
#include <FEXCore/Utils/LogManager.h>
|
|
|
|
#include <bit>
|
|
#include <cstdint>
|
|
#include <type_traits>
|
|
|
|
namespace FEXCore {
|
|
[[nodiscard]] constexpr uint64_t AlignUp(uint64_t value, uint64_t size) {
|
|
return value + (size - value % size) % size;
|
|
}
|
|
|
|
[[nodiscard]] constexpr uint64_t AlignDown(uint64_t value, uint64_t size) {
|
|
return value - value % size;
|
|
}
|
|
|
|
// Returns the ilog2 of a power-of-2 integer.
|
|
// Asserts in the case that the passed in integer is not a power-of-2.
|
|
template<typename T>
|
|
requires(std::is_unsigned_v<T>)
|
|
[[nodiscard]] constexpr T ilog2(T Value) {
|
|
LOGMAN_THROW_A_FMT(std::has_single_bit(Value), "ilog2 requires popcount to be one");
|
|
return std::countr_zero(Value);
|
|
}
|
|
|
|
} // namespace FEXCore
|