aboutsummaryrefslogtreecommitdiff
path: root/sibs/endian.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-10-25 11:43:15 +0200
committerdec05eba <0xdec05eba@gmail.com>2018-10-25 11:43:20 +0200
commitfa94483682bd8bc996d633f38bf3a1018b48ab87 (patch)
treef4528fdc1a64457aa1cf470efdc4cece526470e3 /sibs/endian.hpp
parent7947431ec1e837b2149e94b81e505fe4516ee5c6 (diff)
Remove unused code2.0.1
Diffstat (limited to 'sibs/endian.hpp')
-rw-r--r--sibs/endian.hpp99
1 files changed, 0 insertions, 99 deletions
diff --git a/sibs/endian.hpp b/sibs/endian.hpp
index 13e6a31..14adeaa 100644
--- a/sibs/endian.hpp
+++ b/sibs/endian.hpp
@@ -58,102 +58,3 @@ defined(__alpha__) || defined(__alpha)
#endif
#endif
#endif
-
-#include "types.hpp"
-#include <cstdlib>
-
-namespace sibs
-{
- #if defined(_MSC_VER)
- static u16 byteswap(u16 value)
- {
- return _byteswap_ushort(value);
- }
- static u32 byteswap(u32 value)
- {
- return _byteswap_ulong(value);
- }
- static u64 byteswap(u64 value)
- {
- return _byteswap_uint64(value);
- }
- #elif defined(__GCC__)
- static u16 byteswap(u16 value)
- {
- return __builtin_bswap16(value);
- }
- static u32 byteswap(u32 value)
- {
- return __builtin_bswap32(value);
- }
- static u64 byteswap(u64 value)
- {
- return __builtin_bswap64(value);
- }
- #else
- static u16 byteswap(u16 value)
- {
- u16 result = 0;
- result |= (value & 0x00FF) << 8;
- result |= (value & 0xFF00) >> 8;
- return result;
- }
- static u32 byteswap(u32 value)
- {
- u32 result = 0;
- result |= (value & 0x000000FF) << 24;
- result |= (value & 0x0000FF00) << 8;
- result |= (value & 0x00FF0000) >> 8;
- result |= (value & 0xFF000000) >> 24;
- return result;
- }
- static u64 byteswap(u64 value)
- {
- u64 result = 0;
- result |= (value & 0x00000000000000FF) << 56;
- result |= (value & 0x000000000000FF00) << 40;
- result |= (value & 0x0000000000FF0000) << 24;
- result |= (value & 0x00000000FF000000) << 8;
- result |= (value & 0x000000FF00000000) >> 8;
- result |= (value & 0x0000FF0000000000) >> 24;
- result |= (value & 0x00FF000000000000) >> 40;
- result |= (value & 0xFF00000000000000) >> 56;
- return result;
- }
- #endif
-
- static u16 byteswap16(u16 value)
- {
- return byteswap(value);
- }
-
- static u32 byteswap32(u32 value)
- {
- return byteswap(value);
- }
-
- static u64 byteswap64(u64 value)
- {
- return byteswap(value);
- }
-
- enum class Endianness
- {
- LITTLE,
- BIG,
- MIDDLE, // TODO: Implement conversion from/to middle endian
- UNKNOWN
- };
-
- static Endianness getEndianness()
- {
- u32 endian = 0x12345678;
- u8 *endianByte = (u8*)&endian;
- if (endianByte[0] == (u8)0x78 && endianByte[1] == (u8)0x56)
- return Endianness::LITTLE;
- else if (endianByte[0] == (u8)0x12 && endianByte[1] == (u8)0x34)
- return Endianness::BIG;
- else
- return Endianness::UNKNOWN;
- }
-}