From 7e6485dd32c678c108f68280830e6a129655c49c Mon Sep 17 00:00:00 2001 From: Trond Norbye Date: Fri, 13 Mar 2009 11:23:44 +0100 Subject: [PATCH] Check if the operating system provides a working ntohll --- config/byteorder.m4 | 40 +++++++++++++++++++++++++++++++++++----- libmemcached/Makefile.am | 7 +++++-- libmemcached/common.h | 2 ++ 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/config/byteorder.m4 b/config/byteorder.m4 index fe88605a..0d8cc8f8 100644 --- a/config/byteorder.m4 +++ b/config/byteorder.m4 @@ -1,11 +1,41 @@ -AC_RUN_IFELSE([ - AC_LANG_PROGRAM([ +AC_DEFUN([DETECT_BYTEORDER], +[ + AC_MSG_CHECKING([for htonll]) + have_htoll="no" + AC_RUN_IFELSE([ + AC_LANG_PROGRAM([ #include #include #include - ], [ + ], [ + return htonll(0); + ]) + ], [ + have_htoll="yes" + AC_DEFINE([HAVE_HTONLL], [1], [Have ntohll]) + ]) + + AC_MSG_RESULT([$have_htoll]) + AM_CONDITIONAL([BUILD_BYTEORDER],[test "x$have_htoll" == "xno"]) + if test "x$have_htoll" == "xno" + then + AC_MSG_CHECKING([byteorder]) + have_htoll="no" + AC_RUN_IFELSE([ + AC_LANG_PROGRAM([ +#include +#include +#include + ], [ if (htonl(5) != 5) { return 1; } - ]) - ], AC_DEFINE([BYTEORDER_BIG_ENDIAN], [1], [Enable big endian byteorder])) + ]) + ], [ + AC_MSG_RESULT([big endian]) + AC_DEFINE([BYTEORDER_BIG_ENDIAN], [1], [Enable big endian byteorder]) + ], AC_MSG_RESULT([little endian])) + fi +]) + +DETECT_BYTEORDER diff --git a/libmemcached/Makefile.am b/libmemcached/Makefile.am index bcb3cd65..8e5f85c5 100644 --- a/libmemcached/Makefile.am +++ b/libmemcached/Makefile.am @@ -61,8 +61,11 @@ libmemcached_la_SOURCES = crc.c \ memcached_verbosity.c \ memcached_version.c \ murmur_hash.c \ - jenkins_hash.c \ - byteorder.c + jenkins_hash.c + +if BUILD_BYTEORDER +libmemcached_la_SOURCES += byteorder.c +endif libmemcached_la_DEPENDENCIES = @DTRACE_OBJ@ libmemcached_la_LIBADD = @DTRACE_OBJ@ diff --git a/libmemcached/common.h b/libmemcached/common.h index d91c6b30..b7a65709 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -115,8 +115,10 @@ memcached_return run_distribution(memcached_st *ptr); uint32_t generate_hash(memcached_st *ptr, const char *key, size_t key_length); memcached_return memcached_server_remove(memcached_server_st *st_ptr); +#ifndef HAVE_HTONLL extern uint64_t ntohll(uint64_t); extern uint64_t htonll(uint64_t); +#endif memcached_return memcached_purge(memcached_server_st *ptr); -- 2.30.2