mirror of
https://github.com/minetest/minetest.git
synced 2024-07-04 15:05:27 +02:00
Use __BIG_ENDIAN_
This also corrects the function name to be snake_case because it is not a method.
This commit is contained in:
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user