diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-10-25 11:43:15 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-06 07:16:10 +0200 |
commit | 81b3c9cfbdd99740320bfaf54eaf3929772f5eee (patch) | |
tree | 910a85f1f6d186cdabf1ae1bf8885771200074e9 /sibs/endian.hpp | |
parent | e792431b0aa754c50d2edbc8f48e682e359b562c (diff) |
Remove unused code
Diffstat (limited to 'sibs/endian.hpp')
-rw-r--r-- | sibs/endian.hpp | 99 |
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; - } -} |