mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-22 10:55:14 -04:00
fatal: include stack/tls in reports
This commit is contained in:
parent
2e8f06ef44
commit
846f610fff
4 changed files with 64 additions and 16 deletions
|
@ -20,55 +20,60 @@
|
|||
namespace ams::util {
|
||||
|
||||
/* Utilities for alignment to power of two. */
|
||||
template<typename T>
|
||||
constexpr ALWAYS_INLINE bool IsPowerOfTwo(T value) {
|
||||
using U = typename std::make_unsigned<T>::type;
|
||||
return (static_cast<U>(value) & static_cast<U>(value - 1)) == 0;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr inline T AlignUp(T value, size_t alignment) {
|
||||
constexpr ALWAYS_INLINE T AlignUp(T value, size_t alignment) {
|
||||
using U = typename std::make_unsigned<T>::type;
|
||||
const U invmask = static_cast<U>(alignment - 1);
|
||||
return static_cast<T>((value + invmask) & ~invmask);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr inline T AlignDown(T value, size_t alignment) {
|
||||
constexpr ALWAYS_INLINE T AlignDown(T value, size_t alignment) {
|
||||
using U = typename std::make_unsigned<T>::type;
|
||||
const U invmask = static_cast<U>(alignment - 1);
|
||||
return static_cast<T>(value & ~invmask);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr inline bool IsAligned(T value, size_t alignment) {
|
||||
constexpr ALWAYS_INLINE bool IsAligned(T value, size_t alignment) {
|
||||
using U = typename std::make_unsigned<T>::type;
|
||||
const U invmask = static_cast<U>(alignment - 1);
|
||||
return (value & invmask) == 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
constexpr inline void *AlignUp<void *>(void *value, size_t alignment) {
|
||||
constexpr ALWAYS_INLINE void *AlignUp<void *>(void *value, size_t alignment) {
|
||||
return reinterpret_cast<void *>(AlignUp(reinterpret_cast<uintptr_t>(value), alignment));
|
||||
}
|
||||
|
||||
template<>
|
||||
constexpr inline const void *AlignUp<const void *>(const void *value, size_t alignment) {
|
||||
constexpr ALWAYS_INLINE const void *AlignUp<const void *>(const void *value, size_t alignment) {
|
||||
return reinterpret_cast<const void *>(AlignUp(reinterpret_cast<uintptr_t>(value), alignment));
|
||||
}
|
||||
|
||||
template<>
|
||||
constexpr inline void *AlignDown<void *>(void *value, size_t alignment) {
|
||||
constexpr ALWAYS_INLINE void *AlignDown<void *>(void *value, size_t alignment) {
|
||||
return reinterpret_cast<void *>(AlignDown(reinterpret_cast<uintptr_t>(value), alignment));
|
||||
}
|
||||
|
||||
template<>
|
||||
constexpr inline const void *AlignDown<const void *>(const void *value, size_t alignment) {
|
||||
constexpr ALWAYS_INLINE const void *AlignDown<const void *>(const void *value, size_t alignment) {
|
||||
return reinterpret_cast<void *>(AlignDown(reinterpret_cast<uintptr_t>(value), alignment));
|
||||
}
|
||||
|
||||
template<>
|
||||
constexpr inline bool IsAligned<void *>(void *value, size_t alignment) {
|
||||
constexpr ALWAYS_INLINE bool IsAligned<void *>(void *value, size_t alignment) {
|
||||
return IsAligned(reinterpret_cast<uintptr_t>(value), alignment);
|
||||
}
|
||||
|
||||
template<>
|
||||
constexpr inline bool IsAligned<const void *>(const void *value, size_t alignment) {
|
||||
constexpr ALWAYS_INLINE bool IsAligned<const void *>(const void *value, size_t alignment) {
|
||||
return IsAligned(reinterpret_cast<uintptr_t>(value), alignment);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue