diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-10-25 11:43:15 +0200 |
---|---|---|
committer | dec05eba <0xdec05eba@gmail.com> | 2018-10-25 11:43:20 +0200 |
commit | fa94483682bd8bc996d633f38bf3a1018b48ab87 (patch) | |
tree | f4528fdc1a64457aa1cf470efdc4cece526470e3 /sibs | |
parent | 7947431ec1e837b2149e94b81e505fe4516ee5c6 (diff) |
Remove unused code2.0.1
Diffstat (limited to 'sibs')
-rw-r--r-- | sibs/SafeSerializer.hpp | 1 | ||||
-rw-r--r-- | sibs/endian.hpp | 99 |
2 files changed, 1 insertions, 99 deletions
diff --git a/sibs/SafeSerializer.hpp b/sibs/SafeSerializer.hpp index 68b6e7c..95e7807 100644 --- a/sibs/SafeSerializer.hpp +++ b/sibs/SafeSerializer.hpp @@ -25,6 +25,7 @@ namespace sibs void add(const T &data) { usize offset = buffer.size(); + (void)offset; buffer.insert(buffer.end(), (unsigned char*)&data, (unsigned char*)&data + sizeof(T)); #if BYTE_ORDER == BIG_ENDIAN std::reverse((char*)&buffer[offset], (char*)&buffer[offset] + sizeof(T)); 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; - } -} |