mirror of
https://github.com/zeldaret/botw
synced 2026-05-28 08:25:01 -04:00
18c60323a9
git subrepo clone https://github.com/open-ead/sead lib/sead subrepo: subdir: "lib/sead" merged: "1b66e825d" upstream: origin: "https://github.com/open-ead/sead" branch: "master" commit: "1b66e825d" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" git subrepo clone (merge) https://github.com/open-ead/nnheaders lib/NintendoSDK subrepo: subdir: "lib/NintendoSDK" merged: "9ee21399f" upstream: origin: "https://github.com/open-ead/nnheaders" branch: "master" commit: "9ee21399f" git-subrepo: version: "0.4.3" origin: "ssh://git@github.com/ingydotnet/git-subrepo" commit: "2f68596" git subrepo clone https://github.com/open-ead/agl lib/agl subrepo: subdir: "lib/agl" merged: "7c063271b" upstream: origin: "https://github.com/open-ead/agl" branch: "master" commit: "7c063271b" git-subrepo: version: "0.4.3" origin: "ssh://git@github.com/ingydotnet/git-subrepo" commit: "2f68596" git subrepo clone https://github.com/open-ead/EventFlow lib/EventFlow subrepo: subdir: "lib/EventFlow" merged: "c35d21b34" upstream: origin: "https://github.com/open-ead/EventFlow" branch: "master" commit: "c35d21b34" git-subrepo: version: "0.4.3" origin: "ssh://git@github.com/ingydotnet/git-subrepo" commit: "2f68596"
76 lines
1.3 KiB
C++
76 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#ifdef _MSC_VER
|
|
#include <stdlib.h>
|
|
#endif
|
|
|
|
#include <cstring>
|
|
#include <ore/Types.h>
|
|
|
|
namespace ore {
|
|
|
|
[[nodiscard]] inline u8 SwapEndian(u8 x) {
|
|
return x;
|
|
}
|
|
|
|
[[nodiscard]] inline u16 SwapEndian(u16 x) {
|
|
#ifdef _MSC_VER
|
|
return _byteswap_ushort(x);
|
|
#else
|
|
return __builtin_bswap16(x);
|
|
#endif
|
|
}
|
|
|
|
[[nodiscard]] inline u32 SwapEndian(u32 x) {
|
|
#ifdef _MSC_VER
|
|
return _byteswap_ulong(x);
|
|
#else
|
|
return __builtin_bswap32(x);
|
|
#endif
|
|
}
|
|
|
|
[[nodiscard]] inline u64 SwapEndian(u64 x) {
|
|
#ifdef _MSC_VER
|
|
return _byteswap_uint64(x);
|
|
#else
|
|
return __builtin_bswap64(x);
|
|
#endif
|
|
}
|
|
|
|
[[nodiscard]] inline s8 SwapEndian(s8 x) {
|
|
return SwapEndian(u8(x));
|
|
}
|
|
|
|
[[nodiscard]] inline s16 SwapEndian(s16 x) {
|
|
return SwapEndian(u16(x));
|
|
}
|
|
|
|
[[nodiscard]] inline s32 SwapEndian(s32 x) {
|
|
return SwapEndian(u32(x));
|
|
}
|
|
|
|
[[nodiscard]] inline s64 SwapEndian(s64 x) {
|
|
return SwapEndian(u64(x));
|
|
}
|
|
|
|
[[nodiscard]] inline f32 SwapEndian(f32 x) {
|
|
static_assert(sizeof(u32) == sizeof(f32));
|
|
u32 i;
|
|
std::memcpy(&i, &x, sizeof(i));
|
|
i = SwapEndian(i);
|
|
std::memcpy(&x, &i, sizeof(i));
|
|
return x;
|
|
}
|
|
|
|
template <typename T>
|
|
inline void SwapEndian(T* value) {
|
|
*value = SwapEndian(*value);
|
|
}
|
|
|
|
struct ResEndian {
|
|
char* base;
|
|
bool is_serializing;
|
|
};
|
|
|
|
} // namespace ore
|