From: Monty Taylor Date: Wed, 2 Dec 2009 03:09:57 +0000 (-0600) Subject: Made the byteorder test use standard endian test AC_C_BIGENDIAN. X-Git-Tag: 0.37~83^2~6 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;ds=sidebyside;h=a0fa9535659f0f5a9678406f47201bfd47245114;p=m6w6%2Flibmemcached Made the byteorder test use standard endian test AC_C_BIGENDIAN. --- diff --git a/libmemcached/byteorder.c b/libmemcached/byteorder.c index 5b1cf88b..24f8e8c6 100644 --- a/libmemcached/byteorder.c +++ b/libmemcached/byteorder.c @@ -3,7 +3,7 @@ /* Byte swap a 64-bit number. */ static inline uint64_t swap64(uint64_t in) { -#ifndef BYTEORDER_BIG_ENDIAN +#ifndef WORDS_BIGENDIAN /* Little endian, flip the bytes around until someone makes a faster/better * way to do this. */ uint64_t rv= 0; diff --git a/libmemcached/jenkins_hash.c b/libmemcached/jenkins_hash.c index e84cf3ed..e4aa4f19 100644 --- a/libmemcached/jenkins_hash.c +++ b/libmemcached/jenkins_hash.c @@ -63,7 +63,7 @@ uint32_t jenkins_hash(const void *key, size_t length, uint32_t initval) a = b = c = 0xdeadbeef + ((uint32_t)length) + initval; u.ptr = key; -#ifdef BYTEORDER_LITTLE_ENDIAN +#ifndef WORDS_BIGENDIAN if ((u.i & 0x3) == 0) { const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */ @@ -202,7 +202,7 @@ uint32_t jenkins_hash(const void *key, size_t length, uint32_t initval) case 0 : return c; default : return c; } -#ifdef BYTEORDER_LITTLE_ENDIAN +#ifndef WORDS_BIGENDIAN } #endif diff --git a/m4/byteorder.m4 b/m4/byteorder.m4 index 7d2c99ba..4692bbd2 100644 --- a/m4/byteorder.m4 +++ b/m4/byteorder.m4 @@ -1,40 +1,25 @@ AC_DEFUN([DETECT_BYTEORDER], [ - AC_MSG_CHECKING([for htonll]) - have_htoll="no" + AC_REQUIRE([AC_C_BIGENDIAN]) + AC_CACHE_CHECK([for htonll],[av_cv_have_htonll],[ + AC_RUN_IFELSE([ - AC_LANG_PROGRAM([ + AC_LANG_PROGRAM([[ #include #include #include - ], [ + ]],[[ return htonll(0); - ]) + ]]) ], [ - have_htoll="yes" - AC_DEFINE([HAVE_HTONLL], [1], [Have ntohll]) - ]) + ac_cv_have_htonll=yes + ],[ + ac_cv_have_htonll=no + ])]) - AC_MSG_RESULT([$have_htoll]) - AM_CONDITIONAL([BUILD_BYTEORDER],[test "x$have_htoll" = "xno"]) - AC_MSG_CHECKING([byteorder]) - have_htoll="no" - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([ -#include -#include -#include - ], [ -if (htonl(5) != 5) { - return 1; -} - ]) - ], [ - AC_MSG_RESULT([big endian]) - AC_DEFINE([BYTEORDER_BIG_ENDIAN], [1], [Enable big endian byteorder]) - ], [ - AC_MSG_RESULT([little endian]) - AC_DEFINE([BYTEORDER_LITTLE_ENDIAN], [1], [Enable little endian byteorder]) - ]) + AS_IF([test "x$ac_cv_have_htonll" = "xyes"],[ + AC_DEFINE([HAVE_HTONLL], [1], [Have ntohll])]) + + AM_CONDITIONAL([BUILD_BYTEORDER],[test "x$ac_cv_have_htonll" = "xno"]) ])