Check if the operating system provides a working ntohll
authorTrond Norbye <trond.norbye@sun.com>
Fri, 13 Mar 2009 10:23:44 +0000 (11:23 +0100)
committerTrond Norbye <trond.norbye@sun.com>
Fri, 13 Mar 2009 10:23:44 +0000 (11:23 +0100)
config/byteorder.m4
libmemcached/Makefile.am
libmemcached/common.h

index fe88605a0d9aba5b61bb68575798b7d338855982..0d8cc8f8920918b0024385ddcd9dd1e5800acbe6 100644 (file)
@@ -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 <sys/types.h>
 #include <netinet/in.h>
 #include <inttypes.h>
-      ], [
+       ], [
+          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 <sys/types.h>
+#include <netinet/in.h>
+#include <inttypes.h>
+          ], [
 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
index bcb3cd65cceade57a20658a01beb10d41804a152..8e5f85c51e1df2a42614dcc57dcc953448d51a81 100644 (file)
@@ -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@
index d91c6b302ec1bf7d4586832d56dd0be4b62144d5..b7a657092842dd2f9579456591ecce6e509ff387 100644 (file)
@@ -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);