#ifndef SRC_DAWN_COMMON_MATH_H_
#define SRC_DAWN_COMMON_MATH_H_
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <limits>
#include <optional>
#include <type_traits>
#include "dawn/common/Assert.h"
#include "partition_alloc/pointers/raw_ptr.h"
namespace dawn {
uint32_t ScanForward(uint32_t bits);
uint32_t Log2(uint32_t value);
uint32_t Log2(uint64_t value);
bool IsPowerOfTwo(uint64_t n);
uint64_t RoundUp(uint64_t n, uint64_t m);
constexpr uint32_t ConstexprLog2(uint64_t v) { … }
constexpr uint32_t ConstexprLog2Ceil(uint64_t v) { … }
inline uint32_t Log2Ceil(uint32_t v) { … }
inline uint32_t Log2Ceil(uint64_t v) { … }
uint64_t NextPowerOfTwo(uint64_t n);
bool IsPtrAligned(const void* ptr, size_t alignment);
void* AlignVoidPtr(void* ptr, size_t alignment);
bool IsAligned(uint32_t value, size_t alignment);
template <typename T>
T Align(T value, size_t alignment) { … }
template <typename T>
T AlignDown(T value, size_t alignment) { … }
template <typename T, size_t Alignment>
constexpr size_t AlignSizeof() { … }
template <typename T, size_t Alignment>
std::optional<size_t> AlignSizeofN(uint64_t n) { … }
template <typename T>
DAWN_FORCE_INLINE T* AlignPtr(T* ptr, size_t alignment) { … }
template <typename T, partition_alloc::internal::RawPtrTraits Traits>
DAWN_FORCE_INLINE T* AlignPtr(raw_ptr<T, Traits> ptr, size_t alignment) { … }
template <typename T>
DAWN_FORCE_INLINE const T* AlignPtr(const T* ptr, size_t alignment) { … }
template <typename destType, typename sourceType>
destType BitCast(const sourceType& source) { … }
uint16_t Float32ToFloat16(float fp32);
float Float16ToFloat32(uint16_t fp16);
bool IsFloat16NaN(uint16_t fp16);
template <typename T>
T FloatToUnorm(float value) { … }
float SRGBToLinear(float srgb);
template <typename T1,
typename T2,
typename Enable = typename std::enable_if<sizeof(T1) == sizeof(T2)>::type>
constexpr bool IsSubset(T1 subset, T2 set) { … }
}
#endif