File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 4646// compromising on hash quality.
4747
4848#include "spqrhash.h"
49- #include <byteswap.h>
49+ #include "port/pg_bswap.h"
5050
5151#if defined __GNUC__ && __GNUC__ >= 3
5252#define HAVE_BUILTIN_EXPECT 1
@@ -61,8 +61,13 @@ typedef struct city_uint128 city_uint128;
6161static inline uint64_t Uint128Low64 (const city_uint128 x ) { return x .first ; }
6262static inline uint64_t Uint128High64 (const city_uint128 x ) { return x .second ; }
6363
64- #define uint32_in_expected_order (x ) le32toh(x)
65- #define uint64_in_expected_order (x ) le64toh(x)
64+ #ifdef WORDS_BIGENDIAN
65+ #define uint32_in_expected_order (x ) pg_bswap32(x)
66+ #define uint64_in_expected_order (x ) pg_bswap64(x)
67+ #else
68+ #define uint32_in_expected_order (x ) (x)
69+ #define uint64_in_expected_order (x ) (x)
70+ #endif
6671
6772#if !defined(LIKELY )
6873#if HAVE_BUILTIN_EXPECT
@@ -213,9 +218,9 @@ static uint32_t CityHash32(const char *s, size_t len) {
213218 h = Rotate32 (h , 19 );
214219 h = h * 5 + 0xe6546b64 ;
215220 g ^= a4 ;
216- g = bswap_32 (g ) * 5 ;
221+ g = pg_bswap32 (g ) * 5 ;
217222 h += a4 * 5 ;
218- h = bswap_32 (h );
223+ h = pg_bswap32 (h );
219224 f += a0 ;
220225 tmp = f ;
221226 f = g ;
You can’t perform that action at this time.
0 commit comments