X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fbyteorder.cc;h=44500add8832a8fd33ec318a874575e21a3ae623;hb=b220134a312e2a488810abfef510f5dbf59078a4;hp=80ea0210b9857dcab26a327bd815626829394404;hpb=28adf7b936c6f5c25b7526ff56ec1256da1246d4;p=awesomized%2Flibmemcached diff --git a/libmemcached/byteorder.cc b/libmemcached/byteorder.cc index 80ea0210..44500add 100644 --- a/libmemcached/byteorder.cc +++ b/libmemcached/byteorder.cc @@ -35,12 +35,8 @@ * */ -#include - -#include - -#include -#include +#include "mem_config.h" +#include "libmemcached/byteorder.h" /* Byte swap a 64-bit number. */ #ifndef swap64 @@ -50,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; @@ -63,28 +59,24 @@ static inline uint64_t swap64(uint64_t in) } #endif -#ifdef HAVE_HTONLL +#ifdef HAVE_SYS_TYPES_H +# include +#endif 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