From 8af9b8c2b889d80c22d6bc26ba0df1afb79a30db Mon Sep 17 00:00:00 2001 From: gpike Date: Wed, 31 Jul 2013 23:34:41 +0000 Subject: [PATCH] Try harder to find bswap on various OSes. Also, change on instance of 'int' to 'size_t' to avoid a possible compiler warning. --- src/city.cc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/city.cc b/src/city.cc index b8aafab..41cd5ee 100644 --- a/src/city.cc +++ b/src/city.cc @@ -60,6 +60,24 @@ static uint32 UNALIGNED_LOAD32(const char *p) { #define bswap_32(x) OSSwapInt32(x) #define bswap_64(x) OSSwapInt64(x) +#elif defined(__sun) || defined(sun) + +#include +#define bswap_32(x) BSWAP_32(x) +#define bswap_64(x) BSWAP_64(x) + +#elif defined(__FreeBSD__) + +#include +#define bswap_32(x) bswap32(x) +#define bswap_64(x) bswap64(x) + +#elif defined(__OpenBSD__) + +#include +#define bswap_32(x) swap32(x) +#define bswap_64(x) swap64(x) + #elif defined(__NetBSD__) #include @@ -152,7 +170,7 @@ static uint32 Hash32Len13to24(const char *s, size_t len) { static uint32 Hash32Len0to4(const char *s, size_t len) { uint32 b = 0; uint32 c = 9; - for (int i = 0; i < len; i++) { + for (size_t i = 0; i < len; i++) { signed char v = s[i]; b = b * c1 + v; c ^= b;