PKG Installer fixed, u128 improved

This commit is contained in:
Nekotekina 2015-09-13 01:37:57 +03:00
parent 12f36cf31f
commit 4e62ec7458
12 changed files with 304 additions and 184 deletions

View file

@ -545,13 +545,13 @@ public:
type m_data; // don't access directly
#endif
static_assert(!std::is_class<type>::value, "be_t<> error: invalid type (class or structure)");
static_assert(!std::is_union<type>::value || std::is_same<type, v128>::value, "be_t<> error: invalid type (union)");
static_assert(!std::is_class<type>::value || std::is_same<type, u128>::value, "be_t<> error: invalid type (class or structure)");
static_assert(!std::is_union<type>::value || std::is_same<type, v128>::value || std::is_same<type, u128>::value, "be_t<> error: invalid type (union)");
static_assert(!std::is_pointer<type>::value, "be_t<> error: invalid type (pointer)");
static_assert(!std::is_reference<type>::value, "be_t<> error: invalid type (reference)");
static_assert(!std::is_array<type>::value, "be_t<> error: invalid type (array)");
static_assert(!std::is_enum<type>::value, "be_t<> error: invalid type (enumeration), use integral type instead");
static_assert(__alignof(type) == __alignof(stype), "be_t<> error: unexpected alignment");
static_assert(alignof(type) == alignof(stype), "be_t<> error: unexpected alignment");
be_t() = default;
@ -692,7 +692,7 @@ template<typename T> struct is_be_t<volatile T> : public std::integral_constant<
// to_be_t helper struct
template<typename T> struct to_be
{
using type = std::conditional_t<std::is_arithmetic<T>::value || std::is_enum<T>::value || std::is_same<T, v128>::value, be_t<T>, T>;
using type = std::conditional_t<std::is_arithmetic<T>::value || std::is_enum<T>::value || std::is_same<T, v128>::value || std::is_same<T, u128>::value, be_t<T>, T>;
};
// be_t<T> if possible, T otherwise
@ -724,13 +724,13 @@ public:
type m_data; // don't access directly
static_assert(!std::is_class<type>::value, "le_t<> error: invalid type (class or structure)");
static_assert(!std::is_union<type>::value || std::is_same<type, v128>::value, "le_t<> error: invalid type (union)");
static_assert(!std::is_class<type>::value || std::is_same<type, u128>::value, "le_t<> error: invalid type (class or structure)");
static_assert(!std::is_union<type>::value || std::is_same<type, v128>::value || std::is_same<T, u128>::value, "le_t<> error: invalid type (union)");
static_assert(!std::is_pointer<type>::value, "le_t<> error: invalid type (pointer)");
static_assert(!std::is_reference<type>::value, "le_t<> error: invalid type (reference)");
static_assert(!std::is_array<type>::value, "le_t<> error: invalid type (array)");
static_assert(!std::is_enum<type>::value, "le_t<> error: invalid type (enumeration), use integral type instead");
static_assert(__alignof(type) == __alignof(stype), "le_t<> error: unexpected alignment");
static_assert(alignof(type) == alignof(stype), "le_t<> error: unexpected alignment");
le_t() = default;
@ -807,7 +807,7 @@ template<typename T> struct is_le_t<volatile T> : public std::integral_constant<
template<typename T> struct to_le
{
using type = std::conditional_t<std::is_arithmetic<T>::value || std::is_enum<T>::value || std::is_same<T, v128>::value, le_t<T>, T>;
using type = std::conditional_t<std::is_arithmetic<T>::value || std::is_enum<T>::value || std::is_same<T, v128>::value || std::is_same<T, u128>::value, le_t<T>, T>;
};
// le_t<T> if possible, T otherwise

View file

@ -86,31 +86,147 @@ struct alignas(16) uint128_t
{
uint64_t lo, hi;
uint128_t& operator ++()
uint128_t() = default;
uint128_t(uint64_t l)
: lo(l)
, hi(0)
{
}
[[deprecated("Not implemented")]] inline uint128_t operator +(const uint128_t& r) const
{
return{};
}
inline uint128_t operator +(uint64_t r) const
{
uint128_t value;
value.lo = lo + r;
value.hi = value.lo < r ? hi + 1 : hi;
return value;
}
[[deprecated("Not implemented")]] inline uint128_t operator -(const uint128_t& r) const
{
return{};
}
inline uint128_t operator -(uint64_t r) const
{
uint128_t value;
value.lo = lo - r;
value.hi = lo < r ? hi - 1 : hi;
return value;
}
inline uint128_t operator +() const
{
return *this;
}
inline uint128_t operator -() const
{
uint128_t value;
value.lo = ~lo + 1;
value.hi = lo ? ~hi : ~hi + 1;
return value;
}
inline uint128_t& operator ++()
{
if (!++lo) ++hi;
return *this;
}
uint128_t& operator --()
{
if (!lo--) hi--;
return *this;
}
uint128_t operator ++(int)
inline uint128_t operator ++(int)
{
uint128_t value = *this;
if (!++lo) ++hi;
return value;
}
uint128_t operator --(int)
inline uint128_t& operator --()
{
if (!lo--) hi--;
return *this;
}
inline uint128_t operator --(int)
{
uint128_t value = *this;
if (!lo--) hi--;
return value;
}
inline uint128_t operator ~() const
{
uint128_t value;
value.lo = ~lo;
value.hi = ~hi;
return value;
}
inline uint128_t operator &(const uint128_t& r) const
{
uint128_t value;
value.lo = lo & r.lo;
value.hi = hi & r.hi;
return value;
}
inline uint128_t operator |(const uint128_t& r) const
{
uint128_t value;
value.lo = lo | r.lo;
value.hi = hi | r.hi;
return value;
}
inline uint128_t operator ^(const uint128_t& r) const
{
uint128_t value;
value.lo = lo ^ r.lo;
value.hi = hi ^ r.hi;
return value;
}
[[deprecated("Not implemented")]] inline uint128_t& operator +=(const uint128_t& r)
{
return *this;
}
inline uint128_t& operator +=(uint64_t r)
{
hi = (lo += r) < r ? hi + 1 : hi;
return *this;
}
[[deprecated("Not implemented")]] inline uint128_t& operator -=(const uint128_t& r)
{
return *this;
}
inline uint128_t& operator &=(const uint128_t& r)
{
lo &= r.lo;
hi &= r.hi;
return *this;
}
inline uint128_t& operator |=(const uint128_t& r)
{
lo |= r.lo;
hi |= r.hi;
return *this;
}
inline uint128_t& operator ^=(const uint128_t& r)
{
lo ^= r.lo;
hi ^= r.hi;
return *this;
}
};
using __uint128_t = uint128_t;