Use __BIG_ENDIAN_

This also corrects the function name to be snake_case because it is
not a method.
This commit is contained in:
Josiah VanderZee 2024-05-22 07:55:27 -05:00 committed by Lars Mueller
parent 3a4dde48e8
commit b419d0e445

@ -218,16 +218,19 @@ T SelfType::Accessor<T>::get(std::size_t i) const
} }
// Note: clang and gcc should both optimize this out. // Note: clang and gcc should both optimize this out.
static inline bool isBigEndian() static inline bool is_big_endian()
{ {
const u16 x = 0xFF00; #ifdef __BIG_ENDIAN__
return *(const u8 *)(&x); return true;
#else
return false;
#endif
} }
template <typename T> template <typename T>
T SelfType::rawget(const void *ptr) T SelfType::rawget(const void *ptr)
{ {
if (!isBigEndian()) if (!is_big_endian())
return *reinterpret_cast<const T *>(ptr); return *reinterpret_cast<const T *>(ptr);
// glTF uses little endian. // glTF uses little endian.
// On big-endian systems, we have to swap the byte order. // On big-endian systems, we have to swap the byte order.