// LittleBigEndian.h fixed for 64-bits added union // #ifndef LITTLEBIGENDIAN_H #define LITTLEBIGENDIAN_H // Determine Little-Endian or Big-Endian #define CURRENT_BYTE_ORDER (*(int *)"\x01\x02\x03\x04") #define LITTLE_ENDIAN_BYTE_ORDER 0x04030201 #define BIG_ENDIAN_BYTE_ORDER 0x01020304 #define PDP_ENDIAN_BYTE_ORDER 0x02010403 #define IS_LITTLE_ENDIAN (CURRENT_BYTE_ORDER == LITTLE_ENDIAN_BYTE_ORDER) #define IS_BIG_ENDIAN (CURRENT_BYTE_ORDER == BIG_ENDIAN_BYTE_ORDER) #define IS_PDP_ENDIAN (CURRENT_BYTE_ORDER == PDP_ENDIAN_BYTE_ORDER) // Forward declaration template struct LittleEndian; template struct BigEndian; // Little-Endian template #pragma pack(push,1) template struct LittleEndian { union { unsigned char bytes[sizeof(T)]; T raw_value; }; LittleEndian(T t = T()) { operator =(t); } LittleEndian(const LittleEndian & t) { raw_value = t.raw_value; } LittleEndian(const BigEndian & t) { for (unsigned i = 0; i < sizeof(T); i++) bytes[i] = t.bytes[sizeof(T)-1-i]; } operator const T() const { T t = T(); for (unsigned i = 0; i < sizeof(T); i++) t |= T(bytes[i]) << (i << 3); return t; } const T operator = (const T t) { for (unsigned i = 0; i < sizeof(T); i++) bytes[sizeof(T)-1 - i] = static_cast(t >> (i << 3)); return t; } // operators const T operator += (const T t) { return (*this = *this + t); } const T operator -= (const T t) { return (*this = *this - t); } const T operator *= (const T t) { return (*this = *this * t); } const T operator /= (const T t) { return (*this = *this / t); } const T operator %= (const T t) { return (*this = *this % t); } LittleEndian operator ++ (int) { LittleEndian tmp(*this); operator ++ (); return tmp; } LittleEndian & operator ++ () { for (unsigned i = 0; i < sizeof(T); i++) { ++bytes[i]; if (bytes[i] != 0) break; } return (*this); } LittleEndian operator -- (int) { LittleEndian tmp(*this); operator -- (); return tmp; } LittleEndian & operator -- () { for (unsigned i = 0; i < sizeof(T); i++) { --bytes[i]; if (bytes[i] != (T)(-1)) break; } return (*this); } }; #pragma pack(pop) // Big-Endian template #pragma pack(push,1) template struct BigEndian { union { unsigned char bytes[sizeof(T)]; T raw_value; }; BigEndian(T t = T()) { operator =(t); } BigEndian(const BigEndian & t) { raw_value = t.raw_value; } BigEndian(const LittleEndian & t) { for (unsigned i = 0; i < sizeof(T); i++) bytes[i] = t.bytes[sizeof(T)-1-i]; } operator const T() const { T t = T(); for (unsigned i = 0; i < sizeof(T); i++) t |= T(bytes[sizeof(T) - 1 - i]) << (i << 3); return t; } const T operator = (const T t) { for (unsigned i = 0; i < sizeofHTTP/1.1 200 OK Cache-Control: public, max-age=21600, no-transform Content-Type: text/plain; charset=utf-8 Set-Cookie: i_like_gitea=8fcfd954311d4c00; Path=/; HttpOnly; Secure; SameSite=Lax Set-Cookie: _csrf=zvJTqAOHsHd0GAyQkkyWX0Scq1k6MTc1MzI2ODYxNTMzMzM3OTM3Mw; Path=/; Max-Age=86400; HttpOnly; Secure; SameSite=Lax Content-Length: 4725 Etag: "69f10ee9491928823daf9fd2002c47915c9e0b76" Last-Modified: Wed, 05 Feb 2014 05:14:07 GMT X-Frame-Options: SAMEORIGIN Connection: close Content-Disposition: inline; filename="LittleBigEndian.h"; filename*=UTF-8''LittleBigEndian.h X-Content-Type-Options: nosniff Date: Wed, 23 Jul 2025 11:03:35 GMT Access-Control-Expose-Headers: Content-Disposition X-Cache-Status: HIT X-Cache-Age: 0 // LittleBigEndian.h fixed for 64-bits added union // #ifndef LITTLEBIGENDIAN_H #define LITTLEBIGENDIAN_H // Determine Little-Endian or Big-Endian #define CURRENT_BYTE_ORDER (*(int *)"\x01\x02\x03\x04") #define LITTLE_ENDIAN_BYTE_ORDER 0x04030201 #define BIG_ENDIAN_BYTE_ORDER 0x01020304 #define PDP_ENDIAN_BYTE_ORDER 0x02010403 #define IS_LITTLE_ENDIAN (CURRENT_BYTE_ORDER == LITTLE_ENDIAN_BYTE_ORDER) #define IS_BIG_ENDIAN (CURRENT_BYTE_ORDER == BIG_ENDIAN_BYTE_ORDER) #define IS_PDP_ENDIAN (CURRENT_BYTE_ORDER == PDP_ENDIAN_BYTE_ORDER) // Forward declaration templa