31 #if defined(HAVE__BUILTIN_BSWAP16) 33 #define pg_bswap16(x) __builtin_bswap16(x) 35 #elif defined(_MSC_VER) 37 #define pg_bswap16(x) _byteswap_ushort(x) 53 #if defined(HAVE__BUILTIN_BSWAP32) 55 #define pg_bswap32(x) __builtin_bswap32(x) 57 #elif defined(_MSC_VER) 59 #define pg_bswap32(x) _byteswap_ulong(x) 67 ((x << 24) & 0xff000000) |
68 ((x << 8) & 0x00ff0000) |
69 ((x >> 8) & 0x0000ff00) |
70 ((x >> 24) & 0x000000ff);
77 #if defined(HAVE__BUILTIN_BSWAP64) 79 #define pg_bswap64(x) __builtin_bswap64(x) 82 #elif defined(_MSC_VER) 84 #define pg_bswap64(x) _byteswap_uint64(x) 92 ((x << 56) & UINT64CONST(0xff00000000000000)) |
93 ((x << 40) & UINT64CONST(0x00ff000000000000)) |
94 ((x << 24) & UINT64CONST(0x0000ff0000000000)) |
95 ((x << 8) & UINT64CONST(0x000000ff00000000)) |
96 ((x >> 8) & UINT64CONST(0x00000000ff000000)) |
97 ((x >> 24) & UINT64CONST(0x0000000000ff0000)) |
98 ((x >> 40) & UINT64CONST(0x000000000000ff00)) |
99 ((x >> 56) & UINT64CONST(0x00000000000000ff));
108 #ifdef WORDS_BIGENDIAN 110 #define pg_hton16(x) (x) 111 #define pg_hton32(x) (x) 112 #define pg_hton64(x) (x) 114 #define pg_ntoh16(x) (x) 115 #define pg_ntoh32(x) (x) 116 #define pg_ntoh64(x) (x) 120 #define pg_hton16(x) pg_bswap16(x) 121 #define pg_hton32(x) pg_bswap32(x) 122 #define pg_hton64(x) pg_bswap64(x) 124 #define pg_ntoh16(x) pg_bswap16(x) 125 #define pg_ntoh32(x) pg_bswap32(x) 126 #define pg_ntoh64(x) pg_bswap64(x) 150 #ifdef WORDS_BIGENDIAN 151 #define DatumBigEndianToNative(x) (x) 153 #if SIZEOF_DATUM == 8 154 #define DatumBigEndianToNative(x) pg_bswap64(x) 156 #define DatumBigEndianToNative(x) pg_bswap32(x)
static uint16 pg_bswap16(uint16 x)
static uint64 pg_bswap64(uint64 x)
static uint32 pg_bswap32(uint32 x)