X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fbyteorder.cc;h=9f11aa84b3e27bcc2c5003c1d62856fb42ee8c10;hb=22da6f6d6410053ac1f4682453b52463e6c9a05f;hp=7e141756000cc3a5977e5405d9ff1335d77e4a3c;hpb=7b7b8c93445a962375b17f1b22d1fb1b1f693484;p=awesomized%2Flibmemcached diff --git a/libmemcached/byteorder.cc b/libmemcached/byteorder.cc index 7e141756..9f11aa84 100644 --- a/libmemcached/byteorder.cc +++ b/libmemcached/byteorder.cc @@ -35,7 +35,8 @@ * */ -#include +#include "mem_config.h" +#include "libmemcached/byteorder.h" /* Byte swap a 64-bit number. */ #ifndef swap64 @@ -45,7 +46,7 @@ static inline uint64_t swap64(uint64_t in) /* Little endian, flip the bytes around until someone makes a faster/better * way to do this. */ uint64_t rv= 0; - for (uint8_t x= 0; x < 8; x++) + for (uint8_t x= 0; x < 8; ++x) { rv= (rv << 8) | (in & 0xff); in >>= 8; @@ -58,28 +59,21 @@ static inline uint64_t swap64(uint64_t in) } #endif -#ifdef HAVE_HTONLL uint64_t memcached_ntohll(uint64_t value) { +#ifdef HAVE_HTONLL return ntohll(value); -} - -uint64_t memcached_htonll(uint64_t value) -{ - return htonll(value); -} - -#else // HAVE_HTONLL - -uint64_t memcached_ntohll(uint64_t value) -{ +#else return swap64(value); +#endif } uint64_t memcached_htonll(uint64_t value) { +#ifdef HAVE_HTONLL + return htonll(value); +#else return swap64(value); +#endif } - -#endif // HAVE_HTONLL