mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Split byte order routines out of utils.h
This commit is contained in:
@@ -344,46 +344,6 @@ int strIPtoInt(std::string& ipStr)
|
||||
|
||||
}
|
||||
*/
|
||||
#ifdef WIN32
|
||||
|
||||
//#include "Winsock2.h"
|
||||
//#include <windows.h>
|
||||
// from: http://stackoverflow.com/questions/3022552/is-there-any-standard-htonl-like-function-for-64-bits-integers-in-c
|
||||
// but we don't need to check the endianness
|
||||
uint64_t htobe64(uint64_t value)
|
||||
{
|
||||
// The answer is 42
|
||||
//static const int num = 42;
|
||||
|
||||
// Check the endianness
|
||||
//if (*reinterpret_cast<const char*>(&num) == num)
|
||||
//{
|
||||
const uint32_t high_part = htonl(static_cast<uint32_t>(value >> 32));
|
||||
const uint32_t low_part = htonl(static_cast<uint32_t>(value & 0xFFFFFFFFLL));
|
||||
|
||||
return (static_cast<uint64_t>(low_part) << 32) | high_part;
|
||||
//} else
|
||||
//{
|
||||
// return value;
|
||||
//}
|
||||
}
|
||||
|
||||
uint64_t be64toh(uint64_t value)
|
||||
{
|
||||
return(_byteswap_uint64(value));
|
||||
}
|
||||
|
||||
uint32_t htobe32(uint32_t value)
|
||||
{
|
||||
return(htonl(value));
|
||||
}
|
||||
|
||||
uint32_t be32toh(uint32_t value)
|
||||
{
|
||||
return( _byteswap_ulong(value));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PR_SET_NAME
|
||||
#define HAVE_NAME_THREAD
|
||||
|
||||
@@ -21,39 +21,6 @@
|
||||
|
||||
#define isSetBit(x,y) (!!((x) & (y)))
|
||||
|
||||
// maybe use http://www.mail-archive.com/licq-commits@googlegroups.com/msg02334.html
|
||||
#ifdef WIN32
|
||||
extern uint64_t htobe64(uint64_t value);
|
||||
extern uint64_t be64toh(uint64_t value);
|
||||
extern uint32_t htobe32(uint32_t value);
|
||||
extern uint32_t be32toh(uint32_t value);
|
||||
#elif __APPLE__
|
||||
#include <libkern/OSByteOrder.h>
|
||||
|
||||
#define htobe16(x) OSSwapHostToBigInt16(x)
|
||||
#define htole16(x) OSSwapHostToLittleInt16(x)
|
||||
#define be16toh(x) OSSwapBigToHostInt16(x)
|
||||
#define le16toh(x) OSSwapLittleToHostInt16(x)
|
||||
|
||||
#define htobe32(x) OSSwapHostToBigInt32(x)
|
||||
#define htole32(x) OSSwapHostToLittleInt32(x)
|
||||
#define be32toh(x) OSSwapBigToHostInt32(x)
|
||||
#define le32toh(x) OSSwapLittleToHostInt32(x)
|
||||
|
||||
#define htobe64(x) OSSwapHostToBigInt64(x)
|
||||
#define htole64(x) OSSwapHostToLittleInt64(x)
|
||||
#define be64toh(x) OSSwapBigToHostInt64(x)
|
||||
#define le64toh(x) OSSwapLittleToHostInt64(x)
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
#include <sys/endian.h>
|
||||
#elif defined(__OpenBSD__)
|
||||
#include <sys/types.h>
|
||||
#define be16toh(x) betoh16(x)
|
||||
#define be32toh(x) betoh32(x)
|
||||
#define be64toh(x) betoh64(x)
|
||||
#endif
|
||||
|
||||
|
||||
#define vt_f_black "\033[30m"
|
||||
#define vt_f_red "\033[31m"
|
||||
#define vt_f_green "\033[32m"
|
||||
|
||||
Reference in New Issue
Block a user