mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-22 10:55:14 -04:00
loader: use BitPack for caps
This commit is contained in:
parent
38f942adf5
commit
0d8bde6079
2 changed files with 98 additions and 131 deletions
|
@ -33,7 +33,11 @@ namespace ams::util {
|
|||
static_assert(0 < Count && Count <= BITSIZEOF(IntegralStorageType));
|
||||
static_assert(Index + Count <= BITSIZEOF(IntegralStorageType));
|
||||
|
||||
return ((IntegralStorageType(1) << Count) - 1) << Index;
|
||||
if constexpr (Count == BITSIZEOF(IntegralStorageType)) {
|
||||
return ~IntegralStorageType(0);
|
||||
} else {
|
||||
return ((IntegralStorageType(1) << Count) - 1) << Index;
|
||||
}
|
||||
}();
|
||||
public:
|
||||
template<size_t _Index, size_t _Count, typename T>
|
||||
|
@ -52,6 +56,8 @@ namespace ams::util {
|
|||
private:
|
||||
IntegralStorageType value;
|
||||
public:
|
||||
constexpr ALWAYS_INLINE BitPack(IntegralStorageType v) : value(v) { /* ... */ }
|
||||
|
||||
constexpr ALWAYS_INLINE void Clear() {
|
||||
constexpr IntegralStorageType Zero = IntegralStorageType(0);
|
||||
this->value = Zero;
|
||||
|
@ -79,9 +85,9 @@ namespace ams::util {
|
|||
using BitPack32 = impl::BitPack<u32>;
|
||||
using BitPack64 = impl::BitPack<u64>;
|
||||
|
||||
static_assert(std::is_pod<BitPack8 >::value);
|
||||
static_assert(std::is_pod<BitPack16>::value);
|
||||
static_assert(std::is_pod<BitPack32>::value);
|
||||
static_assert(std::is_pod<BitPack64>::value);
|
||||
static_assert(std::is_trivially_destructible<BitPack8 >::value);
|
||||
static_assert(std::is_trivially_destructible<BitPack16>::value);
|
||||
static_assert(std::is_trivially_destructible<BitPack32>::value);
|
||||
static_assert(std::is_trivially_destructible<BitPack64>::value);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue