Merge lp:~tangent-org/libmemcached/1.0-build Build: jenkins-Libmemcached-1.0-119
authorContinuous Integration <ci@tangent.org>
Sun, 25 Nov 2012 14:14:51 +0000 (09:14 -0500)
committerContinuous Integration <ci@tangent.org>
Sun, 25 Nov 2012 14:14:51 +0000 (09:14 -0500)
45 files changed:
.bzrignore
ChangeLog
clients/include.am
configure.ac
docs/memcached_generate_hash_value.rst
libhashkit-1.0/algorithm.h
libhashkit-1.0/types.h
libhashkit/aes.cc
libhashkit/algorithm.cc
libhashkit/algorithm.h [new file with mode: 0644]
libhashkit/common.h
libhashkit/digest.cc
libhashkit/function.cc
libhashkit/has.cc
libhashkit/include.am
libhashkit/murmur3.cc [new file with mode: 0644]
libhashkit/murmur3.h [new file with mode: 0644]
libhashkit/murmur3_api.cc [new file with mode: 0644]
libhashkit/rijndael.cc
libhashkit/str_algorithm.cc
libmemcached-1.0/t/include.am
libmemcached-1.0/types/hash.h
libmemcached/backtrace.cc
libmemcached/include.am
libmemcachedinternal/include.am
libmemcachedprotocol/include.am
libmemcachedutil/include.am
libtest/backtrace_test.cc [new file with mode: 0644]
libtest/include.am
libtest/memcached.cc
m4/ax_check_library.m4
m4/ax_harden_compiler_flags.m4
m4/ax_libevent.m4
m4/ax_sasl.m4
m4/ax_uuid.m4
m4/libgearman.m4
tests/hash_plus.cc
tests/hash_results.h
tests/hashkit_functions.cc
tests/libmemcached-1.0/all_tests.h
tests/libmemcached-1.0/include.am
tests/libmemcached-1.0/mem_functions.cc
tests/libmemcached-1.0/mem_functions.h
util/instance.cc
util/instance.hpp

index f2156df5ae10d8b4dfb59a9e8661b2391fba1de0..18ba5811c2b770b9c05c1dbf70148c28028b4761 100644 (file)
@@ -29,6 +29,7 @@ Makefile
 Makefile.in
 TAGS
 aclocal.m4
+aminclude.am
 autom4te.cache
 autoscan.log
 build-aux/
@@ -46,9 +47,6 @@ clients/memrm
 clients/memslap
 clients/memstat
 clients/memtouch
-mem_config.h
-mem_config.h.in
-mem_config.in
 config.log
 config.status
 config/compile
@@ -60,6 +58,7 @@ config/ltmain.sh
 config/missing
 config/pandora_vc_revinfo
 config/top.h
+configure
 configure.scan
 docs/*.[13]
 docs/*.html
@@ -81,12 +80,17 @@ libmemcached-1.2/configure.h
 libmemcached-2.0/configure.h
 libmemcached-?.??/
 libmemcached/configure.h
+libmemcached/csl/parser.cc
+libmemcached/csl/parser.h
+libmemcached/csl/scanner.cc
+libmemcached/csl/scanner.h
 libmemcached/dtrace_probes.h
 libmemcached/generated_probes.h
 libmemcached/memcached_configure.h
 libtest/.hg/
 libtest/.hgignore
 libtest/abort
+libtest/core-count
 libtest/skiptest
 libtest/unittest
 libtest/version.h
@@ -101,6 +105,10 @@ m4/lt~obsolete.m4
 man/*.1
 man/*.3
 man/*.8
+man/.doctrees/
+mem_config.h
+mem_config.h.in
+mem_config.in
 memcached/.git
 memcached/.gitignore
 memcached/memcached
@@ -150,4 +158,3 @@ tests/testudp
 tests/var/
 tmp_chroot
 unittests/unittests
-aminclude.am
index ad76682bb37deeb75b221a5a0e0575d4ba5b26e8..e6efb8aba8a6da4f22b25af4ec3f51089ab02dfa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+1.0.15
+
+* Added support for Murmur3 (HASHKIT_HASH_MURMUR3)
+
 1.0.14 Wed Nov 14 04:56:25 EST 2012
 * CLIENT_ERROR fixed to not be treated as a fatal error.
 * Compiler fixes for older Ubuntu releases.
index 72fd39d4ed7a655479c56d64343a88715b3ccd54..bd38ef0420132ee9656b56bf93c34262c1527e64 100644 (file)
@@ -94,7 +94,7 @@ clients_memaslap_SOURCES+= clients/ms_thread.c
 
 clients_memaslap_SOURCES+= clients/generator.cc clients/execute.cc
 clients_memaslap_LDADD=
-clients_memaslap_LDADD+= @LIBEVENT_LDFLAGS@
+clients_memaslap_LDADD+= @LIBEVENT_LIB@
 clients_memaslap_LDADD+= $(CLIENTS_LDADDS)
 
 clients_memcapable_SOURCES=
index b255cefb2e30132e7c0a8d3bcff50a0cadbfa49e..0ca87389ad09fd472c69770ed14d2f762de311c8 100644 (file)
@@ -47,6 +47,7 @@ m4_include([libhashkit/include.m4])
 LT_PREREQ([2.2])
 LT_INIT
 LT_LANG([C++])
+LT_LIB_M
 
 AX_ASSERT
 
@@ -112,6 +113,7 @@ AC_CHECK_HEADERS_ONCE([dlfcn.h])
 AC_CHECK_HEADERS_ONCE([errno.h])
 AC_CHECK_HEADERS_ONCE([execinfo.h])
 AC_CHECK_HEADERS_ONCE([fcntl.h])
+AC_CHECK_HEADERS_ONCE([fnmatch.h])
 AC_CHECK_HEADERS_ONCE([inttypes.h])
 AC_CHECK_HEADERS_ONCE([libintl.h])
 AC_CHECK_HEADERS_ONCE([limits.h])
@@ -121,6 +123,7 @@ AC_CHECK_HEADERS_ONCE([math.h])
 AC_CHECK_HEADERS_ONCE([netdb.h])
 AC_CHECK_HEADERS_ONCE([netinet/in.h])
 AC_CHECK_HEADERS_ONCE([netinet/tcp.h])
+AC_CHECK_HEADERS_ONCE([poll.h])
 AC_CHECK_HEADERS_ONCE([pthread.h])
 AC_CHECK_HEADERS_ONCE([spawn.h])
 AC_CHECK_HEADERS_ONCE([stdarg.h])
@@ -131,13 +134,14 @@ AC_CHECK_HEADERS_ONCE([sys/socket.h])
 AC_CHECK_HEADERS_ONCE([sys/sysctl.h])
 AC_CHECK_HEADERS_ONCE([sys/time.h])
 AC_CHECK_HEADERS_ONCE([sys/un.h])
+AC_CHECK_HEADERS_ONCE([sys/wait.h])
 AC_CHECK_HEADERS_ONCE([syslog.h])
 AC_CHECK_HEADERS_ONCE([time.h])
 AC_CHECK_HEADERS_ONCE([unistd.h])
 
 # Windows only
-AC_CHECK_HEADERS([winsock2.h])
-AC_CHECK_HEADERS([ws2tcpip.h])
+AC_CHECK_HEADERS_ONCE([winsock2.h])
+AC_CHECK_HEADERS_ONCE([ws2tcpip.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 
@@ -160,6 +164,7 @@ AC_CHECK_FUNCS([pipe2])
 AC_CHECK_FUNCS([putenv])
 AC_CHECK_FUNCS([select])
 AC_CHECK_FUNCS([setenv])
+AC_CHECK_FUNCS([sigignore])
 AC_CHECK_FUNCS([socket])
 AC_CHECK_FUNCS([sqrt])
 AC_CHECK_FUNCS([strcasecmp])
@@ -214,14 +219,11 @@ AC_CHECK_LIB([rt],[clock_gettime],
              [AC_DEFINE([HAVE_CLOCK_GETTIME],[0],[Have clock_gettime])])
 
 # Check for the ability to call dlopen
-AS_IF([test "x$enable_static" = "xyes"],
+AS_IF([test "x$enable_shared" = xyes],
       [AC_CHECK_LIB([dl],[dlopen],
                     [AC_SUBST([DL_LIB],[-ldl])
                     AC_DEFINE([HAVE_LIBDL],[1],[Have dlopen])])],
-                    [AC_DEFINE([HAVE_LIBDL], [0], [Have dlopen])])
-
-AC_CHECK_LIB([m],[floor])
-AC_CHECK_FUNCS([sigignore])
+                    [AC_DEFINE([HAVE_LIBDL],[0],[Have dlopen])])
 
 AC_CHECK_HEADERS([atomic.h])
 AS_IF([test "x$ac_cv_header_atomic_h" = "xyes"],
@@ -251,7 +253,6 @@ AC_CHECK_FUNCS([setppriv],
                                 build_solaris_privs=yes])
                ])
 
-AC_CHECK_HEADERS_ONCE([winsock2.h poll.h sys/wait.h fnmatch.h])
 AM_CONDITIONAL([BUILD_POLL],[test "x$ac_cv_header_poll_h" = "xno"])
 AM_CONDITIONAL([BUILD_WIN32_WRAPPERS],[test "x$ac_cv_header_winsock2_h" = "xyes"])
 AS_IF([test "x$ac_cv_header_winsock2_h" = "xyes"],
@@ -263,7 +264,6 @@ SOCKET_SEND_FLAGS
 
 AX_UUID_GENERATE_TIME_SAFE
 
-
 AC_DEFUN([CHECK_FOR_PTHREAD_AND_SASL],
          [AX_PTHREAD(, [AC_MSG_ERROR([could not find libpthread])])
          AX_PTHREAD_TIMEDJOIN_NP
@@ -279,9 +279,10 @@ AC_DEFUN([CHECK_FOR_PTHREAD_AND_SASL],
 CHECK_FOR_PTHREAD_AND_SASL
 
 
-# backtrace() does not work with static builds.
-AS_IF([test "x$enable_static" = "xyes"],
-      [AC_DEFINE([AX_ENABLE_BACKTRACE],[1],[Support for backtrace().])])
+# backtrace(), others require shared builds
+AS_IF([test "x$enable_shared" = "xyes"],
+      [AC_DEFINE([HAVE_SHARED_ENABLED],[1],[Enable code which requires shared library support. Like backtrace().])])
+AM_CONDITIONAL([SHARED_ENABLED],[test "x$enable_shared" = "xyes"])
 
 PANDORA_ENABLE_DTRACE
 HAVE_GCC_ATOMICS
@@ -313,6 +314,7 @@ echo "   * CPP Flags:                 $CPPFLAGS"
 echo "   * LIB Flags:                 $LIB"
 echo "   * Assertions enabled:        $ax_enable_assert"
 echo "   * Debug enabled:             $ax_enable_debug"
+echo "   * Shared:                    $enable_shared"
 echo "   * Warnings as failure:       $ac_cv_warnings_as_errors"
 echo "   * SASL support:              $ax_sasl_option"
 echo "   * make -j:                   $enable_jobserver"
index 5b835df9e6a48c1d710351abf533e8e3e3951cfe..9a9b5a6706316cac661d05824ddca2d7922dccdc 100644 (file)
@@ -40,6 +40,8 @@ SYNOPSIS
 
 .. c:type:: MEMCACHED_HASH_HSIEH
 
+.. c:type:: MEMCACHED_HASH_MURMUR3
+
 
 Compile and link with -lmemcachedutil -lmemcached
 
index b29e9c3ec1789d15a6743f015e65b89a93d47f02..72005aa15d09c90b3c5992c1f04e80a1fdd80b40 100644 (file)
@@ -71,42 +71,15 @@ uint32_t libhashkit_hsieh(const char *key, size_t key_length);
 HASHKIT_API
 uint32_t libhashkit_murmur(const char *key, size_t key_length);
 
+HASHKIT_API
+uint32_t libhashkit_murmur3(const char *key, size_t key_length);
+
 HASHKIT_API
 uint32_t libhashkit_jenkins(const char *key, size_t key_length);
 
 HASHKIT_API
 uint32_t libhashkit_md5(const char *key, size_t key_length);
 
-HASHKIT_LOCAL
-uint32_t hashkit_one_at_a_time(const char *key, size_t key_length, void *context);
-
-HASHKIT_LOCAL
-uint32_t hashkit_fnv1_64(const char *key, size_t key_length, void *context);
-
-HASHKIT_LOCAL
-uint32_t hashkit_fnv1a_64(const char *key, size_t key_length, void *context);
-
-HASHKIT_LOCAL
-uint32_t hashkit_fnv1_32(const char *key, size_t key_length, void *context);
-
-HASHKIT_LOCAL
-uint32_t hashkit_fnv1a_32(const char *key, size_t key_length, void *context);
-
-HASHKIT_LOCAL
-uint32_t hashkit_crc32(const char *key, size_t key_length, void *context);
-
-HASHKIT_LOCAL
-uint32_t hashkit_hsieh(const char *key, size_t key_length, void *context);
-
-HASHKIT_LOCAL
-uint32_t hashkit_murmur(const char *key, size_t key_length, void *context);
-
-HASHKIT_LOCAL
-uint32_t hashkit_jenkins(const char *key, size_t key_length, void *context);
-
-HASHKIT_LOCAL
-uint32_t hashkit_md5(const char *key, size_t key_length, void *context);
-
 HASHKIT_API
 void libhashkit_md5_signature(const unsigned char *key, size_t length, unsigned char *result);
 
index b2ce4278b8352431712748482db6f8a6e088d518..37c33eeb1c69dd9699e186759c28bc50aa88a39f 100644 (file)
@@ -68,6 +68,7 @@ typedef enum {
   HASHKIT_HASH_HSIEH,
   HASHKIT_HASH_MURMUR,
   HASHKIT_HASH_JENKINS,
+  HASHKIT_HASH_MURMUR3,
   HASHKIT_HASH_CUSTOM,
   HASHKIT_HASH_MAX
 } hashkit_hash_algorithm_t;
index 2e91e07c55fb5efd7d83411cebbf5db7668c11c6..c7083a6e4adc3c83676195b59225770ac5876997 100644 (file)
@@ -35,9 +35,9 @@
  */
 
 
-#include <libhashkit/common.h>
+#include "libhashkit/common.h"
 
-#include <libhashkit/rijndael.hpp>
+#include "libhashkit/rijndael.hpp"
 
 #include <cstring>
 
index 0462df0bc66343307b933eaca2b39958ce20444a..3eb28d62fc1c7a0f91867a61d62e9b9f2bd18ec6 100644 (file)
@@ -34,7 +34,7 @@
  *
  */
 
-#include <libhashkit/common.h>
+#include "libhashkit/common.h"
 
 uint32_t libhashkit_one_at_a_time(const char *key, size_t key_length)
 {
@@ -71,6 +71,11 @@ uint32_t libhashkit_hsieh(const char *key, size_t key_length)
   return hashkit_hsieh(key, key_length, NULL);
 }
 
+uint32_t libhashkit_murmur3(const char *key, size_t key_length)
+{
+  return hashkit_murmur3(key, key_length, NULL);
+}
+
 uint32_t libhashkit_murmur(const char *key, size_t key_length)
 {
   return hashkit_murmur(key, key_length, NULL);
diff --git a/libhashkit/algorithm.h b/libhashkit/algorithm.h
new file mode 100644 (file)
index 0000000..93cdc1d
--- /dev/null
@@ -0,0 +1,66 @@
+/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ * 
+ *  HashKit library
+ *
+ *  Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/
+ *  Copyright (C) 2009 Brian Aker All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are
+ *  met:
+ *
+ *      * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ *
+ *      * Redistributions in binary form must reproduce the above
+ *  copyright notice, this list of conditions and the following disclaimer
+ *  in the documentation and/or other materials provided with the
+ *  distribution.
+ *
+ *      * The names of its contributors may not be used to endorse or
+ *  promote products derived from this software without specific prior
+ *  written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+
+/**
+ * @file
+ * @brief HashKit Header
+ */
+
+#pragma once
+
+uint32_t hashkit_one_at_a_time(const char *key, size_t key_length, void *context);
+
+uint32_t hashkit_fnv1_64(const char *key, size_t key_length, void *context);
+
+uint32_t hashkit_fnv1a_64(const char *key, size_t key_length, void *context);
+
+uint32_t hashkit_fnv1_32(const char *key, size_t key_length, void *context);
+
+uint32_t hashkit_fnv1a_32(const char *key, size_t key_length, void *context);
+
+uint32_t hashkit_crc32(const char *key, size_t key_length, void *context);
+
+uint32_t hashkit_hsieh(const char *key, size_t key_length, void *context);
+
+uint32_t hashkit_murmur(const char *key, size_t key_length, void *context);
+
+uint32_t hashkit_murmur3(const char *key, size_t key_length, void *context);
+
+uint32_t hashkit_jenkins(const char *key, size_t key_length, void *context);
+
+uint32_t hashkit_md5(const char *key, size_t key_length, void *context);
index 7affeb366a3f75ef138738f1ac82dbc36553cb63..43a859fe38dd80249c63c7308573f999e08541c7 100644 (file)
 #endif
 
 #include <libhashkit-1.0/hashkit.h>
-#include <libhashkit/is.h>
-#include <libhashkit/string.h>
-#include <libhashkit/aes.h>
+#include "libhashkit/algorithm.h"
+#include "libhashkit/is.h"
+#include "libhashkit/string.h"
+#include "libhashkit/aes.h"
 
 #ifdef __cplusplus
 extern "C" {
index 3b220d0842bdea66c7d3f2aebc4dba1b7f2438b3..2300293430b4fb8efcaeaf93af20d688f18122b2 100644 (file)
@@ -66,6 +66,9 @@ uint32_t libhashkit_digest(const char *key, size_t key_length, hashkit_hash_algo
 #else
     return 1;
 #endif
+  case HASHKIT_HASH_MURMUR3:
+    return libhashkit_murmur3(key, key_length);
+
   case HASHKIT_HASH_MURMUR:
 #ifdef HAVE_MURMUR_HASH
     return libhashkit_murmur(key, key_length);
index 044ca07dd8202f7069972a2ff102bff9b66b250d..bee87ff78a263b6557581f4adecfff1b2b440fcd 100644 (file)
@@ -57,6 +57,7 @@ static hashkit_return_t _set_function(struct hashkit_st::hashkit_function_st *se
     }
     return HASHKIT_INVALID_ARGUMENT;
 
+  case HASHKIT_HASH_MURMUR3:
   case HASHKIT_HASH_MURMUR:
     if (libhashkit_has_algorithm(HASHKIT_HASH_MURMUR))
     {
index 2230a56a73f8d88d5f1fbefecc009a91ae1a353d..843e32e41e36f69b6b383af767360150d4794664 100644 (file)
@@ -57,6 +57,7 @@ bool libhashkit_has_algorithm(const hashkit_hash_algorithm_t algo)
     return false;
 #endif
 
+  case HASHKIT_HASH_MURMUR3:
   case HASHKIT_HASH_MURMUR:
 #ifdef HAVE_MURMUR_HASH
     return true;
index f24a6a4c9f8155ab5074bd95f2cc4bd9bdbc0e9d..cfbacddcdbf724a955c1d49fa23ae5fc9f3c3c27 100644 (file)
@@ -12,6 +12,8 @@
 lib_LTLIBRARIES+= libhashkit/libhashkit.la
 
 noinst_HEADERS+= libhashkit/aes.h
+noinst_HEADERS+= libhashkit/algorithm.h
+noinst_HEADERS+= libhashkit/murmur3.h
 noinst_HEADERS+= libhashkit/common.h
 noinst_HEADERS+= libhashkit/is.h
 noinst_HEADERS+= libhashkit/rijndael.hpp
@@ -20,29 +22,33 @@ noinst_HEADERS+= libhashkit/string.h
 
 nobase_include_HEADERS+= libhashkit/hashkit.h
 
+libhashkit_libhashkit_la_LIBADD=
 libhashkit_libhashkit_la_SOURCES=
 libhashkit_libhashkit_la_CXXFLAGS=
+libhashkit_libhashkit_la_CFLAGS=
 
 libhashkit_libhashkit_la_SOURCES+= libhashkit/aes.cc
-libhashkit_libhashkit_la_SOURCES+= libhashkit/algorithm.cc 
-libhashkit_libhashkit_la_SOURCES+= libhashkit/behavior.cc 
-libhashkit_libhashkit_la_SOURCES+= libhashkit/crc32.cc 
-libhashkit_libhashkit_la_SOURCES+= libhashkit/digest.cc 
+libhashkit_libhashkit_la_SOURCES+= libhashkit/algorithm.cc
+libhashkit_libhashkit_la_SOURCES+= libhashkit/behavior.cc
+libhashkit_libhashkit_la_SOURCES+= libhashkit/crc32.cc
+libhashkit_libhashkit_la_SOURCES+= libhashkit/digest.cc
 libhashkit_libhashkit_la_SOURCES+= libhashkit/encrypt.cc
-libhashkit_libhashkit_la_SOURCES+= libhashkit/fnv_32.cc 
-libhashkit_libhashkit_la_SOURCES+= libhashkit/fnv_64.cc 
-libhashkit_libhashkit_la_SOURCES+= libhashkit/function.cc 
-libhashkit_libhashkit_la_SOURCES+= libhashkit/has.cc 
-libhashkit_libhashkit_la_SOURCES+= libhashkit/hashkit.cc 
-libhashkit_libhashkit_la_SOURCES+= libhashkit/jenkins.cc 
-libhashkit_libhashkit_la_SOURCES+= libhashkit/ketama.cc 
-libhashkit_libhashkit_la_SOURCES+= libhashkit/md5.cc 
-libhashkit_libhashkit_la_SOURCES+= libhashkit/murmur.cc 
-libhashkit_libhashkit_la_SOURCES+= libhashkit/one_at_a_time.cc 
+libhashkit_libhashkit_la_SOURCES+= libhashkit/fnv_32.cc
+libhashkit_libhashkit_la_SOURCES+= libhashkit/fnv_64.cc
+libhashkit_libhashkit_la_SOURCES+= libhashkit/function.cc
+libhashkit_libhashkit_la_SOURCES+= libhashkit/has.cc
+libhashkit_libhashkit_la_SOURCES+= libhashkit/hashkit.cc
+libhashkit_libhashkit_la_SOURCES+= libhashkit/jenkins.cc
+libhashkit_libhashkit_la_SOURCES+= libhashkit/ketama.cc
+libhashkit_libhashkit_la_SOURCES+= libhashkit/md5.cc
+libhashkit_libhashkit_la_SOURCES+= libhashkit/murmur.cc
+libhashkit_libhashkit_la_SOURCES+= libhashkit/murmur3.cc
+libhashkit_libhashkit_la_SOURCES+= libhashkit/murmur3_api.cc
+libhashkit_libhashkit_la_SOURCES+= libhashkit/one_at_a_time.cc
 libhashkit_libhashkit_la_SOURCES+= libhashkit/rijndael.cc
-libhashkit_libhashkit_la_SOURCES+= libhashkit/str_algorithm.cc 
+libhashkit_libhashkit_la_SOURCES+= libhashkit/str_algorithm.cc
 libhashkit_libhashkit_la_SOURCES+= libhashkit/strerror.cc
-libhashkit_libhashkit_la_SOURCES+= libhashkit/string.cc 
+libhashkit_libhashkit_la_SOURCES+= libhashkit/string.cc
 
 if INCLUDE_HSIEH_SRC
 libhashkit_libhashkit_la_SOURCES+= libhashkit/hsieh.cc
@@ -51,8 +57,8 @@ libhashkit_libhashkit_la_SOURCES+= libhashkit/nohsieh.cc
 endif
 
 libhashkit_libhashkit_la_CXXFLAGS+= -DBUILDING_HASHKIT
+libhashkit_libhashkit_la_CFLAGS+= -DBUILDING_HASHKIT
 
-libhashkit_libhashkit_la_LIBADD=
 libhashkit_libhashkit_la_LDFLAGS= -version-info $(HASHKIT_LIBRARY_VERSION)
 
 # library used for testing
@@ -60,4 +66,4 @@ noinst_LTLIBRARIES+= libhashkit/libhashkitinc.la
 
 libhashkit_libhashkitinc_la_SOURCES= ${libhashkit_libhashkit_la_SOURCES}
 libhashkit_libhashkitinc_la_CFLAGS= ${libhashkit_libhashkit_la_CFLAGS}
-libhashkit_libhashkitinc_la_LDFLAGS=  $(LIBM)
+libhashkit_libhashkitinc_la_CXXFLAGS= ${libhashkit_libhashkit_la_CXXFLAGS}
diff --git a/libhashkit/murmur3.cc b/libhashkit/murmur3.cc
new file mode 100644 (file)
index 0000000..5a5666e
--- /dev/null
@@ -0,0 +1,317 @@
+//-----------------------------------------------------------------------------
+//MurmurHash3 was written by Austin Appleby, and is placed in the public
+//domain. The author hereby disclaims copyright to this source code.
+
+// Note - The x86 and x64 versions do _not_ produce the same results, as the
+// algorithms are optimized for their respective platforms. You can still
+// compile and run any of them on any platform, but your performance with the
+// non-native version will be less than optimal.
+
+#include "mem_config.h"
+
+#include "libhashkit/murmur3.h"
+
+//-----------------------------------------------------------------------------
+// Platform-specific functions and macros
+
+#ifdef __GNUC__
+#define FORCE_INLINE __attribute__((always_inline)) inline
+#else
+#define FORCE_INLINE inline
+#endif
+
+static FORCE_INLINE uint32_t rotl32 ( uint32_t x, int8_t r )
+{
+  return (x << r) | (x >> (32 - r));
+}
+
+static FORCE_INLINE uint64_t rotl64 ( uint64_t x, int8_t r )
+{
+  return (x << r) | (x >> (64 - r));
+}
+
+#define        ROTL32(x,y)     rotl32(x,y)
+#define ROTL64(x,y)    rotl64(x,y)
+
+#define BIG_CONSTANT(x) (x##LLU)
+
+//-----------------------------------------------------------------------------
+// Block read - if your platform needs to do endian-swapping or can only
+// handle aligned reads, do the conversion here
+
+#define getblock(p, i) (p[i])
+
+//-----------------------------------------------------------------------------
+// Finalization mix - force all bits of a hash block to avalanche
+
+static FORCE_INLINE uint32_t fmix32 ( uint32_t h )
+{
+  h ^= h >> 16;
+  h *= 0x85ebca6b;
+  h ^= h >> 13;
+  h *= 0xc2b2ae35;
+  h ^= h >> 16;
+
+  return h;
+}
+
+//----------
+
+static FORCE_INLINE uint64_t fmix64 ( uint64_t k )
+{
+  k ^= k >> 33;
+  k *= BIG_CONSTANT(0xff51afd7ed558ccd);
+  k ^= k >> 33;
+  k *= BIG_CONSTANT(0xc4ceb9fe1a85ec53);
+  k ^= k >> 33;
+
+  return k;
+}
+
+//-----------------------------------------------------------------------------
+
+void MurmurHash3_x86_32 ( const void * key, int len,
+                          uint32_t seed, void * out )
+{
+  const uint8_t * data = (const uint8_t*)key;
+  const int nblocks = len / 4;
+  int i;
+
+  uint32_t h1 = seed;
+
+  uint32_t c1 = 0xcc9e2d51;
+  uint32_t c2 = 0x1b873593;
+
+  //----------
+  // body
+
+  const uint32_t * blocks = (const uint32_t *)(data + nblocks*4);
+
+  for(i = -nblocks; i; i++)
+  {
+    uint32_t k1 = getblock(blocks,i);
+
+    k1 *= c1;
+    k1 = ROTL32(k1,15);
+    k1 *= c2;
+    
+    h1 ^= k1;
+    h1 = ROTL32(h1,13); 
+    h1 = h1*5+0xe6546b64;
+  }
+
+  //----------
+  // tail
+
+  const uint8_t * tail = (const uint8_t*)(data + nblocks*4);
+
+  uint32_t k1 = 0;
+
+  switch(len & 3)
+  {
+  case 3: k1 ^= tail[2] << 16;
+  case 2: k1 ^= tail[1] << 8;
+  case 1: k1 ^= tail[0];
+          k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
+  };
+
+  //----------
+  // finalization
+
+  h1 ^= len;
+
+  h1 = fmix32(h1);
+
+  *(uint32_t*)out = h1;
+} 
+
+//-----------------------------------------------------------------------------
+
+void MurmurHash3_x86_128 ( const void * key, const int len,
+                           uint32_t seed, void * out )
+{
+  const uint8_t * data = (const uint8_t*)key;
+  const int nblocks = len / 16;
+  int i;
+
+  uint32_t h1 = seed;
+  uint32_t h2 = seed;
+  uint32_t h3 = seed;
+  uint32_t h4 = seed;
+
+  uint32_t c1 = 0x239b961b; 
+  uint32_t c2 = 0xab0e9789;
+  uint32_t c3 = 0x38b34ae5; 
+  uint32_t c4 = 0xa1e38b93;
+
+  //----------
+  // body
+
+  const uint32_t * blocks = (const uint32_t *)(data + nblocks*16);
+
+  for(i = -nblocks; i; i++)
+  {
+    uint32_t k1 = getblock(blocks,i*4+0);
+    uint32_t k2 = getblock(blocks,i*4+1);
+    uint32_t k3 = getblock(blocks,i*4+2);
+    uint32_t k4 = getblock(blocks,i*4+3);
+
+    k1 *= c1; k1  = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
+
+    h1 = ROTL32(h1,19); h1 += h2; h1 = h1*5+0x561ccd1b;
+
+    k2 *= c2; k2  = ROTL32(k2,16); k2 *= c3; h2 ^= k2;
+
+    h2 = ROTL32(h2,17); h2 += h3; h2 = h2*5+0x0bcaa747;
+
+    k3 *= c3; k3  = ROTL32(k3,17); k3 *= c4; h3 ^= k3;
+
+    h3 = ROTL32(h3,15); h3 += h4; h3 = h3*5+0x96cd1c35;
+
+    k4 *= c4; k4  = ROTL32(k4,18); k4 *= c1; h4 ^= k4;
+
+    h4 = ROTL32(h4,13); h4 += h1; h4 = h4*5+0x32ac3b17;
+  }
+
+  //----------
+  // tail
+
+  const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
+
+  uint32_t k1 = 0;
+  uint32_t k2 = 0;
+  uint32_t k3 = 0;
+  uint32_t k4 = 0;
+
+  switch(len & 15)
+  {
+  case 15: k4 ^= tail[14] << 16;
+  case 14: k4 ^= tail[13] << 8;
+  case 13: k4 ^= tail[12] << 0;
+           k4 *= c4; k4  = ROTL32(k4,18); k4 *= c1; h4 ^= k4;
+
+  case 12: k3 ^= tail[11] << 24;
+  case 11: k3 ^= tail[10] << 16;
+  case 10: k3 ^= tail[ 9] << 8;
+  case  9: k3 ^= tail[ 8] << 0;
+           k3 *= c3; k3  = ROTL32(k3,17); k3 *= c4; h3 ^= k3;
+
+  case  8: k2 ^= tail[ 7] << 24;
+  case  7: k2 ^= tail[ 6] << 16;
+  case  6: k2 ^= tail[ 5] << 8;
+  case  5: k2 ^= tail[ 4] << 0;
+           k2 *= c2; k2  = ROTL32(k2,16); k2 *= c3; h2 ^= k2;
+
+  case  4: k1 ^= tail[ 3] << 24;
+  case  3: k1 ^= tail[ 2] << 16;
+  case  2: k1 ^= tail[ 1] << 8;
+  case  1: k1 ^= tail[ 0] << 0;
+           k1 *= c1; k1  = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
+  };
+
+  //----------
+  // finalization
+
+  h1 ^= len; h2 ^= len; h3 ^= len; h4 ^= len;
+
+  h1 += h2; h1 += h3; h1 += h4;
+  h2 += h1; h3 += h1; h4 += h1;
+
+  h1 = fmix32(h1);
+  h2 = fmix32(h2);
+  h3 = fmix32(h3);
+  h4 = fmix32(h4);
+
+  h1 += h2; h1 += h3; h1 += h4;
+  h2 += h1; h3 += h1; h4 += h1;
+
+  ((uint32_t*)out)[0] = h1;
+  ((uint32_t*)out)[1] = h2;
+  ((uint32_t*)out)[2] = h3;
+  ((uint32_t*)out)[3] = h4;
+}
+
+//-----------------------------------------------------------------------------
+
+void MurmurHash3_x64_128 ( const void * key, const int len,
+                           const uint32_t seed, void * out )
+{
+  const uint8_t * data = (const uint8_t*)key;
+  const int nblocks = len / 16;
+  int i;
+
+  uint64_t h1 = seed;
+  uint64_t h2 = seed;
+
+  uint64_t c1 = BIG_CONSTANT(0x87c37b91114253d5);
+  uint64_t c2 = BIG_CONSTANT(0x4cf5ad432745937f);
+
+  //----------
+  // body
+
+  const uint64_t * blocks = (const uint64_t *)(data);
+
+  for(i = 0; i < nblocks; i++)
+  {
+    uint64_t k1 = getblock(blocks,i*2+0);
+    uint64_t k2 = getblock(blocks,i*2+1);
+
+    k1 *= c1; k1  = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
+
+    h1 = ROTL64(h1,27); h1 += h2; h1 = h1*5+0x52dce729;
+
+    k2 *= c2; k2  = ROTL64(k2,33); k2 *= c1; h2 ^= k2;
+
+    h2 = ROTL64(h2,31); h2 += h1; h2 = h2*5+0x38495ab5;
+  }
+
+  //----------
+  // tail
+
+  const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
+
+  uint64_t k1 = 0;
+  uint64_t k2 = 0;
+
+  switch(len & 15)
+  {
+  case 15: k2 ^= (uint64_t)(tail[14]) << 48;
+  case 14: k2 ^= (uint64_t)(tail[13]) << 40;
+  case 13: k2 ^= (uint64_t)(tail[12]) << 32;
+  case 12: k2 ^= (uint64_t)(tail[11]) << 24;
+  case 11: k2 ^= (uint64_t)(tail[10]) << 16;
+  case 10: k2 ^= (uint64_t)(tail[ 9]) << 8;
+  case  9: k2 ^= (uint64_t)(tail[ 8]) << 0;
+           k2 *= c2; k2  = ROTL64(k2,33); k2 *= c1; h2 ^= k2;
+
+  case  8: k1 ^= (uint64_t)(tail[ 7]) << 56;
+  case  7: k1 ^= (uint64_t)(tail[ 6]) << 48;
+  case  6: k1 ^= (uint64_t)(tail[ 5]) << 40;
+  case  5: k1 ^= (uint64_t)(tail[ 4]) << 32;
+  case  4: k1 ^= (uint64_t)(tail[ 3]) << 24;
+  case  3: k1 ^= (uint64_t)(tail[ 2]) << 16;
+  case  2: k1 ^= (uint64_t)(tail[ 1]) << 8;
+  case  1: k1 ^= (uint64_t)(tail[ 0]) << 0;
+           k1 *= c1; k1  = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
+  };
+
+  //----------
+  // finalization
+
+  h1 ^= len; h2 ^= len;
+
+  h1 += h2;
+  h2 += h1;
+
+  h1 = fmix64(h1);
+  h2 = fmix64(h2);
+
+  h1 += h2;
+  h2 += h1;
+
+  ((uint64_t*)out)[0] = h1;
+  ((uint64_t*)out)[1] = h2;
+}
+
+//-----------------------------------------------------------------------------
+
diff --git a/libhashkit/murmur3.h b/libhashkit/murmur3.h
new file mode 100644 (file)
index 0000000..4eb4fa6
--- /dev/null
@@ -0,0 +1,16 @@
+//-----------------------------------------------------------------------------
+// MurmurHash3 was written by Austin Appleby, and is placed in the
+// public domain. The author hereby disclaims copyright to this source
+// code.
+
+#pragma once
+
+//-----------------------------------------------------------------------------
+
+void MurmurHash3_x86_32 (const void *key, int len, uint32_t seed, void *out);
+
+void MurmurHash3_x86_128(const void *key, int len, uint32_t seed, void *out);
+
+void MurmurHash3_x64_128(const void *key, int len, uint32_t seed, void *out);
+
+//-----------------------------------------------------------------------------
diff --git a/libhashkit/murmur3_api.cc b/libhashkit/murmur3_api.cc
new file mode 100644 (file)
index 0000000..137fd36
--- /dev/null
@@ -0,0 +1,49 @@
+/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ * 
+ *  HashKit library
+ *
+ *  Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are
+ *  met:
+ *
+ *      * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ *
+ *      * Redistributions in binary form must reproduce the above
+ *  copyright notice, this list of conditions and the following disclaimer
+ *  in the documentation and/or other materials provided with the
+ *  distribution.
+ *
+ *      * The names of its contributors may not be used to endorse or
+ *  promote products derived from this software without specific prior
+ *  written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "libhashkit/common.h"
+#include "libhashkit/murmur3.h"
+
+uint32_t hashkit_murmur3(const char *key, size_t length, void *)
+{
+  const uint32_t seed= (0xdeadbeef * (uint32_t)length);
+
+  uint32_t ret;
+  MurmurHash3_x86_32(key, length, seed, &ret);
+
+  return ret;
+}
index 24b736284e2178d5b32c2de2add6e7caec5b6d8f..93997ccb3cd5bba4408a777d7c119972fc5ebc41 100644 (file)
@@ -63,7 +63,7 @@
 #include <assert.h>
 #include <stdlib.h>
 
-#include <libhashkit/rijndael.hpp>
+#include "libhashkit/rijndael.hpp"
 
 /*
 Te0[x] = S [x].[02, 01, 01, 03];
index 0a0613bc6a9fccb68fe7fa5b80937041b784d560..b84a0bb745e8dd57d08892701f2e74122f29dd68 100644 (file)
@@ -49,6 +49,7 @@ const char * libhashkit_string_hash(hashkit_hash_algorithm_t type)
   case HASHKIT_HASH_FNV1A_32: return "FNV1A_32";
   case HASHKIT_HASH_HSIEH: return "HSIEH";
   case HASHKIT_HASH_MURMUR: return "MURMUR";
+  case HASHKIT_HASH_MURMUR3: return "MURMUR3";
   case HASHKIT_HASH_JENKINS: return "JENKINS";
   case HASHKIT_HASH_CUSTOM: return "CUSTOM";
   default:
index 967051144a46bf36e987aabee9c6fcd581d811e2..82136cd835208d737b1359edaf49f7154a513721 100644 (file)
@@ -10,6 +10,7 @@
 
 LIBMEMCACHED_1_0_TEST_PATH= libmemcached-1.0/t
  
+if SHARED_ENABLED
 # Test linking with C application
 libmemcached_1_0_t_c_test_SOURCES= libmemcached-1.0/t/c_test.c
 libmemcached_1_0_t_c_test_LDADD= libmemcached/libmemcached.la
@@ -17,16 +18,18 @@ libmemcached_1_0_t_c_test_DEPENDENCIES= libmemcached/libmemcached.la
 check_PROGRAMS+= libmemcached-1.0/t/c_test
 noinst_PROGRAMS+= libmemcached-1.0/t/c_test
 
-# Test linking with C++ application
-libmemcached_1_0_t_cc_test_SOURCES= libmemcached-1.0/t/cc_test.cc
-libmemcached_1_0_t_cc_test_LDADD= libmemcached/libmemcached.la
-libmemcached_1_0_t_cc_test_DEPENDENCIES= libmemcached/libmemcached.la
-check_PROGRAMS+= libmemcached-1.0/t/cc_test
-noinst_PROGRAMS+= libmemcached-1.0/t/cc_test
-
 # Test linking with C application/SASL include
 libmemcached_1_0_t_c_sasl_test_SOURCES= libmemcached-1.0/t/c_sasl_test.c
 libmemcached_1_0_t_c_sasl_test_LDADD= libmemcached/libmemcached.la
 libmemcached_1_0_t_c_sasl_test_DEPENDENCIES= libmemcached/libmemcached.la
 check_PROGRAMS+= libmemcached-1.0/t/c_sasl_test
 noinst_PROGRAMS+= libmemcached-1.0/t/c_sasl_test
+else
+endif
+
+# Test linking with C++ application
+libmemcached_1_0_t_cc_test_SOURCES= libmemcached-1.0/t/cc_test.cc
+libmemcached_1_0_t_cc_test_LDADD= libmemcached/libmemcached.la
+libmemcached_1_0_t_cc_test_DEPENDENCIES= libmemcached/libmemcached.la
+check_PROGRAMS+= libmemcached-1.0/t/cc_test
+noinst_PROGRAMS+= libmemcached-1.0/t/cc_test
index 7651eb1a17702988a99c5611926e6eb212d463c4..8eee4df7a534ed6f1e47cbcfd5513ec0242af6f8 100644 (file)
@@ -49,6 +49,7 @@ enum memcached_hash_t {
   MEMCACHED_HASH_HSIEH,
   MEMCACHED_HASH_MURMUR,
   MEMCACHED_HASH_JENKINS,
+  MEMCACHED_HASH_MURMUR3,
   MEMCACHED_HASH_CUSTOM,
   MEMCACHED_HASH_MAX
 };
index d297901615258460d6ace623259d90b9dd2009c5..782ea6a91f80d87e3cbca63cb8d62e269d2e85ba 100644 (file)
@@ -1,8 +1,8 @@
 /*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
  * 
- *  libmcachedd client library.
+ *  Libmemcached client library.
  *
- *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *  Copyright (C) 2012 Data Differential, http://datadifferential.com/
  *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
  *
  */
 
-#include <libmemcached/common.h>
+#include "mem_config.h"
 
-#ifdef HAVE_EXECINFO_H
-#  include <execinfo.h>
-#endif
+#include "libmemcached/backtrace.hpp"
 
-#ifdef HAVE_GCC_ABI_DEMANGLE
-#  include <cxxabi.h>
-#endif
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
 
-#ifdef HAVE_DLFCN_H
-#  include <dlfcn.h>
+#if defined(HAVE_SHARED_ENABLED) && HAVE_SHARED_ENABLED
+
+#ifdef HAVE_EXECINFO_H
+#include <execinfo.h>
 #endif
 
 #ifdef HAVE_GCC_ABI_DEMANGLE
-#  define USE_DEMANGLE 1
+# include <cxxabi.h>
+# define USE_DEMANGLE 1
 #else
-#  define USE_DEMANGLE 0
+# define USE_DEMANGLE 0
 #endif
 
+#ifdef HAVE_DLFCN_H
+# include <dlfcn.h>
+#endif   
+
 const int MAX_DEPTH= 50;
 
 void custom_backtrace(void)
 {
 #ifdef HAVE_EXECINFO_H
-  void *array[MAX_DEPTH];
+  void *backtrace_buffer[MAX_DEPTH +1];
 
-  int backtrace_size= backtrace(array, MAX_DEPTH);
-  fprintf(stderr, "Number of stack frames obtained: %d\n", backtrace_size);
+  int stack_frames= backtrace(backtrace_buffer, MAX_DEPTH);
+  if (stack_frames)
+  {
+    char **symbollist= backtrace_symbols(backtrace_buffer, stack_frames);
+    if (symbollist)
+    {
+      for (int x= 0; x < stack_frames; x++) 
+      {
+        bool was_demangled= false;
 
+        if (USE_DEMANGLE)
+        {
 #ifdef HAVE_DLFCN_H
-  Dl_info dlinfo;
-#endif
+          Dl_info dlinfo;
+          if (dladdr(backtrace_buffer[x], &dlinfo))
+          {
+            char demangled_buffer[1024];
+            const char *called_in= "<unresolved>";
+            if (dlinfo.dli_sname)
+            {
+              size_t demangled_size= sizeof(demangled_buffer);
+              int status;
+              char* demangled;
+              if ((demangled= abi::__cxa_demangle(dlinfo.dli_sname, demangled_buffer, &demangled_size, &status)))
+              {
+                called_in= demangled;
+                fprintf(stderr, "---> demangled: %s -> %s\n", demangled_buffer, demangled);
+              }
+              else
+              {
+                called_in= dlinfo.dli_sname;
+              }
 
-  for (int x= 0; x < backtrace_size; ++x)
-  {  
-#ifdef HAVE_DLFCN_H
-    if (dladdr(array[x], &dlinfo) == 0)
-    {
-      continue;
-    }
+              was_demangled= true;
+              fprintf(stderr, "#%d  %lp in %s at %s\n",
+                      x, backtrace_buffer[x],
+                      called_in,
+                      dlinfo.dli_fname);
+            }
+          }
 #endif
+        }
 
-    const char* symname= dlinfo.dli_sname;
+        if (was_demangled == false)
+        {
+          fprintf(stderr, "?%d  %lp in %s\n", x, backtrace_buffer[x], symbollist[x]);
+        }
+      }
 
-    int status;
-    char* demangled= abi::__cxa_demangle(symname, NULL, 0, &status);
-    if (status == 0 and demangled)
-    {
-      symname= demangled;
+      ::free(symbollist);
     }
+  }
+#endif // HAVE_EXECINFO_H
+}
 
-    printf("object: %s, function: %s\n", dlinfo.dli_fname, symname);
+#else // HAVE_SHARED_ENABLED
 
-    if (demangled)
-    {
-      free(demangled);
-    }
-  } 
-#endif // HAVE_EXECINFO_H
+void custom_backtrace(void)
+{
+  fprintf(stderr, "Backtrace null function called\n");
 }
+#endif // AX_ENABLE_BACKTRACE
index e230267ef49091bff28fa7ffbf22bce09338db28..2465b058c228ade522f9962458b03e7efea255f6 100644 (file)
@@ -52,8 +52,10 @@ noinst_HEADERS+= libmemcached/virtual_bucket.h
 noinst_HEADERS+= libmemcached/watchpoint.h
 
 lib_LTLIBRARIES+= libmemcached/libmemcached.la
+libmemcached_libmemcached_la_DEPENDENCIES=
+libmemcached_libmemcached_la_LIBADD=
+libmemcached_libmemcached_la_LDFLAGS=
 libmemcached_libmemcached_la_CFLAGS= -DBUILDING_LIBMEMCACHED
-
 libmemcached_libmemcached_la_CXXFLAGS= -DBUILDING_LIBMEMCACHED
 
 libmemcached_libmemcached_la_SOURCES+= libmemcached/instance.cc
@@ -110,17 +112,13 @@ libmemcached_libmemcached_la_SOURCES+= libmemcached/virtual_bucket.c
 
 libmemcached/options.cc: libmemcached/csl/parser.h
 
-
-libmemcached_libmemcached_la_DEPENDENCIES=
-libmemcached_libmemcached_la_LIBADD=
-libmemcached_libmemcached_la_LDFLAGS=
 libmemcached_libmemcached_la_LDFLAGS+= -version-info ${MEMCACHED_LIBRARY_VERSION}
-libmemcached_libmemcached_la_LDFLAGS+= @DL_LIB@
+libmemcached_libmemcached_la_LIBADD+= @DL_LIB@
 
 if HAVE_SASL
 libmemcached_libmemcached_la_CXXFLAGS+= @PTHREAD_CFLAGS@
 libmemcached_libmemcached_la_LIBADD+= @PTHREAD_LIBS@
-libmemcached_libmemcached_la_LIBADD+= @SASL_LDFLAGS@
+libmemcached_libmemcached_la_LIBADD+= @SASL_LIB@
 endif
 
 if HAVE_DTRACE
index 75e58d637b9a19f90048ea24d8c13ea881eebd54..fafef9a34151db604fb89e4a433186b26559b83b 100644 (file)
@@ -22,8 +22,6 @@ libmemcachedinternal_libmemcachedinternal_la_CXXFLAGS= \
                                                       ${AM_CXXFLAGS} \
                                                       ${NO_CONVERSION} \
                                                       -DBUILDING_LIBMEMCACHEDINTERNAL
-libmemcachedinternal_libmemcachedinternal_la_LDFLAGS=
-libmemcachedinternal_libmemcachedinternal_la_LDFLAGS+= @DL_LIB@
 libmemcachedinternal_libmemcachedinternal_la_LIBADD= $(libmemcached_libmemcached_la_LIBADD)
 libmemcachedinternal_libmemcachedinternal_la_DEPENDENCIES= $(libmemcached_libmemcached_la_DEPENDENCIES)
 endif
index dd350f5ad3ccee7ed0d61cb4a71eaa9519af25e3..6a004598ef02194ff1b6b86fe2d6828d69166ba6 100644 (file)
@@ -30,7 +30,7 @@ libmemcached_libmemcachedprotocol_la_CXXFLAGS+= -DBUILDING_LIBMEMCACHED
 libmemcached_libmemcachedprotocol_la_CXXFLAGS+= @PTHREAD_CFLAGS@
 
 libmemcached_libmemcachedprotocol_la_LIBADD=
-libmemcached_libmemcachedprotocol_la_LIBADD+= @LIBEVENT_LDFLAGS@
+libmemcached_libmemcachedprotocol_la_LIBADD+= @LIBEVENT_LIB@
 libmemcached_libmemcachedprotocol_la_LIBADD+= @PTHREAD_LIBS@
 libmemcached_libmemcachedprotocol_la_LDFLAGS= ${AM_LDFLAGS}
 libmemcached_libmemcachedprotocol_la_LDFLAGS+= -version-info ${MEMCACHED_PROTOCAL_LIBRARY_VERSION}
index 37d4846ee94f1476ceb0e98aebe517bb7196f22f..e0b1fe9597be3583328dcb55e118cd741ee584b5 100644 (file)
@@ -13,13 +13,17 @@ libmemcached_libmemcachedutil_la_SOURCES= \
                                          libmemcachedutil/ping.cc \
                                          libmemcachedutil/pool.cc \
                                          libmemcachedutil/version.cc
-libmemcached_libmemcachedutil_la_CXXFLAGS= \
+libmemcached_libmemcachedutil_la_LIBADD=
+libmemcached_libmemcachedutil_la_LDFLAGS=
+libmemcached_libmemcachedutil_la_CXXFLAGS=
+libmemcached_libmemcachedutil_la_DEPENDENCIES=
+libmemcached_libmemcachedutil_la_CXXFLAGS+= \
                                           ${AM_CXXFLAGS} \
                                           ${NO_CONVERSION} \
                                           -DBUILDING_LIBMEMCACHED
 libmemcached_libmemcachedutil_la_CXXFLAGS+= @PTHREAD_CFLAGS@
-libmemcached_libmemcachedutil_la_LIBADD= libmemcached/libmemcached.la
+libmemcached_libmemcachedutil_la_LDFLAGS+= ${AM_LDFLAGS} -version-info ${MEMCACHED_UTIL_LIBRARY_VERSION}
+libmemcached_libmemcachedutil_la_LIBADD+= libmemcached/libmemcached.la
 libmemcached_libmemcachedutil_la_LIBADD+= @PTHREAD_LIBS@
-libmemcached_libmemcachedutil_la_LDFLAGS= ${AM_LDFLAGS} -version-info ${MEMCACHED_UTIL_LIBRARY_VERSION}
-libmemcached_libmemcachedutil_la_DEPENDENCIES= libmemcached/libmemcached.la
+libmemcached_libmemcachedutil_la_DEPENDENCIES+= libmemcached/libmemcached.la
 
diff --git a/libtest/backtrace_test.cc b/libtest/backtrace_test.cc
new file mode 100644 (file)
index 0000000..d4af451
--- /dev/null
@@ -0,0 +1,123 @@
+/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ *  Data Differential YATL (i.e. libtest)  library
+ *
+ *  Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are
+ *  met:
+ *
+ *      * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ *
+ *      * Redistributions in binary form must reproduce the above
+ *  copyright notice, this list of conditions and the following disclaimer
+ *  in the documentation and/or other materials provided with the
+ *  distribution.
+ *
+ *      * The names of its contributors may not be used to endorse or
+ *  promote products derived from this software without specific prior
+ *  written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <cerrno>
+#include <csignal>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <iostream>
+
+#include "libmemcached/backtrace.hpp"
+
+class Test {
+public:
+  Test()
+  {
+  }
+
+  void call_backtrace()
+  {
+    std::cerr << __func__ << std::endl;
+    custom_backtrace();
+  }
+};
+
+void SIGSEGV_handler(int sig_num, siginfo_t* info, void* ucontext)
+{
+  std::cerr << __func__ << std::endl;
+  (void)sig_num;
+  (void)info;
+  (void)ucontext;
+
+  custom_backtrace();
+}
+
+int raise_SIGSEGV()
+{
+  std::cerr << std::endl << "Calling backtrace()" << std::endl;
+  custom_backtrace();
+  std::cerr << std::endl << "Calling raise()" << std::endl;
+  return raise(SIGSEGV);
+}
+
+int layer4()
+{
+  return raise_SIGSEGV();
+}
+
+int layer3()
+{
+  return layer4();
+}
+
+int layer2()
+{
+  return layer3();
+}
+
+int layer1()
+{
+  return layer2();
+}
+
+int main(int, char **)
+{
+  Test t;
+
+  t.call_backtrace();
+
+  struct sigaction sigact;
+
+  sigact.sa_sigaction= SIGSEGV_handler;
+  sigact.sa_flags= SA_RESTART | SA_SIGINFO;
+
+  if (sigaction(SIGSEGV, &sigact, (struct sigaction *)NULL) != 0)
+  {
+    std::cerr << "error setting signal handler for " << strsignal(SIGSEGV) << "(" <<  SIGSEGV << ")" << std::endl;
+
+    exit(EXIT_FAILURE);
+  }
+
+  int ret= layer1();
+  if (ret)
+  {
+    std::cerr << "raise() " << strerror(errno) << std::endl;
+    exit(EXIT_FAILURE);
+  }
+
+  exit(EXIT_SUCCESS);
+}
index b09fe364536d43027a5cfeafd54853db708201d1..0e495fafc4c2836e6e7488e443dfec6754ba5b53 100644 (file)
@@ -129,13 +129,13 @@ libtest_libtest_la_SOURCES+= libtest/tmpfile.cc
 libtest_libtest_la_SOURCES+= libtest/vchar.cc
 
 libtest_libtest_la_CXXFLAGS+= -DBUILDING_LIBTEST
-libtest_libtest_la_CXXFLAGS+= $(PTHREAD_CFLAGS)
+libtest_libtest_la_CXXFLAGS+= @PTHREAD_CFLAGS@
 libtest_libtest_la_CXXFLAGS+= -DLIBTEST_TEMP="\"tmp_chroot\""
 libtest_libtest_la_CXXFLAGS+= $(CURL_CFLAGS)
 
-libtest_libtest_la_LIBADD+= $(PTHREAD_LIBS)
 libtest_libtest_la_LIBADD+= $(CURL_LIBS)
-libtest_libtest_la_LIBADD+= $(RT_LIB)
+libtest_libtest_la_LIBADD+= @PTHREAD_LIBS@
+libtest_libtest_la_LIBADD+= @RT_LIB@
 
 libtest_libtest_la_DEPENDENCIES+= libtest_tmp_dir
 libtest_libtest_la_DEPENDENCIES+=libtest/abort
@@ -190,8 +190,7 @@ libtest_unittest_DEPENDENCIES+= libgearman/libgearman.la
 libtest_unittest_DEPENDENCIES+= gearmand/gearmand
 else
 if HAVE_LIBGEARMAN
-libtest_libtest_la_DEPENDENCIES+= libgearman/libgearman.la
-libtest_libtest_la_LIBADD+= $(libgearman_LIBS)
+libtest_libtest_la_LIBADD+= @LIBGEARMAN_LDFLAGS@
 libtest_libtest_la_SOURCES+= libtest/blobslap_worker.cc
 libtest_libtest_la_SOURCES+= libtest/gearmand.cc
 libtest_libtest_la_SOURCES+= util/instance.cc
@@ -260,3 +259,15 @@ noinst_PROGRAMS+= libtest/core-count
 
 libtest_abort_SOURCES= libtest/abort.cc
 noinst_PROGRAMS+= libtest/abort
+
+libtest_backtrace_SOURCES=
+libtest_backtrace_LDADD=
+libtest_backtrace_SOURCES+= libtest/backtrace_test.cc
+libtest_backtrace_SOURCES+= libmemcached/backtrace.cc
+libtest_backtrace_LDADD+= @DL_LIB@
+noinst_PROGRAMS+= libtest/backtrace
+test-backtrace: libtest/backtrace
+       @libtest/backtrace
+
+gdb-backtrace: libtest/backtrace
+       @$(GDB_COMMAND) libtest/backtrace
index d2ce941ea54147a3cc1ea630f4c18bc5c4e91aae..c54c6b9048b68fd7344626b38da16e5f777ee09e 100644 (file)
@@ -38,9 +38,6 @@
 
 #include <libtest/common.h>
 
-#include <libmemcached-1.0/memcached.h>
-#include <libmemcachedutil-1.0/util.h>
-
 #include <cassert>
 #include <cerrno>
 #include <cstdio>
index 5998c792553253ee29987e069410d1d744046552..8177acf04696fdb31e5573058a812dd93e4ca7a3 100644 (file)
@@ -60,7 +60,7 @@
 #   modified version of the Autoconf Macro, you may extend this special
 #   exception to the GPL to apply to your modified version as well.
 
-#serial 4
+#serial 6
 
 AC_DEFUN([AX_CHECK_LIBRARY], [
   AC_ARG_VAR($1[_CPPFLAGS], [C preprocessor flags for ]$1[ headers])
@@ -89,7 +89,11 @@ AC_DEFUN([AX_CHECK_LIBRARY], [
     ])
 
   AS_IF([test "$]AS_TR_SH([ax_cv_have_]$1)[" = "yes"],
-    AC_DEFINE([HAVE_]$1, [1], [Define to 1 if ]$1[ is found])
-      m4_ifval( m4_normalize([$4]), [$4]),
-    m4_ifval( m4_normalize([$5]), [$5]))
-])
+      [AC_DEFINE([HAVE_]$1, [1], [Define to 1 if ]$1[ is found])
+      AC_SUBST($1[_CPPFLAGS])
+      AC_SUBST($1[_LDFLAGS])
+      AC_SUBST($1[_LIB],[-l]$3)
+      m4_ifval( m4_normalize([$4]), [$4]), 
+      m4_ifval( m4_normalize([$5]), [$5])])
+  AM_CONDITIONAL([HAVE_]$1,[test "$]AS_TR_SH([ax_cv_have_]$1)[" = "yes"])
+  ])
index caab7853d1fd3240e60e65203297b23d2f3a9f95..3d5eb2e3500d0fdfb26c8a88124eb2239128df7c 100644 (file)
@@ -134,14 +134,15 @@ AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
           _APPEND_COMPILE_FLAGS_ERROR([-fwrapv])
           _APPEND_COMPILE_FLAGS_ERROR([-fmudflapt])
 
-          AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
-                [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])
-                AS_IF([test "x$ac_c_gcc_recent" = xyes],
-                      [_APPEND_COMPILE_FLAGS_ERROR([-D_FORTIFY_SOURCE=2])
-                      _APPEND_COMPILE_FLAGS_ERROR([-Wstack-protector])
-                      _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector])
-                      _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector-all])
-                      ])])
+          AS_IF([test "x$ax_enable_debug" = xno],
+            [AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
+                  [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])
+                  AS_IF([test "x$ac_c_gcc_recent" = xyes],
+                        [_APPEND_COMPILE_FLAGS_ERROR([-D_FORTIFY_SOURCE=2])
+                        _APPEND_COMPILE_FLAGS_ERROR([-Wstack-protector])
+                        _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector])
+                        _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector-all])
+                        ])])])
 
          AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
                [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])],
@@ -210,14 +211,15 @@ AC_DEFUN([_HARDEN_CXX_COMPILER_FLAGS],
             _APPEND_COMPILE_FLAGS_ERROR([-fwrapv])
             _APPEND_COMPILE_FLAGS_ERROR([-fmudflapt])
 
-            AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
+            AS_IF([test "x$ax_enable_debug" = xno],
+            [AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
                   [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])
                   AS_IF([test "x$ac_c_gcc_recent" = xyes],
                         [_APPEND_COMPILE_FLAGS_ERROR([-D_FORTIFY_SOURCE=2])
                         _APPEND_COMPILE_FLAGS_ERROR([-Wstack-protector])
                         _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector])
                         _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector-all])
-                        ])])
+                        ])])])
 
             AS_IF([test "x$ac_cv_warnings_as_errors" = xyes],
                   [_APPEND_COMPILE_FLAGS_ERROR([-Werror])])
index 41392f9d975899178188bcf992ae0d551759be8f..686bff23aa9d5da071bd4180a2d8bc4cb9d67c04 100644 (file)
@@ -3,7 +3,9 @@
 #
 # SYNOPSIS
 #
-#   AX_LIBEVENT(), AX_LIBEVENT2(), AX_LIBEVENT2_EVHTTP()
+#   AX_LIBEVENT([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) 
+#   AX_LIBEVENT2() 
+#   AX_LIBEVENT2_EVHTTP()
 #
 # DESCRIPTION
 #
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 2
+#serial 4
  
 AC_DEFUN([AX_LIBEVENT],
          [AC_PREREQ([2.63])dnl
          AC_CACHE_CHECK([test for a working libevent],[ax_cv_libevent],
-                        [AX_SAVE_FLAGS
-                        LIBS="-levent $LIBS"
-                        AC_LANG_PUSH([C])
-                        AC_RUN_IFELSE([
-                                      AC_LANG_PROGRAM([
+           [AX_SAVE_FLAGS
+           LIBS="-levent $LIBS"
+           AC_LANG_PUSH([C])
+           AC_RUN_IFELSE([AC_LANG_PROGRAM([
 #include <sys/types.h>
 #include <sys/time.h>
 #include <stdlib.h>
 #include <event.h>
-                                                      ],[
-                                                      struct event_base *tmp_event= event_init();
-                                                      event_base_free(tmp_event);
-                                                      ])],
-                                      [ax_cv_libevent=yes],
-                                      [ax_cv_libevent=no],
-                                      [AC_MSG_WARN([test program execution failed])])
-                        AC_LANG_POP
-                        AX_RESTORE_FLAGS
-                        ])
+               ],[
+               struct event_base *tmp_event= event_init();
+               event_base_free(tmp_event);
+               ])],
+             [ax_cv_libevent=yes],
+             [ax_cv_libevent=no],
+             [AC_MSG_WARN([test program execution failed])])
+           AC_LANG_POP
+           AX_RESTORE_FLAGS
+           ])
 
          AS_IF([test "x$ax_cv_libevent" = "xyes"],
-               [LIBEVENT_LDFLAGS="-levent"
-               AC_SUBST(LIBEVENT_LDFLAGS)
-               AC_DEFINE([HAVE_LIBEVENT],[1],[Define if event_init is present in event.h.])],
-               [AC_DEFINE([HAVE_LIBEVENT],[0],[Define if event_init is present in event.h.])])
+             [AC_SUBST([LIBEVENT_LIB],[-levent])
+             AC_DEFINE([HAVE_LIBEVENT],[1],[Define if event_init is present in event.h.])],
+             [AC_DEFINE([HAVE_LIBEVENT],[0],[Define if event_init is present in event.h.])])
 
          AM_CONDITIONAL(HAVE_LIBEVENT, test "x$ax_cv_libevent" = "xyes")
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+         AS_IF([test "x$ax_cv_libevent" = xyes],
+             [$1],
+             [$2])
          ])
 
-  AC_DEFUN([AX_LIBEVENT2],
-           [AC_REQUIRE([AX_LIBEVENT])
-           AC_CACHE_CHECK([test for a working libevent version 2],[ax_cv_libevent2],
-                          [AX_SAVE_FLAGS
-                          LIBS="-levent $LIBS"
-                          AC_LANG_PUSH([C])
-                          AC_RUN_IFELSE([
-                                        AC_LANG_PROGRAM([
+AC_DEFUN([AX_LIBEVENT2],
+    [AC_REQUIRE([AX_LIBEVENT])
+    AC_CACHE_CHECK([test for a working libevent version 2],[ax_cv_libevent2],
+      [AX_SAVE_FLAGS
+      LIBS="-levent $LIBS"
+      AC_LANG_PUSH([C])
+      AC_RUN_IFELSE([AC_LANG_PROGRAM([
 #include <sys/types.h>
 #include <sys/time.h>
 #include <stdlib.h>
 #include <event2/event.h>
-                                                        ],[
-                                                        struct event_base *tmp_event= event_init();
-                                                        event_base_free(tmp_event);
-                                                        ])],
-                                        [ax_cv_libevent2=yes],
-                                        [ax_cv_libevent2=no],
-                                        [AC_MSG_WARN([test program execution failed])])
-                          AC_LANG_POP
-                          AX_RESTORE_FLAGS
-                          ])
+          ],[
+          struct event_base *tmp_event= event_init();
+          event_base_free(tmp_event);
+          ])],
+        [ax_cv_libevent2=yes],
+        [ax_cv_libevent2=no],
+        [AC_MSG_WARN([test program execution failed])])
+      AC_LANG_POP([C])
+      AX_RESTORE_FLAGS
+      ])
 
-           AS_IF([test "x$ax_cv_libevent2" = xyes],
-                 [LIBEVENT2_LDFLAGS="-levent"
-                 AC_SUBST(LIBEVENT2_LDFLAGS)
-                 AC_DEFINE([HAVE_LIBEVENT2],[1],[Define if event_init is present in event2/event.h.])],
-                 [AC_DEFINE([HAVE_LIBEVENT2],[0],[Define if event_init is present in event2/event.h.])])
+    AS_IF([test "x$ax_cv_libevent2" = xyes],
+        [AC_SUBST([LIBEVENT2_LIB],[-levent])
+        AC_DEFINE([HAVE_LIBEVENT2],[1],[Define if event_init is present in event2/event.h.])],
+        [AC_DEFINE([HAVE_LIBEVENT2],[0],[Define if event_init is present in event2/event.h.])])
 
-           AM_CONDITIONAL([HAVE_LIBEVENT2], [test "x$ax_cv_libevent2" = xyes])
-           ])
+    AM_CONDITIONAL([HAVE_LIBEVENT2], [test "x$ax_cv_libevent2" = xyes])
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+    AS_IF([test "x$ax_cv_libevent2" = xyes],
+        [$1],
+        [$2])
+    ])dnl AX_LIBEVENT2
 
-  AC_DEFUN([AX_LIBEVENT2_EVHTTP],
-           [AC_REQUIRE([AX_LIBEVENT2])
-           AC_CACHE_CHECK([test for a working libevent2 evhttp interface], [ax_cv_libevent2_evhttp],
-                          [AX_SAVE_FLAGS
-                          LIBS="-levent $LIBS"
-                          AC_LANG_PUSH([C])
-                          AC_RUN_IFELSE([
-                                        AC_LANG_PROGRAM([
+# 
+AC_DEFUN([AX_LIBEVENT2_EVHTTP],
+    [AC_REQUIRE([AX_LIBEVENT2])
+    AC_CACHE_CHECK([test for a working libevent2 evhttp interface], [ax_cv_libevent2_evhttp],
+      [AX_SAVE_FLAGS
+      LIBS="-levent $LIBS"
+      AC_LANG_PUSH([C])
+      AC_RUN_IFELSE([AC_LANG_PROGRAM([
 #include <sys/types.h>
 #include <sys/time.h>
 #include <stdlib.h>
 #include <event2/event.h>
 #include <event2/http.h>
-                                                        ],[
-                                                        struct event_base *libbase= event_base_new();  
-                                                        struct evhttp *libsrvr= evhttp_new(libbase);
-                                                        ])],
-                                        [ax_cv_libevent2_evhttp=yes],
-                                        [ax_cv_libevent2_evhttp=no],
-                                        [AC_MSG_WARN([test program execution failed])])
-                          AC_LANG_POP
-                          AX_RESTORE_FLAGS
-                          ])
+          ],[
+          struct event_base *libbase= event_base_new();  
+          struct evhttp *libsrvr= evhttp_new(libbase);
+          ])],
+        [ax_cv_libevent2_evhttp=yes],
+        [ax_cv_libevent2_evhttp=no],
+        [AC_MSG_WARN([test program execution failed])])
+      AC_LANG_POP([C])
+      AX_RESTORE_FLAGS
+      ])
 
-           AS_IF([test "x$ax_cv_libevent2_evhttp" = "xyes"],
-                 [LIBEVENT2_LDFLAGS="-levent"
-                 AC_SUBST(LIBEVENT2_LDFLAGS)
-                 AC_DEFINE([HAVE_LIBEVENT2],[1],[Define if event_init is present in event2/event.h.])],
-                 [AC_DEFINE([HAVE_LIBEVENT2],[0],[Define if event_init is present in event2/event.h.])])
+    AS_IF([test "x$ax_cv_libevent2_evhttp" = "xyes"],
+        [AC_DEFINE([HAVE_LIBEVENT2_EVHTTP],[1],[Define if event_init is present in event2/http.h.])],
+        [AC_DEFINE([HAVE_LIBEVENT2_EVHTTP],[0],[Define if event_init is present in event2/http.h.])])
 
-           AM_CONDITIONAL([HAVE_LIBEVENT2_EVHTTP],[test "x$ax_cv_libevent2_evhttp" = xyes])
-           ])
+    AM_CONDITIONAL([HAVE_LIBEVENT2_EVHTTP],[test "x$ax_cv_libevent2_evhttp" = xyes])
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+    AS_IF([test "x$ax_cv_libevent2_evhttp" = xyes],
+        [$1],
+        [$2])
+    ])dnl AX_LIBEVENT2_EVHTTP
index 48b05c7474b2e505f6e8897fe852059459746ead..303fbd2bef5e1046ae6cca911a2132f6cf7cd9c3 100644 (file)
@@ -46,7 +46,7 @@ AC_DEFUN([AX_SASL_CHECK],
     [ax_sasl_check=no
     AX_CHECK_LIBRARY([LIBSASL],[sasl/sasl.h],[sasl2],
       [ax_sasl_check=yes
-      AC_SUBST([SASL_LDFLAGS],[[-lsasl2]])
+      AC_SUBST([SASL_LIB],[[-lsasl2]])
       ])
     AC_MSG_CHECKING([checking to see if sasl works])
     AC_MSG_RESULT(["$ax_sasl_check"])
index 6864b45c7170693c88f9c7fb68684207aa780ab2..93c5f89f2367791683bccd039df80f09677a045f 100644 (file)
@@ -21,7 +21,7 @@
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 5
+#serial 6
 
 AC_DEFUN([AX_UUID],
     [AC_PREREQ([2.63])dnl
@@ -62,14 +62,14 @@ AC_DEFUN([AX_UUID],
           [ax_libuuid=yes])
       ],[ax_libuuid=no])
 
-      AS_IF([test "$ax_libuuid" = yes],
+      AS_IF([test "x$ax_libuuid" = xyes],
           [AC_DEFINE([HAVE_UUID_UUID_H],[1],[Have uuid/uuid.h])
-          AS_IF([test "$ax_cv_libuuid_is_required" = yes],[ LIBUUID_LDFLAGS='-luuid' ])],
+          AS_IF([test "x$ax_cv_libuuid_is_required" = xyes],[ LIBUUID_LIB='-luuid' ])],
           [AC_DEFINE([HAVE_UUID_UUID_H],[0],[Have uuid/uuid.h])
           ])
 
-  AC_SUBST([LIBUUID_LDFLAGS])
-  AM_CONDITIONAL([HAVE_LIBUUID],[test "$ax_libuuid" = yes])
+  AC_SUBST([LIBUUID_LIB])
+  AM_CONDITIONAL([HAVE_LIBUUID],[test "x$ax_libuuid" = xyes])
   ])
 
   AC_DEFUN([AX_UUID_GENERATE_TIME_SAFE],
@@ -78,7 +78,7 @@ AC_DEFUN([AX_UUID],
       AC_CACHE_CHECK([for uuid_generate_time_safe],
         [ax_cv_uuid_generate_time_safe],
         [AX_SAVE_FLAGS
-        LIBS="$LIBUUID_LDFLAGS $LIBS"
+        LIBS="$LIBUUID_LIB $LIBS"
         AC_LANG_PUSH([C])
         AC_RUN_IFELSE([
           AC_LANG_PROGRAM([#include <uuid/uuid.h>],[
index 0501ed3e736116fd03aaef58bf0747122efb99a3..a95c289f8575635f10194e579d28ef85f35f9b10 100644 (file)
@@ -1,10 +1,9 @@
 # serial 1
 AC_DEFUN([CHECK_FOR_LIBGEARMAND],
-    [AX_CHECK_LIBRARY([LIBGEARMAN], [libgearman/gearmand.h], [gearman], 
+    [AX_CHECK_LIBRARY([LIBGEARMAN],[libgearman/gearman.h],[gearman], 
       [ax_check_for_libgearman=yes],
       [ax_check_for_libgearman=no])
     AS_IF([test "$ax_check_for_libgearman" = xyes],
       [AC_DEFINE([HAVE_LIBGEARMAN],[1],[Enables libgearman Support])],
       [AC_DEFINE([HAVE_LIBGEARMAN],[0],[Enables libgearman Support])])
-    AM_CONDITIONAL(HAVE_LIBGEARMAN,[test "$ax_check_for_libgearman" = xyes])
     ])
index 1fb2ef2a82300712650060a0bf93d96418153a9c..8675adef12a6e50afdeb06a7c6c8614d9470c38a 100644 (file)
@@ -130,6 +130,12 @@ static test_return_t set_function_test(void *)
       list= hsieh_values;
       break;
 
+    case HASHKIT_HASH_MURMUR3:
+#ifdef WORDS_BIGENDIAN
+      continue;
+#endif
+      list= murmur3_values;
+      break;
     case HASHKIT_HASH_MURMUR:
 #ifdef WORDS_BIGENDIAN
       continue;
index c05053a74810424db9f596e3d95c8bdb04b7e4e8..ce788b7c734c046a4584be1955c9b87f8689a86e 100644 (file)
@@ -113,8 +113,17 @@ static uint32_t murmur_values[]= {  4142305122U, 734504955U, 3802834688U, 407689
                                     264013145U, 3995512858U, 2400956718U, 2346666219U,
                                     926327338U, 442757446U, 1770805201U, 560483147U,
                                     3902279934U };
+
+static uint32_t murmur3_values[]= { 1120212521U, 1448785489U, 4186307405U, 2686268514U,
+                                    444808887U, 221750260U, 3074673162U, 1946933257U,
+                                    2826416675U, 2430719166U, 3200429559U, 297894347U,
+                                    732888124U, 4050076964U, 3298336176U, 1336207361U,
+                                    810553576U, 3748182674U, 3860119212U, 3439537197U,
+                                    3044240981U, 1464271804U, 3896193724U, 2915115798U,
+                                    1702843840U };
 #else
 static uint32_t murmur_values[]= {  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
+static uint32_t murmur3_values[]= {  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
 #endif
 
 static uint32_t jenkins_values[]= { 1442444624U, 4253821186U, 1885058256U, 2120131735U,
index 1e9ec7bd009784fdbeb44a4815cac1c446725092..9def30259865b83aa80a4c65815e7ffab9601c51 100644 (file)
@@ -262,6 +262,27 @@ static test_return_t hsieh_run (hashkit_st *)
   return TEST_SUCCESS;
 }
 
+static test_return_t murmur3_TEST(hashkit_st *)
+{
+  test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_MURMUR3));
+
+#ifdef WORDS_BIGENDIAN
+  (void)murmur3_values;
+  return TEST_SKIPPED;
+#else
+  uint32_t x;
+  const char **ptr;
+
+  for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
+  {
+    test_compare(murmur3_values[x],
+                 libhashkit_murmur3(*ptr, strlen(*ptr)));
+  }
+
+  return TEST_SUCCESS;
+#endif
+}
+
 static test_return_t murmur_run (hashkit_st *)
 {
   test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_MURMUR));
@@ -509,6 +530,7 @@ test_st hash_tests[] ={
   {"fnv1a_32", 0, (test_callback_fn*)fnv1a_32_run },
   {"hsieh", 0, (test_callback_fn*)hsieh_run },
   {"murmur", 0, (test_callback_fn*)murmur_run },
+  {"murmur3", 0, (test_callback_fn*)murmur3_TEST },
   {"jenkis", 0, (test_callback_fn*)jenkins_run },
   {0, 0, (test_callback_fn*)0}
 };
index 74e619d234bfc45c3df2321c0c727e5bf6d4895e..2da9c7e314b0ad127bf633f0667e15fe7004f7a3 100644 (file)
@@ -361,6 +361,7 @@ test_st hash_tests[] ={
   {"fnv1a_32", false, (test_callback_fn*)fnv1a_32_run },
   {"hsieh", false, (test_callback_fn*)hsieh_run },
   {"murmur", false, (test_callback_fn*)murmur_run },
+  {"murmur3", false, (test_callback_fn*)murmur3_TEST },
   {"jenkis", false, (test_callback_fn*)jenkins_run },
   {"memcached_get_hashkit", false, (test_callback_fn*)memcached_get_hashkit_test },
   {0, 0, (test_callback_fn*)0}
index 1add550fcde17e11eea86d509adc1f08c12addf8..499123d82c508e1559f2ad416eb7ba180e92c361 100644 (file)
@@ -108,7 +108,7 @@ tests_libmemcached_1_0_testapp_DEPENDENCIES+= libtest/libtest.la
 tests_libmemcached_1_0_testapp_DEPENDENCIES+= libhashkit/libhashkit.la
 tests_libmemcached_1_0_testapp_DEPENDENCIES+= libmemcached/libmemcachedutil.la
 
-tests_libmemcached_1_0_testapp_LDADD+= @LIBUUID_LDFLAGS@
+tests_libmemcached_1_0_testapp_LDADD+= @LIBUUID_LIB@
 tests_libmemcached_1_0_testapp_LDADD+= @PTHREAD_LIBS@
 tests_libmemcached_1_0_testapp_LDADD+= libmemcached/libmemcached.la
 tests_libmemcached_1_0_testapp_LDADD+= libmemcached/libmemcachedutil.la
@@ -164,7 +164,7 @@ tests_libmemcached_1_0_testsocket_DEPENDENCIES+= libtest/libtest.la
 tests_libmemcached_1_0_testsocket_DEPENDENCIES+= libhashkit/libhashkit.la
 tests_libmemcached_1_0_testsocket_DEPENDENCIES+= libmemcached/libmemcachedutil.la
 
-tests_libmemcached_1_0_testsocket_LDADD+= @LIBUUID_LDFLAGS@
+tests_libmemcached_1_0_testsocket_LDADD+= @LIBUUID_LIB@
 tests_libmemcached_1_0_testsocket_LDADD+= @PTHREAD_LIBS@
 tests_libmemcached_1_0_testsocket_LDADD+= libmemcached/libmemcached.la
 tests_libmemcached_1_0_testsocket_LDADD+= libmemcached/libmemcachedutil.la
index a0570884a7c8a690133bcaf16a06b979c1e5bf26..49be55da94aa8cee4e5f51d185d5d11482406456 100644 (file)
@@ -3683,6 +3683,27 @@ test_return_t murmur_run (memcached_st *)
 #endif
 }
 
+test_return_t murmur3_TEST(hashkit_st *)
+{
+  test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_MURMUR3));
+
+#ifdef WORDS_BIGENDIAN
+  (void)murmur3_values;
+  return TEST_SKIPPED;
+#else
+  uint32_t x;
+  const char **ptr;
+
+  for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++)
+  {
+    test_compare(murmur3_values[x],
+                 memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_MURMUR3));
+  }
+
+  return TEST_SUCCESS;
+#endif
+}
+
 test_return_t jenkins_run (memcached_st *)
 {
   uint32_t x;
index 104d44eefbd5cdd4282b2edadca6f15f21723848..b3c0bf57221735fad73d7dd314c85095a981e5cf 100644 (file)
@@ -114,6 +114,7 @@ test_return_t mget_result_test(memcached_st *memc);
 test_return_t mget_test(memcached_st *memc);
 test_return_t murmur_avaibility_test (memcached_st *memc);
 test_return_t murmur_run (memcached_st *);
+test_return_t murmur3_TEST(hashkit_st *);
 test_return_t noreply_test(memcached_st *memc);
 test_return_t one_at_a_time_run (memcached_st *);
 test_return_t output_ketama_weighted_keys(memcached_st *);
index a1665f36016ab0826363ff6d61d49decc7739d26..1b99739762d40e158b63a41a0c70688ca58503f9 100644 (file)
@@ -36,7 +36,7 @@
  */
 
 
-#include <mem_config.h>
+#include "mem_config.h"
 
 #include "util/instance.hpp"
 
 #include <sys/types.h>
 
 #ifdef HAVE_UNISTD_H
-#include <unistd.h>
+# include <unistd.h>
+#endif
+
+#ifndef INVALID_SOCKET
+# define INVALID_SOCKET -1
+#endif
+
+#ifndef SOCKET_ERROR
+# define SOCKET_ERROR -1
+#endif
+
+#ifndef get_socket_errno
+# define get_socket_errno() errno
+#endif
+
+#ifndef closesocket
+# define closesocket(a) close(a)
 #endif
 
 
index 1855ef8db2e592f19899f217f7529efca9f416f1..853cc00c4620b9e51fcfe52b9798b367bd545a29 100644 (file)
 
 #pragma once
 
-#include <cstdio>
-#include <cerrno>
 #include <cassert>
+#include <cerrno>
 #include <cstddef>
-#include <sys/socket.h>
+#include <cstdio>
+#include <netinet/in.h>
 #include <string>
+#include <sys/socket.h>
 
 #include "util/operation.hpp"