Skip to content

Commit

Permalink
Try harder to find bswap on various OSes. Also, change on instance of…
Browse files Browse the repository at this point in the history
… 'int' to 'size_t' to avoid a possible compiler warning.
  • Loading branch information
gpike committed Jul 31, 2013
1 parent 34527e1 commit 8af9b8c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/city.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sys/byteorder.h>
#define bswap_32(x) BSWAP_32(x)
#define bswap_64(x) BSWAP_64(x)

#elif defined(__FreeBSD__)

#include <sys/endian.h>
#define bswap_32(x) bswap32(x)
#define bswap_64(x) bswap64(x)

#elif defined(__OpenBSD__)

#include <sys/types.h>
#define bswap_32(x) swap32(x)
#define bswap_64(x) swap64(x)

#elif defined(__NetBSD__)

#include <sys/types.h>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8af9b8c

Please sign in to comment.