Makefile.in
TAGS
aclocal.m4
+aminclude.am
autom4te.cache
autoscan.log
build-aux/
clients/memslap
clients/memstat
clients/memtouch
-mem_config.h
-mem_config.h.in
-mem_config.in
config.log
config.status
config/compile
config/missing
config/pandora_vc_revinfo
config/top.h
+configure
configure.scan
docs/*.[13]
docs/*.html
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
man/*.1
man/*.3
man/*.8
+man/.doctrees/
+mem_config.h
+mem_config.h.in
+mem_config.in
memcached/.git
memcached/.gitignore
memcached/memcached
tests/var/
tmp_chroot
unittests/unittests
-aminclude.am
+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.
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=
LT_PREREQ([2.2])
LT_INIT
LT_LANG([C++])
+LT_LIB_M
AX_ASSERT
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])
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])
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.
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])
[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"],
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"],
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
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
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"
.. c:type:: MEMCACHED_HASH_HSIEH
+.. c:type:: MEMCACHED_HASH_MURMUR3
+
Compile and link with -lmemcachedutil -lmemcached
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);
HASHKIT_HASH_HSIEH,
HASHKIT_HASH_MURMUR,
HASHKIT_HASH_JENKINS,
+ HASHKIT_HASH_MURMUR3,
HASHKIT_HASH_CUSTOM,
HASHKIT_HASH_MAX
} hashkit_hash_algorithm_t;
*/
-#include <libhashkit/common.h>
+#include "libhashkit/common.h"
-#include <libhashkit/rijndael.hpp>
+#include "libhashkit/rijndael.hpp"
#include <cstring>
*
*/
-#include <libhashkit/common.h>
+#include "libhashkit/common.h"
uint32_t libhashkit_one_at_a_time(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);
--- /dev/null
+/* 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);
#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" {
#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);
}
return HASHKIT_INVALID_ARGUMENT;
+ case HASHKIT_HASH_MURMUR3:
case HASHKIT_HASH_MURMUR:
if (libhashkit_has_algorithm(HASHKIT_HASH_MURMUR))
{
return false;
#endif
+ case HASHKIT_HASH_MURMUR3:
case HASHKIT_HASH_MURMUR:
#ifdef HAVE_MURMUR_HASH
return true;
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
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
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
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}
--- /dev/null
+//-----------------------------------------------------------------------------
+//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;
+}
+
+//-----------------------------------------------------------------------------
+
--- /dev/null
+//-----------------------------------------------------------------------------
+// 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);
+
+//-----------------------------------------------------------------------------
--- /dev/null
+/* 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;
+}
#include <assert.h>
#include <stdlib.h>
-#include <libhashkit/rijndael.hpp>
+#include "libhashkit/rijndael.hpp"
/*
Te0[x] = S [x].[02, 01, 01, 03];
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:
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
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
MEMCACHED_HASH_HSIEH,
MEMCACHED_HASH_MURMUR,
MEMCACHED_HASH_JENKINS,
+ MEMCACHED_HASH_MURMUR3,
MEMCACHED_HASH_CUSTOM,
MEMCACHED_HASH_MAX
};
/* 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
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
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
${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
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}
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
--- /dev/null
+/* 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);
+}
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
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
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
#include <libtest/common.h>
-#include <libmemcached-1.0/memcached.h>
-#include <libmemcachedutil-1.0/util.h>
-
#include <cassert>
#include <cerrno>
#include <cstdio>
# 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])
])
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"])
+ ])
_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])],
_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])])
#
# 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
[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"])
# 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
[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],
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>],[
# 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])
])
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;
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,
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));
{"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}
};
{"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}
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
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
#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;
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 *);
*/
-#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
#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"