libmemcached-1.0.8/0000775000076400007640000000000011757025120014377 5ustar00brianbrian00000000000000libmemcached-1.0.8/config.in0000664000076400007640000004333211756761751016221 0ustar00brianbrian00000000000000/* config.in. Generated from configure.ac by autoheader. */ #pragma once /* _SYS_FEATURE_TESTS_H is Solaris, _FEATURES_H is GCC */ #if defined( _SYS_FEATURE_TESTS_H) || defined(_FEATURES_H) #error "You should include config.h as your first include file" #endif /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* the location of */ #undef CINTTYPES_H /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ #undef CRAY_STACKSEG_END /* the location of */ #undef CSTDINT_H /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA /* Define to 1 to enable debugging code. */ #undef DEBUG /* Support for DrizzleD */ #undef DRIZZLED_BINARY /* Another magical number */ #undef EAI_SYSTEM /* machine is bigendian */ #undef ENDIAN_BIG /* machine is littleendian */ #undef ENDIAN_LITTLE /* Name of the gearmand binary used in make test */ #undef GEARMAND_BINARY /* Support for Gearman Blobslap worker */ #undef GEARMAND_BLOBSLAP_WORKER /* Define to 1 if you have the `alarm' function. */ #undef HAVE_ALARM /* Define to 1 if you have `alloca', as a function or macro. */ #undef HAVE_ALLOCA /* Define to 1 if you have and it should be used (not on Ultrix). */ #undef HAVE_ALLOCA_H /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H /* Define to 1 if you have the header file. */ #undef HAVE_ASSERT_H /* Define to 1 if you have the `atomic_add_32' function. */ #undef HAVE_ATOMIC_ADD_32 /* Define to 1 if you have the `atomic_add_64' function. */ #undef HAVE_ATOMIC_ADD_64 /* Define to 1 if you have the header file. */ #undef HAVE_ATOMIC_H /* Have a working clock_gettime function */ #undef HAVE_CLOCK_GETTIME /* Define to 1 if you have the header file. */ #undef HAVE_CXXABI_H /* Define to 1 if you have the declaration of `strerror_r', and to 0 if you don't. */ #undef HAVE_DECL_STRERROR_R /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Support for DrizzleD */ #undef HAVE_DRIZZLED_BINARY /* Define this if you have an implementation of drop_privileges() */ #undef HAVE_DROP_PRIVILEGES /* Enables DTRACE Support */ #undef HAVE_DTRACE /* Define to 1 if you have the `dup2' function. */ #undef HAVE_DUP2 /* Define to 1 if you have the header file. */ #undef HAVE_ERRNO_H /* Define to 1 if you have the header file. */ #undef HAVE_EXECINFO_H /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the header file. */ #undef HAVE_FNMATCH_H /* Enables fnv64 hashing support */ #undef HAVE_FNV64_HASH /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK /* define if the compiler supports GCC C++ ABI name demangling */ #undef HAVE_GCC_ABI_DEMANGLE /* Define to 1 if compiler provides atomic builtins. */ #undef HAVE_GCC_ATOMIC_BUILTINS /* If Gearmand binary is available */ #undef HAVE_GEARMAND_BINARY /* Define to 1 if you have the `getline' function. */ #undef HAVE_GETLINE /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Enables hsieh hashing support */ #undef HAVE_HSIEH_HASH /* Have ntohll */ #undef HAVE_HTONLL /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `bind' library (-lbind). */ #undef HAVE_LIBBIND /* Support for libcurl */ #undef HAVE_LIBCURL /* Define to 1 if you have the `c_p' library (-lc_p). */ #undef HAVE_LIBC_P /* Support for libdrizzle */ #undef HAVE_LIBDRIZZLE /* Define to 1 if LIBEVENT is found */ #undef HAVE_LIBEVENT /* Enables libgearman Support */ #undef HAVE_LIBGEARMAN /* Define to 1 if you have the header file. */ #undef HAVE_LIBINTL_H /* Define to 1 if you have the `m' library (-lm). */ #undef HAVE_LIBM /* Enables libmemcached Support */ #undef HAVE_LIBMEMCACHED /* Define to 1 if you have the `mtmalloc' library (-lmtmalloc). */ #undef HAVE_LIBMTMALLOC /* Support for Postgres */ #undef HAVE_LIBPQ /* Have clock_gettime */ #undef HAVE_LIBRT /* Define to 1 if LIBSASL is found */ #undef HAVE_LIBSASL /* Define to 1 if you have the `socket' library (-lsocket). */ #undef HAVE_LIBSOCKET /* Define to 1 if you have the `tcmalloc' library (-ltcmalloc). */ #undef HAVE_LIBTCMALLOC /* Define to 1 if you have the `tcmalloc-minimal' library (-ltcmalloc-minimal). */ #undef HAVE_LIBTCMALLOC_MINIMAL /* Define to 1 if you have the `umem' library (-lumem). */ #undef HAVE_LIBUMEM /* Have libuuid */ #undef HAVE_LIBUUID /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #undef HAVE_MALLOC /* Define to 1 if you have the header file. */ #undef HAVE_MALLOC_H /* Define to 1 if you have the header file. */ #undef HAVE_MATH_H /* If Memcached binary is available */ #undef HAVE_MEMCACHED_BINARY /* Support for memcached_light */ #undef HAVE_MEMCACHED_LIGHT_BINARY /* Name of the memcached_sasl binary used in make test */ #undef HAVE_MEMCACHED_SASL_BINARY /* Define to 1 if you have the `memchr' function. */ #undef HAVE_MEMCHR /* Define to 1 if you have the `memmove' function. */ #undef HAVE_MEMMOVE /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have a MSG_DONTWAIT */ #undef HAVE_MSG_DONTWAIT /* Define to 1 if you have a MSG_MORE */ #undef HAVE_MSG_MORE /* Define to 1 if you have a MSG_NOSIGNAL */ #undef HAVE_MSG_NOSIGNAL /* Enables murmur hashing support */ #undef HAVE_MURMUR_HASH /* Define to 1 if you have the header file. */ #undef HAVE_NETDB_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if you have the `pipe2' function. */ #undef HAVE_PIPE2 /* Define to 1 if you have the header file. */ #undef HAVE_POLL_H /* Define if you have POSIX threads libraries and header files. */ #undef HAVE_PTHREAD /* Define to 1 if you have the header file. */ #undef HAVE_PTHREAD_H /* Have PTHREAD_PRIO_INHERIT. */ #undef HAVE_PTHREAD_PRIO_INHERIT /* Define to 1 if you have a working SO_RCVTIMEO */ #undef HAVE_RCVTIMEO /* Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise. */ #undef HAVE_REALLOC /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT /* Define to 1 if you have the `setenv' function. */ #undef HAVE_SETENV /* Define to 1 if you have the `setppriv' function. */ #undef HAVE_SETPPRIV /* Define to 1 if you have the `sigignore' function. */ #undef HAVE_SIGIGNORE /* Define to 1 if you have a working SO_SNDTIMEO */ #undef HAVE_SNDTIMEO /* Define to 1 if you have the `socket' function. */ #undef HAVE_SOCKET /* Define to 1 if you have the `sqrt' function. */ #undef HAVE_SQRT /* Define to 1 if you have the header file. */ #undef HAVE_STDARG_H /* Define to 1 if stdbool.h conforms to C99. */ #undef HAVE_STDBOOL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDDEF_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strcasecmp' function. */ #undef HAVE_STRCASECMP /* Define to 1 if you have the `strchr' function. */ #undef HAVE_STRCHR /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the `strerror_r' function. */ #undef HAVE_STRERROR_R /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL /* Define to 1 if you have the `strtoul' function. */ #undef HAVE_STRTOUL /* Define to 1 if you have the `strtoull' function. */ #undef HAVE_STRTOULL /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SDT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SYSCTL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_WAIT_H /* Define this if you have umem.h */ #undef HAVE_UMEM_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vfork' function. */ #undef HAVE_VFORK /* Define to 1 if you have the header file. */ #undef HAVE_VFORK_H /* Define to 1 or 0, depending whether the compiler supports simple visibility declarations. */ #undef HAVE_VISIBILITY /* Define to 1 if you have the header file. */ #undef HAVE_WINSOCK2_H /* Define to 1 if `fork' works. */ #undef HAVE_WORKING_FORK /* Define to 1 if `vfork' works. */ #undef HAVE_WORKING_VFORK /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* CPU of Build System */ #undef HOST_CPU /* OS of Build System */ #undef HOST_OS /* Vendor of Build System */ #undef HOST_VENDOR /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Name of the memcached binary used in make test */ #undef MEMCACHED_BINARY /* Support for memcached_light */ #undef MEMCACHED_LIGHT_BINARY /* Name of the memcached_sasl binary used in make test */ #undef MEMCACHED_SASL_BINARY /* Define to 1 if assertions should be disabled. */ #undef NDEBUG /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Version of the software */ #undef PANDORA_RELEASE_VERSION /* Define to necessary symbol if this constant uses a non-standard name on your system. */ #undef PTHREAD_CREATE_JOINABLE /* Size of long long as computed by sizeof() */ #undef SIZEOF_LONG_LONG /* The size of `off_t', as computed by sizeof. */ #undef SIZEOF_OFF_T /* Size of size_t as computed by sizeof() */ #undef SIZEOF_SIZE_T /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ #undef STACK_DIRECTION /* Define if ISO C++ 1998 header files are present. */ #undef STDCXX_98_HEADERS /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if strerror_r returns char *. */ #undef STRERROR_R_CHAR_P /* CPU of Target System */ #undef TARGET_CPU /* OS of Target System */ #undef TARGET_OS /* Whether we are building for FreeBSD */ #undef TARGET_OS_FREEBSD /* Whether we build for Linux */ #undef TARGET_OS_LINUX /* Whether we build for OSX */ #undef TARGET_OS_OSX /* Whether we are building for Solaris */ #undef TARGET_OS_SOLARIS /* Whether we are building for Windows */ #undef TARGET_OS_WINDOWS /* Vendor of Target System */ #undef TARGET_VENDOR /* Define to 1 if time_t is unsigned */ #undef TIME_T_UNSIGNED /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define to 1 if your declares `struct tm'. */ #undef TM_IN_SYS_TIME /* Define to true if you want to use functions from atomic.h */ #undef USE_ATOMIC_H /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE #endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # undef _GNU_SOURCE #endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # undef _POSIX_PTHREAD_SEMANTICS #endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # undef _TANDEM_SOURCE #endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # undef __EXTENSIONS__ #endif /* Version number of package */ #undef VERSION /* Version of Windows */ #undef WINVER /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES /* Define to 1 if on MINIX. */ #undef _MINIX /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ #undef _POSIX_1_SOURCE /* Define to 1 if you need to in order for `stat' and other things to work. */ #undef _POSIX_SOURCE /* Cause Sun Studio to not be quite so strict with standards conflicts */ #undef _STLP_NO_NEW_C_HEADERS /* Define for Solaris 2.5.1 so the uint32_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT32_T /* Define for Solaris 2.5.1 so the uint64_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT64_T /* Define for Solaris 2.5.1 so the uint8_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT8_T /* Magical number to make things work */ #undef _WIN32_WINNT /* Workaround for bug in FreeBSD headers */ #undef __APPLE_CC__ /* Use STDC Limit Macros in C++ */ #undef __STDC_LIMIT_MACROS /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to the type of a signed integer type of width exactly 16 bits if such a type exists and the standard includes do not define it. */ #undef int16_t /* Define to the type of a signed integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ #undef int32_t /* Define to the type of a signed integer type of width exactly 64 bits if such a type exists and the standard includes do not define it. */ #undef int64_t /* Define to the type of a signed integer type of width exactly 8 bits if such a type exists and the standard includes do not define it. */ #undef int8_t /* Define to rpl_malloc if the replacement function should be used. */ #undef malloc /* Define to `long int' if does not define. */ #undef off_t /* Define to `int' if does not define. */ #undef pid_t /* Define to rpl_realloc if the replacement function should be used. */ #undef realloc /* Define to the equivalent of the C99 'restrict' keyword, or to nothing if this is not supported. Do not define if restrict is supported directly. */ #undef restrict /* Work around a bug in Sun C++: it does not support _Restrict or __restrict__, even though the corresponding Sun C compiler ends up with "#define restrict _Restrict" or "#define restrict __restrict__" in the previous line. Perhaps some future version of Sun C++ will work with restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ #if defined __SUNPRO_CC && !defined __RESTRICT # define _Restrict # define __restrict__ #endif /* Define to `unsigned int' if does not define. */ #undef size_t /* Define to `int' if does not define. */ #undef ssize_t /* Define to the type of an unsigned integer type of width exactly 16 bits if such a type exists and the standard includes do not define it. */ #undef uint16_t /* Define to the type of an unsigned integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ #undef uint32_t /* Define to the type of an unsigned integer type of width exactly 64 bits if such a type exists and the standard includes do not define it. */ #undef uint64_t /* Define to the type of an unsigned integer type of width exactly 8 bits if such a type exists and the standard includes do not define it. */ #undef uint8_t /* Define as `fork' if `vfork' does not work. */ #undef vfork /* Define to empty if the keyword `volatile' does not work. Warning: valid code using `volatile' can become incorrect without. Disable with care. */ #undef volatile #ifndef HAVE_SYS_SOCKET_H # define SHUT_RD SD_RECEIVE # define SHUT_WR SD_SEND # define SHUT_RDWR SD_BOTH #endif #ifndef __STDC_FORMAT_MACROS # define __STDC_FORMAT_MACROS #endif #if defined(__cplusplus) # include CINTTYPES_H #else # include #endif #if !defined(HAVE_ULONG) && !defined(__USE_MISC) # define HAVE_ULONG 1 typedef unsigned long int ulong; #endif #define RPACKAGE "memcached" #define RVERSION "1.4.13" libmemcached-1.0.8/tests/0000775000076400007640000000000011757025120015541 5ustar00brianbrian00000000000000libmemcached-1.0.8/tests/error_conditions.h0000664000076400007640000000345411753573717021322 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif test_return_t memcached_increment_MEMCACHED_NO_SERVERS(memcached_st *junk); #ifdef __cplusplus } #endif libmemcached-1.0.8/tests/parser.cc0000664000076400007640000000742411753763014017362 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached 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 /* C++ interface test */ #include #include using namespace libtest; static test_return_t memcached_NULL_string_TEST(void*) { test_null(memcached(NULL, 75)); return TEST_SUCCESS; } static test_return_t memcached_zero_string_length_TEST(void*) { test_null(memcached("value", 0)); return TEST_SUCCESS; } static test_return_t putenv_localhost_quoted_TEST(void*) { char set_env[1024]; snprintf(set_env, sizeof(set_env), "LIBMEMCACHED=\"--server=localhost\""); test_zero(putenv(set_env)); test_null(memcached(NULL, 0)); return TEST_SUCCESS; } static test_return_t putenv_NULL_TEST(void*) { char set_env[1024]; snprintf(set_env, sizeof(set_env), "LIBMEMCACHED"); test_zero(putenv(set_env)); memcached_st *memc= memcached(NULL, 0); test_true(memc); memcached_free(memc); return TEST_SUCCESS; } static test_return_t putenv_NULL_TEST2(void*) { char set_env[1024]; snprintf(set_env, sizeof(set_env), "LIBMEMCACHED="); test_zero(putenv(set_env)); memcached_st *memc= memcached(NULL, 0); test_true(memc); memcached_free(memc); return TEST_SUCCESS; } static test_return_t putenv_localhost_TEST(void*) { char set_env[1024]; snprintf(set_env, sizeof(set_env), "LIBMEMCACHED=--server=localhost"); test_zero(putenv(set_env)); memcached_st *memc= memcached(NULL, 0); test_true(memc); memcached_free(memc); return TEST_SUCCESS; } test_st memcached_TESTS[] ={ {"memcached(NULL, 75)", false, (test_callback_fn*)memcached_NULL_string_TEST }, {"memcached(\"value\", 0)", false, (test_callback_fn*)memcached_zero_string_length_TEST }, {"putenv(LIBMEMCACHED=--server=localhost)", false, (test_callback_fn*)putenv_localhost_TEST }, {"putenv(LIBMEMCACHED)", false, (test_callback_fn*)putenv_NULL_TEST }, {"putenv(LIBMEMCACHED=)", false, (test_callback_fn*)putenv_NULL_TEST2 }, {"putenv(LIBMEMCACHED=--server=\"localhost\")", false, (test_callback_fn*)putenv_localhost_quoted_TEST }, {0, 0, 0} }; collection_st collection[] ={ {"memcached()", 0, 0, memcached_TESTS}, {0, 0, 0, 0} }; void get_world(Framework *world) { world->collections(collection); } libmemcached-1.0.8/tests/virtual_buckets.h0000664000076400007640000000350711753573717021145 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * Copyright (C) 2011 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. * */ #pragma once struct memcached_st; #ifdef __cplusplus extern "C" { #endif LIBTEST_LOCAL test_return_t virtual_back_map(memcached_st *); #ifdef __cplusplus } #endif libmemcached-1.0.8/tests/include.am0000664000076400007640000001105611753573717017526 0ustar00brianbrian00000000000000# vim:ft=automake # Copyright (C) 2011 Data Differential # All rights reserved. # # Use and distribution licensed under the BSD license. See # the COPYING file in the parent directory for full text. # # included from Top Level Makefile.am # All paths should be given relative to the root TESTS_LDADDS= TESTS_LDADDS+= libmemcached/libmemcached.la TESTS_LDADDS+= libmemcached/libmemcachedutil.la TESTS_LDADDS+= libtest/libtest.la DEBUG_COMMAND= $(LIBTOOL) --mode=execute gdb PAHOLE_COMMAND= $(LIBTOOL) --mode=execute pahole EXTRA_DIST+= tests/cpp_example.cc noinst_HEADERS+= tests/exist.h noinst_HEADERS+= tests/hash_results.h noinst_HEADERS+= tests/keys.hpp noinst_HEADERS+= tests/libmemcached_test_container.h noinst_HEADERS+= tests/libmemcached_world.h noinst_HEADERS+= tests/libmemcached_world_socket.h noinst_HEADERS+= tests/memc.h noinst_HEADERS+= tests/runner.h # Cycle should always run first tests_cycle_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING) tests_cycle_CXXFLAGS= $(AM_CXXFLAGS) tests_cycle_CXXFLAGS+= ${PTHREAD_CFLAGS} tests_cycle_SOURCES= tests/cycle.cc tests_cycle_DEPENDENCIES= $(TESTS_LDADDS) tests_cycle_LDADD= $(tests_cycle_DEPENDENCIES) tests_cycle_LDADD+= ${PTHREAD_LIBS} check_PROGRAMS+= tests/cycle noinst_PROGRAMS+= tests/cycle include tests/libmemcached-1.0/include.am include tests/parser.am tests_failure_SOURCES= tests_failure_SOURCES+= tests/failure.cc tests_failure_SOURCES+= clients/execute.cc tests_failure_SOURCES+= clients/generator.cc tests_failure_SOURCES+= tests/libmemcached-1.0/callback_counter.cc tests_failure_SOURCES+= tests/libmemcached-1.0/fetch_all_results.cc tests_failure_SOURCES+= tests/libmemcached-1.0/generate.cc tests_failure_SOURCES+= tests/libmemcached-1.0/print.cc tests_failure_CXXFLAGS = $(AM_CXXFLAGS) tests_failure_DEPENDENCIES= $(TESTS_LDADDS) tests_failure_LDADD= $(tests_failure_DEPENDENCIES) check_PROGRAMS+= tests/failure noinst_PROGRAMS+= tests/failure test-failure: tests/failure @tests/failure gdb-failure: tests/failure @$(DEBUG_COMMAND) tests/failure tests_testhashkit_SOURCES= tests/hashkit_functions.cc tests_testhashkit_DEPENDENCIES= libtest/libtest.la libhashkit/libhashkit.la $(TESTS_LDADDS) tests_testhashkit_LDADD= $(tests_testhashkit_DEPENDENCIES) check_PROGRAMS+= tests/testhashkit noinst_PROGRAMS+= tests/testhashkit test-hash: tests/testhashkit @tests/testhashkit tests_hash_plus_SOURCES= tests/hash_plus.cc tests_hash_plus_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_hash_plus_DEPENDENCIES= $(tests_testhashkit_DEPENDENCIES) tests_hash_plus_LDADD= $(tests_testhashkit_DEPENDENCIES) check_PROGRAMS+= tests/hash_plus noinst_PROGRAMS+= tests/hash_plus include tests/cli.am test: check check-local: $(TEST_DOCS) @echo "Tests completed" test-mem: tests/libmemcached-1.0/testapp @tests/libmemcached-1.0/testapp test-sasl: tests/sasl @tests/sasl test-atom: tests/atomsmasher @tests/atomsmasher test-plus: tests/testplus @tests/testplus test-hashplus: tests/hash_plus @tests/hash_plus test-cycle: tests/cycle @tests/cycle test-memcapable: tests/memcapable @tests/memcapable pahole-mem: tests/testapp @$(PAHOLE_COMMAND) tests/testapp gdb-mem: tests/libmemcached-1.0/testapp @$(DEBUG_COMMAND) tests/libmemcached-1.0/testapp gdb-sasl: tests/sasl @$(DEBUG_COMMAND) tests/sasl gdb-atom: tests/atomsmasher @$(DEBUG_COMMAND) tests/atomsmasher gdb-plus: tests/testplus $(DEBUG_COMMAND) tests/testplus gdb-hash: tests/testhashkit @$(DEBUG_COMMAND) tests/testhashkit gdb-hashplus: tests/hash_plus @$(DEBUG_COMMAND) tests/hash_plus gdb-cycle: tests/cycle @$(DEBUG_COMMAND) tests/cycle valgrind-cycle: tests/cycle $(VALGRIND_COMMAND) tests/cycle valgrind-mem: tests/libmemcached-1.0/testapp @$(VALGRIND_COMMAND) tests/libmemcached-1.0/testapp valgrind-failure: tests/failure @$(VALGRIND_COMMAND) tests/failure valgrind-atom: tests/atomsmasher $(VALGRIND_COMMAND) tests/atomsmasher valgrind-plus: tests/testplus @$(VALGRIND_COMMAND) tests/testplus valgrind-sasl: tests/sasl @$(VALGRIND_COMMAND) tests/sasl valgrind-hash: tests/testhashkit @$(VALGRIND_COMMAND) tests/testhashkit valgrind-hashplus: tests/hash_plus @$(VALGRIND_COMMAND) tests/hash_plus helgrind-cycle: tests/cycle @$(HELGRIND_COMMAND) tests/cycle helgrind-mem: tests/libmemcached-1.0/testapp @$(HELGRIND_COMMAND) tests/libmemcached-1.0/testapp helgrind-atom: tests/atomsmasher @$(HELGRIND_COMMAND) tests/atomsmasher helgrind-plus: tests/testplus @$(HELGRIND_COMMAND) tests/testplus helgrind-hash: tests/testhashkit @$(HELGRIND_COMMAND) tests/testhashkit helgrind-hashplus: tests/hash_plus @$(HELGRIND_COMMAND) tests/hash_plus libmemcached-1.0.8/tests/pool.h0000664000076400007640000000367411753573717016715 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached client and server library. * * Copyright (C) 2011 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. * */ #pragma once test_return_t memcached_pool_test(memcached_st *); test_return_t connection_pool_test(memcached_st *); test_return_t connection_pool2_test(memcached_st *); test_return_t connection_pool3_test(memcached_st *); test_return_t regression_bug_962815(memcached_st *); libmemcached-1.0.8/tests/namespace.h0000664000076400007640000000335211753573717017671 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached * * Copyright (C) 2011 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. * */ #pragma once LIBTEST_LOCAL test_return_t memcached_increment_namespace(memcached_st *memc); libmemcached-1.0.8/tests/ketama.h0000664000076400007640000000355711753573717017206 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once test_return_t auto_eject_hosts(memcached_st *); test_return_t ketama_compatibility_libmemcached(memcached_st *); test_return_t ketama_compatibility_spymemcached(memcached_st *); test_return_t user_supplied_bug18(memcached_st *); libmemcached-1.0.8/tests/memslap.cc0000664000076400007640000001374211753763014017524 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Test memslap * * Copyright (C) 2011 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. * */ /* Test that we are cycling the servers we are creating during testing. */ #include #include #include using namespace libtest; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif static std::string executable; static test_return_t quiet_test(void *) { const char *args[]= { "--quiet", 0 }; test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t help_test(void *) { const char *args[]= { "--help", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t server_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { buffer, 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t server_concurrency_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { buffer, "--concurrency=10", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t server_concurrency_initial_load_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { buffer, "--concurrency=10", "--initial-load=1000", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t server_concurrency_initial_load_execute_number_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t server_concurrency_initial_load_execute_number_test_get_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", "--test=get", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t server_concurrency_initial_load_execute_number_test_set_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", "--test=set", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t server_concurrency_initial_load_execute_number_test_set_non_blocking_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", "--test=set", "--non-blocking", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } test_st memslap_tests[] ={ {"--quiet", true, quiet_test }, {"--help", true, help_test }, {"--server_test", true, server_test }, {"--concurrency=10", true, server_concurrency_test }, {"--initial-load=1000", true, server_concurrency_initial_load_test }, {"--execute-number=10", true, server_concurrency_initial_load_execute_number_test }, {"--test=get", true, server_concurrency_initial_load_execute_number_test_get_test }, {"--test=set", true, server_concurrency_initial_load_execute_number_test_set_test }, {"--test=set --non-blockin", true, server_concurrency_initial_load_execute_number_test_set_non_blocking_test }, {0, 0, 0} }; collection_st collection[] ={ {"memslap", 0, 0, memslap_tests }, {0, 0, 0, 0} }; static void *world_create(server_startup_st& servers, test_return_t& error) { if (HAVE_MEMCACHED_BINARY == 0) { error= TEST_SKIPPED; return NULL; } const char *argv[1]= { "memslap" }; if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv)) { error= TEST_FAILURE; } return &servers; } void get_world(Framework *world) { executable= "./clients/memslap"; world->collections(collection); world->create(world_create); } libmemcached-1.0.8/tests/exist.h0000664000076400007640000000356611753573717017100 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once test_return_t memcached_exist_NOTFOUND(memcached_st *); test_return_t memcached_exist_SUCCESS(memcached_st *); test_return_t memcached_exist_by_key_NOTFOUND(memcached_st *); test_return_t memcached_exist_by_key_SUCCESS(memcached_st *); libmemcached-1.0.8/tests/libmemcached_test_container.h0000664000076400007640000000440611753573717023434 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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. * */ #pragma once /* The structure we use for the test system */ struct libmemcached_test_container_st { private: memcached_st *_parent; public: libtest::server_startup_st& construct; libmemcached_test_container_st(libtest::server_startup_st &construct_arg) : _parent(NULL), construct(construct_arg) { } memcached_st* parent() { return _parent; } void parent(memcached_st* arg) { reset(); _parent= arg; } void reset() { if (_parent) { memcached_free(_parent); _parent= NULL; } } ~libmemcached_test_container_st() { reset(); } }; libmemcached-1.0.8/tests/deprecated.h0000664000076400007640000000357011753573717020037 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif test_return_t server_list_null_test(memcached_st *ptr); test_return_t regression_bug_728286(memcached_st *); #ifdef __cplusplus } #endif libmemcached-1.0.8/tests/memrm.cc0000664000076400007640000001143511753763014017200 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Test memrm * * Copyright (C) 2011 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. * */ /* Test that we are cycling the servers we are creating during testing. */ #include #include #include using namespace libtest; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif static std::string executable("./clients/memrm"); static test_return_t quiet_test(void *) { const char *args[]= { "--quiet", 0 }; test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t help_test(void *) { const char *args[]= { "--help", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t rm_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); memcached_st *memc= memcached(buffer, strlen(buffer)); test_true(memc); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("foo"), 0, 0, 0, 0)); memcached_return_t rc; test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_SUCCESS, rc); const char *args[]= { buffer, "foo", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_NOTFOUND, rc); memcached_free(memc); return TEST_SUCCESS; } static test_return_t NOT_FOUND_TEST(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); const char *args[]= { buffer, "foo", 0 }; memcached_st *memc= memcached(buffer, strlen(buffer)); test_true(memc); memcached_return_t rc; test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_NOTFOUND, rc); test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_NOTFOUND, rc); memcached_free(memc); return TEST_SUCCESS; } static test_return_t multiple_NOT_FOUND_TEST(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); const char *args[]= { buffer, "protocols", "foo", "mine", "bar", "dog", "cat", "foo", "mine", "eye", "for", "the", "to", "not", "know", "what", "I", "should", "be", "doing", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } test_st memrm_tests[] ={ {"--quiet", true, quiet_test }, {"--help", true, help_test }, {"rm(FOUND)", true, rm_test }, {"rm(NOT_FOUND)", true, NOT_FOUND_TEST }, {"multiple rm(NOT_FOUND)", true, multiple_NOT_FOUND_TEST }, {0, 0, 0} }; collection_st collection[] ={ {"memrm", 0, 0, memrm_tests }, {0, 0, 0, 0} }; static void *world_create(server_startup_st& servers, test_return_t& error) { if (HAVE_MEMCACHED_BINARY == 0) { error= TEST_SKIPPED; return NULL; } if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == false) { error= TEST_FAILURE; } return &servers; } void get_world(Framework *world) { world->collections(collection); world->create(world_create); } libmemcached-1.0.8/tests/libmemcached-1.0/0000775000076400007640000000000011757025120020432 5ustar00brianbrian00000000000000libmemcached-1.0.8/tests/libmemcached-1.0/replication.cc0000664000076400007640000003672711753573717023311 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached client and server library. * * Copyright (C) 2011 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 #include using namespace libtest; #include #include #include #include #include "tests/libmemcached-1.0/setup_and_teardowns.h" test_return_t check_replication_sanity_TEST(memcached_st *memc) { test_true(memc); test_compare(uint64_t(1), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); /* * Make sure that we store the item on all servers * (master + replicas == number of servers) */ test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS), uint64_t(memcached_server_count(memc) - 1)); return TEST_SUCCESS; } test_return_t replication_set_test(memcached_st *memc) { memcached_st *memc_clone= memcached_clone(NULL, memc); test_true(memc_clone); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0)); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, "bubba", 5, "0", 1, 0, 0)); /* ** We are using the quiet commands to store the replicas, so we need ** to ensure that all of them are processed before we can continue. ** In the test we go directly from storing the object to trying to ** receive the object from all of the different servers, so we ** could end up in a race condition (the memcached server hasn't yet ** processed the quiet command from the replication set when it process ** the request from the other client (created by the clone)). As a ** workaround for that we call memcached_quit to send the quit command ** to the server and wait for the response ;-) If you use the test code ** as an example for your own code, please note that you shouldn't need ** to do this ;-) */ memcached_quit(memc); /* ** "bubba" should now be stored on all of our servers. We don't have an ** easy to use API to address each individual server, so I'll just iterate ** through a bunch of "master keys" and I should most likely hit all of the ** servers... */ for (int x= 'a'; x <= 'z'; ++x) { const char key[2]= { (char)x, 0 }; size_t len; uint32_t flags; memcached_return_t rc; char *val= memcached_get_by_key(memc_clone, key, 1, "bubba", 5, &len, &flags, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(val); free(val); } memcached_free(memc_clone); return TEST_SUCCESS; } test_return_t replication_get_test(memcached_st *memc) { /* * Don't do the following in your code. I am abusing the internal details * within the library, and this is not a supported interface. * This is to verify correct behavior in the library */ for (uint32_t host= 0; host < memcached_server_count(memc); ++host) { memcached_st *memc_clone= memcached_clone(NULL, memc); memcached_server_instance_st instance= memcached_server_instance_by_position(memc_clone, host); ((memcached_server_write_instance_st)instance)->port= 0; for (int x= 'a'; x <= 'z'; ++x) { const char key[2]= { (char)x, 0 }; size_t len; uint32_t flags; memcached_return_t rc; char *val= memcached_get_by_key(memc_clone, key, 1, "bubba", 5, &len, &flags, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(val); free(val); } memcached_free(memc_clone); } return TEST_SUCCESS; } test_return_t replication_mget_test(memcached_st *memc) { memcached_st *memc_clone= memcached_clone(NULL, memc); test_true(memc_clone); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0)); const char *keys[]= { "bubba", "key1", "key2", "key3" }; size_t len[]= { 5, 4, 4, 4 }; for (size_t x= 0; x< 4; ++x) { test_compare(MEMCACHED_SUCCESS, memcached_set(memc, keys[x], len[x], "0", 1, 0, 0)); } /* ** We are using the quiet commands to store the replicas, so we need ** to ensure that all of them are processed before we can continue. ** In the test we go directly from storing the object to trying to ** receive the object from all of the different servers, so we ** could end up in a race condition (the memcached server hasn't yet ** processed the quiet command from the replication set when it process ** the request from the other client (created by the clone)). As a ** workaround for that we call memcached_quit to send the quit command ** to the server and wait for the response ;-) If you use the test code ** as an example for your own code, please note that you shouldn't need ** to do this ;-) */ memcached_quit(memc); /* * Don't do the following in your code. I am abusing the internal details * within the library, and this is not a supported interface. * This is to verify correct behavior in the library */ memcached_result_st result_obj; for (uint32_t host= 0; host < memcached_server_count(memc_clone); host++) { memcached_st *new_clone= memcached_clone(NULL, memc); memcached_server_instance_st instance= memcached_server_instance_by_position(new_clone, host); ((memcached_server_write_instance_st)instance)->port= 0; for (int x= 'a'; x <= 'z'; ++x) { char key[2]= { (char)x, 0 }; test_compare(MEMCACHED_SUCCESS, memcached_mget_by_key(new_clone, key, 1, keys, len, 4)); memcached_result_st *results= memcached_result_create(new_clone, &result_obj); test_true(results); int hits= 0; memcached_return_t rc; while ((results= memcached_fetch_result(new_clone, &result_obj, &rc)) != NULL) { hits++; } test_compare(4, hits); memcached_result_free(&result_obj); } memcached_free(new_clone); } memcached_free(memc_clone); return TEST_SUCCESS; } test_return_t replication_randomize_mget_test(memcached_st *memc) { memcached_result_st result_obj; memcached_st *memc_clone= memcached_clone(NULL, memc); memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 3); memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ, 1); const char *keys[]= { "key1", "key2", "key3", "key4", "key5", "key6", "key7" }; size_t len[]= { 4, 4, 4, 4, 4, 4, 4 }; for (size_t x= 0; x< 7; ++x) { test_compare(MEMCACHED_SUCCESS, memcached_set(memc, keys[x], len[x], "1", 1, 0, 0)); } memcached_quit(memc); for (size_t x= 0; x< 7; ++x) { const char key[2]= { (char)x, 0 }; test_compare(MEMCACHED_SUCCESS, memcached_mget_by_key(memc_clone, key, 1, keys, len, 7)); memcached_result_st *results= memcached_result_create(memc_clone, &result_obj); test_true(results); int hits= 0; memcached_return_t rc; while ((results= memcached_fetch_result(memc_clone, &result_obj, &rc)) != NULL) { ++hits; } test_compare(hits, 7); memcached_result_free(&result_obj); } memcached_free(memc_clone); return TEST_SUCCESS; } test_return_t replication_delete_test(memcached_st *memc_just_cloned) { memcached_flush(memc_just_cloned, 0); memcached_st *memc_not_replicate= memcached_clone(NULL, memc_just_cloned); memcached_st *memc_replicated= memcached_clone(NULL, memc_just_cloned); const char *keys[]= { "bubba", "key1", "key2", "key3", "key4" }; test_compare(uint64_t(1), memcached_behavior_get(memc_replicated, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_replicated, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ, false)); // Make one copy test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_replicated, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 1UL)); test_compare(uint64_t(1), memcached_behavior_get(memc_replicated, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_not_replicate, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0UL)); test_compare(uint64_t(0), memcached_behavior_get(memc_not_replicate, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS)); for (size_t x= 0; x < test_array_length(keys); ++x) { memcached_set(memc_replicated, test_string_make_from_cstr(keys[x]), // Keys test_string_make_from_cstr(keys[x]), // We use the keys as values 0, 0); } memcached_flush_buffers(memc_replicated); // Confirm keys with replication read test_compare(TEST_SUCCESS, confirm_keys_exist(memc_replicated, keys, test_array_length(keys), true, true)); test_compare(TEST_SUCCESS, confirm_keys_exist(memc_not_replicate, keys, test_array_length(keys), true, true)); /* Delete the items from all of the servers except 1, we use the non replicated memc so that we know we deleted the keys */ for (size_t x= 0; x < test_array_length(keys); ++x) { test_compare(MEMCACHED_SUCCESS, memcached_delete(memc_replicated, test_string_make_from_cstr(keys[x]), // Keys 0)); } test_compare(TEST_SUCCESS, confirm_keys_dont_exist(memc_replicated, keys, test_array_length(keys))); test_compare(TEST_SUCCESS, confirm_keys_dont_exist(memc_not_replicate, keys, test_array_length(keys))); #if 0 test_zero(confirm_key_count(memc_not_replicate)); #endif memcached_free(memc_not_replicate); memcached_free(memc_replicated); return TEST_SUCCESS; } test_return_t replication_randomize_mget_fail_test(memcached_st *memc) { memcached_st *memc_clone= memcached_clone(NULL, memc); memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 3); for (int x= int(MEMCACHED_SUCCESS); x < int(MEMCACHED_MAXIMUM_RETURN); ++x) { const char *key= memcached_strerror(NULL, memcached_return_t(x)); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, key, strlen(key), key, strlen(key), 0, 0)); } memcached_flush_buffers(memc); // We need to now cause a failure in one server, never do this in your own // code. close(memc_clone->servers[1].fd); memc_clone->servers[1].port= 1; memc_clone->servers[1].address_info_next= NULL; for (int x= int(MEMCACHED_SUCCESS); x < int(MEMCACHED_MAXIMUM_RETURN); ++x) { const char *key= memcached_strerror(NULL, memcached_return_t(x)); uint32_t flags; size_t value_length; memcached_return_t rc; char *value= memcached_get(memc_clone, key, strlen(key), &value_length, &flags, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_compare(strlen(key), value_length); test_strcmp(key, value); free(value); } memcached_free(memc_clone); return TEST_SUCCESS; } /* Test that single miss does not cause replica reads to fail */ test_return_t replication_miss_test(memcached_st *memc) { test_skip(true, false); memcached_st *memc_repl= memcached_clone(NULL, memc); test_true(memc_repl); memcached_st *memc_single= memcached_clone(NULL, memc); test_true(memc_single); const char *value = "my_value"; size_t vlen; uint32_t flags; /* this test makes sense only with 2 or more servers */ test_true(memcached_server_count(memc_repl) > 1); /* Consistent hash */ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set_distribution(memc_repl, MEMCACHED_DISTRIBUTION_CONSISTENT)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set_distribution(memc_single, MEMCACHED_DISTRIBUTION_CONSISTENT)); /* The first clone writes to all servers */ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_repl, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, true)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_repl, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, memcached_server_count(memc_repl))); /* Write to servers */ { memcached_return_t rc= memcached_set(memc_repl, test_literal_param(__func__), value, strlen(value), time_t(1200), uint32_t(0)); test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); } /* Use the second clone to remove the key from primary server. This should remove the key from only one server */ { memcached_return_t rc= memcached_delete(memc_single, test_literal_param(__func__), 0); test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); } /* Remove the server where the key was deleted */ { #if 0 memcached_return_t rc; const memcached_server_st *instance= memcached_server_by_key(memc_single, test_literal_param(__func__), &rc); test_compare(MEMCACHED_SUCCESS, rc); test_compare(MEMCACHED_SUCCESS, memcached_server_remove(instance)); #endif } /* Test that others still have it */ { memcached_return_t rc; char *get_value= memcached_get(memc_single, test_literal_param(__func__), &vlen, &flags, &rc); test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); test_true(get_value and strcmp(get_value, value) == 0); free(get_value); } /* This read should still return the value as we have it on other servers */ { memcached_return_t rc; char *get_value= memcached_get(memc_repl, test_literal_param(__func__), &vlen, &flags, &rc); test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED); test_true(get_value and strcmp(get_value, value) == 0); free(get_value); } memcached_free(memc_repl); memcached_free(memc_single); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/parser.cc0000664000076400007640000006151111753573717022261 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * Copyright (C) 2011 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 #include using namespace libtest; #include #include #include #include #include #include #include enum scanner_type_t { NIL, UNSIGNED, SIGNED, ARRAY }; struct scanner_string_st { const char *c_str; size_t size; }; static inline scanner_string_st scanner_string(const char *arg, size_t arg_size) { scanner_string_st local= { arg, arg_size }; return local; } #define make_scanner_string(X) scanner_string((X), static_cast(sizeof(X) - 1)) static struct scanner_string_st scanner_string_null= { 0, 0}; struct scanner_variable_t { enum scanner_type_t type; struct scanner_string_st option; struct scanner_string_st result; test_return_t (*check_func)(memcached_st *memc, const scanner_string_st &hostname); }; // Check and make sure the first host is what we expect it to be static test_return_t __check_host(memcached_st *memc, const scanner_string_st &hostname) { memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); test_true(instance); const char *first_hostname = memcached_server_name(instance); test_true(first_hostname); test_strcmp(first_hostname, hostname.c_str); return TEST_SUCCESS; } // Check and make sure the prefix_key is what we expect it to be static test_return_t __check_namespace(memcached_st *, const scanner_string_st &) { #if 0 const char *_namespace = memcached_get_namespace(memc); test_true(_namespace); test_strcmp(_namespace, arg.c_str); #endif return TEST_SUCCESS; } static test_return_t __check_IO_MSG_WATERMARK(memcached_st *memc, const scanner_string_st &value) { uint64_t value_number; value_number= atoll(value.c_str); test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK) == value_number); return TEST_SUCCESS; } static test_return_t __check_REMOVE_FAILED_SERVERS(memcached_st *memc, const scanner_string_st &) { test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS)); return TEST_SUCCESS; } static test_return_t __check_NOREPLY(memcached_st *memc, const scanner_string_st &) { test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NOREPLY)); return TEST_SUCCESS; } static test_return_t __check_VERIFY_KEY(memcached_st *memc, const scanner_string_st &) { test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_VERIFY_KEY)); return TEST_SUCCESS; } static test_return_t __check_distribution_RANDOM(memcached_st *memc, const scanner_string_st &) { test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION) == MEMCACHED_DISTRIBUTION_RANDOM); return TEST_SUCCESS; } scanner_variable_t test_server_strings[]= { { ARRAY, make_scanner_string("--server=localhost"), make_scanner_string("localhost"), __check_host }, { ARRAY, make_scanner_string("--server=10.0.2.1"), make_scanner_string("10.0.2.1"), __check_host }, { ARRAY, make_scanner_string("--server=example.com"), make_scanner_string("example.com"), __check_host }, { ARRAY, make_scanner_string("--server=localhost:30"), make_scanner_string("localhost"), __check_host }, { ARRAY, make_scanner_string("--server=10.0.2.1:20"), make_scanner_string("10.0.2.1"), __check_host }, { ARRAY, make_scanner_string("--server=example.com:1024"), make_scanner_string("example.com"), __check_host }, { NIL, scanner_string_null, scanner_string_null, NULL } }; scanner_variable_t test_server_strings_with_weights[]= { { ARRAY, make_scanner_string("--server=10.0.2.1:30/?40"), make_scanner_string("10.0.2.1"), __check_host }, { ARRAY, make_scanner_string("--server=example.com:1024/?30"), make_scanner_string("example.com"), __check_host }, { ARRAY, make_scanner_string("--server=10.0.2.1/?20"), make_scanner_string("10.0.2.1"), __check_host }, { ARRAY, make_scanner_string("--server=example.com/?10"), make_scanner_string("example.com"), __check_host }, { NIL, scanner_string_null, scanner_string_null, NULL } }; scanner_variable_t bad_test_strings[]= { { ARRAY, make_scanner_string("-servers=localhost:11221,localhost:11222,localhost:11223,localhost:11224,localhost:11225"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("-- servers=a.example.com:81,localhost:82,b.example.com"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--servers=localhost:+80"), scanner_string_null, NULL}, { ARRAY, make_scanner_string("--servers=localhost.com."), scanner_string_null, NULL}, { ARRAY, make_scanner_string("--server=localhost.com."), scanner_string_null, NULL}, { ARRAY, make_scanner_string("--server=localhost.com.:80"), scanner_string_null, NULL}, { NIL, scanner_string_null, scanner_string_null, NULL} }; scanner_variable_t test_number_options[]= { { ARRAY, make_scanner_string("--CONNECT-TIMEOUT=456"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--IO-BYTES-WATERMARK=456"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--IO-KEY-PREFETCH=456"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--IO-MSG-WATERMARK=456"), make_scanner_string("456"), __check_IO_MSG_WATERMARK }, { ARRAY, make_scanner_string("--NUMBER-OF-REPLICAS=456"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--POLL-TIMEOUT=456"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--RCV-TIMEOUT=456"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--REMOVE-FAILED-SERVERS=3"), scanner_string_null, __check_REMOVE_FAILED_SERVERS }, { ARRAY, make_scanner_string("--RETRY-TIMEOUT=456"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--SND-TIMEOUT=456"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--SOCKET-RECV-SIZE=456"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--SOCKET-SEND-SIZE=456"), scanner_string_null, NULL }, { NIL, scanner_string_null, scanner_string_null, NULL} }; scanner_variable_t test_boolean_options[]= { { ARRAY, make_scanner_string("--BINARY-PROTOCOL"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--BUFFER-REQUESTS"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--HASH-WITH-NAMESPACE"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--NOREPLY"), scanner_string_null, __check_NOREPLY }, { ARRAY, make_scanner_string("--RANDOMIZE-REPLICA-READ"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--SORT-HOSTS"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--SUPPORT-CAS"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--TCP-NODELAY"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--TCP-KEEPALIVE"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--TCP-KEEPIDLE"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--USE-UDP"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--VERIFY-KEY"), scanner_string_null, __check_VERIFY_KEY }, { NIL, scanner_string_null, scanner_string_null, NULL} }; scanner_variable_t namespace_strings[]= { { ARRAY, make_scanner_string("--NAMESPACE=foo"), make_scanner_string("foo"), __check_namespace }, { ARRAY, make_scanner_string("--NAMESPACE=\"foo\""), make_scanner_string("foo"), __check_namespace }, { ARRAY, make_scanner_string("--NAMESPACE=\"This_is_a_very_long_key\""), make_scanner_string("This_is_a_very_long_key"), __check_namespace }, { NIL, scanner_string_null, scanner_string_null, NULL} }; scanner_variable_t distribution_strings[]= { { ARRAY, make_scanner_string("--DISTRIBUTION=consistent"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--DISTRIBUTION=consistent,CRC"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--DISTRIBUTION=consistent,MD5"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--DISTRIBUTION=random"), scanner_string_null, __check_distribution_RANDOM }, { ARRAY, make_scanner_string("--DISTRIBUTION=modula"), scanner_string_null, NULL }, { NIL, scanner_string_null, scanner_string_null, NULL} }; scanner_variable_t hash_strings[]= { { ARRAY, make_scanner_string("--HASH=CRC"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--HASH=FNV1A_32"), scanner_string_null, NULL }, { ARRAY, make_scanner_string("--HASH=FNV1_32"), scanner_string_null, NULL }, #if 0 { ARRAY, make_scanner_string("--HASH=JENKINS"), scanner_string_null, NULL }, #endif { ARRAY, make_scanner_string("--HASH=MD5"), scanner_string_null, NULL }, { NIL, scanner_string_null, scanner_string_null, NULL} }; static test_return_t _test_option(scanner_variable_t *scanner, bool test_true_opt= true) { for (scanner_variable_t *ptr= scanner; ptr->type != NIL; ptr++) { memcached_st *memc= memcached(ptr->option.c_str, ptr->option.size); // The case that it should have parsed, but it didn't. We will inspect for // an error with libmemcached_check_configuration() if (memc == NULL and test_true_opt) { char buffer[2048]; bool success= libmemcached_check_configuration(ptr->option.c_str, ptr->option.size, buffer, sizeof(buffer)); std::string temp(buffer); temp+= " with option string:"; temp+= ptr->option.c_str; test_true_got(success, temp.c_str()); Error << "Failed for " << temp; return TEST_FAILURE; // The line above should fail since memc should be null } if (test_true_opt) { if (ptr->check_func) { test_return_t test_rc= (*ptr->check_func)(memc, ptr->result); if (test_rc != TEST_SUCCESS) { memcached_free(memc); return test_rc; } } memcached_free(memc); } else { test_false_with(memc, ptr->option.c_str); } } return TEST_SUCCESS; } test_return_t server_test(memcached_st *) { return _test_option(test_server_strings); } test_return_t server_with_weight_test(memcached_st *) { return _test_option(test_server_strings_with_weights); } test_return_t servers_bad_test(memcached_st *) { test_return_t rc; if ((rc= _test_option(bad_test_strings, false)) != TEST_SUCCESS) { return rc; } return TEST_SUCCESS; } test_return_t parser_number_options_test(memcached_st*) { return _test_option(test_number_options); } test_return_t parser_boolean_options_test(memcached_st*) { return _test_option(test_boolean_options); } test_return_t behavior_parser_test(memcached_st*) { return TEST_SUCCESS; } test_return_t parser_hash_test(memcached_st*) { return _test_option(hash_strings); } test_return_t parser_distribution_test(memcached_st*) { return _test_option(distribution_strings); } test_return_t parser_key_prefix_test(memcached_st*) { return _test_option(distribution_strings); } test_return_t test_namespace_keyword(memcached_st*) { return _test_option(namespace_strings); } #define SUPPORT_EXAMPLE_CNF "support/example.cnf" test_return_t memcached_create_with_options_with_filename(memcached_st*) { test_skip(0, access(SUPPORT_EXAMPLE_CNF, R_OK)); memcached_st *memc_ptr= memcached(test_literal_param("--CONFIGURE-FILE=\"support/example.cnf\"")); test_true_got(memc_ptr, "memcached() failed"); memcached_free(memc_ptr); return TEST_SUCCESS; } test_return_t libmemcached_check_configuration_with_filename_test(memcached_st*) { test_skip(0, access(SUPPORT_EXAMPLE_CNF, R_OK)); char buffer[BUFSIZ]; test_compare_hint(MEMCACHED_SUCCESS, libmemcached_check_configuration(test_literal_param("--CONFIGURE-FILE=\"support/example.cnf\""), buffer, sizeof(buffer)), buffer); test_compare_hint(MEMCACHED_SUCCESS, libmemcached_check_configuration(test_literal_param("--CONFIGURE-FILE=support/example.cnf"), buffer, sizeof(buffer)), buffer); test_compare_hint(MEMCACHED_ERRNO, libmemcached_check_configuration(test_literal_param("--CONFIGURE-FILE=\"bad-path/example.cnf\""), buffer, sizeof(buffer)), buffer) ; return TEST_SUCCESS; } test_return_t libmemcached_check_configuration_test(memcached_st*) { char buffer[BUFSIZ]; test_compare(MEMCACHED_SUCCESS, libmemcached_check_configuration(test_literal_param("--server=localhost"), buffer, sizeof(buffer))); test_compare_hint(MEMCACHED_PARSE_ERROR, libmemcached_check_configuration(test_literal_param("--dude=localhost"), buffer, sizeof(buffer)), buffer); return TEST_SUCCESS; } test_return_t memcached_create_with_options_test(memcached_st*) { { memcached_st *memc_ptr; memc_ptr= memcached(test_literal_param("--server=localhost")); test_true_got(memc_ptr, memcached_last_error_message(memc_ptr)); memcached_free(memc_ptr); } { memcached_st *memc_ptr= memcached(test_literal_param("--dude=localhost")); test_false_with(memc_ptr, memcached_last_error_message(memc_ptr)); } return TEST_SUCCESS; } test_return_t test_include_keyword(memcached_st*) { test_skip(0, access(SUPPORT_EXAMPLE_CNF, R_OK)); char buffer[BUFSIZ]; test_compare(MEMCACHED_SUCCESS, libmemcached_check_configuration(test_literal_param("INCLUDE \"support/example.cnf\""), buffer, sizeof(buffer))); return TEST_SUCCESS; } test_return_t test_end_keyword(memcached_st*) { char buffer[BUFSIZ]; test_compare(MEMCACHED_SUCCESS, libmemcached_check_configuration(test_literal_param("--server=localhost END bad keywords"), buffer, sizeof(buffer))); return TEST_SUCCESS; } test_return_t test_reset_keyword(memcached_st*) { char buffer[BUFSIZ]; test_compare(MEMCACHED_SUCCESS, libmemcached_check_configuration(test_literal_param("--server=localhost reset --server=bad.com"), buffer, sizeof(buffer))); return TEST_SUCCESS; } test_return_t test_error_keyword(memcached_st*) { char buffer[BUFSIZ]; memcached_return_t rc; rc= libmemcached_check_configuration(test_literal_param("--server=localhost ERROR --server=bad.com"), buffer, sizeof(buffer)); test_true_got(rc != MEMCACHED_SUCCESS, buffer); return TEST_SUCCESS; } #define RANDOM_STRINGS 1000 test_return_t random_statement_build_test(memcached_st*) { std::vector option_list; for (scanner_variable_t *ptr= test_server_strings; ptr->type != NIL; ptr++) option_list.push_back(&ptr->option); for (scanner_variable_t *ptr= test_number_options; ptr->type != NIL; ptr++) option_list.push_back(&ptr->option); for (scanner_variable_t *ptr= test_boolean_options; ptr->type != NIL; ptr++) option_list.push_back(&ptr->option); for (scanner_variable_t *ptr= namespace_strings; ptr->type != NIL; ptr++) option_list.push_back(&ptr->option); for (scanner_variable_t *ptr= distribution_strings; ptr->type != NIL; ptr++) option_list.push_back(&ptr->option); for (scanner_variable_t *ptr= hash_strings; ptr->type != NIL; ptr++) option_list.push_back(&ptr->option); std::vector used_list; used_list.resize(option_list.size()); struct used_options_st { bool has_hash; bool has_namespace; bool has_distribution; bool has_buffer_requests; bool has_udp; bool has_binary; bool has_verify_key; used_options_st() : has_hash(false), has_namespace(false), has_distribution(false), has_buffer_requests(false), has_udp(false), has_binary(false), has_verify_key(false) { } } used_options; for (uint32_t x= 0; x < RANDOM_STRINGS; x++) { std::string random_options; uint32_t number_of= random() % option_list.size(); for (uint32_t options= 0; options < number_of; options++) { size_t option_list_position= random() % option_list.size(); if (used_list[option_list_position]) { continue; } used_list[option_list_position]= true; std::string random_string= option_list[option_list_position]->c_str; if (random_string.compare(0, test_literal_compare_param("--HASH")) == 0) { if (used_options.has_hash) { continue; } if (used_options.has_distribution) { continue; } used_options.has_hash= true; } if (random_string.compare(0, test_literal_compare_param("--NAMESPACE")) == 0) { if (used_options.has_namespace) { continue; } used_options.has_namespace= true; } if (random_string.compare(0, test_literal_compare_param("--USE-UDP")) == 0) { if (used_options.has_udp) { continue; } used_options.has_udp= true; if (used_options.has_buffer_requests) { continue; } } if (random_string.compare(0, test_literal_compare_param("--BUFFER-REQUESTS")) == 0) { if (used_options.has_buffer_requests) { continue; } used_options.has_buffer_requests= true; if (used_options.has_udp) { continue; } } if (random_string.compare(0, test_literal_compare_param("--BINARY-PROTOCOL")) == 0) { if (used_options.has_binary) { continue; } used_options.has_binary= true; if (used_options.has_verify_key) { continue; } } if (random_string.compare(0, test_literal_compare_param("--VERIFY-KEY")) == 0) { if (used_options.has_verify_key) { continue; } used_options.has_verify_key= true; if (used_options.has_binary) { continue; } } if (random_string.compare(0, test_literal_compare_param("--DISTRIBUTION")) == 0) { if (used_options.has_distribution) { continue; } if (used_options.has_hash) { continue; } used_options.has_distribution= true; } random_options+= random_string; random_options+= " "; } if (random_options.size() <= 1) { continue; } random_options.resize(random_options.size() -1); char buffer[BUFSIZ]; memcached_return_t rc= libmemcached_check_configuration(random_options.c_str(), random_options.size(), buffer, sizeof(buffer)); if (memcached_failed(rc)) { Error << "libmemcached_check_configuration(" << random_options << ") : " << buffer; return TEST_FAILURE; } } return TEST_SUCCESS; } static memcached_return_t dump_server_information(const memcached_st *, const memcached_server_st *instance, void *) { if (strcmp(memcached_server_name(instance), "localhost")) { fatal_assert(not memcached_server_name(instance)); return MEMCACHED_FAILURE; } if (memcached_server_port(instance) < 8888 or memcached_server_port(instance) > 8892) { fatal_assert(not memcached_server_port(instance)); return MEMCACHED_FAILURE; } if (instance->weight > 5 or instance->weight < 2) { fatal_assert(not instance->weight); return MEMCACHED_FAILURE; } return MEMCACHED_SUCCESS; } test_return_t test_hostname_port_weight(memcached_st *) { const char *server_string= "--server=localhost:8888/?2 --server=localhost:8889/?3 --server=localhost:8890/?4 --server=localhost:8891/?5 --server=localhost:8892/?3"; char buffer[BUFSIZ]; test_compare_got(MEMCACHED_SUCCESS, libmemcached_check_configuration(server_string, strlen(server_string), buffer, sizeof(buffer)), buffer); memcached_st *memc= memcached(server_string, strlen(server_string)); test_true(memc); memcached_server_fn callbacks[]= { dump_server_information }; test_true(memcached_success(memcached_server_cursor(memc, callbacks, NULL, 1))); memcached_free(memc); return TEST_SUCCESS; } struct socket_weight_t { const char *socket; size_t weight; }; static memcached_return_t dump_socket_information(const memcached_st *, const memcached_server_st *instance, void *context) { socket_weight_t *check= (socket_weight_t *)context; if (strcmp(memcached_server_name(instance), check->socket)) { Error << memcached_server_name(instance) << " != " << check->socket; return MEMCACHED_FAILURE; } if (instance->weight == check->weight) { return MEMCACHED_SUCCESS; } return MEMCACHED_FAILURE; } test_return_t test_parse_socket(memcached_st *) { char buffer[BUFSIZ]; memcached_server_fn callbacks[]= { dump_socket_information }; { test_compare_got(MEMCACHED_SUCCESS, libmemcached_check_configuration(test_literal_param("--socket=\"/tmp/foo\""), buffer, sizeof(buffer)), buffer); memcached_st *memc= memcached(test_literal_param("--socket=\"/tmp/foo\"")); test_true(memc); socket_weight_t check= { "/tmp/foo", 1 }; test_compare(MEMCACHED_SUCCESS, memcached_server_cursor(memc, callbacks, &check, 1)); memcached_free(memc); } { test_compare_got(MEMCACHED_SUCCESS, libmemcached_check_configuration(test_literal_param("--socket=\"/tmp/foo\"/?23"), buffer, sizeof(buffer)), buffer); memcached_st *memc= memcached(test_literal_param("--socket=\"/tmp/foo\"/?23")); test_true(memc); socket_weight_t check= { "/tmp/foo", 23 }; test_compare(MEMCACHED_SUCCESS, memcached_server_cursor(memc, callbacks, &check, 1)); memcached_free(memc); } return TEST_SUCCESS; } /* By setting the timeout value to zero, we force poll() to return immediatly. */ test_return_t regression_bug_71231153_connect(memcached_st *) { if (libmemcached_util_ping("10.0.2.252", 0, NULL)) // If for whatever reason someone has a host at this address, skip return TEST_SKIPPED; { // Test the connect-timeout, on a bad host we should get MEMCACHED_CONNECTION_FAILURE memcached_st *memc= memcached(test_literal_param("--SERVER=10.0.2.252 --CONNECT-TIMEOUT=0")); test_true(memc); test_zero(memc->connect_timeout); test_compare(MEMCACHED_DEFAULT_TIMEOUT, memc->poll_timeout); memcached_return_t rc; size_t value_len; char *value= memcached_get(memc, test_literal_param("test"), &value_len, NULL, &rc); test_false(value); test_zero(value_len); test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_last_error_message(memc)); memcached_free(memc); } return TEST_SUCCESS; } test_return_t regression_bug_71231153_poll(memcached_st *) { if (libmemcached_util_ping("10.0.2.252", 0, NULL)) // If for whatever reason someone has a host at this address, skip return TEST_SKIPPED; { // Test the poll timeout, on a bad host we should get MEMCACHED_CONNECTION_FAILURE memcached_st *memc= memcached(test_literal_param("--SERVER=10.0.2.252 --POLL-TIMEOUT=0")); test_true(memc); test_compare(MEMCACHED_DEFAULT_CONNECT_TIMEOUT, memc->connect_timeout); test_zero(memc->poll_timeout); memcached_return_t rc; size_t value_len; char *value= memcached_get(memc, test_literal_param("test"), &value_len, NULL, &rc); test_false(value); test_zero(value_len); #ifdef __APPLE__ test_compare_got(MEMCACHED_CONNECTION_FAILURE, rc, memcached_last_error_message(memc)); #else test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_last_error_message(memc)); #endif memcached_free(memc); } return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/error_conditions.cc0000664000076400007640000000447211753573717024352 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached * * Copyright (C) 2011 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 #include #define BUILDING_LIBMEMCACHED #include #include #include test_return_t memcached_increment_MEMCACHED_NO_SERVERS(memcached_st *) { memcached_st *memc_ptr; memc_ptr= memcached_create(NULL); test_true(memc_ptr); memcached_increment(memc_ptr, test_literal_param("dead key"), 1, NULL); test_true(memcached_last_error(memc_ptr) == MEMCACHED_NO_SERVERS); memcached_increment(memc_ptr, test_literal_param("dead key"), 1, NULL); test_true(memcached_last_error(memc_ptr) == MEMCACHED_NO_SERVERS); memcached_free(memc_ptr); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/include.am0000664000076400007640000003323611753573717022423 0ustar00brianbrian00000000000000# vim:ft=automake # Copyright (C) 2011 Data Differential # All rights reserved. # # Use and distribution licensed under the BSD license. See # the COPYING file in the parent directory for full text. # # included from Top Level Makefile.am # All paths should be given relative to the root noinst_HEADERS+= tests/basic.h noinst_HEADERS+= tests/callbacks.h noinst_HEADERS+= tests/debug.h noinst_HEADERS+= tests/deprecated.h noinst_HEADERS+= tests/error_conditions.h noinst_HEADERS+= tests/exist.h noinst_HEADERS+= tests/ketama.h noinst_HEADERS+= tests/ketama_test_cases.h noinst_HEADERS+= tests/ketama_test_cases_spy.h noinst_HEADERS+= tests/libmemcached-1.0/all_tests.h noinst_HEADERS+= tests/libmemcached-1.0/callback_counter.h noinst_HEADERS+= tests/libmemcached-1.0/dump.h noinst_HEADERS+= tests/libmemcached-1.0/encoding_key.h noinst_HEADERS+= tests/libmemcached-1.0/fetch_all_results.h noinst_HEADERS+= tests/libmemcached-1.0/generate.h noinst_HEADERS+= tests/libmemcached-1.0/haldenbrand.h noinst_HEADERS+= tests/libmemcached-1.0/mem_functions.h noinst_HEADERS+= tests/libmemcached-1.0/memcached_get.h noinst_HEADERS+= tests/libmemcached-1.0/parser.h noinst_HEADERS+= tests/libmemcached-1.0/setup_and_teardowns.h noinst_HEADERS+= tests/libmemcached-1.0/stat.h noinst_HEADERS+= tests/namespace.h noinst_HEADERS+= tests/pool.h noinst_HEADERS+= tests/print.h noinst_HEADERS+= tests/replication.h noinst_HEADERS+= tests/server_add.h noinst_HEADERS+= tests/string.h noinst_HEADERS+= tests/touch.h noinst_HEADERS+= tests/virtual_buckets.h # Test internals tests_libmemcached_1_0_internals_CXXFLAGS= tests_libmemcached_1_0_internals_DEPENDENCIES= tests_libmemcached_1_0_internals_LDADD= tests_libmemcached_1_0_internals_SOURCES= tests_libmemcached_1_0_internals_SOURCES+= tests/libmemcached-1.0/internals.cc tests_libmemcached_1_0_internals_SOURCES+= tests/libmemcached-1.0/string.cc tests_libmemcached_1_0_internals_CXXFLAGS+= $(AM_CXXFLAGS) tests_libmemcached_1_0_internals_CXXFLAGS+= ${PTHREAD_CFLAGS} tests_libmemcached_1_0_internals_DEPENDENCIES+= libmemcachedinternal/libmemcachedinternal.la tests_libmemcached_1_0_internals_DEPENDENCIES+= libtest/libtest.la tests_libmemcached_1_0_internals_DEPENDENCIES+= libmemcachedinternal/libmemcachedutilinternal.la tests_libmemcached_1_0_internals_LDADD+= libmemcachedinternal/libmemcachedinternal.la tests_libmemcached_1_0_internals_LDADD+= ${PTHREAD_LIBS} tests_libmemcached_1_0_internals_LDADD+= libmemcachedinternal/libmemcachedutilinternal.la tests_libmemcached_1_0_internals_LDADD+= libtest/libtest.la check_PROGRAMS+= tests/libmemcached-1.0/internals noinst_PROGRAMS+= tests/libmemcached-1.0/internals tests_libmemcached_1_0_testapp_CXXFLAGS= tests_libmemcached_1_0_testapp_CFLAGS= tests_libmemcached_1_0_testapp_SOURCES= tests_libmemcached_1_0_testapp_DEPENDENCIES= tests_libmemcached_1_0_testapp_LDADD= tests_libmemcached_1_0_testapp_CXXFLAGS+= $(AM_CXXFLAGS) tests_libmemcached_1_0_testapp_CXXFLAGS+= ${PTHREAD_CFLAGS} tests_libmemcached_1_0_testapp_CFLAGS+= $(AM_CFLAGS) tests_libmemcached_1_0_testapp_CFLAGS+= $(NO_CONVERSION) tests_libmemcached_1_0_testapp_CFLAGS+= $(NO_STRICT_ALIASING) tests_libmemcached_1_0_testapp_SOURCES+= clients/generator.cc clients/execute.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/all_tests.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/basic.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/callback_counter.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/callbacks.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/debug.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/deprecated.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/dump.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/encoding_key.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/error_conditions.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/exist.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/fetch_all_results.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/generate.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/haldenbrand.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/ketama.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/mem_functions.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/memcached_get.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/namespace.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/parser.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/pool.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/print.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/replication.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/server_add.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/setup_and_teardowns.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/stat.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/touch.cc tests_libmemcached_1_0_testapp_SOURCES+= tests/libmemcached-1.0/virtual_buckets.cc tests_libmemcached_1_0_testapp_DEPENDENCIES+= libmemcached/libmemcached.la 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+= ${PTHREAD_LIBS} tests_libmemcached_1_0_testapp_LDADD+= libmemcached/libmemcached.la tests_libmemcached_1_0_testapp_LDADD+= libmemcached/libmemcachedutil.la tests_libmemcached_1_0_testapp_LDADD+= libtest/libtest.la tests_libmemcached_1_0_testapp_LDADD+= libhashkit/libhashkit.la check_PROGRAMS+= tests/libmemcached-1.0/testapp noinst_PROGRAMS+= tests/libmemcached-1.0/testapp tests_libmemcached_1_0_testsocket_CXXFLAGS= tests_libmemcached_1_0_testsocket_CFLAGS= tests_libmemcached_1_0_testsocket_SOURCES= tests_libmemcached_1_0_testsocket_DEPENDENCIES= tests_libmemcached_1_0_testsocket_LDADD= tests_libmemcached_1_0_testsocket_CXXFLAGS+= ${PTHREAD_CFLAGS} tests_libmemcached_1_0_testsocket_CXXFLAGS+= $(AM_CXXFLAGS) tests_libmemcached_1_0_testsocket_CFLAGS+= $(AM_CFLAGS) tests_libmemcached_1_0_testsocket_CFLAGS+= $(NO_CONVERSION) tests_libmemcached_1_0_testsocket_CFLAGS+= $(NO_STRICT_ALIASING) tests_libmemcached_1_0_testsocket_SOURCES+= clients/execute.cc tests_libmemcached_1_0_testsocket_SOURCES+= clients/generator.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/all_tests_socket.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/basic.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/callback_counter.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/callbacks.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/debug.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/deprecated.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/dump.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/encoding_key.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/error_conditions.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/exist.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/fetch_all_results.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/generate.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/haldenbrand.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/ketama.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/mem_functions.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/memcached_get.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/namespace.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/parser.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/pool.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/print.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/replication.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/server_add.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/setup_and_teardowns.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/stat.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/touch.cc tests_libmemcached_1_0_testsocket_SOURCES+= tests/libmemcached-1.0/virtual_buckets.cc tests_libmemcached_1_0_testsocket_DEPENDENCIES+= libmemcached/libmemcached.la 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+= ${PTHREAD_LIBS} tests_libmemcached_1_0_testsocket_LDADD+= libmemcached/libmemcached.la tests_libmemcached_1_0_testsocket_LDADD+= libmemcached/libmemcachedutil.la tests_libmemcached_1_0_testsocket_LDADD+= libtest/libtest.la tests_libmemcached_1_0_testsocket_LDADD+= libhashkit/libhashkit.la check_PROGRAMS+= tests/libmemcached-1.0/testsocket noinst_PROGRAMS+= tests/libmemcached-1.0/testsocket tests_libmemcached_1_0_sasl_SOURCES= tests_libmemcached_1_0_sasl_DEPENDENCIES= tests_libmemcached_1_0_sasl_LDADD= tests_libmemcached_1_0_sasl_CXXFLAGS= tests_libmemcached_1_0_sasl_CFLAGS= tests_libmemcached_1_0_sasl_CXXFLAGS+= $(AM_CXXFLAGS) tests_libmemcached_1_0_sasl_CXXFLAGS+= ${PTHREAD_CFLAGS} tests_libmemcached_1_0_sasl_CFLAGS+= $(AM_CFLAGS) tests_libmemcached_1_0_sasl_CFLAGS+= $(NO_CONVERSION) tests_libmemcached_1_0_sasl_CFLAGS+= $(NO_STRICT_ALIASING) tests_libmemcached_1_0_sasl_SOURCES+= tests/libmemcached-1.0/basic.cc tests_libmemcached_1_0_sasl_SOURCES+= tests/libmemcached-1.0/debug.cc tests_libmemcached_1_0_sasl_SOURCES+= tests/libmemcached-1.0/deprecated.cc tests_libmemcached_1_0_sasl_SOURCES+= tests/libmemcached-1.0/error_conditions.cc tests_libmemcached_1_0_sasl_SOURCES+= tests/libmemcached-1.0/ketama.cc tests_libmemcached_1_0_sasl_SOURCES+= tests/libmemcached-1.0/namespace.cc tests_libmemcached_1_0_sasl_SOURCES+= tests/libmemcached-1.0/parser.cc tests_libmemcached_1_0_sasl_SOURCES+= tests/libmemcached-1.0/pool.cc tests_libmemcached_1_0_sasl_SOURCES+= tests/libmemcached-1.0/print.cc tests_libmemcached_1_0_sasl_SOURCES+= tests/libmemcached-1.0/replication.cc tests_libmemcached_1_0_sasl_SOURCES+= tests/libmemcached-1.0/sasl.cc tests_libmemcached_1_0_sasl_SOURCES+= tests/libmemcached-1.0/virtual_buckets.cc tests_libmemcached_1_0_sasl_SOURCES+= clients/execute.cc tests_libmemcached_1_0_sasl_SOURCES+= clients/generator.cc tests_libmemcached_1_0_sasl_SOURCES+= tests/libmemcached-1.0/callback_counter.cc tests_libmemcached_1_0_sasl_SOURCES+= tests/libmemcached-1.0/fetch_all_results.cc tests_libmemcached_1_0_sasl_SOURCES+= tests/libmemcached-1.0/generate.cc tests_libmemcached_1_0_sasl_DEPENDENCIES+= libmemcached/libmemcached.la tests_libmemcached_1_0_sasl_DEPENDENCIES+= libtest/libtest.la tests_libmemcached_1_0_sasl_LDADD+= ${PTHREAD_LIBS} tests_libmemcached_1_0_sasl_LDADD+= libmemcached/libmemcached.la tests_libmemcached_1_0_sasl_LDADD+= libmemcached/libmemcachedutil.la tests_libmemcached_1_0_sasl_LDADD+= libtest/libtest.la tests_libmemcached_1_0_sasl_LDADD+= libhashkit/libhashkit.la check_PROGRAMS+= tests/libmemcached-1.0/sasl noinst_PROGRAMS+= tests/libmemcached-1.0/sasl tests_atomsmasher_SOURCES= tests_atomsmasher_DEPENDENCIES= tests_atomsmasher_LDADD= tests_atomsmasher_DEPENDENCIES+= $(TESTS_LDADDS) tests_atomsmasher_LDADD+= $(tests_atomsmasher_DEPENDENCIES) tests_atomsmasher_SOURCES+= clients/execute.cc tests_atomsmasher_SOURCES+= clients/generator.cc tests_atomsmasher_SOURCES+= tests/libmemcached-1.0/atomsmasher.cc tests_atomsmasher_SOURCES+= tests/libmemcached-1.0/callback_counter.cc tests_atomsmasher_SOURCES+= tests/libmemcached-1.0/debug.cc tests_atomsmasher_SOURCES+= tests/libmemcached-1.0/fetch_all_results.cc tests_atomsmasher_SOURCES+= tests/libmemcached-1.0/generate.cc tests_atomsmasher_SOURCES+= tests/libmemcached-1.0/print.cc noinst_PROGRAMS+= tests/atomsmasher tests_testudp_CFLAGS= tests_testudp_SOURCES= tests_testudp_DEPENDENCIES= tests_testudp_LDADD= tests_testudp_CFLAGS+= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING) tests_testudp_SOURCES+= clients/execute.cc tests_testudp_SOURCES+= clients/generator.cc tests_testudp_SOURCES+= tests/libmemcached-1.0/callback_counter.cc tests_testudp_SOURCES+= tests/libmemcached-1.0/fetch_all_results.cc tests_testudp_SOURCES+= tests/libmemcached-1.0/generate.cc tests_testudp_SOURCES+= tests/libmemcached-1.0/print.cc tests_testudp_SOURCES+= tests/mem_udp.cc tests_testudp_DEPENDENCIES+= $(TESTS_LDADDS) tests_testudp_LDADD+= $(tests_testudp_DEPENDENCIES) check_PROGRAMS+= tests/testudp noinst_PROGRAMS+= tests/testudp test-udp: tests/testudp @tests/testudp tests_testplus_SOURCES= tests_testplus_CXXFLAGS= tests_testplus_DEPENDENCIES= tests_testplus_LDADD= tests_testplus_SOURCES+= clients/execute.cc tests_testplus_SOURCES+= clients/generator.cc tests_testplus_SOURCES+= tests/libmemcached-1.0/callback_counter.cc tests_testplus_SOURCES+= tests/libmemcached-1.0/fetch_all_results.cc tests_testplus_SOURCES+= tests/libmemcached-1.0/generate.cc tests_testplus_SOURCES+= tests/libmemcached-1.0/plus.cpp tests_testplus_SOURCES+= tests/libmemcached-1.0/print.cc tests_testplus_CXXFLAGS+= $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_testplus_DEPENDENCIES+= $(TESTS_LDADDS) tests_testplus_LDADD+= $(tests_testplus_DEPENDENCIES) check_PROGRAMS+= tests/testplus noinst_PROGRAMS+= tests/testplus libmemcached-1.0.8/tests/libmemcached-1.0/print.cc0000664000076400007640000000555111753573717022123 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached client and server library. * * Copyright (C) 2011 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 #include using namespace libtest; #include #include #include "tests/print.h" memcached_return_t server_print_callback(const memcached_st*, const memcached_server_st *server, void *context) { if (context) { std::cerr << memcached_server_name(server) << ":" << memcached_server_port(server) << std::endl; } return MEMCACHED_SUCCESS; } const char * print_version(memcached_st *memc) { memcached_server_fn callbacks[1]; callbacks[0]= server_print_version_callback; memcached_server_cursor(memc, callbacks, NULL, 1); return "print_version()"; } memcached_return_t server_print_version_callback(const memcached_st *, const memcached_server_st *server, void *) { std::cerr << "Server: " << memcached_server_name(server) << ":" << memcached_server_port(server) << " " << int(server->major_version) << "." << int(server->minor_version) << "." << int(server->micro_version) << std::endl; return MEMCACHED_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/virtual_buckets.cc0000664000076400007640000001141711753573717024173 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * Copyright (C) 2011 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 #include using namespace libtest; #include #include #include struct libtest_string_t { const char *c_str; size_t size; }; static inline libtest_string_t libtest_string(const char *arg, size_t arg_size) { libtest_string_t local= { arg, arg_size }; return local; } #define make_libtest_string(X) libtest_string((X), static_cast(sizeof(X) - 1)) static libtest_string_t libtest_string_t_null= { 0, 0}; static bool libtest_string_is_null(const libtest_string_t &string) { if (string.c_str == 0 and string.size == 0) return true; return false; } struct expect_t { libtest_string_t key; uint32_t server_id; uint32_t bucket_id; }; expect_t basic_keys[]= { { make_libtest_string("hello"), 0, 0 }, { make_libtest_string("doctor"), 0, 0 }, { make_libtest_string("name"), 1, 3 }, { make_libtest_string("continue"), 1, 3 }, { make_libtest_string("yesterday"), 0, 0 }, { make_libtest_string("tomorrow"), 1, 1 }, { make_libtest_string("another key"), 2, 2 }, { libtest_string_t_null, 0, 0 } }; test_return_t virtual_back_map(memcached_st *) { memcached_return_t rc; memcached_server_st *server_pool; memcached_st *memc; memc= memcached_create(NULL); test_true(memc); uint32_t server_map[] = { 0, 1, 2, 1 }; rc= memcached_bucket_set(memc, server_map, NULL, 4, 2); test_true(rc == MEMCACHED_SUCCESS); memcached_server_distribution_t dt; dt= memcached_behavior_get_distribution(memc); test_true(dt == MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET); memcached_behavior_set_key_hash(memc, MEMCACHED_HASH_CRC); test_true(rc == MEMCACHED_SUCCESS); memcached_hash_t hash_type= memcached_behavior_get_key_hash(memc); test_true(hash_type == MEMCACHED_HASH_CRC); server_pool = memcached_servers_parse("localhost:11211, localhost1:11210, localhost2:11211"); test_true(server_pool); memcached_server_push(memc, server_pool); /* verify that the server list was parsed okay. */ test_true(memcached_server_count(memc) == 3); test_true(strcmp(server_pool[0].hostname, "localhost") == 0); test_true(server_pool[0].port == 11211); test_true(strcmp(server_pool[1].hostname, "localhost1") == 0); test_true(server_pool[1].port == 11210); test_true(strcmp(server_pool[2].hostname, "localhost2") == 0); test_true(server_pool[2].port == 11211); dt= memcached_behavior_get_distribution(memc); hash_type= memcached_behavior_get_key_hash(memc); test_true(dt == MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET); test_true(hash_type == MEMCACHED_HASH_CRC); /* verify the standard ketama set. */ for (expect_t *ptr= basic_keys; not libtest_string_is_null(ptr->key); ptr++) { uint32_t server_idx = memcached_generate_hash(memc, ptr->key.c_str, ptr->key.size); char buffer[1024]; snprintf(buffer, sizeof(buffer), "%.*s:%lu Got/Expected %u == %u", (int)ptr->key.size, ptr->key.c_str, (unsigned long)ptr->key.size, server_idx, ptr->server_id); test_true_got(server_idx == ptr->server_id, buffer); } memcached_server_list_free(server_pool); memcached_free(memc); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/memcached_get.h0000664000076400007640000000352211753573717023372 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached 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. * */ #pragma once test_return_t get_test(memcached_st*); test_return_t get_test2(memcached_st*); test_return_t get_test3(memcached_st*); test_return_t get_test4(memcached_st*); test_return_t get_test5(memcached_st*); libmemcached-1.0.8/tests/libmemcached-1.0/haldenbrand.cc0000664000076400007640000001420411753573717023224 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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 #include #include "tests/libmemcached-1.0/haldenbrand.h" #include "tests/libmemcached-1.0/fetch_all_results.h" /* Test case provided by Cal Haldenbrand */ #define HALDENBRAND_KEY_COUNT 3000U // * 1024576 #define HALDENBRAND_FLAG_KEY 99 // * 1024576 test_return_t haldenbrand_TEST1(memcached_st *memc) { /* We just keep looking at the same values over and over */ srandom(10); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, true)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true)); /* add key */ unsigned long long total= 0; for (uint32_t x= 0 ; total < 20 * 1024576 ; x++ ) { uint32_t size= (uint32_t)(rand() % ( 5 * 1024 ) ) + 400; char randomstuff[6 * 1024]; memset(randomstuff, 0, 6 * 1024); test_true(size < 6 * 1024); /* Being safe here */ for (uint32_t j= 0 ; j < size ;j++) { randomstuff[j] = (signed char) ((rand() % 26) + 97); } total+= size; char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; int key_length= snprintf(key, sizeof(key), "%u", x); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, key, key_length, randomstuff, strlen(randomstuff), time_t(0), HALDENBRAND_FLAG_KEY)); } test_true(total > HALDENBRAND_KEY_COUNT); return TEST_SUCCESS; } /* Test case provided by Cal Haldenbrand */ test_return_t haldenbrand_TEST2(memcached_st *memc) { test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, true)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true)); #ifdef NOT_YET test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, 20 * 1024576)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, 20 * 1024576)); getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE); getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE); for (x= 0, errors= 0; total < 20 * 1024576 ; x++) #endif size_t total_value_length= 0; for (uint32_t x= 0, errors= 0; total_value_length < 24576 ; x++) { uint32_t flags= 0; size_t val_len= 0; char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; int key_length= snprintf(key, sizeof(key), "%u", x); memcached_return_t rc; char *getval= memcached_get(memc, key, key_length, &val_len, &flags, &rc); if (memcached_failed(rc)) { if (rc == MEMCACHED_NOTFOUND) { errors++; } else { test_true(rc); } continue; } test_compare(uint32_t(HALDENBRAND_FLAG_KEY), flags); test_true(getval); total_value_length+= val_len; errors= 0; ::free(getval); } return TEST_SUCCESS; } /* Do a large mget() over all the keys we think exist */ test_return_t haldenbrand_TEST3(memcached_st *memc) { test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, true)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true)); #ifdef NOT_YET memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, 20 * 1024576); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, 20 * 1024576); getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE); getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE); #endif std::vector key_lengths; key_lengths.resize(HALDENBRAND_KEY_COUNT); std::vector keys; keys.resize(key_lengths.size()); for (uint32_t x= 0; x < key_lengths.size(); x++) { char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; int key_length= snprintf(key, sizeof(key), "%u", x); test_true(key_length > 0 and key_length < MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1); keys[x]= strdup(key); key_lengths[x]= key_length; } test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, &keys[0], &key_lengths[0], key_lengths.size())); unsigned int keys_returned; test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned)); test_compare(HALDENBRAND_KEY_COUNT, keys_returned); for (libtest::vchar_ptr_t::iterator iter= keys.begin(); iter != keys.end(); iter++) { ::free(*iter); } return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/encoding_key.cc0000664000076400007640000003571411753573717023431 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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 #include #include #include #include "tests/libmemcached-1.0/encoding_key.h" using namespace libtest; test_return_t memcached_set_encoding_key_TEST(memcached_st* memc) { test_compare(MEMCACHED_SUCCESS, memcached_set_encoding_key(memc, test_literal_param(__func__))); return TEST_SUCCESS; } test_return_t memcached_set_encoding_key_set_get_TEST(memcached_st* memc) { memcached_st *memc_no_crypt= memcached_clone(NULL, memc); test_true(memc_no_crypt); test_compare(MEMCACHED_SUCCESS, memcached_set_encoding_key(memc, test_literal_param(__func__))); test_compare_hint(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param(__func__), // Key test_literal_param(__func__), // Value time_t(0), uint32_t(0)), memcached_last_error_message(memc)); { memcached_return_t rc; size_t value_length; char *value; test_true((value= memcached_get(memc, test_literal_param(__func__), // Key &value_length, NULL, &rc))); test_compare(MEMCACHED_SUCCESS, rc); test_compare(test_literal_param_size(__func__), value_length); test_memcmp(__func__, value, value_length); size_t raw_value_length; char *raw_value; test_true((raw_value= memcached_get(memc_no_crypt, test_literal_param(__func__), // Key &raw_value_length, NULL, &rc))); test_compare(MEMCACHED_SUCCESS, rc); test_ne_compare(value_length, raw_value_length); test_ne_compare(0, memcmp(value, raw_value, raw_value_length)); free(value); free(raw_value); } memcached_free(memc_no_crypt); return TEST_SUCCESS; } test_return_t memcached_set_encoding_key_add_get_TEST(memcached_st* memc) { test_compare(MEMCACHED_SUCCESS, memcached_set_encoding_key(memc, test_literal_param(__func__))); test_compare_hint(MEMCACHED_SUCCESS, memcached_add(memc, test_literal_param(__func__), // Key test_literal_param(__func__), // Value time_t(0), uint32_t(0)), memcached_last_error_message(memc)); { memcached_return_t rc; size_t value_length; char *value; test_true((value= memcached_get(memc, test_literal_param(__func__), // Key &value_length, NULL, &rc))); test_compare(MEMCACHED_SUCCESS, rc); test_compare(test_literal_param_size(__func__), value_length); test_memcmp(__func__, value, value_length); free(value); } return TEST_SUCCESS; } test_return_t memcached_set_encoding_key_replace_get_TEST(memcached_st* memc) { test_compare(MEMCACHED_SUCCESS, memcached_set_encoding_key(memc, test_literal_param(__func__))); // First we add the key { test_compare_hint(MEMCACHED_SUCCESS, memcached_add(memc, test_literal_param(__func__), // Key test_literal_param(__func__), // Value time_t(0), uint32_t(0)), memcached_last_error_message(memc)); memcached_return_t rc; size_t value_length; char *value; test_true((value= memcached_get(memc, test_literal_param(__func__), // Key &value_length, NULL, &rc))); test_compare(MEMCACHED_SUCCESS, rc); test_compare(test_literal_param_size(__func__), value_length); test_memcmp(__func__, value, value_length); free(value); } // Then we replace the key { libtest::vchar_t new_value; vchar::make(new_value); test_compare_hint(MEMCACHED_SUCCESS, memcached_replace(memc, test_literal_param(__func__), // Key vchar_param(new_value), // Value time_t(0), uint32_t(0)), memcached_last_error_message(memc)); memcached_return_t rc; size_t value_length; char *value; test_true((value= memcached_get(memc, test_literal_param(__func__), // Key &value_length, NULL, &rc))); test_compare(MEMCACHED_SUCCESS, rc); test_compare(new_value.size(), value_length); test_compare(0, vchar::compare(new_value, value, value_length)); free(value); } return TEST_SUCCESS; } test_return_t memcached_set_encoding_key_increment_TEST(memcached_st* memc) { test_compare(MEMCACHED_SUCCESS, memcached_set_encoding_key(memc, test_literal_param(__func__))); test_compare(MEMCACHED_NOT_SUPPORTED, memcached_increment(memc, test_literal_param(__func__), // Key uint32_t(0), NULL)); return TEST_SUCCESS; } test_return_t memcached_set_encoding_key_decrement_TEST(memcached_st* memc) { test_compare(MEMCACHED_SUCCESS, memcached_set_encoding_key(memc, test_literal_param(__func__))); test_compare(MEMCACHED_NOT_SUPPORTED, memcached_decrement(memc, test_literal_param(__func__), // Key uint32_t(0), NULL)); return TEST_SUCCESS; } test_return_t memcached_set_encoding_key_increment_with_initial_TEST(memcached_st* memc) { test_compare(MEMCACHED_SUCCESS, memcached_set_encoding_key(memc, test_literal_param(__func__))); test_compare(MEMCACHED_NOT_SUPPORTED, memcached_increment_with_initial(memc, test_literal_param(__func__), // Key uint32_t(0), uint32_t(0), time_t(0), NULL)); return TEST_SUCCESS; } test_return_t memcached_set_encoding_key_decrement_with_initial_TEST(memcached_st* memc) { test_compare(MEMCACHED_SUCCESS, memcached_set_encoding_key(memc, test_literal_param(__func__))); test_compare(MEMCACHED_NOT_SUPPORTED, memcached_decrement_with_initial(memc, test_literal_param(__func__), // Key uint32_t(0), uint32_t(0), time_t(0), NULL)); return TEST_SUCCESS; } test_return_t memcached_set_encoding_key_append_TEST(memcached_st* memc) { test_compare(MEMCACHED_SUCCESS, memcached_set_encoding_key(memc, test_literal_param(__func__))); test_compare(MEMCACHED_NOT_SUPPORTED, memcached_append(memc, test_literal_param(__func__), // Key test_literal_param(__func__), // Value time_t(0), uint32_t(0))); return TEST_SUCCESS; } test_return_t memcached_set_encoding_key_prepend_TEST(memcached_st* memc) { test_compare(MEMCACHED_SUCCESS, memcached_set_encoding_key(memc, test_literal_param(__func__))); test_compare(MEMCACHED_NOT_SUPPORTED, memcached_prepend(memc, test_literal_param(__func__), // Key test_literal_param(__func__), // Value time_t(0), uint32_t(0))); return TEST_SUCCESS; } test_return_t memcached_set_encoding_key_set_get_clone_TEST(memcached_st* memc) { memcached_st *memc_no_crypt= memcached_clone(NULL, memc); test_true(memc_no_crypt); test_compare(MEMCACHED_SUCCESS, memcached_set_encoding_key(memc, test_literal_param(__func__))); memcached_st *memc_crypt= memcached_clone(NULL, memc); test_true(memc_crypt); test_compare_hint(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param(__func__), // Key test_literal_param(__func__), // Value time_t(0), uint32_t(0)), memcached_last_error_message(memc)); { memcached_return_t rc; size_t value_length; char *value; test_true((value= memcached_get(memc, test_literal_param(__func__), // Key &value_length, NULL, &rc))); test_compare(MEMCACHED_SUCCESS, rc); test_compare(test_literal_param_size(__func__), value_length); test_memcmp(__func__, value, value_length); /* Check to make sure that the raw value is not the original. */ size_t raw_value_length; char *raw_value; test_true((raw_value= memcached_get(memc_no_crypt, test_literal_param(__func__), // Key &raw_value_length, NULL, &rc))); test_compare(MEMCACHED_SUCCESS, rc); test_ne_compare(test_literal_param_size(__func__), raw_value_length); test_ne_compare(0, memcmp(__func__, raw_value, raw_value_length)); /* Now we will use our clone, and make sure the encrypted values are the same. */ size_t second_value_length; char *second_value; test_true((second_value= memcached_get(memc_crypt, test_literal_param(__func__), // Key &second_value_length, NULL, &rc))); test_compare(MEMCACHED_SUCCESS, rc); test_compare(value_length, second_value_length); test_compare(0, memcmp(value, second_value, second_value_length)); test_compare(test_literal_param_size(__func__), second_value_length); test_compare(value_length, second_value_length); test_memcmp(__func__, second_value, second_value_length); test_memcmp(value, second_value, second_value_length); free(value); free(raw_value); free(second_value); } memcached_free(memc_no_crypt); memcached_free(memc_crypt); return TEST_SUCCESS; } test_return_t memcached_set_encoding_key_set_grow_key_TEST(memcached_st* memc) { memcached_st *memc_no_crypt= memcached_clone(NULL, memc); test_true(memc_no_crypt); test_compare(MEMCACHED_SUCCESS, memcached_set_encoding_key(memc, test_literal_param(__func__))); size_t payload_size[] = { 100, 1000, 10000, 1000000, 1000000, 0 }; libtest::vchar_t payload; for (size_t *ptr= payload_size; *ptr; ptr++) { payload.reserve(*ptr); for (size_t x= payload.size(); x < *ptr; x++) { payload.push_back(rand()); } { memcached_return_t rc= memcached_set(memc, test_literal_param(__func__), // Key &payload[0], payload.size(), // Value time_t(0), uint32_t(0)); // If we run out of space on the server, we just end the test early. if (rc == MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE) { break; } test_compare_hint(MEMCACHED_SUCCESS, rc, memcached_last_error_message(memc)); } { memcached_return_t rc; size_t value_length; char *value; test_true((value= memcached_get(memc, test_literal_param(__func__), // Key &value_length, NULL, &rc))); test_compare(MEMCACHED_SUCCESS, rc); test_compare(payload.size(), value_length); test_memcmp(&payload[0], value, value_length); size_t raw_value_length; char *raw_value; test_true((raw_value= memcached_get(memc_no_crypt, test_literal_param(__func__), // Key &raw_value_length, NULL, &rc))); test_compare(MEMCACHED_SUCCESS, rc); test_ne_compare(payload.size(), raw_value_length); test_ne_compare(0, memcmp(&payload[0], raw_value, raw_value_length)); free(value); free(raw_value); } } memcached_free(memc_no_crypt); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/all_tests.cc0000664000076400007640000000617111753763014022747 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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 #include #include "tests/basic.h" #include "tests/debug.h" #include "tests/deprecated.h" #include "tests/error_conditions.h" #include "tests/exist.h" #include "tests/ketama.h" #include "tests/namespace.h" #include "tests/libmemcached-1.0/dump.h" #include "tests/libmemcached-1.0/generate.h" #include "tests/libmemcached-1.0/haldenbrand.h" #include "tests/libmemcached-1.0/parser.h" #include "tests/libmemcached-1.0/stat.h" #include "tests/touch.h" #include "tests/callbacks.h" #include "tests/pool.h" #include "tests/print.h" #include "tests/replication.h" #include "tests/server_add.h" #include "tests/virtual_buckets.h" #include "tests/libmemcached-1.0/setup_and_teardowns.h" #include "tests/libmemcached-1.0/mem_functions.h" #include "tests/libmemcached-1.0/encoding_key.h" /* Collections we are running */ #include "tests/libmemcached-1.0/all_tests.h" #include "tests/libmemcached_world.h" void get_world(Framework *world) { if (getenv("LIBMEMCACHED_SERVER_NUMBER")) { unsigned long int set_count= strtoul(getenv("LIBMEMCACHED_SERVER_NUMBER"), (char **) NULL, 10); fatal_assert(set_count >= 1); world->servers().set_servers_to_run(set_count); } else { world->servers().set_servers_to_run(8); } world->collections(collection); world->create((test_callback_create_fn*)world_create); world->destroy((test_callback_destroy_fn*)world_destroy); world->set_runner(new LibmemcachedRunner); world->set_socket(); } libmemcached-1.0.8/tests/libmemcached-1.0/dump.h0000664000076400007640000000336111753573717021573 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached 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. * */ #pragma once test_return_t memcached_dump_TEST(memcached_st *); test_return_t memcached_dump_TEST2(memcached_st *); libmemcached-1.0.8/tests/libmemcached-1.0/sasl.cc0000664000076400007640000000705311753763014021717 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 #include using namespace libtest; /* Test cases */ #include static test_return_t pre_sasl(memcached_st *) { if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0) { return TEST_SKIPPED; } return TEST_SUCCESS; } /* * Test that the sasl authentication works. We cannot use the default * pool of servers, because that would require that all servers we want * to test supports SASL authentication, and that they use the default * creds. */ static test_return_t sasl_auth_test(memcached_st *memc) { if (LIBMEMCACHED_WITH_SASL_SUPPORT) { test_compare(MEMCACHED_SUCCESS, memcached_set(memc, "foo", 3, "bar", 3, (time_t)0, (uint32_t)0)); test_compare(MEMCACHED_SUCCESS, memcached_delete(memc, "foo", 3, 0)); test_compare(MEMCACHED_SUCCESS, memcached_destroy_sasl_auth_data(memc)); test_compare(MEMCACHED_SUCCESS, memcached_destroy_sasl_auth_data(memc)); test_compare(MEMCACHED_INVALID_ARGUMENTS, memcached_destroy_sasl_auth_data(NULL)); memcached_quit(memc); test_compare(MEMCACHED_AUTH_FAILURE, memcached_set(memc, "foo", 3, "bar", 3, (time_t)0, (uint32_t)0)); test_compare(MEMCACHED_SUCCESS, memcached_destroy_sasl_auth_data(memc)); memcached_quit(memc); return TEST_SUCCESS; } return TEST_SKIPPED; } test_st sasl_auth_tests[]= { {"sasl_auth", true, (test_callback_fn*)sasl_auth_test }, {0, 0, (test_callback_fn*)0} }; collection_st collection[] ={ {"sasl_auth", (test_callback_fn*)pre_sasl, 0, sasl_auth_tests }, #if 0 {"sasl", (test_callback_fn*)pre_sasl, 0, tests }, #endif {0, 0, 0, 0} }; #include "tests/libmemcached_world.h" void get_world(Framework *world) { world->collections(collection); world->create((test_callback_create_fn*)world_create); world->destroy((test_callback_destroy_fn*)world_destroy); world->set_runner(new LibmemcachedRunner); world->set_sasl("memcached", "memcached"); } libmemcached-1.0.8/tests/libmemcached-1.0/callback_counter.h0000664000076400007640000000340611753573717024121 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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. * */ #pragma once memcached_return_t callback_counter(const memcached_st*, memcached_result_st*, void *); libmemcached-1.0.8/tests/libmemcached-1.0/setup_and_teardowns.h0000664000076400007640000000532511753573717024700 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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. * */ #pragma once memcached_return_t return_value_based_on_buffering(memcached_st*); test_return_t pre_behavior_ketama(memcached_st*); test_return_t pre_behavior_ketama_weighted(memcached_st*); test_return_t pre_binary(memcached_st*); test_return_t pre_cork(memcached_st*); test_return_t pre_cork_and_nonblock(memcached_st*); test_return_t pre_crc(memcached_st*); test_return_t pre_hash_fnv1_32(memcached_st*); test_return_t pre_hash_fnv1_64(memcached_st*); test_return_t pre_hash_fnv1a_32(memcached_st*); test_return_t pre_hash_fnv1a_64(memcached_st*); test_return_t pre_hsieh(memcached_st*); test_return_t pre_jenkins(memcached_st*); test_return_t pre_md5(memcached_st*); test_return_t pre_murmur(memcached_st*); test_return_t pre_nodelay(memcached_st*); test_return_t pre_nonblock(memcached_st*); test_return_t pre_nonblock_binary(memcached_st*); test_return_t pre_replication(memcached_st*); test_return_t pre_replication_noblock(memcached_st*); test_return_t pre_settimer(memcached_st*); test_return_t pre_unix_socket(memcached_st*); test_return_t pre_buffer(memcached_st*); libmemcached-1.0.8/tests/libmemcached-1.0/setup_and_teardowns.cc0000664000076400007640000001701211753573717025032 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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 #include #include #include "tests/print.h" #include "tests/libmemcached-1.0/setup_and_teardowns.h" #include using namespace libtest; memcached_return_t return_value_based_on_buffering(memcached_st *memc) { if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS)) { return MEMCACHED_BUFFERED; } return MEMCACHED_SUCCESS; } /** @note This should be testing to see if the server really supports the binary protocol. */ test_return_t pre_binary(memcached_st *memc) { test_true(memcached_server_count(memc) > 0); test_skip(true, libmemcached_util_version_check(memc, 1, 4, 4)); test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, true)); return TEST_SUCCESS; } test_return_t pre_buffer(memcached_st *memc) { test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true)); return TEST_SUCCESS; } test_return_t pre_unix_socket(memcached_st *memc) { struct stat buf; memcached_servers_reset(memc); const char *socket_file= libtest::default_socket(); test_skip(true, bool(socket_file)); test_skip(0, stat(socket_file, &buf)); test_compare(MEMCACHED_SUCCESS, memcached_server_add_unix_socket_with_weight(memc, socket_file, 0)); return TEST_SUCCESS; } test_return_t pre_nodelay(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 0); return TEST_SUCCESS; } test_return_t pre_settimer(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SND_TIMEOUT, 1000); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RCV_TIMEOUT, 1000); return TEST_SUCCESS; } test_return_t pre_murmur(memcached_st *memc) { test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MURMUR)); return TEST_SUCCESS; } test_return_t pre_jenkins(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_JENKINS); return TEST_SKIPPED; } test_return_t pre_md5(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MD5); return TEST_SUCCESS; } test_return_t pre_crc(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_CRC); return TEST_SUCCESS; } test_return_t pre_hsieh(memcached_st *memc) { test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_HSIEH)); return TEST_SUCCESS; } test_return_t pre_hash_fnv1_64(memcached_st *memc) { test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MURMUR)); return TEST_SUCCESS; } test_return_t pre_hash_fnv1a_64(memcached_st *memc) { test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1A_64)); return TEST_SUCCESS; } test_return_t pre_hash_fnv1_32(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1_32); return TEST_SUCCESS; } test_return_t pre_hash_fnv1a_32(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1A_32); return TEST_SUCCESS; } test_return_t pre_behavior_ketama(memcached_st *memc) { memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA, 1); test_compare(MEMCACHED_SUCCESS, rc); uint64_t value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA); test_compare(value, uint64_t(1)); return TEST_SUCCESS; } test_return_t pre_behavior_ketama_weighted(memcached_st *memc) { memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1); test_compare(MEMCACHED_SUCCESS, rc); uint64_t value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED); test_compare(value, uint64_t(1)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5)); value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH); test_compare(MEMCACHED_HASH_MD5, memcached_hash_t(value)); return TEST_SUCCESS; } test_return_t pre_replication(memcached_st *memc) { test_skip(TEST_SUCCESS, pre_binary(memc)); /* * Make sure that we store the item on all servers * (master + replicas == number of servers) */ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, memcached_server_count(memc) - 1)); test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS), uint64_t(memcached_server_count(memc) - 1)); return TEST_SUCCESS; } test_return_t pre_replication_noblock(memcached_st *memc) { test_skip(TEST_SUCCESS, pre_replication(memc)); return pre_nonblock(memc); } test_return_t pre_nonblock(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); return TEST_SUCCESS; } test_return_t pre_nonblock_binary(memcached_st *memc) { memcached_st *memc_clone= memcached_clone(NULL, memc); test_true(memc_clone); // The memcached_version needs to be done on a clone, because the server // will not toggle protocol on an connection. memcached_version(memc_clone); memcached_return_t rc= MEMCACHED_FAILURE; if (libmemcached_util_version_check(memc_clone, 1, 4, 4)) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1)); test_compare(uint64_t(1), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); } else { memcached_free(memc_clone); return TEST_SKIPPED; } memcached_free(memc_clone); return rc == MEMCACHED_SUCCESS ? TEST_SUCCESS : TEST_SKIPPED; } libmemcached-1.0.8/tests/libmemcached-1.0/basic.cc0000664000076400007640000000666411753573717022056 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached * * Copyright (C) 2011 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 #include #include #include #include "tests/basic.h" #include test_return_t basic_init_test(memcached_st *junk) { (void)junk; memcached_st memc; memcached_st *memc_ptr; memc_ptr= memcached_create(&memc); test_true(memc_ptr); test_false(memcached_is_allocated(&memc)); memcached_free(memc_ptr); return TEST_SUCCESS; } test_return_t basic_clone_test(memcached_st *memc) { memcached_st *memc_ptr; memc_ptr= memcached_clone(NULL, memc); test_true(memc_ptr); test_true(memcached_is_allocated(memc_ptr)); memcached_free(memc_ptr); return TEST_SUCCESS; } test_return_t basic_reset_stack_test(memcached_st *junk) { (void)junk; memcached_st memc; memcached_create(&memc); memcached_reset(&memc); test_false(memcached_is_allocated(&memc)); memcached_free(&memc); test_false(memcached_is_allocated(&memc)); return TEST_SUCCESS; } test_return_t basic_reset_heap_test(memcached_st *junk) { (void)junk; memcached_st *memc_ptr; memc_ptr= memcached_create(NULL); test_true(memcached_is_allocated(memc_ptr)); memcached_reset(memc_ptr); test_true(memcached_is_allocated(memc_ptr)); memcached_free(memc_ptr); return TEST_SUCCESS; } test_return_t basic_reset_stack_clone_test(memcached_st *memc) { memcached_st clone; memcached_st *memc_ptr; memset(&clone, 0, sizeof(clone)); memc_ptr= memcached_clone(&clone, memc); test_true(memc_ptr); memcached_reset(memc_ptr); memcached_free(memc_ptr); return TEST_SUCCESS; } test_return_t basic_reset_heap_clone_test(memcached_st *memc) { memcached_st *memc_ptr; memc_ptr= memcached_clone(NULL, memc); test_true(memc_ptr); memcached_reset(memc_ptr); memcached_free(memc_ptr); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/fetch_all_results.h0000664000076400007640000000350311753573717024326 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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. * */ #pragma once test_return_t fetch_all_results(memcached_st *, unsigned int&, memcached_return_t&); test_return_t fetch_all_results(memcached_st *, unsigned int&); libmemcached-1.0.8/tests/libmemcached-1.0/internals.cc0000664000076400007640000000460711753763014022756 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached internals test * * Copyright (C) 2011 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 #include using namespace libtest; #include "tests/string.h" /* Test cases */ test_st string_tests[] ={ {"string static with null", false, string_static_null }, {"string alloc with null", false, string_alloc_null }, {"string alloc with 1K", false, string_alloc_with_size }, {"string alloc with malloc failure", false, string_alloc_with_size_toobig }, {"string append", false, string_alloc_append }, {"string append failure (too big)", false, string_alloc_append_toobig }, {"string_alloc_append_multiple", false, string_alloc_append_multiple }, {0, 0, 0} }; collection_st collection[] ={ {"string", 0, 0, string_tests}, {0, 0, 0, 0} }; void get_world(Framework *frame) { frame->collections(collection); } libmemcached-1.0.8/tests/libmemcached-1.0/ketama.cc0000664000076400007640000002613411753573717022231 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 #include #include #include #include #include #include test_return_t ketama_compatibility_libmemcached(memcached_st *) { memcached_st *memc= memcached_create(NULL); test_true(memc); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1)); test_compare(uint64_t(1), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA)); test_compare(MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA, memcached_behavior_get_distribution(memc)); memcached_server_st *server_pool= memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100"); memcached_server_push(memc, server_pool); /* verify that the server list was parsed okay. */ test_compare(8U, memcached_server_count(memc)); test_strcmp(server_pool[0].hostname, "10.0.1.1"); test_compare(in_port_t(11211), server_pool[0].port); test_compare(600U, server_pool[0].weight); test_strcmp(server_pool[2].hostname, "10.0.1.3"); test_compare(in_port_t(11211), server_pool[2].port); test_compare(200U, server_pool[2].weight); test_strcmp(server_pool[7].hostname, "10.0.1.8"); test_compare(in_port_t(11211), server_pool[7].port); test_compare(100U, server_pool[7].weight); /* VDEAAAAA hashes to fffcd1b5, after the last continuum point, and lets * us test the boundary wraparound. */ test_true(memcached_generate_hash(memc, (char *)"VDEAAAAA", 8) == memc->ketama.continuum[0].index); /* verify the standard ketama set. */ for (uint32_t x= 0; x < 99; x++) { uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key)); memcached_server_instance_st instance= memcached_server_instance_by_position(memc, server_idx); const char *hostname = memcached_server_name(instance); test_strcmp(hostname, ketama_test_cases[x].server); } memcached_server_list_free(server_pool); memcached_free(memc); return TEST_SUCCESS; } test_return_t user_supplied_bug18(memcached_st *trash) { memcached_return_t rc; uint64_t value; int x; memcached_st *memc; (void)trash; memc= memcached_create(NULL); test_true(memc); rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1); test_compare(MEMCACHED_SUCCESS, rc); value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED); test_true(value == 1); rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5); test_compare(MEMCACHED_SUCCESS, rc); value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH); test_true(value == MEMCACHED_HASH_MD5); memcached_server_st *server_pool= memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100"); memcached_server_push(memc, server_pool); /* verify that the server list was parsed okay. */ test_true(memcached_server_count(memc) == 8); test_strcmp(server_pool[0].hostname, "10.0.1.1"); test_true(server_pool[0].port == 11211); test_true(server_pool[0].weight == 600); test_strcmp(server_pool[2].hostname, "10.0.1.3"); test_true(server_pool[2].port == 11211); test_true(server_pool[2].weight == 200); test_strcmp(server_pool[7].hostname, "10.0.1.8"); test_true(server_pool[7].port == 11211); test_true(server_pool[7].weight == 100); /* VDEAAAAA hashes to fffcd1b5, after the last continuum point, and lets * us test the boundary wraparound. */ test_true(memcached_generate_hash(memc, (char *)"VDEAAAAA", 8) == memc->ketama.continuum[0].index); /* verify the standard ketama set. */ for (x= 0; x < 99; x++) { uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key)); memcached_server_instance_st instance= memcached_server_instance_by_position(memc, server_idx); const char *hostname = memcached_server_name(instance); test_strcmp(hostname, ketama_test_cases[x].server); } memcached_server_list_free(server_pool); memcached_free(memc); return TEST_SUCCESS; } test_return_t auto_eject_hosts(memcached_st *trash) { (void) trash; memcached_server_instance_st instance; memcached_return_t rc; memcached_st *memc= memcached_create(NULL); test_true(memc); rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1); test_compare(MEMCACHED_SUCCESS, rc); uint64_t value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED); test_true(value == 1); rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5); test_compare(MEMCACHED_SUCCESS, rc); value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH); test_true(value == MEMCACHED_HASH_MD5); /* server should be removed when in delay */ rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS, 1); test_compare(MEMCACHED_SUCCESS, rc); value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS); test_true(value == 1); memcached_server_st *server_pool; server_pool = memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100"); memcached_server_push(memc, server_pool); /* verify that the server list was parsed okay. */ test_true(memcached_server_count(memc) == 8); test_strcmp(server_pool[0].hostname, "10.0.1.1"); test_true(server_pool[0].port == 11211); test_true(server_pool[0].weight == 600); test_strcmp(server_pool[2].hostname, "10.0.1.3"); test_true(server_pool[2].port == 11211); test_true(server_pool[2].weight == 200); test_strcmp(server_pool[7].hostname, "10.0.1.8"); test_true(server_pool[7].port == 11211); test_true(server_pool[7].weight == 100); instance= memcached_server_instance_by_position(memc, 2); ((memcached_server_write_instance_st)instance)->next_retry = time(NULL) + 15; memc->ketama.next_distribution_rebuild= time(NULL) - 1; /* This would not work if there were only two hosts. */ for (ptrdiff_t x= 0; x < 99; x++) { memcached_autoeject(memc); uint32_t server_idx= memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key)); test_true(server_idx != 2); } /* and re-added when it's back. */ ((memcached_server_write_instance_st)instance)->next_retry = time(NULL) - 1; memc->ketama.next_distribution_rebuild= time(NULL) - 1; memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, memc->distribution); for (ptrdiff_t x= 0; x < 99; x++) { uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key)); // We re-use instance from above. instance= memcached_server_instance_by_position(memc, server_idx); const char *hostname = memcached_server_name(instance); test_strcmp(hostname, ketama_test_cases[x].server); } memcached_server_list_free(server_pool); memcached_free(memc); return TEST_SUCCESS; } test_return_t ketama_compatibility_spymemcached(memcached_st *) { memcached_st *memc= memcached_create(NULL); test_true(memc); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1)); test_compare(UINT64_C(1), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY)); test_compare(MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY, memcached_behavior_get_distribution(memc)); memcached_server_st *server_pool= memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100"); test_true(server_pool); memcached_server_push(memc, server_pool); /* verify that the server list was parsed okay. */ test_compare(8U, memcached_server_count(memc)); test_strcmp(server_pool[0].hostname, "10.0.1.1"); test_compare(in_port_t(11211), server_pool[0].port); test_compare(600U, server_pool[0].weight); test_strcmp(server_pool[2].hostname, "10.0.1.3"); test_compare(in_port_t(11211), server_pool[2].port); test_compare(200U, server_pool[2].weight); test_strcmp(server_pool[7].hostname, "10.0.1.8"); test_compare(in_port_t(11211), server_pool[7].port); test_compare(100U, server_pool[7].weight); /* VDEAAAAA hashes to fffcd1b5, after the last continuum point, and lets * us test the boundary wraparound. */ test_true(memcached_generate_hash(memc, (char *)"VDEAAAAA", 8) == memc->ketama.continuum[0].index); /* verify the standard ketama set. */ for (uint32_t x= 0; x < 99; x++) { uint32_t server_idx= memcached_generate_hash(memc, ketama_test_cases_spy[x].key, strlen(ketama_test_cases_spy[x].key)); memcached_server_instance_st instance= memcached_server_instance_by_position(memc, server_idx); const char *hostname= memcached_server_name(instance); test_strcmp(hostname, ketama_test_cases_spy[x].server); } memcached_server_list_free(server_pool); memcached_free(memc); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/memcached_get.cc0000664000076400007640000001651211753573717023533 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached 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 #include /* Test cases */ #include #include "tests/libmemcached-1.0/memcached_get.h" #include "tests/libmemcached-1.0/setup_and_teardowns.h" test_return_t get_test(memcached_st *memc) { uint64_t query_id= memcached_query_id(memc); memcached_return_t rc= memcached_delete(memc, test_literal_param(__func__), time_t(0)); test_true_hint(rc == MEMCACHED_BUFFERED or rc == MEMCACHED_NOTFOUND, memcached_last_error_message(memc)); test_compare(query_id +1, memcached_query_id(memc)); size_t string_length; uint32_t flags; char *string= memcached_get(memc, test_literal_param(__func__), &string_length, &flags, &rc); test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_last_error_message(memc)); test_false(string_length); test_false(string); return TEST_SUCCESS; } test_return_t get_test2(memcached_st *memc) { const char *value= "when we sanitize"; uint64_t query_id= memcached_query_id(memc); test_compare(return_value_based_on_buffering(memc), memcached_set(memc, test_literal_param(__func__), value, strlen(value), time_t(0), uint32_t(0))); test_compare(query_id +1, memcached_query_id(memc)); query_id= memcached_query_id(memc); test_true(query_id); uint32_t flags; size_t string_length; memcached_return_t rc; char *string= memcached_get(memc, test_literal_param(__func__), &string_length, &flags, &rc); test_compare(query_id +1, memcached_query_id(memc)); test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); test_compare_got(MEMCACHED_SUCCESS, memcached_last_error(memc), memcached_last_error_message(memc)); test_true(string); test_compare(strlen(value), string_length); test_memcmp(string, value, string_length); free(string); return TEST_SUCCESS; } test_return_t get_test3(memcached_st *memc) { size_t value_length= 8191; libtest::vchar_t value; value.reserve(value_length); for (uint32_t x= 0; x < value_length; x++) { value.push_back(char(x % 127)); } test_compare_hint(return_value_based_on_buffering(memc), memcached_set(memc, test_literal_param(__func__), &value[0], value.size(), time_t(0), uint32_t(0)), memcached_last_error_message(memc)); size_t string_length; uint32_t flags; memcached_return_t rc; char *string= memcached_get(memc, test_literal_param(__func__), &string_length, &flags, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(string); test_compare(value.size(), string_length); test_memcmp(string, &value[0], string_length); free(string); return TEST_SUCCESS; } test_return_t get_test4(memcached_st *memc) { size_t value_length= 8191; libtest::vchar_t value; value.reserve(value_length); for (uint32_t x= 0; x < value_length; x++) { value.push_back(char(x % 127)); } test_compare_hint(return_value_based_on_buffering(memc), memcached_set(memc, test_literal_param(__func__), &value[0], value.size(), time_t(0), uint32_t(0)), memcached_last_error_message(memc)); for (uint32_t x= 0; x < 10; x++) { uint32_t flags; size_t string_length; memcached_return_t rc; char *string= memcached_get(memc, test_literal_param(__func__), &string_length, &flags, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(string); test_compare(value.size(), string_length); test_memcmp(string, &value[0], string_length); free(string); } return TEST_SUCCESS; } /* * This test verifies that memcached_read_one_response doesn't try to * dereference a NIL-pointer if you issue a multi-get and don't read out all * responses before you execute a storage command. */ test_return_t get_test5(memcached_st *memc) { /* ** Request the same key twice, to ensure that we hash to the same server ** (so that we have multiple response values queued up) ;-) */ const char *keys[]= { "key", "key" }; size_t lengths[]= { 3, 3 }; uint32_t flags; size_t rlen; test_compare_hint(return_value_based_on_buffering(memc), memcached_set(memc, keys[0], lengths[0], keys[0], lengths[0], time_t(0), uint32_t(0)), memcached_last_error_message(memc)); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, lengths, test_array_length(keys))); memcached_result_st results_obj; memcached_result_st *results= memcached_result_create(memc, &results_obj); test_true(results); memcached_return_t rc; results= memcached_fetch_result(memc, &results_obj, &rc); test_true(results); memcached_result_free(&results_obj); /* Don't read out the second result, but issue a set instead.. */ test_compare(MEMCACHED_SUCCESS, memcached_set(memc, keys[0], lengths[0], keys[0], lengths[0], 0, 0)); char *val= memcached_get_by_key(memc, keys[0], lengths[0], "yek", 3, &rlen, &flags, &rc); test_false(val); test_compare(MEMCACHED_NOTFOUND, rc); val= memcached_get(memc, keys[0], lengths[0], &rlen, &flags, &rc); test_true(val); test_compare(MEMCACHED_SUCCESS, rc); free(val); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/deprecated.cc0000664000076400007640000000520011753573717023056 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include #include #include #include test_return_t server_list_null_test(memcached_st *ptr) { memcached_server_st *server_list; memcached_return_t rc; (void)ptr; server_list= memcached_server_list_append_with_weight(NULL, NULL, 0, 0, NULL); test_true(server_list); memcached_server_list_free(server_list); server_list= memcached_server_list_append_with_weight(NULL, "localhost", 0, 0, NULL); test_true(server_list); memcached_server_list_free(server_list); server_list= memcached_server_list_append_with_weight(NULL, NULL, 0, 0, &rc); test_true(server_list); memcached_server_list_free(server_list); return TEST_SUCCESS; } // Look for memory leak test_return_t regression_bug_728286(memcached_st *) { memcached_server_st *servers= memcached_servers_parse("1.2.3.4:99"); fatal_assert(servers); memcached_server_free(servers); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/mem_functions.cc0000664000076400007640000045306011756611200023616 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include #include #if defined(HAVE_LIBUUID) && HAVE_LIBUUID #include #endif /* Test cases */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "clients/generator.h" #define SMALL_STRING_LEN 1024 #include using namespace libtest; #include #include "tests/hash_results.h" #include "tests/libmemcached-1.0/callback_counter.h" #include "tests/libmemcached-1.0/fetch_all_results.h" #include "tests/libmemcached-1.0/mem_functions.h" #include "tests/libmemcached-1.0/setup_and_teardowns.h" #include "tests/print.h" #include "tests/debug.h" #define UUID_STRING_MAXLENGTH 36 #include "tests/keys.hpp" static memcached_st * create_single_instance_memcached(const memcached_st *original_memc, const char *options) { /* If no options are given, copy over at least the binary flag. */ char options_buffer[1024]= { 0 }; if (options == NULL) { if (memcached_is_binary(original_memc)) { snprintf(options_buffer, sizeof(options_buffer), "--BINARY"); } } /* * I only want to hit _one_ server so I know the number of requests I'm * sending in the pipeline. */ memcached_server_instance_st instance= memcached_server_instance_by_position(original_memc, 0); char server_string[1024]; int server_string_length; if (instance->type == MEMCACHED_CONNECTION_UNIX_SOCKET) { if (options) { server_string_length= snprintf(server_string, sizeof(server_string), "--SOCKET=\"%s\" %s", memcached_server_name(instance), options); } else { server_string_length= snprintf(server_string, sizeof(server_string), "--SOCKET=\"%s\"", memcached_server_name(instance)); } } else { if (options) { server_string_length= snprintf(server_string, sizeof(server_string), "--server=%s:%d %s", memcached_server_name(instance), int(memcached_server_port(instance)), options); } else { server_string_length= snprintf(server_string, sizeof(server_string), "--server=%s:%d", memcached_server_name(instance), int(memcached_server_port(instance))); } } if (server_string_length <= 0) { return NULL; } char errror_buffer[1024]; if (memcached_failed(libmemcached_check_configuration(server_string, server_string_length, errror_buffer, sizeof(errror_buffer)))) { Error << "Failed to parse (" << server_string << ") " << errror_buffer; return NULL; } return memcached(server_string, server_string_length); } test_return_t init_test(memcached_st *not_used) { memcached_st memc; (void)not_used; (void)memcached_create(&memc); memcached_free(&memc); return TEST_SUCCESS; } #define TEST_PORT_COUNT 7 in_port_t test_ports[TEST_PORT_COUNT]; static memcached_return_t server_display_function(const memcached_st *ptr, const memcached_server_st *server, void *context) { /* Do Nothing */ size_t bigger= *((size_t *)(context)); (void)ptr; fatal_assert(bigger <= memcached_server_port(server)); *((size_t *)(context))= memcached_server_port(server); return MEMCACHED_SUCCESS; } static memcached_return_t dump_server_information(const memcached_st *ptr, const memcached_server_st *instance, void *context) { /* Do Nothing */ FILE *stream= (FILE *)context; (void)ptr; fprintf(stream, "Memcached Server: %s %u Version %u.%u.%u\n", memcached_server_name(instance), memcached_server_port(instance), instance->major_version, instance->minor_version, instance->micro_version); return MEMCACHED_SUCCESS; } test_return_t server_sort_test(memcached_st *ptr) { size_t bigger= 0; /* Prime the value for the test_true in server_display_function */ memcached_return_t rc; memcached_server_fn callbacks[1]; memcached_st *local_memc; (void)ptr; local_memc= memcached_create(NULL); test_true(local_memc); memcached_behavior_set(local_memc, MEMCACHED_BEHAVIOR_SORT_HOSTS, 1); for (uint32_t x= 0; x < TEST_PORT_COUNT; x++) { test_ports[x]= (in_port_t)random() % 64000; rc= memcached_server_add_with_weight(local_memc, "localhost", test_ports[x], 0); test_compare(memcached_server_count(local_memc), x +1); #if 0 // Rewrite test_true(memcached_server_list_count(memcached_server_list(local_memc)) == x+1); #endif test_compare(MEMCACHED_SUCCESS, rc); } callbacks[0]= server_display_function; memcached_server_cursor(local_memc, callbacks, (void *)&bigger, 1); memcached_free(local_memc); return TEST_SUCCESS; } test_return_t server_sort2_test(memcached_st *ptr) { size_t bigger= 0; /* Prime the value for the test_true in server_display_function */ memcached_server_fn callbacks[1]; memcached_st *local_memc; memcached_server_instance_st instance; (void)ptr; local_memc= memcached_create(NULL); test_true(local_memc); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(local_memc, MEMCACHED_BEHAVIOR_SORT_HOSTS, 1)); test_compare(MEMCACHED_SUCCESS, memcached_server_add_with_weight(local_memc, "MEMCACHED_BEHAVIOR_SORT_HOSTS", 43043, 0)); instance= memcached_server_instance_by_position(local_memc, 0); test_compare(in_port_t(43043), memcached_server_port(instance)); test_compare(MEMCACHED_SUCCESS, memcached_server_add_with_weight(local_memc, "MEMCACHED_BEHAVIOR_SORT_HOSTS", 43042, 0)); instance= memcached_server_instance_by_position(local_memc, 0); test_compare(in_port_t(43042), memcached_server_port(instance)); instance= memcached_server_instance_by_position(local_memc, 1); test_compare(in_port_t(43043), memcached_server_port(instance)); callbacks[0]= server_display_function; memcached_server_cursor(local_memc, callbacks, (void *)&bigger, 1); memcached_free(local_memc); return TEST_SUCCESS; } test_return_t memcached_server_remove_test(memcached_st*) { const char *server_string= "--server=localhost:4444 --server=localhost:4445 --server=localhost:4446 --server=localhost:4447 --server=localhost --server=memcache1.memcache.bk.sapo.pt:11211 --server=memcache1.memcache.bk.sapo.pt:11212 --server=memcache1.memcache.bk.sapo.pt:11213 --server=memcache1.memcache.bk.sapo.pt:11214 --server=memcache2.memcache.bk.sapo.pt:11211 --server=memcache2.memcache.bk.sapo.pt:11212 --server=memcache2.memcache.bk.sapo.pt:11213 --server=memcache2.memcache.bk.sapo.pt:11214"; char buffer[BUFSIZ]; test_compare(MEMCACHED_SUCCESS, libmemcached_check_configuration(server_string, strlen(server_string), buffer, sizeof(buffer))); memcached_st *memc= memcached(server_string, strlen(server_string)); test_true(memc); memcached_server_fn callbacks[1]; callbacks[0]= server_print_callback; memcached_server_cursor(memc, callbacks, NULL, 1); memcached_free(memc); return TEST_SUCCESS; } static memcached_return_t server_display_unsort_function(const memcached_st*, const memcached_server_st *server, void *context) { /* Do Nothing */ uint32_t x= *((uint32_t *)(context)); if (! (test_ports[x] == server->port)) { fprintf(stderr, "%lu -> %lu\n", (unsigned long)test_ports[x], (unsigned long)server->port); return MEMCACHED_FAILURE; } *((uint32_t *)(context))= ++x; return MEMCACHED_SUCCESS; } test_return_t server_unsort_test(memcached_st *ptr) { size_t counter= 0; /* Prime the value for the test_true in server_display_function */ size_t bigger= 0; /* Prime the value for the test_true in server_display_function */ memcached_server_fn callbacks[1]; memcached_st *local_memc; (void)ptr; local_memc= memcached_create(NULL); test_true(local_memc); for (uint32_t x= 0; x < TEST_PORT_COUNT; x++) { test_ports[x]= (in_port_t)(random() % 64000); test_compare(MEMCACHED_SUCCESS, memcached_server_add_with_weight(local_memc, "localhost", test_ports[x], 0)); test_compare(memcached_server_count(local_memc), x +1); #if 0 // Rewrite test_true(memcached_server_list_count(memcached_server_list(local_memc)) == x+1); #endif } callbacks[0]= server_display_unsort_function; memcached_server_cursor(local_memc, callbacks, (void *)&counter, 1); /* Now we sort old data! */ memcached_behavior_set(local_memc, MEMCACHED_BEHAVIOR_SORT_HOSTS, 1); callbacks[0]= server_display_function; memcached_server_cursor(local_memc, callbacks, (void *)&bigger, 1); memcached_free(local_memc); return TEST_SUCCESS; } test_return_t allocation_test(memcached_st *not_used) { (void)not_used; memcached_st *memc; memc= memcached_create(NULL); test_true(memc); memcached_free(memc); return TEST_SUCCESS; } test_return_t clone_test(memcached_st *memc) { /* All null? */ { memcached_st *memc_clone; memc_clone= memcached_clone(NULL, NULL); test_true(memc_clone); memcached_free(memc_clone); } /* Can we init from null? */ { memcached_st *memc_clone; memc_clone= memcached_clone(NULL, memc); test_true(memc_clone); { // Test allocators test_true(memc_clone->allocators.free == memc->allocators.free); test_true(memc_clone->allocators.malloc == memc->allocators.malloc); test_true(memc_clone->allocators.realloc == memc->allocators.realloc); test_true(memc_clone->allocators.calloc == memc->allocators.calloc); } test_true(memc_clone->connect_timeout == memc->connect_timeout); test_true(memc_clone->delete_trigger == memc->delete_trigger); test_true(memc_clone->distribution == memc->distribution); { // Test all of the flags test_true(memc_clone->flags.no_block == memc->flags.no_block); test_true(memc_clone->flags.tcp_nodelay == memc->flags.tcp_nodelay); test_true(memc_clone->flags.support_cas == memc->flags.support_cas); test_true(memc_clone->flags.buffer_requests == memc->flags.buffer_requests); test_true(memc_clone->flags.use_sort_hosts == memc->flags.use_sort_hosts); test_true(memc_clone->flags.verify_key == memc->flags.verify_key); test_true(memc_clone->ketama.weighted == memc->ketama.weighted); test_true(memc_clone->flags.binary_protocol == memc->flags.binary_protocol); test_true(memc_clone->flags.hash_with_namespace == memc->flags.hash_with_namespace); test_true(memc_clone->flags.reply == memc->flags.reply); test_true(memc_clone->flags.use_udp == memc->flags.use_udp); test_true(memc_clone->flags.auto_eject_hosts == memc->flags.auto_eject_hosts); test_true(memc_clone->flags.randomize_replica_read == memc->flags.randomize_replica_read); } test_true(memc_clone->get_key_failure == memc->get_key_failure); test_true(hashkit_compare(&memc_clone->hashkit, &memc->hashkit)); test_true(memc_clone->io_bytes_watermark == memc->io_bytes_watermark); test_true(memc_clone->io_msg_watermark == memc->io_msg_watermark); test_true(memc_clone->io_key_prefetch == memc->io_key_prefetch); test_true(memc_clone->on_cleanup == memc->on_cleanup); test_true(memc_clone->on_clone == memc->on_clone); test_true(memc_clone->poll_timeout == memc->poll_timeout); test_true(memc_clone->rcv_timeout == memc->rcv_timeout); test_true(memc_clone->recv_size == memc->recv_size); test_true(memc_clone->retry_timeout == memc->retry_timeout); test_true(memc_clone->send_size == memc->send_size); test_true(memc_clone->server_failure_limit == memc->server_failure_limit); test_true(memc_clone->snd_timeout == memc->snd_timeout); test_true(memc_clone->user_data == memc->user_data); memcached_free(memc_clone); } /* Can we init from struct? */ { memcached_st declared_clone; memcached_st *memc_clone; memset(&declared_clone, 0 , sizeof(memcached_st)); memc_clone= memcached_clone(&declared_clone, NULL); test_true(memc_clone); memcached_free(memc_clone); } /* Can we init from struct? */ { memcached_st declared_clone; memcached_st *memc_clone; memset(&declared_clone, 0 , sizeof(memcached_st)); memc_clone= memcached_clone(&declared_clone, memc); test_true(memc_clone); memcached_free(memc_clone); } return TEST_SUCCESS; } test_return_t userdata_test(memcached_st *memc) { void* foo= NULL; test_false(memcached_set_user_data(memc, foo)); test_true(memcached_get_user_data(memc) == foo); test_true(memcached_set_user_data(memc, NULL) == foo); return TEST_SUCCESS; } test_return_t connection_test(memcached_st *memc) { test_compare(MEMCACHED_SUCCESS, memcached_server_add_with_weight(memc, "localhost", 0, 0)); return TEST_SUCCESS; } test_return_t libmemcached_string_behavior_test(memcached_st *) { for (int x= MEMCACHED_BEHAVIOR_NO_BLOCK; x < int(MEMCACHED_BEHAVIOR_MAX); ++x) { test_true(libmemcached_string_behavior(memcached_behavior_t(x))); } test_compare(37, int(MEMCACHED_BEHAVIOR_MAX)); return TEST_SUCCESS; } test_return_t libmemcached_string_distribution_test(memcached_st *) { for (int x= MEMCACHED_DISTRIBUTION_MODULA; x < int(MEMCACHED_DISTRIBUTION_CONSISTENT_MAX); ++x) { test_true(libmemcached_string_distribution(memcached_server_distribution_t(x))); } test_compare(7, int(MEMCACHED_DISTRIBUTION_CONSISTENT_MAX)); return TEST_SUCCESS; } test_return_t memcached_return_t_TEST(memcached_st *memc) { uint32_t values[] = { 851992627U, 2337886783U, 4109241422U, 4001849190U, 982370485U, 1263635348U, 4242906218U, 3829656100U, 1891735253U, 334139633U, 2257084983U, 3351789013U, 13199785U, 2542027183U, 1097051614U, 199566778U, 2748246961U, 2465192557U, 1664094137U, 2405439045U, 1842224848U, 692413798U, 3479807801U, 919913813U, 4269430871U, 610793021U, 527273862U, 1437122909U, 2300930706U, 2943759320U, 674306647U, 2400528935U, 54481931U, 4186304426U, 1741088401U, 2979625118U, 4159057246U, 3425930182U, 2593724503U, 1868899624U, 1769812374U, 2302537950U, 1110330676U, 3365377466U, 1336171666U, 3021258493U, 2334992265U, 3861994737U, 3582734124U, 3365377466U }; // You have updated the memcache_error messages but not updated docs/tests. for (int rc= int(MEMCACHED_SUCCESS); rc < int(MEMCACHED_MAXIMUM_RETURN); ++rc) { uint32_t hash_val; const char *msg= memcached_strerror(memc, memcached_return_t(rc)); hash_val= memcached_generate_hash_value(msg, strlen(msg), MEMCACHED_HASH_JENKINS); if (values[rc] != hash_val) { fprintf(stderr, "\n\nYou have updated memcached_return_t without updating the memcached_return_t_TEST\n"); fprintf(stderr, "%u, %s, (%u)\n\n", (uint32_t)rc, memcached_strerror(memc, memcached_return_t(rc)), hash_val); } test_compare(values[rc], hash_val); } test_compare(49, int(MEMCACHED_MAXIMUM_RETURN)); return TEST_SUCCESS; } test_return_t set_test(memcached_st *memc) { memcached_return_t rc= memcached_set(memc, test_literal_param("foo"), test_literal_param("when we sanitize"), time_t(0), (uint32_t)0); test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_last_error_message(memc)); return TEST_SUCCESS; } test_return_t append_test(memcached_st *memc) { memcached_return_t rc; const char *in_value= "we"; size_t value_length; uint32_t flags; test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param(__func__), in_value, strlen(in_value), time_t(0), uint32_t(0))); test_compare(MEMCACHED_SUCCESS, memcached_append(memc, test_literal_param(__func__), " the", strlen(" the"), time_t(0), uint32_t(0))); test_compare(MEMCACHED_SUCCESS, memcached_append(memc, test_literal_param(__func__), " people", strlen(" people"), time_t(0), uint32_t(0))); char *out_value= memcached_get(memc, test_literal_param(__func__), &value_length, &flags, &rc); test_memcmp(out_value, "we the people", strlen("we the people")); test_compare(strlen("we the people"), value_length); test_compare(MEMCACHED_SUCCESS, rc); free(out_value); return TEST_SUCCESS; } test_return_t append_binary_test(memcached_st *memc) { uint32_t store_list[] = { 23, 56, 499, 98, 32847, 0 }; test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param(__func__), NULL, 0, time_t(0), uint32_t(0))); size_t count= 0; for (uint32_t x= 0; store_list[x] ; x++) { test_compare(MEMCACHED_SUCCESS, memcached_append(memc, test_literal_param(__func__), (char *)&store_list[x], sizeof(uint32_t), time_t(0), uint32_t(0))); count++; } size_t value_length; uint32_t flags; memcached_return_t rc; uint32_t *value= (uint32_t *)memcached_get(memc, test_literal_param(__func__), &value_length, &flags, &rc); test_compare(value_length, sizeof(uint32_t) * count); test_compare(MEMCACHED_SUCCESS, rc); for (uint32_t counter= count, *ptr= value; counter; counter--) { test_compare(*ptr, store_list[count - counter]); ptr++; } free(value); return TEST_SUCCESS; } test_return_t memcached_mget_mixed_memcached_get_TEST(memcached_st *memc) { keys_st keys(200); for (libtest::vchar_ptr_t::iterator iter= keys.begin(); iter != keys.end(); iter++) { test_compare_hint(MEMCACHED_SUCCESS, memcached_set(memc, (*iter), 36, NULL, 0, time_t(0), uint32_t(0)), memcached_last_error_message(memc)); } for (ptrdiff_t loop= 0; loop < 20; loop++) { if (random() %2) { test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys.keys_ptr(), keys.lengths_ptr(), keys.size())); memcached_result_st *results= memcached_result_create(memc, NULL); test_true(results); size_t result_count= 0; memcached_return_t rc; while (memcached_fetch_result(memc, results, &rc)) { result_count++; } test_true(keys.size() >= result_count); } else { int which_key= random() %keys.size(); size_t value_length; uint32_t flags; memcached_return_t rc; char *out_value= memcached_get(memc, keys.key_at(which_key), keys.length_at(which_key), &value_length, &flags, &rc); if (rc == MEMCACHED_NOTFOUND) { } // It is possible that the value has been purged. else { test_compare_hint(MEMCACHED_SUCCESS, rc, memcached_last_error_message(memc)); } test_null(out_value); test_zero(value_length); test_zero(flags); } } return TEST_SUCCESS; } test_return_t cas2_test(memcached_st *memc) { const char *keys[]= {"fudge", "son", "food"}; size_t key_length[]= {5, 3, 4}; const char *value= "we the people"; size_t value_length= strlen("we the people"); test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, true)); for (uint32_t x= 0; x < 3; x++) { test_compare(MEMCACHED_SUCCESS, memcached_set(memc, keys[x], key_length[x], keys[x], key_length[x], time_t(50), uint32_t(9))); } test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 3)); memcached_result_st *results= memcached_result_create(memc, NULL); test_true(results); memcached_return_t rc; results= memcached_fetch_result(memc, results, &rc); test_true(results); test_true(results->item_cas); test_compare(MEMCACHED_SUCCESS, rc); test_true(memcached_result_cas(results)); test_memcmp(value, "we the people", strlen("we the people")); test_compare(strlen("we the people"), value_length); test_compare(MEMCACHED_SUCCESS, rc); memcached_result_free(results); return TEST_SUCCESS; } test_return_t cas_test(memcached_st *memc) { const char* keys[2] = { __func__, NULL }; size_t keylengths[2] = { strlen(__func__), 0 }; memcached_result_st results_obj; test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); test_skip(true, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, true)); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param(__func__), test_literal_param("we the people"), (time_t)0, (uint32_t)0)); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, keylengths, 1)); memcached_result_st *results= memcached_result_create(memc, &results_obj); test_true(results); memcached_return_t rc; results= memcached_fetch_result(memc, &results_obj, &rc); test_true(results); test_compare(MEMCACHED_SUCCESS, rc); test_true(memcached_result_cas(results)); test_memcmp("we the people", memcached_result_value(results), test_literal_param_size("we the people")); test_compare(test_literal_param_size("we the people"), strlen(memcached_result_value(results))); uint64_t cas= memcached_result_cas(results); #if 0 results= memcached_fetch_result(memc, &results_obj, &rc); test_true(rc == MEMCACHED_END); test_true(results == NULL); #endif test_compare(MEMCACHED_SUCCESS, memcached_cas(memc, test_literal_param(__func__), test_literal_param("change the value"), 0, 0, cas)); /* * The item will have a new cas value, so try to set it again with the old * value. This should fail! */ test_compare(MEMCACHED_DATA_EXISTS, memcached_cas(memc, test_literal_param(__func__), test_literal_param("change the value"), 0, 0, cas)); memcached_result_free(&results_obj); return TEST_SUCCESS; } test_return_t prepend_test(memcached_st *memc) { const char *key= "fig"; const char *value= "people"; test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, key, strlen(key), value, strlen(value), time_t(0), uint32_t(0))); test_compare(MEMCACHED_SUCCESS, memcached_prepend(memc, key, strlen(key), "the ", strlen("the "), time_t(0), uint32_t(0))); test_compare(MEMCACHED_SUCCESS, memcached_prepend(memc, key, strlen(key), "we ", strlen("we "), time_t(0), uint32_t(0))); size_t value_length; uint32_t flags; memcached_return_t rc; char *out_value= memcached_get(memc, key, strlen(key), &value_length, &flags, &rc); test_memcmp(out_value, "we the people", strlen("we the people")); test_compare(strlen("we the people"), value_length); test_compare(MEMCACHED_SUCCESS, rc); free(out_value); return TEST_SUCCESS; } /* Set the value, then quit to make sure it is flushed. Come back in and test that add fails. */ test_return_t add_test(memcached_st *memc) { test_compare_hint(return_value_based_on_buffering(memc), memcached_set(memc, test_literal_param(__func__), test_literal_param("when we sanitize"), time_t(0), uint32_t(0)), memcached_last_error_message(memc)); memcached_quit(memc); test_compare_hint(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) ? MEMCACHED_DATA_EXISTS : MEMCACHED_NOTSTORED, memcached_add(memc, test_literal_param(__func__), test_literal_param("try something else"), time_t(0), uint32_t(0)), memcached_last_error_message(memc)); return TEST_SUCCESS; } /* ** There was a problem of leaking filedescriptors in the initial release ** of MacOSX 10.5. This test case triggers the problem. On some Solaris ** systems it seems that the kernel is slow on reclaiming the resources ** because the connects starts to time out (the test doesn't do much ** anyway, so just loop 10 iterations) */ test_return_t add_wrapper(memcached_st *memc) { unsigned int max= 10000; #ifdef __sun max= 10; #endif #ifdef __APPLE__ max= 10; #endif for (uint32_t x= 0; x < max; x++) add_test(memc); return TEST_SUCCESS; } test_return_t replace_test(memcached_st *memc) { test_compare_hint(return_value_based_on_buffering(memc), memcached_set(memc, test_literal_param(__func__), test_literal_param("when we sanitize"), time_t(0), uint32_t(0)), memcached_last_error_message(memc)); test_compare_hint(MEMCACHED_SUCCESS, memcached_replace(memc, test_literal_param(__func__), test_literal_param("first we insert some data"), time_t(0), uint32_t(0)), memcached_last_error_message(memc)); return TEST_SUCCESS; } test_return_t delete_test(memcached_st *memc) { test_compare_hint(return_value_based_on_buffering(memc), memcached_set(memc, test_literal_param(__func__), test_literal_param("when we sanitize"), time_t(0), uint32_t(0)), memcached_last_error_message(memc)); test_compare_hint(return_value_based_on_buffering(memc), memcached_delete(memc, test_literal_param(__func__), time_t(0)), memcached_last_error_message(memc)); return TEST_SUCCESS; } test_return_t flush_test(memcached_st *memc) { uint64_t query_id= memcached_query_id(memc); test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); test_compare(query_id +1, memcached_query_id(memc)); return TEST_SUCCESS; } static memcached_return_t server_function(const memcached_st *, const memcached_server_st *, void *) { /* Do Nothing */ return MEMCACHED_SUCCESS; } test_return_t memcached_server_cursor_test(memcached_st *memc) { char context[10]; strncpy(context, "foo bad", sizeof(context)); memcached_server_fn callbacks[1]; callbacks[0]= server_function; memcached_server_cursor(memc, callbacks, context, 1); return TEST_SUCCESS; } test_return_t bad_key_test(memcached_st *memc) { memcached_return_t rc; const char *key= "foo bad"; uint32_t flags; uint64_t query_id= memcached_query_id(memc); // Just skip if we are in binary mode. test_skip(false, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); test_compare(query_id, memcached_query_id(memc)); // We should not increase the query_id for memcached_behavior_get() memcached_st *memc_clone= memcached_clone(NULL, memc); test_true(memc_clone); query_id= memcached_query_id(memc_clone); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, true)); test_compare(query_id, memcached_query_id(memc_clone)); // We should not increase the query_id for memcached_behavior_set() /* All keys are valid in the binary protocol (except for length) */ if (memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == false) { uint64_t before_query_id= memcached_query_id(memc_clone); { size_t string_length; char *string= memcached_get(memc_clone, key, strlen(key), &string_length, &flags, &rc); test_compare(MEMCACHED_BAD_KEY_PROVIDED, rc); test_zero(string_length); test_false(string); } test_compare(before_query_id +1, memcached_query_id(memc_clone)); query_id= memcached_query_id(memc_clone); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, false)); test_compare(query_id, memcached_query_id(memc_clone)); // We should not increase the query_id for memcached_behavior_set() { size_t string_length; char *string= memcached_get(memc_clone, key, strlen(key), &string_length, &flags, &rc); test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc)); test_zero(string_length); test_false(string); } /* Test multi key for bad keys */ const char *keys[] = { "GoodKey", "Bad Key", "NotMine" }; size_t key_lengths[] = { 7, 7, 7 }; query_id= memcached_query_id(memc_clone); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, true)); test_compare(query_id, memcached_query_id(memc_clone)); query_id= memcached_query_id(memc_clone); test_compare(MEMCACHED_BAD_KEY_PROVIDED, memcached_mget(memc_clone, keys, key_lengths, 3)); test_compare(query_id +1, memcached_query_id(memc_clone)); query_id= memcached_query_id(memc_clone); // Grouping keys are not required to follow normal key behaviors test_compare(MEMCACHED_SUCCESS, memcached_mget_by_key(memc_clone, "foo daddy", 9, keys, key_lengths, 1)); test_compare(query_id +1, memcached_query_id(memc_clone)); /* The following test should be moved to the end of this function when the memcached server is updated to allow max size length of the keys in the binary protocol */ test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc_clone, MEMCACHED_CALLBACK_NAMESPACE, NULL)); libtest::vchar_t longkey; { libtest::vchar_t::iterator it= longkey.begin(); longkey.insert(it, MEMCACHED_MAX_KEY, 'a'); } test_compare(longkey.size(), size_t(MEMCACHED_MAX_KEY)); { size_t string_length; // We subtract 1 test_null(memcached_get(memc_clone, &longkey[0], longkey.size() -1, &string_length, &flags, &rc)); test_compare(MEMCACHED_NOTFOUND, rc); test_zero(string_length); test_null(memcached_get(memc_clone, &longkey[0], longkey.size(), &string_length, &flags, &rc)); test_compare(MEMCACHED_BAD_KEY_PROVIDED, rc); test_zero(string_length); } } /* Make sure zero length keys are marked as bad */ { test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, true)); size_t string_length; char *string= memcached_get(memc_clone, key, 0, &string_length, &flags, &rc); test_compare(MEMCACHED_BAD_KEY_PROVIDED, rc); test_zero(string_length); test_false(string); } memcached_free(memc_clone); return TEST_SUCCESS; } #define READ_THROUGH_VALUE "set for me" static memcached_return_t read_through_trigger(memcached_st *, // memc char *, // key size_t, // key_length, memcached_result_st *result) { return memcached_result_set_value(result, READ_THROUGH_VALUE, strlen(READ_THROUGH_VALUE)); } #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif test_return_t read_through(memcached_st *memc) { memcached_trigger_key_fn cb= (memcached_trigger_key_fn)read_through_trigger; size_t string_length; uint32_t flags; memcached_return_t rc; char *string= memcached_get(memc, test_literal_param(__func__), &string_length, &flags, &rc); test_compare(MEMCACHED_NOTFOUND, rc); test_false(string_length); test_false(string); test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_GET_FAILURE, *(void **)&cb)); string= memcached_get(memc, test_literal_param(__func__), &string_length, &flags, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_compare(sizeof(READ_THROUGH_VALUE) -1, string_length); test_compare(0, string[sizeof(READ_THROUGH_VALUE) -1]); test_strcmp(READ_THROUGH_VALUE, string); free(string); string= memcached_get(memc, test_literal_param(__func__), &string_length, &flags, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(string); test_compare(string_length, sizeof(READ_THROUGH_VALUE) -1); test_true(string[sizeof(READ_THROUGH_VALUE) -1] == 0); test_strcmp(READ_THROUGH_VALUE, string); free(string); return TEST_SUCCESS; } test_return_t set_test2(memcached_st *memc) { for (uint32_t x= 0; x < 10; x++) { test_compare_hint(return_value_based_on_buffering(memc), memcached_set(memc, test_literal_param("foo"), test_literal_param("train in the brain"), time_t(0), uint32_t(0)), memcached_last_error_message(memc)); } return TEST_SUCCESS; } test_return_t set_test3(memcached_st *memc) { size_t value_length= 8191; libtest::vchar_t value; value.reserve(value_length); for (uint32_t x= 0; x < value_length; x++) { value.push_back(char(x % 127)); } /* The dump test relies on there being at least 32 items in memcached */ for (uint32_t x= 0; x < 32; x++) { char key[16]; snprintf(key, sizeof(key), "foo%u", x); uint64_t query_id= memcached_query_id(memc); test_compare_hint(return_value_based_on_buffering(memc), memcached_set(memc, key, strlen(key), &value[0], value.size(), time_t(0), uint32_t(0)), memcached_last_error_message(memc)); test_compare(query_id +1, memcached_query_id(memc)); } return TEST_SUCCESS; } test_return_t mget_end(memcached_st *memc) { const char *keys[]= { "foo", "foo2" }; size_t lengths[]= { 3, 4 }; const char *values[]= { "fjord", "41" }; // Set foo and foo2 for (size_t x= 0; x < test_array_length(keys); x++) { test_compare(MEMCACHED_SUCCESS, memcached_set(memc, keys[x], lengths[x], values[x], strlen(values[x]), time_t(0), uint32_t(0))); } char *string; size_t string_length; uint32_t flags; // retrieve both via mget test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, lengths, test_array_length(keys))); char key[MEMCACHED_MAX_KEY]; size_t key_length; memcached_return_t rc; // this should get both for (size_t x= 0; x < test_array_length(keys); x++) { string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc); test_compare(MEMCACHED_SUCCESS, rc); int val = 0; if (key_length == 4) { val= 1; } test_compare(string_length, strlen(values[val])); test_true(strncmp(values[val], string, string_length) == 0); free(string); } // this should indicate end string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc); test_compare(MEMCACHED_END, rc); test_null(string); // now get just one test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, lengths, 1)); string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc); test_compare(key_length, lengths[0]); test_true(strncmp(keys[0], key, key_length) == 0); test_compare(string_length, strlen(values[0])); test_true(strncmp(values[0], string, string_length) == 0); test_compare(MEMCACHED_SUCCESS, rc); free(string); // this should indicate end string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc); test_compare(MEMCACHED_END, rc); test_null(string); return TEST_SUCCESS; } /* Do not copy the style of this code, I just access hosts to testthis function */ test_return_t stats_servername_test(memcached_st *memc) { memcached_stat_st memc_stat; memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); if (LIBMEMCACHED_WITH_SASL_SUPPORT and memcached_get_sasl_callbacks(memc)) { return TEST_SKIPPED; } test_compare(MEMCACHED_SUCCESS, memcached_stat_servername(&memc_stat, NULL, memcached_server_name(instance), memcached_server_port(instance))); return TEST_SUCCESS; } test_return_t increment_test(memcached_st *memc) { uint64_t new_number; test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("number"), test_literal_param("0"), (time_t)0, (uint32_t)0)); test_compare(MEMCACHED_SUCCESS, memcached_increment(memc, test_literal_param("number"), 1, &new_number)); test_compare(uint64_t(1), new_number); test_compare(MEMCACHED_SUCCESS, memcached_increment(memc, test_literal_param("number"), 1, &new_number)); test_compare(uint64_t(2), new_number); return TEST_SUCCESS; } test_return_t increment_with_initial_test(memcached_st *memc) { test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); uint64_t new_number; uint64_t initial= 0; test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc)); test_compare(MEMCACHED_SUCCESS, memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number)); test_compare(new_number, initial); test_compare(MEMCACHED_SUCCESS, memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number)); test_compare(new_number, (initial +1)); return TEST_SUCCESS; } test_return_t decrement_test(memcached_st *memc) { test_compare(return_value_based_on_buffering(memc), memcached_set(memc, test_literal_param(__func__), test_literal_param("3"), time_t(0), uint32_t(0))); // Make sure we flush the value we just set test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc)); uint64_t new_number; test_compare(MEMCACHED_SUCCESS, memcached_decrement(memc, test_literal_param(__func__), 1, &new_number)); test_compare(uint64_t(2), new_number); test_compare(MEMCACHED_SUCCESS, memcached_decrement(memc, test_literal_param(__func__), 1, &new_number)); test_compare(uint64_t(1), new_number); return TEST_SUCCESS; } test_return_t decrement_with_initial_test(memcached_st *memc) { test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); uint64_t initial= 3; test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc)); uint64_t new_number; test_compare(MEMCACHED_SUCCESS, memcached_decrement_with_initial(memc, test_literal_param(__func__), 1, initial, 0, &new_number)); test_compare(new_number, initial); test_compare(MEMCACHED_SUCCESS, memcached_decrement_with_initial(memc, test_literal_param(__func__), 1, initial, 0, &new_number)); test_compare(new_number, (initial - 1)); return TEST_SUCCESS; } test_return_t increment_by_key_test(memcached_st *memc) { const char *master_key= "foo"; const char *key= "number"; const char *value= "0"; test_compare(return_value_based_on_buffering(memc), memcached_set_by_key(memc, master_key, strlen(master_key), key, strlen(key), value, strlen(value), time_t(0), uint32_t(0))); // Make sure we flush the value we just set test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc)); uint64_t new_number; test_compare(MEMCACHED_SUCCESS, memcached_increment_by_key(memc, master_key, strlen(master_key), key, strlen(key), 1, &new_number)); test_compare(uint64_t(1), new_number); test_compare(MEMCACHED_SUCCESS, memcached_increment_by_key(memc, master_key, strlen(master_key), key, strlen(key), 1, &new_number)); test_compare(uint64_t(2), new_number); return TEST_SUCCESS; } test_return_t increment_with_initial_by_key_test(memcached_st *memc) { test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); uint64_t new_number; const char *master_key= "foo"; const char *key= "number"; uint64_t initial= 0; test_compare(MEMCACHED_SUCCESS, memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key), key, strlen(key), 1, initial, 0, &new_number)); test_compare(new_number, initial); test_compare(MEMCACHED_SUCCESS, memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key), key, strlen(key), 1, initial, 0, &new_number)); test_compare(new_number, (initial +1)); return TEST_SUCCESS; } test_return_t decrement_by_key_test(memcached_st *memc) { uint64_t new_number; const char *value= "3"; test_compare(return_value_based_on_buffering(memc), memcached_set_by_key(memc, test_literal_param("foo"), test_literal_param("number"), value, strlen(value), (time_t)0, (uint32_t)0)); test_compare(MEMCACHED_SUCCESS, memcached_decrement_by_key(memc, test_literal_param("foo"), test_literal_param("number"), 1, &new_number)); test_compare(uint64_t(2), new_number); test_compare(MEMCACHED_SUCCESS, memcached_decrement_by_key(memc, test_literal_param("foo"), test_literal_param("number"), 1, &new_number)); test_compare(uint64_t(1), new_number); return TEST_SUCCESS; } test_return_t decrement_with_initial_by_key_test(memcached_st *memc) { test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); uint64_t new_number; uint64_t initial= 3; test_compare(MEMCACHED_SUCCESS, memcached_decrement_with_initial_by_key(memc, test_literal_param("foo"), test_literal_param("number"), 1, initial, 0, &new_number)); test_compare(new_number, initial); test_compare(MEMCACHED_SUCCESS, memcached_decrement_with_initial_by_key(memc, test_literal_param("foo"), test_literal_param("number"), 1, initial, 0, &new_number)); test_compare(new_number, (initial - 1)); return TEST_SUCCESS; } test_return_t binary_increment_with_prefix_test(memcached_st *memc) { test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, (void *)"namespace:")); test_compare(return_value_based_on_buffering(memc), memcached_set(memc, test_literal_param("number"), test_literal_param("0"), (time_t)0, (uint32_t)0)); uint64_t new_number; test_compare(MEMCACHED_SUCCESS, memcached_increment(memc, test_literal_param("number"), 1, &new_number)); test_compare(uint64_t(1), new_number); test_compare(MEMCACHED_SUCCESS, memcached_increment(memc, test_literal_param("number"), 1, &new_number)); test_compare(uint64_t(2), new_number); return TEST_SUCCESS; } test_return_t quit_test(memcached_st *memc) { const char *value= "sanford and sun"; test_compare_hint(return_value_based_on_buffering(memc), memcached_set(memc, test_literal_param(__func__), value, strlen(value), (time_t)10, (uint32_t)3), memcached_last_error_message(memc)); memcached_quit(memc); test_compare_hint(return_value_based_on_buffering(memc), memcached_set(memc, test_literal_param(__func__), value, strlen(value), (time_t)50, (uint32_t)9), memcached_last_error_message(memc)); return TEST_SUCCESS; } test_return_t mget_result_test(memcached_st *memc) { const char *keys[]= {"fudge", "son", "food"}; size_t key_length[]= {5, 3, 4}; memcached_result_st results_obj; memcached_result_st *results; results= memcached_result_create(memc, &results_obj); test_true(results); test_true(&results_obj == results); /* We need to empty the server before continueing test */ test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 3)); memcached_return_t rc; while ((results= memcached_fetch_result(memc, &results_obj, &rc))) { test_true(results); } while ((results= memcached_fetch_result(memc, &results_obj, &rc))) { test_true(false); /* We should never see a value returned */ }; test_false(results); test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc)); for (uint32_t x= 0; x < 3; x++) { rc= memcached_set(memc, keys[x], key_length[x], keys[x], key_length[x], (time_t)50, (uint32_t)9); test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc)); } test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 3)); while ((results= memcached_fetch_result(memc, &results_obj, &rc))) { test_true(results); test_true(&results_obj == results); test_compare(MEMCACHED_SUCCESS, rc); test_memcmp(memcached_result_key_value(results), memcached_result_value(results), memcached_result_length(results)); test_compare(memcached_result_key_length(results), memcached_result_length(results)); } memcached_result_free(&results_obj); return TEST_SUCCESS; } test_return_t mget_result_alloc_test(memcached_st *memc) { const char *keys[]= {"fudge", "son", "food"}; size_t key_length[]= {5, 3, 4}; memcached_result_st *results; /* We need to empty the server before continueing test */ test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 3)); memcached_return_t rc; while ((results= memcached_fetch_result(memc, NULL, &rc))) { test_true(results); } test_false(results); test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc)); for (uint32_t x= 0; x < 3; x++) { rc= memcached_set(memc, keys[x], key_length[x], keys[x], key_length[x], (time_t)50, (uint32_t)9); test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc)); } test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 3)); uint32_t x= 0; while ((results= memcached_fetch_result(memc, NULL, &rc))) { test_true(results); test_compare(MEMCACHED_SUCCESS, rc); test_compare(memcached_result_key_length(results), memcached_result_length(results)); test_memcmp(memcached_result_key_value(results), memcached_result_value(results), memcached_result_length(results)); memcached_result_free(results); x++; } return TEST_SUCCESS; } test_return_t mget_result_function(memcached_st *memc) { const char *keys[]= {"fudge", "son", "food"}; size_t key_length[]= {5, 3, 4}; size_t counter; memcached_execute_fn callbacks[1]; for (uint32_t x= 0; x < 3; x++) { test_compare(return_value_based_on_buffering(memc), memcached_set(memc, keys[x], key_length[x], keys[x], key_length[x], time_t(50), uint32_t(9))); } test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc)); memcached_quit(memc); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 3)); callbacks[0]= &callback_counter; counter= 0; test_compare(MEMCACHED_SUCCESS, memcached_fetch_execute(memc, callbacks, (void *)&counter, 1)); test_compare(size_t(3), counter); return TEST_SUCCESS; } test_return_t mget_test(memcached_st *memc) { const char *keys[]= {"fudge", "son", "food"}; size_t key_length[]= {5, 3, 4}; char return_key[MEMCACHED_MAX_KEY]; size_t return_key_length; char *return_value; size_t return_value_length; test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 3)); uint32_t flags; memcached_return_t rc; while ((return_value= memcached_fetch(memc, return_key, &return_key_length, &return_value_length, &flags, &rc))) { test_true(return_value); } test_false(return_value); test_zero(return_value_length); test_compare(MEMCACHED_NOTFOUND, rc); for (uint32_t x= 0; x < 3; x++) { rc= memcached_set(memc, keys[x], key_length[x], keys[x], key_length[x], (time_t)50, (uint32_t)9); test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc)); } test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 3)); uint32_t x= 0; while ((return_value= memcached_fetch(memc, return_key, &return_key_length, &return_value_length, &flags, &rc))) { test_true(return_value); test_compare(MEMCACHED_SUCCESS, rc); if (not memc->_namespace) { test_compare(return_key_length, return_value_length); test_memcmp(return_value, return_key, return_value_length); } free(return_value); x++; } return TEST_SUCCESS; } test_return_t mget_execute(memcached_st *original_memc) { test_skip(true, memcached_behavior_get(original_memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); memcached_st *memc= create_single_instance_memcached(original_memc, "--BINARY-PROTOCOL"); test_true(memc); keys_st keys(20480); /* First add all of the items.. */ char blob[1024] = {0}; for (size_t x= 0; x < keys.size(); ++x) { uint64_t query_id= memcached_query_id(memc); memcached_return_t rc= memcached_add(memc, keys.key_at(x), keys.length_at(x), blob, sizeof(blob), 0, 0); test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_last_error_message(memc)); test_compare(query_id +1, memcached_query_id(memc)); } /* Try to get all of them with a large multiget */ size_t counter= 0; memcached_execute_fn callbacks[]= { &callback_counter }; test_compare(MEMCACHED_SUCCESS, memcached_mget_execute(memc, keys.keys_ptr(), keys.lengths_ptr(), keys.size(), callbacks, &counter, 1)); { uint64_t query_id= memcached_query_id(memc); test_compare(MEMCACHED_SUCCESS, memcached_fetch_execute(memc, callbacks, (void *)&counter, 1)); test_compare(query_id, memcached_query_id(memc)); /* Verify that we got all of the items */ test_compare(keys.size(), counter); } memcached_free(memc); return TEST_SUCCESS; } #define REGRESSION_BINARY_VS_BLOCK_COUNT 20480 static pairs_st *global_pairs= NULL; test_return_t key_setup(memcached_st *memc) { test_skip(TEST_SUCCESS, pre_binary(memc)); global_pairs= pairs_generate(REGRESSION_BINARY_VS_BLOCK_COUNT, 0); return TEST_SUCCESS; } test_return_t key_teardown(memcached_st *) { pairs_free(global_pairs); global_pairs= NULL; return TEST_SUCCESS; } test_return_t block_add_regression(memcached_st *memc) { /* First add all of the items.. */ for (ptrdiff_t x= 0; x < REGRESSION_BINARY_VS_BLOCK_COUNT; ++x) { libtest::vchar_t blob; libtest::vchar::make(blob, 1024); memcached_return_t rc= memcached_add_by_key(memc, test_literal_param("bob"), global_pairs[x].key, global_pairs[x].key_length, &blob[0], blob.size(), time_t(0), uint32_t(0)); test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE, memcached_strerror(NULL, rc)); } return TEST_SUCCESS; } test_return_t binary_add_regression(memcached_st *memc) { test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, true)); test_return_t rc= block_add_regression(memc); return rc; } test_return_t get_stats_keys(memcached_st *memc) { char **stat_list; char **ptr; memcached_stat_st memc_stat; memcached_return_t rc; stat_list= memcached_stat_get_keys(memc, &memc_stat, &rc); test_compare(MEMCACHED_SUCCESS, rc); for (ptr= stat_list; *ptr; ptr++) test_true(*ptr); free(stat_list); return TEST_SUCCESS; } test_return_t version_string_test(memcached_st *) { test_strcmp(LIBMEMCACHED_VERSION_STRING, memcached_lib_version()); return TEST_SUCCESS; } test_return_t get_stats(memcached_st *memc) { memcached_return_t rc; memcached_stat_st *memc_stat= memcached_stat(memc, NULL, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(memc_stat); for (uint32_t x= 0; x < memcached_server_count(memc); x++) { char **stat_list= memcached_stat_get_keys(memc, memc_stat+x, &rc); test_compare(MEMCACHED_SUCCESS, rc); for (char **ptr= stat_list; *ptr; ptr++) {}; free(stat_list); } memcached_stat_free(NULL, memc_stat); return TEST_SUCCESS; } test_return_t add_host_test(memcached_st *memc) { char servername[]= "0.example.com"; memcached_return_t rc; memcached_server_st *servers= memcached_server_list_append_with_weight(NULL, servername, 400, 0, &rc); test_compare(1U, memcached_server_list_count(servers)); for (unsigned int x= 2; x < 20; x++) { char buffer[SMALL_STRING_LEN]; snprintf(buffer, SMALL_STRING_LEN, "%u.example.com", 400+x); servers= memcached_server_list_append_with_weight(servers, buffer, 401, 0, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_compare(x, memcached_server_list_count(servers)); } test_compare(MEMCACHED_SUCCESS, memcached_server_push(memc, servers)); test_compare(MEMCACHED_SUCCESS, memcached_server_push(memc, servers)); memcached_server_list_free(servers); return TEST_SUCCESS; } test_return_t memcached_fetch_result_NOT_FOUND(memcached_st *memc) { memcached_return_t rc; const char *key= "not_found"; size_t key_length= test_literal_param_size("not_found"); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, &key, &key_length, 1)); memcached_result_st *result= memcached_fetch_result(memc, NULL, &rc); test_null(result); test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc)); memcached_result_free(result); return TEST_SUCCESS; } static memcached_return_t clone_test_callback(memcached_st *, memcached_st *) { return MEMCACHED_SUCCESS; } static memcached_return_t cleanup_test_callback(memcached_st *) { return MEMCACHED_SUCCESS; } test_return_t callback_test(memcached_st *memc) { /* Test User Data */ { int x= 5; int *test_ptr; memcached_return_t rc; test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_USER_DATA, &x)); test_ptr= (int *)memcached_callback_get(memc, MEMCACHED_CALLBACK_USER_DATA, &rc); test_true(*test_ptr == x); } /* Test Clone Callback */ { memcached_clone_fn clone_cb= (memcached_clone_fn)clone_test_callback; void *clone_cb_ptr= *(void **)&clone_cb; void *temp_function= NULL; test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, clone_cb_ptr)); memcached_return_t rc; temp_function= memcached_callback_get(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, &rc); test_true(temp_function == clone_cb_ptr); test_compare(MEMCACHED_SUCCESS, rc); } /* Test Cleanup Callback */ { memcached_cleanup_fn cleanup_cb= (memcached_cleanup_fn)cleanup_test_callback; void *cleanup_cb_ptr= *(void **)&cleanup_cb; void *temp_function= NULL; memcached_return_t rc; test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, cleanup_cb_ptr)); temp_function= memcached_callback_get(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, &rc); test_true(temp_function == cleanup_cb_ptr); } return TEST_SUCCESS; } /* We don't test the behavior itself, we test the switches */ test_return_t behavior_test(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 1); test_compare(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NO_BLOCK)); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1); test_compare(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY)); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, MEMCACHED_HASH_MD5); test_compare(uint64_t(MEMCACHED_HASH_MD5), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH)); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); test_zero(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NO_BLOCK)); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 0); test_zero(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY)); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, MEMCACHED_HASH_DEFAULT); test_compare(uint64_t(MEMCACHED_HASH_DEFAULT), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH)); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, MEMCACHED_HASH_CRC); test_compare(uint64_t(MEMCACHED_HASH_CRC), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH)); test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE)); test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE)); uint64_t value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, value +1); test_compare((value +1), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS)); return TEST_SUCCESS; } test_return_t MEMCACHED_BEHAVIOR_CORK_test(memcached_st *memc) { test_compare(MEMCACHED_DEPRECATED, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_CORK, true)); // Platform dependent #if 0 bool value= (bool)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_CORK); test_false(value); #endif return TEST_SUCCESS; } test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test(memcached_st *memc) { memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE, true); test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOT_SUPPORTED); bool value= (bool)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE); if (memcached_success(rc)) { test_true(value); } else { test_false(value); } return TEST_SUCCESS; } test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test(memcached_st *memc) { memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_KEEPIDLE, true); test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOT_SUPPORTED); bool value= (bool)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_TCP_KEEPIDLE); if (memcached_success(rc)) { test_true(value); } else { test_false(value); } return TEST_SUCCESS; } /* Make sure we behave properly if server list has no values */ test_return_t user_supplied_bug4(memcached_st *memc) { const char *keys[]= {"fudge", "son", "food"}; size_t key_length[]= {5, 3, 4}; /* Here we free everything before running a bunch of mget tests */ memcached_servers_reset(memc); /* We need to empty the server before continueing test */ test_compare(MEMCACHED_NO_SERVERS, memcached_flush(memc, 0)); test_compare(MEMCACHED_NO_SERVERS, memcached_mget(memc, keys, key_length, 3)); { unsigned int keys_returned; memcached_return_t rc; test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned, rc)); test_compare(MEMCACHED_NOTFOUND, rc); test_zero(keys_returned); } for (uint32_t x= 0; x < 3; x++) { test_compare(MEMCACHED_NO_SERVERS, memcached_set(memc, keys[x], key_length[x], keys[x], key_length[x], (time_t)50, (uint32_t)9)); } test_compare(MEMCACHED_NO_SERVERS, memcached_mget(memc, keys, key_length, 3)); { char *return_value; char return_key[MEMCACHED_MAX_KEY]; memcached_return_t rc; size_t return_key_length; size_t return_value_length; uint32_t flags; uint32_t x= 0; while ((return_value= memcached_fetch(memc, return_key, &return_key_length, &return_value_length, &flags, &rc))) { test_true(return_value); test_compare(MEMCACHED_SUCCESS, rc); test_true(return_key_length == return_value_length); test_memcmp(return_value, return_key, return_value_length); free(return_value); x++; } } return TEST_SUCCESS; } #define VALUE_SIZE_BUG5 1048064 test_return_t user_supplied_bug5(memcached_st *memc) { const char *keys[]= {"036790384900", "036790384902", "036790384904", "036790384906"}; size_t key_length[]= {strlen("036790384900"), strlen("036790384902"), strlen("036790384904"), strlen("036790384906")}; char *value; size_t value_length; uint32_t flags; char *insert_data= new (std::nothrow) char[VALUE_SIZE_BUG5]; for (uint32_t x= 0; x < VALUE_SIZE_BUG5; x++) { insert_data[x]= (signed char)rand(); } test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); memcached_return_t rc; test_null(memcached_get(memc, keys[0], key_length[0], &value_length, &flags, &rc)); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 4)); unsigned int count; test_compare(TEST_SUCCESS, fetch_all_results(memc, count, rc)); test_compare(MEMCACHED_NOTFOUND, rc); test_zero(count); for (uint32_t x= 0; x < 4; x++) { test_compare(MEMCACHED_SUCCESS, memcached_set(memc, keys[x], key_length[x], insert_data, VALUE_SIZE_BUG5, (time_t)0, (uint32_t)0)); } for (uint32_t x= 0; x < 10; x++) { value= memcached_get(memc, keys[0], key_length[0], &value_length, &flags, &rc); test_compare(rc, MEMCACHED_SUCCESS); test_true(value); ::free(value); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 4)); test_compare(TEST_SUCCESS, fetch_all_results(memc, count)); test_compare(4U, count); } delete [] insert_data; return TEST_SUCCESS; } test_return_t user_supplied_bug6(memcached_st *memc) { const char *keys[]= {"036790384900", "036790384902", "036790384904", "036790384906"}; size_t key_length[]= {strlen("036790384900"), strlen("036790384902"), strlen("036790384904"), strlen("036790384906")}; char return_key[MEMCACHED_MAX_KEY]; size_t return_key_length; char *value; size_t value_length; uint32_t flags; char *insert_data= new (std::nothrow) char[VALUE_SIZE_BUG5]; for (uint32_t x= 0; x < VALUE_SIZE_BUG5; x++) { insert_data[x]= (signed char)rand(); } test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); test_compare(TEST_SUCCESS, confirm_keys_dont_exist(memc, keys, test_array_length(keys))); // We will now confirm that memcached_mget() returns success, but we will // then check to make sure that no actual keys are returned. test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 4)); memcached_return_t rc; uint32_t count= 0; while ((value= memcached_fetch(memc, return_key, &return_key_length, &value_length, &flags, &rc))) { count++; } test_zero(count); test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc)); for (uint32_t x= 0; x < test_array_length(keys); x++) { test_compare(MEMCACHED_SUCCESS, memcached_set(memc, keys[x], key_length[x], insert_data, VALUE_SIZE_BUG5, (time_t)0, (uint32_t)0)); } test_compare(TEST_SUCCESS, confirm_keys_exist(memc, keys, test_array_length(keys))); for (uint32_t x= 0; x < 2; x++) { value= memcached_get(memc, keys[0], key_length[0], &value_length, &flags, &rc); test_true(value); free(value); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 4)); /* We test for purge of partial complete fetches */ for (count= 3; count; count--) { value= memcached_fetch(memc, return_key, &return_key_length, &value_length, &flags, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_memcmp(value, insert_data, value_length); test_true(value_length); free(value); } } delete [] insert_data; return TEST_SUCCESS; } test_return_t user_supplied_bug8(memcached_st *) { memcached_return_t rc; memcached_st *mine; memcached_st *memc_clone; memcached_server_st *servers; const char *server_list= "memcache1.memcache.bk.sapo.pt:11211, memcache1.memcache.bk.sapo.pt:11212, memcache1.memcache.bk.sapo.pt:11213, memcache1.memcache.bk.sapo.pt:11214, memcache2.memcache.bk.sapo.pt:11211, memcache2.memcache.bk.sapo.pt:11212, memcache2.memcache.bk.sapo.pt:11213, memcache2.memcache.bk.sapo.pt:11214"; servers= memcached_servers_parse(server_list); test_true(servers); mine= memcached_create(NULL); rc= memcached_server_push(mine, servers); test_compare(MEMCACHED_SUCCESS, rc); memcached_server_list_free(servers); test_true(mine); memc_clone= memcached_clone(NULL, mine); memcached_quit(mine); memcached_quit(memc_clone); memcached_free(mine); memcached_free(memc_clone); return TEST_SUCCESS; } /* Test flag store/retrieve */ test_return_t user_supplied_bug7(memcached_st *memc) { char *insert_data= new (std::nothrow) char[VALUE_SIZE_BUG5]; test_true(insert_data); for (size_t x= 0; x < VALUE_SIZE_BUG5; x++) { insert_data[x]= (signed char)rand(); } memcached_flush(memc, 0); const char *keys= "036790384900"; size_t key_length= strlen(keys); test_compare_hint(MEMCACHED_SUCCESS, memcached_set(memc, keys, key_length, insert_data, VALUE_SIZE_BUG5, time_t(0), 245U), memcached_last_error_message(memc)); memcached_return_t rc; size_t value_length; uint32_t flags= 0; char *value= memcached_get(memc, keys, key_length, &value_length, &flags, &rc); test_compare(245U, flags); test_true(value); free(value); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, &keys, &key_length, 1)); char return_key[MEMCACHED_MAX_KEY]; size_t return_key_length; flags= 0; value= memcached_fetch(memc, return_key, &return_key_length, &value_length, &flags, &rc); test_compare(uint32_t(245), flags); test_true(value); free(value); delete [] insert_data; return TEST_SUCCESS; } test_return_t user_supplied_bug9(memcached_st *memc) { const char *keys[]= {"UDATA:edevil@sapo.pt", "fudge&*@#", "for^#@&$not"}; size_t key_length[3]; uint32_t flags; unsigned count= 0; char return_key[MEMCACHED_MAX_KEY]; size_t return_key_length; char *return_value; size_t return_value_length; key_length[0]= strlen("UDATA:edevil@sapo.pt"); key_length[1]= strlen("fudge&*@#"); key_length[2]= strlen("for^#@&$not"); for (unsigned int x= 0; x < 3; x++) { memcached_return_t rc= memcached_set(memc, keys[x], key_length[x], keys[x], key_length[x], (time_t)50, (uint32_t)9); test_compare(MEMCACHED_SUCCESS, rc); } memcached_return_t rc= memcached_mget(memc, keys, key_length, 3); test_compare(MEMCACHED_SUCCESS, rc); /* We need to empty the server before continueing test */ while ((return_value= memcached_fetch(memc, return_key, &return_key_length, &return_value_length, &flags, &rc)) != NULL) { test_true(return_value); free(return_value); count++; } test_compare(3U, count); return TEST_SUCCESS; } /* We are testing with aggressive timeout to get failures */ test_return_t user_supplied_bug10(memcached_st *memc) { test_skip(memc->servers[0].type, MEMCACHED_CONNECTION_TCP); size_t value_length= 512; unsigned int set= 1; memcached_st *mclone= memcached_clone(NULL, memc); memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_NO_BLOCK, set); memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_TCP_NODELAY, set); memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, uint64_t(0)); libtest::vchar_t value; value.reserve(value_length); for (uint32_t x= 0; x < value_length; x++) { value.push_back(char(x % 127)); } for (unsigned int x= 1; x <= 100000; ++x) { memcached_return_t rc= memcached_set(mclone, test_literal_param("foo"), &value[0], value.size(), 0, 0); test_true_got((rc == MEMCACHED_SUCCESS or rc == MEMCACHED_WRITE_FAILURE or rc == MEMCACHED_BUFFERED or rc == MEMCACHED_TIMEOUT or rc == MEMCACHED_CONNECTION_FAILURE or rc == MEMCACHED_SERVER_TEMPORARILY_DISABLED), memcached_strerror(NULL, rc)); if (rc == MEMCACHED_WRITE_FAILURE or rc == MEMCACHED_TIMEOUT) { x--; } } memcached_free(mclone); return TEST_SUCCESS; } /* We are looking failures in the async protocol */ test_return_t user_supplied_bug11(memcached_st *memc) { memcached_st *mclone= memcached_clone(NULL, memc); memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_NO_BLOCK, true); memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_TCP_NODELAY, true); memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, size_t(-1)); test_compare(-1, int32_t(memcached_behavior_get(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT))); libtest::vchar_t value; value.reserve(512); for (unsigned int x= 0; x < 512; x++) { value.push_back(char(x % 127)); } for (unsigned int x= 1; x <= 100000; ++x) { memcached_return_t rc= memcached_set(mclone, test_literal_param("foo"), &value[0], value.size(), 0, 0); (void)rc; } memcached_free(mclone); return TEST_SUCCESS; } /* Bug found where incr was not returning MEMCACHED_NOTFOUND when object did not exist. */ test_return_t user_supplied_bug12(memcached_st *memc) { memcached_return_t rc; uint32_t flags; size_t value_length; char *value; uint64_t number_value; value= memcached_get(memc, "autoincrement", strlen("autoincrement"), &value_length, &flags, &rc); test_null(value); test_compare(MEMCACHED_NOTFOUND, rc); rc= memcached_increment(memc, "autoincrement", strlen("autoincrement"), 1, &number_value); test_null(value); /* The binary protocol will set the key if it doesn't exist */ if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1) { test_compare(MEMCACHED_SUCCESS, rc); } else { test_compare(MEMCACHED_NOTFOUND, rc); } test_compare(MEMCACHED_SUCCESS, memcached_set(memc, "autoincrement", strlen("autoincrement"), "1", 1, 0, 0)); value= memcached_get(memc, "autoincrement", strlen("autoincrement"), &value_length, &flags, &rc); test_true(value); free(value); test_compare(MEMCACHED_SUCCESS, memcached_increment(memc, "autoincrement", strlen("autoincrement"), 1, &number_value)); test_compare(2UL, number_value); return TEST_SUCCESS; } /* Bug found where command total one more than MEMCACHED_MAX_BUFFER set key34567890 0 0 8169 \r\n is sent followed by buffer of size 8169, followed by 8169 */ test_return_t user_supplied_bug13(memcached_st *memc) { char key[] = "key34567890"; char commandFirst[]= "set key34567890 0 0 "; char commandLast[] = " \r\n"; /* first line of command sent to server */ size_t commandLength; commandLength = strlen(commandFirst) + strlen(commandLast) + 4; /* 4 is number of characters in size, probably 8196 */ size_t overflowSize = MEMCACHED_MAX_BUFFER - commandLength; for (size_t testSize= overflowSize - 1; testSize < overflowSize + 1; testSize++) { char *overflow= new (std::nothrow) char[testSize]; test_true(overflow); memset(overflow, 'x', testSize); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, key, strlen(key), overflow, testSize, 0, 0)); delete [] overflow; } return TEST_SUCCESS; } /* Test values of many different sizes Bug found where command total one more than MEMCACHED_MAX_BUFFER set key34567890 0 0 8169 \r\n is sent followed by buffer of size 8169, followed by 8169 */ test_return_t user_supplied_bug14(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true); libtest::vchar_t value; value.reserve(18000); for (ptrdiff_t x= 0; x < 18000; x++) { value.push_back((char) (x % 127)); } for (size_t current_length= 1; current_length < value.size(); current_length++) { memcached_return_t rc= memcached_set(memc, test_literal_param("foo"), &value[0], current_length, (time_t)0, (uint32_t)0); test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); size_t string_length; uint32_t flags; char *string= memcached_get(memc, test_literal_param("foo"), &string_length, &flags, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_compare(string_length, current_length); char buffer[1024]; snprintf(buffer, sizeof(buffer), "%u", uint32_t(string_length)); test_memcmp_hint(string, &value[0], string_length, buffer); free(string); } return TEST_SUCCESS; } /* Look for zero length value problems */ test_return_t user_supplied_bug15(memcached_st *memc) { for (uint32_t x= 0; x < 2; x++) { memcached_return_t rc= memcached_set(memc, test_literal_param("mykey"), NULL, 0, (time_t)0, (uint32_t)0); test_compare(MEMCACHED_SUCCESS, rc); size_t length; uint32_t flags; char *value= memcached_get(memc, test_literal_param("mykey"), &length, &flags, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_false(value); test_zero(length); test_zero(flags); value= memcached_get(memc, test_literal_param("mykey"), &length, &flags, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_null(value); test_zero(length); test_zero(flags); } return TEST_SUCCESS; } /* Check the return sizes on FLAGS to make sure it stores 32bit unsigned values correctly */ test_return_t user_supplied_bug16(memcached_st *memc) { test_compare_hint(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("mykey"), NULL, 0, (time_t)0, UINT32_MAX), memcached_last_error_message(memc)); size_t length; uint32_t flags; memcached_return_t rc; char *value= memcached_get(memc, test_literal_param("mykey"), &length, &flags, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_null(value); test_zero(length); test_compare(flags, UINT32_MAX); return TEST_SUCCESS; } #if !defined(__sun) && !defined(__OpenBSD__) /* Check the validity of chinese key*/ test_return_t user_supplied_bug17(memcached_st *memc) { const char *key= "豆瓣"; const char *value="我们在炎热抑郁的夏天无法停止豆瓣"; memcached_return_t rc= memcached_set(memc, key, strlen(key), value, strlen(value), (time_t)0, 0); test_compare(MEMCACHED_SUCCESS, rc); size_t length; uint32_t flags; char *value2= memcached_get(memc, key, strlen(key), &length, &flags, &rc); test_true(length==strlen(value)); test_compare(MEMCACHED_SUCCESS, rc); test_memcmp(value, value2, length); free(value2); return TEST_SUCCESS; } #endif /* From Andrei on IRC */ test_return_t user_supplied_bug19(memcached_st *) { memcached_return_t res; memcached_st *memc= memcached(test_literal_param("--server=localhost:11311/?100 --server=localhost:11312/?100")); const memcached_server_st *server= memcached_server_by_key(memc, "a", 1, &res); test_true(server); memcached_free(memc); return TEST_SUCCESS; } /* CAS test from Andei */ test_return_t user_supplied_bug20(memcached_st *memc) { const char *key= "abc"; size_t key_len= strlen("abc"); test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, true)); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("abc"), test_literal_param("foobar"), (time_t)0, (uint32_t)0)); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, &key, &key_len, 1)); memcached_result_st result_obj; memcached_result_st *result= memcached_result_create(memc, &result_obj); test_true(result); memcached_result_create(memc, &result_obj); memcached_return_t status; result= memcached_fetch_result(memc, &result_obj, &status); test_true(result); test_compare(MEMCACHED_SUCCESS, status); memcached_result_free(result); return TEST_SUCCESS; } /* Large mget() of missing keys with binary proto * * If many binary quiet commands (such as getq's in an mget) fill the output * buffer and the server chooses not to respond, memcached_flush hangs. See * http://lists.tangent.org/pipermail/libmemcached/2009-August/000918.html */ /* sighandler_t function that always asserts false */ static void fail(int) { fatal_assert(0); } test_return_t _user_supplied_bug21(memcached_st* memc, size_t key_count) { #ifdef WIN32 (void)memc; (void)key_count; return TEST_SKIPPED; #else void (*oldalarm)(int); memcached_st *memc_clone= memcached_clone(NULL, memc); test_true(memc_clone); /* only binproto uses getq for mget */ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, true)); /* empty the cache to ensure misses (hence non-responses) */ test_compare(MEMCACHED_SUCCESS, memcached_flush(memc_clone, 0)); keys_st keys(key_count); oldalarm= signal(SIGALRM, fail); alarm(5); test_compare_got(MEMCACHED_SUCCESS, memcached_mget(memc_clone, keys.keys_ptr(), keys.lengths_ptr(), keys.size()), memcached_last_error_message(memc_clone)); alarm(0); signal(SIGALRM, oldalarm); memcached_return_t rc; uint32_t flags; char return_key[MEMCACHED_MAX_KEY]; size_t return_key_length; char *return_value; size_t return_value_length; while ((return_value= memcached_fetch(memc, return_key, &return_key_length, &return_value_length, &flags, &rc))) { test_false(return_value); // There are no keys to fetch, so the value should never be returned } test_compare(MEMCACHED_NOTFOUND, rc); test_zero(return_value_length); test_zero(return_key_length); test_false(return_key[0]); test_false(return_value); memcached_free(memc_clone); return TEST_SUCCESS; #endif } test_return_t user_supplied_bug21(memcached_st *memc) { test_skip(TEST_SUCCESS, pre_binary(memc)); /* should work as of r580 */ test_compare(TEST_SUCCESS, _user_supplied_bug21(memc, 10)); /* should fail as of r580 */ test_compare(TEST_SUCCESS, _user_supplied_bug21(memc, 1000)); return TEST_SUCCESS; } test_return_t output_ketama_weighted_keys(memcached_st *) { memcached_st *memc= memcached_create(NULL); test_true(memc); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, true)); uint64_t value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED); test_compare(value, uint64_t(1)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5)); value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH); test_true(value == MEMCACHED_HASH_MD5); test_true(memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY) == MEMCACHED_SUCCESS); memcached_server_st *server_pool; server_pool = memcached_servers_parse("10.0.1.1:11211,10.0.1.2:11211,10.0.1.3:11211,10.0.1.4:11211,10.0.1.5:11211,10.0.1.6:11211,10.0.1.7:11211,10.0.1.8:11211,192.168.1.1:11211,192.168.100.1:11211"); memcached_server_push(memc, server_pool); // @todo this needs to be refactored to actually test something. #if 0 FILE *fp; if ((fp = fopen("ketama_keys.txt", "w"))) { // noop } else { printf("cannot write to file ketama_keys.txt"); return TEST_FAILURE; } for (int x= 0; x < 10000; x++) { char key[10]; snprintf(key, sizeof(key), "%d", x); uint32_t server_idx = memcached_generate_hash(memc, key, strlen(key)); char *hostname = memc->hosts[server_idx].hostname; in_port_t port = memc->hosts[server_idx].port; fprintf(fp, "key %s is on host /%s:%u\n", key, hostname, port); memcached_server_instance_st instance= memcached_server_instance_by_position(memc, host_index); } fclose(fp); #endif memcached_server_list_free(server_pool); memcached_free(memc); return TEST_SUCCESS; } test_return_t result_static(memcached_st *memc) { memcached_result_st result; memcached_result_st *result_ptr= memcached_result_create(memc, &result); test_false(result.options.is_allocated); test_true(memcached_is_initialized(&result)); test_true(result_ptr); test_true(result_ptr == &result); memcached_result_free(&result); test_false(result.options.is_allocated); test_false(memcached_is_initialized(&result)); return TEST_SUCCESS; } test_return_t result_alloc(memcached_st *memc) { memcached_result_st *result_ptr= memcached_result_create(memc, NULL); test_true(result_ptr); test_true(result_ptr->options.is_allocated); test_true(memcached_is_initialized(result_ptr)); memcached_result_free(result_ptr); return TEST_SUCCESS; } test_return_t add_host_test1(memcached_st *memc) { memcached_return_t rc; char servername[]= "0.example.com"; memcached_server_st *servers= memcached_server_list_append_with_weight(NULL, servername, 400, 0, &rc); test_true(servers); test_compare(1U, memcached_server_list_count(servers)); for (uint32_t x= 2; x < 20; x++) { char buffer[SMALL_STRING_LEN]; snprintf(buffer, SMALL_STRING_LEN, "%lu.example.com", (unsigned long)(400 +x)); servers= memcached_server_list_append_with_weight(servers, buffer, 401, 0, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_compare(x, memcached_server_list_count(servers)); } test_compare(MEMCACHED_SUCCESS, memcached_server_push(memc, servers)); test_compare(MEMCACHED_SUCCESS, memcached_server_push(memc, servers)); memcached_server_list_free(servers); return TEST_SUCCESS; } static void my_free(const memcached_st *ptr, void *mem, void *context) { (void)context; (void)ptr; #ifdef HARD_MALLOC_TESTS void *real_ptr= (mem == NULL) ? mem : (void*)((caddr_t)mem - 8); free(real_ptr); #else free(mem); #endif } static void *my_malloc(const memcached_st *ptr, const size_t size, void *context) { (void)context; (void)ptr; #ifdef HARD_MALLOC_TESTS void *ret= malloc(size + 8); if (ret != NULL) { ret= (void*)((caddr_t)ret + 8); } #else void *ret= malloc(size); #endif if (ret != NULL) { memset(ret, 0xff, size); } return ret; } static void *my_realloc(const memcached_st *ptr, void *mem, const size_t size, void *) { #ifdef HARD_MALLOC_TESTS void *real_ptr= (mem == NULL) ? NULL : (void*)((caddr_t)mem - 8); void *nmem= realloc(real_ptr, size + 8); void *ret= NULL; if (nmem != NULL) { ret= (void*)((caddr_t)nmem + 8); } return ret; #else (void)ptr; return realloc(mem, size); #endif } static void *my_calloc(const memcached_st *ptr, size_t nelem, const size_t size, void *) { #ifdef HARD_MALLOC_TESTS void *mem= my_malloc(ptr, nelem * size); if (mem) { memset(mem, 0, nelem * size); } return mem; #else (void)ptr; return calloc(nelem, size); #endif } test_return_t selection_of_namespace_tests(memcached_st *memc) { memcached_return_t rc; const char *key= "mine"; char *value; /* Make sure be default none exists */ value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc); test_null(value); test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); /* Test a clean set */ test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, (void *)key)); value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc); test_true(value); test_memcmp(value, key, 4); test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); /* Test that we can turn it off */ test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, NULL)); value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc); test_null(value); test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); /* Now setup for main test */ test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, (void *)key)); value= (char *)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc); test_true(value); test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); test_memcmp(value, key, 4); /* Set to Zero, and then Set to something too large */ { char long_key[255]; memset(long_key, 0, 255); test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, NULL)); value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc); test_null(value); test_compare(MEMCACHED_SUCCESS, rc); /* Test a long key for failure */ /* TODO, extend test to determine based on setting, what result should be */ strncpy(long_key, "Thisismorethentheallottednumberofcharacters", sizeof(long_key)); test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, long_key)); /* Now test a key with spaces (which will fail from long key, since bad key is not set) */ strncpy(long_key, "This is more then the allotted number of characters", sizeof(long_key)); test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) ? MEMCACHED_SUCCESS : MEMCACHED_BAD_KEY_PROVIDED, memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, long_key)); /* Test for a bad prefix, but with a short key */ test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) ? MEMCACHED_INVALID_ARGUMENTS : MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_VERIFY_KEY, 1)); test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) ? MEMCACHED_SUCCESS : MEMCACHED_BAD_KEY_PROVIDED, memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, "dog cat")); } return TEST_SUCCESS; } test_return_t set_namespace(memcached_st *memc) { memcached_return_t rc; const char *key= "mine"; char *value; // Make sure we default to a null namespace value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc); test_null(value); test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); /* Test a clean set */ test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, (void *)key)); value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc); test_true(value); test_memcmp(value, key, 4); test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); return TEST_SUCCESS; } test_return_t set_namespace_and_binary(memcached_st *memc) { test_return_if(pre_binary(memc)); test_return_if(set_namespace(memc)); return TEST_SUCCESS; } #ifdef MEMCACHED_ENABLE_DEPRECATED test_return_t deprecated_set_memory_alloc(memcached_st *memc) { void *test_ptr= NULL; void *cb_ptr= NULL; { memcached_malloc_fn malloc_cb= (memcached_malloc_fn)my_malloc; cb_ptr= *(void **)&malloc_cb; memcached_return_t rc; test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_MALLOC_FUNCTION, cb_ptr)); test_ptr= memcached_callback_get(memc, MEMCACHED_CALLBACK_MALLOC_FUNCTION, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(test_ptr == cb_ptr); } { memcached_realloc_fn realloc_cb= (memcached_realloc_fn)my_realloc; cb_ptr= *(void **)&realloc_cb; memcached_return_t rc; test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_REALLOC_FUNCTION, cb_ptr)); test_ptr= memcached_callback_get(memc, MEMCACHED_CALLBACK_REALLOC_FUNCTION, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(test_ptr == cb_ptr); } { memcached_free_fn free_cb= (memcached_free_fn)my_free; cb_ptr= *(void **)&free_cb; memcached_return_t rc; test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_FREE_FUNCTION, cb_ptr)); test_ptr= memcached_callback_get(memc, MEMCACHED_CALLBACK_FREE_FUNCTION, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(test_ptr == cb_ptr); } return TEST_SUCCESS; } #endif test_return_t set_memory_alloc(memcached_st *memc) { test_compare(MEMCACHED_INVALID_ARGUMENTS, memcached_set_memory_allocators(memc, NULL, my_free, my_realloc, my_calloc, NULL)); test_compare(MEMCACHED_SUCCESS, memcached_set_memory_allocators(memc, my_malloc, my_free, my_realloc, my_calloc, NULL)); memcached_malloc_fn mem_malloc; memcached_free_fn mem_free; memcached_realloc_fn mem_realloc; memcached_calloc_fn mem_calloc; memcached_get_memory_allocators(memc, &mem_malloc, &mem_free, &mem_realloc, &mem_calloc); test_true(mem_malloc == my_malloc); test_true(mem_realloc == my_realloc); test_true(mem_calloc == my_calloc); test_true(mem_free == my_free); return TEST_SUCCESS; } test_return_t enable_consistent_crc(memcached_st *memc) { test_return_t rc; memcached_server_distribution_t value= MEMCACHED_DISTRIBUTION_CONSISTENT; memcached_hash_t hash; memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, value); if ((rc= pre_crc(memc)) != TEST_SUCCESS) return rc; value= (memcached_server_distribution_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION); test_true(value == MEMCACHED_DISTRIBUTION_CONSISTENT); hash= (memcached_hash_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH); if (hash != MEMCACHED_HASH_CRC) return TEST_SKIPPED; return TEST_SUCCESS; } test_return_t enable_consistent_hsieh(memcached_st *memc) { test_return_t rc; memcached_server_distribution_t value= MEMCACHED_DISTRIBUTION_CONSISTENT; memcached_hash_t hash; memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, value); if ((rc= pre_hsieh(memc)) != TEST_SUCCESS) { return rc; } value= (memcached_server_distribution_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION); test_true(value == MEMCACHED_DISTRIBUTION_CONSISTENT); hash= (memcached_hash_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH); if (hash != MEMCACHED_HASH_HSIEH) return TEST_SKIPPED; return TEST_SUCCESS; } test_return_t enable_cas(memcached_st *memc) { unsigned int set= 1; if (libmemcached_util_version_check(memc, 1, 2, 4)) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, set); return TEST_SUCCESS; } return TEST_SKIPPED; } test_return_t check_for_1_2_3(memcached_st *memc) { memcached_version(memc); memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); if ((instance->major_version >= 1 && (instance->minor_version == 2 && instance->micro_version >= 4)) or instance->minor_version > 2) { return TEST_SUCCESS; } return TEST_SKIPPED; } test_return_t MEMCACHED_BEHAVIOR_POLL_TIMEOUT_test(memcached_st *memc) { const uint64_t timeout= 100; // Not using, just checking that it sets memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, timeout); test_compare(timeout, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT)); return TEST_SUCCESS; } test_return_t noreply_test(memcached_st *memc) { test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, true)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, true)); test_compare(1LLU, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NOREPLY)); test_compare(1LLU, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS)); test_compare(1LLU, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS)); memcached_return_t ret; for (int count= 0; count < 5; ++count) { for (size_t x= 0; x < 100; ++x) { char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; int check_length= (size_t)snprintf(key, sizeof(key), "%lu", (unsigned long)x); test_false((size_t)check_length >= sizeof(key) || check_length < 0); size_t len= (size_t)check_length; switch (count) { case 0: ret= memcached_add(memc, key, len, key, len, 0, 0); break; case 1: ret= memcached_replace(memc, key, len, key, len, 0, 0); break; case 2: ret= memcached_set(memc, key, len, key, len, 0, 0); break; case 3: ret= memcached_append(memc, key, len, key, len, 0, 0); break; case 4: ret= memcached_prepend(memc, key, len, key, len, 0, 0); break; default: test_true(count); break; } test_true_got(ret == MEMCACHED_SUCCESS or ret == MEMCACHED_BUFFERED, memcached_strerror(NULL, ret)); } /* ** NOTE: Don't ever do this in your code! this is not a supported use of the ** API and is _ONLY_ done this way to verify that the library works the ** way it is supposed to do!!!! */ #if 0 int no_msg=0; for (uint32_t x= 0; x < memcached_server_count(memc); ++x) { memcached_server_instance_st instance= memcached_server_instance_by_position(memc, x); no_msg+=(int)(instance->cursor_active); } test_true(no_msg == 0); #endif test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc)); /* ** Now validate that all items was set properly! */ for (size_t x= 0; x < 100; ++x) { char key[10]; int check_length= (size_t)snprintf(key, sizeof(key), "%lu", (unsigned long)x); test_false((size_t)check_length >= sizeof(key) || check_length < 0); size_t len= (size_t)check_length; size_t length; uint32_t flags; char* value=memcached_get(memc, key, strlen(key), &length, &flags, &ret); // For the moment we will just go to the next key if (MEMCACHED_TIMEOUT == ret) { continue; } test_true_hint(ret == MEMCACHED_SUCCESS and value != NULL, memcached_last_error_message(memc)); switch (count) { case 0: /* FALLTHROUGH */ case 1: /* FALLTHROUGH */ case 2: test_true(strncmp(value, key, len) == 0); test_true(len == length); break; case 3: test_true(length == len * 2); break; case 4: test_true(length == len * 3); break; default: test_true(count); break; } free(value); } } /* Try setting an illegal cas value (should not return an error to * the caller (because we don't expect a return message from the server) */ const char* keys[]= {"0"}; size_t lengths[]= {1}; size_t length; uint32_t flags; memcached_result_st results_obj; memcached_result_st *results; test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, lengths, 1)); results= memcached_result_create(memc, &results_obj); test_true(results); results= memcached_fetch_result(memc, &results_obj, &ret); test_true(results); test_compare(MEMCACHED_SUCCESS, ret); uint64_t cas= memcached_result_cas(results); memcached_result_free(&results_obj); test_compare(MEMCACHED_SUCCESS, memcached_cas(memc, keys[0], lengths[0], keys[0], lengths[0], 0, 0, cas)); /* * The item will have a new cas value, so try to set it again with the old * value. This should fail! */ test_compare(MEMCACHED_SUCCESS, memcached_cas(memc, keys[0], lengths[0], keys[0], lengths[0], 0, 0, cas)); test_true(memcached_flush_buffers(memc) == MEMCACHED_SUCCESS); char* value=memcached_get(memc, keys[0], lengths[0], &length, &flags, &ret); test_true(ret == MEMCACHED_SUCCESS && value != NULL); free(value); return TEST_SUCCESS; } test_return_t analyzer_test(memcached_st *memc) { memcached_analysis_st *report; memcached_return_t rc; memcached_stat_st *memc_stat= memcached_stat(memc, NULL, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(memc_stat); report= memcached_analyze(memc, memc_stat, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(report); free(report); memcached_stat_free(NULL, memc_stat); return TEST_SUCCESS; } test_return_t util_version_test(memcached_st *memc) { test_compare_hint(MEMCACHED_SUCCESS, memcached_version(memc), memcached_last_error_message(memc)); test_true(libmemcached_util_version_check(memc, 0, 0, 0)); bool if_successful= libmemcached_util_version_check(memc, 9, 9, 9); // We expect failure if (if_successful) { fprintf(stderr, "\n----------------------------------------------------------------------\n"); fprintf(stderr, "\nDumping Server Information\n\n"); memcached_server_fn callbacks[1]; callbacks[0]= dump_server_information; memcached_server_cursor(memc, callbacks, (void *)stderr, 1); fprintf(stderr, "\n----------------------------------------------------------------------\n"); } test_true(if_successful == false); memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); memcached_version(memc); // We only use one binary when we test, so this should be just fine. if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->minor_version, instance->micro_version); test_true(if_successful == true); if (instance->micro_version > 0) { if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->minor_version, (uint8_t)(instance->micro_version -1)); } else if (instance->minor_version > 0) { if_successful= libmemcached_util_version_check(memc, instance->major_version, (uint8_t)(instance->minor_version - 1), instance->micro_version); } else if (instance->major_version > 0) { if_successful= libmemcached_util_version_check(memc, (uint8_t)(instance->major_version -1), instance->minor_version, instance->micro_version); } test_true(if_successful == true); if (instance->micro_version > 0) { if_successful= libmemcached_util_version_check(memc, instance->major_version, instance->minor_version, (uint8_t)(instance->micro_version +1)); } else if (instance->minor_version > 0) { if_successful= libmemcached_util_version_check(memc, instance->major_version, (uint8_t)(instance->minor_version +1), instance->micro_version); } else if (instance->major_version > 0) { if_successful= libmemcached_util_version_check(memc, (uint8_t)(instance->major_version +1), instance->minor_version, instance->micro_version); } test_true(if_successful == false); return TEST_SUCCESS; } test_return_t getpid_connection_failure_test(memcached_st *memc) { test_skip(memc->servers[0].type, MEMCACHED_CONNECTION_TCP); memcached_return_t rc; memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); // Test both the version that returns a code, and the one that does not. test_true(libmemcached_util_getpid(memcached_server_name(instance), memcached_server_port(instance) -1, NULL) == -1); test_true(libmemcached_util_getpid(memcached_server_name(instance), memcached_server_port(instance) -1, &rc) == -1); test_compare_got(MEMCACHED_CONNECTION_FAILURE, rc, memcached_strerror(memc, rc)); return TEST_SUCCESS; } test_return_t getpid_test(memcached_st *memc) { memcached_return_t rc; memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); // Test both the version that returns a code, and the one that does not. test_true(libmemcached_util_getpid(memcached_server_name(instance), memcached_server_port(instance), NULL) > -1); test_true(libmemcached_util_getpid(memcached_server_name(instance), memcached_server_port(instance), &rc) > -1); test_compare(MEMCACHED_SUCCESS, rc); return TEST_SUCCESS; } test_return_t ping_test(memcached_st *memc) { memcached_return_t rc; memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); // Test both the version that returns a code, and the one that does not. test_true(libmemcached_util_ping(memcached_server_name(instance), memcached_server_port(instance), NULL)); test_true(libmemcached_util_ping(memcached_server_name(instance), memcached_server_port(instance), &rc)); test_compare(MEMCACHED_SUCCESS, rc); return TEST_SUCCESS; } #if 0 test_return_t hash_sanity_test (memcached_st *memc) { (void)memc; assert(MEMCACHED_HASH_DEFAULT == MEMCACHED_HASH_DEFAULT); assert(MEMCACHED_HASH_MD5 == MEMCACHED_HASH_MD5); assert(MEMCACHED_HASH_CRC == MEMCACHED_HASH_CRC); assert(MEMCACHED_HASH_FNV1_64 == MEMCACHED_HASH_FNV1_64); assert(MEMCACHED_HASH_FNV1A_64 == MEMCACHED_HASH_FNV1A_64); assert(MEMCACHED_HASH_FNV1_32 == MEMCACHED_HASH_FNV1_32); assert(MEMCACHED_HASH_FNV1A_32 == MEMCACHED_HASH_FNV1A_32); #ifdef HAVE_HSIEH_HASH assert(MEMCACHED_HASH_HSIEH == MEMCACHED_HASH_HSIEH); #endif assert(MEMCACHED_HASH_MURMUR == MEMCACHED_HASH_MURMUR); assert(MEMCACHED_HASH_JENKINS == MEMCACHED_HASH_JENKINS); assert(MEMCACHED_HASH_MAX == MEMCACHED_HASH_MAX); return TEST_SUCCESS; } #endif test_return_t hsieh_avaibility_test (memcached_st *memc) { test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_HSIEH)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_HSIEH)); return TEST_SUCCESS; } test_return_t murmur_avaibility_test (memcached_st *memc) { test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_MURMUR)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MURMUR)); return TEST_SUCCESS; } test_return_t one_at_a_time_run (memcached_st *) { uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(one_at_a_time_values[x], memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_DEFAULT)); } return TEST_SUCCESS; } test_return_t md5_run (memcached_st *) { uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(md5_values[x], memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_MD5)); } return TEST_SUCCESS; } test_return_t crc_run (memcached_st *) { uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(crc_values[x], memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_CRC)); } return TEST_SUCCESS; } test_return_t fnv1_64_run (memcached_st *) { test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_FNV1_64)); uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(fnv1_64_values[x], memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_FNV1_64)); } return TEST_SUCCESS; } test_return_t fnv1a_64_run (memcached_st *) { test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_FNV1A_64)); uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(fnv1a_64_values[x], memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_FNV1A_64)); } return TEST_SUCCESS; } test_return_t fnv1_32_run (memcached_st *) { uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(fnv1_32_values[x], memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_FNV1_32)); } return TEST_SUCCESS; } test_return_t fnv1a_32_run (memcached_st *) { uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(fnv1a_32_values[x], memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_FNV1A_32)); } return TEST_SUCCESS; } test_return_t hsieh_run (memcached_st *) { test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_HSIEH)); uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(hsieh_values[x], memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_HSIEH)); } return TEST_SUCCESS; } test_return_t murmur_run (memcached_st *) { test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_MURMUR)); #ifdef WORDS_BIGENDIAN (void)murmur_values; return TEST_SKIPPED; #else uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(murmur_values[x], memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_MURMUR)); } return TEST_SUCCESS; #endif } test_return_t jenkins_run (memcached_st *) { uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(jenkins_values[x], memcached_generate_hash_value(*ptr, strlen(*ptr), MEMCACHED_HASH_JENKINS)); } return TEST_SUCCESS; } static uint32_t hash_md5_test_function(const char *string, size_t string_length, void *) { return libhashkit_md5(string, string_length); } static uint32_t hash_crc_test_function(const char *string, size_t string_length, void *) { return libhashkit_crc32(string, string_length); } test_return_t memcached_get_hashkit_test (memcached_st *) { uint32_t x; const char **ptr; hashkit_st new_kit; memcached_st *memc= memcached(test_literal_param("--server=localhost:1 --server=localhost:2 --server=localhost:3 --server=localhost:4 --server=localhost5 --DISTRIBUTION=modula")); uint32_t md5_hosts[]= {4U, 1U, 0U, 1U, 4U, 2U, 0U, 3U, 0U, 0U, 3U, 1U, 0U, 0U, 1U, 3U, 0U, 0U, 0U, 3U, 1U, 0U, 4U, 4U, 3U}; uint32_t crc_hosts[]= {2U, 4U, 1U, 0U, 2U, 4U, 4U, 4U, 1U, 2U, 3U, 4U, 3U, 4U, 1U, 3U, 3U, 2U, 0U, 0U, 0U, 1U, 2U, 4U, 0U}; const hashkit_st *kit= memcached_get_hashkit(memc); hashkit_clone(&new_kit, kit); test_compare(HASHKIT_SUCCESS, hashkit_set_custom_function(&new_kit, hash_md5_test_function, NULL)); memcached_set_hashkit(memc, &new_kit); /* Verify Setting the hash. */ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { uint32_t hash_val; hash_val= hashkit_digest(kit, *ptr, strlen(*ptr)); test_compare_got(md5_values[x], hash_val, *ptr); } /* Now check memcached_st. */ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { uint32_t hash_val; hash_val= memcached_generate_hash(memc, *ptr, strlen(*ptr)); test_compare_got(md5_hosts[x], hash_val, *ptr); } test_compare(HASHKIT_SUCCESS, hashkit_set_custom_function(&new_kit, hash_crc_test_function, NULL)); memcached_set_hashkit(memc, &new_kit); /* Verify Setting the hash. */ for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { uint32_t hash_val; hash_val= hashkit_digest(kit, *ptr, strlen(*ptr)); test_true(crc_values[x] == hash_val); } for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { uint32_t hash_val; hash_val= memcached_generate_hash(memc, *ptr, strlen(*ptr)); test_compare(crc_hosts[x], hash_val); } memcached_free(memc); return TEST_SUCCESS; } /* Test case adapted from John Gorman We are testing the error condition when we connect to a server via memcached_get() but find that the server is not available. */ test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *) { size_t len; uint32_t flags; memcached_return rc; // Create a handle. memcached_st *tl_memc_h= memcached(test_literal_param("--server=localhost:9898 --server=localhost:9899")); // This server should not exist // See if memcached is reachable. char *value= memcached_get(tl_memc_h, test_literal_param(__func__), &len, &flags, &rc); test_false(value); test_zero(len); test_true(memcached_failed(rc)); memcached_free(tl_memc_h); return TEST_SUCCESS; } /* We connect to a server which exists, but search for a key that does not exist. */ test_return_t memcached_get_MEMCACHED_NOTFOUND(memcached_st *memc) { size_t len; uint32_t flags; memcached_return rc; // See if memcached is reachable. char *value= memcached_get(memc, test_literal_param(__func__), &len, &flags, &rc); test_false(value); test_zero(len); test_compare(MEMCACHED_NOTFOUND, rc); return TEST_SUCCESS; } /* Test case adapted from John Gorman We are testing the error condition when we connect to a server via memcached_get_by_key() but find that the server is not available. */ test_return_t memcached_get_by_key_MEMCACHED_ERRNO(memcached_st *) { size_t len; uint32_t flags; memcached_return rc; // Create a handle. memcached_st *tl_memc_h= memcached_create(NULL); memcached_server_st *servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist memcached_server_push(tl_memc_h, servers); memcached_server_list_free(servers); // See if memcached is reachable. char *value= memcached_get_by_key(tl_memc_h, test_literal_param(__func__), // Key test_literal_param(__func__), // Value &len, &flags, &rc); test_false(value); test_zero(len); test_true(memcached_failed(rc)); memcached_free(tl_memc_h); return TEST_SUCCESS; } /* We connect to a server which exists, but search for a key that does not exist. */ test_return_t memcached_get_by_key_MEMCACHED_NOTFOUND(memcached_st *memc) { size_t len; uint32_t flags; memcached_return rc; // See if memcached is reachable. char *value= memcached_get_by_key(memc, test_literal_param(__func__), // Key test_literal_param(__func__), // Value &len, &flags, &rc); test_false(value); test_zero(len); test_compare(MEMCACHED_NOTFOUND, rc); return TEST_SUCCESS; } test_return_t regression_bug_434484(memcached_st *memc) { test_skip(TEST_SUCCESS, pre_binary(memc)); test_compare(MEMCACHED_NOTSTORED, memcached_append(memc, test_literal_param(__func__), // Key test_literal_param(__func__), // Value 0, 0)); libtest::vchar_t data; data.resize(2048 * 1024); test_compare(MEMCACHED_E2BIG, memcached_set(memc, test_literal_param(__func__), // Key &data[0], data.size(), 0, 0)); return TEST_SUCCESS; } test_return_t regression_bug_434843(memcached_st *original_memc) { test_skip(TEST_SUCCESS, pre_binary(original_memc)); memcached_return_t rc; size_t counter= 0; memcached_execute_fn callbacks[]= { &callback_counter }; /* * I only want to hit only _one_ server so I know the number of requests I'm * sending in the pipleine to the server. Let's try to do a multiget of * 1024 (that should satisfy most users don't you think?). Future versions * will include a mget_execute function call if you need a higher number. */ memcached_st *memc= create_single_instance_memcached(original_memc, "--BINARY-PROTOCOL"); keys_st keys(1024); /* * Run two times.. the first time we should have 100% cache miss, * and the second time we should have 100% cache hits */ for (ptrdiff_t y= 0; y < 2; y++) { test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys.keys_ptr(), keys.lengths_ptr(), keys.size())); // One the first run we should get a NOT_FOUND, but on the second some data // should be returned. test_compare(y ? MEMCACHED_SUCCESS : MEMCACHED_NOTFOUND, memcached_fetch_execute(memc, callbacks, (void *)&counter, 1)); if (y == 0) { /* The first iteration should give me a 100% cache miss. verify that*/ char blob[1024]= { 0 }; test_false(counter); for (size_t x= 0; x < keys.size(); ++x) { rc= memcached_add(memc, keys.key_at(x), keys.length_at(x), blob, sizeof(blob), 0, 0); test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED); } } else { /* Verify that we received all of the key/value pairs */ test_compare(counter, keys.size()); } } memcached_free(memc); return TEST_SUCCESS; } test_return_t regression_bug_434843_buffered(memcached_st *memc) { test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true)); return regression_bug_434843(memc); } test_return_t regression_bug_421108(memcached_st *memc) { memcached_return_t rc; memcached_stat_st *memc_stat= memcached_stat(memc, NULL, &rc); test_compare(MEMCACHED_SUCCESS, rc); char *bytes_str= memcached_stat_get_value(memc, memc_stat, "bytes", &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(bytes_str); char *bytes_read_str= memcached_stat_get_value(memc, memc_stat, "bytes_read", &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(bytes_read_str); char *bytes_written_str= memcached_stat_get_value(memc, memc_stat, "bytes_written", &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(bytes_written_str); unsigned long long bytes= strtoull(bytes_str, 0, 10); unsigned long long bytes_read= strtoull(bytes_read_str, 0, 10); unsigned long long bytes_written= strtoull(bytes_written_str, 0, 10); test_true(bytes != bytes_read); test_true(bytes != bytes_written); /* Release allocated resources */ free(bytes_str); free(bytes_read_str); free(bytes_written_str); memcached_stat_free(NULL, memc_stat); return TEST_SUCCESS; } /* * The test case isn't obvious so I should probably document why * it works the way it does. Bug 442914 was caused by a bug * in the logic in memcached_purge (it did not handle the case * where the number of bytes sent was equal to the watermark). * In this test case, create messages so that we hit that case * and then disable noreply mode and issue a new command to * verify that it isn't stuck. If we change the format for the * delete command or the watermarks, we need to update this * test.... */ test_return_t regression_bug_442914(memcached_st *original_memc) { test_skip(original_memc->servers[0].type, MEMCACHED_CONNECTION_TCP); memcached_st* memc= create_single_instance_memcached(original_memc, "--NOREPLY --TCP-NODELAY"); for (uint32_t x= 0; x < 250; ++x) { char key[250]; size_t len= (size_t)snprintf(key, sizeof(key), "%0250u", x); memcached_return_t rc= memcached_delete(memc, key, len, 0); char error_buffer[2048]= { 0 }; snprintf(error_buffer, sizeof(error_buffer), "%s key: %s", memcached_last_error_message(memc), key); test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, error_buffer); } // Delete, and then delete again to look for not found { char key[250]; size_t len= snprintf(key, sizeof(key), "%037u", 251U); memcached_return_t rc= memcached_delete(memc, key, len, 0); test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, false)); test_compare(MEMCACHED_NOTFOUND, memcached_delete(memc, key, len, 0)); } memcached_free(memc); return TEST_SUCCESS; } test_return_t regression_bug_447342(memcached_st *memc) { if (memcached_server_count(memc) < 3 or pre_replication(memc) != TEST_SUCCESS) { return TEST_SKIPPED; } test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 2)); keys_st keys(100); for (size_t x= 0; x < keys.size(); ++x) { test_compare(MEMCACHED_SUCCESS, memcached_set(memc, keys.key_at(x), keys.length_at(x), // Keys keys.key_at(x), keys.length_at(x), // Values 0, 0)); } /* ** We are using the quiet commands to store the replicas, so we need ** to ensure that all of them are processed before we can continue. ** In the test we go directly from storing the object to trying to ** receive the object from all of the different servers, so we ** could end up in a race condition (the memcached server hasn't yet ** processed the quiet command from the replication set when it process ** the request from the other client (created by the clone)). As a ** workaround for that we call memcached_quit to send the quit command ** to the server and wait for the response ;-) If you use the test code ** as an example for your own code, please note that you shouldn't need ** to do this ;-) */ memcached_quit(memc); /* Verify that all messages are stored, and we didn't stuff too much * into the servers */ test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys.keys_ptr(), keys.lengths_ptr(), keys.size())); unsigned int counter= 0; memcached_execute_fn callbacks[]= { &callback_counter }; test_compare(MEMCACHED_SUCCESS, memcached_fetch_execute(memc, callbacks, (void *)&counter, 1)); /* Verify that we received all of the key/value pairs */ test_compare(counter, keys.size()); memcached_quit(memc); /* * Don't do the following in your code. I am abusing the internal details * within the library, and this is not a supported interface. * This is to verify correct behavior in the library. Fake that two servers * are dead.. */ memcached_server_instance_st instance_one= memcached_server_instance_by_position(memc, 0); memcached_server_instance_st instance_two= memcached_server_instance_by_position(memc, 2); in_port_t port0= instance_one->port; in_port_t port2= instance_two->port; ((memcached_server_write_instance_st)instance_one)->port= 0; ((memcached_server_write_instance_st)instance_two)->port= 0; test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys.keys_ptr(), keys.lengths_ptr(), keys.size())); counter= 0; test_compare(MEMCACHED_SUCCESS, memcached_fetch_execute(memc, callbacks, (void *)&counter, 1)); test_compare(counter, keys.size()); /* restore the memc handle */ ((memcached_server_write_instance_st)instance_one)->port= port0; ((memcached_server_write_instance_st)instance_two)->port= port2; memcached_quit(memc); /* Remove half of the objects */ for (size_t x= 0; x < keys.size(); ++x) { if (x & 1) { test_compare(MEMCACHED_SUCCESS, memcached_delete(memc, keys.key_at(x), keys.length_at(x), 0)); } } memcached_quit(memc); ((memcached_server_write_instance_st)instance_one)->port= 0; ((memcached_server_write_instance_st)instance_two)->port= 0; /* now retry the command, this time we should have cache misses */ test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys.keys_ptr(), keys.lengths_ptr(), keys.size())); counter= 0; test_compare(MEMCACHED_SUCCESS, memcached_fetch_execute(memc, callbacks, (void *)&counter, 1)); test_compare(counter, (unsigned int)(keys.size() >> 1)); /* restore the memc handle */ ((memcached_server_write_instance_st)instance_one)->port= port0; ((memcached_server_write_instance_st)instance_two)->port= port2; return TEST_SUCCESS; } test_return_t regression_bug_463297(memcached_st *memc) { test_compare(MEMCACHED_INVALID_ARGUMENTS, memcached_delete(memc, "foo", 3, 1)); // Since we blocked timed delete, this test is no longer valid. #if 0 memcached_st *memc_clone= memcached_clone(NULL, memc); test_true(memc_clone); test_true(memcached_version(memc_clone) == MEMCACHED_SUCCESS); memcached_server_instance_st instance= memcached_server_instance_by_position(memc_clone, 0); if (instance->major_version > 1 || (instance->major_version == 1 && instance->minor_version > 2)) { /* Binary protocol doesn't support deferred delete */ memcached_st *bin_clone= memcached_clone(NULL, memc); test_true(bin_clone); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(bin_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1)); test_compare(MEMCACHED_INVALID_ARGUMENTS, memcached_delete(bin_clone, "foo", 3, 1)); memcached_free(bin_clone); memcached_quit(memc_clone); /* If we know the server version, deferred delete should fail * with invalid arguments */ test_compare(MEMCACHED_INVALID_ARGUMENTS, memcached_delete(memc_clone, "foo", 3, 1)); /* If we don't know the server version, we should get a protocol error */ memcached_return_t rc= memcached_delete(memc, "foo", 3, 1); /* but there is a bug in some of the memcached servers (1.4) that treats * the counter as noreply so it doesn't send the proper error message */ test_true_got(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR || rc == MEMCACHED_INVALID_ARGUMENTS, memcached_strerror(NULL, rc)); /* And buffered mode should be disabled and we should get protocol error */ test_true(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1) == MEMCACHED_SUCCESS); rc= memcached_delete(memc, "foo", 3, 1); test_true_got(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR || rc == MEMCACHED_INVALID_ARGUMENTS, memcached_strerror(NULL, rc)); /* Same goes for noreply... */ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1)); rc= memcached_delete(memc, "foo", 3, 1); test_true_got(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR || rc == MEMCACHED_INVALID_ARGUMENTS, memcached_strerror(NULL, rc)); /* but a normal request should go through (and be buffered) */ test_compare(MEMCACHED_BUFFERED, (rc= memcached_delete(memc, "foo", 3, 0))); test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 0)); /* unbuffered noreply should be success */ test_compare(MEMCACHED_SUCCESS, memcached_delete(memc, "foo", 3, 0)); /* unbuffered with reply should be not found... */ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 0)); test_compare(MEMCACHED_NOTFOUND, memcached_delete(memc, "foo", 3, 0)); } memcached_free(memc_clone); #endif return TEST_SUCCESS; } /* Test memcached_server_get_last_disconnect * For a working server set, shall be NULL * For a set of non existing server, shall not be NULL */ test_return_t test_get_last_disconnect(memcached_st *memc) { memcached_return_t rc; memcached_server_instance_st disconnected_server; /* With the working set of server */ const char *key= "marmotte"; const char *value= "milka"; memcached_reset_last_disconnected_server(memc); test_false(memc->last_disconnected_server); rc= memcached_set(memc, key, strlen(key), value, strlen(value), (time_t)0, (uint32_t)0); test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED); disconnected_server = memcached_server_get_last_disconnect(memc); test_false(disconnected_server); /* With a non existing server */ memcached_st *mine; memcached_server_st *servers; const char *server_list= "localhost:9"; servers= memcached_servers_parse(server_list); test_true(servers); mine= memcached_create(NULL); rc= memcached_server_push(mine, servers); test_compare(MEMCACHED_SUCCESS, rc); memcached_server_list_free(servers); test_true(mine); rc= memcached_set(mine, key, strlen(key), value, strlen(value), (time_t)0, (uint32_t)0); test_true(memcached_failed(rc)); disconnected_server= memcached_server_get_last_disconnect(mine); test_true_got(disconnected_server, memcached_strerror(mine, rc)); test_compare(in_port_t(9), memcached_server_port(disconnected_server)); test_false(strncmp(memcached_server_name(disconnected_server),"localhost",9)); memcached_quit(mine); memcached_free(mine); return TEST_SUCCESS; } test_return_t test_multiple_get_last_disconnect(memcached_st *) { const char *server_string= "--server=localhost:8888 --server=localhost:8889 --server=localhost:8890 --server=localhost:8891 --server=localhost:8892"; char buffer[BUFSIZ]; test_compare(MEMCACHED_SUCCESS, libmemcached_check_configuration(server_string, strlen(server_string), buffer, sizeof(buffer))); memcached_st *memc= memcached(server_string, strlen(server_string)); test_true(memc); // We will just use the error strings as our keys uint32_t counter= 100; while (--counter) { for (int x= int(MEMCACHED_SUCCESS); x < int(MEMCACHED_MAXIMUM_RETURN); ++x) { const char *msg= memcached_strerror(memc, memcached_return_t(x)); memcached_return_t ret= memcached_set(memc, msg, strlen(msg), NULL, 0, (time_t)0, (uint32_t)0); test_true_got((ret == MEMCACHED_CONNECTION_FAILURE or ret == MEMCACHED_SERVER_TEMPORARILY_DISABLED), memcached_last_error_message(memc)); memcached_server_instance_st disconnected_server= memcached_server_get_last_disconnect(memc); test_true(disconnected_server); test_strcmp("localhost", memcached_server_name(disconnected_server)); test_true(memcached_server_port(disconnected_server) >= 8888 and memcached_server_port(disconnected_server) <= 8892); if (random() % 2) { memcached_reset_last_disconnected_server(memc); } } } memcached_free(memc); return TEST_SUCCESS; } test_return_t test_verbosity(memcached_st *memc) { memcached_verbosity(memc, 3); return TEST_SUCCESS; } static memcached_return_t stat_printer(memcached_server_instance_st server, const char *key, size_t key_length, const char *value, size_t value_length, void *context) { (void)server; (void)context; (void)key; (void)key_length; (void)value; (void)value_length; return MEMCACHED_SUCCESS; } test_return_t memcached_stat_execute_test(memcached_st *memc) { memcached_return_t rc= memcached_stat_execute(memc, NULL, stat_printer, NULL); test_compare(MEMCACHED_SUCCESS, rc); test_compare(MEMCACHED_SUCCESS, memcached_stat_execute(memc, "slabs", stat_printer, NULL)); test_compare(MEMCACHED_SUCCESS, memcached_stat_execute(memc, "items", stat_printer, NULL)); test_compare(MEMCACHED_SUCCESS, memcached_stat_execute(memc, "sizes", stat_printer, NULL)); return TEST_SUCCESS; } /* * This test ensures that the failure counter isn't incremented during * normal termination of the memcached instance. */ test_return_t wrong_failure_counter_test(memcached_st *original_memc) { memcached_st* memc= create_single_instance_memcached(original_memc, NULL); /* Ensure that we are connected to the server by setting a value */ memcached_return_t rc= memcached_set(memc, test_literal_param(__func__), // Key test_literal_param(__func__), // Value time_t(0), uint32_t(0)); test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); /* The test is to see that the memcached_quit doesn't increase the * the server failure conter, so let's ensure that it is zero * before sending quit */ ((memcached_server_write_instance_st)instance)->server_failure_counter= 0; memcached_quit(memc); /* Verify that it memcached_quit didn't increment the failure counter * Please note that this isn't bullet proof, because an error could * occur... */ test_zero(instance->server_failure_counter); memcached_free(memc); return TEST_SUCCESS; } /* * This tests ensures expected disconnections (for some behavior changes * for instance) do not wrongly increase failure counter */ test_return_t wrong_failure_counter_two_test(memcached_st *memc) { /* Set value to force connection to the server */ const char *key= "marmotte"; const char *value= "milka"; test_compare_hint(MEMCACHED_SUCCESS, memcached_set(memc, key, strlen(key), value, strlen(value), (time_t)0, (uint32_t)0), memcached_last_error_message(memc)); /* put failure limit to 1 */ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, true)); /* Put a retry timeout to effectively activate failure_limit effect */ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, true)); /* change behavior that triggers memcached_quit()*/ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true)); /* Check if we still are connected */ uint32_t flags; size_t string_length; memcached_return rc; char *string= memcached_get(memc, key, strlen(key), &string_length, &flags, &rc); test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc)); test_true(string); free(string); return TEST_SUCCESS; } test_return_t regression_996813_TEST(memcached_st *) { memcached_st* memc= memcached_create(NULL); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 1)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, 1)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, 300)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 30)); // We will never connect to these servers in_port_t base_port= 11211; for (size_t x= 0; x < 17; x++) { test_compare(MEMCACHED_SUCCESS, memcached_server_add(memc, "10.2.3.4", base_port +x)); } test_compare(16U, memcached_generate_hash(memc, test_literal_param("SZ6hu0SHweFmpwpc0w2R"))); test_compare(1U, memcached_generate_hash(memc, test_literal_param("SQCK9eiCf53YxHWnYA.o"))); test_compare(10U, memcached_generate_hash(memc, test_literal_param("SUSDkGXuuZC9t9VhMwa."))); test_compare(8U, memcached_generate_hash(memc, test_literal_param("SnnqnJARfaCNT679iAF_"))); memcached_free(memc); return TEST_SUCCESS; } /* * Test that ensures mget_execute does not end into recursive calls that finally fails */ test_return_t regression_bug_490486(memcached_st *original_memc) { #ifdef __APPLE__ return TEST_SKIPPED; // My MAC can't handle this test #endif test_skip(TEST_SUCCESS, pre_binary(original_memc)); /* * I only want to hit _one_ server so I know the number of requests I'm * sending in the pipeline. */ memcached_st *memc= create_single_instance_memcached(original_memc, "--BINARY-PROTOCOL --POLL-TIMEOUT=1000 --REMOVE-FAILED-SERVERS=1 --RETRY-TIMEOUT=3600"); test_true(memc); keys_st keys(20480); /* First add all of the items.. */ char blob[1024]= { 0 }; for (size_t x= 0; x < keys.size(); ++x) { memcached_return rc= memcached_set(memc, keys.key_at(x), keys.length_at(x), blob, sizeof(blob), 0, 0); test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); // MEMCACHED_TIMEOUT <-- hash been observed on OSX } { /* Try to get all of them with a large multiget */ size_t counter= 0; memcached_execute_function callbacks[]= { &callback_counter }; memcached_return_t rc= memcached_mget_execute(memc, keys.keys_ptr(), keys.lengths_ptr(), keys.size(), callbacks, &counter, 1); test_compare(MEMCACHED_SUCCESS, rc); char* the_value= NULL; char the_key[MEMCACHED_MAX_KEY]; size_t the_key_length; size_t the_value_length; uint32_t the_flags; do { the_value= memcached_fetch(memc, the_key, &the_key_length, &the_value_length, &the_flags, &rc); if ((the_value!= NULL) && (rc == MEMCACHED_SUCCESS)) { ++counter; free(the_value); } } while ( (the_value!= NULL) && (rc == MEMCACHED_SUCCESS)); test_compare(MEMCACHED_END, rc); /* Verify that we got all of the items */ test_compare(counter, keys.size()); } memcached_free(memc); return TEST_SUCCESS; } test_return_t regression_bug_583031(memcached_st *) { memcached_st *memc= memcached_create(NULL); test_true(memc); test_compare(MEMCACHED_SUCCESS, memcached_server_add(memc, "10.2.3.4", 11211)); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, 1000); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 1000); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SND_TIMEOUT, 1000); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RCV_TIMEOUT, 1000); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, 1000); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, 3); memcached_return_t rc; size_t length; uint32_t flags; const char *value= memcached_get(memc, "dsf", 3, &length, &flags, &rc); test_false(value); test_zero(length); test_compare_got(MEMCACHED_TIMEOUT, rc, memcached_last_error_message(memc)); memcached_free(memc); return TEST_SUCCESS; } test_return_t regression_bug_581030(memcached_st *) { #ifndef DEBUG memcached_stat_st *local_stat= memcached_stat(NULL, NULL, NULL); test_false(local_stat); memcached_stat_free(NULL, NULL); #endif return TEST_SUCCESS; } #define regression_bug_655423_COUNT 6000 test_return_t regression_bug_655423(memcached_st *memc) { memcached_st *clone= memcached_clone(NULL, memc); memc= NULL; // Just to make sure it is not used test_true(clone); char payload[100]; #ifdef __APPLE__ return TEST_SKIPPED; #endif test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1)); test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_SUPPORT_CAS, 1)); test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1)); test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH, 1)); memset(payload, int('x'), sizeof(payload)); keys_st keys(regression_bug_655423_COUNT); for (size_t x= 0; x < keys.size(); x++) { test_compare(MEMCACHED_SUCCESS, memcached_set(clone, keys.key_at(x), keys.length_at(x), payload, sizeof(payload), 0, 0)); } for (size_t x= 0; x < keys.size(); x++) { size_t value_length; memcached_return_t rc; char *value= memcached_get(clone, keys.key_at(x), keys.length_at(x), &value_length, NULL, &rc); if (rc == MEMCACHED_NOTFOUND) { test_false(value); test_zero(value_length); continue; } test_compare(MEMCACHED_SUCCESS, rc); test_true(value); test_compare(100LLU, value_length); free(value); } test_compare(MEMCACHED_SUCCESS, memcached_mget(clone, keys.keys_ptr(), keys.lengths_ptr(), keys.size())); uint32_t count= 0; memcached_result_st *result= NULL; while ((result= memcached_fetch_result(clone, result, NULL))) { test_compare(size_t(100), memcached_result_length(result)); count++; } test_true(count > 100); // If we don't get back atleast this, something is up memcached_free(clone); return TEST_SUCCESS; } /* * Test that ensures that buffered set to not trigger problems during io_flush */ #define regression_bug_490520_COUNT 200480 test_return_t regression_bug_490520(memcached_st *original_memc) { memcached_st* memc= create_single_instance_memcached(original_memc, NULL); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK,1); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS,1); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, 1000); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT,1); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 3600); /* First add all of the items.. */ char blob[3333] = {0}; for (uint32_t x= 0; x < regression_bug_490520_COUNT; ++x) { char key[251]; int key_length= snprintf(key, sizeof(key), "0200%u", x); memcached_return rc= memcached_set(memc, key, key_length, blob, sizeof(blob), 0, 0); test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_last_error_message(memc)); } memcached_free(memc); return TEST_SUCCESS; } test_return_t regression_994772_TEST(memcached_st* memc) { test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1)); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param(__func__), // Key test_literal_param(__func__), // Value time_t(0), uint32_t(0))); const char *keys[] = { __func__ }; size_t key_length[]= { strlen(__func__) }; test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, keys, key_length, 1)); memcached_return_t rc; memcached_result_st *results= memcached_fetch_result(memc, NULL, &rc); test_true(results); test_compare(MEMCACHED_SUCCESS, rc); test_strcmp(__func__, memcached_result_value(results)); uint64_t cas_value= memcached_result_cas(results); test_true(cas_value); memcached_result_free(results); // Bad cas value, sanity check test_true(cas_value != 9999); test_compare(MEMCACHED_END, memcached_cas(memc, test_literal_param(__func__), // Key test_literal_param(__FILE__), // Value time_t(0), uint32_t(0), 9999)); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, "different", strlen("different"), // Key test_literal_param(__FILE__), // Value time_t(0), uint32_t(0))); return TEST_SUCCESS; } test_return_t regression_bug_854604(memcached_st *) { char buffer[1024]; test_compare(MEMCACHED_INVALID_ARGUMENTS, libmemcached_check_configuration(0, 0, buffer, 0)); test_compare(MEMCACHED_PARSE_ERROR, libmemcached_check_configuration(test_literal_param("syntax error"), buffer, 0)); test_compare(MEMCACHED_PARSE_ERROR, libmemcached_check_configuration(test_literal_param("syntax error"), buffer, 1)); test_compare(buffer[0], 0); test_compare(MEMCACHED_PARSE_ERROR, libmemcached_check_configuration(test_literal_param("syntax error"), buffer, 10)); test_true(strlen(buffer)); test_compare(MEMCACHED_PARSE_ERROR, libmemcached_check_configuration(test_literal_param("syntax error"), buffer, sizeof(buffer))); test_true(strlen(buffer)); return TEST_SUCCESS; } static void memcached_die(memcached_st* mc, memcached_return error, const char* what, uint32_t it) { fprintf(stderr, "Iteration #%u: ", it); if (error == MEMCACHED_ERRNO) { fprintf(stderr, "system error %d from %s: %s\n", errno, what, strerror(errno)); } else { fprintf(stderr, "error %d from %s: %s\n", error, what, memcached_strerror(mc, error)); } } #define TEST_CONSTANT_CREATION 200 test_return_t regression_bug_(memcached_st *memc) { const char *remote_server; (void)memc; if (! (remote_server= getenv("LIBMEMCACHED_REMOTE_SERVER"))) { return TEST_SKIPPED; } for (uint32_t x= 0; x < TEST_CONSTANT_CREATION; x++) { memcached_st* mc= memcached_create(NULL); memcached_return rc; rc= memcached_behavior_set(mc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1); if (rc != MEMCACHED_SUCCESS) { memcached_die(mc, rc, "memcached_behavior_set", x); } rc= memcached_behavior_set(mc, MEMCACHED_BEHAVIOR_CACHE_LOOKUPS, 1); if (rc != MEMCACHED_SUCCESS) { memcached_die(mc, rc, "memcached_behavior_set", x); } rc= memcached_server_add(mc, remote_server, 0); if (rc != MEMCACHED_SUCCESS) { memcached_die(mc, rc, "memcached_server_add", x); } const char *set_key= "akey"; const size_t set_key_len= strlen(set_key); const char *set_value= "a value"; const size_t set_value_len= strlen(set_value); if (rc == MEMCACHED_SUCCESS) { if (x > 0) { size_t get_value_len; char *get_value; uint32_t get_value_flags; get_value= memcached_get(mc, set_key, set_key_len, &get_value_len, &get_value_flags, &rc); if (rc != MEMCACHED_SUCCESS) { memcached_die(mc, rc, "memcached_get", x); } else { if (x != 0 && (get_value_len != set_value_len || 0!=strncmp(get_value, set_value, get_value_len))) { fprintf(stderr, "Values don't match?\n"); rc= MEMCACHED_FAILURE; } free(get_value); } } rc= memcached_set(mc, set_key, set_key_len, set_value, set_value_len, 0, /* time */ 0 /* flags */ ); if (rc != MEMCACHED_SUCCESS) { memcached_die(mc, rc, "memcached_set", x); } } memcached_quit(mc); memcached_free(mc); if (rc != MEMCACHED_SUCCESS) { break; } } return TEST_SUCCESS; } test_return_t kill_HUP_TEST(memcached_st *original_memc) { memcached_st *memc= create_single_instance_memcached(original_memc, 0); test_true(memc); memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); pid_t pid; test_true((pid= libmemcached_util_getpid(memcached_server_name(instance), memcached_server_port(instance), NULL)) > -1); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param(__func__), // Keys test_literal_param(__func__), // Values 0, 0)); test_true_got(kill(pid, SIGHUP) == 0, strerror(errno)); test_compare(MEMCACHED_CONNECTION_FAILURE, memcached_set(memc, test_literal_param(__func__), // Keys test_literal_param(__func__), // Values 0, 0)); memcached_free(memc); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/pool.cc0000664000076400007640000003167011753573717021741 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * Copyright (C) 2011 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 #include using namespace libtest; #include #include #include #include #include #include #include #include #include #include #include #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif test_return_t memcached_pool_test(memcached_st *) { memcached_return_t rc; const char *config_string= "--SERVER=host10.example.com --SERVER=host11.example.com --SERVER=host10.example.com --POOL-MIN=10 --POOL-MAX=32"; char buffer[2048]; rc= libmemcached_check_configuration(config_string, sizeof(config_string) -1, buffer, sizeof(buffer)); test_true_got(rc != MEMCACHED_SUCCESS, buffer); memcached_pool_st* pool= memcached_pool(config_string, strlen(config_string)); test_true_got(pool, strerror(errno)); memcached_st *memc= memcached_pool_pop(pool, false, &rc); test_true(rc == MEMCACHED_SUCCESS); test_true(memc); /* Release the memc_ptr that was pulled from the pool */ memcached_pool_push(pool, memc); /* Destroy the pool. */ memcached_pool_destroy(pool); return TEST_SUCCESS; } #define POOL_SIZE 10 test_return_t connection_pool_test(memcached_st *memc) { memcached_pool_st* pool= memcached_pool_create(memc, 5, POOL_SIZE); test_true(pool); memcached_st *mmc[POOL_SIZE]; // Fill up our array that we will store the memc that are in the pool for (size_t x= 0; x < POOL_SIZE; ++x) { memcached_return_t rc; mmc[x]= memcached_pool_fetch(pool, NULL, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(mmc[x]); } // All memc should be gone { memcached_return_t rc; test_null(memcached_pool_fetch(pool, NULL, &rc)); test_compare(MEMCACHED_NOTFOUND, rc); } // Release them.. for (size_t x= 0; x < POOL_SIZE; ++x) { if (mmc[x]) { test_compare(MEMCACHED_SUCCESS, memcached_pool_release(pool, mmc[x])); } } test_true(memcached_pool_destroy(pool) == memc); return TEST_SUCCESS; } test_return_t connection_pool2_test(memcached_st *memc) { memcached_pool_st* pool= memcached_pool_create(memc, 5, POOL_SIZE); test_true(pool); memcached_st *mmc[POOL_SIZE]; // Fill up our array that we will store the memc that are in the pool for (size_t x= 0; x < POOL_SIZE; ++x) { memcached_return_t rc; mmc[x]= memcached_pool_fetch(pool, NULL, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(mmc[x]); } // All memc should be gone { memcached_return_t rc; test_null(memcached_pool_fetch(pool, NULL, &rc)); test_compare(MEMCACHED_NOTFOUND, rc); } // verify that I can do ops with all connections test_compare(MEMCACHED_SUCCESS, memcached_set(mmc[0], test_literal_param("key"), "0", 1, 0, 0)); for (uint64_t x= 0; x < POOL_SIZE; ++x) { uint64_t number_value; test_compare(MEMCACHED_SUCCESS, memcached_increment(mmc[x], test_literal_param("key"), 1, &number_value)); test_compare(number_value, (x+1)); } // Release them.. for (size_t x= 0; x < POOL_SIZE; ++x) { test_compare(MEMCACHED_SUCCESS, memcached_pool_release(pool, mmc[x])); } /* verify that I can set behaviors on the pool when I don't have all * of the connections in the pool. It should however be enabled * when I push the item into the pool */ mmc[0]= memcached_pool_fetch(pool, NULL, NULL); test_true(mmc[0]); test_compare(MEMCACHED_SUCCESS, memcached_pool_behavior_set(pool, MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK, 9999)); { memcached_return_t rc; mmc[1]= memcached_pool_fetch(pool, NULL, &rc); test_true(mmc[1]); test_compare(MEMCACHED_SUCCESS, rc); } test_compare(UINT64_C(9999), memcached_behavior_get(mmc[1], MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK)); test_compare(MEMCACHED_SUCCESS, memcached_pool_release(pool, mmc[1])); test_compare(MEMCACHED_SUCCESS, memcached_pool_release(pool, mmc[0])); { memcached_return_t rc; mmc[0]= memcached_pool_fetch(pool, NULL, &rc); test_true(mmc[0]); test_compare(MEMCACHED_SUCCESS, rc); } test_compare(UINT64_C(9999), memcached_behavior_get(mmc[0], MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK)); test_compare(MEMCACHED_SUCCESS, memcached_pool_release(pool, mmc[0])); test_true(memcached_pool_destroy(pool) == memc); return TEST_SUCCESS; } struct test_pool_context_st { volatile memcached_return_t rc; memcached_pool_st* pool; memcached_st* mmc; sem_t _lock; test_pool_context_st(memcached_pool_st *pool_arg, memcached_st *memc_arg): rc(MEMCACHED_FAILURE), pool(pool_arg), mmc(memc_arg) { sem_init(&_lock, 0, 0); } void wait() { sem_wait(&_lock); } void release() { sem_post(&_lock); } ~test_pool_context_st() { sem_destroy(&_lock); } }; static void* connection_release(void *arg) { test_pool_context_st *resource= static_cast(arg); if (resource == NULL) { fatal_message("resource == NULL"); } // Release all of the memc we are holding resource->rc= memcached_pool_release(resource->pool, resource->mmc); resource->release(); pthread_exit(arg); } test_return_t connection_pool3_test(memcached_st *memc) { #ifdef __APPLE__ return TEST_SKIPPED; #endif memcached_pool_st* pool= memcached_pool_create(memc, 1, 1); test_true(pool); memcached_st *pool_memc; { memcached_return_t rc; pool_memc= memcached_pool_fetch(pool, NULL, &rc); test_compare(MEMCACHED_SUCCESS, rc); test_true(pool_memc); } /* @note This comment was written to describe what was believed to be the original authors intent. This portion of the test creates a thread that will wait until told to free a memcached_st that will be grabbed by the main thread. It is believed that this tests whether or not we are handling ownership correctly. */ pthread_t tid; test_pool_context_st item(pool, pool_memc); test_zero(pthread_create(&tid, NULL, connection_release, &item)); item.wait(); memcached_return_t rc; memcached_st *pop_memc; // We do a hard loop, and try N times int counter= 5; do { struct timespec relative_time= { 0, 0 }; pop_memc= memcached_pool_fetch(pool, &relative_time, &rc); if (memcached_success(rc)) { break; } if (memcached_failed(rc)) { test_null(pop_memc); test_true(rc != MEMCACHED_TIMEOUT); // As long as relative_time is zero, MEMCACHED_TIMEOUT is invalid } } while (--counter); if (memcached_failed(rc)) // Cleanup thread since we will exit once we test. { pthread_join(tid, NULL); test_compare(MEMCACHED_SUCCESS, rc); } { int pthread_ret= pthread_join(tid, NULL); test_true(pthread_ret == 0 or pthread_ret == ESRCH); } test_compare(MEMCACHED_SUCCESS, rc); test_true(pool_memc == pop_memc); test_true(memcached_pool_destroy(pool) == memc); return TEST_SUCCESS; } static memcached_st * create_single_instance_memcached(const memcached_st *original_memc, const char *options) { /* If no options are given, copy over at least the binary flag. */ char options_buffer[1024]= { 0 }; if (options == NULL) { if (memcached_is_binary(original_memc)) { snprintf(options_buffer, sizeof(options_buffer), "--BINARY"); } } /* * I only want to hit _one_ server so I know the number of requests I'm * sending in the pipeline. */ memcached_server_instance_st instance= memcached_server_instance_by_position(original_memc, 0); char server_string[1024]; int server_string_length; if (instance->type == MEMCACHED_CONNECTION_UNIX_SOCKET) { if (options) { server_string_length= snprintf(server_string, sizeof(server_string), "--SOCKET=\"%s\" %s", memcached_server_name(instance), options); } else { server_string_length= snprintf(server_string, sizeof(server_string), "--SOCKET=\"%s\"", memcached_server_name(instance)); } } else { if (options) { server_string_length= snprintf(server_string, sizeof(server_string), "--server=%s:%d %s", memcached_server_name(instance), int(memcached_server_port(instance)), options); } else { server_string_length= snprintf(server_string, sizeof(server_string), "--server=%s:%d", memcached_server_name(instance), int(memcached_server_port(instance))); } } if (server_string_length <= 0) { return NULL; } char errror_buffer[1024]; if (memcached_failed(libmemcached_check_configuration(server_string, server_string_length, errror_buffer, sizeof(errror_buffer)))) { Error << "Failed to parse (" << server_string << ") " << errror_buffer; return NULL; } return memcached(server_string, server_string_length); } pthread_mutex_t mutex= PTHREAD_MUTEX_INITIALIZER; static bool _running= false; static void set_running(const bool arg) { int error; if ((error= pthread_mutex_lock(&mutex)) != 0) { fatal_message(strerror(error)); } _running= arg; if ((error= pthread_mutex_unlock(&mutex)) != 0) { fatal_message(strerror(error)); } } static bool running() { int error; bool ret; if ((error= pthread_mutex_lock(&mutex)) != 0) { fatal_message(strerror(error)); } ret= _running; if ((error= pthread_mutex_unlock(&mutex)) != 0) { fatal_message(strerror(error)); } return ret; } static void *worker_thread(void *ctx) { memcached_pool_st *pool= (memcached_pool_st *)ctx; while (running()) { memcached_return_t rc; memcached_st *mc= memcached_pool_pop(pool, true, &rc); if (mc == NULL) { Error << "failed to fetch a connection from the pool" << memcached_strerror(NULL, rc); dream(1, 0); continue; } rc= memcached_set(mc, "test:kv", 7, "value", 5, 600, 0); if (memcached_failed(rc)) { Out << "failed memcached_set()"; } rc= memcached_pool_push(pool, mc); if (memcached_failed(rc)) { Error << "failed to release a connection to the pool" << memcached_strerror(NULL, rc); } } return NULL; } #define NUM_THREADS 20 test_return_t regression_bug_962815(memcached_st *memc) { pthread_t pid[NUM_THREADS]; test_false(running()); memcached_st *master = create_single_instance_memcached(memc, 0); test_true(master); memcached_pool_st *pool= memcached_pool_create(master, 5, 10); test_true(pool); set_running(true); for (size_t x=0; x < NUM_THREADS; x++) { test_compare(0, pthread_create(&pid[x], NULL, worker_thread, (void*)pool)); } { pollfd fds[1]; memset(fds, 0, sizeof(pollfd)); fds[0].fd= -1; //STDIN_FILENO; fds[0].events= POLLIN; fds[0].revents= 0; int active_fd; if ((active_fd= poll(fds, 1, 5000)) == -1) { Error << "poll() failed with:" << strerror(errno); } set_running(false); } for (size_t x=0; x < NUM_THREADS; x++) { test_compare(0, pthread_join(pid[x], NULL)); } if (pool) { memcached_pool_destroy(pool); } if (master) { memcached_free(master); } return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/callback_counter.cc0000664000076400007640000000371011753573717024255 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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 #include #include "tests/libmemcached-1.0/callback_counter.h" memcached_return_t callback_counter(const memcached_st*, memcached_result_st*, void *context) { size_t *counter= (size_t *)context; *counter= *counter + 1; return MEMCACHED_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/exist.cc0000664000076400007640000000667711753573717022135 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 #include #include using namespace libtest; test_return_t memcached_exist_NOTFOUND(memcached_st *memc) { test_compare(MEMCACHED_NOTFOUND, memcached_exist(memc, test_literal_param("frog"))); return TEST_SUCCESS; } test_return_t memcached_exist_SUCCESS(memcached_st *memc) { test_compare_got(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("frog"), 0, 0, 0, 0), memcached_last_error_message(memc)); test_compare_got(MEMCACHED_SUCCESS, memcached_exist(memc, test_literal_param("frog")), memcached_last_error_message(memc)); test_compare_got(MEMCACHED_SUCCESS, memcached_delete(memc, test_literal_param("frog"), 0), memcached_last_error_message(memc)); test_compare_got(MEMCACHED_NOTFOUND, memcached_exist(memc, test_literal_param("frog")), memcached_last_error_message(memc)); return TEST_SUCCESS; } test_return_t memcached_exist_by_key_NOTFOUND(memcached_st *memc) { test_compare(MEMCACHED_NOTFOUND, memcached_exist_by_key(memc, test_literal_param("master"), test_literal_param("frog"))); return TEST_SUCCESS; } test_return_t memcached_exist_by_key_SUCCESS(memcached_st *memc) { test_compare_got(MEMCACHED_SUCCESS, memcached_set_by_key(memc, test_literal_param("master"), test_literal_param("frog"), 0, 0, 0, 0), memcached_last_error_message(memc)); test_compare_got(MEMCACHED_SUCCESS, memcached_exist_by_key(memc, test_literal_param("master"), test_literal_param("frog")), memcached_last_error_message(memc)); test_compare_got(MEMCACHED_SUCCESS, memcached_delete_by_key(memc, test_literal_param("master"), test_literal_param("frog"), 0), memcached_last_error_message(memc)); test_compare_got(MEMCACHED_NOTFOUND, memcached_exist_by_key(memc, test_literal_param("master"), test_literal_param("frog")), memcached_last_error_message(memc)); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/stat.cc0000664000076400007640000000742611753573717021745 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached 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 #include #include #include #include #include using namespace libtest; #include "tests/libmemcached-1.0/stat.h" static memcached_return_t item_counter(memcached_server_instance_st , const char *key, size_t key_length, const char *value, size_t, // value_length, void *context) { if ((key_length == (sizeof("curr_items") -1)) and (strncmp("curr_items", key, (sizeof("curr_items") -1)) == 0)) { uint64_t* counter= (uint64_t*)context; unsigned long number_value= strtoul(value, (char **)NULL, 10); if (number_value == ULONG_MAX) { return MEMCACHED_FAILURE; } *counter= *counter +number_value; } return MEMCACHED_SUCCESS; } test_return_t memcached_stat_TEST(memcached_st *memc) { uint64_t counter= 0; test_compare_got(MEMCACHED_INVALID_ARGUMENTS, memcached_stat_execute(memc, "BAD_ARG_VALUE", item_counter, &counter), memcached_last_error_message(memc)); return TEST_SUCCESS; } #define memcached_dump_TEST2_COUNT 64 test_return_t memcached_stat_TEST2(memcached_st *memc) { test_skip(false, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); /* The dump test relies on there being at least 32 items in memcached */ for (uint32_t x= 0; x < memcached_dump_TEST2_COUNT; x++) { char key[1024]; int length= snprintf(key, sizeof(key), "%s%u", __func__, x); test_true(length > 0); test_compare_hint(MEMCACHED_SUCCESS, memcached_set(memc, key, length, NULL, 0, // Zero length values time_t(0), uint32_t(0)), memcached_last_error_message(memc)); } memcached_quit(memc); uint64_t counter= 0; test_compare_got(MEMCACHED_SUCCESS, memcached_stat_execute(memc, NULL, item_counter, &counter), memcached_last_error_message(memc)); test_true_got(counter > 0, counter); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/callbacks.cc0000664000076400007640000000564511753573717022712 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * Copyright (C) 2011 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 #include #include using namespace libtest; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif static memcached_return_t delete_trigger(memcached_st *, const char *key, size_t key_length) { fatal_assert(key); fatal_assert(key_length); return MEMCACHED_SUCCESS; } test_return_t test_MEMCACHED_CALLBACK_DELETE_TRIGGER_and_MEMCACHED_BEHAVIOR_NOREPLY(memcached_st *) { memcached_st *memc= memcached(test_literal_param("--NOREPLY")); test_true(memc); memcached_trigger_delete_key_fn callback; callback= (memcached_trigger_delete_key_fn)delete_trigger; test_compare(MEMCACHED_INVALID_ARGUMENTS, memcached_callback_set(memc, MEMCACHED_CALLBACK_DELETE_TRIGGER, *(void**)&callback)); memcached_free(memc); return TEST_SUCCESS; } test_return_t test_MEMCACHED_CALLBACK_DELETE_TRIGGER(memcached_st *memc) { memcached_trigger_delete_key_fn callback; callback= (memcached_trigger_delete_key_fn)delete_trigger; test_compare(MEMCACHED_SUCCESS, memcached_callback_set(memc, MEMCACHED_CALLBACK_DELETE_TRIGGER, *(void**)&callback)); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/mem_functions.h0000664000076400007640000002211611753573717023473 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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. * */ #pragma once test_return_t MEMCACHED_BEHAVIOR_CORK_test(memcached_st *memc); test_return_t MEMCACHED_BEHAVIOR_POLL_TIMEOUT_test(memcached_st *memc); test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test(memcached_st *memc); test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test(memcached_st *memc); test_return_t _user_supplied_bug21(memcached_st* memc, size_t key_count); test_return_t add_host_test(memcached_st *memc); test_return_t add_host_test1(memcached_st *memc); test_return_t add_test(memcached_st *memc); test_return_t add_wrapper(memcached_st *memc); test_return_t allocation_test(memcached_st *not_used); test_return_t analyzer_test(memcached_st *memc); test_return_t append_binary_test(memcached_st *memc); test_return_t append_test(memcached_st *memc); test_return_t bad_key_test(memcached_st *memc); test_return_t behavior_test(memcached_st *memc); test_return_t binary_add_regression(memcached_st *memc); test_return_t binary_increment_with_prefix_test(memcached_st *memc); test_return_t block_add_regression(memcached_st *memc); test_return_t callback_test(memcached_st *memc); test_return_t cas2_test(memcached_st *memc); test_return_t cas_test(memcached_st *memc); test_return_t check_for_1_2_3(memcached_st *memc); test_return_t clone_test(memcached_st *memc); test_return_t connection_test(memcached_st *memc); test_return_t crc_run (memcached_st *); test_return_t decrement_by_key_test(memcached_st *memc); test_return_t decrement_test(memcached_st *memc); test_return_t decrement_with_initial_by_key_test(memcached_st *memc); test_return_t decrement_with_initial_test(memcached_st *memc); test_return_t delete_test(memcached_st *memc); test_return_t deprecated_set_memory_alloc(memcached_st *memc); test_return_t enable_cas(memcached_st *memc); test_return_t enable_consistent_crc(memcached_st *memc); test_return_t enable_consistent_hsieh(memcached_st *memc); test_return_t flush_test(memcached_st *memc); test_return_t fnv1_32_run (memcached_st *); test_return_t fnv1_64_run (memcached_st *); test_return_t fnv1a_32_run (memcached_st *); test_return_t fnv1a_64_run (memcached_st *); test_return_t get_stats(memcached_st *memc); test_return_t get_stats_keys(memcached_st *memc); test_return_t getpid_connection_failure_test(memcached_st *memc); test_return_t getpid_test(memcached_st *memc); test_return_t hash_sanity_test (memcached_st *memc); test_return_t hsieh_avaibility_test (memcached_st *memc); test_return_t hsieh_run (memcached_st *); test_return_t increment_by_key_test(memcached_st *memc); test_return_t increment_test(memcached_st *memc); test_return_t increment_with_initial_by_key_test(memcached_st *memc); test_return_t increment_with_initial_test(memcached_st *memc); test_return_t init_test(memcached_st *not_used); test_return_t jenkins_run (memcached_st *); test_return_t key_setup(memcached_st *memc); test_return_t key_teardown(memcached_st *); test_return_t libmemcached_string_behavior_test(memcached_st *); test_return_t libmemcached_string_distribution_test(memcached_st *); test_return_t md5_run (memcached_st *); test_return_t memcached_fetch_result_NOT_FOUND(memcached_st *memc); test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *); test_return_t memcached_get_MEMCACHED_NOTFOUND(memcached_st *memc); test_return_t memcached_get_by_key_MEMCACHED_ERRNO(memcached_st *memc); test_return_t memcached_get_by_key_MEMCACHED_NOTFOUND(memcached_st *memc); test_return_t memcached_get_hashkit_test (memcached_st *); test_return_t memcached_mget_mixed_memcached_get_TEST(memcached_st *memc); test_return_t memcached_return_t_TEST(memcached_st *memc); test_return_t memcached_server_cursor_test(memcached_st *memc); test_return_t memcached_server_remove_test(memcached_st*); test_return_t memcached_stat_execute_test(memcached_st *memc); test_return_t mget_end(memcached_st *memc); test_return_t mget_execute(memcached_st *original_memc); test_return_t mget_result_alloc_test(memcached_st *memc); test_return_t mget_result_function(memcached_st *memc); 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 noreply_test(memcached_st *memc); test_return_t one_at_a_time_run (memcached_st *); test_return_t output_ketama_weighted_keys(memcached_st *); test_return_t ping_test(memcached_st *memc); test_return_t prepend_test(memcached_st *memc); test_return_t quit_test(memcached_st *memc); test_return_t read_through(memcached_st *memc); test_return_t regression_bug_(memcached_st *memc); test_return_t regression_bug_421108(memcached_st *memc); test_return_t regression_bug_434484(memcached_st *memc); test_return_t regression_bug_434843(memcached_st *original_memc); test_return_t regression_bug_434843_buffered(memcached_st *memc); test_return_t regression_bug_442914(memcached_st *memc); test_return_t regression_bug_447342(memcached_st *memc); test_return_t regression_bug_463297(memcached_st *memc); test_return_t regression_bug_490486(memcached_st *original_memc); test_return_t regression_bug_490520(memcached_st *memc); test_return_t regression_bug_581030(memcached_st *); test_return_t regression_bug_583031(memcached_st *); test_return_t regression_bug_655423(memcached_st *memc); test_return_t regression_bug_854604(memcached_st *); test_return_t replace_test(memcached_st *memc); test_return_t result_alloc(memcached_st *memc); test_return_t result_static(memcached_st *memc); test_return_t selection_of_namespace_tests(memcached_st *memc); test_return_t server_sort2_test(memcached_st *ptr); test_return_t server_sort_test(memcached_st *ptr); test_return_t server_unsort_test(memcached_st *ptr); test_return_t set_memory_alloc(memcached_st *memc); test_return_t set_namespace(memcached_st *memc); test_return_t set_namespace_and_binary(memcached_st *memc); test_return_t set_test(memcached_st *memc); test_return_t set_test2(memcached_st *memc); test_return_t set_test3(memcached_st *memc); test_return_t stats_servername_test(memcached_st *memc); test_return_t test_get_last_disconnect(memcached_st *memc); test_return_t test_multiple_get_last_disconnect(memcached_st *); test_return_t test_verbosity(memcached_st *memc); test_return_t user_supplied_bug10(memcached_st *memc); test_return_t user_supplied_bug11(memcached_st *memc); test_return_t user_supplied_bug12(memcached_st *memc); test_return_t user_supplied_bug13(memcached_st *memc); test_return_t user_supplied_bug14(memcached_st *memc); test_return_t user_supplied_bug15(memcached_st *memc); test_return_t user_supplied_bug16(memcached_st *memc); test_return_t user_supplied_bug17(memcached_st *memc); test_return_t user_supplied_bug19(memcached_st *); test_return_t user_supplied_bug20(memcached_st *memc); test_return_t user_supplied_bug21(memcached_st *memc); test_return_t user_supplied_bug4(memcached_st *memc); test_return_t user_supplied_bug5(memcached_st *memc); test_return_t user_supplied_bug6(memcached_st *memc); test_return_t user_supplied_bug7(memcached_st *memc); test_return_t user_supplied_bug8(memcached_st *); test_return_t user_supplied_bug9(memcached_st *memc); test_return_t userdata_test(memcached_st *memc); test_return_t util_version_test(memcached_st *memc); test_return_t version_string_test(memcached_st *); test_return_t wrong_failure_counter_test(memcached_st *memc); test_return_t wrong_failure_counter_two_test(memcached_st *memc); test_return_t kill_HUP_TEST(memcached_st *memc); test_return_t regression_996813_TEST(memcached_st*); test_return_t regression_994772_TEST(memcached_st*); libmemcached-1.0.8/tests/libmemcached-1.0/generate.cc0000664000076400007640000002507711753573717022566 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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 #include #include #include #include #include #include "tests/libmemcached-1.0/callback_counter.h" #include "clients/generator.h" #include "clients/execute.h" #define GLOBAL_COUNT 10000 #define GLOBAL2_COUNT 100 using namespace libtest; static pairs_st *global_pairs= NULL; static const char *global_keys[GLOBAL_COUNT]; static size_t global_keys_length[GLOBAL_COUNT]; static size_t global_count= 0; test_return_t cleanup_pairs(memcached_st*) { pairs_free(global_pairs); global_pairs= NULL; return TEST_SUCCESS; } static test_return_t generate_pairs(memcached_st *) { global_pairs= pairs_generate(GLOBAL_COUNT, 400); global_count= GLOBAL_COUNT; for (size_t x= 0; x < global_count; x++) { global_keys[x]= global_pairs[x].key; global_keys_length[x]= global_pairs[x].key_length; } return TEST_SUCCESS; } test_return_t generate_large_pairs(memcached_st *memc) { global_pairs= pairs_generate(GLOBAL2_COUNT, MEMCACHED_MAX_BUFFER+10); global_count= GLOBAL2_COUNT; for (size_t x= 0; x < global_count; x++) { global_keys[x]= global_pairs[x].key; global_keys_length[x]= global_pairs[x].key_length; } memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true); unsigned int check_execute= execute_set(memc, global_pairs, global_count); test_true(check_execute > (global_count / 2)); return TEST_SUCCESS; } test_return_t generate_data(memcached_st *memc) { test_compare(TEST_SUCCESS, generate_pairs(memc)); unsigned int check_execute= execute_set(memc, global_pairs, global_count); test_true_hint(check_execute > (global_count / 2), "Possible false, positive, memcached may have ejected key/value based on memory needs"); return TEST_SUCCESS; } test_return_t generate_data_with_stats(memcached_st *memc) { test_compare(TEST_SUCCESS, generate_pairs(memc)); unsigned int check_execute= execute_set(memc, global_pairs, global_count); test_compare(check_execute, global_count); // @todo hosts used size stats memcached_return_t rc; memcached_stat_st *stat_p= memcached_stat(memc, NULL, &rc); test_true(stat_p); for (uint32_t host_index= 0; host_index < memcached_server_count(memc); host_index++) { /* This test was changes so that "make test" would work properlly */ if (DEBUG) { memcached_server_instance_st instance= memcached_server_instance_by_position(memc, host_index); printf("\nserver %u|%s|%u bytes: %llu\n", host_index, instance->hostname, instance->port, (unsigned long long)(stat_p + host_index)->bytes); } test_true((unsigned long long)(stat_p + host_index)->bytes); } memcached_stat_free(NULL, stat_p); return TEST_SUCCESS; } test_return_t generate_buffer_data(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true); generate_data(memc); return TEST_SUCCESS; } test_return_t get_read_count(memcached_st *memc) { memcached_st *memc_clone= memcached_clone(NULL, memc); test_true(memc_clone); memcached_server_add_with_weight(memc_clone, "localhost", 6666, 0); { char *return_value; size_t return_value_length; uint32_t flags; uint32_t count; for (size_t x= count= 0; x < global_count; x++) { memcached_return_t rc; return_value= memcached_get(memc_clone, global_keys[x], global_keys_length[x], &return_value_length, &flags, &rc); if (rc == MEMCACHED_SUCCESS) { count++; if (return_value) { free(return_value); } } } } memcached_free(memc_clone); return TEST_SUCCESS; } test_return_t get_read(memcached_st *memc) { size_t keys_returned= 0; for (size_t x= 0; x < global_count; x++) { size_t return_value_length; uint32_t flags; memcached_return_t rc; char *return_value= memcached_get(memc, global_keys[x], global_keys_length[x], &return_value_length, &flags, &rc); /* test_true(return_value); test_compare(MEMCACHED_SUCCESS, rc); */ if (rc == MEMCACHED_SUCCESS && return_value) { keys_returned++; free(return_value); } } test_true_hint(keys_returned > (global_count / 2), "Possible false, positive, memcached may have ejected key/value based on memory needs"); return TEST_SUCCESS; } test_return_t mget_read(memcached_st *memc) { test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4))); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, global_keys, global_keys_length, global_count)); // Go fetch the keys and test to see if all of them were returned { unsigned int keys_returned; test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned)); test_true(keys_returned > (global_count / 2)); } return TEST_SUCCESS; } test_return_t mget_read_result(memcached_st *memc) { test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4))); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, global_keys, global_keys_length, global_count)); /* Turn this into a help function */ { memcached_result_st results_obj; memcached_result_st *results= memcached_result_create(memc, &results_obj); test_true(results); memcached_return_t rc; while ((results= memcached_fetch_result(memc, &results_obj, &rc))) { if (rc == MEMCACHED_IN_PROGRESS) { continue; } test_true(results); test_compare(MEMCACHED_SUCCESS, rc); } test_compare(MEMCACHED_END, rc); memcached_result_free(&results_obj); } return TEST_SUCCESS; } test_return_t mget_read_partial_result(memcached_st *memc) { test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4))); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, global_keys, global_keys_length, global_count)); // We will scan for just one key { memcached_result_st results_obj; memcached_result_st *results= memcached_result_create(memc, &results_obj); memcached_return_t rc; results= memcached_fetch_result(memc, results, &rc); test_true(results); test_compare(MEMCACHED_SUCCESS, rc); memcached_result_free(&results_obj); } // We already have a read happening, lets start up another one. test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, global_keys, global_keys_length, global_count)); { memcached_result_st results_obj; memcached_result_st *results= memcached_result_create(memc, &results_obj); test_true(results); test_false(memcached_is_allocated(results)); memcached_return_t rc; while ((results= memcached_fetch_result(memc, &results_obj, &rc))) { test_true(results); test_compare(MEMCACHED_SUCCESS, rc); } test_compare(MEMCACHED_END, rc); memcached_result_free(&results_obj); } return TEST_SUCCESS; } test_return_t mget_read_function(memcached_st *memc) { test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4))); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, global_keys, global_keys_length, global_count)); memcached_execute_fn callbacks[]= { &callback_counter }; size_t counter= 0; test_compare(MEMCACHED_SUCCESS, memcached_fetch_execute(memc, callbacks, (void *)&counter, 1)); return TEST_SUCCESS; } test_return_t delete_generate(memcached_st *memc) { size_t total= 0; for (size_t x= 0; x < global_count; x++) { if (memcached_success(memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0))) { total++; } } test_true_hint(total > (global_count / 2), "Possible false, positive, memcached may have ejected key/value based on memory needs"); return TEST_SUCCESS; } test_return_t delete_buffer_generate(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true); size_t total= 0; for (size_t x= 0; x < global_count; x++) { if (memcached_success(memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0))) { total++; } } test_true_hint(total > (global_count / 2), "Possible false, positive, memcached may have ejected key/value based on memory needs"); return TEST_SUCCESS; } test_return_t mget_read_internal_result(memcached_st *memc) { test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4))); test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, global_keys, global_keys_length, global_count)); { memcached_result_st *results= NULL; memcached_return_t rc; while ((results= memcached_fetch_result(memc, results, &rc))) { test_true(results); test_compare(MEMCACHED_SUCCESS, rc); } test_compare(MEMCACHED_END, rc); memcached_result_free(results); } return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/stat.h0000664000076400007640000000336111753573717021601 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached 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. * */ #pragma once test_return_t memcached_stat_TEST(memcached_st *); test_return_t memcached_stat_TEST2(memcached_st *); libmemcached-1.0.8/tests/libmemcached-1.0/plus.cpp0000664000076400007640000001771711753763014022145 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include /* C++ interface test */ #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace memcache; using namespace libtest; static void populate_vector(vector &vec, const string &str) { vec.reserve(str.length()); vec.assign(str.begin(), str.end()); } static void copy_vec_to_string(vector &vec, string &str) { str.clear(); if (not vec.empty()) { str.assign(vec.begin(), vec.end()); } } static test_return_t basic_test(memcached_st *memc) { Memcache foo(memc); const string value_set("This is some data"); std::vector value; std::vector test_value; populate_vector(value, value_set); test_true(foo.set("mine", value, 0, 0)); test_true(foo.get("mine", test_value)); test_compare(test_value.size(), value.size()); test_memcmp(&test_value[0], &value[0], test_value.size()); test_false(foo.set("", value, 0, 0)); return TEST_SUCCESS; } static test_return_t increment_test(memcached_st *original) { Memcache mcach(original); const string key("blah"); const string inc_value("1"); std::vector inc_val; vector ret_value; string ret_string; uint64_t int_inc_value; uint64_t int_ret_value; populate_vector(inc_val, inc_value); test_true(mcach.set(key, inc_val, 0, 0)); test_true(mcach.get(key, ret_value)); test_false(ret_value.empty()); copy_vec_to_string(ret_value, ret_string); int_inc_value= uint64_t(atol(inc_value.c_str())); int_ret_value= uint64_t(atol(ret_string.c_str())); test_compare(int_inc_value, int_ret_value); test_true(mcach.increment(key, 1, &int_ret_value)); test_compare(uint64_t(2), int_ret_value); test_true(mcach.increment(key, 1, &int_ret_value)); test_compare(uint64_t(3), int_ret_value); test_true(mcach.increment(key, 5, &int_ret_value)); test_compare(uint64_t(8), int_ret_value); return TEST_SUCCESS; } static test_return_t basic_master_key_test(memcached_st *original) { Memcache foo(original); const string value_set("Data for server A"); vector value; vector test_value; const string master_key_a("server-a"); const string master_key_b("server-b"); const string key("xyz"); populate_vector(value, value_set); test_true(foo.setByKey(master_key_a, key, value, 0, 0)); test_true(foo.getByKey(master_key_a, key, test_value)); test_compare(value.size(), test_value.size()); test_memcmp(&value[0], &test_value[0], value.size()); test_value.clear(); #if 0 test_false(foo.getByKey(master_key_b, key, test_value)); test_zero(test_value.size()); #endif return TEST_SUCCESS; } static test_return_t mget_test(memcached_st *original) { Memcache memc(original); memcached_return_t mc_rc; vector keys; vector< vector *> values; keys.reserve(3); keys.push_back("fudge"); keys.push_back("son"); keys.push_back("food"); vector val1; vector val2; vector val3; populate_vector(val1, "fudge"); populate_vector(val2, "son"); populate_vector(val3, "food"); values.reserve(3); values.push_back(&val1); values.push_back(&val2); values.push_back(&val3); string return_key; vector return_value; /* We need to empty the server before we continue the test */ test_true(memc.flush()); test_true(memc.mget(keys)); test_compare(MEMCACHED_NOTFOUND, memc.fetch(return_key, return_value)); test_true(memc.setAll(keys, values, 50, 9)); test_true(memc.mget(keys)); size_t count= 0; while (memcached_success(mc_rc= memc.fetch(return_key, return_value))) { test_compare(return_key.length(), return_value.size()); test_memcmp(&return_value[0], return_key.c_str(), return_value.size()); count++; } test_compare(values.size(), count); return TEST_SUCCESS; } static test_return_t basic_behavior(memcached_st *original) { Memcache memc(original); test_true(memc.setBehavior(MEMCACHED_BEHAVIOR_VERIFY_KEY, true)); test_compare(true, memc.getBehavior(MEMCACHED_BEHAVIOR_VERIFY_KEY)); return TEST_SUCCESS; } static test_return_t error_test(memcached_st *) { Memcache memc("--server=localhost:178"); std::vector value; test_false(memc.set("key", value, time_t(0), uint32_t(0))); test_true(memc.error()); return TEST_SUCCESS; } static test_return_t error_std_string_test(memcached_st *) { Memcache memc("--server=localhost:178"); std::vector value; test_false(memc.set("key", value, time_t(0), uint32_t(0))); std::string error_message; test_true(memc.error(error_message)); test_false(error_message.empty()); return TEST_SUCCESS; } static test_return_t error_memcached_return_t_test(memcached_st *) { Memcache memc("--server=localhost:178"); std::vector value; test_false(memc.set("key", value, time_t(0), uint32_t(0))); memcached_return_t rc; test_true(memc.error(rc)); test_compare(MEMCACHED_CONNECTION_FAILURE, rc); return TEST_SUCCESS; } test_st error_tests[] ={ { "error()", false, reinterpret_cast(error_test) }, { "error(std::string&)", false, reinterpret_cast(error_std_string_test) }, { "error(memcached_return_t&)", false, reinterpret_cast(error_memcached_return_t_test) }, {0, 0, 0} }; test_st tests[] ={ { "basic", false, reinterpret_cast(basic_test) }, { "basic_master_key", false, reinterpret_cast(basic_master_key_test) }, { "increment_test", false, reinterpret_cast(increment_test) }, { "mget", true, reinterpret_cast(mget_test) }, { "basic_behavior", false, reinterpret_cast(basic_behavior) }, {0, 0, 0} }; collection_st collection[] ={ {"block", 0, 0, tests}, {"error()", 0, 0, error_tests}, {0, 0, 0, 0} }; #define SERVERS_TO_CREATE 5 #define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT +10 #include "tests/libmemcached_world.h" void get_world(Framework *world) { world->collections(collection); world->create((test_callback_create_fn*)world_create); world->destroy((test_callback_destroy_fn*)world_destroy); world->set_runner(new LibmemcachedRunner); } libmemcached-1.0.8/tests/libmemcached-1.0/encoding_key.h0000664000076400007640000000503611753573717023265 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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. * */ #pragma once test_return_t memcached_set_encoding_key_TEST(memcached_st*); test_return_t memcached_set_encoding_key_set_get_TEST(memcached_st*); test_return_t memcached_set_encoding_key_add_get_TEST(memcached_st*); test_return_t memcached_set_encoding_key_replace_get_TEST(memcached_st*); test_return_t memcached_set_encoding_key_increment_TEST(memcached_st*); test_return_t memcached_set_encoding_key_decrement_TEST(memcached_st*); test_return_t memcached_set_encoding_key_increment_with_initial_TEST(memcached_st*); test_return_t memcached_set_encoding_key_decrement_with_initial_TEST(memcached_st*); test_return_t memcached_set_encoding_key_prepend_TEST(memcached_st*); test_return_t memcached_set_encoding_key_append_TEST(memcached_st*); test_return_t memcached_set_encoding_key_set_get_clone_TEST(memcached_st*); test_return_t memcached_set_encoding_key_set_grow_key_TEST(memcached_st*); libmemcached-1.0.8/tests/libmemcached-1.0/haldenbrand.h0000664000076400007640000000350111753573717023064 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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. * */ #pragma once test_return_t haldenbrand_TEST1(memcached_st *); test_return_t haldenbrand_TEST2(memcached_st *); test_return_t haldenbrand_TEST3(memcached_st *); libmemcached-1.0.8/tests/libmemcached-1.0/string.cc0000664000076400007640000001323311753573717022271 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached client and server library. * * Copyright (C) 2011 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. * */ // We let libmemcached/common.h define config since we are looking at // library internals. #include #include #include #include #include #include test_return_t string_static_null(void*) { memcached_st *memc= memcached_create(NULL); memcached_string_st string; memcached_string_st *string_ptr= memcached_string_create(memc, &string, 0); test_true(string.options.is_initialized); test_true(string_ptr); /* The following two better be the same! */ test_false(memcached_is_allocated(string_ptr)); test_false(memcached_is_allocated(&string)); test_true(&string == string_ptr); test_true(string.options.is_initialized); test_true(memcached_is_initialized(&string)); memcached_string_free(&string); test_false(memcached_is_initialized(&string)); memcached_free(memc); return TEST_SUCCESS; } test_return_t string_alloc_null(void*) { memcached_st *memc= memcached_create(NULL); memcached_string_st *string= memcached_string_create(memc, NULL, 0); test_true(string); test_true(memcached_is_allocated(string)); test_true(memcached_is_initialized(string)); memcached_string_free(string); memcached_free(memc); return TEST_SUCCESS; } test_return_t string_alloc_with_size(void*) { memcached_st *memc= memcached_create(NULL); memcached_string_st *string= memcached_string_create(memc, NULL, 1024); test_true(string); test_true(memcached_is_allocated(string)); test_true(memcached_is_initialized(string)); memcached_string_free(string); memcached_free(memc); return TEST_SUCCESS; } test_return_t string_alloc_with_size_toobig(void*) { memcached_st *memc= memcached_create(NULL); memcached_string_st *string= memcached_string_create(memc, NULL, SIZE_MAX); test_zero(string); memcached_free(memc); return TEST_SUCCESS; } test_return_t string_alloc_append(void*) { memcached_st *memc= memcached_create(NULL); char buffer[BUFSIZ]; memcached_string_st *string; /* Ring the bell! */ memset(buffer, 6, BUFSIZ); string= memcached_string_create(memc, NULL, 100); test_true(string); test_true(memcached_is_allocated(string)); test_true(memcached_is_initialized(string)); for (unsigned int x= 0; x < 1024; x++) { memcached_return_t rc; rc= memcached_string_append(string, buffer, BUFSIZ); test_true(rc == MEMCACHED_SUCCESS); } test_true(memcached_is_allocated(string)); memcached_string_free(string); memcached_free(memc); return TEST_SUCCESS; } test_return_t string_alloc_append_toobig(void*) { memcached_st *memc= memcached_create(NULL); memcached_return_t rc; char buffer[BUFSIZ]; memcached_string_st *string; /* Ring the bell! */ memset(buffer, 6, sizeof(buffer)); string= memcached_string_create(memc, NULL, 100); test_true(string); test_true(memcached_is_allocated(string)); test_true(memcached_is_initialized(string)); for (unsigned int x= 0; x < 1024; x++) { rc= memcached_string_append(string, buffer, BUFSIZ); test_true(rc == MEMCACHED_SUCCESS); } rc= memcached_string_append(string, buffer, SIZE_MAX); test_true(rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE); test_true(memcached_is_allocated(string)); memcached_string_free(string); memcached_free(memc); return TEST_SUCCESS; } test_return_t string_alloc_append_multiple(void*) { memcached_st *memc= memcached_create(NULL); memcached_string_st *error_string= memcached_string_create(memc, NULL, 1024); memcached_string_append(error_string, test_literal_param("Error occured while parsing: ")); memcached_string_append(error_string, test_string_make_from_cstr("jog the strlen() method")); memcached_string_append(error_string, test_literal_param(" (")); memcached_string_append(error_string, test_string_make_from_cstr(memcached_strerror(NULL, MEMCACHED_SUCCESS))); memcached_string_append(error_string, test_literal_param(")")); memcached_string_free(error_string); memcached_free(memc); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/parser.h0000664000076400007640000000672011753573717022124 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif test_return_t memcached_NULL_string_TEST(memcached_st*); test_return_t memcached_zero_string_length_TEST(memcached_st*); LIBTEST_LOCAL test_return_t server_test(memcached_st *memc); LIBTEST_LOCAL test_return_t servers_bad_test(memcached_st *memc); LIBTEST_LOCAL test_return_t behavior_parser_test(memcached_st*); LIBTEST_LOCAL test_return_t parser_number_options_test(memcached_st*); LIBTEST_LOCAL test_return_t parser_distribution_test(memcached_st*); LIBTEST_LOCAL test_return_t parser_hash_test(memcached_st*); LIBTEST_LOCAL test_return_t parser_boolean_options_test(memcached_st*); LIBTEST_LOCAL test_return_t parser_key_prefix_test(memcached_st*); LIBTEST_LOCAL test_return_t libmemcached_check_configuration_test(memcached_st*); LIBTEST_LOCAL test_return_t memcached_create_with_options_test(memcached_st*); LIBTEST_LOCAL test_return_t memcached_create_with_options_with_filename(memcached_st*); LIBTEST_LOCAL test_return_t libmemcached_check_configuration_with_filename_test(memcached_st*); LIBTEST_LOCAL test_return_t random_statement_build_test(memcached_st*); LIBTEST_LOCAL test_return_t test_include_keyword(memcached_st*); LIBTEST_LOCAL test_return_t test_end_keyword(memcached_st*); LIBTEST_LOCAL test_return_t test_reset_keyword(memcached_st*); LIBTEST_LOCAL test_return_t test_error_keyword(memcached_st*); LIBTEST_LOCAL test_return_t server_with_weight_test(memcached_st *); LIBTEST_LOCAL test_return_t test_hostname_port_weight(memcached_st *); LIBTEST_LOCAL test_return_t regression_bug_71231153_connect(memcached_st *); LIBTEST_LOCAL test_return_t regression_bug_71231153_poll(memcached_st *); LIBTEST_LOCAL test_return_t test_parse_socket(memcached_st *); LIBTEST_LOCAL test_return_t test_namespace_keyword(memcached_st*); #ifdef __cplusplus } #endif libmemcached-1.0.8/tests/libmemcached-1.0/dump.cc0000664000076400007640000001143111753573717021726 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached 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 #include #include #include #include #include using namespace libtest; #include "tests/libmemcached-1.0/dump.h" static memcached_return_t callback_dump_counter(const memcached_st *, const char*, // key, size_t, // length, void *context) { size_t *counter= (size_t *)context; #if 0 std::cerr.write(key, length); std::cerr << std::endl; #endif *counter= *counter +1; return MEMCACHED_SUCCESS; } static memcached_return_t item_counter(memcached_server_instance_st , const char *key, size_t key_length, const char *value, size_t, // value_length, void *context) { if ((key_length == (sizeof("curr_items") -1)) and (strncmp("curr_items", key, (sizeof("curr_items") -1)) == 0)) { uint64_t* counter= (uint64_t*)context; unsigned long number_value= strtoul(value, (char **)NULL, 10); if (number_value == ULONG_MAX) { return MEMCACHED_FAILURE; } *counter= *counter +number_value; } return MEMCACHED_SUCCESS; } #if 0 test_return_t memcached_dump_TEST(memcached_st *memc) { test_skip(false, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); size_t count= 0; memcached_dump_fn callbacks[1]; callbacks[0]= &callback_dump_counter; uint64_t counter= 0; test_compare_got(MEMCACHED_SUCCESS, memcached_stat_execute(memc, NULL, item_counter, &counter), memcached_last_error_message(memc)); test_zero(counter); test_compare_got(MEMCACHED_SUCCESS, memcached_dump(memc, callbacks, &count, 1), memcached_last_error_message(memc)); return TEST_SUCCESS; } #endif #define memcached_dump_TEST2_COUNT 64 test_return_t memcached_dump_TEST2(memcached_st *memc) { test_skip(false, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); /* The dump test relies on there being at least 32 items in memcached */ for (uint32_t x= 0; x < memcached_dump_TEST2_COUNT; x++) { char key[1024]; int length= snprintf(key, sizeof(key), "%s%u", __func__, x); test_true(length > 0); test_compare_hint(MEMCACHED_SUCCESS, memcached_set(memc, key, length, NULL, 0, // Zero length values time_t(0), uint32_t(0)), memcached_last_error_message(memc)); } memcached_quit(memc); uint64_t counter= 0; test_compare_got(MEMCACHED_SUCCESS, memcached_stat_execute(memc, NULL, item_counter, &counter), memcached_last_error_message(memc)); test_true_got(counter > 0, counter); size_t count= 0; memcached_dump_fn callbacks[1]; callbacks[0]= &callback_dump_counter; test_compare_got(MEMCACHED_SUCCESS, memcached_dump(memc, callbacks, &count, 1), memcached_last_error_message(memc)); test_true(count); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/server_add.cc0000664000076400007640000000437711753573717023112 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * Copyright (C) 2011 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 #include using namespace libtest; #include #include test_return_t memcached_server_add_null_test(memcached_st*) { memcached_st *memc= memcached_create(NULL); test_compare(MEMCACHED_SUCCESS, memcached_server_add(memc, NULL, 0)); memcached_free(memc); return TEST_SUCCESS; } test_return_t memcached_server_add_empty_test(memcached_st*) { memcached_st *memc= memcached_create(NULL); test_compare(MEMCACHED_SUCCESS, memcached_server_add(memc, "", 0)); memcached_free(memc); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/fetch_all_results.cc0000664000076400007640000000442211753573717024465 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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 #include #include test_return_t fetch_all_results(memcached_st *memc, unsigned int &keys_returned, memcached_return_t& rc) { keys_returned= 0; memcached_result_st* result= NULL; while ((result= memcached_fetch_result(memc, result, &rc))) { test_compare(MEMCACHED_SUCCESS, rc); keys_returned+= 1; } memcached_result_free(result); return TEST_SUCCESS; } test_return_t fetch_all_results(memcached_st *memc, unsigned int &keys_returned) { memcached_return_t rc; return fetch_all_results(memc, keys_returned, rc); } libmemcached-1.0.8/tests/libmemcached-1.0/all_tests_socket.cc0000664000076400007640000000547611753763014024326 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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 #include #include "tests/basic.h" #include "tests/debug.h" #include "tests/deprecated.h" #include "tests/error_conditions.h" #include "tests/exist.h" #include "tests/ketama.h" #include "tests/namespace.h" #include "tests/libmemcached-1.0/parser.h" #include "tests/libmemcached-1.0/dump.h" #include "tests/libmemcached-1.0/generate.h" #include "tests/libmemcached-1.0/haldenbrand.h" #include "tests/libmemcached-1.0/stat.h" #include "tests/touch.h" #include "tests/callbacks.h" #include "tests/pool.h" #include "tests/print.h" #include "tests/replication.h" #include "tests/server_add.h" #include "tests/virtual_buckets.h" #include "tests/libmemcached-1.0/setup_and_teardowns.h" #include "tests/libmemcached-1.0/mem_functions.h" #include "tests/libmemcached-1.0/encoding_key.h" /* Collections we are running */ #include "tests/libmemcached-1.0/all_tests.h" #include "tests/libmemcached_world_socket.h" void get_world(Framework *world) { world->collections(collection); world->create((test_callback_create_fn*)world_create); world->destroy((test_callback_destroy_fn*)world_destroy); world->set_runner(new LibmemcachedRunner); } libmemcached-1.0.8/tests/libmemcached-1.0/debug.cc0000664000076400007640000001355311753641027022044 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached client and server library. * * Copyright (C) 2011 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 #include #include using namespace libtest; #include #include #include /* Dump each server's keys */ static memcached_return_t print_keys_callback(const memcached_st *, const char *key, size_t key_length, void *) { Out << "\t" << key << " (" << key_length << ")"; return MEMCACHED_SUCCESS; } static memcached_return_t server_wrapper_for_dump_callback(const memcached_st *, memcached_server_instance_st server, void *) { memcached_st *memc= memcached_create(NULL); if (server->type == MEMCACHED_CONNECTION_UNIX_SOCKET) { if (memcached_failed(memcached_server_add_unix_socket(memc, memcached_server_name(server)))) { return MEMCACHED_FAILURE; } } else { if (memcached_failed(memcached_server_add(memc, memcached_server_name(server), memcached_server_port(server)))) { return MEMCACHED_FAILURE; } } memcached_dump_fn callbacks[1]; callbacks[0]= &print_keys_callback; Out << memcached_server_name(server) << ":" << memcached_server_port(server); if (memcached_failed(memcached_dump(memc, callbacks, NULL, 1))) { return MEMCACHED_FAILURE; } memcached_free(memc); return MEMCACHED_SUCCESS; } test_return_t confirm_keys_exist(memcached_st *memc, const char * const *keys, const size_t number_of_keys, bool key_matches_value, bool require_all) { for (size_t x= 0; x < number_of_keys; ++x) { memcached_return_t rc; size_t value_length; char *value= memcached_get(memc, test_string_make_from_cstr(keys[x]), // Keys &value_length, 0, &rc); if (require_all) { test_true_got(value, keys[x]); if (key_matches_value) { test_strcmp(keys[x], value); } } else if (memcached_success(rc)) { test_warn_hint(value, keys[x]); if (value and key_matches_value) { test_strcmp(keys[x], value); } } if (value) { free(value); } } return TEST_SUCCESS; } test_return_t confirm_keys_dont_exist(memcached_st *memc, const char * const *keys, const size_t number_of_keys) { for (size_t x= 0; x < number_of_keys; ++x) { memcached_return_t rc; size_t value_length; char *value= memcached_get(memc, test_string_make_from_cstr(keys[x]), // Keys &value_length, 0, &rc); test_false(value); test_compare(MEMCACHED_NOTFOUND, rc); } return TEST_SUCCESS; } test_return_t print_keys_by_server(memcached_st *memc) { memcached_server_fn callback[]= { server_wrapper_for_dump_callback }; test_compare(MEMCACHED_SUCCESS, memcached_server_cursor(memc, callback, NULL, test_array_length(callback))); return TEST_SUCCESS; } static memcached_return_t callback_dump_counter(const memcached_st *ptr, const char *key, size_t key_length, void *context) { (void)ptr; (void)key; (void)key_length; size_t *counter= (size_t *)context; *counter= *counter + 1; return MEMCACHED_SUCCESS; } size_t confirm_key_count(memcached_st *memc) { memcached_st *clone= memcached_clone(NULL, memc); if (memcached_failed(memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, false))) { memcached_free(clone); return ULONG_MAX; } memcached_dump_fn callbacks[1]; callbacks[0]= &callback_dump_counter; size_t count= 0; if (memcached_failed(memcached_dump(clone, callbacks, (void *)&count, 1))) { memcached_free(clone); return ULONG_MAX; } memcached_free(clone); return count; } void print_servers(memcached_st *memc) { memcached_server_fn callbacks[1]; callbacks[0]= server_print_callback; memcached_server_cursor(memc, callbacks, NULL, 1); } libmemcached-1.0.8/tests/libmemcached-1.0/generate.h0000664000076400007640000000452211753573717022420 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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. * */ #pragma once test_return_t cleanup_pairs(memcached_st*); test_return_t delete_buffer_generate(memcached_st*); test_return_t delete_generate(memcached_st*); test_return_t generate_buffer_data(memcached_st*); test_return_t generate_data(memcached_st*); test_return_t generate_data_with_stats(memcached_st*); test_return_t generate_large_pairs(memcached_st *); test_return_t get_read(memcached_st*); test_return_t get_read_count(memcached_st*); test_return_t mget_read(memcached_st*); test_return_t mget_read_function(memcached_st*); test_return_t mget_read_partial_result(memcached_st*); test_return_t mget_read_result(memcached_st*); test_return_t mget_read_internal_result(memcached_st*); libmemcached-1.0.8/tests/libmemcached-1.0/touch.cc0000664000076400007640000001257411753573717022114 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * Copyright (C) 2011 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 #include using namespace libtest; #include #include #include "tests/touch.h" static test_return_t pre_touch(memcached_st *memc) { test_compare(MEMCACHED_SUCCESS, memcached_version(memc)); test_skip(true, libmemcached_util_version_check(memc, 1, 4, 8)); return TEST_SUCCESS; } test_return_t test_memcached_touch(memcached_st *memc) { test_skip(TEST_SUCCESS, pre_touch(memc)); size_t len; uint32_t flags; memcached_return rc; test_null(memcached_get(memc, test_literal_param(__func__), &len, &flags, &rc)); test_zero(len); test_compare(MEMCACHED_NOTFOUND, rc); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param(__func__), test_literal_param("touchval"), 2, 0)); { char *value= memcached_get(memc, test_literal_param(__func__), &len, &flags, &rc); test_compare(8U, test_literal_param_size("touchval")); test_true(value); test_strcmp(value, "touchval"); test_compare(MEMCACHED_SUCCESS, rc); free(value); } test_compare(MEMCACHED_SUCCESS, memcached_touch(memc, test_literal_param(__func__), 60 *60)); test_skip(false ,memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); rc= memcached_touch(memc, test_literal_param(__func__), 60 *60 *24 *60); test_compare_hint(MEMCACHED_SUCCESS, rc, memcached_last_error_message(memc)); test_compare(MEMCACHED_NOTFOUND, memcached_exist(memc, test_literal_param(__func__))); return TEST_SUCCESS; } test_return_t test_memcached_touch_by_key(memcached_st *memc) { test_skip(TEST_SUCCESS, pre_touch(memc)); size_t len; uint32_t flags; memcached_return rc; test_null(memcached_get_by_key(memc, test_literal_param("grouping_key"), test_literal_param(__func__), &len, &flags, &rc)); test_zero(len); test_compare(MEMCACHED_NOTFOUND, rc); test_compare(MEMCACHED_SUCCESS, memcached_set_by_key(memc, test_literal_param("grouping_key"), test_literal_param(__func__), test_literal_param("touchval"), 2, 0)); { char *value= memcached_get_by_key(memc, test_literal_param("grouping_key"), test_literal_param(__func__), &len, &flags, &rc); test_compare(8U, test_literal_param_size("touchval")); test_true(value); test_strcmp(value, "touchval"); test_compare(MEMCACHED_SUCCESS, rc); free(value); } test_compare(MEMCACHED_SUCCESS, memcached_touch_by_key(memc, test_literal_param("grouping_key"), test_literal_param(__func__), 60 *60)); test_skip(false ,memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); test_compare(MEMCACHED_SUCCESS, memcached_touch_by_key(memc, test_literal_param("grouping_key"), test_literal_param(__func__), 60 *60 *24 *60)); test_compare(MEMCACHED_NOTFOUND, memcached_exist_by_key(memc, test_literal_param("grouping_key"),test_literal_param(__func__))); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/all_tests.h0000664000076400007640000006355611753573717022634 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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. * */ #pragma once #include /* Clean the server before beginning testing */ test_st tests[] ={ {"util_version", true, (test_callback_fn*)util_version_test }, {"flush", false, (test_callback_fn*)flush_test }, {"init", false, (test_callback_fn*)init_test }, {"allocation", false, (test_callback_fn*)allocation_test }, {"server_list_null_test", false, (test_callback_fn*)server_list_null_test}, {"server_unsort", false, (test_callback_fn*)server_unsort_test}, {"server_sort", false, (test_callback_fn*)server_sort_test}, {"server_sort2", false, (test_callback_fn*)server_sort2_test}, {"memcached_server_remove", false, (test_callback_fn*)memcached_server_remove_test}, {"clone_test", false, (test_callback_fn*)clone_test }, {"connection_test", false, (test_callback_fn*)connection_test}, {"callback_test", false, (test_callback_fn*)callback_test}, {"userdata_test", false, (test_callback_fn*)userdata_test}, {"memcached_set()", false, (test_callback_fn*)set_test }, {"memcached_set() 2", false, (test_callback_fn*)set_test2 }, {"memcached_set() 3", false, (test_callback_fn*)set_test3 }, {"add", true, (test_callback_fn*)add_test }, {"memcached_fetch_result(MEMCACHED_NOTFOUND)", true, (test_callback_fn*)memcached_fetch_result_NOT_FOUND }, {"replace", true, (test_callback_fn*)replace_test }, {"delete", true, (test_callback_fn*)delete_test }, {"memcached_get()", true, (test_callback_fn*)get_test }, {"get2", false, (test_callback_fn*)get_test2 }, {"get3", false, (test_callback_fn*)get_test3 }, {"get4", false, (test_callback_fn*)get_test4 }, {"partial mget", false, (test_callback_fn*)get_test5 }, {"stats_servername", false, (test_callback_fn*)stats_servername_test }, {"increment", false, (test_callback_fn*)increment_test }, {"increment_with_initial", true, (test_callback_fn*)increment_with_initial_test }, {"decrement", false, (test_callback_fn*)decrement_test }, {"decrement_with_initial", true, (test_callback_fn*)decrement_with_initial_test }, {"increment_by_key", false, (test_callback_fn*)increment_by_key_test }, {"increment_with_initial_by_key", true, (test_callback_fn*)increment_with_initial_by_key_test }, {"decrement_by_key", false, (test_callback_fn*)decrement_by_key_test }, {"decrement_with_initial_by_key", true, (test_callback_fn*)decrement_with_initial_by_key_test }, {"binary_increment_with_prefix", true, (test_callback_fn*)binary_increment_with_prefix_test }, {"quit", false, (test_callback_fn*)quit_test }, {"mget", true, (test_callback_fn*)mget_test }, {"mget_result", true, (test_callback_fn*)mget_result_test }, {"mget_result_alloc", true, (test_callback_fn*)mget_result_alloc_test }, {"mget_result_function", true, (test_callback_fn*)mget_result_function }, {"mget_execute", true, (test_callback_fn*)mget_execute }, {"mget_end", false, (test_callback_fn*)mget_end }, {"get_stats", false, (test_callback_fn*)get_stats }, {"add_host_test", false, (test_callback_fn*)add_host_test }, {"add_host_test_1", false, (test_callback_fn*)add_host_test1 }, {"get_stats_keys", false, (test_callback_fn*)get_stats_keys }, {"version_string_test", true, (test_callback_fn*)version_string_test}, {"memcached_mget() mixed memcached_get()", true, (test_callback_fn*)memcached_mget_mixed_memcached_get_TEST}, {"bad_key", true, (test_callback_fn*)bad_key_test }, {"memcached_server_cursor", true, (test_callback_fn*)memcached_server_cursor_test }, {"read_through", true, (test_callback_fn*)read_through }, {"delete_through", true, (test_callback_fn*)test_MEMCACHED_CALLBACK_DELETE_TRIGGER }, {"noreply", true, (test_callback_fn*)noreply_test}, {"analyzer", true, (test_callback_fn*)analyzer_test}, {"memcached_pool_st", true, (test_callback_fn*)connection_pool_test }, {"memcached_pool_st #2", true, (test_callback_fn*)connection_pool2_test }, #if 0 {"memcached_pool_st #3", true, (test_callback_fn*)connection_pool3_test }, #endif {"memcached_pool_test", true, (test_callback_fn*)memcached_pool_test }, {"test_get_last_disconnect", true, (test_callback_fn*)test_get_last_disconnect}, {"verbosity", true, (test_callback_fn*)test_verbosity}, {"memcached_stat_execute", true, (test_callback_fn*)memcached_stat_execute_test}, {"memcached_exist(MEMCACHED_NOTFOUND)", true, (test_callback_fn*)memcached_exist_NOTFOUND }, {"memcached_exist(MEMCACHED_SUCCESS)", true, (test_callback_fn*)memcached_exist_SUCCESS }, {"memcached_exist_by_key(MEMCACHED_NOTFOUND)", true, (test_callback_fn*)memcached_exist_by_key_NOTFOUND }, {"memcached_exist_by_key(MEMCACHED_SUCCESS)", true, (test_callback_fn*)memcached_exist_by_key_SUCCESS }, {"memcached_touch", 0, (test_callback_fn*)test_memcached_touch}, {"memcached_touch_with_prefix", 0, (test_callback_fn*)test_memcached_touch_by_key}, #if 0 {"memcached_dump() no data", true, (test_callback_fn*)memcached_dump_TEST }, #endif {"memcached_dump() with data", true, (test_callback_fn*)memcached_dump_TEST2 }, {0, 0, 0} }; test_st touch_tests[] ={ {"memcached_touch", 0, (test_callback_fn*)test_memcached_touch}, {"memcached_touch_with_prefix", 0, (test_callback_fn*)test_memcached_touch_by_key}, {0, 0, 0} }; test_st kill_TESTS[] ={ {"kill(HUP)", 0, (test_callback_fn*)kill_HUP_TEST}, {0, 0, 0} }; test_st memcached_stat_tests[] ={ {"memcached_stat() INVALID ARG", 0, (test_callback_fn*)memcached_stat_TEST}, {"memcached_stat()", 0, (test_callback_fn*)memcached_stat_TEST2}, {0, 0, 0} }; test_st behavior_tests[] ={ {"libmemcached_string_behavior()", false, (test_callback_fn*)libmemcached_string_behavior_test}, {"libmemcached_string_distribution()", false, (test_callback_fn*)libmemcached_string_distribution_test}, {"behavior_test", false, (test_callback_fn*)behavior_test}, {"MEMCACHED_BEHAVIOR_CORK", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_CORK_test}, {"MEMCACHED_BEHAVIOR_TCP_KEEPALIVE", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test}, {"MEMCACHED_BEHAVIOR_TCP_KEEPIDLE", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test}, {"MEMCACHED_BEHAVIOR_POLL_TIMEOUT", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_POLL_TIMEOUT_test}, {"MEMCACHED_CALLBACK_DELETE_TRIGGER_and_MEMCACHED_BEHAVIOR_NOREPLY", false, (test_callback_fn*)test_MEMCACHED_CALLBACK_DELETE_TRIGGER_and_MEMCACHED_BEHAVIOR_NOREPLY}, {0, 0, 0} }; test_st libmemcachedutil_tests[] ={ {"libmemcached_util_ping()", true, (test_callback_fn*)ping_test }, {"libmemcached_util_getpid()", true, (test_callback_fn*)getpid_test }, {"libmemcached_util_getpid(MEMCACHED_CONNECTION_FAILURE)", true, (test_callback_fn*)getpid_connection_failure_test }, {0, 0, 0} }; test_st basic_tests[] ={ {"init", true, (test_callback_fn*)basic_init_test}, {"clone", true, (test_callback_fn*)basic_clone_test}, {"reset", true, (test_callback_fn*)basic_reset_stack_test}, {"reset heap", true, (test_callback_fn*)basic_reset_heap_test}, {"reset stack clone", true, (test_callback_fn*)basic_reset_stack_clone_test}, {"reset heap clone", true, (test_callback_fn*)basic_reset_heap_clone_test}, {"memcached_return_t", false, (test_callback_fn*)memcached_return_t_TEST }, {0, 0, 0} }; test_st regression_binary_vs_block[] ={ {"block add", true, (test_callback_fn*)block_add_regression}, {"binary add", true, (test_callback_fn*)binary_add_regression}, {0, 0, 0} }; test_st async_tests[] ={ {"add", true, (test_callback_fn*)add_wrapper }, {0, 0, 0} }; test_st memcached_server_get_last_disconnect_tests[] ={ {"memcached_server_get_last_disconnect()", false, (test_callback_fn*)test_multiple_get_last_disconnect}, {0, 0, (test_callback_fn*)0} }; test_st result_tests[] ={ {"result static", false, (test_callback_fn*)result_static}, {"result alloc", false, (test_callback_fn*)result_alloc}, {0, 0, (test_callback_fn*)0} }; test_st version_1_2_3[] ={ {"append", false, (test_callback_fn*)append_test }, {"prepend", false, (test_callback_fn*)prepend_test }, {"cas", false, (test_callback_fn*)cas_test }, {"cas2", false, (test_callback_fn*)cas2_test }, {"append_binary", false, (test_callback_fn*)append_binary_test }, {0, 0, (test_callback_fn*)0} }; test_st haldenbrand_TESTS[] ={ {"memcached_set", false, (test_callback_fn*)haldenbrand_TEST1 }, {"memcached_get()", false, (test_callback_fn*)haldenbrand_TEST2 }, {"memcached_mget()", false, (test_callback_fn*)haldenbrand_TEST3 }, {0, 0, (test_callback_fn*)0} }; test_st user_tests[] ={ {"user_supplied_bug4", true, (test_callback_fn*)user_supplied_bug4 }, {"user_supplied_bug5", true, (test_callback_fn*)user_supplied_bug5 }, {"user_supplied_bug6", true, (test_callback_fn*)user_supplied_bug6 }, {"user_supplied_bug7", true, (test_callback_fn*)user_supplied_bug7 }, {"user_supplied_bug8", true, (test_callback_fn*)user_supplied_bug8 }, {"user_supplied_bug9", true, (test_callback_fn*)user_supplied_bug9 }, {"user_supplied_bug10", true, (test_callback_fn*)user_supplied_bug10 }, {"user_supplied_bug11", true, (test_callback_fn*)user_supplied_bug11 }, {"user_supplied_bug12", true, (test_callback_fn*)user_supplied_bug12 }, {"user_supplied_bug13", true, (test_callback_fn*)user_supplied_bug13 }, {"user_supplied_bug14", true, (test_callback_fn*)user_supplied_bug14 }, {"user_supplied_bug15", true, (test_callback_fn*)user_supplied_bug15 }, {"user_supplied_bug16", true, (test_callback_fn*)user_supplied_bug16 }, #if !defined(__sun) && !defined(__OpenBSD__) /* ** It seems to be something weird with the character sets.. ** value_fetch is unable to parse the value line (iscntrl "fails"), so I ** guess I need to find out how this is supposed to work.. Perhaps I need ** to run the test in a specific locale (I tried zh_CN.UTF-8 without success, ** so just disable the code for now...). */ {"user_supplied_bug17", true, (test_callback_fn*)user_supplied_bug17 }, #endif {"user_supplied_bug18", true, (test_callback_fn*)user_supplied_bug18 }, {"user_supplied_bug19", true, (test_callback_fn*)user_supplied_bug19 }, {"user_supplied_bug20", true, (test_callback_fn*)user_supplied_bug20 }, {"user_supplied_bug21", true, (test_callback_fn*)user_supplied_bug21 }, {"wrong_failure_counter_test", true, (test_callback_fn*)wrong_failure_counter_test}, {"wrong_failure_counter_two_test", true, (test_callback_fn*)wrong_failure_counter_two_test}, {0, 0, (test_callback_fn*)0} }; test_st replication_tests[]= { {"validate replication setup", true, (test_callback_fn*)check_replication_sanity_TEST }, {"set", true, (test_callback_fn*)replication_set_test }, {"get", false, (test_callback_fn*)replication_get_test }, {"mget", false, (test_callback_fn*)replication_mget_test }, {"delete", true, (test_callback_fn*)replication_delete_test }, {"rand_mget", false, (test_callback_fn*)replication_randomize_mget_test }, {"miss", false, (test_callback_fn*)replication_miss_test }, {"fail", false, (test_callback_fn*)replication_randomize_mget_fail_test }, {0, 0, (test_callback_fn*)0} }; /* * The following test suite is used to verify that we don't introduce * regression bugs. If you want more information about the bug / test, * you should look in the bug report at * http://bugs.launchpad.net/libmemcached */ test_st regression_tests[]= { {"lp:434484", true, (test_callback_fn*)regression_bug_434484 }, {"lp:434843", true, (test_callback_fn*)regression_bug_434843 }, {"lp:434843-buffered", true, (test_callback_fn*)regression_bug_434843_buffered }, {"lp:421108", true, (test_callback_fn*)regression_bug_421108 }, {"lp:442914", true, (test_callback_fn*)regression_bug_442914 }, {"lp:447342", true, (test_callback_fn*)regression_bug_447342 }, {"lp:463297", true, (test_callback_fn*)regression_bug_463297 }, {"lp:490486", true, (test_callback_fn*)regression_bug_490486 }, {"lp:583031", true, (test_callback_fn*)regression_bug_583031 }, {"lp:?", true, (test_callback_fn*)regression_bug_ }, {"lp:728286", true, (test_callback_fn*)regression_bug_728286 }, {"lp:581030", true, (test_callback_fn*)regression_bug_581030 }, {"lp:71231153 connect()", true, (test_callback_fn*)regression_bug_71231153_connect }, {"lp:71231153 poll()", true, (test_callback_fn*)regression_bug_71231153_poll }, {"lp:655423", true, (test_callback_fn*)regression_bug_655423 }, {"lp:490520", true, (test_callback_fn*)regression_bug_490520 }, {"lp:854604", true, (test_callback_fn*)regression_bug_854604 }, {"lp:996813", true, (test_callback_fn*)regression_996813_TEST }, {"lp:994772", true, (test_callback_fn*)regression_994772_TEST }, {0, false, (test_callback_fn*)0} }; test_st ketama_compatibility[]= { {"libmemcached", true, (test_callback_fn*)ketama_compatibility_libmemcached }, {"spymemcached", true, (test_callback_fn*)ketama_compatibility_spymemcached }, {0, 0, (test_callback_fn*)0} }; test_st generate_tests[] ={ {"generate_data", true, (test_callback_fn*)generate_data }, {"get_read", false, (test_callback_fn*)get_read }, {"delete_generate", false, (test_callback_fn*)delete_generate }, {"cleanup", true, (test_callback_fn*)cleanup_pairs }, {0, 0, (test_callback_fn*)0} }; // New start test_st generate_mget_TESTS[] ={ {"generate_data", true, (test_callback_fn*)generate_data }, {"mget_read", false, (test_callback_fn*)mget_read }, {"mget_read_result", false, (test_callback_fn*)mget_read_result }, {"memcached_fetch_result() use internal result", false, (test_callback_fn*)mget_read_internal_result }, {"memcached_fetch_result() partial read", false, (test_callback_fn*)mget_read_partial_result }, {"mget_read_function", false, (test_callback_fn*)mget_read_function }, {"cleanup", true, (test_callback_fn*)cleanup_pairs }, {0, 0, (test_callback_fn*)0} }; test_st generate_large_TESTS[] ={ {"generate_large_pairs", true, (test_callback_fn*)generate_large_pairs }, {"cleanup", true, (test_callback_fn*)cleanup_pairs }, {0, 0, (test_callback_fn*)0} }; test_st consistent_tests[] ={ {"generate_data", true, (test_callback_fn*)generate_data }, {"get_read", 0, (test_callback_fn*)get_read_count }, {"cleanup", true, (test_callback_fn*)cleanup_pairs }, {0, 0, (test_callback_fn*)0} }; test_st consistent_weighted_tests[] ={ {"generate_data", true, (test_callback_fn*)generate_data_with_stats }, {"get_read", false, (test_callback_fn*)get_read_count }, {"cleanup", true, (test_callback_fn*)cleanup_pairs }, {0, 0, (test_callback_fn*)0} }; test_st hsieh_availability[] ={ {"hsieh_avaibility_test", false, (test_callback_fn*)hsieh_avaibility_test}, {0, 0, (test_callback_fn*)0} }; test_st murmur_availability[] ={ {"murmur_avaibility_test", false, (test_callback_fn*)murmur_avaibility_test}, {0, 0, (test_callback_fn*)0} }; #if 0 test_st hash_sanity[] ={ {"hash sanity", 0, (test_callback_fn*)hash_sanity_test}, {0, 0, (test_callback_fn*)0} }; #endif test_st ketama_auto_eject_hosts[] ={ {"auto_eject_hosts", true, (test_callback_fn*)auto_eject_hosts }, {"output_ketama_weighted_keys", true, (test_callback_fn*)output_ketama_weighted_keys }, {0, 0, (test_callback_fn*)0} }; test_st hash_tests[] ={ {"one_at_a_time_run", false, (test_callback_fn*)one_at_a_time_run }, {"md5", false, (test_callback_fn*)md5_run }, {"crc", false, (test_callback_fn*)crc_run }, {"fnv1_64", false, (test_callback_fn*)fnv1_64_run }, {"fnv1a_64", false, (test_callback_fn*)fnv1a_64_run }, {"fnv1_32", false, (test_callback_fn*)fnv1_32_run }, {"fnv1a_32", false, (test_callback_fn*)fnv1a_32_run }, {"hsieh", false, (test_callback_fn*)hsieh_run }, {"murmur", false, (test_callback_fn*)murmur_run }, {"jenkis", false, (test_callback_fn*)jenkins_run }, {"memcached_get_hashkit", false, (test_callback_fn*)memcached_get_hashkit_test }, {0, 0, (test_callback_fn*)0} }; test_st error_conditions[] ={ {"memcached_get(MEMCACHED_ERRNO)", false, (test_callback_fn*)memcached_get_MEMCACHED_ERRNO }, {"memcached_get(MEMCACHED_NOTFOUND)", false, (test_callback_fn*)memcached_get_MEMCACHED_NOTFOUND }, {"memcached_get_by_key(MEMCACHED_ERRNO)", false, (test_callback_fn*)memcached_get_by_key_MEMCACHED_ERRNO }, {"memcached_get_by_key(MEMCACHED_NOTFOUND)", false, (test_callback_fn*)memcached_get_by_key_MEMCACHED_NOTFOUND }, {"memcached_get_by_key(MEMCACHED_NOTFOUND)", false, (test_callback_fn*)memcached_get_by_key_MEMCACHED_NOTFOUND }, {"memcached_increment(MEMCACHED_NO_SERVERS)", false, (test_callback_fn*)memcached_increment_MEMCACHED_NO_SERVERS }, {0, 0, (test_callback_fn*)0} }; test_st parser_tests[] ={ {"behavior", false, (test_callback_fn*)behavior_parser_test }, {"boolean_options", false, (test_callback_fn*)parser_boolean_options_test }, {"configure_file", false, (test_callback_fn*)memcached_create_with_options_with_filename }, {"distribtions", false, (test_callback_fn*)parser_distribution_test }, {"hash", false, (test_callback_fn*)parser_hash_test }, {"libmemcached_check_configuration", false, (test_callback_fn*)libmemcached_check_configuration_test }, {"libmemcached_check_configuration_with_filename", false, (test_callback_fn*)libmemcached_check_configuration_with_filename_test }, {"number_options", false, (test_callback_fn*)parser_number_options_test }, {"randomly generated options", false, (test_callback_fn*)random_statement_build_test }, {"namespace", false, (test_callback_fn*)parser_key_prefix_test }, {"server", false, (test_callback_fn*)server_test }, {"bad server strings", false, (test_callback_fn*)servers_bad_test }, {"server with weights", false, (test_callback_fn*)server_with_weight_test }, {"parsing servername, port, and weight", false, (test_callback_fn*)test_hostname_port_weight }, {"--socket=", false, (test_callback_fn*)test_parse_socket }, {"--namespace=", false, (test_callback_fn*)test_namespace_keyword }, {0, 0, (test_callback_fn*)0} }; test_st virtual_bucket_tests[] ={ {"basic", false, (test_callback_fn*)virtual_back_map }, {0, 0, (test_callback_fn*)0} }; test_st memcached_server_add_tests[] ={ {"memcached_server_add(\"\")", false, (test_callback_fn*)memcached_server_add_empty_test }, {"memcached_server_add(NULL)", false, (test_callback_fn*)memcached_server_add_null_test }, {0, 0, (test_callback_fn*)0} }; test_st pool_TESTS[] ={ {"lp:962815", true, (test_callback_fn*)regression_bug_962815 }, {0, 0, (test_callback_fn*)0} }; test_st memcached_set_encoding_key_TESTS[] ={ {"memcached_set_encoding_key()", true, (test_callback_fn*)memcached_set_encoding_key_TEST }, {"memcached_set_encoding_key() +set() + get()", true, (test_callback_fn*)memcached_set_encoding_key_set_get_TEST }, {"memcached_set_encoding_key() +add() + get()", true, (test_callback_fn*)memcached_set_encoding_key_add_get_TEST }, {"memcached_set_encoding_key() +replace() + get()", true, (test_callback_fn*)memcached_set_encoding_key_replace_get_TEST }, {"memcached_set_encoding_key() +prepend()", true, (test_callback_fn*)memcached_set_encoding_key_prepend_TEST }, {"memcached_set_encoding_key() +append()", true, (test_callback_fn*)memcached_set_encoding_key_append_TEST }, {"memcached_set_encoding_key() +increment()", true, (test_callback_fn*)memcached_set_encoding_key_increment_TEST }, {"memcached_set_encoding_key() +decrement()", true, (test_callback_fn*)memcached_set_encoding_key_increment_TEST }, {"memcached_set_encoding_key() +increment_with_initial()", true, (test_callback_fn*)memcached_set_encoding_key_increment_with_initial_TEST }, {"memcached_set_encoding_key() +decrement_with_initial()", true, (test_callback_fn*)memcached_set_encoding_key_decrement_with_initial_TEST }, {"memcached_set_encoding_key() +set() +get() +cloen()", true, (test_callback_fn*)memcached_set_encoding_key_set_get_clone_TEST }, {"memcached_set_encoding_key() +set() +get() increase value size", true, (test_callback_fn*)memcached_set_encoding_key_set_grow_key_TEST }, {0, 0, (test_callback_fn*)0} }; test_st namespace_tests[] ={ {"basic tests", true, (test_callback_fn*)selection_of_namespace_tests }, {"increment", true, (test_callback_fn*)memcached_increment_namespace }, {0, 0, (test_callback_fn*)0} }; collection_st collection[] ={ #if 0 {"hash_sanity", 0, 0, hash_sanity}, #endif {"libmemcachedutil", 0, 0, libmemcachedutil_tests}, {"basic", 0, 0, basic_tests}, {"hsieh_availability", 0, 0, hsieh_availability}, {"murmur_availability", 0, 0, murmur_availability}, {"memcached_server_add", 0, 0, memcached_server_add_tests}, {"block", 0, 0, tests}, {"binary", (test_callback_fn*)pre_binary, 0, tests}, {"nonblock", (test_callback_fn*)pre_nonblock, 0, tests}, {"nodelay", (test_callback_fn*)pre_nodelay, 0, tests}, {"settimer", (test_callback_fn*)pre_settimer, 0, tests}, {"md5", (test_callback_fn*)pre_md5, 0, tests}, {"crc", (test_callback_fn*)pre_crc, 0, tests}, {"hsieh", (test_callback_fn*)pre_hsieh, 0, tests}, {"jenkins", (test_callback_fn*)pre_jenkins, 0, tests}, {"fnv1_64", (test_callback_fn*)pre_hash_fnv1_64, 0, tests}, {"fnv1a_64", (test_callback_fn*)pre_hash_fnv1a_64, 0, tests}, {"fnv1_32", (test_callback_fn*)pre_hash_fnv1_32, 0, tests}, {"fnv1a_32", (test_callback_fn*)pre_hash_fnv1a_32, 0, tests}, {"ketama", (test_callback_fn*)pre_behavior_ketama, 0, tests}, {"ketama_auto_eject_hosts", (test_callback_fn*)pre_behavior_ketama, 0, ketama_auto_eject_hosts}, {"unix_socket", (test_callback_fn*)pre_unix_socket, 0, tests}, {"unix_socket_nodelay", (test_callback_fn*)pre_nodelay, 0, tests}, {"gets", (test_callback_fn*)enable_cas, 0, tests}, {"consistent_crc", (test_callback_fn*)enable_consistent_crc, 0, tests}, {"consistent_hsieh", (test_callback_fn*)enable_consistent_hsieh, 0, tests}, #ifdef MEMCACHED_ENABLE_DEPRECATED {"deprecated_memory_allocators", (test_callback_fn*)deprecated_set_memory_alloc, 0, tests}, #endif {"memory_allocators", (test_callback_fn*)set_memory_alloc, 0, tests}, {"namespace", (test_callback_fn*)set_namespace, 0, tests}, {"namespace(BINARY)", (test_callback_fn*)set_namespace_and_binary, 0, tests}, {"specific namespace", 0, 0, namespace_tests}, {"specific namespace(BINARY)", (test_callback_fn*)pre_binary, 0, namespace_tests}, {"version_1_2_3", (test_callback_fn*)check_for_1_2_3, 0, version_1_2_3}, {"result", 0, 0, result_tests}, {"async", (test_callback_fn*)pre_nonblock, 0, async_tests}, {"async(BINARY)", (test_callback_fn*)pre_nonblock_binary, 0, async_tests}, {"Cal Haldenbrand's tests", 0, 0, haldenbrand_TESTS}, {"user written tests", 0, 0, user_tests}, {"generate", 0, 0, generate_tests}, {"generate MEMCACHED_BEHAVIOR_BUFFER_REQUESTS", (test_callback_fn*)pre_buffer, 0, generate_tests}, {"mget generate MEMCACHED_BEHAVIOR_BUFFER_REQUESTS", (test_callback_fn*)pre_buffer, 0, generate_mget_TESTS}, {"generate large", 0, 0, generate_large_TESTS}, {"generate_hsieh", (test_callback_fn*)pre_hsieh, 0, generate_tests}, {"generate_ketama", (test_callback_fn*)pre_behavior_ketama, 0, generate_tests}, {"generate_hsieh_consistent", (test_callback_fn*)enable_consistent_hsieh, 0, generate_tests}, {"generate_md5", (test_callback_fn*)pre_md5, 0, generate_tests}, {"generate_murmur", (test_callback_fn*)pre_murmur, 0, generate_tests}, {"generate_jenkins", (test_callback_fn*)pre_jenkins, 0, generate_tests}, {"generate_nonblock", (test_callback_fn*)pre_nonblock, 0, generate_tests}, {"mget generate_nonblock", (test_callback_fn*)pre_nonblock, 0, generate_mget_TESTS}, {"consistent_not", 0, 0, consistent_tests}, {"consistent_ketama", (test_callback_fn*)pre_behavior_ketama, 0, consistent_tests}, {"consistent_ketama_weighted", (test_callback_fn*)pre_behavior_ketama_weighted, 0, consistent_weighted_tests}, {"ketama_compat", 0, 0, ketama_compatibility}, {"test_hashes", 0, 0, hash_tests}, {"replication", (test_callback_fn*)pre_replication, 0, replication_tests}, {"replication_noblock", (test_callback_fn*)pre_replication_noblock, 0, replication_tests}, {"regression", 0, 0, regression_tests}, {"behaviors", 0, 0, behavior_tests}, {"regression_binary_vs_block", (test_callback_fn*)key_setup, (test_callback_fn*)key_teardown, regression_binary_vs_block}, {"error_conditions", 0, 0, error_conditions}, {"parser", 0, 0, parser_tests}, {"virtual buckets", 0, 0, virtual_bucket_tests}, {"memcached_server_get_last_disconnect", 0, 0, memcached_server_get_last_disconnect_tests}, {"touch", 0, 0, touch_tests}, {"touch", (test_callback_fn*)pre_binary, 0, touch_tests}, {"memcached_stat()", 0, 0, memcached_stat_tests}, {"memcached_pool_create()", 0, 0, pool_TESTS}, {"memcached_set_encoding_key()", 0, 0, memcached_set_encoding_key_TESTS}, {"kill()", 0, 0, kill_TESTS}, {0, 0, 0, 0} }; libmemcached-1.0.8/tests/libmemcached-1.0/namespace.cc0000664000076400007640000000767011753573717022727 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * Copyright (C) 2011 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 #include using namespace libtest; #include #include test_return_t memcached_increment_namespace(memcached_st *memc) { uint64_t new_number; test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("number"), test_literal_param("0"), (time_t)0, (uint32_t)0)); test_compare(MEMCACHED_SUCCESS, memcached_increment(memc, test_literal_param("number"), 1, &new_number)); test_compare(uint64_t(1), new_number); test_compare(MEMCACHED_SUCCESS, memcached_increment(memc, test_literal_param("number"), 1, &new_number)); test_compare(uint64_t(2), new_number); memcached_st *clone= memcached_clone(NULL, memc); test_compare(MEMCACHED_SUCCESS, memcached_callback_set(clone, MEMCACHED_CALLBACK_NAMESPACE, "all_your_bases")); test_compare(MEMCACHED_NOTFOUND, memcached_increment(clone, test_literal_param("number"), 1, &new_number)); test_compare(MEMCACHED_SUCCESS, memcached_add(clone, test_literal_param("number"), test_literal_param("10"), (time_t)0, (uint32_t)0)); char *value= memcached_get(clone, test_literal_param("number"), 0, 0, 0); test_true(value); test_compare(2UL, strlen(value)); test_strcmp("10", value); free(value); test_compare(MEMCACHED_SUCCESS, memcached_increment(clone, test_literal_param("number"), 1, &new_number)); test_compare(uint64_t(11), new_number); test_compare(MEMCACHED_SUCCESS, memcached_increment(memc, test_literal_param("number"), 1, &new_number)); test_compare(uint64_t(3), new_number); memcached_free(clone); return TEST_SUCCESS; } libmemcached-1.0.8/tests/libmemcached-1.0/atomsmasher.cc0000664000076400007640000001511011753763014023271 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ /* Sample test application. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "tests/libmemcached-1.0/generate.h" using namespace libtest; /* Number of items generated for tests */ #define GLOBAL_COUNT 100000 /* Number of times to run the test loop */ #define TEST_COUNTER 500000 static pairs_st *global_pairs; static char *global_keys[GLOBAL_COUNT]; static size_t global_keys_length[GLOBAL_COUNT]; static test_return_t cleanup_pairs_TEST(memcached_st *) { pairs_free(global_pairs); return TEST_SUCCESS; } static test_return_t generate_pairs_TEST(memcached_st *) { global_pairs= pairs_generate(GLOBAL_COUNT, 400); for (ptrdiff_t x= 0; x < GLOBAL_COUNT; x++) { global_keys[x]= global_pairs[x].key; global_keys_length[x]= global_pairs[x].key_length; } return TEST_SUCCESS; } static test_return_t drizzle_TEST(memcached_st *memc) { infinite: for (ptrdiff_t x= 0; x < TEST_COUNTER; x++) { memcached_return_t rc; uint32_t test_bit= (uint32_t)(random() % GLOBAL_COUNT); uint8_t which= (uint8_t)(random() % 2); if (which == 0) { size_t return_value_length; uint32_t flags; char* return_value= memcached_get(memc, global_keys[test_bit], global_keys_length[test_bit], &return_value_length, &flags, &rc); if (rc == MEMCACHED_SUCCESS && return_value) { free(return_value); } else if (rc == MEMCACHED_NOTFOUND) { continue; } else { test_compare(MEMCACHED_SUCCESS, rc); } } else { rc= memcached_set(memc, global_pairs[test_bit].key, global_pairs[test_bit].key_length, global_pairs[test_bit].value, global_pairs[test_bit].value_length, 0, 0); if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_BUFFERED) { test_compare(MEMCACHED_SUCCESS, rc); } } } if (getenv("MEMCACHED_ATOM_BURIN_IN")) { goto infinite; } return TEST_SUCCESS; } static test_return_t pre_nonblock(memcached_st *memc) { test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0)); return TEST_SUCCESS; } /* Set the value, then quit to make sure it is flushed. Come back in and test that add fails. */ static test_return_t add_test(memcached_st *memc) { const char *key= "foo"; const char *value= "when we sanitize"; memcached_return_t rc= memcached_set(memc, key, strlen(key), value, strlen(value), time_t(0), uint32_t(0)); test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc)); memcached_quit(memc); rc= memcached_add(memc, key, strlen(key), value, strlen(value), (time_t)0, (uint32_t)0); if (rc == MEMCACHED_CONNECTION_FAILURE) { print_servers(memc); } /* Too many broken OS'es have broken loopback in async, so we can't be sure of the result */ if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NO_BLOCK)) { test_true(rc == MEMCACHED_NOTSTORED or rc == MEMCACHED_STORED); } else { test_compare_got(MEMCACHED_NOTSTORED, rc, memcached_strerror(NULL, rc)); } return TEST_SUCCESS; } /* * repeating add_tests many times * may show a problem in timing */ static test_return_t many_adds(memcached_st *memc) { test_true(memc); for (ptrdiff_t x= 0; x < TEST_COUNTER; x++) { test_compare_got(TEST_SUCCESS, add_test(memc), x); } return TEST_SUCCESS; } test_st smash_tests[] ={ {"generate_pairs", true, (test_callback_fn*)generate_pairs_TEST }, {"drizzle", true, (test_callback_fn*)drizzle_TEST }, {"cleanup", true, (test_callback_fn*)cleanup_pairs_TEST }, {"many_adds", true, (test_callback_fn*)many_adds }, {0, 0, 0} }; #define BENCHMARK_TEST_LOOP 20000 struct benchmark_state_st { bool create_init; bool clone_init; memcached_st *create; memcached_st *clone; } benchmark_state; static test_return_t memcached_create_benchmark(memcached_st *) { benchmark_state.create_init= true; for (ptrdiff_t x= 0; x < BENCHMARK_TEST_LOOP; x++) { memcached_st *ptr= memcached_create(&benchmark_state.create[x]); test_true(ptr); } return TEST_SUCCESS; } static test_return_t memcached_clone_benchmark(memcached_st *memc) { benchmark_state.clone_init= true; for (ptrdiff_t x= 0; x < BENCHMARK_TEST_LOOP; x++) { memcached_st *ptr= memcached_clone(&benchmark_state.clone[x], memc); test_true(ptr); } return TEST_SUCCESS; } static test_return_t pre_allocate(memcached_st *) { memset(&benchmark_state, 0, sizeof(benchmark_state)); benchmark_state.create= (memcached_st *)calloc(BENCHMARK_TEST_LOOP, sizeof(memcached_st)); test_true(benchmark_state.create); benchmark_state.clone= (memcached_st *)calloc(BENCHMARK_TEST_LOOP, sizeof(memcached_st)); test_true(benchmark_state.clone); return TEST_SUCCESS; } static test_return_t post_allocate(memcached_st *) { for (ptrdiff_t x= 0; x < BENCHMARK_TEST_LOOP; x++) { if (benchmark_state.create_init) { memcached_free(&benchmark_state.create[x]); } if (benchmark_state.clone_init) { memcached_free(&benchmark_state.clone[x]); } } free(benchmark_state.create); free(benchmark_state.clone); return TEST_SUCCESS; } test_st micro_tests[] ={ {"memcached_create", 1, (test_callback_fn*)memcached_create_benchmark }, {"memcached_clone", 1, (test_callback_fn*)memcached_clone_benchmark }, {0, 0, 0} }; collection_st collection[] ={ {"smash", 0, 0, smash_tests}, {"smash_nonblock", (test_callback_fn*)pre_nonblock, 0, smash_tests}, {"micro-benchmark", (test_callback_fn*)pre_allocate, (test_callback_fn*)post_allocate, micro_tests}, {0, 0, 0, 0} }; #include "tests/libmemcached_world.h" void get_world(Framework *world) { world->collections(collection); world->create((test_callback_create_fn*)world_create); world->destroy((test_callback_destroy_fn*)world_destroy); world->set_runner(new LibmemcachedRunner); } libmemcached-1.0.8/tests/touch.h0000664000076400007640000000341211753573717017054 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached * * Copyright (C) 2011 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. * */ #pragma once test_return_t test_memcached_touch(memcached_st *); test_return_t test_memcached_touch_by_key(memcached_st *); libmemcached-1.0.8/tests/memerror.cc0000664000076400007640000000644011753763014017713 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Test memerror * * Copyright (C) 2011 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. * */ /* Test that we are cycling the servers we are creating during testing. */ #include #include #include using namespace libtest; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif static std::string executable("./clients/memerror"); static test_return_t help_TEST(void *) { const char *args[]= { "--help", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t version_TEST(void *) { const char *args[]= { "--version", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t error_test(void *) { const char *args[]= { "memcached_success", 0 }; test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t SUCCESS_TEST(void *) { const char *args[]= { "0", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t bad_input_test(void *) { const char *args[]= { "bad input", 0 }; test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } test_st memerror_tests[] ={ {"--help", 0, help_TEST}, {"--version", 0, version_TEST}, {"", 0, error_test}, {"0", 0, SUCCESS_TEST}, {"", 0, bad_input_test}, {0, 0, 0} }; collection_st collection[] ={ {"memerror", 0, 0, memerror_tests }, {0, 0, 0, 0} }; static void *world_create(server_startup_st&, test_return_t&) { return NULL; } void get_world(Framework *world) { world->collections(collection); world->create(world_create); } libmemcached-1.0.8/tests/ketama_test_cases_spy.h0000664000076400007640000001415311753573717022310 0ustar00brianbrian00000000000000/* * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ #pragma once static struct { const char *key; unsigned long hash1; unsigned long hash2; const char *server; } ketama_test_cases_spy[99]= { { "SVa_]_V41)", 443691461UL, 445379617UL, "10.0.1.2" }, { "*/Z;?V(.\\8", 1422915503UL, 1428303028UL, "10.0.1.4" }, { "30C1*Z*S/_", 1473165754UL, 1480075959UL, "10.0.1.2" }, { "ERR:EC58G>", 2148406511UL, 2168579133UL, "10.0.1.7" }, { "1I=cTMNTKF", 2882686667UL, 2885206587UL, "10.0.1.4" }, { "]VG<`I*Z8)", 1103544263UL, 1104827657UL, "10.0.1.5" }, { "UUTC`-V159", 3716288206UL, 3727224240UL, "10.0.1.7" }, { "@7RU6C6T+Z", 3862737685UL, 3871917949UL, "10.0.1.6" }, { "/XLN0@+36;", 1623269830UL, 1627683651UL, "10.0.1.7" }, { "4(`X;\\V.^c", 373546328UL, 383925769UL, "10.0.1.6" }, { "726bW=9*a4", 4213440020UL, 4213950705UL, "10.0.1.3" }, { "\\`)32", 536016577UL, 539988520UL, "10.0.1.7" }, { "U))Fb-(`,.", 4128682289UL, 4136854163UL, "10.0.1.7" }, { "R-08RNTaRT", 3718170086UL, 3727224240UL, "10.0.1.5" }, { "(LHcO203I3", 1007779411UL, 1014643570UL, "10.0.1.1" }, { "=256P+;Qc8", 3976201210UL, 3976304873UL, "10.0.1.3" }, { "OI5XZ_BBT(", 2155922164UL, 2168579133UL, "10.0.1.5" }, { "2TLRL/UL;:", 1086800909UL, 1095659802UL, "10.0.1.2" }, { "WHD\\O1`ZRW", 3087923411UL, 3095471560UL, "10.0.1.1" }, { ".=54)_c;=T", 2497691631UL, 2502731301UL, "10.0.1.6" }, { ";GE`)FT\\4", 580747448UL, 581063326UL, "10.0.1.5" }, { "HZAU*;P*N]", 2564670474UL, 2565697267UL, "10.0.1.1" }, { "NZ@ZE=O84_", 533335275UL, 539988520UL, "10.0.1.7" }, { "6,cEI`F_P>", 3972869246UL, 3974773167UL, "10.0.1.3" }, { "c,5AQ/T5)6", 2835605783UL, 2847870057UL, "10.0.1.7" }, { ".O,>>BT)RX", 3857978174UL, 3871917949UL, "10.0.1.7" }, { "XY\\X::LX50", 1749241099UL, 1752196488UL, "10.0.1.7" }, { "+550F^/.01", 3781824099UL, 3783248219UL, "10.0.1.2" }, { "<.X9E2S5+9", 3232479481UL, 3234387706UL, "10.0.1.7" }, { "]\\.UH8_0a1", 2419699252UL, 2423002920UL, "10.0.1.6" }, { "8(6=(T0/Z0", 728266737UL, 729026070UL, "10.0.1.6" }, { "8*6a;Sc*X+", 4223431086UL, 4230156966UL, "10.0.1.5" }, { "J5/", 2776949824UL, 2784182515UL, "10.0.1.6" }, { "[>RZHG97Q9", 71954686UL, 72034069UL, "10.0.1.4" }, { "J3/G[)9<^Z", 2799896459UL, 2805183696UL, "10.0.1.6" }, { "N-)88>[O`,", 50404102UL, 51792557UL, "10.0.1.2" }, { "NP:=FR\\OaA", 3837333776UL, 3837792034UL, "10.0.1.7" }, { "`@L+W;a,O[", 1512157148UL, 1522285852UL, "10.0.1.5" }, { "W2`P:-+1T[", 2945171975UL, 2946196424UL, "10.0.1.7" }, { "-6G7K^YDIN", 3168617340UL, 3170513015UL, "10.0.1.5" }, { "U>*>9ZI6V5", 668514946UL, 674097631UL, "10.0.1.5" }, { ".I?^6Ic9RK", 938419020UL, 942832691UL, "10.0.1.6" }, { "0OZH^9BKM[", 3682518606UL, 3686781297UL, "10.0.1.2" }, { "5?50UGZ:ML", 868610882UL, 869425986UL, "10.0.1.6" }, { "?K2NF@3=IU", 381218851UL, 383925769UL, "10.0.1.6" }, { "YI@G-2X?UB", 3688706179UL, 3693197681UL, "10.0.1.6" }, { "7cY", 2590140172UL, 2598117636UL, "10.0.1.5" }, { "\\[a\\^=V_M0", 689410119UL, 698690782UL, "10.0.1.7" }, { "7;RM+8J9YC", 1530175299UL, 1531107082UL, "10.0.1.7" }, { "4*=.SPR[AV", 3928582722UL, 3928853792UL, "10.0.1.3" }, { "-2F+^88P4U", 3023552752UL, 3025823613UL, "10.0.1.7" }, { "X;-F`(N?9D", 570465234UL, 572485994UL, "10.0.1.5" }, { "R=F_D-K2a]", 1287750228UL, 1290935562UL, "10.0.1.1" }, { "X*+2aaC.EG", 3200948713UL, 3201088518UL, "10.0.1.3" }, { "[1ZXONX2]a", 4108881567UL, 4109865744UL, "10.0.1.7" }, { "FL;\\GWacaV", 458449508UL, 467374054UL, "10.0.1.7" }, { "\\MQ_XNT7L-", 1259349383UL, 1259509450UL, "10.0.1.5" }, { "VD6D0]ba_\\", 3842502950UL, 3842588691UL, "10.0.1.7" }, }; libmemcached-1.0.8/tests/libmemcached_world_socket.h0000664000076400007640000000542511753573717023114 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #include #include "tests/libmemcached_test_container.h" static void *world_create(libtest::server_startup_st& servers, test_return_t& error) { if (HAVE_MEMCACHED_BINARY == 0) { error= TEST_SKIPPED; return NULL; } for (uint32_t x= 0; x < servers.servers_to_run(); x++) { const char *argv[1]= { "memcached" }; if (servers.start_socket_server("memcached", libtest::get_free_port(), 1, argv) == false) { fatal_message("Could not launch memcached"); } } libmemcached_test_container_st *global_container= new libmemcached_test_container_st(servers); error= TEST_SUCCESS; return global_container; } static bool world_destroy(void *object) { libmemcached_test_container_st *container= (libmemcached_test_container_st *)object; #if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT if (LIBMEMCACHED_WITH_SASL_SUPPORT) { sasl_done(); } #endif delete container; return TEST_SUCCESS; } typedef test_return_t (*libmemcached_test_callback_fn)(memcached_st *); #include "tests/runner.h" libmemcached-1.0.8/tests/cpp_example.cc0000664000076400007640000000703611753573717020373 0ustar00brianbrian00000000000000/* * An example file showing the usage of the C++ libmemcached interface. */ #include #include #include #include #include #include #include #include using namespace std; using namespace memcache; class DeletePtrs { public: template inline void operator()(const T *ptr) const { delete ptr; } }; class MyCache { public: static const uint32_t num_of_clients= 10; static MyCache &singleton() { static MyCache instance; return instance; } void set(const string &key, const vector &value) { time_t expiry= 0; uint32_t flags= 0; getCache()->set(key, value, expiry, flags); } vector get(const string &key) { vector ret_value; getCache()->get(key, ret_value); return ret_value; } void remove(const string &key) { getCache()->remove(key); } Memcache *getCache() { /* * pick a random element from the vector of clients. Obviously, this is * not very random but suffices as an example! */ uint32_t index= rand() % num_of_clients; return clients[index]; } private: /* * A vector of clients. */ std::vector clients; MyCache() : clients() { /* create clients and add them to the vector */ for (uint32_t i= 0; i < num_of_clients; i++) { Memcache *client= new Memcache("127.0.0.1:11211"); clients.push_back(client); } } ~MyCache() { for_each(clients.begin(), clients.end(), DeletePtrs()); clients.clear(); } MyCache(const MyCache&); }; class Product { public: Product(int in_id, double in_price) : id(in_id), price(in_price) {} Product() : id(0), price(0.0) {} int getId() const { return id; } double getPrice() const { return price; } private: int id; double price; }; void setAllProducts(vector &products) { vector raw_products(products.size() * sizeof(Product)); memcpy(&raw_products[0], &products[0], products.size() * sizeof(Product)); MyCache::singleton().set("AllProducts", raw_products); } vector getAllProducts() { vector raw_products = MyCache::singleton().get("AllProducts"); vector products(raw_products.size() / sizeof(Product)); memcpy(&products[0], &raw_products[0], raw_products.size()); return products; } Product getProduct(const string &key) { vector raw_product= MyCache::singleton().get(key); Product ret; if (! raw_product.empty()) { memcpy(&ret, &raw_product[0], sizeof(Product)); } else { /* retrieve it from the persistent store */ } return ret; } void setProduct(const string &key, const Product &product) { vector raw_product(sizeof(Product)); memcpy(&raw_product[0], &product, sizeof(Product)); MyCache::singleton().set(key, raw_product); } int main() { Memcache first_client("127.0.0.1:19191"); map< string, map > my_stats; first_client.getStats(my_stats); /* * Iterate through the retrieved stats. */ map< string, map >::iterator it= my_stats.begin(); while (it != my_stats.end()) { cout << "working with server: " << (*it).first << endl; map serv_stats= (*it).second; map::iterator iter= serv_stats.begin(); while (iter != serv_stats.end()) { cout << (*iter).first << ":" << (*iter).second << endl; ++iter; } ++it; } return EXIT_SUCCESS; } libmemcached-1.0.8/tests/memcat.cc0000664000076400007640000001022411753763014017324 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Test memcat * * Copyright (C) 2011 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. * */ /* Test that we are cycling the servers we are creating during testing. */ #include #include #include using namespace libtest; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif static std::string executable("clients/memcat"); static test_return_t help_test(void *) { const char *args[]= { "--help", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t cat_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); const char *args[]= { buffer, "foo", 0 }; memcached_st *memc= memcached(buffer, strlen(buffer)); test_true(memc); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("foo"), 0, 0, 0, 0)); memcached_return_t rc; test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_SUCCESS, rc); test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_SUCCESS, rc); memcached_free(memc); return TEST_SUCCESS; } static test_return_t NOT_FOUND_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); const char *args[]= { buffer, "foo", 0 }; memcached_st *memc= memcached(buffer, strlen(buffer)); test_true(memc); test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); memcached_return_t rc; test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_NOTFOUND, rc); test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_NOTFOUND, rc); memcached_free(memc); return TEST_SUCCESS; } test_st memcat_tests[] ={ {"--help", true, help_test }, {"cat(FOUND)", true, cat_test }, {"cat(NOT_FOUND)", true, NOT_FOUND_test }, {0, 0, 0} }; collection_st collection[] ={ {"memcat", 0, 0, memcat_tests }, {0, 0, 0, 0} }; static void *world_create(server_startup_st& servers, test_return_t& error) { if (HAVE_MEMCACHED_BINARY == 0) { error= TEST_SKIPPED; return NULL; } if (not server_startup(servers, "memcached", libtest::default_port(), 0, NULL)) { error= TEST_FAILURE; } return &servers; } void get_world(Framework *world) { world->collections(collection); world->create(world_create); } libmemcached-1.0.8/tests/runner.h0000664000076400007640000001157311753573717017252 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * 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. * */ #pragma once #include "tests/libmemcached-1.0/generate.h" #include "tests/memc.h" #include "tests/print.h" class LibmemcachedRunner : public libtest::Runner { public: test_return_t run(test_callback_fn* func, void *object) { return _runner_default(libmemcached_test_callback_fn(func), (libmemcached_test_container_st*)object); } test_return_t flush(void* arg) { return flush((libmemcached_test_container_st*)arg); } test_return_t flush(libmemcached_test_container_st *container) { Memc memc(container->parent()); memcached_flush(&memc, 0); memcached_quit(&memc); return TEST_SUCCESS; } test_return_t pre(test_callback_fn* func, void *object) { return _pre_runner_default(libmemcached_test_callback_fn(func), (libmemcached_test_container_st*)object); } test_return_t post(test_callback_fn* func, void *object) { return _post_runner_default(libmemcached_test_callback_fn(func), (libmemcached_test_container_st*)object); } private: test_return_t _runner_default(libmemcached_test_callback_fn func, libmemcached_test_container_st *container) { test_true(container); test_true(container->parent()); Memc memc(container->parent()); test_compare(true, check()); test_return_t ret= TEST_SUCCESS; if (func) { test_true(container); try { ret= func(&memc); } catch (std::exception& e) { libtest::Error << e.what(); ret= TEST_FAILURE; } } return ret; } test_return_t _pre_runner_default(libmemcached_test_callback_fn func, libmemcached_test_container_st *container) { container->reset(); { char buffer[BUFSIZ]; test_compare_got(MEMCACHED_SUCCESS, libmemcached_check_configuration(container->construct.option_string().c_str(), container->construct.option_string().size(), buffer, sizeof(buffer)), container->construct.option_string().c_str()); test_null(container->parent()); container->parent(memcached(container->construct.option_string().c_str(), container->construct.option_string().size())); test_true(container->parent()); #if 0 test_compare(MEMCACHED_SUCCESS, memcached_version(container->parent())); #endif if (container->construct.sasl()) { if (memcached_failed(memcached_behavior_set(container->parent(), MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1))) { container->reset(); return TEST_FAILURE; } if (memcached_failed(memcached_set_sasl_auth_data(container->parent(), container->construct.username().c_str(), container->construct.password().c_str()))) { container->reset(); return TEST_FAILURE; } } } test_compare(true, check()); if (func) { return func(container->parent()); } return TEST_SUCCESS; } test_return_t _post_runner_default(libmemcached_test_callback_fn func, libmemcached_test_container_st *container) { test_compare(true, check()); cleanup_pairs(NULL); test_return_t rc= TEST_SUCCESS; if (func) { rc= func(container->parent()); } container->reset(); return rc; } }; libmemcached-1.0.8/tests/memcp.cc0000664000076400007640000000573611753763014017173 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Test memcp * * Copyright (C) 2011 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. * */ /* Test that we are cycling the servers we are creating during testing. */ #include #include #include using namespace libtest; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif static std::string executable("./clients/memcp"); static test_return_t help_test(void *) { const char *args[]= { "--help", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t server_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { buffer, 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } test_st memcp_tests[] ={ {"--help", true, help_test }, {"--server_test", true, server_test }, {0, 0, 0} }; collection_st collection[] ={ {"memcp", 0, 0, memcp_tests }, {0, 0, 0, 0} }; static void *world_create(server_startup_st& servers, test_return_t& error) { if (HAVE_MEMCACHED_BINARY == 0) { error= TEST_SKIPPED; return NULL; } if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == false) { error= TEST_FAILURE; } return &servers; } void get_world(Framework *world) { world->collections(collection); world->create(world_create); } libmemcached-1.0.8/tests/ketama_test_cases.h0000664000076400007640000001421311753573717021412 0ustar00brianbrian00000000000000/* * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ #pragma once static struct { const char *key; unsigned long hash1; unsigned long hash2; const char *server; } ketama_test_cases[99]= { { "SVa_]_V41)", 443691461UL, 445379617UL, "10.0.1.7" }, { "*/Z;?V(.\\8", 1422915503UL, 1428303028UL, "10.0.1.1" }, { "30C1*Z*S/_", 1473165754UL, 1480075959UL, "10.0.1.2" }, { "ERR:EC58G>", 2148406511UL, 2168579133UL, "10.0.1.7" }, { "1I=cTMNTKF", 2882686667UL, 2885206587UL, "10.0.1.5" }, { "]VG<`I*Z8)", 1103544263UL, 1104827657UL, "10.0.1.5" }, { "UUTC`-V159", 3716288206UL, 3727224240UL, "10.0.1.5" }, { "@7RU6C6T+Z", 3862737685UL, 3871917949UL, "10.0.1.5" }, { "/XLN0@+36;", 1623269830UL, 1627683651UL, "10.0.1.1" }, { "4(`X;\\V.^c", 373546328UL, 383925769UL, "10.0.1.1" }, { "726bW=9*a4", 4213440020UL, 4213950705UL, "10.0.1.7" }, { "\\`)32", 536016577UL, 539988520UL, "10.0.1.7" }, { "U))Fb-(`,.", 4128682289UL, 4136854163UL, "10.0.1.7" }, { "R-08RNTaRT", 3718170086UL, 3727224240UL, "10.0.1.5" }, { "(LHcO203I3", 1007779411UL, 1014643570UL, "10.0.1.5" }, { "=256P+;Qc8", 3976201210UL, 3976304873UL, "10.0.1.5" }, { "OI5XZ_BBT(", 2155922164UL, 2168579133UL, "10.0.1.7" }, { "2TLRL/UL;:", 1086800909UL, 1095659802UL, "10.0.1.7" }, { "WHD\\O1`ZRW", 3087923411UL, 3095471560UL, "10.0.1.5" }, { ".=54)_c;=T", 2497691631UL, 2502731301UL, "10.0.1.1" }, { ";GE`)FT\\4", 580747448UL, 581063326UL, "10.0.1.2" }, { "HZAU*;P*N]", 2564670474UL, 2565697267UL, "10.0.1.7" }, { "NZ@ZE=O84_", 533335275UL, 539988520UL, "10.0.1.7" }, { "6,cEI`F_P>", 3972869246UL, 3974773167UL, "10.0.1.6" }, { "c,5AQ/T5)6", 2835605783UL, 2847870057UL, "10.0.1.8" }, { ".O,>>BT)RX", 3857978174UL, 3871917949UL, "10.0.1.5" }, { "XY\\X::LX50", 1749241099UL, 1752196488UL, "10.0.1.6" }, { "+550F^/.01", 3781824099UL, 3783248219UL, "10.0.1.6" }, { "<.X9E2S5+9", 3232479481UL, 3234387706UL, "10.0.1.7" }, { "]\\.UH8_0a1", 2419699252UL, 2423002920UL, "10.0.1.4" }, { "8(6=(T0/Z0", 728266737UL, 729026070UL, "10.0.1.7" }, { "8*6a;Sc*X+", 4223431086UL, 4230156966UL, "10.0.1.2" }, { "J5/", 2776949824UL, 2784182515UL, "10.0.1.7" }, { "[>RZHG97Q9", 71954686UL, 72034069UL, "10.0.1.6" }, { "J3/G[)9<^Z", 2799896459UL, 2805183696UL, "10.0.1.7" }, { "N-)88>[O`,", 50404102UL, 51792557UL, "10.0.1.5" }, { "NP:=FR\\OaA", 3837333776UL, 3837792034UL, "10.0.1.7" }, { "`@L+W;a,O[", 1512157148UL, 1522285852UL, "10.0.1.6" }, { "W2`P:-+1T[", 2945171975UL, 2946196424UL, "10.0.1.5" }, { "-6G7K^YDIN", 3168617340UL, 3170513015UL, "10.0.1.7" }, { "U>*>9ZI6V5", 668514946UL, 674097631UL, "10.0.1.6" }, { ".I?^6Ic9RK", 938419020UL, 942832691UL, "10.0.1.6" }, { "0OZH^9BKM[", 3682518606UL, 3686781297UL, "10.0.1.8" }, { "5?50UGZ:ML", 868610882UL, 869425986UL, "10.0.1.5" }, { "?K2NF@3=IU", 381218851UL, 383925769UL, "10.0.1.1" }, { "YI@G-2X?UB", 3688706179UL, 3693197681UL, "10.0.1.5" }, { "7cY", 2590140172UL, 2598117636UL, "10.0.1.7" }, { "\\[a\\^=V_M0", 689410119UL, 698690782UL, "10.0.1.6" }, { "7;RM+8J9YC", 1530175299UL, 1531107082UL, "10.0.1.7" }, { "4*=.SPR[AV", 3928582722UL, 3928853792UL, "10.0.1.1" }, { "-2F+^88P4U", 3023552752UL, 3025823613UL, "10.0.1.7" }, { "X;-F`(N?9D", 570465234UL, 572485994UL, "10.0.1.7" }, { "R=F_D-K2a]", 1287750228UL, 1290935562UL, "10.0.1.7" }, { "X*+2aaC.EG", 3200948713UL, 3201088518UL, "10.0.1.5" }, { "[1ZXONX2]a", 4108881567UL, 4109865744UL, "10.0.1.4" }, { "FL;\\GWacaV", 458449508UL, 467374054UL, "10.0.1.4" }, { "\\MQ_XNT7L-", 1259349383UL, 1259509450UL, "10.0.1.7" }, { "VD6D0]ba_\\", 3842502950UL, 3842588691UL, "10.0.1.1" }, }; #include "ketama_test_cases_spy.h" libmemcached-1.0.8/tests/hash_plus.cc0000664000076400007640000001040111753763014020041 0ustar00brianbrian00000000000000/* C++ to libhashkit */ #include #include #include #include #include #include using namespace libtest; #include "tests/hash_results.h" static test_return_t exists_test(void *) { Hashkit hashk; (void)hashk; return TEST_SUCCESS; } static test_return_t new_test(void *) { Hashkit *hashk= new Hashkit; (void)hashk; delete hashk; return TEST_SUCCESS; } static test_return_t copy_test(void *) { Hashkit *hashk= new Hashkit; Hashkit *copy(hashk); (void)copy; delete hashk; return TEST_SUCCESS; } static test_return_t assign_test(void *) { Hashkit hashk; Hashkit copy; copy= hashk; (void)copy; return TEST_SUCCESS; } static test_return_t digest_test(void *) { Hashkit hashk; test_true(hashk.digest("Foo", sizeof("Foo"))); return TEST_SUCCESS; } static test_return_t set_function_test(void *) { Hashkit hashk; hashkit_hash_algorithm_t algo_list[]= { HASHKIT_HASH_DEFAULT, HASHKIT_HASH_MD5, HASHKIT_HASH_CRC, HASHKIT_HASH_FNV1_64, HASHKIT_HASH_FNV1A_64, HASHKIT_HASH_FNV1_32, HASHKIT_HASH_FNV1A_32, HASHKIT_HASH_MURMUR, HASHKIT_HASH_JENKINS, HASHKIT_HASH_MAX }; for (hashkit_hash_algorithm_t *algo= algo_list; *algo != HASHKIT_HASH_MAX; algo++) { hashkit_return_t rc= hashk.set_function(*algo); if (rc == HASHKIT_INVALID_ARGUMENT) { continue; } test_compare(HASHKIT_SUCCESS, rc); uint32_t *list; switch (*algo) { case HASHKIT_HASH_DEFAULT: list= one_at_a_time_values; break; case HASHKIT_HASH_MD5: list= md5_values; break; case HASHKIT_HASH_CRC: list= crc_values; break; case HASHKIT_HASH_FNV1_64: list= fnv1_64_values; break; case HASHKIT_HASH_FNV1A_64: list= fnv1a_64_values; break; case HASHKIT_HASH_FNV1_32: list= fnv1_32_values; break; case HASHKIT_HASH_FNV1A_32: list= fnv1a_32_values; break; case HASHKIT_HASH_HSIEH: list= hsieh_values; break; case HASHKIT_HASH_MURMUR: #ifdef WORDS_BIGENDIAN continue; #endif list= murmur_values; break; case HASHKIT_HASH_JENKINS: list= jenkins_values; break; case HASHKIT_HASH_CUSTOM: case HASHKIT_HASH_MAX: default: list= NULL; test_fail("We ended up on a non-existent hash"); } // Now we make sure we did set the hash correctly. uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { uint32_t hash_val; hash_val= hashk.digest(*ptr, strlen(*ptr)); char buffer[1024]; snprintf(buffer, sizeof(buffer), "%lu %lus %s", (unsigned long)list[x], (unsigned long)hash_val, libhashkit_string_hash(*algo)); test_true_got(list[x] == hash_val, buffer); } } return TEST_SUCCESS; } static test_return_t set_distribution_function_test(void *) { Hashkit hashk; hashkit_return_t rc; rc= hashk.set_distribution_function(HASHKIT_HASH_CUSTOM); test_true_got(rc == HASHKIT_FAILURE or rc == HASHKIT_INVALID_ARGUMENT, hashkit_strerror(NULL, rc)); test_compare(HASHKIT_SUCCESS, hashk.set_distribution_function(HASHKIT_HASH_JENKINS)); return TEST_SUCCESS; } static test_return_t compare_function_test(void *) { Hashkit a, b; b= a; test_true(a == b); b.set_function(HASHKIT_HASH_MURMUR); test_false(a == b); test_true(b == b); test_true(a == a); return TEST_SUCCESS; } test_st basic[] ={ { "exists", 0, reinterpret_cast(exists_test) }, { "new", 0, reinterpret_cast(new_test) }, { "copy", 0, reinterpret_cast(copy_test) }, { "assign", 0, reinterpret_cast(assign_test) }, { "digest", 0, reinterpret_cast(digest_test) }, { "set_function", 0, reinterpret_cast(set_function_test) }, { "set_distribution_function", 0, reinterpret_cast(set_distribution_function_test) }, { "compare", 0, reinterpret_cast(compare_function_test) }, { 0, 0, 0} }; collection_st collection[] ={ {"basic", 0, 0, basic}, {0, 0, 0, 0} }; void get_world(Framework *world) { world->collections(collection); } libmemcached-1.0.8/tests/memdump.cc0000664000076400007640000000736211753763014017533 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Test memdump * * Copyright (C) 2011 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. * */ /* Test that we are cycling the servers we are creating during testing. */ #include #include #include using namespace libtest; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif static std::string executable("./clients/memdump"); static test_return_t help_test(void *) { const char *args[]= { "--help", "--quiet", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t server_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { buffer, 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t FOUND_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); const char *args[]= { buffer, 0 }; memcached_st *memc= memcached(buffer, strlen(buffer)); test_true(memc); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("foo"), 0, 0, 0, 0)); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("foo2"), 0, 0, 0, 0)); memcached_return_t rc; test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_SUCCESS, rc); test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); memcached_free(memc); return TEST_SUCCESS; } test_st memdump_tests[] ={ {"--help", true, help_test }, {"--server", true, server_test }, {"FOUND", true, FOUND_test }, {0, 0, 0} }; collection_st collection[] ={ {"memdump", 0, 0, memdump_tests }, {0, 0, 0, 0} }; static void *world_create(server_startup_st& servers, test_return_t& error) { if (HAVE_MEMCACHED_BINARY == 0) { error= TEST_SKIPPED; return NULL; } if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == false) { error= TEST_FAILURE; } return &servers; } void get_world(Framework *world) { world->collections(collection); world->create(world_create); } libmemcached-1.0.8/tests/cycle.cc0000664000076400007640000000757311753763014017172 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Cycle the Gearmand server * * Copyright (C) 2011 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. * */ /* Test that we are cycling the servers we are creating during testing. */ #include #include using namespace libtest; #include static test_return_t server_startup_single_TEST(void *obj) { server_startup_st *servers= (server_startup_st*)obj; test_compare(true, server_startup(*servers, "memcached", libtest::get_free_port(), 0, NULL, false)); test_compare(true, servers->shutdown()); return TEST_SUCCESS; } static test_return_t server_startup_multiple_TEST(void *obj) { server_startup_st *servers= (server_startup_st*)obj; for (size_t x= 0; x < 10; x++) { test_compare(true, server_startup(*servers, "memcached", libtest::get_free_port(), 0, NULL, false)); } test_compare(true, servers->shutdown()); return TEST_SUCCESS; } static test_return_t shutdown_and_remove_TEST(void *obj) { server_startup_st *servers= (server_startup_st*)obj; servers->clear(); return TEST_SUCCESS; } test_st server_startup_TESTS[] ={ {"server_startup(1)", false, (test_callback_fn*)server_startup_single_TEST }, {"server_startup(10)", false, (test_callback_fn*)server_startup_multiple_TEST }, {"shutdown_and_remove()", false, (test_callback_fn*)shutdown_and_remove_TEST }, {"server_startup(10)", false, (test_callback_fn*)server_startup_multiple_TEST }, {0, 0, 0} }; #if 0 static test_return_t collection_INIT(void *object) { server_startup_st *servers= (server_startup_st*)object; test_zero(servers->count()); test_compare(true, server_startup(*servers, "memcached", libtest::default_port(), 0, NULL)); return TEST_SUCCESS; } #endif static test_return_t validate_sanity_INIT(void *object) { server_startup_st *servers= (server_startup_st*)object; test_zero(servers->count()); return TEST_SUCCESS; } static test_return_t collection_FINAL(void *object) { server_startup_st *servers= (server_startup_st*)object; servers->clear(); return TEST_SUCCESS; } collection_st collection[] ={ {"server_startup()", validate_sanity_INIT, collection_FINAL, server_startup_TESTS }, {0, 0, 0, 0} }; static void *world_create(server_startup_st& servers, test_return_t& ) { return &servers; } void get_world(Framework *world) { world->collections(collection); world->create(world_create); } libmemcached-1.0.8/tests/callbacks.h0000664000076400007640000000353111753573717017653 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * Copyright (C) 2011 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. * */ #pragma once test_return_t test_MEMCACHED_CALLBACK_DELETE_TRIGGER_and_MEMCACHED_BEHAVIOR_NOREPLY(memcached_st *); test_return_t test_MEMCACHED_CALLBACK_DELETE_TRIGGER(memcached_st *); libmemcached-1.0.8/tests/basic.h0000664000076400007640000000426311753573717017020 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached * * Copyright (C) 2011 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. * */ #pragma once #include #ifdef __cplusplus extern "C" { #endif LIBTEST_LOCAL test_return_t basic_init_test(memcached_st *junk); LIBTEST_LOCAL test_return_t basic_clone_test(memcached_st *memc); LIBTEST_LOCAL test_return_t basic_reset_stack_test(memcached_st *junk); LIBTEST_LOCAL test_return_t basic_reset_heap_test(memcached_st *junk); LIBTEST_LOCAL test_return_t basic_reset_stack_clone_test(memcached_st *memc); LIBTEST_LOCAL test_return_t basic_reset_heap_clone_test(memcached_st *memc); #ifdef __cplusplus } #endif libmemcached-1.0.8/tests/debug.h0000664000076400007640000000413311753573717017021 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached client and server library. * * Copyright (C) 2011 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. * */ #pragma once test_return_t confirm_keys_exist(memcached_st *memc, const char * const *keys, const size_t number_of_keys, bool key_matches_value= false, bool require_all= false); test_return_t confirm_keys_dont_exist(memcached_st *memc, const char * const *keys, const size_t number_of_keys); test_return_t print_keys_by_server(memcached_st *memc); size_t confirm_key_count(memcached_st *memc); void print_servers(memcached_st *); libmemcached-1.0.8/tests/hash_results.h0000664000076400007640000001401711753573717020441 0ustar00brianbrian00000000000000/* * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ /** @brief We list strings and results for testing different hashing algo in this file. */ static const char *list_to_hash[]= { "apple", "beat", "carrot", "daikon", "eggplant", "flower", "green", "hide", "ick", "jack", "kick", "lime", "mushrooms", "nectarine", "orange", "peach", "quant", "ripen", "strawberry", "tang", "up", "volumne", "when", "yellow", "zip", NULL }; static uint32_t one_at_a_time_values[]= { 2297466611U, 3902465932U, 469785835U, 1937308741U, 261917617U, 3785641677U, 1439605128U, 1649152283U, 1493851484U, 1246520657U, 2221159044U, 1973511823U, 384136800U, 214358653U, 2379473940U, 4269788650U, 2864377005U, 2638630052U, 427683330U, 990491717U, 1747111141U, 792127364U, 2599214128U, 2553037199U, 2509838425U }; static uint32_t md5_values[]= { 3195025439U, 2556848621U, 3724893440U, 3332385401U, 245758794U, 2550894432U, 121710495U, 3053817768U, 1250994555U, 1862072655U, 2631955953U, 2951528551U, 1451250070U, 2820856945U, 2060845566U, 3646985608U, 2138080750U, 217675895U, 2230934345U, 1234361223U, 3968582726U, 2455685270U, 1293568479U, 199067604U, 2042482093U }; static uint32_t crc_values[]= { 10542U, 22009U, 14526U, 19510U, 19432U, 10199U, 20634U, 9369U, 11511U, 10362U, 7893U, 31289U, 11313U, 9354U, 7621U, 30628U, 15218U, 25967U, 2695U, 9380U, 17300U, 28156U, 9192U, 20484U, 16925U }; static uint32_t fnv1_64_values[]= { 473199127U, 4148981457U, 3971873300U, 3257986707U, 1722477987U, 2991193800U, 4147007314U, 3633179701U, 1805162104U, 3503289120U, 3395702895U, 3325073042U, 2345265314U, 3340346032U, 2722964135U, 1173398992U, 2815549194U, 2562818319U, 224996066U, 2680194749U, 3035305390U, 246890365U, 2395624193U, 4145193337U, 1801941682U }; static uint32_t fnv1a_64_values[]= { 1488911807U, 2500855813U, 1510099634U, 1390325195U, 3647689787U, 3241528582U, 1669328060U, 2604311949U, 734810122U, 1516407546U, 560948863U, 1767346780U, 561034892U, 4156330026U, 3716417003U, 3475297030U, 1518272172U, 227211583U, 3938128828U, 126112909U, 3043416448U, 3131561933U, 1328739897U, 2455664041U, 2272238452U }; static uint32_t fnv1_32_values[]= { 67176023U, 1190179409U, 2043204404U, 3221866419U, 2567703427U, 3787535528U, 4147287986U, 3500475733U, 344481048U, 3865235296U, 2181839183U, 119581266U, 510234242U, 4248244304U, 1362796839U, 103389328U, 1449620010U, 182962511U, 3554262370U, 3206747549U, 1551306158U, 4127558461U, 1889140833U, 2774173721U, 1180552018U }; static uint32_t fnv1a_32_values[]= { 280767167U, 2421315013U, 3072375666U, 855001899U, 459261019U, 3521085446U, 18738364U, 1625305005U, 2162232970U, 777243802U, 3323728671U, 132336572U, 3654473228U, 260679466U, 1169454059U, 2698319462U, 1062177260U, 235516991U, 2218399068U, 405302637U, 1128467232U, 3579622413U, 2138539289U, 96429129U, 2877453236U }; #ifdef HAVE_HSIEH_HASH static uint32_t hsieh_values[]= { 3738850110U, 3636226060U, 3821074029U, 3489929160U, 3485772682U, 80540287U, 1805464076U, 1895033657U, 409795758U, 979934958U, 3634096985U, 1284445480U, 2265380744U, 707972988U, 353823508U, 1549198350U, 1327930172U, 9304163U, 4220749037U, 2493964934U, 2777873870U, 2057831732U, 1510213931U, 2027828987U, 3395453351U }; #else static uint32_t hsieh_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 #ifdef HAVE_MURMUR_HASH static uint32_t murmur_values[]= { 4142305122U, 734504955U, 3802834688U, 4076891445U, 387802650U, 560515427U, 3274673488U, 3150339524U, 1527441970U, 2728642900U, 3613992239U, 2938419259U, 2321988328U, 1145154116U, 4038540960U, 2224541613U, 264013145U, 3995512858U, 2400956718U, 2346666219U, 926327338U, 442757446U, 1770805201U, 560483147U, 3902279934U }; #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 }; #endif static uint32_t jenkins_values[]= { 1442444624U, 4253821186U, 1885058256U, 2120131735U, 3261968576U, 3515188778U, 4232909173U, 4288625128U, 1812047395U, 3689182164U, 2502979932U, 1214050606U, 2415988847U, 1494268927U, 1025545760U, 3920481083U, 4153263658U, 3824871822U, 3072759809U, 798622255U, 3065432577U, 1453328165U, 2691550971U, 3408888387U, 2629893356U }; libmemcached-1.0.8/tests/memstat.cc0000664000076400007640000000735411753763014017542 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Test memstat * * Copyright (C) 2011 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. * */ /* Test that we are cycling the servers we are creating during testing. */ #include #include #include using namespace libtest; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif static std::string executable("./clients/memstat"); static test_return_t help_test(void *) { const char *args[]= { "--help", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t binary_TEST(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(libtest::default_port())); const char *args[]= { buffer, " --binary ", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t server_version_TEST(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(libtest::default_port())); const char *args[]= { buffer, " --server-version", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t binary_server_version_TEST(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(libtest::default_port())); const char *args[]= { buffer, " --binary --server-version", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } test_st memstat_tests[] ={ {"--help", 0, help_test}, {"--binary", 0, binary_TEST}, {"--server-version", 0, server_version_TEST}, {"--binary --server-version", 0, binary_server_version_TEST}, {0, 0, 0} }; collection_st collection[] ={ {"memstat", 0, 0, memstat_tests }, {0, 0, 0, 0} }; static void *world_create(server_startup_st& servers, test_return_t& error) { if (HAVE_MEMCACHED_BINARY == 0) { error= TEST_SKIPPED; return NULL; } if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == false) { error= TEST_FAILURE; } return &servers; } void get_world(Framework *world) { world->collections(collection); world->create(world_create); } libmemcached-1.0.8/tests/print.h0000664000076400007640000000421611753573717017071 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached client and server library. * * Copyright (C) 2011 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. * */ #pragma once memcached_return_t server_print_callback(const memcached_st *ptr, const memcached_server_st *server, void *context); memcached_return_t server_print_version_callback(const memcached_st *ptr, const memcached_server_st *server, void *context); const char * print_version(memcached_st *memc); libmemcached-1.0.8/tests/memc.h0000664000076400007640000000425611753573717016662 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Gearmand client and server library. * * Copyright (C) 2011 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. * */ #pragma once class Memc { public: Memc() { _memc= memcached_create(NULL); if (_memc == NULL) { throw "memcached_create() failed"; } } Memc(memcached_st* arg) { _memc= memcached_clone(NULL, arg); if (_memc == NULL) { throw "memcached_clone() failed"; } } memcached_st* operator&() const { return _memc; } memcached_st* operator->() const { return _memc; } ~Memc() { memcached_free(_memc); } private: memcached_st *_memc; }; libmemcached-1.0.8/tests/memtouch.cc0000664000076400007640000001124511753763014017703 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Test memtouch * * Copyright (C) 2011 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. * */ /* Test that we are cycling the servers we are creating during testing. */ #include #include #include #include using namespace libtest; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif static std::string executable; static test_return_t help_test(void *) { const char *args[]= { "--help", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t touch_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); memcached_st *memc= memcached(buffer, strlen(buffer)); test_true(memc); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("foo"), 0, 0, 0, 0)); test_compare(MEMCACHED_SUCCESS, memcached_exist(memc, test_literal_param("foo"))); snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { "--expire=30", buffer, "foo", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); test_compare(MEMCACHED_SUCCESS, memcached_exist(memc, test_literal_param("foo"))); memcached_free(memc); return TEST_SUCCESS; } static test_return_t NOT_FOUND_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); memcached_st *memc= memcached(buffer, strlen(buffer)); test_true(memc); test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); test_compare(MEMCACHED_NOTFOUND, memcached_exist(memc, test_literal_param("foo"))); snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { "--expire=30", buffer, "foo", 0 }; test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); test_compare(MEMCACHED_NOTFOUND, memcached_exist(memc, test_literal_param("foo"))); memcached_free(memc); return TEST_SUCCESS; } static test_return_t check_version(void*) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); memcached_st *memc= memcached(buffer, strlen(buffer)); test_true(memc); test_return_t result= TEST_SUCCESS; if (libmemcached_util_version_check(memc, 1, 4, 8) == false) { result= TEST_SKIPPED; } memcached_free(memc); return result; } test_st memtouch_tests[] ={ {"--help", true, help_test }, {"touch(FOUND)", true, touch_test }, {"touch(NOT_FOUND)", true, NOT_FOUND_test }, {0, 0, 0} }; collection_st collection[] ={ {"memtouch", check_version, 0, memtouch_tests }, {0, 0, 0, 0} }; static void *world_create(server_startup_st& servers, test_return_t& error) { if (HAVE_MEMCACHED_BINARY == 0) { error= TEST_SKIPPED; return NULL; } if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == false) { error= TEST_FAILURE; } return &servers; } void get_world(Framework *world) { executable= "./clients/memtouch"; world->collections(collection); world->create(world_create); } libmemcached-1.0.8/tests/keys.hpp0000664000076400007640000000673311753573717017256 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached 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. * */ struct keys_st { public: keys_st(size_t arg) { init(arg, UUID_STRING_MAXLENGTH); } keys_st(size_t arg, size_t padding) { init(arg, padding); } void init(size_t arg, size_t padding) { _lengths.resize(arg); _keys.resize(arg); for (size_t x= 0; x < _keys.size(); x++) { libtest::vchar_t key_buffer; key_buffer.resize(padding +1); memset(&key_buffer[0], 'x', padding); if (HAVE_LIBUUID) { #if defined(HAVE_LIBUUID) && HAVE_LIBUUID uuid_t out; uuid_generate(out); uuid_unparse(out, &key_buffer[0]); _keys[x]= strdup(&key_buffer[0]); (_keys[x])[UUID_STRING_MAXLENGTH]= 'x'; #endif } else // We just use a number and pad the string if UUID is not available { char int_buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; int key_length= snprintf(int_buffer, sizeof(int_buffer), "%u", uint32_t(x)); memcpy(&key_buffer[0], int_buffer, key_length); _keys[x]= strdup(&key_buffer[0]); } _lengths[x]= padding; } } ~keys_st() { for (libtest::vchar_ptr_t::iterator iter= _keys.begin(); iter != _keys.end(); iter++) { ::free(*iter); } } libtest::vchar_ptr_t::iterator begin() { return _keys.begin(); } libtest::vchar_ptr_t::iterator end() { return _keys.end(); } size_t size() const { return _keys.size(); } std::vector& lengths() { return _lengths; } libtest::vchar_ptr_t& keys() { return _keys; } size_t* lengths_ptr() { return &_lengths[0]; } char** keys_ptr() { return &_keys[0]; } char* key_at(size_t arg) { return _keys[arg]; } size_t length_at(size_t arg) { return _lengths[arg]; } private: libtest::vchar_ptr_t _keys; std::vector _lengths; }; libmemcached-1.0.8/tests/mem_udp.cc0000664000076400007640000004327611753763014017521 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ /* Sample test application. */ #include #include using namespace libtest; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif /** @note This should be testing to see if the server really supports the binary protocol. */ static test_return_t pre_binary(memcached_st *memc) { memcached_st *memc_clone= memcached_clone(NULL, memc); test_true(memc_clone); // The memcached_version needs to be done on a clone, because the server // will not toggle protocol on an connection. memcached_version(memc_clone); test_compare(MEMCACHED_SUCCESS, memcached_version(memc)); test_compare(true, libmemcached_util_version_check(memc, 1, 2, 1)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, true)); test_compare(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); memcached_free(memc_clone); return TEST_SUCCESS; } typedef std::vector Expected; static void increment_request_id(uint16_t *id) { (*id)++; if ((*id & UDP_REQUEST_ID_THREAD_MASK) != 0) { *id= 0; } } static void get_udp_request_ids(memcached_st *memc, Expected &ids) { for (uint32_t x= 0; x < memcached_server_count(memc); x++) { memcached_server_instance_st instance= memcached_server_instance_by_position(memc, x); ids.push_back(get_udp_datagram_request_id((struct udp_datagram_header_st *) ((memcached_server_instance_st )instance)->write_buffer)); } } static test_return_t post_udp_op_check(memcached_st *memc, Expected& expected_req_ids) { (void)memc; (void)expected_req_ids; #if 0 memcached_server_st *cur_server = memcached_server_list(memc); uint16_t *cur_req_ids = get_udp_request_ids(memc); for (size_t x= 0; x < memcached_server_count(memc); x++) { test_true(cur_server[x].cursor_active == 0); test_true(cur_req_ids[x] == expected_req_ids[x]); } free(expected_req_ids); free(cur_req_ids); #endif return TEST_SUCCESS; } /* ** There is a little bit of a hack here, instead of removing ** the servers, I just set num host to 0 and them add then new udp servers **/ static test_return_t init_udp(memcached_st *memc) { test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, true)); return TEST_SUCCESS; } static test_return_t init_udp_valgrind(memcached_st *memc) { if (getenv("TESTS_ENVIRONMENT")) { return TEST_SKIPPED; } test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, true)); return TEST_SUCCESS; } static test_return_t binary_init_udp(memcached_st *memc) { if (getenv("TESTS_ENVIRONMENT")) { return TEST_SKIPPED; } test_skip(TEST_SUCCESS, pre_binary(memc)); return init_udp(memc); } /* Make sure that I cant add a tcp server to a udp client */ static test_return_t add_tcp_server_udp_client_test(memcached_st *memc) { (void)memc; #if 0 memcached_server_st server; memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); memcached_server_clone(&server, &memc->hosts[0]); test_true(memcached_server_remove(&(memc->hosts[0])) == MEMCACHED_SUCCESS); test_true(memcached_server_add(memc, server.hostname, server.port) == MEMCACHED_INVALID_HOST_PROTOCOL); #endif return TEST_SUCCESS; } /* Make sure that I cant add a udp server to a tcp client */ static test_return_t add_udp_server_tcp_client_test(memcached_st *memc) { (void)memc; #if 0 memcached_server_st server; memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); memcached_server_clone(&server, &memc->hosts[0]); test_true(memcached_server_remove(&(memc->hosts[0])) == MEMCACHED_SUCCESS); memcached_st tcp_client; memcached_create(&tcp_client); test_true(memcached_server_add_udp(&tcp_client, server.hostname, server.port) == MEMCACHED_INVALID_HOST_PROTOCOL); #endif return TEST_SUCCESS; } static test_return_t version_TEST(memcached_st *memc) { test_compare(MEMCACHED_NOT_SUPPORTED, memcached_version(memc)); return TEST_SUCCESS; } static test_return_t verbosity_TEST(memcached_st *memc) { test_compare(MEMCACHED_SUCCESS, memcached_verbosity(memc, 0)); return TEST_SUCCESS; } static test_return_t memcached_get_TEST(memcached_st *memc) { memcached_return_t rc; test_null(memcached_get(memc, test_literal_param(__func__), 0, 0, &rc)); test_compare(MEMCACHED_NOT_SUPPORTED, rc); return TEST_SUCCESS; } static test_return_t memcached_mget_execute_by_key_TEST(memcached_st *memc) { char **keys= NULL; size_t *key_length= NULL; test_compare(MEMCACHED_NOT_SUPPORTED, memcached_mget_execute_by_key(memc, test_literal_param(__func__), // Group key keys, key_length, // Actual key 0, // Number of keys 0, // callbacks 0, // context 0)); // Number of callbacks return TEST_SUCCESS; } static test_return_t memcached_stat_TEST(memcached_st *memc) { memcached_return_t rc; test_null(memcached_stat(memc, 0, &rc)); test_compare(MEMCACHED_NOT_SUPPORTED, rc); return TEST_SUCCESS; } static test_return_t set_udp_behavior_test(memcached_st *memc) { memcached_quit(memc); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, memc->distribution)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, true)); test_compare(true, memc->flags.use_udp); test_compare(false, memc->flags.reply); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, false)); test_compare(false, memc->flags.use_udp); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, false)); test_compare(true, memc->flags.reply); return TEST_SUCCESS; } static test_return_t udp_set_test(memcached_st *memc) { // Assume we are running under valgrind, and bail if (getenv("TESTS_ENVIRONMENT")) { return TEST_SUCCESS; } const unsigned int num_iters= 1025; //request id rolls over at 1024 test_true(memc); for (size_t x= 0; x < num_iters;x++) { Expected expected_ids; get_udp_request_ids(memc, expected_ids); unsigned int server_key= memcached_generate_hash(memc, test_literal_param("foo")); test_true(server_key < memcached_server_count(memc)); memcached_server_instance_st instance= memcached_server_instance_by_position(memc, server_key); size_t init_offset= instance->write_buffer_offset; test_compare_hint(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("foo"), test_literal_param("when we sanitize"), time_t(0), uint32_t(0)), memcached_last_error_message(memc)); /* NB, the check below assumes that if new write_ptr is less than the original write_ptr that we have flushed. For large payloads, this maybe an invalid assumption, but for the small payload we have it is OK */ if (instance->write_buffer_offset < init_offset) { increment_request_id(&expected_ids[server_key]); } test_compare(TEST_SUCCESS, post_udp_op_check(memc, expected_ids)); } return TEST_SUCCESS; } static test_return_t udp_buffered_set_test(memcached_st *memc) { test_true(memc); test_compare(MEMCACHED_INVALID_ARGUMENTS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true)); return TEST_SUCCESS; } static test_return_t udp_set_too_big_test(memcached_st *memc) { test_true(memc); Expected expected_ids; get_udp_request_ids(memc, expected_ids); std::vector value; value.resize(1024 * 1024 * 10); test_compare_hint(MEMCACHED_WRITE_FAILURE, memcached_set(memc, test_literal_param(__func__), &value[0], value.size(), time_t(0), uint32_t(0)), memcached_last_error_message(memc)); memcached_quit(memc); return post_udp_op_check(memc, expected_ids); } static test_return_t udp_delete_test(memcached_st *memc) { test_true(memc); //request id rolls over at 1024 for (size_t x= 0; x < 1025; x++) { Expected expected_ids; get_udp_request_ids(memc, expected_ids); unsigned int server_key= memcached_generate_hash(memc, test_literal_param("foo")); memcached_server_instance_st instance= memcached_server_instance_by_position(memc, server_key); size_t init_offset= instance->write_buffer_offset; test_compare(MEMCACHED_SUCCESS, memcached_delete(memc, test_literal_param("foo"), 0)); if (instance->write_buffer_offset < init_offset) { increment_request_id(&expected_ids[server_key]); } test_compare(TEST_SUCCESS, post_udp_op_check(memc, expected_ids)); } return TEST_SUCCESS; } static test_return_t udp_buffered_delete_test(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1); return udp_delete_test(memc); } static test_return_t udp_verbosity_test(memcached_st *memc) { Expected expected_ids; get_udp_request_ids(memc, expected_ids); for (size_t x= 0; x < memcached_server_count(memc); x++) { increment_request_id(&expected_ids[x]); } test_compare(MEMCACHED_SUCCESS, memcached_verbosity(memc, 3)); return post_udp_op_check(memc, expected_ids); } static test_return_t udp_quit_test(memcached_st *memc) { Expected expected_ids; memcached_quit(memc); return post_udp_op_check(memc, expected_ids); } static test_return_t udp_flush_test(memcached_st *memc) { Expected expected_ids; get_udp_request_ids(memc, expected_ids); for (size_t x= 0; x < memcached_server_count(memc); x++) { increment_request_id(&expected_ids[x]); } memcached_error_print(memc); test_compare_hint(MEMCACHED_SUCCESS, memcached_flush(memc, 0), memcached_last_error_message(memc)); return post_udp_op_check(memc, expected_ids); } static test_return_t udp_incr_test(memcached_st *memc) { test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("incr"), test_literal_param("1"), (time_t)0, (uint32_t)0)); Expected expected_ids; get_udp_request_ids(memc, expected_ids); unsigned int server_key= memcached_generate_hash(memc, test_literal_param("incr")); increment_request_id(&expected_ids[server_key]); uint64_t newvalue; test_compare(MEMCACHED_SUCCESS, memcached_increment(memc, test_literal_param("incr"), 1, &newvalue)); return post_udp_op_check(memc, expected_ids); } static test_return_t udp_decr_test(memcached_st *memc) { test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param(__func__), test_literal_param("1"), time_t(0), uint32_t(0))); Expected expected_ids; get_udp_request_ids(memc, expected_ids); unsigned int server_key= memcached_generate_hash(memc, test_literal_param(__func__)); increment_request_id(&expected_ids[server_key]); uint64_t newvalue; test_compare(MEMCACHED_SUCCESS, memcached_decrement(memc, test_literal_param(__func__), 1, &newvalue)); return post_udp_op_check(memc, expected_ids); } static test_return_t udp_stat_test(memcached_st *memc) { memcached_return_t rc; char args[]= ""; Expected expected_ids; get_udp_request_ids(memc, expected_ids); memcached_stat_st *rv= memcached_stat(memc, args, &rc); memcached_stat_free(memc, rv); test_compare(MEMCACHED_NOT_SUPPORTED, rc); return post_udp_op_check(memc, expected_ids); } static test_return_t udp_version_test(memcached_st *memc) { Expected expected_ids; get_udp_request_ids(memc, expected_ids); test_compare(MEMCACHED_NOT_SUPPORTED, memcached_version(memc)); return post_udp_op_check(memc, expected_ids); } static test_return_t udp_get_test(memcached_st *memc) { memcached_return_t rc; size_t vlen; Expected expected_ids; get_udp_request_ids(memc, expected_ids); test_null(memcached_get(memc, test_literal_param("foo"), &vlen, (uint32_t)0, &rc)); test_compare(MEMCACHED_NOT_SUPPORTED, rc); return post_udp_op_check(memc, expected_ids); } static test_return_t udp_mixed_io_test(memcached_st *memc) { test_st mixed_io_ops [] ={ {"udp_set_test", 0, (test_callback_fn*)udp_set_test}, {"udp_set_too_big_test", 0, (test_callback_fn*)udp_set_too_big_test}, {"udp_delete_test", 0, (test_callback_fn*)udp_delete_test}, {"udp_verbosity_test", 0, (test_callback_fn*)udp_verbosity_test}, {"udp_quit_test", 0, (test_callback_fn*)udp_quit_test}, #if 0 {"udp_flush_test", 0, (test_callback_fn*)udp_flush_test}, #endif {"udp_incr_test", 0, (test_callback_fn*)udp_incr_test}, {"udp_decr_test", 0, (test_callback_fn*)udp_decr_test}, {"udp_version_test", 0, (test_callback_fn*)udp_version_test} }; for (size_t x= 0; x < 500; x++) { test_st current_op= mixed_io_ops[(random() % 8)]; test_compare(TEST_SUCCESS, current_op.test_fn(memc)); } return TEST_SUCCESS; } test_st compatibility_TESTS[] ={ {"version", 0, (test_callback_fn*)version_TEST }, {"version", 0, (test_callback_fn*)verbosity_TEST }, {"memcached_get()", 0, (test_callback_fn*)memcached_get_TEST }, {"memcached_mget_execute_by_key()", 0, (test_callback_fn*)memcached_mget_execute_by_key_TEST }, {"memcached_stat()", 0, (test_callback_fn*)memcached_stat_TEST }, {0, 0, 0} }; test_st udp_setup_server_tests[] ={ {"set_udp_behavior_test", 0, (test_callback_fn*)set_udp_behavior_test}, {"add_tcp_server_udp_client_test", 0, (test_callback_fn*)add_tcp_server_udp_client_test}, {"add_udp_server_tcp_client_test", 0, (test_callback_fn*)add_udp_server_tcp_client_test}, {0, 0, 0} }; test_st upd_io_tests[] ={ {"udp_set_test", 0, (test_callback_fn*)udp_set_test}, {"udp_buffered_set_test", 0, (test_callback_fn*)udp_buffered_set_test}, {"udp_set_too_big_test", 0, (test_callback_fn*)udp_set_too_big_test}, {"udp_delete_test", 0, (test_callback_fn*)udp_delete_test}, {"udp_buffered_delete_test", 0, (test_callback_fn*)udp_buffered_delete_test}, {"udp_verbosity_test", 0, (test_callback_fn*)udp_verbosity_test}, {"udp_quit_test", 0, (test_callback_fn*)udp_quit_test}, {"udp_flush_test", 0, (test_callback_fn*)udp_flush_test}, {"udp_incr_test", 0, (test_callback_fn*)udp_incr_test}, {"udp_decr_test", 0, (test_callback_fn*)udp_decr_test}, {"udp_stat_test", 0, (test_callback_fn*)udp_stat_test}, {"udp_version_test", 0, (test_callback_fn*)udp_version_test}, {"udp_get_test", 0, (test_callback_fn*)udp_get_test}, {"udp_mixed_io_test", 0, (test_callback_fn*)udp_mixed_io_test}, {0, 0, 0} }; collection_st collection[] ={ {"udp_setup", (test_callback_fn*)init_udp, 0, udp_setup_server_tests}, {"compatibility", (test_callback_fn*)init_udp, 0, compatibility_TESTS}, {"udp_io", (test_callback_fn*)init_udp_valgrind, 0, upd_io_tests}, {"udp_binary_io", (test_callback_fn*)binary_init_udp, 0, upd_io_tests}, {0, 0, 0, 0} }; #include "tests/libmemcached_world.h" void get_world(Framework *world) { world->collections(collection); world->create((test_callback_create_fn*)world_create); world->destroy((test_callback_destroy_fn*)world_destroy); world->set_runner(new LibmemcachedRunner); } libmemcached-1.0.8/tests/hashkit_functions.cc0000664000076400007640000003254511753763014021613 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * libHashKit Functions Test * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include #include using namespace libtest; #include #include #include #include #include #include "tests/hash_results.h" static hashkit_st global_hashk; /** @brief hash_test_st is a structure we use in testing. It is currently empty. */ typedef struct hash_test_st hash_test_st; struct hash_test_st { bool _unused; }; static test_return_t init_test(void *) { hashkit_st hashk; hashkit_st *hashk_ptr; hashk_ptr= hashkit_create(&hashk); test_true(hashk_ptr); test_true(hashk_ptr == &hashk); test_false(hashkit_is_allocated(hashk_ptr)); hashkit_free(hashk_ptr); return TEST_SUCCESS; } static test_return_t allocation_test(void *) { hashkit_st *hashk_ptr; hashk_ptr= hashkit_create(NULL); test_true(hashk_ptr); test_true(hashkit_is_allocated(hashk_ptr)); hashkit_free(hashk_ptr); return TEST_SUCCESS; } static test_return_t clone_test(hashkit_st *hashk) { // First we make sure that the testing system is giving us what we expect. test_true(&global_hashk == hashk); // Second we test if hashk is even valid /* All null? */ { hashkit_st *hashk_ptr; hashk_ptr= hashkit_clone(NULL, NULL); test_true(hashk_ptr); test_true(hashkit_is_allocated(hashk_ptr)); hashkit_free(hashk_ptr); } /* Can we init from null? */ { hashkit_st *hashk_ptr; hashk_ptr= hashkit_clone(NULL, hashk); test_true(hashk_ptr); test_true(hashkit_is_allocated(hashk_ptr)); hashkit_free(hashk_ptr); } /* Can we init from struct? */ { hashkit_st declared_clone; hashkit_st *hash_clone; hash_clone= hashkit_clone(&declared_clone, NULL); test_true(hash_clone); test_true(hash_clone == &declared_clone); test_false(hashkit_is_allocated(hash_clone)); hashkit_free(hash_clone); } /* Can we init from struct? */ { hashkit_st declared_clone; hashkit_st *hash_clone; hash_clone= hashkit_clone(&declared_clone, hashk); test_true(hash_clone); test_true(hash_clone == &declared_clone); test_false(hashkit_is_allocated(hash_clone)); hashkit_free(hash_clone); } return TEST_SUCCESS; } static test_return_t one_at_a_time_run (hashkit_st *) { uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(one_at_a_time_values[x], libhashkit_one_at_a_time(*ptr, strlen(*ptr))); } return TEST_SUCCESS; } static test_return_t md5_run (hashkit_st *) { uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(md5_values[x], libhashkit_md5(*ptr, strlen(*ptr))); } return TEST_SUCCESS; } static test_return_t crc_run (hashkit_st *) { uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(crc_values[x], libhashkit_crc32(*ptr, strlen(*ptr))); } return TEST_SUCCESS; } static test_return_t fnv1_64_run (hashkit_st *) { test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_FNV1_64)); uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(fnv1_64_values[x], libhashkit_fnv1_64(*ptr, strlen(*ptr))); } return TEST_SUCCESS; } static test_return_t fnv1a_64_run (hashkit_st *) { test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_FNV1A_64)); uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(fnv1a_64_values[x], libhashkit_fnv1a_64(*ptr, strlen(*ptr))); } return TEST_SUCCESS; } static test_return_t fnv1_32_run (hashkit_st *) { uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(fnv1_32_values[x], libhashkit_fnv1_32(*ptr, strlen(*ptr))); } return TEST_SUCCESS; } static test_return_t fnv1a_32_run (hashkit_st *) { uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(fnv1a_32_values[x], libhashkit_fnv1a_32(*ptr, strlen(*ptr))); } return TEST_SUCCESS; } static test_return_t hsieh_run (hashkit_st *) { test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_HSIEH)); uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(hsieh_values[x], libhashkit_hsieh(*ptr, strlen(*ptr))); } return TEST_SUCCESS; } static test_return_t murmur_run (hashkit_st *) { test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_MURMUR)); #ifdef WORDS_BIGENDIAN (void)murmur_values; return TEST_SKIPPED; #else uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(murmur_values[x], libhashkit_murmur(*ptr, strlen(*ptr))); } return TEST_SUCCESS; #endif } static test_return_t jenkins_run (hashkit_st *) { uint32_t x; const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(jenkins_values[x], libhashkit_jenkins(*ptr, strlen(*ptr))); } return TEST_SUCCESS; } /** @brief now we list out the tests. */ test_st allocation[]= { {"init", 0, (test_callback_fn*)init_test}, {"create and free", 0, (test_callback_fn*)allocation_test}, {"clone", 0, (test_callback_fn*)clone_test}, {0, 0, 0} }; static test_return_t hashkit_digest_test(hashkit_st *hashk) { test_true(hashkit_digest(hashk, "a", sizeof("a"))); return TEST_SUCCESS; } static test_return_t hashkit_set_function_test(hashkit_st *hashk) { for (int algo= int(HASHKIT_HASH_DEFAULT); algo < int(HASHKIT_HASH_MAX); algo++) { uint32_t x; const char **ptr; uint32_t *list; test_skip(true, libhashkit_has_algorithm(static_cast(algo))); hashkit_return_t rc= hashkit_set_function(hashk, static_cast(algo)); test_compare_got(HASHKIT_SUCCESS, rc, hashkit_strerror(NULL, rc)); switch (algo) { case HASHKIT_HASH_DEFAULT: list= one_at_a_time_values; break; case HASHKIT_HASH_MD5: list= md5_values; break; case HASHKIT_HASH_CRC: list= crc_values; break; case HASHKIT_HASH_FNV1_64: list= fnv1_64_values; break; case HASHKIT_HASH_FNV1A_64: list= fnv1a_64_values; break; case HASHKIT_HASH_FNV1_32: list= fnv1_32_values; break; case HASHKIT_HASH_FNV1A_32: list= fnv1a_32_values; break; case HASHKIT_HASH_HSIEH: list= hsieh_values; break; case HASHKIT_HASH_MURMUR: list= murmur_values; break; case HASHKIT_HASH_JENKINS: list= jenkins_values; break; case HASHKIT_HASH_CUSTOM: case HASHKIT_HASH_MAX: default: list= NULL; break; } // Now we make sure we did set the hash correctly. if (list) { for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(list[x], hashkit_digest(hashk, *ptr, strlen(*ptr))); } } else { return TEST_FAILURE; } } return TEST_SUCCESS; } static uint32_t hash_test_function(const char *string, size_t string_length, void *) { return libhashkit_md5(string, string_length); } static test_return_t hashkit_set_custom_function_test(hashkit_st *hashk) { uint32_t x; const char **ptr; test_compare(HASHKIT_SUCCESS, hashkit_set_custom_function(hashk, hash_test_function, NULL)); for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { test_compare(md5_values[x], hashkit_digest(hashk, *ptr, strlen(*ptr))); } return TEST_SUCCESS; } static test_return_t hashkit_set_distribution_function_test(hashkit_st *hashk) { for (int algo= int(HASHKIT_HASH_DEFAULT); algo < int(HASHKIT_HASH_MAX); algo++) { hashkit_return_t rc= hashkit_set_distribution_function(hashk, static_cast(algo)); /* Hsieh is disabled most of the time for patent issues */ if (rc == HASHKIT_INVALID_ARGUMENT) continue; test_compare(HASHKIT_SUCCESS, rc); } return TEST_SUCCESS; } static test_return_t hashkit_set_custom_distribution_function_test(hashkit_st *hashk) { test_compare(HASHKIT_SUCCESS, hashkit_set_custom_distribution_function(hashk, hash_test_function, NULL)); return TEST_SUCCESS; } static test_return_t hashkit_get_function_test(hashkit_st *hashk) { for (int algo= int(HASHKIT_HASH_DEFAULT); algo < int(HASHKIT_HASH_MAX); algo++) { if (HASHKIT_HASH_CUSTOM) { continue; } test_skip(true, libhashkit_has_algorithm(static_cast(algo))); test_compare(HASHKIT_SUCCESS, hashkit_set_function(hashk, static_cast(algo))); test_compare(hashkit_get_function(hashk), algo); } return TEST_SUCCESS; } static test_return_t hashkit_compare_test(hashkit_st *hashk) { hashkit_st *clone= hashkit_clone(NULL, hashk); test_true(hashkit_compare(clone, hashk)); hashkit_free(clone); return TEST_SUCCESS; } test_st hashkit_st_functions[] ={ {"hashkit_digest", 0, (test_callback_fn*)hashkit_digest_test}, {"hashkit_set_function", 0, (test_callback_fn*)hashkit_set_function_test}, {"hashkit_set_custom_function", 0, (test_callback_fn*)hashkit_set_custom_function_test}, {"hashkit_get_function", 0, (test_callback_fn*)hashkit_get_function_test}, {"hashkit_set_distribution_function", 0, (test_callback_fn*)hashkit_set_distribution_function_test}, {"hashkit_set_custom_distribution_function", 0, (test_callback_fn*)hashkit_set_custom_distribution_function_test}, {"hashkit_compare", 0, (test_callback_fn*)hashkit_compare_test}, {0, 0, 0} }; static test_return_t libhashkit_digest_test(hashkit_st *) { test_true(libhashkit_digest("a", sizeof("a"), HASHKIT_HASH_DEFAULT)); return TEST_SUCCESS; } test_st library_functions[] ={ {"libhashkit_digest", 0, (test_callback_fn*)libhashkit_digest_test}, {0, 0, 0} }; test_st hash_tests[] ={ {"one_at_a_time", 0, (test_callback_fn*)one_at_a_time_run }, {"md5", 0, (test_callback_fn*)md5_run }, {"crc", 0, (test_callback_fn*)crc_run }, {"fnv1_64", 0, (test_callback_fn*)fnv1_64_run }, {"fnv1a_64", 0, (test_callback_fn*)fnv1a_64_run }, {"fnv1_32", 0, (test_callback_fn*)fnv1_32_run }, {"fnv1a_32", 0, (test_callback_fn*)fnv1a_32_run }, {"hsieh", 0, (test_callback_fn*)hsieh_run }, {"murmur", 0, (test_callback_fn*)murmur_run }, {"jenkis", 0, (test_callback_fn*)jenkins_run }, {0, 0, (test_callback_fn*)0} }; /* * The following test suite is used to verify that we don't introduce * regression bugs. If you want more information about the bug / test, * you should look in the bug report at * http://bugs.launchpad.net/libmemcached */ test_st regression[]= { {0, 0, 0} }; collection_st collection[] ={ {"allocation", 0, 0, allocation}, {"hashkit_st_functions", 0, 0, hashkit_st_functions}, {"library_functions", 0, 0, library_functions}, {"hashing", 0, 0, hash_tests}, {"regression", 0, 0, regression}, {0, 0, 0, 0} }; static void *world_create(libtest::server_startup_st&, test_return_t& error) { hashkit_st *hashk_ptr= hashkit_create(&global_hashk); if (hashk_ptr != &global_hashk) { error= TEST_FAILURE; return NULL; } if (hashkit_is_allocated(hashk_ptr) == true) { error= TEST_FAILURE; return NULL; } return hashk_ptr; } static bool world_destroy(void *object) { hashkit_st *hashk= (hashkit_st *)object; // Did we get back what we expected? test_true(hashkit_is_allocated(hashk) == false); hashkit_free(&global_hashk); return TEST_SUCCESS; } void get_world(Framework *world) { world->collections(collection); world->create(world_create); world->destroy(world_destroy); } libmemcached-1.0.8/tests/memcapable.cc0000664000076400007640000000674611753763014020162 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Test memcapable * * Copyright (C) 2011 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. * */ /* Test that we are cycling the servers we are creating during testing. */ #include #include #include using namespace libtest; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif static std::string executable; static test_return_t quiet_test(void *) { const char *args[]= { "-q", 0 }; test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t help_test(void *) { const char *args[]= { "-h", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t ascii_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "%d", int(default_port())); const char *args[]= { "-p", buffer, " -a ", 0 }; test_true(exec_cmdline(executable, args, true) <= EXIT_FAILURE); return TEST_SUCCESS; } static test_return_t binary_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "%d", int(default_port())); const char *args[]= { "-p", buffer, " -b ", 0 }; test_true(exec_cmdline(executable, args, true) <= EXIT_FAILURE); return TEST_SUCCESS; } test_st memcapable_tests[] ={ {"--quiet", 0, quiet_test}, {"-h", 0, help_test}, {"-a, ascii", 0, ascii_test}, {"-b, binary", 0, binary_test}, {0, 0, 0} }; collection_st collection[] ={ {"memcapable", 0, 0, memcapable_tests }, {0, 0, 0, 0} }; static void *world_create(server_startup_st& servers, test_return_t& error) { if (HAVE_MEMCACHED_BINARY == 0) { error= TEST_SKIPPED; return NULL; } if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == false) { error= TEST_FAILURE; } return &servers; } void get_world(Framework *world) { executable= "./clients/memcapable"; world->collections(collection); world->create(world_create); } libmemcached-1.0.8/tests/failure.cc0000664000076400007640000001677711753763014017530 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 /* C++ interface test */ #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace memcache; using namespace libtest; Framework *global_framework= NULL; static test_return_t shutdown_servers(memcached_st *memc) { test_skip_valgrind(); test_compare(memcached_server_count(memc), 1U); // Disable a single server, just the first global_framework->servers().shutdown(0); return TEST_SUCCESS; } static test_return_t add_shutdown_servers(memcached_st *memc) { test_skip_valgrind(); while (memcached_server_count(memc) < 2) { const char *argv[1]= { "add_shutdown_server" }; test_true(global_framework->servers().start_socket_server("memcached", libtest::default_port(), 1, argv)); test_compare(MEMCACHED_SUCCESS, memcached_server_add(memc, "localhost", libtest::default_port())); } // Disable a single server, just the first global_framework->servers().shutdown(0); return TEST_SUCCESS; } static test_return_t restart_servers(memcached_st *) { // Restart the servers global_framework->servers().restart(); return TEST_SUCCESS; } static test_return_t cull_TEST(memcached_st *memc) { uint32_t count= memcached_server_count(memc); // Do not do this in your code, it is not supported. memc->servers[0].options.is_dead= true; memc->state.is_time_for_rebuild= true; uint32_t new_count= memcached_server_count(memc); test_compare(count, new_count); return TEST_SUCCESS; } static test_return_t MEMCACHED_SERVER_TEMPORARILY_DISABLED_TEST(memcached_st *memc) { test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 30)); test_compare_got(MEMCACHED_CONNECTION_FAILURE, memcached_set(memc, test_literal_param("foo"), NULL, 0, time_t(0), uint32_t(0)), memcached_last_error_message(memc)); /* Setting server_failure_counter==0 should not influence the timeout that we set above, since we check the timeout that is created by the failure before we check how many times a server has failed. */ test_compare(MEMCACHED_SERVER_TEMPORARILY_DISABLED, memcached_set(memc, test_literal_param("foo"), NULL, 0, time_t(0), uint32_t(0))); return TEST_SUCCESS; } static test_return_t MEMCACHED_SERVER_TEMPORARILY_DISABLED_to_success_TEST(memcached_st *memc) { test_compare_got(MEMCACHED_CONNECTION_FAILURE, memcached_set(memc, test_literal_param("foo"), NULL, 0, time_t(0), uint32_t(0)), memcached_last_error_message(memc)); /* Setting server_failure_counter==0 should not influence the timeout that we set above, since we check the timeout that is created by the failure before we check how many times a server has failed. */ test_compare(MEMCACHED_SERVER_TEMPORARILY_DISABLED, memcached_set(memc, test_literal_param("foo"), NULL, 0, time_t(0), uint32_t(0))); global_framework->servers().restart(); memcached_return_t ret; do { libtest::dream(3, 0); ret= memcached_set(memc, test_literal_param("foo"), NULL, 0, time_t(0), uint32_t(0)); } while (ret == MEMCACHED_SERVER_TEMPORARILY_DISABLED); test_compare_got(MEMCACHED_SUCCESS, ret, memcached_last_error_message(memc)); return TEST_SUCCESS; } static test_return_t MEMCACHED_SERVER_MARKED_DEAD_TEST(memcached_st *memc) { test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 30)); test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS, true)); memcached_return_t ret; do { ret= memcached_set(memc, test_literal_param("foo"), NULL, 0, time_t(0), uint32_t(0)); } while (ret == MEMCACHED_SUCCESS or ret == MEMCACHED_CONNECTION_FAILURE); test_compare(MEMCACHED_SERVER_TEMPORARILY_DISABLED, ret); do { libtest::dream(3, 0); ret= memcached_set(memc, test_literal_param("foo"), NULL, 0, time_t(0), uint32_t(0)); } while (ret == MEMCACHED_SERVER_TEMPORARILY_DISABLED or ret == MEMCACHED_SUCCESS); test_compare_got(MEMCACHED_SERVER_MARKED_DEAD, ret, memcached_last_error_message(memc)); return TEST_SUCCESS; } test_st cull_TESTS[] ={ { "cull servers", true, (test_callback_fn*)cull_TEST }, { 0, 0, 0 } }; test_st server_temporarily_disabled_TESTS[] ={ { "memcached_set(MEMCACHED_SERVER_TEMPORARILY_DISABLED)", true, (test_callback_fn*)MEMCACHED_SERVER_TEMPORARILY_DISABLED_TEST }, { "memcached_set(MEMCACHED_SERVER_TEMPORARILY_DISABLED -> MEMCACHED_SUCCESS)", true, (test_callback_fn*)MEMCACHED_SERVER_TEMPORARILY_DISABLED_to_success_TEST }, { 0, 0, 0 } }; test_st server_permanently_disabled_TESTS[] ={ { "memcached_set(MEMCACHED_SERVER_MARKED_DEAD)", true, (test_callback_fn*)MEMCACHED_SERVER_MARKED_DEAD_TEST }, { 0, 0, 0 } }; collection_st collection[] ={ { "cull", (test_callback_fn*)shutdown_servers, (test_callback_fn*)restart_servers, cull_TESTS }, { "server failed", (test_callback_fn*)shutdown_servers, (test_callback_fn*)restart_servers, server_temporarily_disabled_TESTS }, { "server eject", (test_callback_fn*)add_shutdown_servers, (test_callback_fn*)restart_servers, server_permanently_disabled_TESTS }, { 0, 0, 0, 0 } }; #include "tests/libmemcached_world.h" void get_world(Framework *world) { world->servers().set_servers_to_run(1); world->collections(collection); world->create((test_callback_create_fn*)world_create); world->destroy((test_callback_destroy_fn*)world_destroy); world->set_runner(new LibmemcachedRunner); global_framework= world; } libmemcached-1.0.8/tests/replication.h0000664000076400007640000000424111753573717020244 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached client and server library. * * Copyright (C) 2011 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. * */ #pragma once test_return_t replication_set_test(memcached_st *memc); test_return_t replication_get_test(memcached_st *memc); test_return_t replication_mget_test(memcached_st *memc); test_return_t replication_delete_test(memcached_st *memc); test_return_t replication_randomize_mget_test(memcached_st *memc); test_return_t replication_randomize_mget_fail_test(memcached_st *memc); test_return_t replication_miss_test(memcached_st *memc); test_return_t check_replication_sanity_TEST(memcached_st*); libmemcached-1.0.8/tests/memexist.cc0000664000076400007640000001115511753763014017715 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Test memexist * * Copyright (C) 2011 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. * */ /* Test that we are cycling the servers we are creating during testing. */ #include #include #include #include using namespace libtest; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif static std::string executable("./clients/memexist"); static test_return_t help_test(void *) { const char *args[]= { "--help", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t exist_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); const char *args[]= { buffer, "foo", 0 }; memcached_st *memc= memcached(buffer, strlen(buffer)); test_true(memc); test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("foo"), 0, 0, 0, 0)); memcached_return_t rc; test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_SUCCESS, rc); test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_SUCCESS, rc); memcached_free(memc); return TEST_SUCCESS; } static test_return_t NOT_FOUND_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); const char *args[]= { buffer, "foo", 0 }; memcached_st *memc= memcached(buffer, strlen(buffer)); test_true(memc); test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0)); memcached_return_t rc; test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_NOTFOUND, rc); test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc)); test_compare(MEMCACHED_NOTFOUND, rc); memcached_free(memc); return TEST_SUCCESS; } static test_return_t check_version(void*) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port())); memcached_st *memc= memcached(buffer, strlen(buffer)); test_true(memc); test_return_t result= TEST_SUCCESS; if (libmemcached_util_version_check(memc, 1, 4, 8) == false) { result= TEST_SKIPPED; } memcached_free(memc); return result; } test_st memexist_tests[] ={ {"--help", true, help_test }, {"exist(FOUND)", true, exist_test }, {"exist(NOT_FOUND)", true, NOT_FOUND_test }, {0, 0, 0} }; collection_st collection[] ={ {"memexist", check_version, 0, memexist_tests }, {0, 0, 0, 0} }; static void *world_create(server_startup_st& servers, test_return_t& error) { if (HAVE_MEMCACHED_BINARY == 0) { error= TEST_SKIPPED; return NULL; } if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == false) { error= TEST_FAILURE; } return &servers; } void get_world(Framework *world) { world->collections(collection); world->create(world_create); } libmemcached-1.0.8/tests/cli.am0000664000076400007640000000733711753573717016661 0ustar00brianbrian00000000000000# vim:ft=automake # Copyright (C) 2012 Data Differential # All rights reserved. # # Use and distribution licensed under the BSD license. See # the COPYING file in the parent directory for full text. # # included from Top Level Makefile.am # All paths should be given relative to the root tests_memcapable_SOURCES= tests/memcapable.cc tests_memcapable_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_memcapable_DEPENDENCIES= libtest/libtest.la $(TESTS_LDADDS) clients/memcapable tests_memcapable_LDADD= libtest/libtest.la $(TESTS_LDADDS) check_PROGRAMS+= tests/memcapable noinst_PROGRAMS+= tests/memcapable tests_memstat_SOURCES= tests/memstat.cc tests_memstat_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_memstat_DEPENDENCIES= libtest/libtest.la $(TESTS_LDADDS) clients/memstat tests_memstat_LDADD= libtest/libtest.la $(TESTS_LDADDS) check_PROGRAMS+= tests/memstat noinst_PROGRAMS+= tests/memstat tests_memcp_SOURCES= tests/memcp.cc tests_memcp_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_memcp_DEPENDENCIES= libtest/libtest.la $(TESTS_LDADDS) clients/memcp tests_memcp_LDADD= libtest/libtest.la $(TESTS_LDADDS) check_PROGRAMS+= tests/memcp noinst_PROGRAMS+= tests/memcp tests_memflush_SOURCES= tests/memflush.cc tests_memflush_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_memflush_DEPENDENCIES= libtest/libtest.la $(TESTS_LDADDS) clients/memflush tests_memflush_LDADD= libtest/libtest.la $(TESTS_LDADDS) check_PROGRAMS+= tests/memflush noinst_PROGRAMS+= tests/memflush tests_memrm_SOURCES= tests/memrm.cc tests_memrm_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_memrm_DEPENDENCIES= libtest/libtest.la $(TESTS_LDADDS) clients/memrm tests_memrm_LDADD= libtest/libtest.la $(TESTS_LDADDS) check_PROGRAMS+= tests/memrm noinst_PROGRAMS+= tests/memrm tests_memexist_SOURCES= tests/memexist.cc tests_memexist_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_memexist_DEPENDENCIES= libtest/libtest.la $(TESTS_LDADDS) clients/memexist tests_memexist_LDADD= libtest/libtest.la $(TESTS_LDADDS) check_PROGRAMS+= tests/memexist noinst_PROGRAMS+= tests/memexist tests_memtouch_SOURCES= tests/memtouch.cc tests_memtouch_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_memtouch_DEPENDENCIES= libtest/libtest.la $(TESTS_LDADDS) clients/memtouch tests_memtouch_LDADD= libtest/libtest.la $(TESTS_LDADDS) check_PROGRAMS+= tests/memtouch noinst_PROGRAMS+= tests/memtouch tests_memcat_SOURCES= tests/memcat.cc tests_memcat_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_memcat_DEPENDENCIES= libtest/libtest.la $(TESTS_LDADDS) clients/memcat tests_memcat_LDADD= libtest/libtest.la $(TESTS_LDADDS) check_PROGRAMS+= tests/memcat noinst_PROGRAMS+= tests/memcat tests_memerror_SOURCES= tests/memerror.cc tests_memerror_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_memerror_DEPENDENCIES= libtest/libtest.la $(TESTS_LDADDS) clients/memerror tests_memerror_LDADD= libtest/libtest.la $(TESTS_LDADDS) check_PROGRAMS+= tests/memerror noinst_PROGRAMS+= tests/memerror tests_memslap_SOURCES= tests/memslap.cc tests_memslap_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_memslap_DEPENDENCIES= libtest/libtest.la $(TESTS_LDADDS) clients/memslap tests_memslap_LDADD= libtest/libtest.la $(TESTS_LDADDS) check_PROGRAMS+= tests/memslap noinst_PROGRAMS+= tests/memslap tests_memdump_SOURCES= tests/memdump.cc tests_memdump_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_memdump_DEPENDENCIES= libtest/libtest.la $(TESTS_LDADDS) clients/memdump tests_memdump_LDADD= libtest/libtest.la $(TESTS_LDADDS) check_PROGRAMS+= tests/memdump noinst_PROGRAMS+= tests/memdump test-memstat: tests/memstat tests/memstat test-memerror: tests/memerror tests/memerror test-memtouch: tests/memtouch tests/memtouch valgrind-memerror: tests/memerror @$(VALGRIND_COMMAND) tests/memerror valgrind-memtouch: tests/memtouch @$(VALGRIND_COMMAND) tests/memtouch libmemcached-1.0.8/tests/memflush.cc0000664000076400007640000000630611753763014017704 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Test memflush * * Copyright (C) 2011 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. * */ /* Test that we are cycling the servers we are creating during testing. */ #include #include #include using namespace libtest; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif static std::string executable; static test_return_t quiet_test(void *) { const char *args[]= { "--quiet", 0 }; test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t help_test(void *) { const char *args[]= { "--help", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t server_test(void *) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); const char *args[]= { buffer, 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } test_st memflush_tests[] ={ {"--quiet", true, quiet_test }, {"--help", true, help_test }, {"--server", true, server_test }, {0, 0, 0} }; collection_st collection[] ={ {"memflush", 0, 0, memflush_tests }, {0, 0, 0, 0} }; static void *world_create(server_startup_st& servers, test_return_t& error) { if (HAVE_MEMCACHED_BINARY == 0) { error= TEST_SKIPPED; return NULL; } if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == 0) { error= TEST_FAILURE; } return &servers; } void get_world(Framework *world) { executable= "./clients/memflush"; world->collections(collection); world->create(world_create); } libmemcached-1.0.8/tests/string.h0000664000076400007640000000425211753573717017243 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached client and server library. * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBTEST_LOCAL test_return_t string_static_null(void *); LIBTEST_LOCAL test_return_t string_alloc_null(void *); LIBTEST_LOCAL test_return_t string_alloc_with_size(void *); LIBTEST_LOCAL test_return_t string_alloc_with_size_toobig(void *); LIBTEST_LOCAL test_return_t string_alloc_append(void *); LIBTEST_LOCAL test_return_t string_alloc_append_toobig(void *); LIBTEST_LOCAL test_return_t string_alloc_append_multiple(void *); #ifdef __cplusplus } #endif libmemcached-1.0.8/tests/libmemcached_world.h0000664000076400007640000000632411753573717021543 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * Copyright (C) 2012 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #include "tests/libmemcached_test_container.h" static void *world_create(libtest::server_startup_st& servers, test_return_t& error) { if (HAVE_MEMCACHED_BINARY == 0) { error= TEST_SKIPPED; return NULL; } if (servers.sasl() and (LIBMEMCACHED_WITH_SASL_SUPPORT == 0 or MEMCACHED_SASL_BINARY == 0)) { error= TEST_SKIPPED; return NULL; } // Assume we are running under valgrind, and bail if (servers.sasl() and getenv("TESTS_ENVIRONMENT")) { error= TEST_SKIPPED; return NULL; } for (uint32_t x= 0; x < servers.servers_to_run(); x++) { in_port_t port= libtest::get_free_port(); if (servers.sasl()) { if (server_startup(servers, "memcached-sasl", port, 0, NULL) == false) { fatal_message("Could not start memcached-sasl"); } } else { if (server_startup(servers, "memcached", port, 0, NULL) == false) { fatal_message("Could not start memcached"); } } } libmemcached_test_container_st *global_container= new libmemcached_test_container_st(servers); return global_container; } static bool world_destroy(void *object) { libmemcached_test_container_st *container= (libmemcached_test_container_st *)object; #if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT if (LIBMEMCACHED_WITH_SASL_SUPPORT) { sasl_done(); } #endif delete container; return TEST_SUCCESS; } typedef test_return_t (*libmemcached_test_callback_fn)(memcached_st *); #include "tests/runner.h" libmemcached-1.0.8/tests/server_add.h0000664000076400007640000000345111753573717020053 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Client and Server * * Copyright (C) 2011 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. * */ #pragma once test_return_t memcached_server_add_null_test(memcached_st*); test_return_t memcached_server_add_empty_test(memcached_st*); libmemcached-1.0.8/tests/parser.am0000664000076400007640000000142411753573717017375 0ustar00brianbrian00000000000000# vim:ft=automake # Copyright (C) 2012 Data Differential # All rights reserved. # # Use and distribution licensed under the BSD license. See # the COPYING file in the parent directory for full text. # # included from Top Level Makefile.am # All paths should be given relative to the root noinst_HEADERS+= tests/libmemcached-1.0/parser.h tests_parser_SOURCES= tests_parser_CXXFLAGS= tests_parser_DEPENDENCIES= tests_parser_LDADD= tests_parser_SOURCES+= tests/parser.cc tests_parser_CXXFLAGS+= $(AM_CXXFLAGS) $(NO_EFF_CXX) tests_parser_DEPENDENCIES+= $(TESTS_LDADDS) tests_parser_LDADD+= $(tests_parser_DEPENDENCIES) check_PROGRAMS+= tests/parser noinst_PROGRAMS+= tests/parser test-parser: tests/parser @tests/parser valgrind-parser: tests/parser $(VALGRIND_COMMAND) tests/parser libmemcached-1.0.8/example/0000775000076400007640000000000011757025120016032 5ustar00brianbrian00000000000000libmemcached-1.0.8/example/byteorder.cc0000664000076400007640000000502711753573717020364 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include #include #include /* Byte swap a 64-bit number. */ #ifndef swap64 static inline uint64_t swap64(uint64_t in) { #ifndef WORDS_BIGENDIAN /* Little endian, flip the bytes around until someone makes a faster/better * way to do this. */ uint64_t rv= 0; for (uint8_t x= 0; x < 8; x++) { rv= (rv << 8) | (in & 0xff); in >>= 8; } return rv; #else /* big-endian machines don't need byte swapping */ return in; #endif // WORDS_BIGENDIAN } #endif #ifdef HAVE_HTONLL uint64_t example_ntohll(uint64_t value) { return ntohll(value); } uint64_t example_htonll(uint64_t value) { return htonll(value); } #else // HAVE_HTONLL uint64_t example_ntohll(uint64_t value) { return swap64(value); } uint64_t example_htonll(uint64_t value) { return swap64(value); } #endif // HAVE_HTONLL libmemcached-1.0.8/example/include.am0000664000076400007640000000124611753573717020017 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root if HAVE_LIBEVENT noinst_PROGRAMS += example/memcached_light endif noinst_HEADERS+= \ example/byteorder.h \ example/memcached_light.h \ example/storage.h example_memcached_light_SOURCES= \ example/byteorder.cc \ example/interface_v0.cc \ example/interface_v1.cc \ example/memcached_light.cc \ util/daemon.cc \ util/pidfile.cc example_memcached_light_LDADD= libmemcached/libmemcachedprotocol.la \ $(LIBEVENT_LDFLAGS) example_memcached_light_SOURCES+= example/storage.cc include example/t/include.am libmemcached-1.0.8/example/t/0000775000076400007640000000000011757025120016275 5ustar00brianbrian00000000000000libmemcached-1.0.8/example/t/include.am0000664000076400007640000000302211753573717020254 0ustar00brianbrian00000000000000# vim:ft=automake # Copyright (C) 2012 Data Differential # All rights reserved. # # Use and distribution licensed under the BSD license. See # the COPYING file in the parent directory for full text. # # included from Top Level Makefile.am # All paths should be given relative to the root MEMCACHED_LIGHT_TESTS_LDADDS= \ libmemcached/libmemcached.la \ libmemcached/libmemcachedutil.la \ libtest/libtest.la example_t_memcached_light_SOURCES= example_t_memcached_light_LDADD= example_t_memcached_light_SOURCES+= example/t/memcached_light.cc example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/memcached_get.cc example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/print.cc example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/setup_and_teardowns.cc example_t_memcached_light_CXXFLAGS = $(AM_CXXFLAGS) example_t_memcached_light_DEPENDENCIES= $(MEMCACHED_LIGHT_TESTS_LDADDS) example/memcached_light example_t_memcached_light_LDADD+= $(MEMCACHED_LIGHT_TESTS_LDADDS) example_t_memcached_light_LDADD+= $(LIBUUID_LDFLAGS) check_PROGRAMS+= example/t/memcached_light noinst_PROGRAMS+= example/t/memcached_light test-memcached_light: example/t/memcached_light example/memcached_light @example/t/memcached_light gdb-memcached_light: example/t/memcached_light example/memcached_light @$(DEBUG_COMMAND) example/t/memcached_light valgrind-memcached_light: example/t/memcached_light example/memcached_light $(VALGRIND_COMMAND) example/t/memcached_light libmemcached-1.0.8/example/t/memcached_light.cc0000664000076400007640000001423611753763014021716 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Test memcat * * Copyright (C) 2011 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. * */ /* Test that we are cycling the servers we are creating during testing. */ #include #include #include #include "tests/libmemcached-1.0/memcached_get.h" using namespace libtest; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif static std::string executable("example/memcached_light"); static test_return_t help_TEST(void *) { const char *args[]= { "--help", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t verbose_TEST(void *) { const char *args[]= { "--help", "--verbose", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t daemon_TEST(void *) { const char *args[]= { "--help", "--daemon", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t protocol_TEST(void *) { const char *args[]= { "--help", "--protocol", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t version_TEST(void *) { const char *args[]= { "--help", "--version", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t port_TEST(void *) { const char *args[]= { "--help", "--port=9090", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t pid_file_TEST(void *) { const char *args[]= { "--help", "--pid-file=/tmp/foo.pid", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t log_file_TEST(void *) { const char *args[]= { "--help", "--log-file=/tmp/foo.log", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } static test_return_t max_connections_file_TEST(void *) { const char *args[]= { "--help", "--max-connections=/tmp/foo.max_connections", 0 }; test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true)); return TEST_SUCCESS; } typedef test_return_t (*libmemcached_test_callback_fn)(memcached_st *); static test_return_t _runner_default(libmemcached_test_callback_fn func, void *object) { if (func) { test_true(object); test_return_t ret; try { ret= func((memcached_st*)object); } catch (std::exception& e) { libtest::Error << e.what(); return TEST_FAILURE; } return ret; } return TEST_SUCCESS; } class MemcachedLightRunner : public libtest::Runner { public: test_return_t run(test_callback_fn* func, void *object) { return _runner_default(libmemcached_test_callback_fn(func), object); } }; test_st cmdline_option_TESTS[] ={ {"--help", true, help_TEST }, {"--verbose", true, verbose_TEST }, {"--daemon", true, daemon_TEST }, {"--protocol", true, protocol_TEST }, {"--version", true, version_TEST }, {"--port", true, port_TEST }, {"--pid-file", true, pid_file_TEST }, {"--log-file", true, log_file_TEST }, {"--max-connections", true, max_connections_file_TEST }, {0, 0, 0} }; /* Clean the server before beginning testing */ test_st basic_TESTS[] ={ #if 0 {"memcached_get()", true, (test_callback_fn*)get_test }, {"memcached_get() test 2", false, (test_callback_fn*)get_test2 }, {"memcached_get() test 3", false, (test_callback_fn*)get_test3 }, {"memcached_get() test 4", false, (test_callback_fn*)get_test4 }, {"memcached_get() test 5", false, (test_callback_fn*)get_test5 }, #endif {0, 0, 0} }; collection_st collection[] ={ {"command line options", 0, 0, cmdline_option_TESTS }, {"basic", 0, 0, basic_TESTS }, {0, 0, 0, 0} }; static void *world_create(server_startup_st& servers, test_return_t& error) { if (HAVE_MEMCACHED_LIGHT_BINARY == 0) { error= TEST_SKIPPED; return NULL; } if (server_startup(servers, "memcached-light", libtest::default_port(), 0, NULL) == 0) { error= TEST_FAILURE; } char buffer[1024]; int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(libtest::default_port())); fatal_assert(length > 0); memcached_st *memc= memcached(buffer, length); fatal_assert(memc); return (void*)memc; } static bool world_destroy(void *object) { memcached_st *memc= (memcached_st*)object; memcached_free(memc); return TEST_SUCCESS; } void get_world(Framework *world) { world->create(world_create); world->destroy(world_destroy); world->collections(collection); world->set_runner(new MemcachedLightRunner); } libmemcached-1.0.8/example/interface_v0.cc0000664000076400007640000005536411753573717020743 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /** * This file contains an implementation of the callback interface for level 0 * in the protocol library. You might want to have your copy of the protocol * specification next to your coffee ;-) */ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include "example/memcached_light.h" #include "example/storage.h" #include "util/log.hpp" using namespace datadifferential; static util::log_info_st *log_file= NULL; static protocol_binary_response_status noop_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { protocol_binary_response_no_extras response; memset(&response, 0, sizeof(protocol_binary_response_no_extras)); response.message.header.response.magic= PROTOCOL_BINARY_RES; response.message.header.response.opcode= PROTOCOL_BINARY_CMD_NOOP; response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); response.message.header.response.opaque= header->request.opaque; return response_handler(cookie, header, (protocol_binary_response_header*)&response); } static protocol_binary_response_status quit_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { protocol_binary_response_no_extras response; memset(&response, 0, sizeof(protocol_binary_response_no_extras)); response.message.header.response.magic= PROTOCOL_BINARY_RES; response.message.header.response.opcode= PROTOCOL_BINARY_CMD_QUIT; response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); response.message.header.response.opaque= header->request.opaque; if (header->request.opcode == PROTOCOL_BINARY_CMD_QUIT) { response_handler(cookie, header, (protocol_binary_response_header*)&response); } /* I need a better way to signal to close the connection */ return PROTOCOL_BINARY_RESPONSE_EINTERNAL; } static protocol_binary_response_status get_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { uint8_t opcode= header->request.opcode; union protocol_binary_response_get_un { protocol_binary_response_get response; char buffer[4096]; }; protocol_binary_response_get_un msg; memset(&msg, 0, sizeof(protocol_binary_response_get_un)); msg.response.message.header.response.magic= PROTOCOL_BINARY_RES; msg.response.message.header.response.opcode= opcode; msg.response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); msg.response.message.header.response.opaque= header->request.opaque; struct item *item= get_item(header + 1, ntohs(header->request.keylen)); if (item) { msg.response.message.body.flags= htonl(item->flags); char *ptr= (char*)(msg.response.bytes + sizeof(*header) + 4); uint32_t bodysize= 4; msg.response.message.header.response.cas= example_htonll(item->cas); if (opcode == PROTOCOL_BINARY_CMD_GETK || opcode == PROTOCOL_BINARY_CMD_GETKQ) { memcpy(ptr, item->key, item->nkey); msg.response.message.header.response.keylen= htons((uint16_t)item->nkey); ptr += item->nkey; bodysize += (uint32_t)item->nkey; } memcpy(ptr, item->data, item->size); bodysize += (uint32_t)item->size; msg.response.message.header.response.bodylen= htonl(bodysize); msg.response.message.header.response.extlen= 4; release_item(item); return response_handler(cookie, header, (protocol_binary_response_header*)&msg); } else if (opcode == PROTOCOL_BINARY_CMD_GET || opcode == PROTOCOL_BINARY_CMD_GETK) { msg.response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_ENOENT); return response_handler(cookie, header, (protocol_binary_response_header*)&msg); } /* Q shouldn't report a miss ;-) */ return PROTOCOL_BINARY_RESPONSE_SUCCESS; } static protocol_binary_response_status delete_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { size_t keylen= ntohs(header->request.keylen); char *key= ((char*)header) + sizeof(*header); protocol_binary_response_no_extras response; memset(&response, 0, sizeof(protocol_binary_response_no_extras)); response.message.header.response.magic= PROTOCOL_BINARY_RES; response.message.header.response.opcode= header->request.opcode; response.message.header.response.opaque= header->request.opaque; if (delete_item(key, keylen) == false) { log_file->write(util::VERBOSE_NOTICE, "%s not found: %.*s", __func__, keylen, key); response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_ENOENT); return response_handler(cookie, header, (protocol_binary_response_header*)&response); } else if (header->request.opcode == PROTOCOL_BINARY_CMD_DELETE) { log_file->write(util::VERBOSE_NOTICE, "%s not found: %.*s", __func__, keylen, key); /* DELETEQ doesn't want success response */ response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); return response_handler(cookie, header, (protocol_binary_response_header*)&response); } log_file->write(util::VERBOSE_NOTICE, "%s deleted: %.*s", __func__, keylen, key); return PROTOCOL_BINARY_RESPONSE_SUCCESS; } static protocol_binary_response_status flush_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { uint8_t opcode= header->request.opcode; /* @fixme sett inn when! */ flush(0); if (opcode == PROTOCOL_BINARY_CMD_FLUSH) { protocol_binary_response_no_extras response; memset(&response, 0, sizeof(protocol_binary_response_no_extras)); response.message.header.response.magic= PROTOCOL_BINARY_RES; response.message.header.response.opcode= opcode; response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); response.message.header.response.opaque= header->request.opaque; return response_handler(cookie, header, (protocol_binary_response_header*)&response); } return PROTOCOL_BINARY_RESPONSE_SUCCESS; } static protocol_binary_response_status arithmetic_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { protocol_binary_request_incr *req= (protocol_binary_request_incr*)header; protocol_binary_response_incr response; memset(&response, 0, sizeof(protocol_binary_response_incr)); response.message.header.response.magic= PROTOCOL_BINARY_RES; response.message.header.response.opcode= header->request.opcode; response.message.header.response.opaque= header->request.opaque; uint16_t keylen= ntohs(header->request.keylen); uint64_t initial= example_ntohll(req->message.body.initial); uint64_t delta= example_ntohll(req->message.body.delta); uint32_t expiration= ntohl(req->message.body.expiration); uint32_t flags= 0; void *key= req->bytes + sizeof(req->bytes); protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; uint64_t value= initial; struct item *item= get_item(key, keylen); if (item != NULL) { if (header->request.opcode == PROTOCOL_BINARY_CMD_INCREMENT || header->request.opcode == PROTOCOL_BINARY_CMD_INCREMENTQ) { value= (*(uint64_t*)item->data) + delta; } else { if (delta > *(uint64_t*)item->data) { value= 0; } else { value= *(uint64_t*)item->data - delta; } } expiration= (uint32_t)item->exp; flags= item->flags; release_item(item); delete_item(key, keylen); } item= create_item(key, keylen, NULL, sizeof(value), flags, (time_t)expiration); if (item == NULL) { rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; } else { memcpy(item->data, &value, sizeof(value)); put_item(item); } response.message.header.response.status= htons(rval); if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS) { response.message.header.response.bodylen= ntohl(8); response.message.body.value= example_ntohll((*(uint64_t*)item->data)); response.message.header.response.cas= example_ntohll(item->cas); release_item(item); if (header->request.opcode == PROTOCOL_BINARY_CMD_INCREMENTQ || header->request.opcode == PROTOCOL_BINARY_CMD_DECREMENTQ) { return PROTOCOL_BINARY_RESPONSE_SUCCESS; } } return response_handler(cookie, header, (protocol_binary_response_header*)&response); } static protocol_binary_response_status version_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { const char *versionstring= "1.0.0"; union protocol_binary_response_header_un { protocol_binary_response_header packet; char buffer[256]; }; protocol_binary_response_header_un response; memset(&response, 0, sizeof(protocol_binary_response_header_un)); response.packet.response.magic= PROTOCOL_BINARY_RES; response.packet.response.opcode= PROTOCOL_BINARY_CMD_VERSION; response.packet.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); response.packet.response.opaque= header->request.opaque; response.packet.response.cas= 0; response.packet.response.bodylen= htonl((uint32_t)strlen(versionstring)); assert(sizeof(protocol_binary_response_header) +strlen(versionstring) <= 256); memcpy(response.buffer + sizeof(protocol_binary_response_header), versionstring, strlen(versionstring)); return response_handler(cookie, header, (protocol_binary_response_header*)&response); } static protocol_binary_response_status concat_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; uint16_t keylen= ntohs(header->request.keylen); uint64_t cas= example_ntohll(header->request.cas); void *key= header + 1; uint32_t vallen= ntohl(header->request.bodylen) - keylen; void *val= (char*)key + keylen; struct item *item= get_item(key, keylen); struct item *nitem= NULL; if (item == NULL) { rval= PROTOCOL_BINARY_RESPONSE_KEY_ENOENT; } else if (cas != 0 && cas != item->cas) { rval= PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; } else if ((nitem= create_item(key, keylen, NULL, item->size + vallen, item->flags, item->exp)) == NULL) { release_item(item); rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; } else { if (header->request.opcode == PROTOCOL_BINARY_CMD_APPEND || header->request.opcode == PROTOCOL_BINARY_CMD_APPENDQ) { memcpy(nitem->data, item->data, item->size); memcpy(((char*)(nitem->data)) + item->size, val, vallen); } else { memcpy(nitem->data, val, vallen); memcpy(((char*)(nitem->data)) + vallen, item->data, item->size); } release_item(item); delete_item(key, keylen); put_item(nitem); cas= nitem->cas; release_item(nitem); if (header->request.opcode == PROTOCOL_BINARY_CMD_APPEND || header->request.opcode == PROTOCOL_BINARY_CMD_PREPEND) { protocol_binary_response_no_extras response; memset(&response, 0, sizeof(protocol_binary_response_no_extras)); response.message.header.response.magic= PROTOCOL_BINARY_RES; response.message.header.response.opcode= header->request.opcode; response.message.header.response.status= htons(rval); response.message.header.response.opaque= header->request.opaque; response.message.header.response.cas= example_htonll(cas); return response_handler(cookie, header, (protocol_binary_response_header*)&response); } } return rval; } static protocol_binary_response_status set_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { size_t keylen= ntohs(header->request.keylen); size_t datalen= ntohl(header->request.bodylen) - keylen - 8; protocol_binary_request_replace *request= (protocol_binary_request_replace*)header; uint32_t flags= ntohl(request->message.body.flags); time_t timeout= (time_t)ntohl(request->message.body.expiration); char *key= ((char*)header) + sizeof(*header) + 8; char *data= key + keylen; protocol_binary_response_no_extras response; memset(&response, 0, sizeof(protocol_binary_response_no_extras)); response.message.header.response.magic= PROTOCOL_BINARY_RES; response.message.header.response.opcode= header->request.opcode; response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); response.message.header.response.opaque= header->request.opaque; if (header->request.cas != 0) { /* validate cas */ struct item* item= get_item(key, keylen); if (item != NULL) { if (item->cas != example_ntohll(header->request.cas)) { release_item(item); response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS); return response_handler(cookie, header, (protocol_binary_response_header*)&response); } release_item(item); } } delete_item(key, keylen); struct item* item= create_item(key, keylen, data, datalen, flags, timeout); if (item == NULL) { response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_ENOMEM); } else { put_item(item); /* SETQ shouldn't return a message */ if (header->request.opcode == PROTOCOL_BINARY_CMD_SET) { response.message.header.response.cas= example_htonll(item->cas); release_item(item); return response_handler(cookie, header, (protocol_binary_response_header*)&response); } release_item(item); return PROTOCOL_BINARY_RESPONSE_SUCCESS; } return response_handler(cookie, header, (protocol_binary_response_header*)&response); } static protocol_binary_response_status add_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { size_t keylen= ntohs(header->request.keylen); size_t datalen= ntohl(header->request.bodylen) - keylen - 8; protocol_binary_request_add *request= (protocol_binary_request_add*)header; uint32_t flags= ntohl(request->message.body.flags); time_t timeout= (time_t)ntohl(request->message.body.expiration); char *key= ((char*)header) + sizeof(*header) + 8; char *data= key + keylen; protocol_binary_response_no_extras response; memset(&response, 0, sizeof(protocol_binary_response_no_extras)); response.message.header.response.magic= PROTOCOL_BINARY_RES; response.message.header.response.opcode= header->request.opcode; response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); response.message.header.response.opaque= header->request.opaque; struct item* item= get_item(key, keylen); if (item == NULL) { item= create_item(key, keylen, data, datalen, flags, timeout); if (item == NULL) response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_ENOMEM); else { put_item(item); /* ADDQ shouldn't return a message */ if (header->request.opcode == PROTOCOL_BINARY_CMD_ADD) { response.message.header.response.cas= example_htonll(item->cas); release_item(item); return response_handler(cookie, header, (protocol_binary_response_header*)&response); } release_item(item); return PROTOCOL_BINARY_RESPONSE_SUCCESS; } } else { release_item(item); response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS); } return response_handler(cookie, header, (protocol_binary_response_header*)&response); } static protocol_binary_response_status replace_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { size_t keylen= ntohs(header->request.keylen); size_t datalen= ntohl(header->request.bodylen) - keylen - 8; protocol_binary_request_replace *request= (protocol_binary_request_replace*)header; uint32_t flags= ntohl(request->message.body.flags); time_t timeout= (time_t)ntohl(request->message.body.expiration); char *key= ((char*)header) + sizeof(*header) + 8; char *data= key + keylen; protocol_binary_response_no_extras response; memset(&response, 0, sizeof(protocol_binary_response_no_extras)); response.message.header.response.magic= PROTOCOL_BINARY_RES; response.message.header.response.opcode= header->request.opcode; response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); response.message.header.response.opaque= header->request.opaque; struct item* item= get_item(key, keylen); if (item == NULL) { response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_ENOENT); } else if (header->request.cas == 0 || example_ntohll(header->request.cas) == item->cas) { release_item(item); delete_item(key, keylen); item= create_item(key, keylen, data, datalen, flags, timeout); if (item == NULL) { response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_ENOMEM); } else { put_item(item); /* REPLACEQ shouldn't return a message */ if (header->request.opcode == PROTOCOL_BINARY_CMD_REPLACE) { response.message.header.response.cas= example_htonll(item->cas); release_item(item); return response_handler(cookie, header, (protocol_binary_response_header*)&response); } release_item(item); return PROTOCOL_BINARY_RESPONSE_SUCCESS; } } else { response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS); release_item(item); } return response_handler(cookie, header, (protocol_binary_response_header*)&response); } static protocol_binary_response_status stat_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { /* Just send the terminating packet*/ protocol_binary_response_no_extras response; memset(&response, 0, sizeof(protocol_binary_response_no_extras)); response.message.header.response.magic= PROTOCOL_BINARY_RES; response.message.header.response.opcode= PROTOCOL_BINARY_CMD_STAT; response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS); response.message.header.response.opaque= header->request.opaque; return response_handler(cookie, header, (protocol_binary_response_header*)&response); } memcached_binary_protocol_callback_st interface_v0_impl; void initialize_interface_v0_handler(util::log_info_st& arg) { log_file= &arg; interface_v0_impl.interface_version= MEMCACHED_PROTOCOL_HANDLER_V0; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_GET]= get_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_SET]= set_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_ADD]= add_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_REPLACE]= replace_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_DELETE]= delete_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_INCREMENT]= arithmetic_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_DECREMENT]= arithmetic_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_QUIT]= quit_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_FLUSH]= flush_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_GETQ]= get_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_NOOP]= noop_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_VERSION]= version_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_GETK]= get_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_GETKQ]= get_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_APPEND]= concat_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_PREPEND]= concat_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_STAT]= stat_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_SETQ]= set_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_ADDQ]= add_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_REPLACEQ]= replace_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_DELETEQ]= delete_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_INCREMENTQ]= arithmetic_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_DECREMENTQ]= arithmetic_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_QUITQ]= quit_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_FLUSHQ]= flush_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_APPENDQ]= concat_command_handler; interface_v0_impl.interface.v0.comcode[PROTOCOL_BINARY_CMD_PREPENDQ]= concat_command_handler; } libmemcached-1.0.8/example/memcached_light.cc0000664000076400007640000004214311753573717021462 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /** * What is a library without an example to show you how to use the library? * This example use both interfaces to implement a small memcached server. * Please note that this is an exemple on how to use the library, not * an implementation of a scalable memcached server. If you look closely * at the example it isn't even multithreaded ;-) * * With that in mind, let me give you some pointers into the source: * storage.c/h - Implements the item store for this server and not really * interesting for this example. * interface_v0.cc - Shows an implementation of the memcached server by using * the "raw" access to the packets as they arrive * interface_v1.cc - Shows an implementation of the memcached server by using * the more "logical" interface. * memcached_light.cc- This file sets up all of the sockets and run the main * message loop. * * * config.h is included so that I can use the ntohll/htonll on platforms that * doesn't have that (this is a private function inside libmemcached, so you * cannot use it directly from libmemcached without special modifications to * the library) */ #include #include #include #include #include "example/storage.h" #include "example/memcached_light.h" #include "util/daemon.hpp" #include "util/log.hpp" #include "util/pidfile.hpp" using namespace datadifferential; #include #include #include #include #include #include #include #include #include #include #include extern memcached_binary_protocol_callback_st interface_v0_impl; extern memcached_binary_protocol_callback_st interface_v1_impl; static memcached_socket_t server_sockets[1024]; static int num_server_sockets= 0; struct connection { void *userdata; struct event event; }; /* The default maximum number of connections... (change with -c) */ static int maxconns= 1024; static struct connection *socket_userdata_map; static struct event_base *event_base= NULL; struct options_st { std::string pid_file; std::string service; std::string log_file; bool is_verbose; bool opt_daemon; options_st() : service("9999"), is_verbose(false) { } }; static options_st global_options; /** * Callback for driving a client connection * @param fd the socket for the client socket * @param which identifying the event that occurred (not used) * @param arg the connection structure for the client */ static void drive_client(memcached_socket_t fd, short, void *arg) { struct connection *client= (struct connection*)arg; struct memcached_protocol_client_st* c= (struct memcached_protocol_client_st*)client->userdata; assert(c != NULL); memcached_protocol_event_t events= memcached_protocol_client_work(c); if (events & MEMCACHED_PROTOCOL_ERROR_EVENT) { if (global_options.is_verbose) { struct sockaddr_in sin; socklen_t addrlen= sizeof(sin); if (getsockname(fd, (struct sockaddr *)&sin, &addrlen) != -1) { std::cout << __FILE__ << ":" << __LINE__ << " close(MEMCACHED_PROTOCOL_ERROR_EVENT)" << " " << inet_ntoa(sin.sin_addr) << ":" << sin.sin_port << " fd:" << fd << std::endl; } else { std::cout << __FILE__ << ":" << __LINE__ << "close() MEMCACHED_PROTOCOL_ERROR_EVENT" << std::endl; } } memcached_protocol_client_destroy(c); closesocket(fd); } else { short flags = 0; if (events & MEMCACHED_PROTOCOL_WRITE_EVENT) { flags= EV_WRITE; } if (events & MEMCACHED_PROTOCOL_READ_EVENT) { flags|= EV_READ; } event_set(&client->event, (intptr_t)fd, flags, drive_client, client); event_base_set(event_base, &client->event); if (event_add(&client->event, 0) == -1) { memcached_protocol_client_destroy(c); closesocket(fd); } } } /** * Callback for accepting new connections * @param fd the socket for the server socket * @param which identifying the event that occurred (not used) * @param arg the connection structure for the server */ static void accept_handler(memcached_socket_t fd, short, void *arg) { struct connection *server= (struct connection *)arg; /* accept new client */ struct sockaddr_storage addr; socklen_t addrlen= sizeof(addr); memcached_socket_t sock= accept(fd, (struct sockaddr *)&addr, &addrlen); if (sock == INVALID_SOCKET) { perror("Failed to accept client"); } #ifndef WIN32 if (sock >= maxconns) { closesocket(sock); return ; } #endif struct memcached_protocol_client_st* c= memcached_protocol_create_client((memcached_protocol_st*)server->userdata, sock); if (c == NULL) { closesocket(sock); } else { memcached_protocol_client_set_verbose(c, global_options.is_verbose); struct connection *client = &socket_userdata_map[sock]; client->userdata= c; event_set(&client->event, (intptr_t)sock, EV_READ, drive_client, client); event_base_set(event_base, &client->event); if (event_add(&client->event, 0) == -1) { std::cerr << "Failed to add event for " << sock << std::endl; memcached_protocol_client_destroy(c); closesocket(sock); } } } static bool server_socket(util::log_info_st& log_file, const std::string& service) { struct addrinfo *ai; struct addrinfo hints; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_flags= AI_PASSIVE; hints.ai_family= AF_UNSPEC; hints.ai_socktype= SOCK_STREAM; int error= getaddrinfo("127.0.0.1", service.c_str(), &hints, &ai); if (error != 0) { if (error != EAI_SYSTEM) { std::string buffer("getaddrinfo: "); buffer+= gai_strerror(error); log_file.write(util::VERBOSE_ERROR, buffer.c_str()); } else { std::string buffer("getaddrinfo: "); buffer+= strerror(errno); log_file.write(util::VERBOSE_ERROR, buffer.c_str()); } return false; } struct linger ling= {0, 0}; for (struct addrinfo *next= ai; next; next= next->ai_next) { memcached_socket_t sock= socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (sock == INVALID_SOCKET) { std::string buffer("Failed to create socket: "); buffer+= strerror(errno); log_file.write(util::VERBOSE_ERROR, buffer.c_str()); continue; } int flags; #ifdef WIN32 u_long arg = 1; if (ioctlsocket(sock, FIONBIO, &arg) == SOCKET_ERROR) { std::cerr << "Failed to set nonblocking io: " << strerror(errno) << std::endl; closesocket(sock); continue; } #else flags= fcntl(sock, F_GETFL, 0); if (flags == -1) { std::string buffer("Failed to get socket flags: "); buffer+= strerror(errno); log_file.write(util::VERBOSE_ERROR, buffer.c_str()); closesocket(sock); continue; } if ((flags & O_NONBLOCK) != O_NONBLOCK) { if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) == -1) { std::string buffer("Failed to set socket to nonblocking mode: "); buffer+= strerror(errno); log_file.write(util::VERBOSE_ERROR, buffer.c_str()); closesocket(sock); continue; } } #endif flags= 1; if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&flags, sizeof(flags)) != 0) { std::cerr << "Failed to set SO_REUSEADDR: " << strerror(errno) << std::endl; } if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&flags, sizeof(flags)) != 0) { std::cerr << "Failed to set SO_KEEPALIVE: " << strerror(errno) << std::endl; } if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (void *)&ling, sizeof(ling)) != 0) { std::cerr << "Failed to set SO_LINGER: " << strerror(errno) << std::endl; } if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *)&flags, sizeof(flags)) != 0) { std::cerr << "Failed to set TCP_NODELAY: " << strerror(errno) << std::endl; } if (bind(sock, next->ai_addr, next->ai_addrlen) == SOCKET_ERROR) { if (get_socket_errno() != EADDRINUSE) { std::cerr << "bind(): " << strerror(errno) << std::endl; freeaddrinfo(ai); } closesocket(sock); continue; } if (listen(sock, 1024) == SOCKET_ERROR) { std::string buffer("listen(): "); buffer+= strerror(errno); log_file.write(util::VERBOSE_ERROR, buffer.c_str()); closesocket(sock); continue; } if (global_options.is_verbose) { std::string buffer("Listening to: "); buffer+= global_options.service; log_file.write(util::VERBOSE_NOTICE, buffer.c_str()); } server_sockets[num_server_sockets++]= sock; } freeaddrinfo(ai); return (num_server_sockets > 0) ? true : false; } /** * Convert a command code to a textual string * @param cmd the comcode to convert * @return a textual string with the command or NULL for unknown commands */ static const char* comcode2str(uint8_t cmd) { static const char * const text[] = { "GET", "SET", "ADD", "REPLACE", "DELETE", "INCREMENT", "DECREMENT", "QUIT", "FLUSH", "GETQ", "NOOP", "VERSION", "GETK", "GETKQ", "APPEND", "PREPEND", "STAT", "SETQ", "ADDQ", "REPLACEQ", "DELETEQ", "INCREMENTQ", "DECREMENTQ", "QUITQ", "FLUSHQ", "APPENDQ", "PREPENDQ" }; if (cmd <= PROTOCOL_BINARY_CMD_PREPENDQ) { return text[cmd]; } return NULL; } /** * Print out the command we are about to execute */ static void pre_execute(const void *cookie, protocol_binary_request_header *header) { if (global_options.is_verbose) { if (header) { const char *cmd= comcode2str(header->request.opcode); if (cmd != NULL) { std::cout << "pre_execute from " << cookie << ": " << cmd << std::endl; } else { std::cout << "pre_execute from " << cookie << ": " << header->request.opcode << std::endl; } } else { std::cout << "pre_execute from " << cookie << std::endl; } } } /** * Print out the command we just executed */ static void post_execute(const void *cookie, protocol_binary_request_header *header) { if (global_options.is_verbose) { if (header) { const char *cmd= comcode2str(header->request.opcode); if (cmd != NULL) { std::cout << "post_execute from " << cookie << ": " << cmd << std::endl; } else { std::cout << "post_execute from " << cookie << ": " << header->request.opcode << std::endl; } } else { std::cout << "post_execute from " << cookie << std::endl; } } } /** * Callback handler for all unknown commands. * Send an unknown command back to the client */ static protocol_binary_response_status unknown(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { protocol_binary_response_no_extras response; memset(&response, 0, sizeof(protocol_binary_response_no_extras)); response.message.header.response.magic= PROTOCOL_BINARY_RES; response.message.header.response.opcode= header->request.opcode; response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND); response.message.header.response.opaque= header->request.opaque; return response_handler(cookie, header, (protocol_binary_response_header*)&response); } /** * Program entry point. Bind to the specified port(s) and serve clients * * @param argc number of items in the argument vector * @param argv argument vector * @return EXIT_SUCCESS on success, 1 otherwise */ int main(int argc, char **argv) { memcached_binary_protocol_callback_st *interface= &interface_v0_impl; { enum long_option_t { OPT_HELP, OPT_VERBOSE, OPT_DAEMON, OPT_PROTOCOL_VERSION, OPT_VERSION, OPT_PORT, OPT_MAX_CONNECTIONS, OPT_LOGFILE, OPT_PIDFILE }; static struct option long_options[]= { { "help", no_argument, NULL, OPT_HELP }, { "port", required_argument, NULL, OPT_PORT }, { "verbose", no_argument, NULL, OPT_VERBOSE }, { "daemon", no_argument, NULL, OPT_DAEMON }, { "protocol", no_argument, NULL, OPT_PROTOCOL_VERSION }, { "version", no_argument, NULL, OPT_VERSION }, { "max-connections", required_argument, NULL, OPT_MAX_CONNECTIONS }, { "pid-file", required_argument, NULL, OPT_PIDFILE }, { "log-file", required_argument, NULL, OPT_LOGFILE }, {0, 0, 0, 0} }; bool opt_help= false; int option_index; bool done= false; while (done == false) { switch (getopt_long(argc, argv, "", long_options, &option_index)) { case -1: done= true; break; case OPT_PROTOCOL_VERSION: interface= &interface_v1_impl; break; case OPT_PIDFILE: global_options.pid_file= optarg; break; case OPT_LOGFILE: global_options.log_file= optarg; break; case OPT_VERBOSE: global_options.is_verbose= true; break; case OPT_VERSION: break; case OPT_DAEMON: global_options.opt_daemon= true; break; case OPT_PORT: global_options.service= optarg; break; case OPT_MAX_CONNECTIONS: maxconns= atoi(optarg); break; case OPT_HELP: /* FALLTHROUGH */ opt_help= true; break; default: { std::cerr << "Unknown option: " << optarg << std::endl; return EXIT_FAILURE; } } } if (opt_help) { std::cout << "Usage: " << argv[0] << std::endl; for (struct option *ptr_option= long_options; ptr_option->name; ptr_option++) { std::cout << "\t" << ptr_option->name << std::endl; } return EXIT_SUCCESS; } } if (global_options.opt_daemon) { util::daemonize(false, true); } if (initialize_storage() == false) { /* Error message already printed */ return EXIT_FAILURE; } util::Pidfile _pid_file(global_options.pid_file); if (_pid_file.create() == false) { std::cerr << "Failed to create pid-file" << _pid_file.error_message() << std::endl; return EXIT_FAILURE; } util::log_info_st log_file(argv[0], global_options.log_file, false); log_file.write(util::VERBOSE_NOTICE, "starting log"); /* * We need to initialize the handlers manually due to a bug in the * warnings generated by struct initialization in gcc (all the way up to 4.4) */ initialize_interface_v0_handler(log_file); initialize_interface_v1_handler(log_file); if (server_socket(log_file, global_options.service) == false) { return EXIT_FAILURE; } if (num_server_sockets == 0) { log_file.write(util::VERBOSE_ERROR, "No server sockets are available."); return EXIT_FAILURE; } /* * Create and initialize the handles to the protocol handlers. I want * to be able to trace the traffic throught the pre/post handlers, and * set up a common handler for unknown messages */ interface->pre_execute= pre_execute; interface->post_execute= post_execute; interface->unknown= unknown; struct memcached_protocol_st *protocol_handle; if ((protocol_handle= memcached_protocol_create_instance()) == NULL) { log_file.write(util::VERBOSE_ERROR, "No server sockets are available."); return EXIT_FAILURE; } socket_userdata_map= (struct connection*)calloc((size_t)(maxconns), sizeof(struct connection)); if (socket_userdata_map == NULL) { log_file.write(util::VERBOSE_ERROR, "Failed to allocate room for connections"); return EXIT_FAILURE; } memcached_binary_protocol_set_callbacks(protocol_handle, interface); memcached_binary_protocol_set_pedantic(protocol_handle, true); event_base= event_init(); if (event_base == NULL) { std::cerr << "Failed to create an instance of libevent" << std::endl; return EXIT_FAILURE; } for (int xx= 0; xx < num_server_sockets; ++xx) { struct connection *conn= &socket_userdata_map[server_sockets[xx]]; conn->userdata= protocol_handle; event_set(&conn->event, (intptr_t)server_sockets[xx], EV_READ | EV_PERSIST, accept_handler, conn); event_base_set(event_base, &conn->event); if (event_add(&conn->event, 0) == -1) { log_file.write(util::VERBOSE_ERROR, "Failed to add event"); closesocket(server_sockets[xx]); } } if (global_options.opt_daemon) { if (util::daemon_is_ready(true) == false) { log_file.write(util::VERBOSE_ERROR, "Failed for util::daemon_is_ready()"); return EXIT_FAILURE; } } /* Serve all of the clients */ switch (event_base_loop(event_base, 0)) { case -1: log_file.write(util::VERBOSE_ERROR, "event_base_loop() failed"); break; case 1: log_file.write(util::VERBOSE_ERROR, "event_base_loop(), no events were registered"); break; default: break; } log_file.write(util::VERBOSE_NOTICE, "exiting"); /* NOTREACHED */ return EXIT_SUCCESS; } libmemcached-1.0.8/example/storage.cc0000664000076400007640000000556711753573717020042 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ #include "config.h" #include #include #include #include #include #include "storage.h" struct list_entry { struct item item; struct list_entry *next; struct list_entry *prev; }; static struct list_entry *root; static uint64_t cas; bool initialize_storage(void) { return true; } void shutdown_storage(void) { /* Do nothing */ } void put_item(struct item* item) { struct list_entry* entry= (struct list_entry*)item; update_cas(item); if (root == NULL) { entry->next= entry->prev= entry; } else { entry->prev= root->prev; entry->next= root; entry->prev->next= entry; entry->next->prev= entry; } root= entry; } struct item* get_item(const void* key, size_t nkey) { struct list_entry *walker= root; if (root == NULL) { return NULL; } do { if (((struct item*)walker)->nkey == nkey && memcmp(((struct item*)walker)->key, key, nkey) == 0) { return (struct item*)walker; } walker= walker->next; } while (walker != root); return NULL; } struct item* create_item(const void* key, size_t nkey, const void* data, size_t size, uint32_t flags, time_t exp) { struct item* ret= (struct item*)calloc(1, sizeof(struct list_entry)); if (ret != NULL) { ret->key= malloc(nkey); if (size > 0) { ret->data= malloc(size); } if (ret->key == NULL || (size > 0 && ret->data == NULL)) { free(ret->key); free(ret->data); free(ret); return NULL; } memcpy(ret->key, key, nkey); if (data != NULL) { memcpy(ret->data, data, size); } ret->nkey= nkey; ret->size= size; ret->flags= flags; ret->exp= exp; } return ret; } bool delete_item(const void* key, size_t nkey) { struct item* item= get_item(key, nkey); bool ret= false; if (item) { /* remove from linked list */ struct list_entry *entry= (struct list_entry*)item; if (entry->next == entry) { /* Only one object in the list */ root= NULL; } else { /* ensure that we don't loose track of the root, and this will * change the start position for the next search ;-) */ root= entry->next; entry->prev->next= entry->next; entry->next->prev= entry->prev; } free(item->key); free(item->data); free(item); ret= true; } return ret; } void flush(uint32_t /* when */) { /* remove the complete linked list */ if (root == NULL) { return; } root->prev->next= NULL; while (root != NULL) { struct item* tmp= (struct item*)root; root= root->next; free(tmp->key); free(tmp->data); free(tmp); } } void update_cas(struct item* item) { item->cas= ++cas; } void release_item(struct item* /* item */) { } libmemcached-1.0.8/example/storage.h0000664000076400007640000000121411753573717017665 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ #pragma once struct item { uint64_t cas; void* key; size_t nkey; void* data; size_t size; uint32_t flags; time_t exp; }; bool initialize_storage(void); void shutdown_storage(void); void update_cas(struct item* item); void put_item(struct item* item); struct item* get_item(const void* key, size_t nkey); struct item* create_item(const void* key, size_t nkey, const void *data, size_t size, uint32_t flags, time_t exp); bool delete_item(const void* key, size_t nkey); void flush(uint32_t when); void release_item(struct item* item); libmemcached-1.0.8/example/interface_v1.cc0000664000076400007640000003233511753573717020735 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /** * This file contains an implementation of the callback interface for level 1 * in the protocol library. If you compare the implementation with the one * in interface_v0.cc you will see that this implementation is much easier and * hides all of the protocol logic and let you focus on the application * logic. One "problem" with this layer is that it is synchronous, so that * you will not receive the next command before a answer to the previous * command is being sent. */ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include "example/memcached_light.h" #include "example/storage.h" #include "util/log.hpp" static datadifferential::util::log_info_st *log_file= NULL; static protocol_binary_response_status add_handler(const void *cookie, const void *key, uint16_t keylen, const void *data, uint32_t datalen, uint32_t flags, uint32_t exptime, uint64_t *cas) { (void)cookie; protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; struct item* item= get_item(key, keylen); if (item == NULL) { item= create_item(key, keylen, data, datalen, flags, (time_t)exptime); if (item == 0) { rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; } else { put_item(item); *cas= item->cas; release_item(item); } } else { rval= PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; } return rval; } static protocol_binary_response_status append_handler(const void *cookie, const void *key, uint16_t keylen, const void* val, uint32_t vallen, uint64_t cas, uint64_t *result_cas) { (void)cookie; protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; struct item *item= get_item(key, keylen); struct item *nitem; if (item == NULL) { rval= PROTOCOL_BINARY_RESPONSE_KEY_ENOENT; } else if (cas != 0 && cas != item->cas) { rval= PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; } else if ((nitem= create_item(key, keylen, NULL, item->size + vallen, item->flags, item->exp)) == NULL) { release_item(item); rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; } else { memcpy(nitem->data, item->data, item->size); memcpy(((char*)(nitem->data)) + item->size, val, vallen); release_item(item); delete_item(key, keylen); put_item(nitem); *result_cas= nitem->cas; release_item(nitem); } return rval; } static protocol_binary_response_status decrement_handler(const void *cookie, const void *key, uint16_t keylen, uint64_t delta, uint64_t initial, uint32_t expiration, uint64_t *result, uint64_t *result_cas) { (void)cookie; protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; uint64_t val= initial; struct item *item= get_item(key, keylen); if (item != NULL) { if (delta > *(uint64_t*)item->data) val= 0; else val= *(uint64_t*)item->data - delta; expiration= (uint32_t)item->exp; release_item(item); delete_item(key, keylen); } item= create_item(key, keylen, NULL, sizeof(initial), 0, (time_t)expiration); if (item == 0) { rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; } else { memcpy(item->data, &val, sizeof(val)); put_item(item); *result= val; *result_cas= item->cas; release_item(item); } return rval; } static protocol_binary_response_status delete_handler(const void *, // cookie const void *key, uint16_t keylen, uint64_t cas) { protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; if (cas != 0) { struct item *item= get_item(key, keylen); if (item != NULL) { if (item->cas != cas) { release_item(item); return PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; } release_item(item); } } if (!delete_item(key, keylen)) { rval= PROTOCOL_BINARY_RESPONSE_KEY_ENOENT; } return rval; } static protocol_binary_response_status flush_handler(const void * /* cookie */, uint32_t /* when */) { return PROTOCOL_BINARY_RESPONSE_SUCCESS; } static protocol_binary_response_status get_handler(const void *cookie, const void *key, uint16_t keylen, memcached_binary_protocol_get_response_handler response_handler) { struct item *item= get_item(key, keylen); if (item == NULL) { return PROTOCOL_BINARY_RESPONSE_KEY_ENOENT; } protocol_binary_response_status rc; rc= response_handler(cookie, key, (uint16_t)keylen, item->data, (uint32_t)item->size, item->flags, item->cas); release_item(item); return rc; } static protocol_binary_response_status increment_handler(const void *cookie, const void *key, uint16_t keylen, uint64_t delta, uint64_t initial, uint32_t expiration, uint64_t *result, uint64_t *result_cas) { (void)cookie; protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; uint64_t val= initial; struct item *item= get_item(key, keylen); if (item != NULL) { val= (*(uint64_t*)item->data) + delta; expiration= (uint32_t)item->exp; release_item(item); delete_item(key, keylen); } item= create_item(key, keylen, NULL, sizeof(initial), 0, (time_t)expiration); if (item == NULL) { rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; } else { char buffer[1024] = {0}; memcpy(buffer, key, keylen); memcpy(item->data, &val, sizeof(val)); put_item(item); *result= val; *result_cas= item->cas; release_item(item); } return rval; } static protocol_binary_response_status noop_handler(const void *cookie) { (void)cookie; return PROTOCOL_BINARY_RESPONSE_SUCCESS; } static protocol_binary_response_status prepend_handler(const void *cookie, const void *key, uint16_t keylen, const void* val, uint32_t vallen, uint64_t cas, uint64_t *result_cas) { (void)cookie; protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; struct item *item= get_item(key, keylen); struct item *nitem= NULL; if (item == NULL) { rval= PROTOCOL_BINARY_RESPONSE_KEY_ENOENT; } else if (cas != 0 && cas != item->cas) { rval= PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; } else if ((nitem= create_item(key, keylen, NULL, item->size + vallen, item->flags, item->exp)) == NULL) { rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; } else { memcpy(nitem->data, val, vallen); memcpy(((char*)(nitem->data)) + vallen, item->data, item->size); release_item(item); item= NULL; delete_item(key, keylen); put_item(nitem); *result_cas= nitem->cas; } if (item) release_item(item); if (nitem) release_item(nitem); return rval; } static protocol_binary_response_status quit_handler(const void *) //cookie { return PROTOCOL_BINARY_RESPONSE_SUCCESS; } static protocol_binary_response_status replace_handler(const void *, // cookie const void *key, uint16_t keylen, const void* data, uint32_t datalen, uint32_t flags, uint32_t exptime, uint64_t cas, uint64_t *result_cas) { protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; struct item* item= get_item(key, keylen); if (item == NULL) { rval= PROTOCOL_BINARY_RESPONSE_KEY_ENOENT; } else if (cas == 0 || cas == item->cas) { release_item(item); delete_item(key, keylen); item= create_item(key, keylen, data, datalen, flags, (time_t)exptime); if (item == 0) { rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; } else { put_item(item); *result_cas= item->cas; release_item(item); } } else { rval= PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; release_item(item); } return rval; } static protocol_binary_response_status set_handler(const void *cookie, const void *key, uint16_t keylen, const void* data, uint32_t datalen, uint32_t flags, uint32_t exptime, uint64_t cas, uint64_t *result_cas) { (void)cookie; protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; if (cas != 0) { struct item* item= get_item(key, keylen); if (item != NULL && cas != item->cas) { /* Invalid CAS value */ release_item(item); return PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; } } delete_item(key, keylen); struct item* item= create_item(key, keylen, data, datalen, flags, (time_t)exptime); if (item == 0) { rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; } else { put_item(item); *result_cas= item->cas; release_item(item); } return rval; } static protocol_binary_response_status stat_handler(const void *cookie, const void *, // key uint16_t, // keylen, memcached_binary_protocol_stat_response_handler response_handler) { /* Just return an empty packet */ return response_handler(cookie, NULL, 0, NULL, 0); } static protocol_binary_response_status version_handler(const void *cookie, memcached_binary_protocol_version_response_handler response_handler) { const char *version= "0.1.1"; return response_handler(cookie, version, (uint32_t)strlen(version)); } memcached_binary_protocol_callback_st interface_v1_impl; void initialize_interface_v1_handler(datadifferential::util::log_info_st& arg) { log_file= &arg; memset(&interface_v1_impl, 0, sizeof(memcached_binary_protocol_callback_st)); interface_v1_impl.interface_version= MEMCACHED_PROTOCOL_HANDLER_V1; interface_v1_impl.interface.v1.add= add_handler; interface_v1_impl.interface.v1.append= append_handler; interface_v1_impl.interface.v1.decrement= decrement_handler; interface_v1_impl.interface.v1.delete_object= delete_handler; interface_v1_impl.interface.v1.flush_object= flush_handler; interface_v1_impl.interface.v1.get= get_handler; interface_v1_impl.interface.v1.increment= increment_handler; interface_v1_impl.interface.v1.noop= noop_handler; interface_v1_impl.interface.v1.prepend= prepend_handler; interface_v1_impl.interface.v1.quit= quit_handler; interface_v1_impl.interface.v1.replace= replace_handler; interface_v1_impl.interface.v1.set= set_handler; interface_v1_impl.interface.v1.stat= stat_handler; interface_v1_impl.interface.v1.version= version_handler; } libmemcached-1.0.8/example/memcached_light.h0000664000076400007640000000366311753573717021330 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Memcached Light interface definitions * * 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. * */ /* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ #pragma once #include "util/log.hpp" void initialize_interface_v0_handler(datadifferential::util::log_info_st&); void initialize_interface_v1_handler(datadifferential::util::log_info_st&); libmemcached-1.0.8/example/byteorder.h0000664000076400007640000000342711753573717020230 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Byteorder for example * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif uint64_t example_ntohll(uint64_t); uint64_t example_htonll(uint64_t); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached/0000775000076400007640000000000011757025120016774 5ustar00brianbrian00000000000000libmemcached-1.0.8/libmemcached/result.cc0000664000076400007640000001206311756535564020644 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ /* memcached_result_st are used to internally represent the return values from memcached. We use a structure so that long term as identifiers are added to memcached we will be able to absorb new attributes without having to addjust the entire API. */ #include static inline void _result_init(memcached_result_st *self, memcached_st *memc) { self->item_flags= 0; self->item_expiration= 0; self->key_length= 0; self->item_cas= 0; self->root= memc; self->numeric_value= UINT64_MAX; self->count= 0; self->item_key[0]= 0; } memcached_result_st *memcached_result_create(const memcached_st *memc, memcached_result_st *ptr) { WATCHPOINT_ASSERT(memc); /* Saving malloc calls :) */ if (ptr) { ptr->options.is_allocated= false; } else { ptr= libmemcached_xmalloc(memc, memcached_result_st); if (not ptr) { return NULL; } ptr->options.is_allocated= true; } ptr->options.is_initialized= true; _result_init(ptr, (memcached_st *)memc); WATCHPOINT_SET(ptr->value.options.is_initialized= false); memcached_string_create((memcached_st*)memc, &ptr->value, 0); WATCHPOINT_ASSERT_INITIALIZED(&ptr->value); WATCHPOINT_ASSERT(ptr->value.string == NULL); return ptr; } void memcached_result_reset(memcached_result_st *ptr) { ptr->key_length= 0; memcached_string_reset(&ptr->value); ptr->item_flags= 0; ptr->item_cas= 0; ptr->item_expiration= 0; ptr->numeric_value= UINT64_MAX; } void memcached_result_free(memcached_result_st *ptr) { if (ptr == NULL) { return; } memcached_string_free(&ptr->value); ptr->numeric_value= UINT64_MAX; if (memcached_is_allocated(ptr)) { WATCHPOINT_ASSERT(ptr->root); // Without a root, that means that result was not properly initialized. libmemcached_free(ptr->root, ptr); } else { ptr->count= 0; ptr->options.is_initialized= false; } } void memcached_result_reset_value(memcached_result_st *ptr) { memcached_string_reset(&ptr->value); } memcached_return_t memcached_result_set_value(memcached_result_st *ptr, const char *value, size_t length) { if (memcached_failed(memcached_string_append(&ptr->value, value, length))) { return memcached_set_errno(*ptr->root, errno, MEMCACHED_AT); } return MEMCACHED_SUCCESS; } const char *memcached_result_key_value(const memcached_result_st *self) { return self->key_length ? self->item_key : NULL; } size_t memcached_result_key_length(const memcached_result_st *self) { return self->key_length; } const char *memcached_result_value(const memcached_result_st *self) { const memcached_string_st *sptr= &self->value; return memcached_string_value(sptr); } size_t memcached_result_length(const memcached_result_st *self) { const memcached_string_st *sptr= &self->value; return memcached_string_length(sptr); } uint32_t memcached_result_flags(const memcached_result_st *self) { return self->item_flags; } uint64_t memcached_result_cas(const memcached_result_st *self) { return self->item_cas; } void memcached_result_set_flags(memcached_result_st *self, uint32_t flags) { self->item_flags= flags; } void memcached_result_set_expiration(memcached_result_st *self, time_t expiration) { self->item_expiration= expiration; } libmemcached-1.0.8/libmemcached/util.h0000664000076400007640000000326211753573717020145 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #include libmemcached-1.0.8/libmemcached/key.cc0000664000076400007640000000662411753573717020123 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include memcached_return_t memcached_key_test(memcached_st &memc, const char * const *keys, const size_t *key_length, size_t number_of_keys) { if (keys == NULL or key_length == NULL) { return memcached_set_error(memc, MEMCACHED_BAD_KEY_PROVIDED, MEMCACHED_AT, memcached_literal_param("Key was NULL or length of key was zero.")); } // If we don't need to verify the key, or we are using the binary protoocol, // we just check the size of the key if (memc.flags.verify_key == false or memc.flags.binary_protocol == true) { for (size_t x= 0; x < number_of_keys; x++) { // We should set binary key, but the memcached server is broken for // longer keys at the moment. memcached_return_t rc= memcached_validate_key_length(*(key_length +x), false /* memc.flags.binary_protocol */); if (memcached_failed(rc)) { return memcached_set_error(memc, rc, MEMCACHED_AT, memcached_literal_param("Key provided was too long.")); } } return MEMCACHED_SUCCESS; } for (size_t x= 0; x < number_of_keys; x++) { memcached_return_t rc= memcached_validate_key_length(*(key_length + x), false); if (memcached_failed(rc)) { return memcached_set_error(memc, rc, MEMCACHED_AT, memcached_literal_param("Key provided was too long.")); } for (size_t y= 0; y < *(key_length + x); y++) { if ((isgraph(keys[x][y])) == 0) { return memcached_set_error(memc, MEMCACHED_BAD_KEY_PROVIDED, MEMCACHED_AT, memcached_literal_param("Key provided had invalid character.")); } } } return MEMCACHED_SUCCESS; } libmemcached-1.0.8/libmemcached/common.h0000664000076400007640000001172511756611200020442 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ /* Common include file for libmemached */ #pragma once #include #ifdef __cplusplus #include #include #include #include #include #include #include #else #include #include #include #include #include #include #endif #include #include #include #ifdef HAVE_STRINGS_H #include #endif #include #include #include #include #ifdef HAVE_POLL_H #include #else #include "poll/poll.h" #endif #ifdef __cplusplus extern "C" { #endif typedef memcached_return_t (*memcached_server_execute_fn)(memcached_st *ptr, memcached_server_write_instance_st server, void *context); LIBMEMCACHED_LOCAL memcached_server_write_instance_st memcached_server_instance_fetch(memcached_st *ptr, uint32_t server_key); LIBMEMCACHED_LOCAL memcached_return_t memcached_server_execute(memcached_st *ptr, memcached_server_execute_fn callback, void *context); #ifdef __cplusplus } // extern "C" #endif /* These are private not to be installed headers */ #include #include #include #ifdef __cplusplus #include #include #include #include #include #include #include #include #include #include #include #include #include #endif #include #include #include #include #include #include #ifdef __cplusplus #include #endif #include #include #ifdef __cplusplus #include #include #include #include #include #include #endif #include #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) #define likely(x) if((x)) #define unlikely(x) if((x)) #else #define likely(x) if(__builtin_expect((x) != 0, 1)) #define unlikely(x) if(__builtin_expect((x) != 0, 0)) #endif #define MEMCACHED_BLOCK_SIZE 1024 #define MEMCACHED_DEFAULT_COMMAND_SIZE 350 #define SMALL_STRING_LEN 1024 #define HUGE_STRING_LEN 8196 #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_LOCAL memcached_return_t run_distribution(memcached_st *ptr); #define memcached_server_response_increment(A) (A)->cursor_active++ #define memcached_server_response_decrement(A) (A)->cursor_active-- #define memcached_server_response_reset(A) (A)->cursor_active=0 bool memcached_purge(memcached_server_write_instance_st ptr); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached/allocators.hpp0000664000076400007640000000407311753573717021674 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once void _libmemcached_free(const memcached_st *ptr, void *mem, void *context); void *_libmemcached_malloc(const memcached_st *ptr, const size_t size, void *context); void *_libmemcached_realloc(const memcached_st *ptr, void *mem, const size_t size, void *context); void *_libmemcached_calloc(const memcached_st *ptr, size_t nelem, size_t size, void *context); struct memcached_allocator_t memcached_allocators_return_default(void); libmemcached-1.0.8/libmemcached/fetch.cc0000664000076400007640000001545011756611200020400 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, size_t *value_length, uint32_t *flags, memcached_return_t *error) { memcached_result_st *result_buffer= &ptr->result; memcached_return_t unused; if (error == NULL) { error= &unused; } if (memcached_is_udp(ptr)) { if (value_length) { *value_length= 0; } if (key_length) { *key_length= 0; } if (flags) { *flags= 0; } if (key) { *key= 0; } *error= MEMCACHED_NOT_SUPPORTED; return NULL; } result_buffer= memcached_fetch_result(ptr, result_buffer, error); if (result_buffer == NULL or memcached_failed(*error)) { WATCHPOINT_ASSERT(result_buffer == NULL); if (value_length) { *value_length= 0; } if (key_length) { *key_length= 0; } if (flags) { *flags= 0; } if (key) { *key= 0; } return NULL; } if (value_length) { *value_length= memcached_string_length(&result_buffer->value); } if (key) { if (result_buffer->key_length > MEMCACHED_MAX_KEY) { *error= MEMCACHED_KEY_TOO_BIG; if (value_length) { *value_length= 0; } if (key_length) { *key_length= 0; } if (flags) { *flags= 0; } if (key) { *key= 0; } return NULL; } strncpy(key, result_buffer->item_key, result_buffer->key_length); // For the binary protocol we will cut off the key :( if (key_length) { *key_length= result_buffer->key_length; } } if (flags) { *flags= result_buffer->item_flags; } return memcached_string_take_value(&result_buffer->value); } memcached_result_st *memcached_fetch_result(memcached_st *ptr, memcached_result_st *result, memcached_return_t *error) { memcached_return_t unused; if (error == NULL) { error= &unused; } if (ptr == NULL) { *error= MEMCACHED_INVALID_ARGUMENTS; return NULL; } if (memcached_is_udp(ptr)) { *error= MEMCACHED_NOT_SUPPORTED; return NULL; } if (result == NULL) { // If we have already initialized (ie it is in use) our internal, we // create one. if (memcached_is_initialized(&ptr->result)) { if ((result= memcached_result_create(ptr, NULL)) == NULL) { *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE; return NULL; } } else { result= memcached_result_create(ptr, &ptr->result); } } *error= MEMCACHED_MAXIMUM_RETURN; // We use this to see if we ever go into the loop memcached_server_st *server; while ((server= memcached_io_get_readable_server(ptr))) { char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; *error= memcached_response(server, buffer, sizeof(buffer), result); if (*error == MEMCACHED_IN_PROGRESS) { continue; } else if (*error == MEMCACHED_SUCCESS) { result->count++; return result; } else if (*error == MEMCACHED_END) { memcached_server_response_reset(server); } else if (*error != MEMCACHED_NOTFOUND) { break; } } if (*error == MEMCACHED_NOTFOUND and result->count) { *error= MEMCACHED_END; } else if (*error == MEMCACHED_MAXIMUM_RETURN and result->count) { *error= MEMCACHED_END; } else if (*error == MEMCACHED_MAXIMUM_RETURN) // while() loop was never entered { *error= MEMCACHED_NOTFOUND; } else if (*error == MEMCACHED_SUCCESS) { *error= MEMCACHED_END; } else if (result->count == 0) { *error= MEMCACHED_NOTFOUND; } /* We have completed reading data */ if (memcached_is_allocated(result)) { memcached_result_free(result); } else { result->count= 0; memcached_string_reset(&result->value); } return NULL; } memcached_return_t memcached_fetch_execute(memcached_st *ptr, memcached_execute_fn *callback, void *context, uint32_t number_of_callbacks) { memcached_result_st *result= &ptr->result; memcached_return_t rc; bool some_errors= false; while ((result= memcached_fetch_result(ptr, result, &rc))) { if (memcached_failed(rc) and rc == MEMCACHED_NOTFOUND) { continue; } else if (memcached_failed(rc)) { memcached_set_error(*ptr, rc, MEMCACHED_AT); some_errors= true; continue; } for (uint32_t x= 0; x < number_of_callbacks; x++) { memcached_return_t ret= (*callback[x])(ptr, result, context); if (memcached_failed(ret)) { some_errors= true; memcached_set_error(*ptr, ret, MEMCACHED_AT); break; } } } if (some_errors) { return MEMCACHED_SOME_ERRORS; } // If we were able to run all keys without issue we return // MEMCACHED_SUCCESS if (memcached_success(rc)) { return MEMCACHED_SUCCESS; } return rc; } libmemcached-1.0.8/libmemcached/byteorder.cc0000664000076400007640000000476411753573717021335 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include /* Byte swap a 64-bit number. */ #ifndef swap64 static inline uint64_t swap64(uint64_t in) { #ifndef WORDS_BIGENDIAN /* Little endian, flip the bytes around until someone makes a faster/better * way to do this. */ uint64_t rv= 0; for (uint8_t x= 0; x < 8; x++) { rv= (rv << 8) | (in & 0xff); in >>= 8; } return rv; #else /* big-endian machines don't need byte swapping */ return in; #endif // WORDS_BIGENDIAN } #endif #ifdef HAVE_HTONLL uint64_t memcached_ntohll(uint64_t value) { return ntohll(value); } uint64_t memcached_htonll(uint64_t value) { return htonll(value); } #else // HAVE_HTONLL uint64_t memcached_ntohll(uint64_t value) { return swap64(value); } uint64_t memcached_htonll(uint64_t value) { return swap64(value); } #endif // HAVE_HTONLL libmemcached-1.0.8/libmemcached/quit.cc0000664000076400007640000001207111753573717020306 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #include /* This closes all connections (forces flush of input as well). Maybe add a host specific, or key specific version? The reason we send "quit" is that in case we have buffered IO, this will force data to be completed. */ void memcached_quit_server(memcached_server_st *ptr, bool io_death) { if (ptr->fd != INVALID_SOCKET) { if (io_death == false and memcached_is_udp(ptr->root) == false and ptr->options.is_shutting_down == false) { ptr->options.is_shutting_down= true; memcached_return_t rc; if (ptr->root->flags.binary_protocol) { protocol_binary_request_quit request= {}; // = {.bytes= {0}}; request.message.header.request.magic = PROTOCOL_BINARY_REQ; request.message.header.request.opcode = PROTOCOL_BINARY_CMD_QUIT; request.message.header.request.datatype = PROTOCOL_BINARY_RAW_BYTES; libmemcached_io_vector_st vector[]= { { request.bytes, sizeof(request.bytes) } }; rc= memcached_vdo(ptr, vector, 1, true); } else { libmemcached_io_vector_st vector[]= { { memcached_literal_param("quit\r\n") } }; rc= memcached_vdo(ptr, vector, 1, true); } /* read until socket is closed, or there is an error * closing the socket before all data is read * results in server throwing away all data which is * not read * * In .40 we began to only do this if we had been doing buffered * requests of had replication enabled. */ if (memcached_success(rc) and (ptr->root->flags.buffer_requests or ptr->root->number_of_replicas)) { if (0) { memcached_return_t rc_slurp; while (memcached_continue(rc_slurp= memcached_io_slurp(ptr))) {} ; WATCHPOINT_ASSERT(rc_slurp == MEMCACHED_CONNECTION_FAILURE); } else { memcached_io_slurp(ptr); } } /* * memcached_io_read may call memcached_quit_server with io_death if * it encounters problems, but we don't care about those occurences. * The intention of that loop is to drain the data sent from the * server to ensure that the server processed all of the data we * sent to the server. */ ptr->server_failure_counter= 0; } memcached_io_close(ptr); } ptr->state= MEMCACHED_SERVER_STATE_NEW; ptr->cursor_active= 0; ptr->io_bytes_sent= 0; ptr->write_buffer_offset= size_t(ptr->root and memcached_is_udp(ptr->root) ? UDP_DATAGRAM_HEADER_LENGTH : 0); ptr->read_buffer_length= 0; ptr->read_ptr= ptr->read_buffer; ptr->options.is_shutting_down= false; memcached_server_response_reset(ptr); // We reset the version so that if we end up talking to a different server // we don't have stale server version information. ptr->major_version= ptr->minor_version= ptr->micro_version= UINT8_MAX; if (io_death) { memcached_mark_server_for_timeout(ptr); } } void send_quit(memcached_st *ptr) { for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); memcached_quit_server(instance, false); } } void memcached_quit(memcached_st *ptr) { memcached_return_t rc; if (memcached_failed(rc= initialize_query(ptr, true))) { return; } send_quit(ptr); } libmemcached-1.0.8/libmemcached/include.am0000664000076400007640000001205211753573717020756 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root libmemcached_libmemcached_la_SOURCES = include libmemcached/csl/include.am EXTRA_DIST+= libmemcached/libmemcached_probes.d EXTRA_DIST+= libmemcached/memcached/README.txt nobase_include_HEADERS+= libmemcached/memcached.h nobase_include_HEADERS+= libmemcached/memcached.hpp nobase_include_HEADERS+= libmemcached/util.h noinst_HEADERS+= libmemcached/array.h noinst_HEADERS+= libmemcached/assert.hpp noinst_HEADERS+= libmemcached/backtrace.hpp noinst_HEADERS+= libmemcached/byteorder.h noinst_HEADERS+= libmemcached/common.h noinst_HEADERS+= libmemcached/connect.hpp noinst_HEADERS+= libmemcached/continuum.hpp noinst_HEADERS+= libmemcached/do.hpp noinst_HEADERS+= libmemcached/encoding_key.h noinst_HEADERS+= libmemcached/error.hpp noinst_HEADERS+= libmemcached/initialize_query.h noinst_HEADERS+= libmemcached/internal.h noinst_HEADERS+= libmemcached/io.h noinst_HEADERS+= libmemcached/io.hpp noinst_HEADERS+= libmemcached/is.h noinst_HEADERS+= libmemcached/key.hpp noinst_HEADERS+= libmemcached/libmemcached_probes.h noinst_HEADERS+= libmemcached/memcached/protocol_binary.h noinst_HEADERS+= libmemcached/memcached/vbucket.h noinst_HEADERS+= libmemcached/memory.h noinst_HEADERS+= libmemcached/namespace.h noinst_HEADERS+= libmemcached/options.hpp noinst_HEADERS+= libmemcached/response.h noinst_HEADERS+= libmemcached/result.h noinst_HEADERS+= libmemcached/sasl.hpp noinst_HEADERS+= libmemcached/server.hpp noinst_HEADERS+= libmemcached/server_instance.h noinst_HEADERS+= libmemcached/socket.hpp noinst_HEADERS+= libmemcached/string.hpp noinst_HEADERS+= libmemcached/udp.hpp noinst_HEADERS+= libmemcached/virtual_bucket.h noinst_HEADERS+= libmemcached/watchpoint.h lib_LTLIBRARIES+= libmemcached/libmemcached.la libmemcached_libmemcached_la_CFLAGS= -DBUILDING_LIBMEMCACHED libmemcached_libmemcached_la_CXXFLAGS= -DBUILDING_LIBMEMCACHED libmemcached_libmemcached_la_SOURCES+= \ ${libhashkit_libhashkit_la_SOURCES} \ libmemcached/allocators.cc \ libmemcached/allocators.hpp \ libmemcached/analyze.cc \ libmemcached/array.c \ libmemcached/auto.cc \ libmemcached/backtrace.cc \ libmemcached/behavior.cc \ libmemcached/behavior.hpp \ libmemcached/byteorder.cc \ libmemcached/callback.cc \ libmemcached/connect.cc \ libmemcached/delete.cc \ libmemcached/do.cc \ libmemcached/dump.cc \ libmemcached/error.cc \ libmemcached/exist.cc \ libmemcached/fetch.cc \ libmemcached/flush.cc \ libmemcached/flush_buffers.cc \ libmemcached/get.cc \ libmemcached/hash.cc \ libmemcached/hash.hpp \ libmemcached/hosts.cc \ libmemcached/initialize_query.cc \ libmemcached/io.cc \ libmemcached/key.cc \ libmemcached/memcached.cc \ libmemcached/encoding_key.cc \ libmemcached/namespace.cc \ libmemcached/options.cc \ libmemcached/parse.cc \ libmemcached/purge.cc \ libmemcached/quit.cc \ libmemcached/quit.hpp \ libmemcached/response.cc \ libmemcached/result.cc \ libmemcached/sasl.cc \ libmemcached/server.cc \ libmemcached/server_list.cc \ libmemcached/server_list.hpp \ libmemcached/stats.cc \ libmemcached/storage.cc \ libmemcached/strerror.cc \ libmemcached/string.cc \ libmemcached/touch.cc \ libmemcached/verbosity.cc \ libmemcached/version.cc \ libmemcached/udp.cc \ 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} if HAVE_SASL libmemcached_libmemcached_la_CXXFLAGS+= $(LIBSASL_CPPFLAGS) libmemcached_libmemcached_la_CXXFLAGS+= $(PTHREAD_CFLAGS) libmemcached_libmemcached_la_LIBADD+= $(PTHREAD_LIBS) libmemcached_libmemcached_la_LIBADD+= $(LIBSASL_LDFLAGS) endif if HAVE_DTRACE BUILT_SOURCES+= libmemcached/dtrace_probes.h CLEANFILES+= libmemcached/dtrace_probes.h CLEANFILES+= libmemcached/libmemcached_probes.o libmemcached_libmemcached_la_DEPENDENCIES += libmemcached/libmemcached_probes.o libmemcached_libmemcached_la_LIBADD += libmemcached/libmemcached_probes.o libmemcached_libmemcached_la_SOURCES += libmemcached/libmemcached_probes.d endif SUFFIXES+= .d libmemcached/dtrace_probes.h: libmemcached/libmemcached_probes.d $(DTRACE) $(DTRACEFLAGS) -h -o ${top_srcdir}/libmemcached/dtrace_probes.h -s ${top_srcdir}/libmemcached/libmemcached_probes.d libmemcached/libmemcached_probes.o: libmemcached/libmemcached_probes.d ${libmemcached_libmemcached_la_OBJECTS} .d.o: $(DTRACE) $(DTRACEFLAGS) -o $@ -G -s libmemcached/libmemcached_probes.d libmemcached-1.0.8/libmemcached/purge.cc0000664000076400007640000001135011756611200020424 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include #define memcached_set_purging(__object, __value) ((__object)->state.is_purging= (__value)) class Purge { public: Purge(memcached_st* arg) : _memc(arg) { memcached_set_purging(_memc, true); } ~Purge() { memcached_set_purging(_memc, false); } private: memcached_st* _memc; }; class PollTimeout { public: PollTimeout(memcached_st* arg) : _timeout(arg->poll_timeout), _origin(arg->poll_timeout) { _origin = 2000; } ~PollTimeout() { _origin= _timeout; } private: int32_t _timeout; int32_t& _origin; }; bool memcached_purge(memcached_server_write_instance_st ptr) { memcached_st *root= (memcached_st *)ptr->root; if (memcached_is_purging(ptr->root) || /* already purging */ (memcached_server_response_count(ptr) < ptr->root->io_msg_watermark && ptr->io_bytes_sent < ptr->root->io_bytes_watermark) || (ptr->io_bytes_sent >= ptr->root->io_bytes_watermark && memcached_server_response_count(ptr) < 2)) { return true; } /* memcached_io_write and memcached_response may call memcached_purge so we need to be able stop any recursion.. */ Purge set_purge(root); WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET); /* Force a flush of the buffer to ensure that we don't have the n-1 pending requests buffered up.. */ if (memcached_io_write(ptr) == false) { memcached_set_error(*ptr, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT); return false; } WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET); bool is_successful= true; uint32_t no_msg= memcached_server_response_count(ptr) - 1; if (no_msg > 0) { memcached_result_st result; /* * We need to increase the timeout, because we might be waiting for * data to be sent from the server (the commands was in the output buffer * and just flushed */ PollTimeout poll_timeout(ptr->root); memcached_result_st* result_ptr= memcached_result_create(root, &result); assert(result_ptr); for (uint32_t x= 0; x < no_msg; x++) { memcached_result_reset(result_ptr); memcached_return_t rc= memcached_read_one_response(ptr, result_ptr); /* * Purge doesn't care for what kind of command results that is received. * The only kind of errors I care about if is I'm out of sync with the * protocol or have problems reading data from the network.. */ if (rc== MEMCACHED_PROTOCOL_ERROR or rc == MEMCACHED_UNKNOWN_READ_FAILURE or rc == MEMCACHED_READ_FAILURE) { WATCHPOINT_ERROR(rc); memcached_io_reset(ptr); is_successful= false; } if (ptr->root->callbacks != NULL) { memcached_callback_st cb = *ptr->root->callbacks; if (memcached_success(rc)) { for (uint32_t y= 0; y < cb.number_of_callback; y++) { if (memcached_fatal((*cb.callback[y])(ptr->root, result_ptr, cb.context))) { break; } } } } } memcached_result_free(result_ptr); } return is_successful; } libmemcached-1.0.8/libmemcached/encoding_key.cc0000664000076400007640000000413411753573717021763 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 #include static void _set_encoding_key(memcached_st& self, const char *key, size_t key_length) { hashkit_key(&self.hashkit, key, key_length); } memcached_return_t memcached_set_encoding_key(memcached_st* self, const char *key, size_t key_length) { if (self == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } _set_encoding_key(*self, key, key_length); return MEMCACHED_SUCCESS; } libmemcached-1.0.8/libmemcached/udp.cc0000664000076400007640000000577211753573717020126 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 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 /* * The udp request id consists of two seperate sections * 1) The thread id * 2) The message number * The thread id should only be set when the memcached_st struct is created * and should not be changed. * * The message num is incremented for each new message we send, this function * extracts the message number from message_id, increments it and then * writes the new value back into the header */ void increment_udp_message_id(memcached_server_write_instance_st ptr) { struct udp_datagram_header_st *header= (struct udp_datagram_header_st *)ptr->write_buffer; uint16_t cur_req= get_udp_datagram_request_id(header); int msg_num= get_msg_num_from_request_id(cur_req); int thread_id= get_thread_id_from_request_id(cur_req); if (((++msg_num) & UDP_REQUEST_ID_THREAD_MASK) != 0) msg_num= 0; header->request_id= htons((uint16_t) (thread_id | msg_num)); } bool memcached_io_init_udp_header(memcached_server_write_instance_st ptr, const uint16_t thread_id) { if (thread_id > UDP_REQUEST_ID_MAX_THREAD_ID) { return MEMCACHED_FAILURE; } struct udp_datagram_header_st *header= (struct udp_datagram_header_st *)ptr->write_buffer; header->request_id= htons(uint16_t((generate_udp_request_thread_id(thread_id)))); header->num_datagrams= htons(1); header->sequence_number= htons(0); return MEMCACHED_SUCCESS; } libmemcached-1.0.8/libmemcached/namespace.h0000664000076400007640000000365511753573717021132 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_LOCAL memcached_return_t memcached_set_namespace(memcached_st *self, const char *str, size_t length); LIBMEMCACHED_LOCAL const char * memcached_get_namespace(memcached_st *self); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached/key.hpp0000664000076400007640000000443711753573717020325 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once memcached_return_t memcached_key_test(memcached_st& memc, const char * const *keys, const size_t *key_length, size_t number_of_keys); static inline memcached_return_t memcached_validate_key_length(size_t key_length, bool binary) { if (key_length == 0) { return MEMCACHED_BAD_KEY_PROVIDED; } if (binary) { if (key_length > 0xffff) { return MEMCACHED_BAD_KEY_PROVIDED; } } else { if (key_length >= MEMCACHED_MAX_KEY) { return MEMCACHED_BAD_KEY_PROVIDED; } } return MEMCACHED_SUCCESS; } libmemcached-1.0.8/libmemcached/options.cc0000664000076400007640000001334511753573717021024 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 #include #include const char *memcached_parse_filename(memcached_st *memc) { assert_msg(memc, "Invalid memcached_st"); return memcached_array_string(memc->configure.filename); } size_t memcached_parse_filename_length(memcached_st *memc) { return memcached_array_size(memc->configure.filename); } static memcached_return_t _parse_file_options(memcached_st& self, memcached_array_st *real_name) { FILE *fp= fopen(memcached_array_string(real_name), "r"); if (not fp) { memcached_string_t error_message= memcached_array_to_string(real_name); memcached_return_t rc= memcached_set_errno(self, errno, MEMCACHED_AT, error_message); return rc; } char buffer[BUFSIZ]; memcached_return_t rc= MEMCACHED_INVALID_ARGUMENTS; while (fgets(buffer, sizeof(buffer), fp)) { size_t length= strlen(buffer); if (length == 1 and buffer[0] == '\n') continue; if (memcached_failed(rc= memcached_parse_configuration(&self, buffer, length))) break; } fclose(fp); return rc; } memcached_return_t libmemcached_check_configuration(const char *option_string, size_t length, char *error_buffer, size_t error_buffer_size) { memcached_st memc, *memc_ptr; if (option_string == NULL or length == 0) { return MEMCACHED_INVALID_ARGUMENTS; } if (error_buffer and error_buffer_size) { error_buffer[0]= 0; } if (not (memc_ptr= memcached_create(&memc))) { return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } memcached_return_t rc= memcached_parse_configuration(memc_ptr, option_string, length); if (memcached_failed(rc) and error_buffer and error_buffer_size) { strncpy(error_buffer, memcached_last_error_message(memc_ptr), error_buffer_size); error_buffer[error_buffer_size -1]= 0; } bool has_filename= memcached_behavior_get(memc_ptr, MEMCACHED_BEHAVIOR_LOAD_FROM_FILE); if (memcached_success(rc) and has_filename) { assert_msg(memcached_parse_filename(memc_ptr), "Invalid configuration file"); assert_msg(memcached_parse_filename_length(memc_ptr), "Invalid configuration file"); rc= _parse_file_options(*memc_ptr, memc_ptr->configure.filename); if (memcached_failed(rc) and error_buffer and error_buffer_size) { strncpy(error_buffer, memcached_last_error_message(memc_ptr), error_buffer_size); error_buffer[error_buffer_size -1]= 0; } } memcached_free(memc_ptr); return rc; } memcached_return_t memcached_parse_configuration(memcached_st *self, char const *option_string, size_t length) { WATCHPOINT_ASSERT(self); if (not self) { return MEMCACHED_INVALID_ARGUMENTS; } memcached_return_t rc; Context context(option_string, length, self, rc); context.start(); return rc; } void memcached_set_configuration_file(memcached_st *self, const char *filename, size_t filename_length) { assert_msg(filename, "Invalid filename"); assert_msg(filename_length, "Invalid filename_length"); memcached_array_free(self->configure.filename); self->configure.filename= memcached_strcpy(self, filename, filename_length); } memcached_return_t memcached_parse_configure_file(memcached_st& self, const char *filename, size_t length) { if (not filename) { return memcached_set_error(self, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT); } WATCHPOINT_ASSERT(self); if (not length) { return memcached_set_error(self, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT); } memcached_array_st *tmp_array= memcached_strcpy(&self, filename, length); if (not tmp_array) { return memcached_set_error(self, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); } memcached_return_t rc= memcached_parse_configure_file(self, *tmp_array); memcached_array_free(tmp_array); return rc; } memcached_return_t memcached_parse_configure_file(memcached_st& self, memcached_array_st& filename) { WATCHPOINT_ASSERT(memcached_array_size(&filename)); if (not memcached_array_size(&filename)) { return memcached_set_error(self, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT); } return _parse_file_options(self, &filename); } libmemcached-1.0.8/libmemcached/hosts.cc0000664000076400007640000004311711753573717020471 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-2010 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. * */ #include #include #include /* Protoypes (static) */ static memcached_return_t update_continuum(memcached_st *ptr); static int compare_servers(const void *p1, const void *p2) { memcached_server_instance_st a= (memcached_server_instance_st)p1; memcached_server_instance_st b= (memcached_server_instance_st)p2; int return_value= strcmp(a->hostname, b->hostname); if (return_value == 0) { return_value= (int) (a->port - b->port); } return return_value; } static void sort_hosts(memcached_st *ptr) { if (memcached_server_count(ptr)) { memcached_server_write_instance_st instance; qsort(memcached_server_list(ptr), memcached_server_count(ptr), sizeof(memcached_server_st), compare_servers); instance= memcached_server_instance_fetch(ptr, 0); instance->number_of_hosts= memcached_server_count(ptr); } } memcached_return_t run_distribution(memcached_st *ptr) { if (ptr->flags.use_sort_hosts) { sort_hosts(ptr); } switch (ptr->distribution) { case MEMCACHED_DISTRIBUTION_CONSISTENT: case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA: case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY: case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED: return update_continuum(ptr); case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: case MEMCACHED_DISTRIBUTION_MODULA: break; case MEMCACHED_DISTRIBUTION_RANDOM: srandom((uint32_t) time(NULL)); break; case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX: default: assert_msg(0, "Invalid distribution type passed to run_distribution()"); } return MEMCACHED_SUCCESS; } static uint32_t ketama_server_hash(const char *key, size_t key_length, uint32_t alignment) { unsigned char results[16]; libhashkit_md5_signature((unsigned char*)key, key_length, results); return ((uint32_t) (results[3 + alignment * 4] & 0xFF) << 24) | ((uint32_t) (results[2 + alignment * 4] & 0xFF) << 16) | ((uint32_t) (results[1 + alignment * 4] & 0xFF) << 8) | (results[0 + alignment * 4] & 0xFF); } static int continuum_item_cmp(const void *t1, const void *t2) { memcached_continuum_item_st *ct1= (memcached_continuum_item_st *)t1; memcached_continuum_item_st *ct2= (memcached_continuum_item_st *)t2; /* Why 153? Hmmm... */ WATCHPOINT_ASSERT(ct1->value != 153); if (ct1->value == ct2->value) return 0; else if (ct1->value > ct2->value) return 1; else return -1; } static memcached_return_t update_continuum(memcached_st *ptr) { uint32_t continuum_index= 0; memcached_server_st *list; uint32_t pointer_counter= 0; uint32_t pointer_per_server= MEMCACHED_POINTS_PER_SERVER; uint32_t pointer_per_hash= 1; uint32_t live_servers= 0; struct timeval now; if (gettimeofday(&now, NULL)) { return memcached_set_errno(*ptr, errno, MEMCACHED_AT); } list= memcached_server_list(ptr); /* count live servers (those without a retry delay set) */ bool is_auto_ejecting= _is_auto_eject_host(ptr); if (is_auto_ejecting) { live_servers= 0; ptr->ketama.next_distribution_rebuild= 0; for (uint32_t host_index= 0; host_index < memcached_server_count(ptr); ++host_index) { if (list[host_index].next_retry <= now.tv_sec) { live_servers++; } else { if (ptr->ketama.next_distribution_rebuild == 0 or list[host_index].next_retry < ptr->ketama.next_distribution_rebuild) { ptr->ketama.next_distribution_rebuild= list[host_index].next_retry; } } } } else { live_servers= memcached_server_count(ptr); } uint64_t is_ketama_weighted= memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED); uint32_t points_per_server= (uint32_t) (is_ketama_weighted ? MEMCACHED_POINTS_PER_SERVER_KETAMA : MEMCACHED_POINTS_PER_SERVER); if (not live_servers) { return MEMCACHED_SUCCESS; } if (live_servers > ptr->ketama.continuum_count) { memcached_continuum_item_st *new_ptr; new_ptr= libmemcached_xrealloc(ptr, ptr->ketama.continuum, (live_servers + MEMCACHED_CONTINUUM_ADDITION) * points_per_server, memcached_continuum_item_st); if (new_ptr == 0) { return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } ptr->ketama.continuum= new_ptr; ptr->ketama.continuum_count= live_servers + MEMCACHED_CONTINUUM_ADDITION; } uint64_t total_weight= 0; if (is_ketama_weighted) { for (uint32_t host_index = 0; host_index < memcached_server_count(ptr); ++host_index) { if (is_auto_ejecting == false or list[host_index].next_retry <= now.tv_sec) { total_weight += list[host_index].weight; } } } for (uint32_t host_index= 0; host_index < memcached_server_count(ptr); ++host_index) { if (is_auto_ejecting and list[host_index].next_retry > now.tv_sec) { continue; } if (is_ketama_weighted) { float pct= (float)list[host_index].weight / (float)total_weight; pointer_per_server= (uint32_t) ((::floor((float) (pct * MEMCACHED_POINTS_PER_SERVER_KETAMA / 4 * (float)live_servers + 0.0000000001))) * 4); pointer_per_hash= 4; if (DEBUG) { printf("ketama_weighted:%s|%d|%llu|%u\n", list[host_index].hostname, list[host_index].port, (unsigned long long)list[host_index].weight, pointer_per_server); } } if (ptr->distribution == MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY) { for (uint32_t pointer_index= 0; pointer_index < pointer_per_server / pointer_per_hash; pointer_index++) { char sort_host[1 +MEMCACHED_NI_MAXHOST +1 +MEMCACHED_NI_MAXSERV +1 + MEMCACHED_NI_MAXSERV ]= ""; int sort_host_length; // Spymemcached ketema key format is: hostname/ip:port-index // If hostname is not available then: /ip:port-index sort_host_length= snprintf(sort_host, sizeof(sort_host), "/%s:%u-%u", list[host_index].hostname, (uint32_t)list[host_index].port, pointer_index); if (size_t(sort_host_length) >= sizeof(sort_host) or sort_host_length < 0) { return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("snprintf(sizeof(sort_host))")); } if (DEBUG) { fprintf(stdout, "update_continuum: key is %s\n", sort_host); } if (is_ketama_weighted) { for (uint32_t x= 0; x < pointer_per_hash; x++) { uint32_t value= ketama_server_hash(sort_host, (size_t)sort_host_length, x); ptr->ketama.continuum[continuum_index].index= host_index; ptr->ketama.continuum[continuum_index++].value= value; } } else { uint32_t value= hashkit_digest(&ptr->hashkit, sort_host, (size_t)sort_host_length); ptr->ketama.continuum[continuum_index].index= host_index; ptr->ketama.continuum[continuum_index++].value= value; } } } else { for (uint32_t pointer_index= 1; pointer_index <= pointer_per_server / pointer_per_hash; pointer_index++) { char sort_host[MEMCACHED_NI_MAXHOST +1 +MEMCACHED_NI_MAXSERV +1 +MEMCACHED_NI_MAXSERV]= ""; int sort_host_length; if (list[host_index].port == MEMCACHED_DEFAULT_PORT) { sort_host_length= snprintf(sort_host, sizeof(sort_host), "%s-%u", list[host_index].hostname, pointer_index - 1); } else { sort_host_length= snprintf(sort_host, sizeof(sort_host), "%s:%u-%u", list[host_index].hostname, (uint32_t)list[host_index].port, pointer_index - 1); } if (size_t(sort_host_length) >= sizeof(sort_host) or sort_host_length < 0) { return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("snprintf(sizeof(sort_host)))")); } if (is_ketama_weighted) { for (uint32_t x = 0; x < pointer_per_hash; x++) { uint32_t value= ketama_server_hash(sort_host, (size_t)sort_host_length, x); ptr->ketama.continuum[continuum_index].index= host_index; ptr->ketama.continuum[continuum_index++].value= value; } } else { uint32_t value= hashkit_digest(&ptr->hashkit, sort_host, (size_t)sort_host_length); ptr->ketama.continuum[continuum_index].index= host_index; ptr->ketama.continuum[continuum_index++].value= value; } } } pointer_counter+= pointer_per_server; } WATCHPOINT_ASSERT(ptr); WATCHPOINT_ASSERT(ptr->ketama.continuum); WATCHPOINT_ASSERT(memcached_server_count(ptr) * MEMCACHED_POINTS_PER_SERVER <= MEMCACHED_CONTINUUM_SIZE); ptr->ketama.continuum_points_counter= pointer_counter; qsort(ptr->ketama.continuum, ptr->ketama.continuum_points_counter, sizeof(memcached_continuum_item_st), continuum_item_cmp); if (DEBUG) { for (uint32_t pointer_index= 0; memcached_server_count(ptr) && pointer_index < ((live_servers * MEMCACHED_POINTS_PER_SERVER) - 1); pointer_index++) { WATCHPOINT_ASSERT(ptr->ketama.continuum[pointer_index].value <= ptr->ketama.continuum[pointer_index + 1].value); } } return MEMCACHED_SUCCESS; } static memcached_return_t server_add(memcached_st *ptr, const memcached_string_t& hostname, in_port_t port, uint32_t weight, memcached_connection_t type) { assert_msg(ptr, "Programmer mistake, somehow server_add() was passed a NULL memcached_st"); memcached_server_st *new_host_list= libmemcached_xrealloc(ptr, memcached_server_list(ptr), (ptr->number_of_hosts + 1), memcached_server_st); if (new_host_list == NULL) { return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); } memcached_server_list_set(ptr, new_host_list); /* TODO: Check return type */ memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, memcached_server_count(ptr)); if (__server_create_with(ptr, instance, hostname, port, weight, type) == NULL) { return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); } if (weight > 1) { ptr->ketama.weighted= true; } ptr->number_of_hosts++; // @note we place the count in the bottom of the server list instance= memcached_server_instance_fetch(ptr, 0); memcached_servers_set_count(instance, memcached_server_count(ptr)); return run_distribution(ptr); } memcached_return_t memcached_server_push(memcached_st *ptr, const memcached_server_list_st list) { if (list == NULL) { return MEMCACHED_SUCCESS; } uint32_t count= memcached_server_list_count(list); memcached_server_st *new_host_list; new_host_list= libmemcached_xrealloc(ptr, memcached_server_list(ptr), (count + memcached_server_count(ptr)), memcached_server_st); if (new_host_list == NULL) { return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } memcached_server_list_set(ptr, new_host_list); for (uint32_t x= 0; x < count; x++) { memcached_server_write_instance_st instance; WATCHPOINT_ASSERT(list[x].hostname[0] != 0); // We have extended the array, and now we will find it, and use it. instance= memcached_server_instance_fetch(ptr, memcached_server_count(ptr)); WATCHPOINT_ASSERT(instance); memcached_string_t hostname= { memcached_string_make_from_cstr(list[x].hostname) }; if (__server_create_with(ptr, instance, hostname, list[x].port, list[x].weight, list[x].type) == NULL) { return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); } if (list[x].weight > 1) { ptr->ketama.weighted= true; } ptr->number_of_hosts++; } // Provides backwards compatibility with server list. { memcached_server_write_instance_st instance; instance= memcached_server_instance_fetch(ptr, 0); instance->number_of_hosts= memcached_server_count(ptr); } return run_distribution(ptr); } memcached_return_t memcached_server_add_unix_socket(memcached_st *ptr, const char *filename) { return memcached_server_add_unix_socket_with_weight(ptr, filename, 0); } memcached_return_t memcached_server_add_unix_socket_with_weight(memcached_st *ptr, const char *filename, uint32_t weight) { if (ptr == NULL) { return MEMCACHED_FAILURE; } memcached_string_t _filename= { memcached_string_make_from_cstr(filename) }; if (memcached_is_valid_servername(_filename) == false) { memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid filename for socket provided")); } return server_add(ptr, _filename, 0, weight, MEMCACHED_CONNECTION_UNIX_SOCKET); } memcached_return_t memcached_server_add_udp(memcached_st *ptr, const char *hostname, in_port_t port) { return memcached_server_add_udp_with_weight(ptr, hostname, port, 0); } memcached_return_t memcached_server_add_udp_with_weight(memcached_st *ptr, const char *, in_port_t, uint32_t) { if (ptr == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } return memcached_set_error(*ptr, MEMCACHED_DEPRECATED, MEMCACHED_AT); } memcached_return_t memcached_server_add(memcached_st *ptr, const char *hostname, in_port_t port) { return memcached_server_add_with_weight(ptr, hostname, port, 0); } memcached_return_t memcached_server_add_with_weight(memcached_st *ptr, const char *hostname, in_port_t port, uint32_t weight) { if (ptr == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } if (port == 0) { port= MEMCACHED_DEFAULT_PORT; } size_t hostname_length= hostname ? strlen(hostname) : 0; if (hostname_length == 0) { hostname= "localhost"; hostname_length= memcached_literal_param_size("localhost"); } memcached_string_t _hostname= { hostname, hostname_length }; if (memcached_is_valid_servername(_hostname) == false) { return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid hostname provided")); } return server_add(ptr, _hostname, port, weight, _hostname.c_str[0] == '/' ? MEMCACHED_CONNECTION_UNIX_SOCKET : MEMCACHED_CONNECTION_TCP); } memcached_return_t memcached_server_add_parsed(memcached_st *ptr, const char *hostname, size_t hostname_length, in_port_t port, uint32_t weight) { char buffer[NI_MAXHOST]; memcpy(buffer, hostname, hostname_length); buffer[hostname_length]= 0; memcached_string_t _hostname= { buffer, hostname_length }; return server_add(ptr, _hostname, port, weight, MEMCACHED_CONNECTION_TCP); } libmemcached-1.0.8/libmemcached/server_list.cc0000664000076400007640000001051411753573717021665 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-2010 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. * */ #include memcached_server_list_st memcached_server_list_append_with_weight(memcached_server_list_st ptr, const char *hostname, in_port_t port, uint32_t weight, memcached_return_t *error) { uint32_t count; memcached_server_list_st new_host_list; memcached_return_t unused; if (error == NULL) error= &unused; if (hostname == NULL) { hostname= "localhost"; } if (hostname[0] == '/') { port = 0; } else if (not port) { port= MEMCACHED_DEFAULT_PORT; } /* Increment count for hosts */ count= 1; if (ptr != NULL) { count+= memcached_server_list_count(ptr); } new_host_list= (memcached_server_write_instance_st)realloc(ptr, sizeof(memcached_server_st) * count); if (not new_host_list) { *error= memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); return NULL; } memcached_string_t _hostname= { memcached_string_make_from_cstr(hostname) }; /* @todo Check return type */ if (__server_create_with(NULL, &new_host_list[count-1], _hostname, port, weight, port ? MEMCACHED_CONNECTION_TCP : MEMCACHED_CONNECTION_UNIX_SOCKET) == NULL) { *error= memcached_set_errno(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); return NULL; } #if 0 // Handset allocated since new_host_list->options.is_allocated= true; #endif /* Backwards compatibility hack */ memcached_servers_set_count(new_host_list, count); *error= MEMCACHED_SUCCESS; return new_host_list; } memcached_server_list_st memcached_server_list_append(memcached_server_list_st ptr, const char *hostname, in_port_t port, memcached_return_t *error) { return memcached_server_list_append_with_weight(ptr, hostname, port, 0, error); } uint32_t memcached_server_list_count(const memcached_server_list_st self) { return (self == NULL) ? 0 : self->number_of_hosts; } memcached_server_st *memcached_server_list(const memcached_st *self) { if (self) { return self->servers; } return NULL; } void memcached_server_list_set(memcached_st *self, memcached_server_st *list) { self->servers= list; } void memcached_server_list_free(memcached_server_list_st self) { if (not self) return; for (uint32_t x= 0; x < memcached_server_list_count(self); x++) { assert_msg(not memcached_is_allocated(&self[x]), "You have called memcached_server_list_free(), but you did not pass it a valid memcached_server_list_st"); __server_free(&self[x]); } libmemcached_free(self->root, self); } libmemcached-1.0.8/libmemcached/response.h0000664000076400007640000000440211753573717021023 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #pragma once /* Read a single response from the server */ memcached_return_t memcached_read_one_response(memcached_server_write_instance_st ptr, memcached_result_st *result); memcached_return_t memcached_response(memcached_server_write_instance_st ptr, memcached_result_st *result); memcached_return_t memcached_response(memcached_server_write_instance_st ptr, char *buffer, size_t buffer_length, memcached_result_st *result); libmemcached-1.0.8/libmemcached/sasl.cc0000664000076400007640000003676211756611200020262 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include #include #if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT #if defined(HAVE_LIBSASL) && HAVE_LIBSASL #include #endif #include void memcached_set_sasl_callbacks(memcached_st *ptr, const sasl_callback_t *callbacks) { ptr->sasl.callbacks= const_cast(callbacks); ptr->sasl.is_allocated= false; } sasl_callback_t *memcached_get_sasl_callbacks(memcached_st *ptr) { return ptr->sasl.callbacks; } /** * Resolve the names for both ends of a connection * @param fd socket to check * @param laddr local address (out) * @param raddr remote address (out) * @return true on success false otherwise (errno contains more info) */ static memcached_return_t resolve_names(memcached_server_st& server, char *laddr, size_t laddr_length, char *raddr, size_t raddr_length) { char host[NI_MAXHOST]; char port[NI_MAXSERV]; struct sockaddr_storage saddr; socklen_t salen= sizeof(saddr); if (getsockname(server.fd, (struct sockaddr *)&saddr, &salen) < 0) { return memcached_set_errno(server, MEMCACHED_ERRNO, MEMCACHED_AT); } if (getnameinfo((struct sockaddr *)&saddr, salen, host, sizeof(host), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV) < 0) { return MEMCACHED_HOST_LOOKUP_FAILURE; } (void)snprintf(laddr, laddr_length, "%s;%s", host, port); salen= sizeof(saddr); if (getpeername(server.fd, (struct sockaddr *)&saddr, &salen) < 0) { return memcached_set_errno(server, MEMCACHED_ERRNO, MEMCACHED_AT); } if (getnameinfo((struct sockaddr *)&saddr, salen, host, sizeof(host), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV) < 0) { return memcached_set_error(server, MEMCACHED_HOST_LOOKUP_FAILURE, MEMCACHED_AT); } (void)snprintf(raddr, raddr_length, "%s;%s", host, port); return MEMCACHED_SUCCESS; } extern "C" { static void sasl_shutdown_function() { sasl_done(); } static volatile int sasl_startup_state= SASL_OK; pthread_mutex_t sasl_startup_state_LOCK= PTHREAD_MUTEX_INITIALIZER; static pthread_once_t sasl_startup_once= PTHREAD_ONCE_INIT; static void sasl_startup_function(void) { sasl_startup_state= sasl_client_init(NULL); if (sasl_startup_state == SASL_OK) { (void)atexit(sasl_shutdown_function); } } } // extern "C" memcached_return_t memcached_sasl_authenticate_connection(memcached_server_st *server) { if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0) { return MEMCACHED_NOT_SUPPORTED; } if (server == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } /* SANITY CHECK: SASL can only be used with the binary protocol */ if (memcached_is_binary(server->root) == false) { return memcached_set_error(*server, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("memcached_sasl_authenticate_connection() is not supported via the ASCII protocol")); } /* Try to get the supported mech from the server. Servers without SASL * support will return UNKNOWN COMMAND, so we can just treat that * as authenticated */ protocol_binary_request_no_extras request= { }; request.message.header.request.magic= PROTOCOL_BINARY_REQ; request.message.header.request.opcode= PROTOCOL_BINARY_CMD_SASL_LIST_MECHS; if (memcached_io_write(server, request.bytes, sizeof(request.bytes), 1) != sizeof(request.bytes)) { return MEMCACHED_WRITE_FAILURE; } memcached_server_response_increment(server); char mech[MEMCACHED_MAX_BUFFER]; memcached_return_t rc= memcached_response(server, mech, sizeof(mech), NULL); if (memcached_failed(rc)) { if (rc == MEMCACHED_PROTOCOL_ERROR) { /* If the server doesn't support SASL it will return PROTOCOL_ERROR. * This error may also be returned for other errors, but let's assume * that the server don't support SASL and treat it as success and * let the client fail with the next operation if the error was * caused by another problem.... */ rc= MEMCACHED_SUCCESS; } return rc; } /* set ip addresses */ char laddr[NI_MAXHOST + NI_MAXSERV]; char raddr[NI_MAXHOST + NI_MAXSERV]; if (memcached_failed(rc= resolve_names(*server, laddr, sizeof(laddr), raddr, sizeof(raddr)))) { return rc; } int pthread_error; if ((pthread_error= pthread_once(&sasl_startup_once, sasl_startup_function)) != 0) { return memcached_set_errno(*server, pthread_error, MEMCACHED_AT); } (void)pthread_mutex_lock(&sasl_startup_state_LOCK); if (sasl_startup_state != SASL_OK) { const char *sasl_error_msg= sasl_errstring(sasl_startup_state, NULL, NULL); return memcached_set_error(*server, MEMCACHED_AUTH_PROBLEM, MEMCACHED_AT, memcached_string_make_from_cstr(sasl_error_msg)); } (void)pthread_mutex_unlock(&sasl_startup_state_LOCK); sasl_conn_t *conn; int ret; if ((ret= sasl_client_new("memcached", server->hostname, laddr, raddr, server->root->sasl.callbacks, 0, &conn) ) != SASL_OK) { const char *sasl_error_msg= sasl_errstring(ret, NULL, NULL); sasl_dispose(&conn); return memcached_set_error(*server, MEMCACHED_AUTH_PROBLEM, MEMCACHED_AT, memcached_string_make_from_cstr(sasl_error_msg)); } const char *data; const char *chosenmech; unsigned int len; ret= sasl_client_start(conn, mech, NULL, &data, &len, &chosenmech); if (ret != SASL_OK and ret != SASL_CONTINUE) { const char *sasl_error_msg= sasl_errstring(ret, NULL, NULL); sasl_dispose(&conn); return memcached_set_error(*server, MEMCACHED_AUTH_PROBLEM, MEMCACHED_AT, memcached_string_make_from_cstr(sasl_error_msg)); } uint16_t keylen= (uint16_t)strlen(chosenmech); request.message.header.request.opcode= PROTOCOL_BINARY_CMD_SASL_AUTH; request.message.header.request.keylen= htons(keylen); request.message.header.request.bodylen= htonl(len + keylen); do { /* send the packet */ libmemcached_io_vector_st vector[]= { { request.bytes, sizeof(request.bytes) }, { chosenmech, keylen }, { data, len } }; if (memcached_io_writev(server, vector, 3, true) == false) { rc= MEMCACHED_WRITE_FAILURE; break; } memcached_server_response_increment(server); /* read the response */ rc= memcached_response(server, NULL, 0, NULL); if (rc != MEMCACHED_AUTH_CONTINUE) { break; } ret= sasl_client_step(conn, memcached_result_value(&server->root->result), (unsigned int)memcached_result_length(&server->root->result), NULL, &data, &len); if (ret != SASL_OK && ret != SASL_CONTINUE) { rc= MEMCACHED_AUTH_PROBLEM; break; } request.message.header.request.opcode= PROTOCOL_BINARY_CMD_SASL_STEP; request.message.header.request.bodylen= htonl(len + keylen); } while (true); /* Release resources */ sasl_dispose(&conn); return memcached_set_error(*server, rc, MEMCACHED_AT); } static int get_username(void *context, int id, const char **result, unsigned int *len) { if (!context || !result || (id != SASL_CB_USER && id != SASL_CB_AUTHNAME)) { return SASL_BADPARAM; } *result= (char *)context; if (len) { *len= (unsigned int)strlen(*result); } return SASL_OK; } static int get_password(sasl_conn_t *conn, void *context, int id, sasl_secret_t **psecret) { if (!conn || ! psecret || id != SASL_CB_PASS) { return SASL_BADPARAM; } *psecret= (sasl_secret_t *)context; return SASL_OK; } memcached_return_t memcached_set_sasl_auth_data(memcached_st *ptr, const char *username, const char *password) { if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0) { return MEMCACHED_NOT_SUPPORTED; } if (ptr == NULL or username == NULL or password == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } memcached_return_t ret; if (memcached_failed(ret= memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1))) { return memcached_set_error(*ptr, ret, MEMCACHED_AT, memcached_literal_param("Unable change to binary protocol which is required for SASL.")); } memcached_destroy_sasl_auth_data(ptr); sasl_callback_t *callbacks= libmemcached_xcalloc(ptr, 4, sasl_callback_t); size_t password_length= strlen(password); size_t username_length= strlen(username); char *name= (char *)libmemcached_malloc(ptr, username_length +1); sasl_secret_t *secret= (sasl_secret_t*)libmemcached_malloc(ptr, password_length +1 + sizeof(sasl_secret_t)); if (callbacks == NULL or name == NULL or secret == NULL) { libmemcached_free(ptr, callbacks); libmemcached_free(ptr, name); libmemcached_free(ptr, secret); return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); } secret->len= password_length; memcpy(secret->data, password, password_length); secret->data[password_length]= 0; callbacks[0].id= SASL_CB_USER; callbacks[0].proc= (int (*)())get_username; callbacks[0].context= strncpy(name, username, username_length +1); callbacks[1].id= SASL_CB_AUTHNAME; callbacks[1].proc= (int (*)())get_username; callbacks[1].context= name; callbacks[2].id= SASL_CB_PASS; callbacks[2].proc= (int (*)())get_password; callbacks[2].context= secret; callbacks[3].id= SASL_CB_LIST_END; ptr->sasl.callbacks= callbacks; ptr->sasl.is_allocated= true; return MEMCACHED_SUCCESS; } memcached_return_t memcached_destroy_sasl_auth_data(memcached_st *ptr) { if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0) { return MEMCACHED_NOT_SUPPORTED; } if (ptr == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } if (ptr->sasl.callbacks == NULL) { return MEMCACHED_SUCCESS; } if (ptr->sasl.is_allocated) { libmemcached_free(ptr, ptr->sasl.callbacks[0].context); libmemcached_free(ptr, ptr->sasl.callbacks[2].context); libmemcached_free(ptr, (void*)ptr->sasl.callbacks); ptr->sasl.is_allocated= false; } ptr->sasl.callbacks= NULL; return MEMCACHED_SUCCESS; } memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st *source) { if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0) { return MEMCACHED_NOT_SUPPORTED; } if (clone == NULL or source == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } if (source->sasl.callbacks == NULL) { return MEMCACHED_SUCCESS; } /* Hopefully we are using our own callback mechanisms.. */ if (source->sasl.callbacks[0].id == SASL_CB_USER && source->sasl.callbacks[0].proc == (int (*)())get_username && source->sasl.callbacks[1].id == SASL_CB_AUTHNAME && source->sasl.callbacks[1].proc == (int (*)())get_username && source->sasl.callbacks[2].id == SASL_CB_PASS && source->sasl.callbacks[2].proc == (int (*)())get_password && source->sasl.callbacks[3].id == SASL_CB_LIST_END) { sasl_secret_t *secret= (sasl_secret_t *)source->sasl.callbacks[2].context; return memcached_set_sasl_auth_data(clone, (const char*)source->sasl.callbacks[0].context, (const char*)secret->data); } /* * But we're not. It may work if we know what the user tries to pass * into the list, but if we don't know the ID we don't know how to handle * the context... */ ptrdiff_t total= 0; while (source->sasl.callbacks[total].id != SASL_CB_LIST_END) { switch (source->sasl.callbacks[total].id) { case SASL_CB_USER: case SASL_CB_AUTHNAME: case SASL_CB_PASS: break; default: /* I don't know how to deal with this... */ return MEMCACHED_NOT_SUPPORTED; } ++total; } sasl_callback_t *callbacks= libmemcached_xcalloc(clone, total +1, sasl_callback_t); if (callbacks == NULL) { return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } memcpy(callbacks, source->sasl.callbacks, (total + 1) * sizeof(sasl_callback_t)); /* Now update the context... */ for (ptrdiff_t x= 0; x < total; ++x) { if (callbacks[x].id == SASL_CB_USER || callbacks[x].id == SASL_CB_AUTHNAME) { callbacks[x].context= (sasl_callback_t*)libmemcached_malloc(clone, strlen((const char*)source->sasl.callbacks[x].context)); if (callbacks[x].context == NULL) { /* Failed to allocate memory, clean up previously allocated memory */ for (ptrdiff_t y= 0; y < x; ++y) { libmemcached_free(clone, clone->sasl.callbacks[y].context); } libmemcached_free(clone, callbacks); return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } strncpy((char*)callbacks[x].context, (const char*)source->sasl.callbacks[x].context, sizeof(callbacks[x].context)); } else { sasl_secret_t *src= (sasl_secret_t *)source->sasl.callbacks[x].context; sasl_secret_t *n= (sasl_secret_t*)libmemcached_malloc(clone, src->len + 1 + sizeof(*n)); if (n == NULL) { /* Failed to allocate memory, clean up previously allocated memory */ for (ptrdiff_t y= 0; y < x; ++y) { libmemcached_free(clone, clone->sasl.callbacks[y].context); } libmemcached_free(clone, callbacks); return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } memcpy(n, src, src->len + 1 + sizeof(*n)); callbacks[x].context= n; } } clone->sasl.callbacks= callbacks; clone->sasl.is_allocated= true; return MEMCACHED_SUCCESS; } #else void memcached_set_sasl_callbacks(memcached_st *, const sasl_callback_t *) { } sasl_callback_t *memcached_get_sasl_callbacks(memcached_st *) { return NULL; } memcached_return_t memcached_set_sasl_auth_data(memcached_st *, const char *, const char *) { return MEMCACHED_NOT_SUPPORTED; } memcached_return_t memcached_clone_sasl(memcached_st *, const memcached_st *) { return MEMCACHED_NOT_SUPPORTED; } #endif libmemcached-1.0.8/libmemcached/internal.h0000664000076400007640000000341211753573717021001 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached/memory.h0000664000076400007640000000674211753573717020506 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #include #include #ifdef __cplusplus #include #include #else #include #include #endif static inline void libmemcached_free(const memcached_st *self, void *mem) { if (self) { self->allocators.free(self, mem, self->allocators.context); } else if (mem) { #ifdef __cplusplus std::free(mem); #else free(mem); #endif } } static inline void *libmemcached_malloc(const memcached_st *self, const size_t size) { if (self) { return self->allocators.malloc(self, size, self->allocators.context); } #ifdef __cplusplus return std::malloc(size); #else return malloc(size); #endif } #define libmemcached_xmalloc(__memcachd_st, __type) ((__type *)libmemcached_malloc((__memcachd_st), sizeof(__type))) static inline void *libmemcached_realloc(const memcached_st *self, void *mem, size_t nmemb, const size_t size) { if (self) { return self->allocators.realloc(self, mem, nmemb * size, self->allocators.context); } #ifdef __cplusplus return std::realloc(mem, size); #else return realloc(mem, size); #endif } #define libmemcached_xrealloc(__memcachd_st, __mem, __nelem, __type) ((__type *)libmemcached_realloc((__memcachd_st), (__mem), (__nelem), sizeof(__type))) #define libmemcached_xvalloc(__memcachd_st, __nelem, __type) ((__type *)libmemcached_realloc((__memcachd_st), NULL, (__nelem), sizeof(__type))) static inline void *libmemcached_calloc(const memcached_st *self, size_t nelem, size_t size) { if (self) { return self->allocators.calloc(self, nelem, size, self->allocators.context); } #ifdef __cplusplus return std::calloc(nelem, size); #else return calloc(nelem, size); #endif } #define libmemcached_xcalloc(__memcachd_st, __nelem, __type) ((__type *)libmemcached_calloc((__memcachd_st), (__nelem), sizeof(__type))) libmemcached-1.0.8/libmemcached/libmemcached_probes.h0000664000076400007640000001217011753573717023135 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once /* * This file contains the definition of the various probes supported by * libmemcached. Currently it only support DTRACE, but just create an * implementation of the following macros to create your own sort of * probing :) */ #ifdef HAVE_DTRACE /* * Create the DTrace probes on the system using it (to support both Solaris * and MacOS X */ #include "libmemcached/dtrace_probes.h" #else /* * Provide dummy macros so that we don't need to clutter the code with * ifdefs when we want to use the probes. */ #define LIBMEMCACHED_MEMCACHED_ADD_END() #define LIBMEMCACHED_MEMCACHED_ADD_END_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_ADD_START() #define LIBMEMCACHED_MEMCACHED_ADD_START_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_CONNECT_END() #define LIBMEMCACHED_MEMCACHED_CONNECT_END_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_CONNECT_START() #define LIBMEMCACHED_MEMCACHED_CONNECT_START_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_DECREMENT_END() #define LIBMEMCACHED_MEMCACHED_DECREMENT_END_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_DECREMENT_START() #define LIBMEMCACHED_MEMCACHED_DECREMENT_START_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_DECREMENT_WITH_INITIAL_END() #define LIBMEMCACHED_MEMCACHED_DECREMENT_WITH_INITIAL_END_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_DECREMENT_WITH_INITIAL_START() #define LIBMEMCACHED_MEMCACHED_DECREMENT_WITH_INITIAL_START_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_DELETE_END() #define LIBMEMCACHED_MEMCACHED_DELETE_END_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_DELETE_START() #define LIBMEMCACHED_MEMCACHED_DELETE_START_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_FLUSH_END() #define LIBMEMCACHED_MEMCACHED_FLUSH_END_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_FLUSH_START() #define LIBMEMCACHED_MEMCACHED_FLUSH_START_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_GET_END() #define LIBMEMCACHED_MEMCACHED_GET_END_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_GET_START() #define LIBMEMCACHED_MEMCACHED_GET_START_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_TOUCH_END() #define LIBMEMCACHED_MEMCACHED_TOUCH_END_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_TOUCH_START() #define LIBMEMCACHED_MEMCACHED_TOUCH_START_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_INCREMENT_END() #define LIBMEMCACHED_MEMCACHED_INCREMENT_END_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_INCREMENT_START() #define LIBMEMCACHED_MEMCACHED_INCREMENT_START_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_END() #define LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_END_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_START() #define LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_START_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_MGET_END() #define LIBMEMCACHED_MEMCACHED_MGET_END_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_MGET_START() #define LIBMEMCACHED_MEMCACHED_MGET_START_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_REPLACE_END() #define LIBMEMCACHED_MEMCACHED_REPLACE_END_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_REPLACE_START() #define LIBMEMCACHED_MEMCACHED_REPLACE_START_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_SERVER_ADD_END() #define LIBMEMCACHED_MEMCACHED_SERVER_ADD_END_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_SERVER_ADD_START() #define LIBMEMCACHED_MEMCACHED_SERVER_ADD_START_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_SET_END() #define LIBMEMCACHED_MEMCACHED_SET_END_ENABLED() (0) #define LIBMEMCACHED_MEMCACHED_SET_START() #define LIBMEMCACHED_MEMCACHED_SET_START_ENABLED() (0) #endif libmemcached-1.0.8/libmemcached/memcached/0000775000076400007640000000000011757025120020702 5ustar00brianbrian00000000000000libmemcached-1.0.8/libmemcached/memcached/README.txt0000664000076400007640000000052011753573717022415 0ustar00brianbrian00000000000000For your convenience libmemcached contains a copy of protocol_binary.h so that you may compile libmemcached without having a memcached server with support for the binary protocol installed on your computer. Please do not modify this fine, but replace it with a fresh copy from a new distribution if they are out of sync. Trond Norbye libmemcached-1.0.8/libmemcached/memcached/protocol_binary.h0000664000076400007640000006233211753573717024306 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright (c) <2008>, Sun Microsystems, Inc. * 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. * * Neither the name of the nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY SUN MICROSYSTEMS, INC. ``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 SUN MICROSYSTEMS, INC. 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. */ /* * Summary: Constants used by to implement the binary protocol. * * Copy: See Copyright for the status of this software. * * Author: Trond Norbye */ #ifndef PROTOCOL_BINARY_H #define PROTOCOL_BINARY_H #include /** * \addtogroup Protocol * @{ */ /** * This file contains definitions of the constants and packet formats * defined in the binary specification. Please note that you _MUST_ remember * to convert each multibyte field to / from network byte order to / from * host order. */ #ifdef __cplusplus extern "C" { #endif /** * Definition of the legal "magic" values used in a packet. * See section 3.1 Magic byte */ typedef enum { PROTOCOL_BINARY_REQ = 0x80, PROTOCOL_BINARY_RES = 0x81 } protocol_binary_magic; /** * Definition of the valid response status numbers. * See section 3.2 Response Status */ typedef enum { PROTOCOL_BINARY_RESPONSE_SUCCESS = 0x00, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT = 0x01, PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS = 0x02, PROTOCOL_BINARY_RESPONSE_E2BIG = 0x03, PROTOCOL_BINARY_RESPONSE_EINVAL = 0x04, PROTOCOL_BINARY_RESPONSE_NOT_STORED = 0x05, PROTOCOL_BINARY_RESPONSE_DELTA_BADVAL = 0x06, PROTOCOL_BINARY_RESPONSE_NOT_MY_VBUCKET = 0x07, PROTOCOL_BINARY_RESPONSE_AUTH_ERROR = 0x20, PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE = 0x21, PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND = 0x81, PROTOCOL_BINARY_RESPONSE_ENOMEM = 0x82, PROTOCOL_BINARY_RESPONSE_NOT_SUPPORTED = 0x83, PROTOCOL_BINARY_RESPONSE_EINTERNAL = 0x84, PROTOCOL_BINARY_RESPONSE_EBUSY = 0x85, PROTOCOL_BINARY_RESPONSE_ETMPFAIL = 0x86 } protocol_binary_response_status; /** * Defintion of the different command opcodes. * See section 3.3 Command Opcodes */ typedef enum { PROTOCOL_BINARY_CMD_GET = 0x00, PROTOCOL_BINARY_CMD_SET = 0x01, PROTOCOL_BINARY_CMD_ADD = 0x02, PROTOCOL_BINARY_CMD_REPLACE = 0x03, PROTOCOL_BINARY_CMD_DELETE = 0x04, PROTOCOL_BINARY_CMD_INCREMENT = 0x05, PROTOCOL_BINARY_CMD_DECREMENT = 0x06, PROTOCOL_BINARY_CMD_QUIT = 0x07, PROTOCOL_BINARY_CMD_FLUSH = 0x08, PROTOCOL_BINARY_CMD_GETQ = 0x09, PROTOCOL_BINARY_CMD_NOOP = 0x0a, PROTOCOL_BINARY_CMD_VERSION = 0x0b, PROTOCOL_BINARY_CMD_GETK = 0x0c, PROTOCOL_BINARY_CMD_GETKQ = 0x0d, PROTOCOL_BINARY_CMD_APPEND = 0x0e, PROTOCOL_BINARY_CMD_PREPEND = 0x0f, PROTOCOL_BINARY_CMD_STAT = 0x10, PROTOCOL_BINARY_CMD_SETQ = 0x11, PROTOCOL_BINARY_CMD_ADDQ = 0x12, PROTOCOL_BINARY_CMD_REPLACEQ = 0x13, PROTOCOL_BINARY_CMD_DELETEQ = 0x14, PROTOCOL_BINARY_CMD_INCREMENTQ = 0x15, PROTOCOL_BINARY_CMD_DECREMENTQ = 0x16, PROTOCOL_BINARY_CMD_QUITQ = 0x17, PROTOCOL_BINARY_CMD_FLUSHQ = 0x18, PROTOCOL_BINARY_CMD_APPENDQ = 0x19, PROTOCOL_BINARY_CMD_PREPENDQ = 0x1a, PROTOCOL_BINARY_CMD_VERBOSITY = 0x1b, PROTOCOL_BINARY_CMD_TOUCH = 0x1c, PROTOCOL_BINARY_CMD_GAT = 0x1d, PROTOCOL_BINARY_CMD_GATQ = 0x1e, PROTOCOL_BINARY_CMD_GATK = 0x23, PROTOCOL_BINARY_CMD_GATKQ = 0x24, PROTOCOL_BINARY_CMD_SASL_LIST_MECHS = 0x20, PROTOCOL_BINARY_CMD_SASL_AUTH = 0x21, PROTOCOL_BINARY_CMD_SASL_STEP = 0x22, /* These commands are used for range operations and exist within * this header for use in other projects. Range operations are * not expected to be implemented in the memcached server itself. */ PROTOCOL_BINARY_CMD_RGET = 0x30, PROTOCOL_BINARY_CMD_RSET = 0x31, PROTOCOL_BINARY_CMD_RSETQ = 0x32, PROTOCOL_BINARY_CMD_RAPPEND = 0x33, PROTOCOL_BINARY_CMD_RAPPENDQ = 0x34, PROTOCOL_BINARY_CMD_RPREPEND = 0x35, PROTOCOL_BINARY_CMD_RPREPENDQ = 0x36, PROTOCOL_BINARY_CMD_RDELETE = 0x37, PROTOCOL_BINARY_CMD_RDELETEQ = 0x38, PROTOCOL_BINARY_CMD_RINCR = 0x39, PROTOCOL_BINARY_CMD_RINCRQ = 0x3a, PROTOCOL_BINARY_CMD_RDECR = 0x3b, PROTOCOL_BINARY_CMD_RDECRQ = 0x3c, /* End Range operations */ /* VBucket commands */ PROTOCOL_BINARY_CMD_SET_VBUCKET = 0x3d, PROTOCOL_BINARY_CMD_GET_VBUCKET = 0x3e, PROTOCOL_BINARY_CMD_DEL_VBUCKET = 0x3f, /* End VBucket commands */ /* TAP commands */ PROTOCOL_BINARY_CMD_TAP_CONNECT = 0x40, PROTOCOL_BINARY_CMD_TAP_MUTATION = 0x41, PROTOCOL_BINARY_CMD_TAP_DELETE = 0x42, PROTOCOL_BINARY_CMD_TAP_FLUSH = 0x43, PROTOCOL_BINARY_CMD_TAP_OPAQUE = 0x44, PROTOCOL_BINARY_CMD_TAP_VBUCKET_SET = 0x45, PROTOCOL_BINARY_CMD_TAP_CHECKPOINT_START = 0x46, PROTOCOL_BINARY_CMD_TAP_CHECKPOINT_END = 0x47, /* End TAP */ PROTOCOL_BINARY_CMD_LAST_RESERVED = 0xef, /* Scrub the data */ PROTOCOL_BINARY_CMD_SCRUB = 0xf0 } protocol_binary_command; /** * Definition of the data types in the packet * See section 3.4 Data Types */ typedef enum { PROTOCOL_BINARY_RAW_BYTES = 0x00 } protocol_binary_datatypes; /** * Definition of the header structure for a request packet. * See section 2 */ typedef union { struct { uint8_t magic; uint8_t opcode; uint16_t keylen; uint8_t extlen; uint8_t datatype; uint16_t vbucket; uint32_t bodylen; uint32_t opaque; uint64_t cas; } request; uint8_t bytes[24]; } protocol_binary_request_header; /** * Definition of the header structure for a response packet. * See section 2 */ typedef union { struct { uint8_t magic; uint8_t opcode; uint16_t keylen; uint8_t extlen; uint8_t datatype; uint16_t status; uint32_t bodylen; uint32_t opaque; uint64_t cas; } response; uint8_t bytes[24]; } protocol_binary_response_header; /** * Definition of a request-packet containing no extras */ union protocol_binary_request_no_extras { struct { protocol_binary_request_header header; } message; uint8_t bytes[sizeof(protocol_binary_request_header)]; }; typedef union protocol_binary_request_no_extras protocol_binary_request_no_extras; /** * Definition of a response-packet containing no extras */ typedef union { struct { protocol_binary_response_header header; } message; uint8_t bytes[sizeof(protocol_binary_response_header)]; } protocol_binary_response_no_extras; /** * Definition of the packet used by the get, getq, getk and getkq command. * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_get; typedef protocol_binary_request_no_extras protocol_binary_request_getq; typedef protocol_binary_request_no_extras protocol_binary_request_getk; typedef protocol_binary_request_no_extras protocol_binary_request_getkq; /** * Definition of the packet returned from a successful get, getq, getk and * getkq. * See section 4 */ typedef union { struct { protocol_binary_response_header header; struct { uint32_t flags; } body; } message; uint8_t bytes[sizeof(protocol_binary_response_header) + 4]; } protocol_binary_response_get; typedef protocol_binary_response_get protocol_binary_response_getq; typedef protocol_binary_response_get protocol_binary_response_getk; typedef protocol_binary_response_get protocol_binary_response_getkq; /** * Definition of the packet used by the delete command * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_delete; /** * Definition of the packet returned by the delete command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_delete; /** * Definition of the packet used by the flush command * See section 4 * Please note that the expiration field is optional, so remember to see * check the header.bodysize to see if it is present. */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_flush; /** * Definition of the packet returned by the flush command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_flush; /** * Definition of the packet used by set, add and replace * See section 4 */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t flags; uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 8]; } protocol_binary_request_set; typedef protocol_binary_request_set protocol_binary_request_add; typedef protocol_binary_request_set protocol_binary_request_replace; /** * Definition of the packet returned by set, add and replace * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_set; typedef protocol_binary_response_no_extras protocol_binary_response_add; typedef protocol_binary_response_no_extras protocol_binary_response_replace; /** * Definition of the noop packet * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_noop; /** * Definition of the packet returned by the noop command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_noop; /** * Definition of the structure used by the increment and decrement * command. * See section 4 */ typedef union { struct { protocol_binary_request_header header; struct { uint64_t delta; uint64_t initial; uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 20]; } protocol_binary_request_incr; typedef protocol_binary_request_incr protocol_binary_request_decr; /** * Definition of the response from an incr or decr command * command. * See section 4 */ typedef union { struct { protocol_binary_response_header header; struct { uint64_t value; } body; } message; uint8_t bytes[sizeof(protocol_binary_response_header) + 8]; } protocol_binary_response_incr; typedef protocol_binary_response_incr protocol_binary_response_decr; /** * Definition of the quit * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_quit; /** * Definition of the packet returned by the quit command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_quit; /** * Definition of the packet used by append and prepend command * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_append; typedef protocol_binary_request_no_extras protocol_binary_request_prepend; /** * Definition of the packet returned from a successful append or prepend * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_append; typedef protocol_binary_response_no_extras protocol_binary_response_prepend; /** * Definition of the packet used by the version command * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_version; /** * Definition of the packet returned from a successful version command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_version; /** * Definition of the packet used by the stats command. * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_stats; /** * Definition of the packet returned from a successful stats command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_stats; /** * Definition of the packet used by the verbosity command */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t level; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_verbosity; /** * Definition of the packet returned from the verbosity command */ typedef protocol_binary_response_no_extras protocol_binary_response_verbosity; /** * Definition of the packet used by the touch command. */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_touch; /** * Definition of the packet returned from the touch command */ typedef protocol_binary_response_no_extras protocol_binary_response_touch; /** * Definition of the packet used by the GAT(Q) command. */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_gat; typedef protocol_binary_request_gat protocol_binary_request_gatq; /** * Definition of the packet returned from the GAT(Q) */ typedef protocol_binary_response_get protocol_binary_response_gat; typedef protocol_binary_response_get protocol_binary_response_gatq; /** * Definition of a request for a range operation. * See http://code.google.com/p/memcached/wiki/RangeOps * * These types are used for range operations and exist within * this header for use in other projects. Range operations are * not expected to be implemented in the memcached server itself. */ typedef union { struct { protocol_binary_response_header header; struct { uint16_t size; uint8_t reserved; uint8_t flags; uint32_t max_results; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_rangeop; typedef protocol_binary_request_rangeop protocol_binary_request_rget; typedef protocol_binary_request_rangeop protocol_binary_request_rset; typedef protocol_binary_request_rangeop protocol_binary_request_rsetq; typedef protocol_binary_request_rangeop protocol_binary_request_rappend; typedef protocol_binary_request_rangeop protocol_binary_request_rappendq; typedef protocol_binary_request_rangeop protocol_binary_request_rprepend; typedef protocol_binary_request_rangeop protocol_binary_request_rprependq; typedef protocol_binary_request_rangeop protocol_binary_request_rdelete; typedef protocol_binary_request_rangeop protocol_binary_request_rdeleteq; typedef protocol_binary_request_rangeop protocol_binary_request_rincr; typedef protocol_binary_request_rangeop protocol_binary_request_rincrq; typedef protocol_binary_request_rangeop protocol_binary_request_rdecr; typedef protocol_binary_request_rangeop protocol_binary_request_rdecrq; /** * Definition of tap commands * See To be written * */ typedef union { struct { protocol_binary_request_header header; struct { /** * flags is a bitmask used to set properties for the * the connection. Please In order to be forward compatible * you should set all undefined bits to 0. * * If the bit require extra userdata, it will be stored * in the user-data field of the body (passed to the engine * as enginespeciffic). That means that when you parse the * flags and the engine-specific data, you have to work your * way from bit 0 and upwards to find the correct offset for * the data. * */ uint32_t flags; /** * Backfill age * * By using this flag you can limit the amount of data being * transmitted. If you don't specify a backfill age, the * server will transmit everything it contains. * * The first 8 bytes in the engine specific data contains * the oldest entry (from epoc) you're interested in. * Specifying a time in the future (for the server you are * connecting to), will cause it to start streaming current * changes. */ #define TAP_CONNECT_FLAG_BACKFILL 0x01 /** * Dump will cause the server to send the data stored on the * server, but disconnect when the keys stored in the server * are transmitted. */ #define TAP_CONNECT_FLAG_DUMP 0x02 /** * The body contains a list of 16 bits words in network byte * order specifying the vbucket ids to monitor. The first 16 * bit word contains the number of buckets. The number of 0 * means "all buckets" */ #define TAP_CONNECT_FLAG_LIST_VBUCKETS 0x04 /** * The responsibility of the vbuckets is to be transferred * over to the caller when all items are transferred. */ #define TAP_CONNECT_FLAG_TAKEOVER_VBUCKETS 0x08 /** * The tap consumer supports ack'ing of tap messages */ #define TAP_CONNECT_SUPPORT_ACK 0x10 /** * The tap consumer would prefer to just get the keys * back. If the engine supports this it will set * the TAP_FLAG_NO_VALUE flag in each of the * tap packets returned. */ #define TAP_CONNECT_REQUEST_KEYS_ONLY 0x20 /** * The body contains a list of (vbucket_id, last_checkpoint_id) * pairs. This provides the checkpoint support in TAP streams. * The last checkpoint id represents the last checkpoint that * was successfully persisted. */ #define TAP_CONNECT_CHECKPOINT 0x40 /** * The tap consumer is a registered tap client, which means that * the tap server will maintain its checkpoint cursor permanently. */ #define TAP_CONNECT_REGISTERED_CLIENT 0x80 } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_tap_connect; typedef union { struct { protocol_binary_request_header header; struct { struct { uint16_t enginespecific_length; /* * The flag section support the following flags */ /** * Request that the consumer send a response packet * for this packet. The opaque field must be preserved * in the response. */ #define TAP_FLAG_ACK 0x01 /** * The value for the key is not included in the packet */ #define TAP_FLAG_NO_VALUE 0x02 uint16_t flags; uint8_t ttl; uint8_t res1; uint8_t res2; uint8_t res3; } tap; struct { uint32_t flags; uint32_t expiration; } item; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 16]; } protocol_binary_request_tap_mutation; typedef union { struct { protocol_binary_request_header header; struct { struct { uint16_t enginespecific_length; /** * See the definition of the flags for * protocol_binary_request_tap_mutation for a description * of the available flags. */ uint16_t flags; uint8_t ttl; uint8_t res1; uint8_t res2; uint8_t res3; } tap; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 8]; } protocol_binary_request_tap_no_extras; typedef protocol_binary_request_tap_no_extras protocol_binary_request_tap_delete; typedef protocol_binary_request_tap_no_extras protocol_binary_request_tap_flush; typedef protocol_binary_request_tap_no_extras protocol_binary_request_tap_opaque; typedef protocol_binary_request_tap_no_extras protocol_binary_request_tap_vbucket_set; /** * Definition of the packet used by the scrub. */ typedef protocol_binary_request_no_extras protocol_binary_request_scrub; /** * Definition of the packet returned from scrub. */ typedef protocol_binary_response_no_extras protocol_binary_response_scrub; /** * Definition of the packet used by set vbucket */ typedef union { struct { protocol_binary_request_header header; struct { vbucket_state_t state; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + sizeof(vbucket_state_t)]; } protocol_binary_request_set_vbucket; /** * Definition of the packet returned from set vbucket */ typedef protocol_binary_response_no_extras protocol_binary_response_set_vbucket; /** * Definition of the packet used by del vbucket */ typedef protocol_binary_request_no_extras protocol_binary_request_del_vbucket; /** * Definition of the packet returned from del vbucket */ typedef protocol_binary_response_no_extras protocol_binary_response_del_vbucket; /** * Definition of the packet used by get vbucket */ typedef protocol_binary_request_no_extras protocol_binary_request_get_vbucket; /** * Definition of the packet returned from get vbucket */ typedef union { struct { protocol_binary_response_header header; struct { vbucket_state_t state; } body; } message; uint8_t bytes[sizeof(protocol_binary_response_header) + sizeof(vbucket_state_t)]; } protocol_binary_response_get_vbucket; /** * @} */ #ifdef __cplusplus } #endif #endif /* PROTOCOL_BINARY_H */ libmemcached-1.0.8/libmemcached/memcached/vbucket.h0000664000076400007640000000426611753573717022546 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif typedef enum { vbucket_state_active = 1, /**< Actively servicing a vbucket. */ vbucket_state_replica, /**< Servicing a vbucket as a replica only. */ vbucket_state_pending, /**< Pending active. */ vbucket_state_dead /**< Not in use, pending deletion. */ } vbucket_state_t; #define is_valid_vbucket_state_t(state) \ (state == vbucket_state_active || \ state == vbucket_state_replica || \ state == vbucket_state_pending || \ state == vbucket_state_dead) #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached/io.h0000664000076400007640000000341711753573717017601 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once struct libmemcached_io_vector_st { const void *buffer; size_t length; }; libmemcached-1.0.8/libmemcached/hash.cc0000664000076400007640000001270211753573717020250 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include #include #include uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash_t hash_algorithm) { return libhashkit_digest(key, key_length, (hashkit_hash_algorithm_t)hash_algorithm); } static inline uint32_t generate_hash(const memcached_st *ptr, const char *key, size_t key_length) { return hashkit_digest(&ptr->hashkit, key, key_length); } static uint32_t dispatch_host(const memcached_st *ptr, uint32_t hash) { switch (ptr->distribution) { case MEMCACHED_DISTRIBUTION_CONSISTENT: case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED: case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA: case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY: { uint32_t num= ptr->ketama.continuum_points_counter; WATCHPOINT_ASSERT(ptr->ketama.continuum); memcached_continuum_item_st *begin, *end, *left, *right, *middle; begin= left= ptr->ketama.continuum; end= right= ptr->ketama.continuum + num; while (left < right) { middle= left + (right - left) / 2; if (middle->value < hash) left= middle + 1; else right= middle; } if (right == end) right= begin; return right->index; } case MEMCACHED_DISTRIBUTION_MODULA: return hash % memcached_server_count(ptr); case MEMCACHED_DISTRIBUTION_RANDOM: return (uint32_t) random() % memcached_server_count(ptr); case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: { return memcached_virtual_bucket_get(ptr, hash); } default: case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX: WATCHPOINT_ASSERT(0); /* We have added a distribution without extending the logic */ return hash % memcached_server_count(ptr); } /* NOTREACHED */ } /* One version is public and will not modify the distribution hash, the other will. */ static inline uint32_t _generate_hash_wrapper(const memcached_st *ptr, const char *key, size_t key_length) { WATCHPOINT_ASSERT(memcached_server_count(ptr)); if (memcached_server_count(ptr) == 1) return 0; if (ptr->flags.hash_with_namespace) { size_t temp_length= memcached_array_size(ptr->_namespace) + key_length; char temp[MEMCACHED_MAX_KEY]; if (temp_length > MEMCACHED_MAX_KEY -1) return 0; strncpy(temp, memcached_array_string(ptr->_namespace), memcached_array_size(ptr->_namespace)); strncpy(temp + memcached_array_size(ptr->_namespace), key, key_length); return generate_hash(ptr, temp, temp_length); } else { return generate_hash(ptr, key, key_length); } } static inline void _regen_for_auto_eject(memcached_st *ptr) { if (_is_auto_eject_host(ptr) && ptr->ketama.next_distribution_rebuild) { struct timeval now; if (gettimeofday(&now, NULL) == 0 and now.tv_sec > ptr->ketama.next_distribution_rebuild) { run_distribution(ptr); } } } void memcached_autoeject(memcached_st *ptr) { _regen_for_auto_eject(ptr); } uint32_t memcached_generate_hash_with_redistribution(memcached_st *ptr, const char *key, size_t key_length) { uint32_t hash= _generate_hash_wrapper(ptr, key, key_length); _regen_for_auto_eject(ptr); return dispatch_host(ptr, hash); } uint32_t memcached_generate_hash(const memcached_st *ptr, const char *key, size_t key_length) { return dispatch_host(ptr, _generate_hash_wrapper(ptr, key, key_length)); } const hashkit_st *memcached_get_hashkit(const memcached_st *ptr) { return &ptr->hashkit; } memcached_return_t memcached_set_hashkit(memcached_st *self, hashkit_st *hashk) { hashkit_free(&self->hashkit); hashkit_clone(&self->hashkit, hashk); return MEMCACHED_SUCCESS; } const char * libmemcached_string_hash(memcached_hash_t type) { return libhashkit_string_hash((hashkit_hash_algorithm_t)type); } libmemcached-1.0.8/libmemcached/string.hpp0000664000076400007640000000726611753573717021046 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * libmcachedd client library. * * Copyright (C) 2011 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. * */ #pragma once #include "util/string.hpp" #define memcached_literal_param util_literal_param #define memcached_literal_param_size util_literal_param_size #define memcached_string_make_from_cstr util_string_make_from_cstr #define memcached_array_length util_array_length /** Strings are always under our control so we make some assumptions about them. 1) is_initialized is always valid. 2) A string once intialized will always be, until free where we unset this flag. 3) A string always has a root. */ memcached_string_st *memcached_string_create(memcached_st *ptr, memcached_string_st *string, size_t initial_size); memcached_return_t memcached_string_check(memcached_string_st *string, size_t need); char *memcached_string_c_copy(memcached_string_st *string); memcached_return_t memcached_string_append_character(memcached_string_st *string, char character); memcached_return_t memcached_string_append(memcached_string_st *string, const char *value, size_t length); void memcached_string_reset(memcached_string_st *string); void memcached_string_free(memcached_string_st *string); void memcached_string_free(memcached_string_st&); size_t memcached_string_length(const memcached_string_st *self); size_t memcached_string_length(const memcached_string_st&); size_t memcached_string_size(const memcached_string_st *self); const char *memcached_string_value(const memcached_string_st *self); const char *memcached_string_value(const memcached_string_st&); char *memcached_string_take_value(memcached_string_st *self); char *memcached_string_value_mutable(const memcached_string_st *self); void memcached_string_set_length(memcached_string_st *self, size_t length); void memcached_string_set_length(memcached_string_st&, const size_t length); bool memcached_string_resize(memcached_string_st&, const size_t); char *memcached_string_c_str(memcached_string_st&); libmemcached-1.0.8/libmemcached/server.hpp0000664000076400007640000001026611753573717021040 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #ifdef HAVE_SYS_TIME_H #include #endif #include memcached_server_st *__server_create_with(memcached_st *memc, memcached_server_write_instance_st host, const memcached_string_t& hostname, const in_port_t port, uint32_t weight, const memcached_connection_t type); memcached_server_st *memcached_server_clone(memcached_server_st *destination, memcached_server_st *source); memcached_return_t memcached_server_add_parsed(memcached_st *ptr, const char *hostname, size_t hostname_length, in_port_t port, uint32_t weight); void __server_free(memcached_server_st *); static inline bool memcached_is_valid_servername(const memcached_string_t& arg) { return arg.size > 0 or arg.size < NI_MAXHOST; } static inline void memcached_mark_server_as_clean(memcached_server_write_instance_st server) { server->server_failure_counter= 0; server->next_retry= 0; } static inline void set_last_disconnected_host(memcached_server_write_instance_st self) { assert(self->root); if (self->root == NULL) { return; } if (self->root->last_disconnected_server and self->root->last_disconnected_server->version == self->version) { return; } // const_cast memcached_st *root= (memcached_st *)self->root; memcached_server_free(root->last_disconnected_server); root->last_disconnected_server= memcached_server_clone(NULL, self); root->last_disconnected_server->version= self->version; } static inline void memcached_mark_server_for_timeout(memcached_server_write_instance_st server) { if (server->state != MEMCACHED_SERVER_STATE_IN_TIMEOUT) { struct timeval next_time; if (gettimeofday(&next_time, NULL) == 0) { server->next_retry= next_time.tv_sec +server->root->retry_timeout; } else { server->next_retry= 1; // Setting the value to 1 causes the timeout to occur immediatly } server->state= MEMCACHED_SERVER_STATE_IN_TIMEOUT; if (server->server_failure_counter_query_id != server->root->query_id) { server->server_failure_counter++; server->server_failure_counter_query_id= server->root->query_id; } set_last_disconnected_host(server); } } libmemcached-1.0.8/libmemcached/parse.cc0000664000076400007640000000640211753573717020437 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ /* I debated about putting this in the client library since it does an action I don't really believe belongs in the library. Frankly its too damn useful not to be here though. */ #include memcached_server_list_st memcached_servers_parse(const char *server_strings) { char *string; const char *begin_ptr; const char *end_ptr; memcached_server_st *servers= NULL; memcached_return_t rc; WATCHPOINT_ASSERT(server_strings); end_ptr= server_strings + strlen(server_strings); for (begin_ptr= server_strings, string= (char *)index(server_strings, ','); begin_ptr != end_ptr; string= (char *)index(begin_ptr, ',')) { char buffer[HUGE_STRING_LEN]; char *ptr, *ptr2; uint32_t weight= 0; if (string) { memcpy(buffer, begin_ptr, (size_t) (string - begin_ptr)); buffer[(unsigned int)(string - begin_ptr)]= 0; begin_ptr= string+1; } else { size_t length= strlen(begin_ptr); memcpy(buffer, begin_ptr, length); buffer[length]= 0; begin_ptr= end_ptr; } ptr= index(buffer, ':'); in_port_t port= 0; if (ptr) { ptr[0]= 0; ptr++; port= (in_port_t) strtoul(ptr, (char **)NULL, 10); ptr2= index(ptr, ' '); if (! ptr2) ptr2= index(ptr, ':'); if (ptr2) { ptr2++; weight = (uint32_t) strtoul(ptr2, (char **)NULL, 10); } } servers= memcached_server_list_append_with_weight(servers, buffer, port, weight, &rc); if (isspace(*begin_ptr)) begin_ptr++; } return servers; } libmemcached-1.0.8/libmemcached/io.hpp0000664000076400007640000000627011756611200020120 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once bool memcached_io_write(memcached_server_write_instance_st ptr); ssize_t memcached_io_write(memcached_server_write_instance_st ptr, const void *buffer, size_t length, bool with_flush); bool memcached_io_writev(memcached_server_write_instance_st ptr, libmemcached_io_vector_st vector[], const size_t number_of, const bool with_flush); memcached_return_t memcached_io_wait_for_write(memcached_server_write_instance_st ptr); void memcached_io_reset(memcached_server_write_instance_st ptr); memcached_return_t memcached_io_read(memcached_server_write_instance_st ptr, void *buffer, size_t length, ssize_t& nread); /* Read a line (terminated by '\n') into the buffer */ memcached_return_t memcached_io_readline(memcached_server_write_instance_st ptr, char *buffer_ptr, size_t size, size_t& total); void memcached_io_close(memcached_server_write_instance_st ptr); /* Read n bytes of data from the server and store them in dta */ memcached_return_t memcached_safe_read(memcached_server_write_instance_st ptr, void *dta, const size_t size); memcached_server_write_instance_st memcached_io_get_readable_server(memcached_st *memc); memcached_return_t memcached_io_slurp(memcached_server_write_instance_st ptr); libmemcached-1.0.8/libmemcached/do.hpp0000664000076400007640000000370211753573717020131 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once memcached_return_t memcached_vdo(memcached_server_write_instance_st ptr, libmemcached_io_vector_st vector[], const size_t count, const bool with_flush); libmemcached-1.0.8/libmemcached/response.cc0000664000076400007640000006771711753573717021203 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include #include static memcached_return_t textual_value_fetch(memcached_server_write_instance_st instance, char *buffer, memcached_result_st *result) { char *next_ptr; ssize_t read_length= 0; size_t value_length; WATCHPOINT_ASSERT(instance->root); char *end_ptr= buffer + MEMCACHED_DEFAULT_COMMAND_SIZE; memcached_result_reset(result); char *string_ptr= buffer; string_ptr+= 6; /* "VALUE " */ // Just used for cases of AES decrypt currently memcached_return_t rc= MEMCACHED_SUCCESS; /* We load the key */ { char *key= result->item_key; result->key_length= 0; for (ptrdiff_t prefix_length= memcached_array_size(instance->root->_namespace); !(iscntrl(*string_ptr) || isspace(*string_ptr)) ; string_ptr++) { if (prefix_length == 0) { *key= *string_ptr; key++; result->key_length++; } else prefix_length--; } result->item_key[result->key_length]= 0; } if (end_ptr == string_ptr) { goto read_error; } /* Flags fetch move past space */ string_ptr++; if (end_ptr == string_ptr) { goto read_error; } for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++) {}; result->item_flags= (uint32_t) strtoul(next_ptr, &string_ptr, 10); if (end_ptr == string_ptr) { goto read_error; } /* Length fetch move past space*/ string_ptr++; if (end_ptr == string_ptr) { goto read_error; } for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++) {}; value_length= (size_t)strtoull(next_ptr, &string_ptr, 10); if (end_ptr == string_ptr) { goto read_error; } /* Skip spaces */ if (*string_ptr == '\r') { /* Skip past the \r\n */ string_ptr+= 2; } else { string_ptr++; for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++) {}; result->item_cas= strtoull(next_ptr, &string_ptr, 10); } if (end_ptr < string_ptr) { goto read_error; } /* We add two bytes so that we can walk the \r\n */ if (memcached_failed(memcached_string_check(&result->value, value_length +2))) { return memcached_set_error(*instance, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); } { char *value_ptr= memcached_string_value_mutable(&result->value); /* We read the \r\n into the string since not doing so is more cycles then the waster of memory to do so. We are null terminating through, which will most likely make some people lazy about using the return length. */ size_t to_read= (value_length) + 2; memcached_return_t rrc= memcached_io_read(instance, value_ptr, to_read, read_length); if (memcached_failed(rrc) and rrc == MEMCACHED_IN_PROGRESS) { memcached_quit_server(instance, true); return memcached_set_error(*instance, MEMCACHED_IN_PROGRESS, MEMCACHED_AT); } else if (memcached_failed(rrc)) { return rrc; } } if (read_length != (ssize_t)(value_length + 2)) { goto read_error; } /* This next bit blows the API, but this is internal....*/ { char *char_ptr; char_ptr= memcached_string_value_mutable(&result->value);; char_ptr[value_length]= 0; char_ptr[value_length +1]= 0; memcached_string_set_length(&result->value, value_length); } if (memcached_is_encrypted(instance->root) and memcached_result_length(result)) { hashkit_string_st *destination; if ((destination= hashkit_decrypt(&instance->root->hashkit, memcached_result_value(result), memcached_result_length(result))) == NULL) { rc= memcached_set_error(*instance->root, MEMCACHED_FAILURE, MEMCACHED_AT, memcached_literal_param("hashkit_decrypt() failed")); } else { memcached_result_reset_value(result); if (memcached_failed(memcached_result_set_value(result, hashkit_string_c_str(destination), hashkit_string_length(destination)))) { rc= memcached_set_error(*instance->root, MEMCACHED_FAILURE, MEMCACHED_AT, memcached_literal_param("hashkit_decrypt() failed")); } } if (memcached_failed(rc)) { memcached_result_reset(result); } hashkit_string_free(destination); } return rc; read_error: memcached_io_reset(instance); return MEMCACHED_PARTIAL_READ; } static memcached_return_t textual_read_one_response(memcached_server_write_instance_st instance, char *buffer, const size_t buffer_length, memcached_result_st *result) { size_t total_read; memcached_return_t rc= memcached_io_readline(instance, buffer, buffer_length, total_read); if (memcached_failed(rc)) { return rc; } assert(total_read); switch(buffer[0]) { case 'V': { // VALUE if (buffer[1] == 'A' and buffer[2] == 'L' and buffer[3] == 'U' and buffer[4] == 'E') /* VALUE */ { /* We add back in one because we will need to search for END */ memcached_server_response_increment(instance); return textual_value_fetch(instance, buffer, result); } // VERSION else if (buffer[1] == 'E' and buffer[2] == 'R' and buffer[3] == 'S' and buffer[4] == 'I' and buffer[5] == 'O' and buffer[6] == 'N') /* VERSION */ { /* Find the space, and then move one past it to copy version */ char *response_ptr= index(buffer, ' '); char *endptr; long int version= strtol(response_ptr, &endptr, 10); if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX or version == 0) { instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX; return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse major version")); } instance->major_version= uint8_t(version); endptr++; version= strtol(endptr, &endptr, 10); if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX) { instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX; return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse minor version")); } instance->minor_version= uint8_t(version); endptr++; version= strtol(endptr, &endptr, 10); if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX) { instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX; return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version")); } instance->micro_version= uint8_t(version); return MEMCACHED_SUCCESS; } } break; case 'O': { // OK if (buffer[1] == 'K') { return MEMCACHED_SUCCESS; } } break; case 'S': { // STAT if (buffer[1] == 'T' and buffer[2] == 'A' and buffer[3] == 'T') /* STORED STATS */ { memcached_server_response_increment(instance); return MEMCACHED_STAT; } // SERVER_ERROR else if (buffer[1] == 'E' and buffer[2] == 'R' and buffer[3] == 'V' and buffer[4] == 'E' and buffer[5] == 'R' and buffer[6] == '_' and buffer[7] == 'E' and buffer[8] == 'R' and buffer[9] == 'R' and buffer[10] == 'O' and buffer[11] == 'R' ) { if (total_read == memcached_literal_param_size("SERVER_ERROR")) { return MEMCACHED_SERVER_ERROR; } if (total_read >= memcached_literal_param_size("SERVER_ERROR object too large for cache") and (memcmp(buffer, memcached_literal_param("SERVER_ERROR object too large for cache")) == 0)) { return MEMCACHED_E2BIG; } if (total_read >= memcached_literal_param_size("SERVER_ERROR out of memory storing object") and (memcmp(buffer, memcached_literal_param("SERVER_ERROR out of memory storing object")) == 0)) { return MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE; } // Move past the basic error message and whitespace char *startptr= buffer + memcached_literal_param_size("SERVER_ERROR"); if (startptr[0] == ' ') { startptr++; } char *endptr= startptr; while (*endptr != '\r' && *endptr != '\n') endptr++; return memcached_set_error(*instance, MEMCACHED_SERVER_ERROR, MEMCACHED_AT, startptr, size_t(endptr - startptr)); } // STORED else if (buffer[1] == 'T' and buffer[2] == 'O' and buffer[3] == 'R') // and buffer[4] == 'E' and buffer[5] == 'D') { return MEMCACHED_STORED; } } break; case 'D': { // DELETED if (buffer[1] == 'E' and buffer[2] == 'L' and buffer[3] == 'E' and buffer[4] == 'T' and buffer[5] == 'E' and buffer[6] == 'D') { return MEMCACHED_DELETED; } } break; case 'N': { // NOT_FOUND if (buffer[1] == 'O' and buffer[2] == 'T' and buffer[3] == '_' and buffer[4] == 'F' and buffer[5] == 'O' and buffer[6] == 'U' and buffer[7] == 'N' and buffer[8] == 'D') { return MEMCACHED_NOTFOUND; } // NOT_STORED else if (buffer[1] == 'O' and buffer[2] == 'T' and buffer[3] == '_' and buffer[4] == 'S' and buffer[5] == 'T' and buffer[6] == 'O' and buffer[7] == 'R' and buffer[8] == 'E' and buffer[9] == 'D') { return MEMCACHED_NOTSTORED; } } break; case 'E': /* PROTOCOL ERROR or END */ { // END if (buffer[1] == 'N' and buffer[2] == 'D') { return MEMCACHED_END; } #if 0 // PROTOCOL_ERROR else if (buffer[1] == 'R' and buffer[2] == 'O' and buffer[3] == 'T' and buffer[4] == 'O' and buffer[5] == 'C' and buffer[6] == 'O' and buffer[7] == 'L' and buffer[8] == '_' and buffer[9] == 'E' and buffer[10] == 'R' and buffer[11] == 'R' and buffer[12] == 'O' and buffer[13] == 'R') { return MEMCACHED_PROTOCOL_ERROR; } #endif // ERROR else if (buffer[1] == 'R' and buffer[2] == 'R' and buffer[3] == 'O' and buffer[4] == 'R') { return MEMCACHED_ERROR; } // EXISTS else if (buffer[1] == 'X' and buffer[2] == 'I' and buffer[3] == 'S' and buffer[4] == 'T' and buffer[5] == 'S') { return MEMCACHED_DATA_EXISTS; } } break; case 'T': /* TOUCHED */ { // TOUCHED if (buffer[1] == 'O' and buffer[2] == 'U' and buffer[3] == 'C' and buffer[4] == 'H' and buffer[5] == 'E' and buffer[6] == 'D') { return MEMCACHED_SUCCESS; } } break; case 'I': /* ITEM */ { // ITEM if (buffer[1] == 'T' and buffer[2] == 'E' and buffer[3] == 'M') { /* We add back in one because we will need to search for END */ memcached_server_response_increment(instance); return MEMCACHED_ITEM; } } break; case 'C': /* CLIENT ERROR */ { // CLIENT_ERROR if (buffer[1] == 'L' and buffer[2] == 'I' and buffer[3] == 'E' and buffer[4] == 'N' and buffer[5] == 'T' and buffer[6] == '_' and buffer[7] == 'E' and buffer[8] == 'R' and buffer[9] == 'R' and buffer[10] == 'O' and buffer[11] == 'R') { return MEMCACHED_CLIENT_ERROR; } } break; case '0': /* INCR/DECR response */ case '1': /* INCR/DECR response */ case '2': /* INCR/DECR response */ case '3': /* INCR/DECR response */ case '4': /* INCR/DECR response */ case '5': /* INCR/DECR response */ case '6': /* INCR/DECR response */ case '7': /* INCR/DECR response */ case '8': /* INCR/DECR response */ case '9': /* INCR/DECR response */ { unsigned long long int auto_return_value= strtoull(buffer, (char **)NULL, 10); if (auto_return_value == ULLONG_MAX and errno == ERANGE) { result->numeric_value= UINT64_MAX; return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("Numeric response was out of range")); } else if (errno == EINVAL) { result->numeric_value= UINT64_MAX; return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("Numeric response was out of range")); } result->numeric_value= uint64_t(auto_return_value); WATCHPOINT_STRING(buffer); return MEMCACHED_SUCCESS; } default: break; } buffer[total_read]= 0; #if 0 if (total_read >= sizeof("STORSTORED") -1) { fprintf(stderr, "%s:%d '%s', %.*s\n", __FILE__, __LINE__, buffer, MEMCACHED_MAX_BUFFER, instance->read_buffer); assert(memcmp(buffer,"STORSTORED", sizeof("STORSTORED") -1)); } #endif return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, buffer, total_read); } static memcached_return_t binary_read_one_response(memcached_server_write_instance_st instance, char *buffer, const size_t buffer_length, memcached_result_st *result) { memcached_return_t rc; protocol_binary_response_header header; if ((rc= memcached_safe_read(instance, &header.bytes, sizeof(header.bytes))) != MEMCACHED_SUCCESS) { WATCHPOINT_ERROR(rc); return rc; } if (header.response.magic != PROTOCOL_BINARY_RES) { return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT); } /* ** Convert the header to host local endian! */ header.response.keylen= ntohs(header.response.keylen); header.response.status= ntohs(header.response.status); header.response.bodylen= ntohl(header.response.bodylen); header.response.cas= memcached_ntohll(header.response.cas); uint32_t bodylen= header.response.bodylen; if (header.response.status == PROTOCOL_BINARY_RESPONSE_SUCCESS or header.response.status == PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE) { switch (header.response.opcode) { case PROTOCOL_BINARY_CMD_GETKQ: /* * We didn't increment the response counter for the GETKQ packet * (only the final NOOP), so we need to increment the counter again. */ memcached_server_response_increment(instance); /* FALLTHROUGH */ case PROTOCOL_BINARY_CMD_GETK: { uint16_t keylen= header.response.keylen; memcached_result_reset(result); result->item_cas= header.response.cas; if ((rc= memcached_safe_read(instance, &result->item_flags, sizeof (result->item_flags))) != MEMCACHED_SUCCESS) { WATCHPOINT_ERROR(rc); return MEMCACHED_UNKNOWN_READ_FAILURE; } result->item_flags= ntohl(result->item_flags); bodylen -= header.response.extlen; result->key_length= keylen; if (memcached_failed(rc= memcached_safe_read(instance, result->item_key, keylen))) { WATCHPOINT_ERROR(rc); return MEMCACHED_UNKNOWN_READ_FAILURE; } // Only bother with doing this if key_length > 0 if (result->key_length) { if (memcached_array_size(instance->root->_namespace) and memcached_array_size(instance->root->_namespace) >= result->key_length) { return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT); } if (memcached_array_size(instance->root->_namespace)) { result->key_length-= memcached_array_size(instance->root->_namespace); memmove(result->item_key, result->item_key +memcached_array_size(instance->root->_namespace), result->key_length); } } bodylen -= keylen; if (memcached_failed(memcached_string_check(&result->value, bodylen))) { return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } char *vptr= memcached_string_value_mutable(&result->value); if (memcached_failed(rc= memcached_safe_read(instance, vptr, bodylen))) { WATCHPOINT_ERROR(rc); return MEMCACHED_UNKNOWN_READ_FAILURE; } memcached_string_set_length(&result->value, bodylen); } break; case PROTOCOL_BINARY_CMD_INCREMENT: case PROTOCOL_BINARY_CMD_DECREMENT: { if (bodylen != sizeof(uint64_t)) { result->numeric_value= UINT64_MAX; return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT); } uint64_t val; if ((rc= memcached_safe_read(instance, &val, sizeof(val))) != MEMCACHED_SUCCESS) { result->numeric_value= UINT64_MAX; return MEMCACHED_UNKNOWN_READ_FAILURE; } result->numeric_value= memcached_ntohll(val); } break; case PROTOCOL_BINARY_CMD_SASL_LIST_MECHS: { if (header.response.keylen != 0 || bodylen + 1 > buffer_length) { return MEMCACHED_UNKNOWN_READ_FAILURE; } else { if ((rc= memcached_safe_read(instance, buffer, bodylen)) != MEMCACHED_SUCCESS) { return MEMCACHED_UNKNOWN_READ_FAILURE; } } } break; case PROTOCOL_BINARY_CMD_VERSION: { char version_buffer[32]; // @todo document this number memset(version_buffer, 0, sizeof(version_buffer)); if (memcached_safe_read(instance, version_buffer, bodylen) != MEMCACHED_SUCCESS) { return MEMCACHED_UNKNOWN_READ_FAILURE; } char *endptr; long int version= strtol(version_buffer, &endptr, 10); if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX or version == 0) { instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX; return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse major version")); } instance->major_version= uint8_t(version); endptr++; version= strtol(endptr, &endptr, 10); if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX) { instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX; return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse minor version")); } instance->minor_version= uint8_t(version); endptr++; version= strtol(endptr, &endptr, 10); if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX) { instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX; return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version")); } instance->micro_version= uint8_t(version); } break; case PROTOCOL_BINARY_CMD_FLUSH: case PROTOCOL_BINARY_CMD_QUIT: case PROTOCOL_BINARY_CMD_SET: case PROTOCOL_BINARY_CMD_ADD: case PROTOCOL_BINARY_CMD_REPLACE: case PROTOCOL_BINARY_CMD_APPEND: case PROTOCOL_BINARY_CMD_PREPEND: case PROTOCOL_BINARY_CMD_DELETE: case PROTOCOL_BINARY_CMD_TOUCH: { WATCHPOINT_ASSERT(bodylen == 0); return MEMCACHED_SUCCESS; } case PROTOCOL_BINARY_CMD_NOOP: { WATCHPOINT_ASSERT(bodylen == 0); return MEMCACHED_END; } case PROTOCOL_BINARY_CMD_STAT: { if (bodylen == 0) { return MEMCACHED_END; } else if (bodylen + 1 > buffer_length) { /* not enough space in buffer.. should not happen... */ return MEMCACHED_UNKNOWN_READ_FAILURE; } else { size_t keylen= header.response.keylen; memset(buffer, 0, buffer_length); if ((rc= memcached_safe_read(instance, buffer, keylen)) != MEMCACHED_SUCCESS || (rc= memcached_safe_read(instance, buffer + keylen + 1, bodylen - keylen)) != MEMCACHED_SUCCESS) { WATCHPOINT_ERROR(rc); return MEMCACHED_UNKNOWN_READ_FAILURE; } } } break; case PROTOCOL_BINARY_CMD_SASL_AUTH: case PROTOCOL_BINARY_CMD_SASL_STEP: { memcached_result_reset(result); result->item_cas= header.response.cas; if (memcached_string_check(&result->value, bodylen) != MEMCACHED_SUCCESS) return MEMCACHED_MEMORY_ALLOCATION_FAILURE; char *vptr= memcached_string_value_mutable(&result->value); if ((rc= memcached_safe_read(instance, vptr, bodylen)) != MEMCACHED_SUCCESS) { WATCHPOINT_ERROR(rc); return MEMCACHED_UNKNOWN_READ_FAILURE; } memcached_string_set_length(&result->value, bodylen); } break; default: { /* Command not implemented yet! */ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT); } } } else if (header.response.bodylen) { /* What should I do with the error message??? just discard it for now */ char hole[SMALL_STRING_LEN]; while (bodylen > 0) { size_t nr= (bodylen > SMALL_STRING_LEN) ? SMALL_STRING_LEN : bodylen; if ((rc= memcached_safe_read(instance, hole, nr)) != MEMCACHED_SUCCESS) { WATCHPOINT_ERROR(rc); return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT); } bodylen-= (uint32_t) nr; } /* This might be an error from one of the quiet commands.. if * so, just throw it away and get the next one. What about creating * a callback to the user with the error information? */ switch (header.response.opcode) { case PROTOCOL_BINARY_CMD_SETQ: case PROTOCOL_BINARY_CMD_ADDQ: case PROTOCOL_BINARY_CMD_REPLACEQ: case PROTOCOL_BINARY_CMD_APPENDQ: case PROTOCOL_BINARY_CMD_PREPENDQ: return binary_read_one_response(instance, buffer, buffer_length, result); default: break; } } rc= MEMCACHED_SUCCESS; if (header.response.status != 0) { switch (header.response.status) { case PROTOCOL_BINARY_RESPONSE_KEY_ENOENT: rc= MEMCACHED_NOTFOUND; break; case PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS: rc= MEMCACHED_DATA_EXISTS; break; case PROTOCOL_BINARY_RESPONSE_NOT_STORED: rc= MEMCACHED_NOTSTORED; break; case PROTOCOL_BINARY_RESPONSE_E2BIG: rc= MEMCACHED_E2BIG; break; case PROTOCOL_BINARY_RESPONSE_ENOMEM: rc= MEMCACHED_MEMORY_ALLOCATION_FAILURE; break; case PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE: rc= MEMCACHED_AUTH_CONTINUE; break; case PROTOCOL_BINARY_RESPONSE_AUTH_ERROR: rc= MEMCACHED_AUTH_FAILURE; break; case PROTOCOL_BINARY_RESPONSE_EINVAL: case PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND: default: return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT); break; } } return rc; } static memcached_return_t _read_one_response(memcached_server_write_instance_st instance, char *buffer, const size_t buffer_length, memcached_result_st *result) { memcached_server_response_decrement(instance); if (result == NULL) { memcached_st *root= (memcached_st *)instance->root; result = &root->result; } memcached_return_t rc; if (memcached_is_binary(instance->root)) { rc= binary_read_one_response(instance, buffer, buffer_length, result); } else { rc= textual_read_one_response(instance, buffer, buffer_length, result); } if (memcached_fatal(rc)) { memcached_io_reset(instance); } return rc; } memcached_return_t memcached_read_one_response(memcached_server_write_instance_st instance, memcached_result_st *result) { char buffer[SMALL_STRING_LEN]; if (memcached_is_udp(instance->root)) { return memcached_set_error(*instance, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT); } return _read_one_response(instance, buffer, sizeof(buffer), result); } memcached_return_t memcached_response(memcached_server_write_instance_st instance, memcached_result_st *result) { char buffer[1024]; return memcached_response(instance, buffer, sizeof(buffer), result); } memcached_return_t memcached_response(memcached_server_write_instance_st instance, char *buffer, size_t buffer_length, memcached_result_st *result) { if (memcached_is_udp(instance->root)) { return memcached_set_error(*instance, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT); } /* We may have old commands in the buffer not set, first purge */ if ((instance->root->flags.no_block) and (memcached_is_processing_input(instance->root) == false)) { (void)memcached_io_write(instance); } /* * The previous implementation purged all pending requests and just * returned the last one. Purge all pending messages to ensure backwards * compatibility. */ if (memcached_is_binary(instance->root) == false and memcached_server_response_count(instance) > 1) { memcached_result_st junked_result; memcached_result_st *junked_result_ptr= memcached_result_create(instance->root, &junked_result); assert(junked_result_ptr); while (memcached_server_response_count(instance) > 1) { memcached_return_t rc= _read_one_response(instance, buffer, buffer_length, junked_result_ptr); // @TODO should we return an error on another but a bad read case? if (memcached_fatal(rc)) { memcached_result_free(junked_result_ptr); return rc; } } memcached_result_free(junked_result_ptr); } return _read_one_response(instance, buffer, buffer_length, result); } libmemcached-1.0.8/libmemcached/backtrace.cc0000664000076400007640000000744311753573717021252 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * libmcachedd client library. * * Copyright (C) 2011 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 #include #include #ifdef HAVE_EXECINFO_H #include #endif #ifdef HAVE_CXXABI_H #include #endif #ifdef HAVE_GCC_ABI_DEMANGLE #define USE_DEMANGLE 1 #else #define USE_DEMANGLE 0 #endif void custom_backtrace(void) { #ifdef HAVE_EXECINFO_H void *array[50]; size_t size= backtrace(array, 50); char **strings= backtrace_symbols(array, size); if (strings == NULL) { return; } fprintf(stderr, "Number of stack frames obtained: %lu\n", (unsigned long)size); char *named_function= (char *)std::realloc(NULL, 1024); if (named_function == NULL) { std::free(strings); return; } for (size_t x= 1; x < size; x++) { if (USE_DEMANGLE) { size_t sz= 200; char *named_function_ptr= (char *)std::realloc(named_function, sz); if (named_function_ptr == NULL) { continue; } named_function= named_function_ptr; char *begin_name= 0; char *begin_offset= 0; char *end_offset= 0; for (char *j= strings[x]; *j; ++j) { if (*j == '(') { begin_name= j; } else if (*j == '+') { begin_offset= j; } else if (*j == ')' and begin_offset) { end_offset= j; break; } } if (begin_name and begin_offset and end_offset and begin_name < begin_offset) { *begin_name++= '\0'; *begin_offset++= '\0'; *end_offset= '\0'; int status; char *ret= abi::__cxa_demangle(begin_name, named_function, &sz, &status); if (ret) // realloc()'ed string { named_function= ret; fprintf(stderr, " %s : %s()+%s\n", strings[x], begin_name, begin_offset); } else { fprintf(stderr, " %s : %s()+%s\n", strings[x], begin_name, begin_offset); } } else { fprintf(stderr, " %s\n", strings[x]); } } else { fprintf(stderr, " unmangled: %s\n", strings[x]); } } std::free(named_function); std::free(strings); #endif // HAVE_EXECINFO_H } libmemcached-1.0.8/libmemcached/virtual_bucket.h0000664000076400007640000000445111753573717022214 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_LOCAL memcached_return_t memcached_virtual_bucket_create(memcached_st *self, const uint32_t *host_map, const uint32_t *forward_map, const uint32_t buckets, const uint32_t replicas); LIBMEMCACHED_LOCAL uint32_t memcached_virtual_bucket_get(const memcached_st *self, uint32_t digest); LIBMEMCACHED_LOCAL void memcached_virtual_bucket_free(memcached_st *self); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached/io.cc0000664000076400007640000005464011756611200017722 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include enum memc_read_or_write { MEM_READ, MEM_WRITE }; /** * Try to fill the input buffer for a server with as much * data as possible. * * @param ptr the server to pack */ static bool repack_input_buffer(memcached_server_write_instance_st ptr) { if (ptr->read_ptr != ptr->read_buffer) { /* Move all of the data to the beginning of the buffer so ** that we can fit more data into the buffer... */ memmove(ptr->read_buffer, ptr->read_ptr, ptr->read_buffer_length); ptr->read_ptr= ptr->read_buffer; ptr->read_data_length= ptr->read_buffer_length; } /* There is room in the buffer, try to fill it! */ if (ptr->read_buffer_length != MEMCACHED_MAX_BUFFER) { do { /* Just try a single read to grab what's available */ ssize_t nr; if ((nr= recv(ptr->fd, ptr->read_ptr + ptr->read_data_length, MEMCACHED_MAX_BUFFER - ptr->read_data_length, MSG_DONTWAIT)) <= 0) { if (nr == 0) { memcached_set_error(*ptr, MEMCACHED_CONNECTION_FAILURE, MEMCACHED_AT); } else { switch (get_socket_errno()) { case EINTR: continue; #if EWOULDBLOCK != EAGAIN case EWOULDBLOCK: #endif case EAGAIN: #ifdef TARGET_OS_LINUX case ERESTART: #endif break; // No IO is fine, we can just move on default: memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT); } } break; } else // We read data, append to our read buffer { ptr->read_data_length+= size_t(nr); ptr->read_buffer_length+= size_t(nr); return true; } } while (false); } return false; } /** * If the we have callbacks connected to this server structure * we may start process the input queue and fire the callbacks * for the incomming messages. This function is _only_ called * when the input buffer is full, so that we _know_ that we have * at least _one_ message to process. * * @param ptr the server to star processing iput messages for * @return true if we processed anything, false otherwise */ static bool process_input_buffer(memcached_server_write_instance_st ptr) { /* ** We might be able to process some of the response messages if we ** have a callback set up */ if (ptr->root->callbacks != NULL) { /* * We might have responses... try to read them out and fire * callbacks */ memcached_callback_st cb= *ptr->root->callbacks; memcached_set_processing_input((memcached_st *)ptr->root, true); char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; memcached_st *root= (memcached_st *)ptr->root; memcached_return_t error= memcached_response(ptr, buffer, sizeof(buffer), &root->result); memcached_set_processing_input(root, false); if (error == MEMCACHED_SUCCESS) { for (unsigned int x= 0; x < cb.number_of_callback; x++) { error= (*cb.callback[x])(ptr->root, &root->result, cb.context); if (error != MEMCACHED_SUCCESS) { break; } } /* @todo what should I do with the error message??? */ } /* @todo what should I do with other error messages?? */ return true; } return false; } static memcached_return_t io_wait(memcached_server_write_instance_st ptr, const memc_read_or_write read_or_write) { /* ** We are going to block on write, but at least on Solaris we might block ** on write if we haven't read anything from our input buffer.. ** Try to purge the input buffer if we don't do any flow control in the ** application layer (just sending a lot of data etc) ** The test is moved down in the purge function to avoid duplication of ** the test. */ if (read_or_write == MEM_WRITE) { if (memcached_purge(ptr) == false) { return MEMCACHED_FAILURE; } } struct pollfd fds; fds.fd= ptr->fd; fds.events= POLLIN; fds.revents= 0; if (read_or_write == MEM_WRITE) /* write */ { fds.events= POLLOUT; ptr->io_wait_count.write++; } else { ptr->io_wait_count.read++; } if (ptr->root->poll_timeout == 0) // Mimic 0 causes timeout behavior (not all platforms do this) { ptr->io_wait_count.timeouts++; return memcached_set_error(*ptr, MEMCACHED_TIMEOUT, MEMCACHED_AT); } int local_errno; size_t loop_max= 5; while (--loop_max) // While loop is for ERESTART or EINTR { int active_fd= poll(&fds, 1, ptr->root->poll_timeout); if (active_fd >= 1) { assert_msg(active_fd == 1 , "poll() returned an unexpected value"); return MEMCACHED_SUCCESS; } else if (active_fd == 0) { ptr->io_wait_count.timeouts++; return memcached_set_error(*ptr, MEMCACHED_TIMEOUT, MEMCACHED_AT); } // Only an error should result in this code being called. local_errno= get_socket_errno(); // We cache in case memcached_quit_server() modifies errno assert_msg(active_fd == -1 , "poll() returned an unexpected value"); switch (local_errno) { #ifdef TARGET_OS_LINUX case ERESTART: #endif case EINTR: continue; case EFAULT: case ENOMEM: return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); case EINVAL: return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("RLIMIT_NOFILE exceeded, or if OSX the timeout value was invalid")); default: if (fds.revents & POLLERR) { int err; socklen_t len= sizeof (err); if (getsockopt(ptr->fd, SOL_SOCKET, SO_ERROR, &err, &len) == 0) { if (err == 0) // treat this as EINTR { continue; } local_errno= err; } } break; } break; // should only occur from poll error } memcached_quit_server(ptr, true); return memcached_set_errno(*ptr, local_errno, MEMCACHED_AT); } static bool io_flush(memcached_server_write_instance_st ptr, const bool with_flush, memcached_return_t& error) { /* ** We might want to purge the input buffer if we haven't consumed ** any output yet... The test for the limits is the purge is inline ** in the purge function to avoid duplicating the logic.. */ { WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET); if (memcached_purge(ptr) == false) { return false; } } char *local_write_ptr= ptr->write_buffer; size_t write_length= ptr->write_buffer_offset; error= MEMCACHED_SUCCESS; WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET); /* Looking for memory overflows */ #if defined(DEBUG) if (write_length == MEMCACHED_MAX_BUFFER) WATCHPOINT_ASSERT(ptr->write_buffer == local_write_ptr); WATCHPOINT_ASSERT((ptr->write_buffer + MEMCACHED_MAX_BUFFER) >= (local_write_ptr + write_length)); #endif while (write_length) { WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET); WATCHPOINT_ASSERT(write_length > 0); int flags= with_flush ? MSG_NOSIGNAL|MSG_DONTWAIT : MSG_NOSIGNAL|MSG_DONTWAIT|MSG_MORE; ssize_t sent_length= ::send(ptr->fd, local_write_ptr, write_length, flags); if (sent_length == SOCKET_ERROR) { #if 0 // @todo I should look at why we hit this bit of code hard frequently WATCHPOINT_ERRNO(get_socket_errno()); WATCHPOINT_NUMBER(get_socket_errno()); #endif switch (get_socket_errno()) { case ENOBUFS: continue; #if EWOULDBLOCK != EAGAIN case EWOULDBLOCK: #endif case EAGAIN: { /* * We may be blocked on write because the input buffer * is full. Let's check if we have room in our input * buffer for more data and retry the write before * waiting.. */ if (repack_input_buffer(ptr) or process_input_buffer(ptr)) { continue; } memcached_return_t rc= io_wait(ptr, MEM_WRITE); if (memcached_success(rc)) { continue; } else if (rc == MEMCACHED_TIMEOUT) { return false; } memcached_quit_server(ptr, true); error= memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT); return false; } case ENOTCONN: case EPIPE: default: memcached_quit_server(ptr, true); error= memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT); WATCHPOINT_ASSERT(ptr->fd == INVALID_SOCKET); return false; } } ptr->io_bytes_sent+= uint32_t(sent_length); local_write_ptr+= sent_length; write_length-= uint32_t(sent_length); } WATCHPOINT_ASSERT(write_length == 0); ptr->write_buffer_offset= 0; return true; } memcached_return_t memcached_io_wait_for_write(memcached_server_write_instance_st ptr) { return io_wait(ptr, MEM_WRITE); } memcached_return_t memcached_io_read(memcached_server_write_instance_st ptr, void *buffer, size_t length, ssize_t& nread) { assert(memcached_is_udp(ptr->root) == false); assert_msg(ptr, "Programmer error, memcached_io_read() recieved an invalid memcached_server_write_instance_st"); // Programmer error char *buffer_ptr= static_cast(buffer); if (ptr->fd == INVALID_SOCKET) { #if 0 assert_msg(int(ptr->state) <= int(MEMCACHED_SERVER_STATE_ADDRINFO), "Programmer error, invalid socket state"); #endif return MEMCACHED_CONNECTION_FAILURE; } while (length) { if (ptr->read_buffer_length == 0) { ssize_t data_read; do { data_read= ::recv(ptr->fd, ptr->read_buffer, MEMCACHED_MAX_BUFFER, MSG_DONTWAIT); if (data_read == SOCKET_ERROR) { switch (get_socket_errno()) { case EINTR: // We just retry continue; case ETIMEDOUT: // OSX #if EWOULDBLOCK != EAGAIN case EWOULDBLOCK: #endif case EAGAIN: #ifdef TARGET_OS_LINUX case ERESTART: #endif { memcached_return_t io_wait_ret; if (memcached_success(io_wait_ret= io_wait(ptr, MEM_READ))) { continue; } return io_wait_ret; } /* fall through */ case ENOTCONN: // Programmer Error WATCHPOINT_ASSERT(0); case ENOTSOCK: WATCHPOINT_ASSERT(0); case EBADF: assert_msg(ptr->fd != INVALID_SOCKET, "Programmer error, invalid socket"); case EINVAL: case EFAULT: case ECONNREFUSED: default: { memcached_quit_server(ptr, true); nread= -1; return memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT); } } } else if (data_read == 0) { /* EOF. Any data received so far is incomplete so discard it. This always reads by byte in case of TCP and protocol enforcement happens at memcached_response() looking for '\n'. We do not care for UDB which requests 8 bytes at once. Generally, this means that connection went away. Since for blocking I/O we do not return 0 and for non-blocking case it will return EGAIN if data is not immediatly available. */ WATCHPOINT_STRING("We had a zero length recv()"); memcached_quit_server(ptr, true); nread= -1; return memcached_set_error(*ptr, MEMCACHED_CONNECTION_FAILURE, MEMCACHED_AT, memcached_literal_param("::rec() returned zero, server has disconnected")); } } while (data_read <= 0); ptr->io_bytes_sent = 0; ptr->read_data_length= (size_t) data_read; ptr->read_buffer_length= (size_t) data_read; ptr->read_ptr= ptr->read_buffer; } if (length > 1) { size_t difference; difference= (length > ptr->read_buffer_length) ? ptr->read_buffer_length : length; memcpy(buffer_ptr, ptr->read_ptr, difference); length -= difference; ptr->read_ptr+= difference; ptr->read_buffer_length-= difference; buffer_ptr+= difference; } else { *buffer_ptr= *ptr->read_ptr; ptr->read_ptr++; ptr->read_buffer_length--; buffer_ptr++; break; } } nread= ssize_t(buffer_ptr - (char*)buffer); return MEMCACHED_SUCCESS; } memcached_return_t memcached_io_slurp(memcached_server_write_instance_st ptr) { assert_msg(ptr, "Programmer error, invalid memcached_server_write_instance_st"); assert(memcached_is_udp(ptr->root) == false); if (ptr->fd == INVALID_SOCKET) { assert_msg(int(ptr->state) <= int(MEMCACHED_SERVER_STATE_ADDRINFO), "Invalid socket state"); return MEMCACHED_CONNECTION_FAILURE; } ssize_t data_read; char buffer[MEMCACHED_MAX_BUFFER]; do { data_read= recv(ptr->fd, ptr->read_buffer, sizeof(buffer), MSG_DONTWAIT); if (data_read == SOCKET_ERROR) { switch (get_socket_errno()) { case EINTR: // We just retry continue; case ETIMEDOUT: // OSX #if EWOULDBLOCK != EAGAIN case EWOULDBLOCK: #endif case EAGAIN: #ifdef TARGET_OS_LINUX case ERESTART: #endif if (memcached_success(io_wait(ptr, MEM_READ))) { continue; } return MEMCACHED_IN_PROGRESS; /* fall through */ case ENOTCONN: // Programmer Error assert(0); case ENOTSOCK: assert(0); case EBADF: assert_msg(ptr->fd != INVALID_SOCKET, "Invalid socket state"); case EINVAL: case EFAULT: case ECONNREFUSED: default: return MEMCACHED_CONNECTION_FAILURE; // We want this! } } } while (data_read > 0); return MEMCACHED_CONNECTION_FAILURE; } static bool _io_write(memcached_server_write_instance_st ptr, const void *buffer, size_t length, bool with_flush, size_t& written) { assert(ptr->fd != INVALID_SOCKET); assert(memcached_is_udp(ptr->root) == false); const char *buffer_ptr= static_cast(buffer); const size_t original_length= length; while (length) { char *write_ptr; size_t buffer_end= MEMCACHED_MAX_BUFFER; size_t should_write= buffer_end -ptr->write_buffer_offset; should_write= (should_write < length) ? should_write : length; write_ptr= ptr->write_buffer + ptr->write_buffer_offset; memcpy(write_ptr, buffer_ptr, should_write); ptr->write_buffer_offset+= should_write; buffer_ptr+= should_write; length-= should_write; if (ptr->write_buffer_offset == buffer_end) { WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET); memcached_return_t rc; if (io_flush(ptr, with_flush, rc) == false) { written= original_length -length; return false; } } } if (with_flush) { memcached_return_t rc; WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET); if (io_flush(ptr, with_flush, rc) == false) { written= original_length -length; return false; } } written= original_length -length; return true; } bool memcached_io_write(memcached_server_write_instance_st ptr) { size_t written; return _io_write(ptr, NULL, 0, true, written); } ssize_t memcached_io_write(memcached_server_write_instance_st ptr, const void *buffer, const size_t length, const bool with_flush) { size_t written; if (_io_write(ptr, buffer, length, with_flush, written) == false) { return -1; } return ssize_t(written); } bool memcached_io_writev(memcached_server_write_instance_st ptr, libmemcached_io_vector_st vector[], const size_t number_of, const bool with_flush) { ssize_t complete_total= 0; ssize_t total= 0; for (size_t x= 0; x < number_of; x++, vector++) { complete_total+= vector->length; if (vector->length) { size_t written; if ((_io_write(ptr, vector->buffer, vector->length, false, written)) == false) { return false; } total+= written; } } if (with_flush) { if (memcached_io_write(ptr) == false) { return false; } } return (complete_total == total); } void memcached_io_close(memcached_server_write_instance_st ptr) { if (ptr->fd == INVALID_SOCKET) { return; } /* in case of death shutdown to avoid blocking at close() */ if (shutdown(ptr->fd, SHUT_RDWR) == SOCKET_ERROR && get_socket_errno() != ENOTCONN) { WATCHPOINT_NUMBER(ptr->fd); WATCHPOINT_ERRNO(get_socket_errno()); WATCHPOINT_ASSERT(get_socket_errno()); } if (closesocket(ptr->fd) == SOCKET_ERROR) { WATCHPOINT_ERRNO(get_socket_errno()); } ptr->state= MEMCACHED_SERVER_STATE_NEW; ptr->fd= INVALID_SOCKET; } memcached_server_write_instance_st memcached_io_get_readable_server(memcached_st *memc) { #define MAX_SERVERS_TO_POLL 100 struct pollfd fds[MAX_SERVERS_TO_POLL]; nfds_t host_index= 0; for (uint32_t x= 0; x < memcached_server_count(memc) and host_index < MAX_SERVERS_TO_POLL; ++x) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc, x); if (instance->read_buffer_length > 0) /* I have data in the buffer */ { return instance; } if (memcached_server_response_count(instance) > 0) { fds[host_index].events = POLLIN; fds[host_index].revents = 0; fds[host_index].fd = instance->fd; ++host_index; } } if (host_index < 2) { /* We have 0 or 1 server with pending events.. */ for (uint32_t x= 0; x< memcached_server_count(memc); ++x) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc, x); if (memcached_server_response_count(instance) > 0) { return instance; } } return NULL; } int error= poll(fds, host_index, memc->poll_timeout); switch (error) { case -1: memcached_set_errno(*memc, get_socket_errno(), MEMCACHED_AT); /* FALLTHROUGH */ case 0: break; default: for (nfds_t x= 0; x < host_index; ++x) { if (fds[x].revents & POLLIN) { for (uint32_t y= 0; y < memcached_server_count(memc); ++y) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc, y); if (instance->fd == fds[x].fd) { return instance; } } } } } return NULL; } /* Eventually we will just kill off the server with the problem. */ void memcached_io_reset(memcached_server_write_instance_st ptr) { memcached_quit_server(ptr, true); } /** * Read a given number of bytes from the server and place it into a specific * buffer. Reset the IO channel on this server if an error occurs. */ memcached_return_t memcached_safe_read(memcached_server_write_instance_st ptr, void *dta, const size_t size) { size_t offset= 0; char *data= static_cast(dta); while (offset < size) { ssize_t nread; memcached_return_t rc; while (memcached_continue(rc= memcached_io_read(ptr, data + offset, size - offset, nread))) { }; if (memcached_failed(rc)) { return rc; } offset+= size_t(nread); } return MEMCACHED_SUCCESS; } memcached_return_t memcached_io_readline(memcached_server_write_instance_st ptr, char *buffer_ptr, size_t size, size_t& total_nr) { total_nr= 0; bool line_complete= false; while (line_complete == false) { if (ptr->read_buffer_length == 0) { /* * We don't have any data in the buffer, so let's fill the read * buffer. Call the standard read function to avoid duplicating * the logic. */ ssize_t nread; memcached_return_t rc= memcached_io_read(ptr, buffer_ptr, 1, nread); if (memcached_failed(rc) and rc == MEMCACHED_IN_PROGRESS) { memcached_quit_server(ptr, true); return memcached_set_error(*ptr, rc, MEMCACHED_AT); } else if (memcached_failed(rc)) { return rc; } if (*buffer_ptr == '\n') { line_complete= true; } ++buffer_ptr; ++total_nr; } /* Now let's look in the buffer and copy as we go! */ while (ptr->read_buffer_length and total_nr < size and line_complete == false) { *buffer_ptr = *ptr->read_ptr; if (*buffer_ptr == '\n') { line_complete = true; } --ptr->read_buffer_length; ++ptr->read_ptr; ++total_nr; ++buffer_ptr; } if (total_nr == size) { return MEMCACHED_PROTOCOL_ERROR; } } return MEMCACHED_SUCCESS; } libmemcached-1.0.8/libmemcached/flush_buffers.cc0000664000076400007640000000451611753573717022166 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #include memcached_return_t memcached_flush_buffers(memcached_st *memc) { memcached_return_t ret= MEMCACHED_SUCCESS; for (uint32_t x= 0; x < memcached_server_count(memc); ++x) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc, x); if (instance->write_buffer_offset != 0) { if (instance->fd == INVALID_SOCKET and (ret= memcached_connect(instance)) != MEMCACHED_SUCCESS) { WATCHPOINT_ERROR(ret); return ret; } if (memcached_io_write(instance) == false) { ret= MEMCACHED_SOME_ERRORS; } } } return ret; } libmemcached-1.0.8/libmemcached/is.h0000664000076400007640000000553611756611200017570 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 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. * */ #pragma once /* These are private */ #define memcached_is_allocated(__object) ((__object)->options.is_allocated) #define memcached_is_encrypted(__object) ((__object)->hashkit._key) #define memcached_is_udp(__object) ((__object)->flags.use_udp) #define memcached_is_verify_key(__object) ((__object)->flags.verify_key) #define memcached_is_binary(__object) ((__object)->flags.binary_protocol) #define memcached_is_initialized(__object) ((__object)->options.is_initialized) #define memcached_is_purging(__object) ((__object)->state.is_purging) #define memcached_is_processing_input(__object) ((__object)->state.is_processing_input) #define memcached_is_buffering(__object) ((__object)->flags.buffer_requests) #define memcached_is_replying(__object) ((__object)->flags.reply) #define memcached_has_error(__object) ((__object)->error_messages) #define memcached_has_replicas(__object) ((__object)->root->number_of_replicas) #define memcached_set_processing_input(__object, __value) ((__object)->state.is_processing_input= (__value)) #define memcached_set_initialized(__object, __value) ((__object)->options.is_initialized(= (__value)) #define memcached_set_allocated(__object, __value) ((__object)->options.is_allocated= (__value)) libmemcached-1.0.8/libmemcached/do.cc0000664000076400007640000000500211756611200017701 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2010 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #include memcached_return_t memcached_vdo(memcached_server_write_instance_st instance, libmemcached_io_vector_st vector[], const size_t count, const bool with_flush) { memcached_return_t rc; assert_msg(vector, "Invalid vector passed"); if (memcached_failed(rc= memcached_connect(instance))) { WATCHPOINT_ERROR(rc); assert_msg(instance->error_messages, "memcached_connect() returned an error but the memcached_server_write_instance_st showed none."); return rc; } /* ** Since non buffering ops in UDP mode dont check to make sure they will fit ** before they start writing, if there is any data in buffer, clear it out, ** otherwise we might get a partial write. **/ if (memcached_is_udp(instance->root)) { if (vector[0].buffer or vector[0].length) { return memcached_set_error(*instance->root, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT, memcached_literal_param("UDP messages was attempted, but vector was not setup for it")); } struct msghdr msg; memset(&msg, 0, sizeof(msg)); increment_udp_message_id(instance); vector[0].buffer= instance->write_buffer; vector[0].length= UDP_DATAGRAM_HEADER_LENGTH; msg.msg_iov= (struct iovec*)vector; msg.msg_iovlen= count; uint32_t retry= 5; while (--retry) { ssize_t sendmsg_length= ::sendmsg(instance->fd, &msg, 0); if (sendmsg_length > 0) { break; } else if (sendmsg_length < 0) { if (errno == EMSGSIZE) { return memcached_set_error(*instance, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT); } return memcached_set_errno(*instance, errno, MEMCACHED_AT); } } return MEMCACHED_SUCCESS; } bool sent_success= memcached_io_writev(instance, vector, count, with_flush); if (sent_success == false) { if (memcached_last_error(instance->root) == MEMCACHED_SUCCESS) { return memcached_set_error(*instance, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT); } else { rc= MEMCACHED_WRITE_FAILURE; } } else if (memcached_is_replying(instance->root)) { memcached_server_response_increment(instance); } return rc; } libmemcached-1.0.8/libmemcached/behavior.hpp0000664000076400007640000000327511753573717021333 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once bool _is_auto_eject_host(const memcached_st *ptr); libmemcached-1.0.8/libmemcached/watchpoint.h0000664000076400007640000000417511753573717021354 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #define WATCHPOINT #define WATCHPOINT_ERROR(A) #define WATCHPOINT_IFERROR(__memcached_return_t) (void)(__memcached_return_t) #define WATCHPOINT_STRING(A) #define WATCHPOINT_NUMBER(A) #define WATCHPOINT_LABELED_NUMBER(A,B) #define WATCHPOINT_IF_LABELED_NUMBER(A,B,C) #define WATCHPOINT_ERRNO(A) #define WATCHPOINT_ASSERT_PRINT(A,B,C) #define WATCHPOINT_ASSERT(A) (void)(A) #define WATCHPOINT_ASSERT_INITIALIZED(A) #define WATCHPOINT_SET(A) libmemcached-1.0.8/libmemcached/connect.cc0000664000076400007640000004671611756611200020751 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-2010 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. * */ #include #include #include #include static memcached_return_t connect_poll(memcached_server_st *server) { struct pollfd fds[1]; fds[0].fd= server->fd; fds[0].events= POLLOUT; size_t loop_max= 5; if (server->root->poll_timeout == 0) { return memcached_set_error(*server, MEMCACHED_TIMEOUT, MEMCACHED_AT); } while (--loop_max) // Should only loop on cases of ERESTART or EINTR { int number_of; if ((number_of= poll(fds, 1, server->root->connect_timeout)) <= 0) { if (number_of == -1) { int local_errno= get_socket_errno(); // We cache in case closesocket() modifies errno switch (local_errno) { #ifdef TARGET_OS_LINUX case ERESTART: #endif case EINTR: continue; case EFAULT: case ENOMEM: return memcached_set_error(*server, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); case EINVAL: return memcached_set_error(*server, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("RLIMIT_NOFILE exceeded, or if OSX the timeout value was invalid")); default: // This should not happen if (fds[0].revents & POLLERR) { int err; socklen_t len= sizeof(err); if (getsockopt(server->fd, SOL_SOCKET, SO_ERROR, &err, &len) == 0) { if (err == 0) { // This should never happen, if it does? Punt. continue; } local_errno= err; } } assert_msg(server->fd != INVALID_SOCKET, "poll() was passed an invalid file descriptor"); (void)closesocket(server->fd); server->fd= INVALID_SOCKET; server->state= MEMCACHED_SERVER_STATE_NEW; return memcached_set_errno(*server, local_errno, MEMCACHED_AT); } } assert(number_of == 0); server->io_wait_count.timeouts++; return memcached_set_error(*server, MEMCACHED_TIMEOUT, MEMCACHED_AT); } if (fds[0].revents & POLLERR or fds[0].revents & POLLHUP or fds[0].revents & POLLNVAL) { int err; socklen_t len= sizeof (err); if (getsockopt(fds[0].fd, SOL_SOCKET, SO_ERROR, &err, &len) == 0) { // We check the value to see what happened wth the socket. if (err == 0) { return MEMCACHED_SUCCESS; } errno= err; } return memcached_set_errno(*server, err, MEMCACHED_AT); } assert(fds[0].revents & POLLIN or fds[0].revents & POLLOUT); return MEMCACHED_SUCCESS; } // This should only be possible from ERESTART or EINTR; return memcached_set_errno(*server, get_socket_errno(), MEMCACHED_AT); } static memcached_return_t set_hostinfo(memcached_server_st *server) { assert(server->type != MEMCACHED_CONNECTION_UNIX_SOCKET); if (server->address_info) { freeaddrinfo(server->address_info); server->address_info= NULL; server->address_info_next= NULL; } char str_port[NI_MAXSERV]; int length= snprintf(str_port, NI_MAXSERV, "%u", (uint32_t)server->port); if (length >= NI_MAXSERV or length < 0) { return MEMCACHED_FAILURE; } struct addrinfo hints; memset(&hints, 0, sizeof(struct addrinfo)); #if 0 hints.ai_family= AF_INET; #endif if (memcached_is_udp(server->root)) { hints.ai_protocol= IPPROTO_UDP; hints.ai_socktype= SOCK_DGRAM; } else { hints.ai_socktype= SOCK_STREAM; hints.ai_protocol= IPPROTO_TCP; } server->address_info= NULL; int errcode; switch(errcode= getaddrinfo(server->hostname, str_port, &hints, &server->address_info)) { case 0: break; case EAI_AGAIN: return memcached_set_error(*server, MEMCACHED_TIMEOUT, MEMCACHED_AT, memcached_string_make_from_cstr(gai_strerror(errcode))); case EAI_SYSTEM: return memcached_set_errno(*server, errno, MEMCACHED_AT, memcached_literal_param("getaddrinfo(EAI_SYSTEM)")); case EAI_BADFLAGS: return memcached_set_error(*server, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("getaddrinfo(EAI_BADFLAGS)")); case EAI_MEMORY: return memcached_set_error(*server, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("getaddrinfo(EAI_MEMORY)")); default: { return memcached_set_error(*server, MEMCACHED_HOST_LOOKUP_FAILURE, MEMCACHED_AT, memcached_string_make_from_cstr(gai_strerror(errcode))); } } server->address_info_next= server->address_info; server->state= MEMCACHED_SERVER_STATE_ADDRINFO; return MEMCACHED_SUCCESS; } static inline void set_socket_nonblocking(memcached_server_st *server) { #ifdef WIN32 u_long arg= 1; if (ioctlsocket(server->fd, FIONBIO, &arg) == SOCKET_ERROR) { memcached_set_errno(*server, get_socket_errno(), NULL); } #else int flags; do { flags= fcntl(server->fd, F_GETFL, 0); } while (flags == -1 && (errno == EINTR || errno == EAGAIN)); if (flags == -1) { memcached_set_errno(*server, errno, NULL); } else if ((flags & O_NONBLOCK) == 0) { int rval; do { rval= fcntl(server->fd, F_SETFL, flags | O_NONBLOCK); } while (rval == -1 && (errno == EINTR or errno == EAGAIN)); if (rval == -1) { memcached_set_errno(*server, errno, NULL); } } #endif } static void set_socket_options(memcached_server_st *server) { assert_msg(server->fd != INVALID_SOCKET, "invalid socket was passed to set_socket_options()"); if (memcached_is_udp(server->root)) { return; } #ifdef HAVE_SNDTIMEO if (server->root->snd_timeout) { struct timeval waittime; waittime.tv_sec= 0; waittime.tv_usec= server->root->snd_timeout; int error= setsockopt(server->fd, SOL_SOCKET, SO_SNDTIMEO, &waittime, (socklen_t)sizeof(struct timeval)); assert(error == 0); } #endif #ifdef HAVE_RCVTIMEO if (server->root->rcv_timeout) { struct timeval waittime; waittime.tv_sec= 0; waittime.tv_usec= server->root->rcv_timeout; int error= setsockopt(server->fd, SOL_SOCKET, SO_RCVTIMEO, &waittime, (socklen_t)sizeof(struct timeval)); assert(error == 0); } #endif #if defined(__MACH__) && defined(__APPLE__) || defined(__FreeBSD__) { int set= 1; int error= setsockopt(server->fd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int)); // This is not considered a fatal error if (error == -1) { WATCHPOINT_ERRNO(get_socket_errno()); perror("setsockopt(SO_NOSIGPIPE)"); } } #endif if (server->root->flags.no_block) { struct linger linger; linger.l_onoff= 1; linger.l_linger= 0; /* By default on close() just drop the socket */ int error= setsockopt(server->fd, SOL_SOCKET, SO_LINGER, &linger, (socklen_t)sizeof(struct linger)); assert(error == 0); } if (server->root->flags.tcp_nodelay) { int flag= 1; int error= setsockopt(server->fd, IPPROTO_TCP, TCP_NODELAY, &flag, (socklen_t)sizeof(int)); assert(error == 0); } if (server->root->flags.tcp_keepalive) { int flag= 1; int error= setsockopt(server->fd, SOL_SOCKET, SO_KEEPALIVE, &flag, (socklen_t)sizeof(int)); assert(error == 0); } #ifdef TCP_KEEPIDLE if (server->root->tcp_keepidle > 0) { int error= setsockopt(server->fd, IPPROTO_TCP, TCP_KEEPIDLE, &server->root->tcp_keepidle, (socklen_t)sizeof(int)); assert(error == 0); } #endif if (server->root->send_size > 0) { int error= setsockopt(server->fd, SOL_SOCKET, SO_SNDBUF, &server->root->send_size, (socklen_t)sizeof(int)); assert(error == 0); } if (server->root->recv_size > 0) { int error= setsockopt(server->fd, SOL_SOCKET, SO_RCVBUF, &server->root->recv_size, (socklen_t)sizeof(int)); assert(error == 0); } /* libmemcached will always use nonblocking IO to avoid write deadlocks */ set_socket_nonblocking(server); } static memcached_return_t unix_socket_connect(memcached_server_st *server) { #ifndef WIN32 WATCHPOINT_ASSERT(server->fd == INVALID_SOCKET); if ((server->fd= socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { memcached_set_errno(*server, errno, NULL); return MEMCACHED_CONNECTION_FAILURE; } struct sockaddr_un servAddr; memset(&servAddr, 0, sizeof (struct sockaddr_un)); servAddr.sun_family= AF_UNIX; strncpy(servAddr.sun_path, server->hostname, sizeof(servAddr.sun_path)); /* Copy filename */ do { if (connect(server->fd, (struct sockaddr *)&servAddr, sizeof(servAddr)) < 0) { switch (errno) { case EINPROGRESS: case EALREADY: case EINTR: continue; case EISCONN: /* We were spinning waiting on connect */ { assert(0); // Programmer error break; } default: WATCHPOINT_ERRNO(errno); memcached_set_errno(*server, errno, MEMCACHED_AT); return MEMCACHED_CONNECTION_FAILURE; } } } while (0); server->state= MEMCACHED_SERVER_STATE_CONNECTED; WATCHPOINT_ASSERT(server->fd != INVALID_SOCKET); return MEMCACHED_SUCCESS; #else (void)server; return MEMCACHED_NOT_SUPPORTED; #endif } static memcached_return_t network_connect(memcached_server_st *server) { bool timeout_error_occured= false; WATCHPOINT_ASSERT(server->fd == INVALID_SOCKET); WATCHPOINT_ASSERT(server->cursor_active == 0); /* We want to check both of these because if address_info_next has been fully tried, we want to do a new lookup to make sure we have picked up on any new DNS information. */ if (server->address_info == NULL or server->address_info_next == NULL) { WATCHPOINT_ASSERT(server->state == MEMCACHED_SERVER_STATE_NEW); server->address_info_next= NULL; memcached_return_t rc; uint32_t counter= 5; while (--counter) { if ((rc= set_hostinfo(server)) != MEMCACHED_TIMEOUT) { break; } #ifndef WIN32 struct timespec dream, rem; dream.tv_nsec= 1000; dream.tv_sec= 0; nanosleep(&dream, &rem); #endif } if (memcached_failed(rc)) { return rc; } } if (server->address_info_next == NULL) { server->address_info_next= server->address_info; server->state= MEMCACHED_SERVER_STATE_ADDRINFO; } /* Create the socket */ while (server->address_info_next and server->fd == INVALID_SOCKET) { /* Memcache server does not support IPV6 in udp mode, so skip if not ipv4 */ if (memcached_is_udp(server->root) and server->address_info_next->ai_family != AF_INET) { server->address_info_next= server->address_info_next->ai_next; continue; } if ((server->fd= socket(server->address_info_next->ai_family, server->address_info_next->ai_socktype, server->address_info_next->ai_protocol)) < 0) { return memcached_set_errno(*server, get_socket_errno(), NULL); } set_socket_options(server); /* connect to server */ if ((connect(server->fd, server->address_info_next->ai_addr, server->address_info_next->ai_addrlen) != SOCKET_ERROR)) { server->state= MEMCACHED_SERVER_STATE_CONNECTED; return MEMCACHED_SUCCESS; } /* An error occurred */ switch (get_socket_errno()) { case ETIMEDOUT: timeout_error_occured= true; break; case EAGAIN: #if EWOULDBLOCK != EAGAIN case EWOULDBLOCK: #endif case EINPROGRESS: // nonblocking mode - first return case EALREADY: // nonblocking mode - subsequent returns { server->state= MEMCACHED_SERVER_STATE_IN_PROGRESS; memcached_return_t rc= connect_poll(server); if (memcached_success(rc)) { server->state= MEMCACHED_SERVER_STATE_CONNECTED; return MEMCACHED_SUCCESS; } // A timeout here is treated as an error, we will not retry if (rc == MEMCACHED_TIMEOUT) { timeout_error_occured= true; } } break; case EISCONN: // we are connected :-) WATCHPOINT_ASSERT(0); // This is a programmer's error break; case EINTR: // Special case, we retry ai_addr WATCHPOINT_ASSERT(server->fd != INVALID_SOCKET); (void)closesocket(server->fd); server->fd= INVALID_SOCKET; continue; default: break; } WATCHPOINT_ASSERT(server->fd != INVALID_SOCKET); (void)closesocket(server->fd); server->fd= INVALID_SOCKET; server->address_info_next= server->address_info_next->ai_next; } WATCHPOINT_ASSERT(server->fd == INVALID_SOCKET); if (timeout_error_occured) { if (server->fd != INVALID_SOCKET) { (void)closesocket(server->fd); server->fd= INVALID_SOCKET; } } WATCHPOINT_STRING("Never got a good file descriptor"); if (memcached_has_current_error(*server)) { return memcached_server_error_return(server); } if (timeout_error_occured and server->state < MEMCACHED_SERVER_STATE_IN_PROGRESS) { return memcached_set_error(*server, MEMCACHED_TIMEOUT, MEMCACHED_AT); } return memcached_set_error(*server, MEMCACHED_CONNECTION_FAILURE, MEMCACHED_AT); /* The last error should be from connect() */ } /* backoff_handling() Based on time/failure count fail the connect without trying. This prevents waiting in a state where we get caught spending cycles just waiting. */ static memcached_return_t backoff_handling(memcached_server_write_instance_st server, bool& in_timeout) { struct timeval curr_time; bool _gettime_success= (gettimeofday(&curr_time, NULL) == 0); /* If we hit server_failure_limit then something is completely wrong about the server. 1) If autoeject is enabled we do that. 2) If not? We go into timeout again, there is much else to do :( */ if (server->server_failure_counter >= server->root->server_failure_limit) { /* We just auto_eject if we hit this point */ if (_is_auto_eject_host(server->root)) { set_last_disconnected_host(server); // Retry dead servers if requested if (_gettime_success and server->root->dead_timeout > 0) { server->next_retry= curr_time.tv_sec +server->root->dead_timeout; // We only retry dead servers once before assuming failure again server->server_failure_counter= server->root->server_failure_limit -1; } memcached_return_t rc; if (memcached_failed(rc= run_distribution((memcached_st *)server->root))) { return memcached_set_error(*server, rc, MEMCACHED_AT, memcached_literal_param("Backoff handling failed during run_distribution")); } return memcached_set_error(*server, MEMCACHED_SERVER_MARKED_DEAD, MEMCACHED_AT); } server->state= MEMCACHED_SERVER_STATE_IN_TIMEOUT; // Sanity check/setting if (server->next_retry == 0) { server->next_retry= 1; } } if (server->state == MEMCACHED_SERVER_STATE_IN_TIMEOUT) { /* If next_retry is less then our current time, then we reset and try everything again. */ if (_gettime_success and server->next_retry < curr_time.tv_sec) { server->state= MEMCACHED_SERVER_STATE_NEW; } else { return memcached_set_error(*server, MEMCACHED_SERVER_TEMPORARILY_DISABLED, MEMCACHED_AT); } in_timeout= true; } return MEMCACHED_SUCCESS; } static memcached_return_t _memcached_connect(memcached_server_write_instance_st server, const bool set_last_disconnected) { if (server->fd != INVALID_SOCKET) { return MEMCACHED_SUCCESS; } LIBMEMCACHED_MEMCACHED_CONNECT_START(); bool in_timeout= false; memcached_return_t rc; if (memcached_failed(rc= backoff_handling(server, in_timeout))) { set_last_disconnected_host(server); return rc; } if (LIBMEMCACHED_WITH_SASL_SUPPORT and server->root->sasl.callbacks and memcached_is_udp(server->root)) { return memcached_set_error(*server, MEMCACHED_INVALID_HOST_PROTOCOL, MEMCACHED_AT, memcached_literal_param("SASL is not supported for UDP connections")); } if (server->hostname[0] == '/') { server->type= MEMCACHED_CONNECTION_UNIX_SOCKET; } /* We need to clean up the multi startup piece */ switch (server->type) { case MEMCACHED_CONNECTION_UDP: case MEMCACHED_CONNECTION_TCP: rc= network_connect(server); if (LIBMEMCACHED_WITH_SASL_SUPPORT) { if (server->fd != INVALID_SOCKET and server->root->sasl.callbacks) { rc= memcached_sasl_authenticate_connection(server); if (memcached_failed(rc) and server->fd != INVALID_SOCKET) { WATCHPOINT_ASSERT(server->fd != INVALID_SOCKET); (void)closesocket(server->fd); server->fd= INVALID_SOCKET; } } } break; case MEMCACHED_CONNECTION_UNIX_SOCKET: rc= unix_socket_connect(server); break; } if (memcached_success(rc)) { memcached_mark_server_as_clean(server); return rc; } else if (set_last_disconnected) { set_last_disconnected_host(server); if (memcached_has_current_error(*server)) { memcached_mark_server_for_timeout(server); assert(memcached_failed(memcached_server_error_return(server))); } else { memcached_set_error(*server, rc, MEMCACHED_AT); memcached_mark_server_for_timeout(server); } LIBMEMCACHED_MEMCACHED_CONNECT_END(); if (in_timeout) { char buffer[1024]; int snprintf_length= snprintf(buffer, sizeof(buffer), "%s:%d", server->hostname, int(server->port)); return memcached_set_error(*server, MEMCACHED_SERVER_TEMPORARILY_DISABLED, MEMCACHED_AT, buffer, snprintf_length); } } return rc; } memcached_return_t memcached_connect_try(memcached_server_write_instance_st server) { return _memcached_connect(server, false); } memcached_return_t memcached_connect(memcached_server_write_instance_st server) { return _memcached_connect(server, true); } libmemcached-1.0.8/libmemcached/socket.hpp0000664000076400007640000000516711753573717021026 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once /* To hide the platform differences between MS Windows and Unix, I am * going to use the Microsoft way and #define the Microsoft-specific * functions to the unix way. Microsoft use a separate subsystem for sockets, * but Unix normally just use a filedescriptor on the same functions. It is * a lot easier to map back to the unix way with macros than going the other * way without side effect ;-) */ #ifdef WIN32 #include "win32/wrappers.h" #define get_socket_errno() WSAGetLastError() #else #include #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 #define closesocket(a) close(a) #define get_socket_errno() errno #endif #ifdef __cplusplus static inline void memcached_close_socket(int& socket_fd) { closesocket(socket_fd); socket_fd= INVALID_SOCKET; } #endif #ifndef HAVE_MSG_NOSIGNAL #define MSG_NOSIGNAL 0 #endif #ifndef HAVE_MSG_DONTWAIT #define MSG_DONTWAIT 0 #endif #ifndef HAVE_MSG_MORE #define MSG_MORE 0 #endif libmemcached-1.0.8/libmemcached/callback.cc0000664000076400007640000000765211753573717021071 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: Change any of the possible callbacks. * */ #include #include #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif /* These functions provide data and function callback support */ memcached_return_t memcached_callback_set(memcached_st *ptr, const memcached_callback_t flag, const void *data) { switch (flag) { case MEMCACHED_CALLBACK_PREFIX_KEY: { return memcached_set_namespace(ptr, (char*)data, data ? strlen((char*)data) : 0); } case MEMCACHED_CALLBACK_USER_DATA: { ptr->user_data= const_cast(data); break; } case MEMCACHED_CALLBACK_CLEANUP_FUNCTION: { memcached_cleanup_fn func= *(memcached_cleanup_fn *)&data; ptr->on_cleanup= func; break; } case MEMCACHED_CALLBACK_CLONE_FUNCTION: { memcached_clone_fn func= *(memcached_clone_fn *)&data; ptr->on_clone= func; break; } case MEMCACHED_CALLBACK_GET_FAILURE: { memcached_trigger_key_fn func= *(memcached_trigger_key_fn *)&data; ptr->get_key_failure= func; break; } case MEMCACHED_CALLBACK_DELETE_TRIGGER: { if (data) // NULL would mean we are disabling. { if (memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS)) { return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Delete triggers cannot be used if buffering is enabled")); } if (memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_NOREPLY)) { return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Delete triggers cannot be used if MEMCACHED_BEHAVIOR_NOREPLY is set")); } } memcached_trigger_delete_key_fn func= *(memcached_trigger_delete_key_fn *)&data; ptr->delete_trigger= func; break; } case MEMCACHED_CALLBACK_MAX: return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid callback supplied")); } return MEMCACHED_SUCCESS; } void *memcached_callback_get(memcached_st *ptr, const memcached_callback_t flag, memcached_return_t *error) { memcached_return_t local_error; if (error == NULL) { error = &local_error; } if (ptr == NULL) { *error= MEMCACHED_INVALID_ARGUMENTS; return NULL; } switch (flag) { case MEMCACHED_CALLBACK_PREFIX_KEY: { *error= MEMCACHED_SUCCESS; if (ptr->_namespace) { return (void *)memcached_array_string(ptr->_namespace); } return NULL; } case MEMCACHED_CALLBACK_USER_DATA: { *error= ptr->user_data ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; return (void *)ptr->user_data; } case MEMCACHED_CALLBACK_CLEANUP_FUNCTION: { *error= ptr->on_cleanup ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; return *(void **)&ptr->on_cleanup; } case MEMCACHED_CALLBACK_CLONE_FUNCTION: { *error= ptr->on_clone ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; return *(void **)&ptr->on_clone; } case MEMCACHED_CALLBACK_GET_FAILURE: { *error= ptr->get_key_failure ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; return *(void **)&ptr->get_key_failure; } case MEMCACHED_CALLBACK_DELETE_TRIGGER: { *error= ptr->delete_trigger ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; return *(void **)&ptr->delete_trigger; } case MEMCACHED_CALLBACK_MAX: break; } assert_msg(0, "Invalid behavior passed to memcached_behavior_set()"); *error= MEMCACHED_FAILURE; return NULL; } libmemcached-1.0.8/libmemcached/virtual_bucket.c0000664000076400007640000000721411753573717022207 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 struct bucket_t { uint32_t master; uint32_t forward; }; struct memcached_virtual_bucket_t { bool has_forward; uint32_t size; uint32_t replicas; struct bucket_t buckets[]; }; memcached_return_t memcached_virtual_bucket_create(memcached_st *self, const uint32_t *host_map, const uint32_t *forward_map, const uint32_t buckets, const uint32_t replicas) { if (! self || ! host_map || ! buckets) { return MEMCACHED_INVALID_ARGUMENTS; } memcached_virtual_bucket_free(self); struct memcached_virtual_bucket_t *virtual_bucket= (struct memcached_virtual_bucket_t *)malloc(sizeof(struct memcached_virtual_bucket_t) + sizeof(struct bucket_t) *buckets); if (virtual_bucket == NULL) { return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } virtual_bucket->size= buckets; virtual_bucket->replicas= replicas; self->virtual_bucket= virtual_bucket; uint32_t x= 0; for (; x < buckets; x++) { virtual_bucket->buckets[x].master= host_map[x]; if (forward_map) { virtual_bucket->buckets[x].forward= forward_map[x]; } else { virtual_bucket->buckets[x].forward= 0; } } return MEMCACHED_SUCCESS; } void memcached_virtual_bucket_free(memcached_st *self) { if (self == NULL) { return; } if (self->virtual_bucket == NULL) { return; } free(self->virtual_bucket); self->virtual_bucket= NULL; } uint32_t memcached_virtual_bucket_get(const memcached_st *self, uint32_t digest) { if (self == NULL) { return 0; } if (self->virtual_bucket == NULL) { return 0; } if (self->virtual_bucket) { uint32_t result= (uint32_t) (digest & (self->virtual_bucket->size -1)); return self->virtual_bucket->buckets[result].master; } return (uint32_t) (digest & (self->number_of_hosts -1)); } libmemcached-1.0.8/libmemcached/analyze.cc0000664000076400007640000000672311753573717020776 0ustar00brianbrian00000000000000#include static void calc_largest_consumption(memcached_analysis_st *result, const uint32_t server_num, const uint64_t nbytes) { if (result->most_used_bytes < nbytes) { result->most_used_bytes= nbytes; result->most_consumed_server= server_num; } } static void calc_oldest_node(memcached_analysis_st *result, const uint32_t server_num, const uint32_t uptime) { if (result->longest_uptime < uptime) { result->longest_uptime= uptime; result->oldest_server= server_num; } } static void calc_least_free_node(memcached_analysis_st *result, const uint32_t server_num, const uint64_t max_allowed_bytes, const uint64_t used_bytes) { uint64_t remaining_bytes= max_allowed_bytes - used_bytes; if (result->least_remaining_bytes == 0 || remaining_bytes < result->least_remaining_bytes) { result->least_remaining_bytes= remaining_bytes; result->least_free_server= server_num; } } static void calc_average_item_size(memcached_analysis_st *result, const uint64_t total_items, const uint64_t total_bytes) { if (total_items > 0 && total_bytes > 0) { result->average_item_size= (uint32_t) (total_bytes / total_items); } } static void calc_hit_ratio(memcached_analysis_st *result, const uint64_t total_get_hits, const uint64_t total_get_cmds) { if (total_get_hits == 0 || total_get_cmds == 0) { result->pool_hit_ratio= 0; return; } double temp= double(total_get_hits) / total_get_cmds; result->pool_hit_ratio= temp * 100; } memcached_analysis_st *memcached_analyze(memcached_st *memc, memcached_stat_st *memc_stat, memcached_return_t *error) { uint64_t total_items= 0, total_bytes= 0; uint64_t total_get_cmds= 0, total_get_hits= 0; if (memc == NULL or memc_stat == NULL) { return NULL; } memcached_return_t not_used; if (error == NULL) { error= ¬_used; } *error= MEMCACHED_SUCCESS; uint32_t server_count= memcached_server_count(memc); memcached_analysis_st *result= (memcached_analysis_st*)libmemcached_xcalloc(memc, memcached_server_count(memc), memcached_analysis_st); if (result == NULL) { *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE; return NULL; } result->root= memc; for (uint32_t x= 0; x < server_count; x++) { calc_largest_consumption(result, x, memc_stat[x].bytes); calc_oldest_node(result, x, memc_stat[x].uptime); calc_least_free_node(result, x, memc_stat[x].limit_maxbytes, memc_stat[x].bytes); total_get_hits+= memc_stat[x].get_hits; total_get_cmds+= memc_stat[x].cmd_get; total_items+= memc_stat[x].curr_items; total_bytes+= memc_stat[x].bytes; } calc_average_item_size(result, total_items, total_bytes); calc_hit_ratio(result, total_get_hits, total_get_cmds); return result; } void memcached_analyze_free(memcached_analysis_st *ptr) { libmemcached_free(ptr->root, ptr); } libmemcached-1.0.8/libmemcached/memcached.h0000664000076400007640000000326111753573717021075 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #include libmemcached-1.0.8/libmemcached/server_instance.h0000664000076400007640000000345111753573717022362 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif typedef struct memcached_server_st * memcached_server_write_instance_st; #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached/stats.cc0000664000076400007640000005006511753573717020467 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 static const char *memcached_stat_keys[] = { "pid", "uptime", "time", "version", "pointer_size", "rusage_user", "rusage_system", "curr_items", "total_items", "bytes", "curr_connections", "total_connections", "connection_structures", "cmd_get", "cmd_set", "get_hits", "get_misses", "evictions", "bytes_read", "bytes_written", "limit_maxbytes", "threads", NULL }; struct local_context { memcached_stat_fn func; void *context; const char *args; const size_t args_length; local_context(memcached_stat_fn func_arg, void *context_arg, const char *args_arg, const size_t args_length_arg) : func(func_arg), context(context_arg), args(args_arg), args_length(args_length_arg) { } }; static memcached_return_t set_data(memcached_stat_st *memc_stat, const char *key, const char *value) { if (strlen(key) < 1) { WATCHPOINT_STRING(key); return MEMCACHED_UNKNOWN_STAT_KEY; } else if (strcmp("pid", key) == 0) { int64_t temp= strtoll(value, (char **)NULL, 10); if (temp <= INT32_MAX and ( sizeof(pid_t) == sizeof(int32_t) )) { memc_stat->pid= temp; } else if (temp > -1) { memc_stat->pid= temp; } else { // If we got a value less then -1 then something went wrong in the // protocol } } else if (not strcmp("uptime", key)) { memc_stat->uptime= strtoul(value, (char **)NULL, 10); } else if (not strcmp("time", key)) { memc_stat->time= strtoul(value, (char **)NULL, 10); } else if (not strcmp("version", key)) { memcpy(memc_stat->version, value, strlen(value)); memc_stat->version[strlen(value)]= 0; } else if (not strcmp("pointer_size", key)) { memc_stat->pointer_size= strtoul(value, (char **)NULL, 10); } else if (not strcmp("rusage_user", key)) { char *walk_ptr; for (walk_ptr= (char*)value; (!ispunct(*walk_ptr)); walk_ptr++) {}; *walk_ptr= 0; walk_ptr++; memc_stat->rusage_user_seconds= strtoul(value, (char **)NULL, 10); memc_stat->rusage_user_microseconds= strtoul(walk_ptr, (char **)NULL, 10); } else if (not strcmp("rusage_system", key)) { char *walk_ptr; for (walk_ptr= (char*)value; (!ispunct(*walk_ptr)); walk_ptr++) {}; *walk_ptr= 0; walk_ptr++; memc_stat->rusage_system_seconds= strtoul(value, (char **)NULL, 10); memc_stat->rusage_system_microseconds= strtoul(walk_ptr, (char **)NULL, 10); } else if (not strcmp("curr_items", key)) { memc_stat->curr_items= strtoul(value, (char **)NULL, 10); } else if (not strcmp("total_items", key)) { memc_stat->total_items= strtoul(value, (char **)NULL, 10); } else if (not strcmp("bytes_read", key)) { memc_stat->bytes_read= strtoull(value, (char **)NULL, 10); } else if (not strcmp("bytes_written", key)) { memc_stat->bytes_written= strtoull(value, (char **)NULL, 10); } else if (not strcmp("bytes", key)) { memc_stat->bytes= strtoull(value, (char **)NULL, 10); } else if (not strcmp("curr_connections", key)) { memc_stat->curr_connections= strtoull(value, (char **)NULL, 10); } else if (not strcmp("total_connections", key)) { memc_stat->total_connections= strtoull(value, (char **)NULL, 10); } else if (not strcmp("connection_structures", key)) { memc_stat->connection_structures= strtoul(value, (char **)NULL, 10); } else if (not strcmp("cmd_get", key)) { memc_stat->cmd_get= strtoull(value, (char **)NULL, 10); } else if (not strcmp("cmd_set", key)) { memc_stat->cmd_set= strtoull(value, (char **)NULL, 10); } else if (not strcmp("get_hits", key)) { memc_stat->get_hits= strtoull(value, (char **)NULL, 10); } else if (not strcmp("get_misses", key)) { memc_stat->get_misses= strtoull(value, (char **)NULL, 10); } else if (not strcmp("evictions", key)) { memc_stat->evictions= strtoull(value, (char **)NULL, 10); } else if (not strcmp("limit_maxbytes", key)) { memc_stat->limit_maxbytes= strtoull(value, (char **)NULL, 10); } else if (not strcmp("threads", key)) { memc_stat->threads= strtoul(value, (char **)NULL, 10); } else if (not (strcmp("delete_misses", key) == 0 or /* New stats in the 1.3 beta */ strcmp("delete_hits", key) == 0 or /* Just swallow them for now.. */ strcmp("incr_misses", key) == 0 or strcmp("incr_hits", key) == 0 or strcmp("decr_misses", key) == 0 or strcmp("decr_hits", key) == 0 or strcmp("cas_misses", key) == 0 or strcmp("cas_hits", key) == 0 or strcmp("cas_badval", key) == 0 or strcmp("cmd_flush", key) == 0 or strcmp("accepting_conns", key) == 0 or strcmp("listen_disabled_num", key) == 0 or strcmp("conn_yields", key) == 0 or strcmp("auth_cmds", key) == 0 or strcmp("auth_errors", key) == 0 or strcmp("reclaimed", key) == 0)) { WATCHPOINT_STRING(key); /* return MEMCACHED_UNKNOWN_STAT_KEY; */ return MEMCACHED_SUCCESS; } return MEMCACHED_SUCCESS; } char *memcached_stat_get_value(const memcached_st *ptr, memcached_stat_st *memc_stat, const char *key, memcached_return_t *error) { char buffer[SMALL_STRING_LEN]; int length; char *ret; *error= MEMCACHED_SUCCESS; if (memcmp("pid", key, sizeof("pid") -1) == 0) { length= snprintf(buffer, SMALL_STRING_LEN,"%lld", (signed long long)memc_stat->pid); } else if (not memcmp("uptime", key, sizeof("uptime") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->uptime); } else if (not memcmp("time", key, sizeof("time") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->time); } else if (not memcmp("version", key, sizeof("version") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%s", memc_stat->version); } else if (not memcmp("pointer_size", key, sizeof("pointer_size") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->pointer_size); } else if (not memcmp("rusage_user", key, sizeof("rusage_user") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%lu.%lu", memc_stat->rusage_user_seconds, memc_stat->rusage_user_microseconds); } else if (not memcmp("rusage_system", key, sizeof("rusage_system") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%lu.%lu", memc_stat->rusage_system_seconds, memc_stat->rusage_system_microseconds); } else if (not memcmp("curr_items", key, sizeof("curr_items") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->curr_items); } else if (not memcmp("total_items", key, sizeof("total_items") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->total_items); } else if (not memcmp("curr_connections", key, sizeof("curr_connections") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->curr_connections); } else if (not memcmp("total_connections", key, sizeof("total_connections") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->total_connections); } else if (not memcmp("connection_structures", key, sizeof("connection_structures") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->connection_structures); } else if (not memcmp("cmd_get", key, sizeof("cmd_get") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->cmd_get); } else if (not memcmp("cmd_set", key, sizeof("cmd_set") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->cmd_set); } else if (not memcmp("get_hits", key, sizeof("get_hits") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->get_hits); } else if (not memcmp("get_misses", key, sizeof("get_misses") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->get_misses); } else if (not memcmp("evictions", key, sizeof("evictions") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->evictions); } else if (not memcmp("bytes_read", key, sizeof("bytes_read") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->bytes_read); } else if (not memcmp("bytes_written", key, sizeof("bytes_written") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->bytes_written); } else if (not memcmp("bytes", key, sizeof("bytes") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->bytes); } else if (not memcmp("limit_maxbytes", key, sizeof("limit_maxbytes") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)memc_stat->limit_maxbytes); } else if (not memcmp("threads", key, sizeof("threads") -1)) { length= snprintf(buffer, SMALL_STRING_LEN,"%lu", memc_stat->threads); } else { *error= MEMCACHED_NOTFOUND; return NULL; } if (length >= SMALL_STRING_LEN || length < 0) { *error= MEMCACHED_FAILURE; return NULL; } ret= static_cast(libmemcached_malloc(ptr, (size_t) (length + 1))); memcpy(ret, buffer, (size_t) length); ret[length]= '\0'; return ret; } static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, const char *args, const size_t args_length, memcached_server_write_instance_st instance, struct local_context *check) { char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; protocol_binary_request_stats request= {}; // = {.bytes= {0}}; request.message.header.request.magic= PROTOCOL_BINARY_REQ; request.message.header.request.opcode= PROTOCOL_BINARY_CMD_STAT; request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; if (args_length) { request.message.header.request.keylen= htons(uint16_t(args_length)); request.message.header.request.bodylen= htonl(uint32_t( args_length)); libmemcached_io_vector_st vector[]= { { request.bytes, sizeof(request.bytes) }, { args, args_length } }; if (memcached_vdo(instance, vector, 2, true) != MEMCACHED_SUCCESS) { memcached_io_reset(instance); return MEMCACHED_WRITE_FAILURE; } } else { libmemcached_io_vector_st vector[]= { { request.bytes, sizeof(request.bytes) } }; if (memcached_vdo(instance, vector, 1, true) != MEMCACHED_SUCCESS) { memcached_io_reset(instance); return MEMCACHED_WRITE_FAILURE; } } memcached_server_response_decrement(instance); do { memcached_return_t rc= memcached_response(instance, buffer, sizeof(buffer), NULL); if (rc == MEMCACHED_END) { break; } if (rc != MEMCACHED_SUCCESS) { memcached_io_reset(instance); return rc; } if (check && check->func) { size_t key_length= strlen(buffer); check->func(instance, buffer, key_length, buffer+key_length+1, strlen(buffer+key_length+1), check->context); } if (memc_stat) { if ((set_data(memc_stat, buffer, buffer + strlen(buffer) + 1)) == MEMCACHED_UNKNOWN_STAT_KEY) { WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY); WATCHPOINT_ASSERT(0); } } } while (1); /* * memcached_response will decrement the counter, so I need to reset it.. * todo: look at this and try to find a better solution. * */ instance->cursor_active= 0; return MEMCACHED_SUCCESS; } static memcached_return_t ascii_stats_fetch(memcached_stat_st *memc_stat, const char *args, const size_t args_length, memcached_server_write_instance_st instance, struct local_context *check) { libmemcached_io_vector_st vector[]= { { memcached_literal_param("stats ") }, { args, args_length }, { memcached_literal_param("\r\n") } }; memcached_return_t rc= memcached_vdo(instance, vector, 3, true); if (memcached_success(rc)) { char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; while ((rc= memcached_response(instance, buffer, sizeof(buffer), NULL)) == MEMCACHED_STAT) { char *string_ptr= buffer; string_ptr+= 5; /* Move past STAT */ char *end_ptr; for (end_ptr= string_ptr; isgraph(*end_ptr); end_ptr++) {}; char *key= string_ptr; key[size_t(end_ptr-string_ptr)]= 0; string_ptr= end_ptr + 1; for (end_ptr= string_ptr; !(isspace(*end_ptr)); end_ptr++) {}; char *value= string_ptr; value[(size_t)(end_ptr -string_ptr)]= 0; #if 0 bool check_bool= bool(check); bool check_func_bool= bool(check) ? bool(check->func) : false; fprintf(stderr, "%s:%d %s %s %d:%d\n", __FILE__, __LINE__, key, value, check_bool, check_func_bool); #endif if (check and check->func) { check->func(instance, key, strlen(key), value, strlen(value), check->context); } if (memc_stat) { if((set_data(memc_stat, key, value)) == MEMCACHED_UNKNOWN_STAT_KEY) { WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY); WATCHPOINT_ASSERT(0); } } } } if (rc == MEMCACHED_ERROR) { return MEMCACHED_INVALID_ARGUMENTS; } if (rc == MEMCACHED_END) { return MEMCACHED_SUCCESS; } return rc; } memcached_stat_st *memcached_stat(memcached_st *self, char *args, memcached_return_t *error) { memcached_return_t unused; if (error == NULL) { error= &unused; } if (memcached_failed(*error= initialize_query(self, true))) { return NULL; } if (memcached_is_udp(self)) { *error= memcached_set_error(*self, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT); return NULL; } memcached_return_t rc; size_t args_length= 0; if (args) { args_length= strlen(args); rc= memcached_validate_key_length(args_length, self->flags.binary_protocol); if (memcached_failed(rc)) { *error= memcached_set_error(*self, rc, MEMCACHED_AT); return NULL; } } WATCHPOINT_ASSERT(error); memcached_stat_st *stats= libmemcached_xcalloc(self, memcached_server_count(self), memcached_stat_st); if (stats == NULL) { *error= memcached_set_error(*self, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); return NULL; } WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS); rc= MEMCACHED_SUCCESS; for (uint32_t x= 0; x < memcached_server_count(self); x++) { memcached_stat_st* stat_instance= stats +x; stat_instance->pid= -1; stat_instance->root= self; memcached_server_write_instance_st instance= memcached_server_instance_fetch(self, x); memcached_return_t temp_return; if (memcached_is_binary(self)) { temp_return= binary_stats_fetch(stat_instance, args, args_length, instance, NULL); } else { temp_return= ascii_stats_fetch(stat_instance, args, args_length, instance, NULL); } // Special case where "args" is invalid if (temp_return == MEMCACHED_INVALID_ARGUMENTS) { rc= MEMCACHED_INVALID_ARGUMENTS; break; } if (memcached_failed(temp_return)) { rc= MEMCACHED_SOME_ERRORS; } } *error= rc; return stats; } memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat, char *args, const char *hostname, in_port_t port) { memcached_st memc; memset(memc_stat, 0, sizeof(memcached_stat_st)); memcached_st *memc_ptr= memcached_create(&memc); if (memc_ptr == NULL) { return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } memcached_return_t rc; if (memcached_failed(rc= memcached_server_add(&memc, hostname, port))) { memcached_free(&memc); return rc; } if (memcached_success(rc= initialize_query(memc_ptr, true))) { size_t args_length= 0; if (args) { args_length= strlen(args); rc= memcached_validate_key_length(args_length, memc.flags.binary_protocol); } if (memcached_success(rc)) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc_ptr, 0); if (memc.flags.binary_protocol) { rc= binary_stats_fetch(memc_stat, args, args_length, instance, NULL); } else { rc= ascii_stats_fetch(memc_stat, args, args_length, instance, NULL); } } } memcached_free(&memc); return rc; } /* We make a copy of the keys since at some point in the not so distant future we will add support for "found" keys. */ char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *, memcached_return_t *error) { if (ptr == NULL) { return NULL; } char **list= static_cast(libmemcached_malloc(ptr, sizeof(memcached_stat_keys))); if (not list) { *error= memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); return NULL; } memcpy(list, memcached_stat_keys, sizeof(memcached_stat_keys)); *error= MEMCACHED_SUCCESS; return list; } void memcached_stat_free(const memcached_st *, memcached_stat_st *memc_stat) { WATCHPOINT_ASSERT(memc_stat); // Be polite, but when debugging catch this as an error if (memc_stat == NULL) { return; } if (memc_stat->root) { libmemcached_free(memc_stat->root, memc_stat); return; } libmemcached_free(NULL, memc_stat); } static memcached_return_t call_stat_fn(memcached_st *ptr, memcached_server_write_instance_st instance, void *context) { memcached_return_t rc; local_context *check= (struct local_context *)context; if (memcached_is_binary(ptr)) { rc= binary_stats_fetch(NULL, check->args, check->args_length, instance, check); } else { rc= ascii_stats_fetch(NULL, check->args, check->args_length, instance, check); } return rc; } memcached_return_t memcached_stat_execute(memcached_st *memc, const char *args, memcached_stat_fn func, void *context) { memcached_version(memc); local_context check(func, context, args, args ? strlen(args) : 0); return memcached_server_execute(memc, call_stat_fn, (void *)&check); } libmemcached-1.0.8/libmemcached/error.hpp0000664000076400007640000000777611753573717020677 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 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 #pragma once #ifdef __cplusplus #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) #define MEMCACHED_AT __FILE__ ":" TOSTRING(__LINE__) LIBMEMCACHED_LOCAL memcached_return_t memcached_set_parser_error(memcached_st& memc, const char *at, const char *format, ...); LIBMEMCACHED_LOCAL memcached_return_t memcached_set_error(memcached_st&, memcached_return_t rc, const char *at); LIBMEMCACHED_LOCAL memcached_return_t memcached_set_error(memcached_server_st&, memcached_return_t rc, const char *at); LIBMEMCACHED_LOCAL memcached_return_t memcached_set_error(memcached_st&, memcached_return_t rc, const char *at, const char *str, size_t length); LIBMEMCACHED_LOCAL memcached_return_t memcached_set_error(memcached_server_st&, memcached_return_t rc, const char *at, const char *str, size_t length); LIBMEMCACHED_LOCAL memcached_return_t memcached_set_error(memcached_st& memc, memcached_return_t rc, const char *at, memcached_string_t& str); LIBMEMCACHED_LOCAL memcached_return_t memcached_set_error(memcached_server_st&, memcached_return_t rc, const char *at, memcached_string_t& str); LIBMEMCACHED_LOCAL memcached_return_t memcached_set_errno(memcached_st& memc, int local_errno, const char *at, memcached_string_t& str); LIBMEMCACHED_LOCAL memcached_return_t memcached_set_errno(memcached_server_st&, int local_errno, const char *at, memcached_string_t& str); LIBMEMCACHED_LOCAL memcached_return_t memcached_set_errno(memcached_st& memc, int local_errno, const char *at, const char *str, size_t length); LIBMEMCACHED_LOCAL memcached_return_t memcached_set_errno(memcached_server_st&, int local_errno, const char *at, const char *str, size_t length); LIBMEMCACHED_LOCAL memcached_return_t memcached_set_errno(memcached_st& memc, int local_errno, const char *at); LIBMEMCACHED_LOCAL memcached_return_t memcached_set_errno(memcached_server_st&, int local_errno, const char *at); LIBMEMCACHED_LOCAL bool memcached_has_current_error(memcached_st&); LIBMEMCACHED_LOCAL bool memcached_has_current_error(memcached_server_st&); LIBMEMCACHED_LOCAL void memcached_error_free(memcached_st&); LIBMEMCACHED_LOCAL void memcached_error_free(memcached_server_st&); LIBMEMCACHED_LOCAL memcached_error_t *memcached_error_copy(const memcached_server_st&); #endif libmemcached-1.0.8/libmemcached/options.hpp0000664000076400007640000000447311753573717021230 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once LIBMEMCACHED_LOCAL void memcached_set_configuration_file(memcached_st *self, const char *filename, size_t filename_length); LIBMEMCACHED_LOCAL const char *memcached_parse_filename(memcached_st *memc); LIBMEMCACHED_LOCAL memcached_return_t memcached_parse_configuration(memcached_st *ptr, const char *option_string, size_t length); LIBMEMCACHED_LOCAL size_t memcached_parse_filename_length(memcached_st *memc); LIBMEMCACHED_LOCAL memcached_return_t memcached_parse_configure_file(memcached_st&, const char *filename, size_t length); LIBMEMCACHED_LOCAL memcached_return_t memcached_parse_configure_file(memcached_st&, memcached_array_st& filename); libmemcached-1.0.8/libmemcached/storage.cc0000664000076400007640000005042311753573717020773 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include enum memcached_storage_action_t { SET_OP, REPLACE_OP, ADD_OP, PREPEND_OP, APPEND_OP, CAS_OP }; /* Inline this */ static inline const char *storage_op_string(memcached_storage_action_t verb) { switch (verb) { case REPLACE_OP: return "replace "; case ADD_OP: return "add "; case PREPEND_OP: return "prepend "; case APPEND_OP: return "append "; case CAS_OP: return "cas "; case SET_OP: break; } return "set "; } static inline uint8_t can_by_encrypted(const memcached_storage_action_t verb) { switch (verb) { case SET_OP: case ADD_OP: case CAS_OP: case REPLACE_OP: return true; case APPEND_OP: case PREPEND_OP: break; } return false; } static inline uint8_t get_com_code(const memcached_storage_action_t verb, const bool reply) { if (reply == false) { switch (verb) { case SET_OP: return PROTOCOL_BINARY_CMD_SETQ; case ADD_OP: return PROTOCOL_BINARY_CMD_ADDQ; case CAS_OP: /* FALLTHROUGH */ case REPLACE_OP: return PROTOCOL_BINARY_CMD_REPLACEQ; case APPEND_OP: return PROTOCOL_BINARY_CMD_APPENDQ; case PREPEND_OP: return PROTOCOL_BINARY_CMD_PREPENDQ; } } switch (verb) { case SET_OP: break; case ADD_OP: return PROTOCOL_BINARY_CMD_ADD; case CAS_OP: /* FALLTHROUGH */ case REPLACE_OP: return PROTOCOL_BINARY_CMD_REPLACE; case APPEND_OP: return PROTOCOL_BINARY_CMD_APPEND; case PREPEND_OP: return PROTOCOL_BINARY_CMD_PREPEND; } return PROTOCOL_BINARY_CMD_SET; } static memcached_return_t memcached_send_binary(memcached_st *ptr, memcached_server_write_instance_st server, uint32_t server_key, const char *key, const size_t key_length, const char *value, const size_t value_length, const time_t expiration, const uint32_t flags, const uint64_t cas, const bool flush, const bool reply, memcached_storage_action_t verb) { protocol_binary_request_set request= {}; size_t send_length= sizeof(request.bytes); request.message.header.request.magic= PROTOCOL_BINARY_REQ; request.message.header.request.opcode= get_com_code(verb, reply); request.message.header.request.keylen= htons((uint16_t)(key_length + memcached_array_size(ptr->_namespace))); request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; if (verb == APPEND_OP or verb == PREPEND_OP) { send_length -= 8; /* append & prepend does not contain extras! */ } else { request.message.header.request.extlen= 8; request.message.body.flags= htonl(flags); request.message.body.expiration= htonl((uint32_t)expiration); } request.message.header.request.bodylen= htonl((uint32_t) (key_length + memcached_array_size(ptr->_namespace) + value_length + request.message.header.request.extlen)); if (cas) { request.message.header.request.cas= memcached_htonll(cas); } libmemcached_io_vector_st vector[]= { { NULL, 0 }, { request.bytes, send_length }, { memcached_array_string(ptr->_namespace), memcached_array_size(ptr->_namespace) }, { key, key_length }, { value, value_length } }; /* write the header */ memcached_return_t rc; if ((rc= memcached_vdo(server, vector, 5, flush)) != MEMCACHED_SUCCESS) { memcached_io_reset(server); #if 0 if (memcached_has_error(ptr)) { memcached_set_error(*server, rc, MEMCACHED_AT); } #endif return MEMCACHED_WRITE_FAILURE; } if (verb == SET_OP and ptr->number_of_replicas > 0) { request.message.header.request.opcode= PROTOCOL_BINARY_CMD_SETQ; WATCHPOINT_STRING("replicating"); for (uint32_t x= 0; x < ptr->number_of_replicas; x++) { ++server_key; if (server_key == memcached_server_count(ptr)) { server_key= 0; } memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, server_key); if (memcached_vdo(instance, vector, 5, false) != MEMCACHED_SUCCESS) { memcached_io_reset(instance); } else { memcached_server_response_decrement(instance); } } } if (flush == false) { return MEMCACHED_BUFFERED; } // No reply always assumes success if (reply == false) { return MEMCACHED_SUCCESS; } return memcached_response(server, NULL, 0, NULL); } static memcached_return_t memcached_send_ascii(memcached_st *ptr, memcached_server_write_instance_st instance, const char *key, const size_t key_length, const char *value, const size_t value_length, const time_t expiration, const uint32_t flags, const uint64_t cas, const bool flush, const bool reply, const memcached_storage_action_t verb) { char flags_buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; int flags_buffer_length= snprintf(flags_buffer, sizeof(flags_buffer), " %u", flags); if (size_t(flags_buffer_length) >= sizeof(flags_buffer) or flags_buffer_length < 0) { return memcached_set_error(*instance, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("snprintf(MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH)")); } char expiration_buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; int expiration_buffer_length= snprintf(expiration_buffer, sizeof(expiration_buffer), " %llu", (unsigned long long)expiration); if (size_t(expiration_buffer_length) >= sizeof(expiration_buffer) or expiration_buffer_length < 0) { return memcached_set_error(*instance, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("snprintf(MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH)")); } char value_buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; int value_buffer_length= snprintf(value_buffer, sizeof(value_buffer), " %llu", (unsigned long long)value_length); if (size_t(value_buffer_length) >= sizeof(value_buffer) or value_buffer_length < 0) { return memcached_set_error(*instance, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("snprintf(MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH)")); } char cas_buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; int cas_buffer_length= 0; if (cas) { cas_buffer_length= snprintf(cas_buffer, sizeof(cas_buffer), " %llu", (unsigned long long)cas); if (size_t(cas_buffer_length) >= sizeof(cas_buffer) or cas_buffer_length < 0) { return memcached_set_error(*instance, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("snprintf(MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH)")); } } libmemcached_io_vector_st vector[]= { { NULL, 0 }, { storage_op_string(verb), strlen(storage_op_string(verb))}, { memcached_array_string(ptr->_namespace), memcached_array_size(ptr->_namespace) }, { key, key_length }, { flags_buffer, flags_buffer_length }, { expiration_buffer, expiration_buffer_length }, { value_buffer, value_buffer_length }, { cas_buffer, cas_buffer_length }, { " noreply", reply ? 0 : memcached_literal_param_size(" noreply") }, { memcached_literal_param("\r\n") }, { value, value_length }, { memcached_literal_param("\r\n") } }; /* Send command header */ memcached_return_t rc= memcached_vdo(instance, vector, 12, flush); // If we should not reply, return with MEMCACHED_SUCCESS, unless error if (reply == false) { return memcached_success(rc) ? MEMCACHED_SUCCESS : rc; } if (flush == false) { return memcached_success(rc) ? MEMCACHED_BUFFERED : rc; } if (rc == MEMCACHED_SUCCESS) { char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; rc= memcached_response(instance, buffer, sizeof(buffer), NULL); if (rc == MEMCACHED_STORED) { return MEMCACHED_SUCCESS; } } if (rc == MEMCACHED_WRITE_FAILURE) { memcached_io_reset(instance); } assert(memcached_failed(rc)); #if 0 if (memcached_has_error(ptr) == false) { return memcached_set_error(*ptr, rc, MEMCACHED_AT); } #endif return rc; } static inline memcached_return_t memcached_send(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, const time_t expiration, const uint32_t flags, const uint64_t cas, memcached_storage_action_t verb) { memcached_return_t rc; if (memcached_failed(rc= initialize_query(ptr, true))) { return rc; } if (memcached_failed(memcached_key_test(*ptr, (const char **)&key, &key_length, 1))) { return memcached_last_error(ptr); } uint32_t server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length); memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, server_key); WATCHPOINT_SET(instance->io_wait_count.read= 0); WATCHPOINT_SET(instance->io_wait_count.write= 0); bool flush= true; if (memcached_is_buffering(instance->root) and verb == SET_OP) { flush= false; } bool reply= memcached_is_replying(ptr); hashkit_string_st* destination= NULL; if (memcached_is_encrypted(ptr)) { if (can_by_encrypted(verb) == false) { return memcached_set_error(*ptr, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT, memcached_literal_param("Operation not allowed while encyrption is enabled")); } if ((destination= hashkit_encrypt(&ptr->hashkit, value, value_length)) == NULL) { return rc; } value= hashkit_string_c_str(destination); value_length= hashkit_string_length(destination); } if (memcached_is_binary(ptr)) { rc= memcached_send_binary(ptr, instance, server_key, key, key_length, value, value_length, expiration, flags, cas, flush, reply, verb); } else { rc= memcached_send_ascii(ptr, instance, key, key_length, value, value_length, expiration, flags, cas, flush, reply, verb); } hashkit_string_free(destination); return rc; } memcached_return_t memcached_set(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags) { memcached_return_t rc; LIBMEMCACHED_MEMCACHED_SET_START(); rc= memcached_send(ptr, key, key_length, key, key_length, value, value_length, expiration, flags, 0, SET_OP); LIBMEMCACHED_MEMCACHED_SET_END(); return rc; } memcached_return_t memcached_add(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags) { memcached_return_t rc; LIBMEMCACHED_MEMCACHED_ADD_START(); rc= memcached_send(ptr, key, key_length, key, key_length, value, value_length, expiration, flags, 0, ADD_OP); LIBMEMCACHED_MEMCACHED_ADD_END(); return rc; } memcached_return_t memcached_replace(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags) { memcached_return_t rc; LIBMEMCACHED_MEMCACHED_REPLACE_START(); rc= memcached_send(ptr, key, key_length, key, key_length, value, value_length, expiration, flags, 0, REPLACE_OP); LIBMEMCACHED_MEMCACHED_REPLACE_END(); return rc; } memcached_return_t memcached_prepend(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags) { memcached_return_t rc; rc= memcached_send(ptr, key, key_length, key, key_length, value, value_length, expiration, flags, 0, PREPEND_OP); return rc; } memcached_return_t memcached_append(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags) { memcached_return_t rc; rc= memcached_send(ptr, key, key_length, key, key_length, value, value_length, expiration, flags, 0, APPEND_OP); return rc; } memcached_return_t memcached_cas(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags, uint64_t cas) { memcached_return_t rc; rc= memcached_send(ptr, key, key_length, key, key_length, value, value_length, expiration, flags, cas, CAS_OP); return rc; } memcached_return_t memcached_set_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags) { memcached_return_t rc; LIBMEMCACHED_MEMCACHED_SET_START(); rc= memcached_send(ptr, group_key, group_key_length, key, key_length, value, value_length, expiration, flags, 0, SET_OP); LIBMEMCACHED_MEMCACHED_SET_END(); return rc; } memcached_return_t memcached_add_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags) { memcached_return_t rc; LIBMEMCACHED_MEMCACHED_ADD_START(); rc= memcached_send(ptr, group_key, group_key_length, key, key_length, value, value_length, expiration, flags, 0, ADD_OP); LIBMEMCACHED_MEMCACHED_ADD_END(); return rc; } memcached_return_t memcached_replace_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags) { memcached_return_t rc; LIBMEMCACHED_MEMCACHED_REPLACE_START(); rc= memcached_send(ptr, group_key, group_key_length, key, key_length, value, value_length, expiration, flags, 0, REPLACE_OP); LIBMEMCACHED_MEMCACHED_REPLACE_END(); return rc; } memcached_return_t memcached_prepend_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags) { return memcached_send(ptr, group_key, group_key_length, key, key_length, value, value_length, expiration, flags, 0, PREPEND_OP); } memcached_return_t memcached_append_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags) { return memcached_send(ptr, group_key, group_key_length, key, key_length, value, value_length, expiration, flags, 0, APPEND_OP); } memcached_return_t memcached_cas_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags, uint64_t cas) { return memcached_send(ptr, group_key, group_key_length, key, key_length, value, value_length, expiration, flags, cas, CAS_OP); } libmemcached-1.0.8/libmemcached/version.cc0000664000076400007640000001127511753573717021016 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #include const char * memcached_lib_version(void) { return LIBMEMCACHED_VERSION_STRING; } static inline memcached_return_t memcached_version_textual(memcached_st *ptr) { libmemcached_io_vector_st vector[]= { { memcached_literal_param("version\r\n") }, }; uint32_t success= 0; bool errors_happened= false; for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); // Optimization, we only fetch version once. if (instance->major_version != UINT8_MAX) { continue; } memcached_return_t rrc; if (memcached_failed(rrc= memcached_vdo(instance, vector, 1, true))) { errors_happened= true; (void)memcached_set_error(*instance, rrc, MEMCACHED_AT); continue; } success++; } if (success) { // Collect the returned items memcached_server_write_instance_st instance; while ((instance= memcached_io_get_readable_server(ptr))) { memcached_return_t rrc= memcached_response(instance, NULL); if (memcached_failed(rrc)) { memcached_io_reset(instance); errors_happened= true; } } } return errors_happened ? MEMCACHED_SOME_ERRORS : MEMCACHED_SUCCESS; } static inline memcached_return_t memcached_version_binary(memcached_st *ptr) { protocol_binary_request_version request= {}; request.message.header.request.magic= PROTOCOL_BINARY_REQ; request.message.header.request.opcode= PROTOCOL_BINARY_CMD_VERSION; request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; libmemcached_io_vector_st vector[]= { { request.bytes, sizeof(request.bytes) } }; uint32_t success= 0; bool errors_happened= false; for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); if (instance->major_version != UINT8_MAX) { continue; } memcached_return_t rrc= memcached_vdo(instance, vector, 1, true); if (memcached_failed(rrc)) { memcached_io_reset(instance); errors_happened= true; continue; } success++; } if (success) { // Collect the returned items memcached_server_write_instance_st instance; while ((instance= memcached_io_get_readable_server(ptr))) { char buffer[32]; memcached_return_t rrc= memcached_response(instance, buffer, sizeof(buffer), NULL); if (memcached_failed(rrc)) { memcached_io_reset(instance); errors_happened= true; } } } return errors_happened ? MEMCACHED_SOME_ERRORS : MEMCACHED_SUCCESS; } memcached_return_t memcached_version(memcached_st *ptr) { memcached_return_t rc; if (memcached_failed(rc= initialize_query(ptr, true))) { return rc; } if (memcached_is_udp(ptr)) { return MEMCACHED_NOT_SUPPORTED; } if (memcached_is_binary(ptr)) { return memcached_version_binary(ptr); } return memcached_version_textual(ptr); } libmemcached-1.0.8/libmemcached/udp.hpp0000664000076400007640000000523411753573717020321 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 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. * */ #define MAX_UDP_DATAGRAM_LENGTH 1400 #define UDP_DATAGRAM_HEADER_LENGTH 8 #define UDP_REQUEST_ID_MSG_SIG_DIGITS 10 #define UDP_REQUEST_ID_THREAD_MASK 0xFFFF << UDP_REQUEST_ID_MSG_SIG_DIGITS #define get_udp_datagram_request_id(A) ntohs((A)->request_id) #define get_udp_datagram_seq_num(A) ntohs((A)->sequence_number) #define get_udp_datagram_num_datagrams(A) ntohs((A)->num_datagrams) #define get_msg_num_from_request_id(A) ( (A) & (~(UDP_REQUEST_ID_THREAD_MASK)) ) #define get_thread_id_from_request_id(A) ( (A) & (UDP_REQUEST_ID_THREAD_MASK) ) >> UDP_REQUEST_ID_MSG_SIG_DIGITS #define generate_udp_request_thread_id(A) (A) << UDP_REQUEST_ID_MSG_SIG_DIGITS #define UDP_REQUEST_ID_MAX_THREAD_ID get_thread_id_from_request_id(0xFFFF) struct udp_datagram_header_st { uint16_t request_id; uint16_t sequence_number; uint16_t num_datagrams; uint16_t reserved; }; bool memcached_io_init_udp_header(memcached_server_write_instance_st ptr, const uint16_t thread_id); void increment_udp_message_id(memcached_server_write_instance_st ptr); libmemcached-1.0.8/libmemcached/initialize_query.h0000664000076400007640000000344211753573717022556 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once memcached_return_t initialize_query(memcached_st *self, bool increment_query_id); memcached_return_t initialize_const_query(const memcached_st *self); libmemcached-1.0.8/libmemcached/memcached.hpp0000664000076400007640000000326511753573717021441 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #include libmemcached-1.0.8/libmemcached/exist.cc0000664000076400007640000001223411753573717020461 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 static memcached_return_t ascii_exist(memcached_st *memc, memcached_server_write_instance_st instance, const char *key, size_t key_length) { libmemcached_io_vector_st vector[]= { { NULL, 0 }, { memcached_literal_param("add ") }, { memcached_array_string(memc->_namespace), memcached_array_size(memc->_namespace) }, { key, key_length }, { memcached_literal_param(" 0") }, { memcached_literal_param(" 2678400") }, { memcached_literal_param(" 0") }, { memcached_literal_param("\r\n") }, { memcached_literal_param("\r\n") } }; /* Send command header */ memcached_return_t rc; if (memcached_fatal(rc= memcached_vdo(instance, vector, 9, true))) { return rc; } char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL); if (rc == MEMCACHED_NOTSTORED) { rc= MEMCACHED_SUCCESS; } if (rc == MEMCACHED_STORED) { rc= MEMCACHED_NOTFOUND; } return rc; } static memcached_return_t binary_exist(memcached_st *memc, memcached_server_write_instance_st instance, const char *key, size_t key_length) { protocol_binary_request_set request= {}; size_t send_length= sizeof(request.bytes); request.message.header.request.magic= PROTOCOL_BINARY_REQ; request.message.header.request.opcode= PROTOCOL_BINARY_CMD_ADD; request.message.header.request.keylen= htons((uint16_t)(key_length + memcached_array_size(memc->_namespace))); request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; request.message.header.request.extlen= 8; request.message.body.flags= 0; request.message.body.expiration= htonl(2678400); request.message.header.request.bodylen= htonl((uint32_t) (key_length +memcached_array_size(memc->_namespace) +request.message.header.request.extlen)); libmemcached_io_vector_st vector[]= { { NULL, 0 }, { request.bytes, send_length }, { memcached_array_string(memc->_namespace), memcached_array_size(memc->_namespace) }, { key, key_length } }; /* write the header */ memcached_return_t rc; if (memcached_fatal(rc= memcached_vdo(instance, vector, 4, true))) { return rc; } rc= memcached_response(instance, NULL, 0, NULL); if (rc == MEMCACHED_SUCCESS) { rc= MEMCACHED_NOTFOUND; } if (rc == MEMCACHED_DATA_EXISTS) { rc= MEMCACHED_SUCCESS; } return rc; } memcached_return_t memcached_exist(memcached_st *memc, const char *key, size_t key_length) { return memcached_exist_by_key(memc, key, key_length, key, key_length); } memcached_return_t memcached_exist_by_key(memcached_st *memc, const char *group_key, size_t group_key_length, const char *key, size_t key_length) { memcached_return_t rc; if (memcached_failed(rc= initialize_query(memc, true))) { return rc; } if (memcached_is_udp(memc)) { return memcached_set_error(*memc, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT); } uint32_t server_key= memcached_generate_hash_with_redistribution(memc, group_key, group_key_length); memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc, server_key); if (memcached_is_binary(memc)) { rc= binary_exist(memc, instance, key, key_length); } else { rc= ascii_exist(memc, instance, key, key_length); } if (memcached_fatal(rc)) { memcached_io_reset(instance); } return rc; } libmemcached-1.0.8/libmemcached/auto.cc0000664000076400007640000003654311753573717020306 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include static void auto_response(memcached_server_write_instance_st instance, const bool reply, memcached_return_t& rc, uint64_t* value) { // If the message was successfully sent, then get the response, otherwise // fail. if (memcached_success(rc)) { if (reply == false) { *value= UINT64_MAX; return; } rc= memcached_response(instance, &instance->root->result); } if (memcached_success(rc)) { *value= instance->root->result.numeric_value; } else { *value= UINT64_MAX; } } static memcached_return_t text_incr_decr(memcached_server_write_instance_st instance, const bool is_incr, const char *key, size_t key_length, const uint64_t offset, const bool reply) { char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; int send_length= snprintf(buffer, sizeof(buffer), " %" PRIu64, offset); if (size_t(send_length) >= sizeof(buffer) or send_length < 0) { return memcached_set_error(*instance, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)")); } libmemcached_io_vector_st vector[]= { { NULL, 0 }, { memcached_literal_param("incr ") }, { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) }, { key, key_length }, { buffer, send_length }, { " noreply", reply ? 0 : memcached_literal_param_size(" noreply") }, { memcached_literal_param("\r\n") } }; if (is_incr == false) { vector[1].buffer= "decr "; } return memcached_vdo(instance, vector, 7, true); } static memcached_return_t binary_incr_decr(memcached_server_write_instance_st instance, protocol_binary_command cmd, const char *key, const size_t key_length, const uint64_t offset, const uint64_t initial, const uint32_t expiration, const bool reply) { if (reply == false) { if(cmd == PROTOCOL_BINARY_CMD_DECREMENT) { cmd= PROTOCOL_BINARY_CMD_DECREMENTQ; } if(cmd == PROTOCOL_BINARY_CMD_INCREMENT) { cmd= PROTOCOL_BINARY_CMD_INCREMENTQ; } } protocol_binary_request_incr request= {}; // = {.bytes= {0}}; request.message.header.request.magic= PROTOCOL_BINARY_REQ; request.message.header.request.opcode= cmd; request.message.header.request.keylen= htons((uint16_t)(key_length + memcached_array_size(instance->root->_namespace))); request.message.header.request.extlen= 20; request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; request.message.header.request.bodylen= htonl((uint32_t)(key_length + memcached_array_size(instance->root->_namespace) +request.message.header.request.extlen)); request.message.body.delta= memcached_htonll(offset); request.message.body.initial= memcached_htonll(initial); request.message.body.expiration= htonl((uint32_t) expiration); libmemcached_io_vector_st vector[]= { { NULL, 0 }, { request.bytes, sizeof(request.bytes) }, { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) }, { key, key_length } }; return memcached_vdo(instance, vector, 4, true); } memcached_return_t memcached_increment(memcached_st *memc, const char *key, size_t key_length, uint32_t offset, uint64_t *value) { return memcached_increment_by_key(memc, key, key_length, key, key_length, offset, value); } static memcached_return_t increment_decrement_by_key(const protocol_binary_command command, memcached_st *memc, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t *value) { uint64_t local_value; if (value == NULL) { value= &local_value; } memcached_return_t rc; if (memcached_failed(rc= initialize_query(memc, true))) { return rc; } if (memcached_is_encrypted(memc)) { return memcached_set_error(*memc, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT, memcached_literal_param("Operation not allowed while encyrption is enabled")); } if (memcached_failed(rc= memcached_key_test(*memc, (const char **)&key, &key_length, 1))) { return memcached_last_error(memc); } uint32_t server_key= memcached_generate_hash_with_redistribution(memc, group_key, group_key_length); memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc, server_key); bool reply= memcached_is_replying(instance->root); if (memcached_is_binary(memc)) { rc= binary_incr_decr(instance, command, key, key_length, uint64_t(offset), 0, MEMCACHED_EXPIRATION_NOT_ADD, reply); } else { rc= text_incr_decr(instance, command == PROTOCOL_BINARY_CMD_INCREMENT ? true : false, key, key_length, offset, reply); } auto_response(instance, reply, rc, value); return rc; } static memcached_return_t increment_decrement_with_initial_by_key(const protocol_binary_command command, memcached_st *memc, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value) { uint64_t local_value; if (value == NULL) { value= &local_value; } memcached_return_t rc; if (memcached_failed(rc= initialize_query(memc, true))) { return rc; } if (memcached_is_encrypted(memc)) { return memcached_set_error(*memc, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT, memcached_literal_param("Operation not allowed while encyrption is enabled")); } if (memcached_failed(rc= memcached_key_test(*memc, (const char **)&key, &key_length, 1))) { return memcached_last_error(memc); } uint32_t server_key= memcached_generate_hash_with_redistribution(memc, group_key, group_key_length); memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc, server_key); bool reply= memcached_is_replying(instance->root); if (memcached_is_binary(memc)) { rc= binary_incr_decr(instance, command, key, key_length, offset, initial, uint32_t(expiration), reply); } else { rc= memcached_set_error(*memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("memcached_increment_with_initial_by_key() is not supported via the ASCII protocol")); } auto_response(instance, reply, rc, value); return rc; } memcached_return_t memcached_decrement(memcached_st *memc, const char *key, size_t key_length, uint32_t offset, uint64_t *value) { return memcached_decrement_by_key(memc, key, key_length, key, key_length, offset, value); } memcached_return_t memcached_increment_by_key(memcached_st *memc, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t *value) { LIBMEMCACHED_MEMCACHED_INCREMENT_START(); memcached_return_t rc= increment_decrement_by_key(PROTOCOL_BINARY_CMD_INCREMENT, memc, group_key, group_key_length, key, key_length, offset, value); LIBMEMCACHED_MEMCACHED_INCREMENT_END(); return rc; } memcached_return_t memcached_decrement_by_key(memcached_st *memc, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t *value) { LIBMEMCACHED_MEMCACHED_DECREMENT_START(); memcached_return_t rc= increment_decrement_by_key(PROTOCOL_BINARY_CMD_DECREMENT, memc, group_key, group_key_length, key, key_length, offset, value); LIBMEMCACHED_MEMCACHED_DECREMENT_END(); return rc; } memcached_return_t memcached_increment_with_initial(memcached_st *memc, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value) { return memcached_increment_with_initial_by_key(memc, key, key_length, key, key_length, offset, initial, expiration, value); } memcached_return_t memcached_increment_with_initial_by_key(memcached_st *memc, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value) { LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_START(); memcached_return_t rc= increment_decrement_with_initial_by_key(PROTOCOL_BINARY_CMD_INCREMENT, memc, group_key, group_key_length, key, key_length, offset, initial, expiration, value); LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_END(); return rc; } memcached_return_t memcached_decrement_with_initial(memcached_st *memc, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value) { return memcached_decrement_with_initial_by_key(memc, key, key_length, key, key_length, offset, initial, expiration, value); } memcached_return_t memcached_decrement_with_initial_by_key(memcached_st *memc, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value) { LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_START(); memcached_return_t rc= increment_decrement_with_initial_by_key(PROTOCOL_BINARY_CMD_DECREMENT, memc, group_key, group_key_length, key, key_length, offset, initial, expiration, value); LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_END(); return rc; } libmemcached-1.0.8/libmemcached/sasl.hpp0000664000076400007640000000357211753573717020476 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st *source); memcached_return_t memcached_sasl_authenticate_connection(memcached_server_st *server); libmemcached-1.0.8/libmemcached/server_list.hpp0000664000076400007640000000357211753573717022075 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once uint32_t memcached_servers_set_count(memcached_server_list_st servers, uint32_t count); memcached_server_st *memcached_server_list(const memcached_st *); void memcached_server_list_set(memcached_st *self, memcached_server_list_st list); libmemcached-1.0.8/libmemcached/csl/0000775000076400007640000000000011757025120017555 5ustar00brianbrian00000000000000libmemcached-1.0.8/libmemcached/csl/common.h0000664000076400007640000000336211753573717021242 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Configure Scripting Language * * Copyright (C) 2011 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. * */ #pragma once #include #include libmemcached-1.0.8/libmemcached/csl/parser.cc0000664000076400007640000020717211753573717021411 0ustar00brianbrian00000000000000/* A Bison parser, made by GNU Bison 2.5. */ /* Bison implementation for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "2.5" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 1 /* Push parsers. */ #define YYPUSH 0 /* Pull parsers. */ #define YYPULL 1 /* Using locations. */ #define YYLSP_NEEDED 0 /* Substitute the variable and function names. */ #define yyparse config_parse #define yylex config_lex #define yyerror config_error #define yylval config_lval #define yychar config_char #define yydebug config_debug #define yynerrs config_nerrs /* Copy the first part of user declarations. */ /* Line 268 of yacc.c */ #line 52 "libmemcached/csl/parser.yy" #include #include #include #include #include #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wold-style-cast" #endif int conf_lex(YYSTYPE* lvalp, void* scanner); #define select_yychar(__context) yychar == UNKNOWN ? ( (__context)->previous_token == END ? UNKNOWN : (__context)->previous_token ) : yychar #define stryytname(__yytokentype) ((__yytokentype) < YYNTOKENS ) ? yytname[(__yytokentype)] : "" #define parser_abort(__context, __error_message) do { (__context)->abort((__error_message), yytokentype(select_yychar(__context)), stryytname(YYTRANSLATE(select_yychar(__context)))); YYABORT; } while (0) // This is bison calling error. inline void __config_error(Context *context, yyscan_t *scanner, const char *error, int last_token, const char *last_token_str) { if (not context->end()) { context->error(error, yytokentype(last_token), last_token_str); } else { context->error(error, yytokentype(last_token), last_token_str); } } #define config_error(__context, __scanner, __error_msg) do { __config_error((__context), (__scanner), (__error_msg), select_yychar(__context), stryytname(YYTRANSLATE(select_yychar(__context)))); } while (0) /* Line 268 of yacc.c */ #line 119 "libmemcached/csl/parser.cc" /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 #endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 1 #endif /* Enabling the token table. */ #ifndef YYTOKEN_TABLE # define YYTOKEN_TABLE 0 #endif /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { COMMENT = 258, END = 259, ERROR = 260, RESET = 261, PARSER_DEBUG = 262, INCLUDE = 263, CONFIGURE_FILE = 264, EMPTY_LINE = 265, SERVER = 266, SOCKET = 267, SERVERS = 268, SERVERS_OPTION = 269, UNKNOWN_OPTION = 270, UNKNOWN = 271, BINARY_PROTOCOL = 272, BUFFER_REQUESTS = 273, CONNECT_TIMEOUT = 274, DISTRIBUTION = 275, HASH = 276, HASH_WITH_NAMESPACE = 277, IO_BYTES_WATERMARK = 278, IO_KEY_PREFETCH = 279, IO_MSG_WATERMARK = 280, KETAMA_HASH = 281, KETAMA_WEIGHTED = 282, NOREPLY = 283, NUMBER_OF_REPLICAS = 284, POLL_TIMEOUT = 285, RANDOMIZE_REPLICA_READ = 286, RCV_TIMEOUT = 287, REMOVE_FAILED_SERVERS = 288, RETRY_TIMEOUT = 289, SND_TIMEOUT = 290, SOCKET_RECV_SIZE = 291, SOCKET_SEND_SIZE = 292, SORT_HOSTS = 293, SUPPORT_CAS = 294, USER_DATA = 295, USE_UDP = 296, VERIFY_KEY = 297, _TCP_KEEPALIVE = 298, _TCP_KEEPIDLE = 299, _TCP_NODELAY = 300, NAMESPACE = 301, POOL_MIN = 302, POOL_MAX = 303, MD5 = 304, CRC = 305, FNV1_64 = 306, FNV1A_64 = 307, FNV1_32 = 308, FNV1A_32 = 309, HSIEH = 310, MURMUR = 311, JENKINS = 312, CONSISTENT = 313, MODULA = 314, RANDOM = 315, TRUE = 316, FALSE = 317, FLOAT = 318, NUMBER = 319, PORT = 320, WEIGHT_START = 321, IPADDRESS = 322, HOSTNAME = 323, STRING = 324, QUOTED_STRING = 325, FILE_PATH = 326 }; #endif #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif /* Copy the second part of user declarations. */ /* Line 343 of yacc.c */ #line 231 "libmemcached/csl/parser.cc" #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #elif (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) typedef signed char yytype_int8; #else typedef short int yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short int yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned int # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) # endif # endif # ifndef YY_ # define YY_(msgid) msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(e) ((void) (e)) #else # define YYUSE(e) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint # define YYID(n) (n) #else #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int YYID (int yyi) #else static int YYID (yyi) int yyi; #endif { return yyi; } #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yytype_int16 yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (YYID (0)) #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (YYID (0)) # endif # endif #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 71 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 74 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 75 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 12 /* YYNRULES -- Number of rules. */ #define YYNRULES 67 /* YYNRULES -- Number of states. */ #define YYNSTATES 85 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 326 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 74, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 63, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 64, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 65, 66, 67, 68, 69, 70, 71, 72, 73 }; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const yytype_uint8 yyprhs[] = { 0, 0, 3, 5, 9, 11, 13, 15, 17, 19, 21, 23, 27, 32, 37, 41, 44, 47, 50, 52, 55, 58, 63, 66, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 122, 124, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { 76, 0, -1, 77, -1, 76, 74, 77, -1, 78, -1, 3, -1, 10, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, 74, 85, -1, 11, 70, 82, 83, -1, 11, 69, 82, 83, -1, 12, 85, 83, -1, 9, 85, -1, 47, 66, -1, 48, 66, -1, 79, -1, 46, 85, -1, 20, 86, -1, 20, 86, 63, 84, -1, 21, 84, -1, 80, 66, -1, 81, -1, 40, -1, 33, -1, 19, -1, 25, -1, 23, -1, 24, -1, 29, -1, 30, -1, 32, -1, 34, -1, 35, -1, 36, -1, 37, -1, 17, -1, 18, -1, 22, -1, 28, -1, 31, -1, 38, -1, 39, -1, 45, -1, 43, -1, 44, -1, 41, -1, 42, -1, -1, 67, -1, -1, 68, -1, 49, -1, 50, -1, 51, -1, 52, -1, 53, -1, 54, -1, 55, -1, 56, -1, 57, -1, 71, -1, 72, -1, 58, -1, 59, -1, 60, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 188, 188, 189, 193, 195, 197, 199, 204, 209, 213, 217, 228, 238, 248, 257, 261, 265, 269, 273, 285, 298, 311, 318, 325, 334, 340, 344, 348, 352, 356, 360, 364, 368, 372, 376, 380, 384, 391, 395, 399, 403, 407, 411, 415, 419, 423, 427, 431, 435, 442, 443, 448, 449, 454, 458, 462, 466, 470, 474, 478, 482, 486, 493, 497, 504, 508, 512 }; #endif #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "COMMENT", "END", "ERROR", "RESET", "PARSER_DEBUG", "INCLUDE", "CONFIGURE_FILE", "EMPTY_LINE", "SERVER", "SOCKET", "SERVERS", "SERVERS_OPTION", "UNKNOWN_OPTION", "UNKNOWN", "BINARY_PROTOCOL", "BUFFER_REQUESTS", "CONNECT_TIMEOUT", "DISTRIBUTION", "HASH", "HASH_WITH_NAMESPACE", "IO_BYTES_WATERMARK", "IO_KEY_PREFETCH", "IO_MSG_WATERMARK", "KETAMA_HASH", "KETAMA_WEIGHTED", "NOREPLY", "NUMBER_OF_REPLICAS", "POLL_TIMEOUT", "RANDOMIZE_REPLICA_READ", "RCV_TIMEOUT", "REMOVE_FAILED_SERVERS", "RETRY_TIMEOUT", "SND_TIMEOUT", "SOCKET_RECV_SIZE", "SOCKET_SEND_SIZE", "SORT_HOSTS", "SUPPORT_CAS", "USER_DATA", "USE_UDP", "VERIFY_KEY", "_TCP_KEEPALIVE", "_TCP_KEEPIDLE", "_TCP_NODELAY", "NAMESPACE", "POOL_MIN", "POOL_MAX", "MD5", "CRC", "FNV1_64", "FNV1A_64", "FNV1_32", "FNV1A_32", "HSIEH", "MURMUR", "JENKINS", "CONSISTENT", "MODULA", "RANDOM", "TRUE", "FALSE", "','", "'='", "FLOAT", "NUMBER", "PORT", "WEIGHT_START", "IPADDRESS", "HOSTNAME", "STRING", "QUOTED_STRING", "FILE_PATH", "' '", "$accept", "begin", "statement", "expression", "behaviors", "behavior_number", "behavior_boolean", "optional_port", "optional_weight", "hash", "string", "distribution", 0 }; #endif # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 44, 61, 318, 319, 320, 321, 322, 323, 324, 325, 326, 32 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { 0, 75, 76, 76, 77, 77, 77, 77, 77, 77, 77, 77, 78, 78, 78, 78, 78, 78, 78, 79, 79, 79, 79, 79, 79, 79, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 82, 82, 83, 83, 84, 84, 84, 84, 84, 84, 84, 84, 84, 85, 85, 86, 86, 86 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 4, 4, 3, 2, 2, 2, 1, 2, 2, 4, 2, 2, 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, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. Performed when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { 0, 5, 7, 8, 9, 10, 0, 0, 6, 0, 0, 38, 39, 27, 0, 0, 40, 29, 30, 28, 41, 31, 32, 42, 33, 26, 34, 35, 36, 37, 43, 44, 25, 48, 49, 46, 47, 45, 0, 0, 0, 0, 2, 4, 18, 0, 24, 0, 63, 64, 15, 50, 50, 52, 65, 66, 67, 20, 54, 55, 56, 57, 58, 59, 60, 61, 62, 22, 19, 16, 17, 1, 0, 23, 11, 51, 52, 52, 53, 14, 0, 3, 13, 12, 21 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { -1, 41, 42, 43, 44, 45, 46, 76, 79, 67, 50, 57 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -61 static const yytype_int8 yypact[] = { -2, -61, -61, -61, -61, -61, -60, -24, -61, -20, -24, -61, -61, -61, -47, 13, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -24, -41, -15, 0, -61, -61, -61, -11, -61, -24, -61, -61, -61, -10, -10, -12, -61, -61, -61, -5, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -61, -2, -61, -61, -61, -12, -12, -61, -61, 13, -61, -61, -61, -61 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -61, -61, -13, -61, -61, -61, -61, 8, -23, -9, 14, -61 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { 71, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 54, 55, 56, 47, 11, 12, 13, 14, 15, 16, 17, 18, 19, 53, 69, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 48, 49, 51, 52, 70, 68, 82, 83, 73, 78, 75, 80, 81, 77, 74, 58, 59, 60, 61, 62, 63, 64, 65, 66, 84, 0, 0, 72 }; #define yypact_value_is_default(yystate) \ ((yystate) == (-61)) #define yytable_value_is_error(yytable_value) \ YYID (0) static const yytype_int8 yycheck[] = { 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 58, 59, 60, 74, 17, 18, 19, 20, 21, 22, 23, 24, 25, 10, 66, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 71, 72, 69, 70, 66, 38, 76, 77, 66, 68, 67, 63, 72, 52, 47, 49, 50, 51, 52, 53, 54, 55, 56, 57, 80, -1, -1, 74 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 17, 18, 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 76, 77, 78, 79, 80, 81, 74, 71, 72, 85, 69, 70, 85, 58, 59, 60, 86, 49, 50, 51, 52, 53, 54, 55, 56, 57, 84, 85, 66, 66, 0, 74, 66, 85, 67, 82, 82, 68, 83, 63, 77, 83, 83, 84 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. However, YYFAIL appears to be in use. Nevertheless, it is formally deprecated in Bison 2.4.2's NEWS entry, where a plan to phase it out is discussed. */ #define YYFAIL goto yyerrlab #if defined YYFAIL /* This is here to suppress warnings from the GCC cpp's -Wunused-macros. Normally we don't worry about that warning, but some users do, and we want to make it easy for users to remove YYFAIL uses, which will produce warnings from Bison 2.5. */ #endif #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ YYPOPSTACK (1); \ goto yybackup; \ } \ else \ { \ yyerror (context, scanner, YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ #define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ if (YYID (N)) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ } \ else \ { \ (Current).first_line = (Current).last_line = \ YYRHSLOC (Rhs, 0).last_line; \ (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ while (YYID (0)) #endif /* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, YYLEX_PARAM) #else # define YYLEX yylex (&yylval, scanner) #endif /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (YYID (0)) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value, context, scanner); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context, yyscan_t *scanner) #else static void yy_symbol_value_print (yyoutput, yytype, yyvaluep, context, scanner) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; Context *context; yyscan_t *scanner; #endif { if (!yyvaluep) return; YYUSE (context); YYUSE (scanner); # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # else YYUSE (yyoutput); # endif switch (yytype) { default: break; } } /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context, yyscan_t *scanner) #else static void yy_symbol_print (yyoutput, yytype, yyvaluep, context, scanner) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; Context *context; yyscan_t *scanner; #endif { if (yytype < YYNTOKENS) YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep, context, scanner); YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void yy_stack_print (yybottom, yytop) yytype_int16 *yybottom; yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) { int yybot = *yybottom; YYFPRINTF (stderr, " %d", yybot); } YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_reduce_print (YYSTYPE *yyvsp, int yyrule, Context *context, yyscan_t *scanner) #else static void yy_reduce_print (yyvsp, yyrule, context, scanner) YYSTYPE *yyvsp; int yyrule; Context *context; yyscan_t *scanner; #endif { int yynrhs = yyr2[yyrule]; int yyi; unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) , context, scanner); YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyvsp, Rule, context, scanner); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) #else static YYSIZE_T yystrlen (yystr) const char *yystr; #endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) #else static char * yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; #endif { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return yystpcpy (yyres, yystr) - yyres; } # endif /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message about the unexpected token YYTOKEN for the state stack whose top is YYSSP. Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is not large enough to hold the message. In that case, also set *YYMSG_ALLOC to the required number of bytes. Return 2 if the required number of bytes is too large to store. */ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); YYSIZE_T yysize = yysize0; YYSIZE_T yysize1; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = 0; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per "expected"). */ int yycount = 0; /* There are many possibilities here to consider: - Assume YYFAIL is not used. It's too flawed to consider. See for details. YYERROR is fine as it does not invoke this function. - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected tokens because there are none. - The only way there can be no lookahead present (in yychar) is if this state is a consistent state with a default action. Thus, detecting the absence of a lookahead is sufficient to determine that there is no unexpected or expected token to report. In that case, just report a simple "syntax error". - Don't assume there isn't a lookahead just because this state is a consistent state with a default action. There might have been a previous inconsistent state, consistent state with a non-default action, or user semantic action that manipulated yychar. - Of course, the expected token list depends on states to have correct lookahead information, and it depends on the parser not to perform extra reductions after fetching a lookahead from the scanner and before detecting a syntax error. Thus, state merging (from LALR or IELR) and default reductions corrupt the expected token list. However, the list is correct for canonical LR with one exception: it will still contain any token that will not be accepted due to an error action in a later state. */ if (yytoken != YYEMPTY) { int yyn = yypact[*yyssp]; yyarg[yycount++] = yytname[yytoken]; if (!yypact_value_is_default (yyn)) { /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. In other words, skip the first -YYN actions for this state because they are default actions. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yyx; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; break; } yyarg[yycount++] = yytname[yyx]; yysize1 = yysize + yytnamerr (0, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } } } switch (yycount) { # define YYCASE_(N, S) \ case N: \ yyformat = S; \ break YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); # undef YYCASE_ } yysize1 = yysize + yystrlen (yyformat); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; if (*yymsg_alloc < yysize) { *yymsg_alloc = 2 * yysize; if (! (yysize <= *yymsg_alloc && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; return 1; } /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ { char *yyp = *yymsg; int yyi = 0; while ((*yyp = *yyformat) != '\0') if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyformat += 2; } else { yyp++; yyformat++; } } return 0; } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Context *context, yyscan_t *scanner) #else static void yydestruct (yymsg, yytype, yyvaluep, context, scanner) const char *yymsg; int yytype; YYSTYPE *yyvaluep; Context *context; yyscan_t *scanner; #endif { YYUSE (yyvaluep); YYUSE (context); YYUSE (scanner); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); switch (yytype) { default: break; } } /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); #else int yyparse (); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus int yyparse (Context *context, yyscan_t *scanner); #else int yyparse (); #endif #endif /* ! YYPARSE_PARAM */ /*----------. | yyparse. | `----------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (void *YYPARSE_PARAM) #else int yyparse (YYPARSE_PARAM) void *YYPARSE_PARAM; #endif #else /* ! YYPARSE_PARAM */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (Context *context, yyscan_t *scanner) #else int yyparse (context, scanner) Context *context; yyscan_t *scanner; #endif #endif { /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: `yyss': related to states. `yyvs': related to semantic values. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; YYSIZE_T yystacksize; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ int yytoken; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; yytoken = 0; yyss = yyssa; yyvs = yyvsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yytable_value_is_error (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token. */ yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 4: /* Line 1806 of yacc.c */ #line 194 "libmemcached/csl/parser.yy" { } break; case 5: /* Line 1806 of yacc.c */ #line 196 "libmemcached/csl/parser.yy" { } break; case 6: /* Line 1806 of yacc.c */ #line 198 "libmemcached/csl/parser.yy" { } break; case 7: /* Line 1806 of yacc.c */ #line 200 "libmemcached/csl/parser.yy" { context->set_end(); YYACCEPT; } break; case 8: /* Line 1806 of yacc.c */ #line 205 "libmemcached/csl/parser.yy" { context->rc= MEMCACHED_PARSE_USER_ERROR; parser_abort(context, "ERROR called directly"); } break; case 9: /* Line 1806 of yacc.c */ #line 210 "libmemcached/csl/parser.yy" { memcached_reset(context->memc); } break; case 10: /* Line 1806 of yacc.c */ #line 214 "libmemcached/csl/parser.yy" { yydebug= 1; } break; case 11: /* Line 1806 of yacc.c */ #line 218 "libmemcached/csl/parser.yy" { if ((context->rc= memcached_parse_configure_file(*context->memc, (yyvsp[(3) - (3)].string).c_str, (yyvsp[(3) - (3)].string).size)) != MEMCACHED_SUCCESS) { parser_abort(context, "Failed to parse configuration file"); } } break; case 12: /* Line 1806 of yacc.c */ #line 229 "libmemcached/csl/parser.yy" { if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, (yyvsp[(2) - (4)].server).c_str, (yyvsp[(3) - (4)].number), (yyvsp[(4) - (4)].number)))) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "Failed to add server: %s:%u", (yyvsp[(2) - (4)].server).c_str, uint32_t((yyvsp[(3) - (4)].number))); parser_abort(context, buffer); } context->unset_server(); } break; case 13: /* Line 1806 of yacc.c */ #line 239 "libmemcached/csl/parser.yy" { if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, (yyvsp[(2) - (4)].server).c_str, (yyvsp[(3) - (4)].number), (yyvsp[(4) - (4)].number)))) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "Failed to add server: %s:%u", (yyvsp[(2) - (4)].server).c_str, uint32_t((yyvsp[(3) - (4)].number))); parser_abort(context, buffer); } context->unset_server(); } break; case 14: /* Line 1806 of yacc.c */ #line 249 "libmemcached/csl/parser.yy" { if (memcached_failed(context->rc= memcached_server_add_unix_socket_with_weight(context->memc, (yyvsp[(2) - (3)].string).c_str, (yyvsp[(3) - (3)].number)))) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "Failed to add server: %s", (yyvsp[(2) - (3)].string).c_str); parser_abort(context, buffer); } } break; case 15: /* Line 1806 of yacc.c */ #line 258 "libmemcached/csl/parser.yy" { memcached_set_configuration_file(context->memc, (yyvsp[(2) - (2)].string).c_str, (yyvsp[(2) - (2)].string).size); } break; case 16: /* Line 1806 of yacc.c */ #line 262 "libmemcached/csl/parser.yy" { context->memc->configure.initial_pool_size= (yyvsp[(2) - (2)].number); } break; case 17: /* Line 1806 of yacc.c */ #line 266 "libmemcached/csl/parser.yy" { context->memc->configure.max_pool_size= (yyvsp[(2) - (2)].number); } break; case 19: /* Line 1806 of yacc.c */ #line 274 "libmemcached/csl/parser.yy" { if (memcached_callback_get(context->memc, MEMCACHED_CALLBACK_PREFIX_KEY, NULL)) { parser_abort(context, "--NAMESPACE can only be called once"); } if ((context->rc= memcached_set_namespace(context->memc, (yyvsp[(2) - (2)].string).c_str, (yyvsp[(2) - (2)].string).size)) != MEMCACHED_SUCCESS) { parser_abort(context, memcached_last_error_message(context->memc)); } } break; case 20: /* Line 1806 of yacc.c */ #line 286 "libmemcached/csl/parser.yy" { // Check to see if DISTRIBUTION has already been set if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, (yyvsp[(2) - (2)].distribution))) != MEMCACHED_SUCCESS) { parser_abort(context, "--DISTRIBUTION can only be called once"); } if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, (yyvsp[(2) - (2)].distribution))) != MEMCACHED_SUCCESS) { parser_abort(context, memcached_last_error_message(context->memc));; } } break; case 21: /* Line 1806 of yacc.c */ #line 299 "libmemcached/csl/parser.yy" { // Check to see if DISTRIBUTION has already been set if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, (yyvsp[(2) - (4)].distribution))) != MEMCACHED_SUCCESS) { parser_abort(context, "--DISTRIBUTION can only be called once"); } if ((context->rc= memcached_behavior_set_distribution_hash(context->memc, (yyvsp[(4) - (4)].hash))) != MEMCACHED_SUCCESS) { parser_abort(context, "Unable to set the hash for the DISTRIBUTION requested"); } } break; case 22: /* Line 1806 of yacc.c */ #line 312 "libmemcached/csl/parser.yy" { if (context->set_hash((yyvsp[(2) - (2)].hash)) == false) { parser_abort(context, "--HASH can only be set once"); } } break; case 23: /* Line 1806 of yacc.c */ #line 319 "libmemcached/csl/parser.yy" { if ((context->rc= memcached_behavior_set(context->memc, (yyvsp[(1) - (2)].behavior), (yyvsp[(2) - (2)].number))) != MEMCACHED_SUCCESS) { parser_abort(context, "Unable to set behavior"); } } break; case 24: /* Line 1806 of yacc.c */ #line 326 "libmemcached/csl/parser.yy" { if ((context->rc= memcached_behavior_set(context->memc, (yyvsp[(1) - (1)].behavior), true)) != MEMCACHED_SUCCESS) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "Could not set: %s", libmemcached_string_behavior((yyvsp[(1) - (1)].behavior))); parser_abort(context, buffer); } } break; case 25: /* Line 1806 of yacc.c */ #line 335 "libmemcached/csl/parser.yy" { } break; case 26: /* Line 1806 of yacc.c */ #line 341 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS; } break; case 27: /* Line 1806 of yacc.c */ #line 345 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT; } break; case 28: /* Line 1806 of yacc.c */ #line 349 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK; } break; case 29: /* Line 1806 of yacc.c */ #line 353 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK; } break; case 30: /* Line 1806 of yacc.c */ #line 357 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH; } break; case 31: /* Line 1806 of yacc.c */ #line 361 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS; } break; case 32: /* Line 1806 of yacc.c */ #line 365 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_POLL_TIMEOUT; } break; case 33: /* Line 1806 of yacc.c */ #line 369 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_RCV_TIMEOUT; } break; case 34: /* Line 1806 of yacc.c */ #line 373 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_RETRY_TIMEOUT; } break; case 35: /* Line 1806 of yacc.c */ #line 377 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_SND_TIMEOUT; } break; case 36: /* Line 1806 of yacc.c */ #line 381 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE; } break; case 37: /* Line 1806 of yacc.c */ #line 385 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE; } break; case 38: /* Line 1806 of yacc.c */ #line 392 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_BINARY_PROTOCOL; } break; case 39: /* Line 1806 of yacc.c */ #line 396 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_BUFFER_REQUESTS; } break; case 40: /* Line 1806 of yacc.c */ #line 400 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY; } break; case 41: /* Line 1806 of yacc.c */ #line 404 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_NOREPLY; } break; case 42: /* Line 1806 of yacc.c */ #line 408 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ; } break; case 43: /* Line 1806 of yacc.c */ #line 412 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_SORT_HOSTS; } break; case 44: /* Line 1806 of yacc.c */ #line 416 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_SUPPORT_CAS; } break; case 45: /* Line 1806 of yacc.c */ #line 420 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_TCP_NODELAY; } break; case 46: /* Line 1806 of yacc.c */ #line 424 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_TCP_KEEPALIVE; } break; case 47: /* Line 1806 of yacc.c */ #line 428 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_TCP_KEEPIDLE; } break; case 48: /* Line 1806 of yacc.c */ #line 432 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_USE_UDP; } break; case 49: /* Line 1806 of yacc.c */ #line 436 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_VERIFY_KEY; } break; case 50: /* Line 1806 of yacc.c */ #line 442 "libmemcached/csl/parser.yy" { (yyval.number)= MEMCACHED_DEFAULT_PORT;} break; case 51: /* Line 1806 of yacc.c */ #line 444 "libmemcached/csl/parser.yy" { } break; case 52: /* Line 1806 of yacc.c */ #line 448 "libmemcached/csl/parser.yy" { (yyval.number)= 1; } break; case 53: /* Line 1806 of yacc.c */ #line 450 "libmemcached/csl/parser.yy" { } break; case 54: /* Line 1806 of yacc.c */ #line 455 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_MD5; } break; case 55: /* Line 1806 of yacc.c */ #line 459 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_CRC; } break; case 56: /* Line 1806 of yacc.c */ #line 463 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_FNV1_64; } break; case 57: /* Line 1806 of yacc.c */ #line 467 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_FNV1A_64; } break; case 58: /* Line 1806 of yacc.c */ #line 471 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_FNV1_32; } break; case 59: /* Line 1806 of yacc.c */ #line 475 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_FNV1A_32; } break; case 60: /* Line 1806 of yacc.c */ #line 479 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_HSIEH; } break; case 61: /* Line 1806 of yacc.c */ #line 483 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_MURMUR; } break; case 62: /* Line 1806 of yacc.c */ #line 487 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_JENKINS; } break; case 63: /* Line 1806 of yacc.c */ #line 494 "libmemcached/csl/parser.yy" { (yyval.string)= (yyvsp[(1) - (1)].string); } break; case 64: /* Line 1806 of yacc.c */ #line 498 "libmemcached/csl/parser.yy" { (yyval.string)= (yyvsp[(1) - (1)].string); } break; case 65: /* Line 1806 of yacc.c */ #line 505 "libmemcached/csl/parser.yy" { (yyval.distribution)= MEMCACHED_DISTRIBUTION_CONSISTENT; } break; case 66: /* Line 1806 of yacc.c */ #line 509 "libmemcached/csl/parser.yy" { (yyval.distribution)= MEMCACHED_DISTRIBUTION_MODULA; } break; case 67: /* Line 1806 of yacc.c */ #line 513 "libmemcached/csl/parser.yy" { (yyval.distribution)= MEMCACHED_DISTRIBUTION_RANDOM; } break; /* Line 1806 of yacc.c */ #line 2172 "libmemcached/csl/parser.cc" default: break; } /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. One alternative is translating here after every semantic action, but that translation would be missed if the semantic action invokes YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an incorrect destructor might then be invoked immediately. In the case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (context, scanner, YY_("syntax error")); #else # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ yyssp, yytoken) { char const *yymsgp = YY_("syntax error"); int yysyntax_error_status; yysyntax_error_status = YYSYNTAX_ERROR; if (yysyntax_error_status == 0) yymsgp = yymsg; else if (yysyntax_error_status == 1) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); if (!yymsg) { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; yysyntax_error_status = 2; } else { yysyntax_error_status = YYSYNTAX_ERROR; yymsgp = yymsg; } } yyerror (context, scanner, yymsgp); if (yysyntax_error_status == 2) goto yyexhaustedlab; } # undef YYSYNTAX_ERROR #endif } if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval, context, scanner); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yydestruct ("Error: popping", yystos[yystate], yyvsp, context, scanner); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } *++yyvsp = yylval; /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (context, scanner, YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEMPTY) { /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = YYTRANSLATE (yychar); yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, context, scanner); } /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp, context, scanner); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif /* Make sure YYID is used. */ return YYID (yyresult); } /* Line 2067 of yacc.c */ #line 518 "libmemcached/csl/parser.yy" void Context::start() { config_parse(this, (void **)scanner); } libmemcached-1.0.8/libmemcached/csl/scanner.h0000664000076400007640000002475211753573717021411 0ustar00brianbrian00000000000000#ifndef config_HEADER_H #define config_HEADER_H 1 #define config_IN_HEADER 1 #line 6 "libmemcached/csl/scanner.h" #line 39 "libmemcached/csl/scanner.l" #include #include #include #include #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wold-style-cast" #pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wunused-parameter" #endif #define YY_NO_INPUT #define YY_EXTRA_TYPE Context* #line 27 "libmemcached/csl/scanner.h" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ /* %not-for-header */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif /* %if-c++-only */ /* %endif */ /* %if-c-only */ /* %endif */ /* %if-c-only */ /* %endif */ /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ /* %if-c-only */ #include #include #include #include /* %endif */ /* %if-tables-serialization */ /* %endif */ /* end standard C headers. */ /* %if-c-or-c++ */ /* flex integer type definitions */ #ifndef FLEXINT_H #define FLEXINT_H /* C99 systems have . Non-C99 systems may or may not. */ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 #endif #include typedef int8_t flex_int8_t; typedef uint8_t flex_uint8_t; typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; #endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN #define INT8_MIN (-128) #endif #ifndef INT16_MIN #define INT16_MIN (-32767-1) #endif #ifndef INT32_MIN #define INT32_MIN (-2147483647-1) #endif #ifndef INT8_MAX #define INT8_MAX (127) #endif #ifndef INT16_MAX #define INT16_MAX (32767) #endif #ifndef INT32_MAX #define INT32_MAX (2147483647) #endif #ifndef UINT8_MAX #define UINT8_MAX (255U) #endif #ifndef UINT16_MAX #define UINT16_MAX (65535U) #endif #ifndef UINT32_MAX #define UINT32_MAX (4294967295U) #endif #endif /* ! FLEXINT_H */ /* %endif */ /* %if-c++-only */ /* %endif */ #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ /* C99 requires __STDC__ to be defined as 1. */ #if defined (__STDC__) #define YY_USE_CONST #endif /* defined (__STDC__) */ #endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif /* %not-for-header */ /* %not-for-header */ /* %if-reentrant */ /* An opaque pointer. */ #ifndef YY_TYPEDEF_YY_SCANNER_T #define YY_TYPEDEF_YY_SCANNER_T typedef void* yyscan_t; #endif /* For convenience, these vars (plus the bison vars far below) are macros in the reentrant scanner. */ #define yyin yyg->yyin_r #define yyout yyg->yyout_r #define yyextra yyg->yyextra_r #define yyleng yyg->yyleng_r #define yytext yyg->yytext_r #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) #define yy_flex_debug yyg->yy_flex_debug_r /* %endif */ /* %if-not-reentrant */ /* %endif */ /* Size of default input buffer. */ #ifndef YY_BUF_SIZE #define YY_BUF_SIZE 16384 #endif #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif /* %if-not-reentrant */ /* %endif */ /* %if-c-only */ /* %if-not-reentrant */ /* %endif */ /* %endif */ #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; #endif #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { /* %if-c-only */ FILE *yy_input_file; /* %endif */ /* %if-c++-only */ /* %endif */ char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* %if-c-only Standard (non-C++) definition */ /* %not-for-header */ /* %endif */ /* %if-c-only Standard (non-C++) definition */ /* %if-not-reentrant */ /* %not-for-header */ /* %endif */ void config_restart (FILE *input_file ,yyscan_t yyscanner ); void config__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); YY_BUFFER_STATE config__create_buffer (FILE *file,int size ,yyscan_t yyscanner ); void config__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); void config__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); void config_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); void config_pop_buffer_state (yyscan_t yyscanner ); YY_BUFFER_STATE config__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); YY_BUFFER_STATE config__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); YY_BUFFER_STATE config__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); /* %endif */ void *config_alloc (yy_size_t ,yyscan_t yyscanner ); void *config_realloc (void *,yy_size_t ,yyscan_t yyscanner ); void config_free (void * ,yyscan_t yyscanner ); /* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */ /* Begin user sect3 */ #define config_wrap(n) 1 #define YY_SKIP_YYWRAP #define FLEX_DEBUG #define yytext_ptr yytext_r /* %if-c-only Standard (non-C++) definition */ /* %endif */ #ifdef YY_HEADER_EXPORT_START_CONDITIONS #define INITIAL 0 #endif #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ /* %if-c-only */ #include /* %endif */ /* %if-c++-only */ /* %endif */ #endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif /* %if-c-only Reentrant structure and macros (non-C++). */ /* %if-reentrant */ /* %if-c-only */ /* %endif */ /* %if-reentrant */ int config_lex_init (yyscan_t* scanner); int config_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); /* %endif */ /* %endif End reentrant structures and macros. */ /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ int config_lex_destroy (yyscan_t yyscanner ); int config_get_debug (yyscan_t yyscanner ); void config_set_debug (int debug_flag ,yyscan_t yyscanner ); YY_EXTRA_TYPE config_get_extra (yyscan_t yyscanner ); void config_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); FILE *config_get_in (yyscan_t yyscanner ); void config_set_in (FILE * in_str ,yyscan_t yyscanner ); FILE *config_get_out (yyscan_t yyscanner ); void config_set_out (FILE * out_str ,yyscan_t yyscanner ); int config_get_leng (yyscan_t yyscanner ); char *config_get_text (yyscan_t yyscanner ); int config_get_lineno (yyscan_t yyscanner ); void config_set_lineno (int line_number ,yyscan_t yyscanner ); int config_get_column (yyscan_t yyscanner ); void config_set_column (int column_no ,yyscan_t yyscanner ); /* %if-bison-bridge */ YYSTYPE * config_get_lval (yyscan_t yyscanner ); void config_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); /* %endif */ /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus extern "C" int config_wrap (yyscan_t yyscanner ); #else extern int config_wrap (yyscan_t yyscanner ); #endif #endif /* %not-for-header */ /* %endif */ #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT /* %if-c-only Standard (non-C++) definition */ /* %not-for-header */ /* %endif */ #endif /* %if-c-only */ /* %endif */ /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #define YY_READ_BUF_SIZE 8192 #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* %if-tables-serialization structures and prototypes */ /* %not-for-header */ /* %not-for-header */ /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 /* %if-c-only Standard (non-C++) definition */ extern int config_lex \ (YYSTYPE * yylval_param ,yyscan_t yyscanner); #define YY_DECL int config_lex \ (YYSTYPE * yylval_param , yyscan_t yyscanner) /* %endif */ /* %if-c++-only C++ definition */ /* %endif */ #endif /* !YY_DECL */ /* %not-for-header */ /* %if-c++-only */ /* %not-for-header */ /* %endif */ /* yy_get_previous_state - get the state just before the EOB char was reached */ /* %if-c-only */ /* %not-for-header */ #undef YY_NEW_FILE #undef YY_FLUSH_BUFFER #undef yy_set_bol #undef yy_new_buffer #undef yy_set_interactive #undef YY_DO_BEFORE_ACTION #ifdef YY_DECL_IS_OURS #undef YY_DECL_IS_OURS #undef YY_DECL #endif #line 220 "libmemcached/csl/scanner.l" #line 482 "libmemcached/csl/scanner.h" #undef config_IN_HEADER #endif /* config_HEADER_H */ libmemcached-1.0.8/libmemcached/csl/include.am0000664000076400007640000000121411753573717021535 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root DISTCLEANFILES+= libmemcached/csl/parser.output noinst_HEADERS+= libmemcached/csl/common.h noinst_HEADERS+= libmemcached/csl/context.h noinst_HEADERS+= libmemcached/csl/parser.h noinst_HEADERS+= libmemcached/csl/scanner.h noinst_HEADERS+= libmemcached/csl/server.h noinst_HEADERS+= libmemcached/csl/symbol.h libmemcached_libmemcached_la_SOURCES+= libmemcached/csl/context.cc libmemcached_libmemcached_la_SOURCES+= libmemcached/csl/parser.cc libmemcached_libmemcached_la_SOURCES+= libmemcached/csl/scanner.cc include libmemcached/csl/parser.am libmemcached-1.0.8/libmemcached/csl/symbol.h0000664000076400007640000000377111753573717021263 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Configure Scripting Language * * Copyright (C) 2011 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. * */ #pragma once #include union YYSTYPE { long long number; memcached_string_t string; memcached_string_t option; double double_number; memcached_server_distribution_t distribution; memcached_hash_t hash; memcached_behavior_t behavior; bool boolean; server_t server; }; typedef union YYSTYPE YYSTYPE; libmemcached-1.0.8/libmemcached/csl/context.cc0000664000076400007640000000760111753573717021574 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Configure Scripting Language * * Copyright (C) 2011 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 #include void Context::abort(const char *error_arg, yytokentype last_token, const char *last_token_str) { rc= MEMCACHED_PARSE_ERROR; (void)last_token; if (error_arg) { memcached_set_parser_error(*memc, MEMCACHED_AT, "%s", error_arg); return; } if (last_token_str) { memcached_set_parser_error(*memc, MEMCACHED_AT, "%s", last_token_str); return; } memcached_set_parser_error(*memc, MEMCACHED_AT, "unknown parsing error"); } void Context::error(const char *error_arg, yytokentype last_token, const char *last_token_str) { rc= MEMCACHED_PARSE_ERROR; if (not error_arg) { memcached_set_parser_error(*memc, MEMCACHED_AT, "Unknown error occured during parsing (%s)", last_token_str ? last_token_str : " "); return; } if (error_arg and strcmp(error_arg, "memory exhausted") == 0) { (void)memcached_set_error(*memc, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_string_make_from_cstr(error_arg)); return; } // We now test if it is something other then a syntax error, if it we // return a generic message if (error_arg and strcmp(error_arg, "syntax error") == 0) { } else if (error_arg) { memcached_set_parser_error(*memc, MEMCACHED_AT, "Error occured during parsing (%s)", error_arg); return; } if (last_token == UNKNOWN_OPTION and begin) { memcached_set_parser_error(*memc, MEMCACHED_AT, "Unknown option: %s", begin); } else if (last_token == UNKNOWN) { memcached_set_parser_error(*memc, MEMCACHED_AT, "Error occured durring parsing, an unknown token was found."); } else { memcached_set_parser_error(*memc, MEMCACHED_AT, "Error occured while parsing (%s)", last_token_str ? last_token_str : " "); } } const char *Context::set_hostname(const char *str, size_t size) { size_t copy_length= size_t(NI_MAXHOST) > size ? size : size_t(NI_MAXHOST); memcpy(_hostname, str, copy_length); _hostname[copy_length]= 0; return _hostname; } bool Context::set_hash(memcached_hash_t hash) { if (_has_hash) { return false; } if ((memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, hash)) != MEMCACHED_SUCCESS) { return false; } return _has_hash= true; } libmemcached-1.0.8/libmemcached/csl/scanner.cc0000664000076400007640000031507211753573717021545 0ustar00brianbrian00000000000000#line 2 "libmemcached/csl/scanner.cc" #line 39 "libmemcached/csl/scanner.l" #include #include #include #include #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wold-style-cast" #pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wunused-parameter" #endif #define YY_NO_INPUT #define YY_EXTRA_TYPE Context* #line 23 "libmemcached/csl/scanner.cc" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ /* %not-for-header */ /* %if-c-only */ /* %if-not-reentrant */ /* %endif */ /* %endif */ /* %ok-for-header */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif /* %if-c++-only */ /* %endif */ /* %if-c-only */ /* %endif */ /* %if-c-only */ /* %endif */ /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ /* %if-c-only */ #include #include #include #include /* %endif */ /* %if-tables-serialization */ /* %endif */ /* end standard C headers. */ /* %if-c-or-c++ */ /* flex integer type definitions */ #ifndef FLEXINT_H #define FLEXINT_H /* C99 systems have . Non-C99 systems may or may not. */ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 #endif #include typedef int8_t flex_int8_t; typedef uint8_t flex_uint8_t; typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; #endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN #define INT8_MIN (-128) #endif #ifndef INT16_MIN #define INT16_MIN (-32767-1) #endif #ifndef INT32_MIN #define INT32_MIN (-2147483647-1) #endif #ifndef INT8_MAX #define INT8_MAX (127) #endif #ifndef INT16_MAX #define INT16_MAX (32767) #endif #ifndef INT32_MAX #define INT32_MAX (2147483647) #endif #ifndef UINT8_MAX #define UINT8_MAX (255U) #endif #ifndef UINT16_MAX #define UINT16_MAX (65535U) #endif #ifndef UINT32_MAX #define UINT32_MAX (4294967295U) #endif #endif /* ! FLEXINT_H */ /* %endif */ /* %if-c++-only */ /* %endif */ #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ /* C99 requires __STDC__ to be defined as 1. */ #if defined (__STDC__) #define YY_USE_CONST #endif /* defined (__STDC__) */ #endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif /* %not-for-header */ /* Returned upon end-of-file. */ #define YY_NULL 0 /* %ok-for-header */ /* %not-for-header */ /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* %ok-for-header */ /* %if-reentrant */ /* An opaque pointer. */ #ifndef YY_TYPEDEF_YY_SCANNER_T #define YY_TYPEDEF_YY_SCANNER_T typedef void* yyscan_t; #endif /* For convenience, these vars (plus the bison vars far below) are macros in the reentrant scanner. */ #define yyin yyg->yyin_r #define yyout yyg->yyout_r #define yyextra yyg->yyextra_r #define yyleng yyg->yyleng_r #define yytext yyg->yytext_r #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) #define yy_flex_debug yyg->yy_flex_debug_r /* %endif */ /* %if-not-reentrant */ /* %endif */ /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN yyg->yy_start = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START ((yyg->yy_start - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE config_restart(yyin ,yyscanner ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE #define YY_BUF_SIZE 16384 #endif /* The state buf must be large enough to hold one state per character in the main buffer. */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif /* %if-not-reentrant */ /* %endif */ /* %if-c-only */ /* %if-not-reentrant */ /* %endif */ /* %endif */ #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = yyg->yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; #endif #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { /* %if-c-only */ FILE *yy_input_file; /* %endif */ /* %if-c++-only */ /* %endif */ char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via config_restart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* %if-c-only Standard (non-C++) definition */ /* %not-for-header */ /* %if-not-reentrant */ /* %endif */ /* %ok-for-header */ /* %endif */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". * * Returns the top of the stack, or NULL. */ #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ : NULL) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] /* %if-c-only Standard (non-C++) definition */ /* %if-not-reentrant */ /* %not-for-header */ /* %ok-for-header */ /* %endif */ void config_restart (FILE *input_file ,yyscan_t yyscanner ); void config__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); YY_BUFFER_STATE config__create_buffer (FILE *file,int size ,yyscan_t yyscanner ); void config__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); void config__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); void config_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); void config_pop_buffer_state (yyscan_t yyscanner ); static void config_ensure_buffer_stack (yyscan_t yyscanner ); static void config__load_buffer_state (yyscan_t yyscanner ); static void config__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); #define YY_FLUSH_BUFFER config__flush_buffer(YY_CURRENT_BUFFER ,yyscanner) YY_BUFFER_STATE config__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); YY_BUFFER_STATE config__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); YY_BUFFER_STATE config__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); /* %endif */ void *config_alloc (yy_size_t ,yyscan_t yyscanner ); void *config_realloc (void *,yy_size_t ,yyscan_t yyscanner ); void config_free (void * ,yyscan_t yyscanner ); #define yy_new_buffer config__create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ config_ensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ config__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ config_ensure_buffer_stack (yyscanner); \ YY_CURRENT_BUFFER_LVALUE = \ config__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */ /* Begin user sect3 */ #define config_wrap(n) 1 #define YY_SKIP_YYWRAP #define FLEX_DEBUG typedef unsigned char YY_CHAR; typedef int yy_state_type; #define yytext_ptr yytext_r /* %if-c-only Standard (non-C++) definition */ static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); static int yy_get_next_buffer (yyscan_t yyscanner ); static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); /* %endif */ /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ yyg->yytext_ptr = yy_bp; \ /* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\ yyleng = (size_t) (yy_cp - yy_bp); \ yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ /* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\ yyg->yy_c_buf_p = yy_cp; /* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */ #define YY_NUM_RULES 65 #define YY_END_OF_BUFFER 66 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info { flex_int32_t yy_verify; flex_int32_t yy_nxt; }; static yyconst flex_int16_t yy_accept[521] = { 0, 0, 0, 66, 64, 5, 5, 1, 64, 64, 64, 2, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 63, 0, 48, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 4, 62, 62, 2, 3, 62, 53, 62, 44, 62, 62, 62, 62, 62, 62, 63, 0, 62, 52, 62, 62, 62, 62, 62, 62, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 4, 0, 62, 2, 3, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 46, 48, 48, 48, 48, 48, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 4, 62, 62, 3, 62, 42, 45, 47, 62, 0, 58, 62, 62, 62, 62, 62, 41, 62, 48, 48, 48, 48, 48, 48, 0, 0, 0, 48, 48, 48, 48, 48, 48, 0, 48, 48, 48, 0, 48, 48, 48, 0, 0, 48, 48, 4, 0, 62, 3, 62, 0, 62, 62, 62, 62, 50, 59, 51, 62, 48, 48, 48, 48, 48, 0, 15, 0, 0, 0, 48, 48, 48, 0, 0, 48, 0, 48, 48, 48, 0, 48, 0, 48, 0, 0, 0, 0, 48, 4, 61, 62, 62, 62, 62, 56, 54, 40, 60, 43, 48, 48, 48, 48, 48, 0, 0, 0, 0, 48, 48, 48, 0, 0, 48, 0, 48, 0, 48, 0, 48, 0, 48, 0, 0, 0, 0, 48, 61, 62, 57, 55, 0, 0, 48, 48, 48, 0, 0, 0, 0, 48, 19, 0, 0, 0, 0, 48, 0, 0, 0, 7, 0, 0, 8, 0, 48, 0, 0, 34, 0, 0, 61, 62, 0, 0, 48, 0, 48, 0, 0, 0, 0, 48, 0, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, 48, 0, 48, 0, 0, 0, 0, 48, 0, 0, 38, 37, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, 0, 0, 48, 0, 0, 0, 0, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 0, 0, 0, 0, 36, 0, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 33, 0, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 23, 0, 0, 26, 0, 0, 0, 32, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 0, 0, 9, 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 27, 28, 0, 0, 0, 0, 0, 14, 16, 20, 0, 0, 0, 0, 0, 0, 22, 24, 0 } ; static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 5, 6, 1, 1, 1, 1, 1, 1, 1, 1, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 11, 11, 11, 18, 1, 1, 19, 1, 20, 1, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 1, 47, 1, 1, 48, 1, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 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, 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, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst flex_int32_t yy_meta[75] = { 0, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 } ; static yyconst flex_int16_t yy_base[526] = { 0, 0, 622, 626, 1711, 1711, 1711, 1711, 70, 617, 597, 67, 74, 0, 57, 52, 59, 73, 57, 64, 74, 610, 77, 79, 77, 65, 609, 101, 1711, 606, 138, 202, 215, 217, 230, 237, 250, 252, 259, 265, 277, 282, 287, 297, 271, 315, 377, 323, 342, 350, 359, 364, 396, 401, 591, 1711, 449, 242, 73, 80, 89, 76, 378, 78, 397, 398, 91, 76, 91, 441, 328, 515, 528, 481, 499, 421, 541, 543, 548, 553, 559, 565, 576, 590, 595, 649, 0, 597, 622, 614, 624, 656, 632, 674, 85, 131, 124, 230, 249, 572, 260, 272, 285, 403, 300, 319, 375, 336, 376, 650, 381, 401, 415, 436, 717, 730, 743, 756, 768, 781, 787, 789, 797, 803, 808, 825, 810, 838, 852, 854, 863, 870, 702, 454, 455, 651, 442, 456, 656, 461, 534, 538, 533, 537, 562, 571, 581, 628, 642, 570, 655, 650, 656, 569, 687, 664, 893, 921, 872, 928, 907, 879, 942, 944, 949, 951, 958, 967, 973, 975, 980, 993, 995, 1000, 660, 683, 720, 750, 755, 126, 755, 795, 786, 787, 805, 860, 567, 564, 856, 856, 855, 941, 969, 971, 987, 547, 981, 996, 976, 546, 999, 1048, 1062, 1075, 1711, 1088, 1090, 1024, 1097, 1106, 1112, 1117, 1124, 1132, 1134, 1012, 1043, 1089, 1095, 1090, 1081, 1711, 1087, 1085, 1107, 1099, 1116, 1111, 1110, 1120, 1124, 1132, 1139, 527, 1128, 1138, 1128, 1141, 1132, 1146, 1139, 1151, 1159, 1139, 1711, 1205, 1182, 1199, 1218, 1220, 1228, 1233, 1235, 1240, 1246, 526, 517, 1165, 1192, 1217, 1217, 1225, 514, 513, 1235, 1212, 472, 1229, 1240, 1230, 1229, 471, 1223, 457, 1231, 258, 1230, 1230, 1246, 1248, 1237, 1254, 456, 1297, 1310, 1312, 1317, 1243, 1257, 1258, 451, 1263, 1287, 1289, 1293, 1288, 1310, 0, 1299, 1302, 1292, 1304, 1293, 1315, 1315, 1313, 1711, 1318, 1308, 1711, 1309, 406, 1313, 1325, 1711, 1311, 1321, 1376, 1378, 1316, 1348, 1363, 1349, 1351, 1364, 403, 1355, 1373, 1370, 1371, 1374, 373, 372, 1375, 1367, 1382, 1371, 1370, 1381, 1382, 1368, 1386, 1418, 1378, 1391, 1388, 1406, 1394, 1405, 367, 1414, 1415, 362, 1402, 1423, 1409, 346, 352, 1415, 1711, 1711, 348, 1410, 1423, 1428, 1414, 1433, 1424, 1420, 1439, 1429, 1438, 1442, 1711, 1419, 1425, 1425, 1442, 1436, 1439, 1448, 1464, 1469, 1473, 1711, 1461, 1459, 1463, 1463, 1472, 1470, 1466, 1465, 1484, 1711, 1470, 1482, 1480, 1469, 1711, 1480, 1491, 1488, 1493, 1485, 1499, 1481, 1497, 1486, 1500, 1490, 1513, 334, 1516, 1510, 333, 340, 336, 1711, 1512, 1530, 1711, 1533, 1518, 1527, 1525, 322, 1528, 1537, 1523, 1531, 1529, 321, 1531, 1711, 1544, 1530, 1711, 1532, 1533, 1548, 1711, 1539, 1535, 1551, 1536, 1711, 1553, 1542, 1558, 1565, 1562, 1711, 1565, 319, 289, 1578, 1581, 1711, 1579, 1573, 285, 1573, 1576, 1583, 1589, 1580, 1590, 1591, 1582, 1711, 1577, 1578, 1711, 1711, 1711, 282, 1590, 1606, 253, 1597, 1606, 1607, 1606, 1607, 1608, 1711, 1613, 1598, 1711, 243, 1616, 1621, 1612, 237, 221, 1630, 1632, 1711, 1627, 229, 1625, 1711, 1711, 1643, 217, 208, 1631, 1646, 1711, 1711, 1711, 1647, 1635, 1653, 1636, 1652, 202, 1711, 1711, 1711, 1704, 154, 1706, 131, 1708 } ; static yyconst flex_int16_t yy_def[526] = { 0, 520, 1, 520, 520, 520, 520, 520, 521, 520, 520, 522, 520, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 523, 521, 520, 521, 520, 520, 524, 524, 524, 520, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 525, 524, 524, 524, 524, 524, 524, 524, 523, 520, 30, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 520, 524, 524, 524, 520, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 525, 85, 524, 524, 524, 524, 524, 524, 524, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 520, 524, 524, 524, 520, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 56, 56, 56, 56, 56, 520, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 520, 524, 524, 520, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 56, 56, 56, 56, 56, 56, 520, 520, 520, 56, 56, 56, 56, 56, 56, 520, 56, 56, 56, 520, 56, 56, 56, 520, 520, 56, 56, 520, 524, 524, 520, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 56, 56, 56, 56, 56, 520, 520, 520, 520, 520, 56, 56, 56, 520, 520, 56, 520, 56, 56, 56, 520, 56, 520, 56, 520, 520, 520, 520, 56, 520, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 56, 56, 56, 56, 56, 520, 520, 520, 520, 56, 56, 56, 520, 520, 56, 520, 56, 520, 56, 520, 56, 520, 56, 520, 520, 520, 520, 56, 524, 524, 524, 524, 520, 520, 56, 56, 56, 520, 520, 520, 520, 56, 56, 520, 520, 520, 520, 56, 520, 520, 520, 520, 520, 520, 520, 520, 56, 520, 520, 520, 520, 520, 524, 524, 520, 520, 56, 520, 56, 520, 520, 520, 520, 56, 520, 520, 520, 520, 56, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 524, 520, 520, 56, 520, 56, 520, 520, 520, 520, 56, 520, 520, 520, 520, 56, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 56, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 56, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 56, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 0, 520, 520, 520, 520, 520 } ; static yyconst flex_int16_t yy_nxt[1786] = { 0, 4, 5, 6, 7, 8, 4, 7, 9, 4, 10, 11, 11, 11, 11, 11, 11, 11, 12, 7, 4, 13, 13, 14, 15, 16, 17, 13, 18, 19, 20, 13, 21, 22, 13, 13, 13, 13, 23, 24, 25, 13, 13, 13, 13, 13, 13, 4, 4, 13, 13, 14, 15, 16, 17, 13, 18, 19, 20, 13, 21, 22, 13, 13, 13, 13, 23, 24, 25, 13, 13, 13, 13, 13, 13, 28, 33, 38, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 36, 39, 41, 37, 43, 40, 44, 45, 50, 47, 52, 53, 51, 38, 28, 42, 96, 97, 98, 99, 48, 103, 111, 112, 113, 29, 49, 133, 36, 39, 41, 37, 43, 40, 44, 45, 50, 47, 52, 53, 51, 70, 220, 42, 96, 97, 98, 99, 48, 103, 111, 112, 113, 221, 49, 133, 29, 56, 56, 56, 56, 56, 56, 56, 32, 134, 135, 56, 57, 58, 59, 56, 56, 56, 60, 61, 56, 56, 56, 56, 62, 56, 63, 56, 64, 65, 66, 67, 68, 56, 56, 56, 56, 134, 135, 56, 57, 58, 59, 56, 56, 56, 60, 61, 56, 56, 56, 56, 62, 56, 63, 56, 64, 65, 66, 67, 68, 56, 56, 56, 56, 69, 69, 69, 69, 69, 69, 69, 32, 519, 32, 32, 32, 32, 32, 511, 71, 71, 71, 71, 71, 71, 71, 32, 510, 507, 32, 33, 503, 72, 72, 72, 72, 72, 72, 72, 73, 73, 73, 73, 73, 73, 73, 32, 502, 32, 32, 32, 32, 32, 498, 32, 32, 32, 308, 32, 32, 136, 32, 94, 489, 32, 32, 75, 32, 309, 32, 32, 32, 76, 32, 95, 74, 32, 32, 32, 137, 77, 32, 32, 32, 139, 82, 32, 32, 136, 32, 94, 32, 486, 32, 75, 475, 32, 32, 32, 470, 76, 140, 95, 74, 32, 79, 78, 137, 77, 141, 32, 32, 139, 82, 32, 32, 32, 81, 469, 32, 80, 32, 32, 32, 32, 144, 32, 32, 32, 140, 87, 452, 446, 79, 78, 439, 32, 141, 32, 438, 83, 32, 32, 437, 434, 81, 32, 387, 80, 32, 32, 385, 145, 144, 32, 32, 384, 88, 32, 32, 32, 380, 32, 32, 32, 148, 377, 32, 83, 27, 27, 27, 27, 84, 27, 27, 85, 85, 27, 89, 145, 32, 360, 359, 90, 88, 27, 27, 27, 32, 100, 149, 32, 148, 91, 32, 32, 32, 32, 146, 32, 32, 353, 32, 101, 341, 147, 89, 152, 104, 102, 105, 90, 106, 107, 29, 85, 32, 100, 149, 32, 32, 91, 108, 109, 92, 142, 146, 153, 143, 110, 154, 101, 93, 147, 32, 152, 104, 102, 105, 32, 106, 107, 114, 114, 114, 114, 114, 114, 114, 322, 108, 109, 92, 142, 316, 153, 143, 110, 154, 32, 93, 56, 56, 56, 155, 174, 306, 56, 56, 304, 298, 175, 178, 56, 179, 56, 183, 56, 56, 56, 56, 56, 118, 118, 118, 118, 118, 118, 118, 56, 56, 56, 155, 174, 32, 56, 56, 32, 32, 175, 178, 56, 179, 56, 183, 56, 56, 56, 56, 56, 32, 295, 294, 32, 115, 288, 116, 116, 116, 116, 116, 116, 116, 32, 287, 272, 32, 33, 119, 117, 117, 117, 117, 117, 117, 117, 32, 32, 32, 32, 32, 32, 32, 32, 242, 237, 32, 32, 32, 184, 185, 32, 32, 32, 32, 186, 119, 32, 32, 187, 32, 123, 229, 32, 32, 228, 32, 197, 193, 189, 138, 32, 120, 121, 32, 32, 188, 184, 185, 32, 124, 32, 122, 186, 55, 32, 32, 187, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 125, 520, 120, 121, 55, 32, 188, 46, 190, 31, 124, 32, 122, 126, 32, 32, 32, 30, 520, 32, 26, 32, 32, 32, 32, 32, 520, 520, 125, 32, 32, 520, 32, 32, 520, 32, 190, 32, 520, 128, 129, 126, 27, 27, 27, 27, 84, 27, 27, 85, 85, 27, 520, 32, 32, 127, 32, 32, 191, 27, 27, 27, 32, 520, 32, 150, 131, 128, 129, 176, 180, 32, 32, 130, 32, 32, 192, 177, 194, 181, 151, 182, 195, 127, 196, 200, 191, 198, 29, 85, 215, 132, 520, 150, 131, 520, 32, 176, 180, 32, 216, 130, 32, 32, 192, 177, 194, 181, 151, 182, 195, 520, 196, 200, 32, 520, 520, 199, 215, 132, 156, 156, 156, 156, 156, 156, 156, 32, 216, 520, 32, 32, 520, 157, 157, 157, 157, 157, 157, 157, 32, 217, 32, 32, 115, 199, 158, 158, 158, 158, 158, 158, 158, 32, 520, 520, 32, 32, 520, 117, 117, 117, 117, 117, 117, 117, 520, 218, 520, 217, 32, 159, 159, 159, 159, 159, 159, 159, 32, 520, 520, 32, 32, 32, 32, 219, 32, 32, 32, 32, 32, 520, 222, 520, 32, 218, 32, 32, 32, 520, 32, 520, 160, 32, 32, 32, 161, 32, 32, 32, 32, 32, 223, 219, 163, 520, 164, 224, 225, 162, 222, 32, 32, 520, 520, 32, 32, 32, 166, 32, 160, 168, 520, 226, 161, 32, 520, 32, 32, 32, 223, 520, 163, 165, 164, 224, 225, 162, 32, 32, 32, 32, 32, 32, 32, 32, 166, 520, 167, 168, 32, 226, 169, 32, 32, 32, 520, 32, 520, 32, 32, 32, 32, 115, 520, 520, 32, 227, 32, 32, 32, 171, 520, 230, 520, 170, 167, 173, 231, 232, 169, 520, 32, 520, 32, 172, 201, 201, 201, 201, 201, 201, 201, 32, 32, 227, 520, 32, 32, 171, 32, 230, 32, 170, 520, 173, 231, 232, 32, 32, 520, 32, 202, 172, 203, 203, 203, 203, 203, 203, 203, 204, 204, 204, 204, 204, 204, 204, 205, 32, 520, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 520, 520, 32, 520, 207, 32, 32, 208, 32, 520, 520, 32, 520, 205, 32, 32, 520, 32, 520, 32, 32, 32, 32, 32, 32, 233, 520, 32, 32, 32, 209, 32, 520, 234, 520, 211, 206, 32, 32, 32, 32, 32, 32, 32, 32, 32, 210, 32, 32, 520, 235, 236, 520, 233, 32, 238, 241, 212, 209, 520, 32, 234, 32, 211, 243, 213, 239, 32, 32, 240, 520, 32, 32, 520, 210, 520, 250, 214, 235, 236, 32, 520, 32, 238, 241, 212, 520, 32, 520, 520, 520, 520, 243, 213, 239, 520, 255, 240, 244, 244, 244, 244, 244, 244, 244, 214, 32, 520, 520, 32, 32, 32, 245, 245, 245, 245, 245, 245, 245, 32, 256, 520, 32, 202, 255, 246, 246, 246, 246, 246, 246, 246, 32, 520, 32, 32, 32, 32, 32, 520, 520, 32, 520, 248, 32, 32, 249, 520, 256, 32, 32, 251, 520, 32, 32, 257, 32, 258, 259, 32, 32, 32, 32, 260, 32, 32, 261, 247, 32, 262, 252, 32, 32, 263, 264, 32, 32, 32, 32, 32, 32, 32, 32, 257, 32, 258, 259, 265, 266, 267, 253, 260, 268, 32, 261, 247, 269, 262, 252, 32, 270, 263, 264, 271, 32, 273, 274, 275, 276, 277, 278, 32, 254, 279, 280, 265, 266, 267, 253, 32, 268, 32, 281, 282, 269, 520, 32, 520, 270, 32, 202, 271, 520, 273, 274, 275, 276, 277, 278, 520, 254, 279, 280, 32, 520, 289, 32, 32, 520, 32, 281, 282, 32, 32, 520, 283, 283, 283, 283, 283, 283, 283, 32, 284, 32, 32, 32, 32, 32, 32, 285, 290, 32, 289, 286, 32, 32, 32, 291, 32, 32, 32, 32, 32, 32, 292, 32, 32, 32, 293, 32, 284, 32, 32, 32, 296, 297, 299, 302, 290, 300, 303, 305, 307, 310, 32, 291, 32, 301, 311, 312, 313, 314, 292, 315, 32, 520, 293, 319, 520, 32, 520, 32, 296, 297, 299, 302, 32, 300, 303, 305, 307, 310, 32, 320, 321, 301, 311, 312, 313, 314, 32, 315, 323, 32, 32, 319, 317, 317, 317, 317, 317, 317, 317, 32, 520, 32, 32, 32, 32, 32, 32, 320, 321, 32, 32, 324, 325, 326, 520, 327, 323, 328, 329, 330, 331, 520, 332, 333, 334, 335, 336, 337, 318, 32, 338, 339, 340, 342, 343, 344, 345, 520, 347, 324, 325, 326, 32, 327, 32, 328, 329, 330, 331, 32, 332, 333, 334, 335, 336, 337, 318, 348, 338, 339, 340, 342, 343, 344, 345, 32, 347, 32, 32, 32, 32, 32, 349, 350, 520, 351, 352, 354, 355, 356, 520, 357, 520, 358, 361, 348, 362, 363, 364, 365, 366, 367, 368, 369, 372, 32, 373, 374, 32, 32, 349, 350, 346, 351, 352, 354, 355, 356, 32, 357, 32, 358, 361, 375, 362, 363, 364, 365, 366, 367, 368, 369, 372, 370, 373, 374, 376, 378, 379, 381, 346, 371, 382, 383, 386, 388, 389, 390, 32, 391, 392, 375, 393, 394, 395, 396, 397, 398, 399, 400, 401, 370, 402, 403, 376, 378, 379, 381, 404, 371, 382, 383, 386, 388, 389, 390, 405, 391, 392, 406, 393, 394, 395, 396, 397, 398, 399, 400, 401, 407, 402, 403, 408, 409, 410, 411, 404, 412, 413, 414, 415, 416, 417, 418, 405, 419, 420, 406, 421, 422, 423, 424, 425, 426, 427, 428, 429, 407, 430, 431, 408, 409, 410, 411, 432, 412, 413, 414, 415, 416, 417, 418, 433, 419, 420, 435, 421, 422, 423, 424, 425, 426, 427, 428, 429, 436, 430, 431, 440, 441, 442, 443, 432, 444, 445, 447, 448, 449, 450, 451, 433, 453, 454, 435, 455, 456, 457, 458, 459, 460, 461, 462, 463, 436, 464, 465, 440, 441, 442, 443, 466, 444, 445, 447, 448, 449, 450, 451, 467, 453, 454, 468, 455, 456, 457, 458, 459, 460, 461, 462, 463, 471, 464, 465, 472, 473, 474, 476, 466, 477, 478, 479, 480, 481, 482, 483, 467, 484, 485, 468, 487, 488, 490, 491, 492, 493, 494, 495, 496, 471, 497, 499, 472, 473, 474, 476, 500, 477, 478, 479, 480, 481, 482, 483, 501, 484, 485, 504, 487, 488, 490, 491, 492, 493, 494, 495, 496, 505, 497, 499, 506, 508, 509, 512, 500, 513, 514, 515, 516, 517, 518, 520, 501, 520, 520, 504, 520, 520, 520, 520, 520, 520, 520, 520, 520, 505, 520, 520, 506, 508, 509, 512, 520, 513, 514, 515, 516, 517, 518, 27, 27, 54, 54, 86, 86, 3, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520 } ; static yyconst flex_int16_t yy_chk[1786] = { 0, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 11, 15, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 14, 16, 17, 14, 18, 16, 19, 20, 23, 22, 24, 25, 23, 15, 27, 17, 58, 59, 60, 61, 22, 63, 66, 67, 68, 8, 22, 94, 14, 16, 17, 14, 18, 16, 19, 20, 23, 22, 24, 25, 23, 524, 179, 17, 58, 59, 60, 61, 22, 63, 66, 67, 68, 179, 22, 94, 27, 30, 30, 30, 30, 30, 30, 30, 522, 95, 96, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 95, 96, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 32, 517, 33, 32, 32, 33, 33, 506, 33, 33, 33, 33, 33, 33, 33, 34, 505, 500, 34, 34, 495, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 36, 494, 37, 36, 36, 37, 37, 490, 32, 38, 33, 275, 38, 38, 97, 39, 57, 479, 39, 39, 37, 44, 275, 34, 44, 44, 38, 40, 57, 36, 40, 40, 41, 98, 39, 41, 41, 42, 100, 44, 42, 42, 97, 36, 57, 37, 476, 43, 37, 461, 43, 43, 38, 455, 38, 101, 57, 36, 39, 41, 40, 98, 39, 102, 44, 45, 100, 44, 45, 45, 40, 43, 454, 47, 42, 41, 47, 47, 70, 104, 42, 70, 70, 101, 47, 432, 426, 41, 40, 417, 43, 102, 48, 416, 45, 48, 48, 415, 412, 43, 49, 361, 42, 49, 49, 357, 105, 104, 45, 50, 356, 48, 50, 50, 51, 352, 47, 51, 51, 107, 349, 70, 45, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 49, 105, 48, 332, 331, 50, 48, 46, 46, 46, 49, 62, 108, 52, 107, 51, 52, 52, 53, 50, 106, 53, 53, 325, 51, 62, 311, 106, 49, 110, 64, 62, 64, 50, 64, 65, 46, 46, 75, 62, 108, 75, 75, 51, 65, 65, 52, 103, 106, 111, 103, 65, 112, 62, 53, 106, 52, 110, 64, 62, 64, 53, 64, 65, 69, 69, 69, 69, 69, 69, 69, 290, 65, 65, 52, 103, 282, 111, 103, 65, 112, 75, 53, 56, 56, 56, 113, 133, 273, 56, 56, 271, 266, 134, 136, 56, 137, 56, 139, 56, 56, 56, 56, 56, 73, 73, 73, 73, 73, 73, 73, 56, 56, 56, 113, 133, 74, 56, 56, 74, 74, 134, 136, 56, 137, 56, 139, 56, 56, 56, 56, 56, 71, 263, 262, 71, 71, 256, 71, 71, 71, 71, 71, 71, 71, 72, 255, 233, 72, 72, 74, 72, 72, 72, 72, 72, 72, 72, 76, 74, 77, 76, 76, 77, 77, 78, 199, 195, 78, 78, 79, 140, 141, 79, 79, 71, 80, 142, 74, 80, 80, 143, 81, 80, 187, 81, 81, 186, 72, 153, 149, 145, 99, 82, 76, 78, 82, 82, 144, 140, 141, 76, 81, 77, 79, 142, 54, 83, 78, 143, 83, 83, 84, 79, 87, 84, 84, 87, 87, 80, 82, 29, 76, 78, 26, 81, 144, 21, 146, 10, 81, 89, 79, 83, 89, 89, 82, 9, 3, 88, 2, 90, 88, 88, 90, 90, 0, 0, 82, 92, 83, 0, 92, 92, 0, 84, 146, 87, 0, 89, 90, 83, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 0, 91, 89, 88, 91, 91, 147, 85, 85, 85, 88, 0, 90, 109, 92, 89, 90, 135, 138, 93, 92, 91, 93, 93, 148, 135, 150, 138, 109, 138, 151, 88, 152, 155, 147, 154, 85, 85, 174, 93, 0, 109, 92, 0, 91, 135, 138, 132, 175, 91, 132, 132, 148, 135, 150, 138, 109, 138, 151, 0, 152, 155, 93, 0, 0, 154, 174, 93, 114, 114, 114, 114, 114, 114, 114, 115, 175, 0, 115, 115, 0, 115, 115, 115, 115, 115, 115, 115, 116, 176, 132, 116, 116, 154, 116, 116, 116, 116, 116, 116, 116, 117, 0, 0, 117, 117, 0, 117, 117, 117, 117, 117, 117, 117, 0, 177, 0, 176, 115, 118, 118, 118, 118, 118, 118, 118, 119, 0, 0, 119, 119, 116, 120, 178, 121, 120, 120, 121, 121, 0, 180, 0, 122, 177, 117, 122, 122, 0, 123, 0, 119, 123, 123, 124, 120, 126, 124, 124, 126, 126, 181, 178, 122, 0, 123, 182, 183, 121, 180, 119, 125, 0, 0, 125, 125, 120, 124, 121, 119, 126, 0, 184, 120, 127, 0, 122, 127, 127, 181, 0, 122, 123, 123, 182, 183, 121, 124, 128, 126, 129, 128, 128, 129, 129, 124, 0, 125, 126, 130, 184, 127, 130, 130, 125, 0, 131, 0, 158, 131, 131, 158, 158, 0, 0, 161, 185, 127, 161, 161, 129, 0, 188, 0, 128, 125, 131, 189, 190, 127, 0, 128, 0, 129, 130, 156, 156, 156, 156, 156, 156, 156, 130, 160, 185, 0, 160, 160, 129, 131, 188, 158, 128, 0, 131, 189, 190, 157, 161, 0, 157, 157, 130, 157, 157, 157, 157, 157, 157, 157, 159, 159, 159, 159, 159, 159, 159, 160, 162, 0, 163, 162, 162, 163, 163, 164, 160, 165, 164, 164, 165, 165, 0, 0, 166, 0, 165, 166, 166, 165, 157, 0, 0, 167, 0, 160, 167, 167, 0, 168, 0, 169, 168, 168, 169, 169, 170, 191, 0, 170, 170, 162, 167, 163, 0, 192, 0, 169, 164, 171, 165, 172, 171, 171, 172, 172, 173, 166, 168, 173, 173, 0, 193, 194, 0, 191, 167, 196, 198, 170, 167, 0, 168, 192, 169, 169, 200, 171, 197, 170, 207, 197, 0, 207, 207, 0, 168, 0, 207, 173, 193, 194, 171, 0, 172, 196, 198, 170, 0, 173, 0, 0, 0, 0, 200, 171, 197, 0, 215, 197, 201, 201, 201, 201, 201, 201, 201, 173, 202, 0, 0, 202, 202, 207, 202, 202, 202, 202, 202, 202, 202, 203, 216, 0, 203, 203, 215, 203, 203, 203, 203, 203, 203, 203, 205, 0, 206, 205, 205, 206, 206, 0, 0, 208, 0, 206, 208, 208, 206, 0, 216, 202, 209, 208, 0, 209, 209, 217, 210, 218, 219, 210, 210, 211, 203, 220, 211, 211, 222, 205, 212, 223, 209, 212, 212, 224, 225, 205, 213, 206, 214, 213, 213, 214, 214, 217, 208, 218, 219, 226, 227, 228, 210, 220, 229, 209, 222, 205, 230, 223, 209, 210, 231, 224, 225, 232, 211, 234, 235, 236, 237, 238, 239, 212, 214, 240, 241, 226, 227, 228, 210, 213, 229, 214, 242, 243, 230, 0, 246, 0, 231, 246, 246, 232, 0, 234, 235, 236, 237, 238, 239, 0, 214, 240, 241, 247, 0, 257, 247, 247, 0, 245, 242, 243, 245, 245, 0, 245, 245, 245, 245, 245, 245, 245, 248, 247, 249, 248, 248, 249, 249, 246, 248, 258, 250, 257, 249, 250, 250, 251, 259, 252, 251, 251, 252, 252, 253, 260, 247, 253, 253, 261, 254, 247, 245, 254, 254, 264, 265, 267, 269, 258, 268, 270, 272, 274, 276, 248, 259, 249, 268, 277, 278, 279, 280, 260, 281, 250, 0, 261, 287, 0, 251, 0, 252, 264, 265, 267, 269, 253, 268, 270, 272, 274, 276, 254, 288, 289, 268, 277, 278, 279, 280, 283, 281, 291, 283, 283, 287, 283, 283, 283, 283, 283, 283, 283, 284, 0, 285, 284, 284, 285, 285, 286, 288, 289, 286, 286, 292, 293, 294, 0, 295, 291, 296, 298, 299, 300, 0, 301, 302, 303, 304, 305, 307, 284, 283, 308, 308, 310, 312, 313, 315, 316, 0, 319, 292, 293, 294, 284, 295, 285, 296, 298, 299, 300, 286, 301, 302, 303, 304, 305, 307, 284, 320, 308, 308, 310, 312, 313, 315, 316, 317, 319, 318, 317, 317, 318, 318, 321, 322, 0, 323, 324, 326, 327, 328, 0, 329, 0, 330, 333, 320, 334, 335, 336, 337, 338, 339, 340, 341, 343, 346, 344, 345, 346, 346, 321, 322, 318, 323, 324, 326, 327, 328, 317, 329, 318, 330, 333, 347, 334, 335, 336, 337, 338, 339, 340, 341, 343, 342, 344, 345, 348, 350, 351, 353, 318, 342, 354, 355, 358, 362, 363, 364, 346, 365, 366, 347, 367, 368, 369, 370, 371, 372, 374, 375, 376, 342, 377, 378, 348, 350, 351, 353, 379, 342, 354, 355, 358, 362, 363, 364, 380, 365, 366, 381, 367, 368, 369, 370, 371, 372, 374, 375, 376, 382, 377, 378, 383, 385, 386, 387, 379, 388, 389, 390, 391, 392, 393, 395, 380, 396, 397, 381, 398, 400, 401, 402, 403, 404, 405, 406, 407, 382, 408, 409, 383, 385, 386, 387, 410, 388, 389, 390, 391, 392, 393, 395, 411, 396, 397, 413, 398, 400, 401, 402, 403, 404, 405, 406, 407, 414, 408, 409, 419, 420, 422, 423, 410, 424, 425, 427, 428, 429, 430, 431, 411, 433, 435, 413, 436, 438, 439, 440, 442, 443, 444, 445, 447, 414, 448, 449, 419, 420, 422, 423, 450, 424, 425, 427, 428, 429, 430, 431, 451, 433, 435, 453, 436, 438, 439, 440, 442, 443, 444, 445, 447, 456, 448, 449, 457, 459, 460, 462, 450, 463, 464, 465, 466, 467, 468, 469, 451, 471, 472, 453, 477, 478, 480, 481, 482, 483, 484, 485, 487, 456, 488, 491, 457, 459, 460, 462, 492, 463, 464, 465, 466, 467, 468, 469, 493, 471, 472, 496, 477, 478, 480, 481, 482, 483, 484, 485, 487, 497, 488, 491, 499, 501, 504, 507, 492, 508, 512, 513, 514, 515, 516, 0, 493, 0, 0, 496, 0, 0, 0, 0, 0, 0, 0, 0, 0, 497, 0, 0, 499, 501, 504, 507, 0, 508, 512, 513, 514, 515, 516, 521, 521, 523, 523, 525, 525, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520 } ; static yyconst flex_int16_t yy_rule_linenum[65] = { 0, 98, 100, 102, 104, 106, 109, 113, 115, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 146, 147, 149, 151, 152, 153, 154, 155, 156, 158, 159, 162, 167, 168, 169, 171, 172, 173, 174, 175, 176, 177, 178, 179, 181, 190, 208, 215 } ; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET #line 1 "libmemcached/csl/scanner.l" /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached 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. * */ #line 59 "libmemcached/csl/scanner.l" #include #include #define PARAM config_get_extra(yyscanner) #define get_lex_chars(buffer, result, max_size, context) \ { \ if (context->pos >= context->length) \ { \ result= YY_NULL; \ } \ else \ { \ result= (int)(context->length - context->pos); \ (size_t)result > (size_t)max_size ? result= max_size : 0; \ memcpy(buffer, context->buf + context->pos, result); \ context->pos += result; \ } \ } #define YY_INPUT(buffer, result, max_size) get_lex_chars(buffer, result, max_size, PARAM) #line 1174 "libmemcached/csl/scanner.cc" #define INITIAL 0 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ /* %if-c-only */ #include /* %endif */ /* %if-c++-only */ /* %endif */ #endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif /* %if-c-only Reentrant structure and macros (non-C++). */ /* %if-reentrant */ /* Holds the entire state of the reentrant scanner. */ struct yyguts_t { /* User-defined. Not touched by flex. */ YY_EXTRA_TYPE yyextra_r; /* The rest are the same as the globals declared in the non-reentrant scanner. */ FILE *yyin_r, *yyout_r; size_t yy_buffer_stack_top; /**< index of top of stack. */ size_t yy_buffer_stack_max; /**< capacity of stack. */ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ char yy_hold_char; int yy_n_chars; int yyleng_r; char *yy_c_buf_p; int yy_init; int yy_start; int yy_did_buffer_switch_on_eof; int yy_start_stack_ptr; int yy_start_stack_depth; int *yy_start_stack; yy_state_type yy_last_accepting_state; char* yy_last_accepting_cpos; int yylineno_r; int yy_flex_debug_r; char *yytext_r; int yy_more_flag; int yy_more_len; YYSTYPE * yylval_r; }; /* end struct yyguts_t */ /* %if-c-only */ static int yy_init_globals (yyscan_t yyscanner ); /* %endif */ /* %if-reentrant */ /* This must go here because YYSTYPE and YYLTYPE are included * from bison output in section 1.*/ # define yylval yyg->yylval_r int config_lex_init (yyscan_t* scanner); int config_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); /* %endif */ /* %endif End reentrant structures and macros. */ /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ int config_lex_destroy (yyscan_t yyscanner ); int config_get_debug (yyscan_t yyscanner ); void config_set_debug (int debug_flag ,yyscan_t yyscanner ); YY_EXTRA_TYPE config_get_extra (yyscan_t yyscanner ); void config_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); FILE *config_get_in (yyscan_t yyscanner ); void config_set_in (FILE * in_str ,yyscan_t yyscanner ); FILE *config_get_out (yyscan_t yyscanner ); void config_set_out (FILE * out_str ,yyscan_t yyscanner ); int config_get_leng (yyscan_t yyscanner ); char *config_get_text (yyscan_t yyscanner ); int config_get_lineno (yyscan_t yyscanner ); void config_set_lineno (int line_number ,yyscan_t yyscanner ); int config_get_column (yyscan_t yyscanner ); void config_set_column (int column_no ,yyscan_t yyscanner ); /* %if-bison-bridge */ YYSTYPE * config_get_lval (yyscan_t yyscanner ); void config_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); /* %endif */ /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus extern "C" int config_wrap (yyscan_t yyscanner ); #else extern int config_wrap (yyscan_t yyscanner ); #endif #endif /* %not-for-header */ /* %ok-for-header */ /* %endif */ #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT /* %if-c-only Standard (non-C++) definition */ /* %not-for-header */ #ifdef __cplusplus static int yyinput (yyscan_t yyscanner ); #else static int input (yyscan_t yyscanner ); #endif /* %ok-for-header */ /* %endif */ #endif /* %if-c-only */ /* %endif */ /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #define YY_READ_BUF_SIZE 8192 #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO /* %if-c-only Standard (non-C++) definition */ /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) /* %endif */ /* %if-c++-only C++ definition */ /* %endif */ #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ /* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ unsigned n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ break; \ } \ errno=0; \ clearerr(yyin); \ } \ }\ \ /* %if-c++-only C++ definition \ */\ /* %endif */ #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR /* %if-c-only */ #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) /* %endif */ /* %if-c++-only */ /* %endif */ #endif /* %if-tables-serialization structures and prototypes */ /* %not-for-header */ /* %ok-for-header */ /* %not-for-header */ /* %tables-yydmap generated elements */ /* %endif */ /* end tables serialization structures and prototypes */ /* %ok-for-header */ /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 /* %if-c-only Standard (non-C++) definition */ extern int config_lex \ (YYSTYPE * yylval_param ,yyscan_t yyscanner); #define YY_DECL int config_lex \ (YYSTYPE * yylval_param , yyscan_t yyscanner) /* %endif */ /* %if-c++-only C++ definition */ /* %endif */ #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK break; #endif /* %% [6.0] YY_RULE_SETUP definition goes here */ #define YY_RULE_SETUP \ if ( yyleng > 0 ) \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ (yytext[yyleng - 1] == '\n'); \ YY_USER_ACTION /* %not-for-header */ /** The main scanner function which does all the work. */ YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* %% [7.0] user's declarations go here */ #line 95 "libmemcached/csl/scanner.l" #line 1481 "libmemcached/csl/scanner.cc" yylval = yylval_param; if ( !yyg->yy_init ) { yyg->yy_init = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif if ( ! yyg->yy_start ) yyg->yy_start = 1; /* first start state */ if ( ! yyin ) /* %if-c-only */ yyin = stdin; /* %endif */ /* %if-c++-only */ /* %endif */ if ( ! yyout ) /* %if-c-only */ yyout = stdout; /* %endif */ /* %if-c++-only */ /* %endif */ if ( ! YY_CURRENT_BUFFER ) { config_ensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = config__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); } config__load_buffer_state(yyscanner ); } while ( 1 ) /* loops until end-of-file is reached */ { /* %% [8.0] yymore()-related code goes here */ yy_cp = yyg->yy_c_buf_p; /* Support of yytext. */ *yy_cp = yyg->yy_hold_char; /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; /* %% [9.0] code to set up and find next match goes here */ yy_current_state = yyg->yy_start; yy_current_state += YY_AT_BOL(); yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 521 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 1711 ); yy_find_action: /* %% [10.0] code to find the action number goes here */ yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; /* %% [11.0] code for yylineno update goes here */ do_action: /* This label is used only to access EOF actions. */ /* %% [12.0] debug code goes here */ if ( yy_flex_debug ) { if ( yy_act == 0 ) fprintf( stderr, "--scanner backing up\n" ); else if ( yy_act < 65 ) fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", (long)yy_rule_linenum[yy_act], yytext ); else if ( yy_act == 65 ) fprintf( stderr, "--accepting default rule (\"%s\")\n", yytext ); else if ( yy_act == 66 ) fprintf( stderr, "--(end of buffer or a NUL)\n" ); else fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); } switch ( yy_act ) { /* beginning of action switch */ /* %% [13.0] actions go here */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = yyg->yy_hold_char; yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; goto yy_find_action; case 1: YY_RULE_SETUP #line 98 "libmemcached/csl/scanner.l" { return yytext[0];} YY_BREAK case 2: YY_RULE_SETUP #line 100 "libmemcached/csl/scanner.l" { yylval->number= atoi(yytext); return (NUMBER); } YY_BREAK case 3: YY_RULE_SETUP #line 102 "libmemcached/csl/scanner.l" { yylval->number= atoi(yytext +1); return PORT; } YY_BREAK case 4: YY_RULE_SETUP #line 104 "libmemcached/csl/scanner.l" { yylval->number= atoi(yytext +2); return WEIGHT_START; } YY_BREAK case 5: /* rule 5 can match eol */ YY_RULE_SETUP #line 106 "libmemcached/csl/scanner.l" ; /* skip whitespace */ YY_BREAK case 6: *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP #line 109 "libmemcached/csl/scanner.l" { return COMMENT; } YY_BREAK case 7: YY_RULE_SETUP #line 113 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; yyextra->set_server(); return yyextra->previous_token= SERVER; } YY_BREAK case 8: YY_RULE_SETUP #line 115 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET; } YY_BREAK case 9: YY_RULE_SETUP #line 117 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= BINARY_PROTOCOL; } YY_BREAK case 10: YY_RULE_SETUP #line 118 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= BUFFER_REQUESTS; } YY_BREAK case 11: YY_RULE_SETUP #line 119 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= CONFIGURE_FILE; } YY_BREAK case 12: YY_RULE_SETUP #line 120 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= CONNECT_TIMEOUT; } YY_BREAK case 13: YY_RULE_SETUP #line 121 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= DISTRIBUTION; } YY_BREAK case 14: YY_RULE_SETUP #line 122 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= HASH_WITH_NAMESPACE; } YY_BREAK case 15: YY_RULE_SETUP #line 123 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= HASH; } YY_BREAK case 16: YY_RULE_SETUP #line 124 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= IO_BYTES_WATERMARK; } YY_BREAK case 17: YY_RULE_SETUP #line 125 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= IO_KEY_PREFETCH; } YY_BREAK case 18: YY_RULE_SETUP #line 126 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= IO_MSG_WATERMARK; } YY_BREAK case 19: YY_RULE_SETUP #line 127 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= NOREPLY; } YY_BREAK case 20: YY_RULE_SETUP #line 128 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= NUMBER_OF_REPLICAS; } YY_BREAK case 21: YY_RULE_SETUP #line 129 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= POLL_TIMEOUT; } YY_BREAK case 22: YY_RULE_SETUP #line 130 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= RANDOMIZE_REPLICA_READ; } YY_BREAK case 23: YY_RULE_SETUP #line 131 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= RCV_TIMEOUT; } YY_BREAK case 24: YY_RULE_SETUP #line 132 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= REMOVE_FAILED_SERVERS; } YY_BREAK case 25: YY_RULE_SETUP #line 133 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= RETRY_TIMEOUT; } YY_BREAK case 26: YY_RULE_SETUP #line 134 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SND_TIMEOUT; } YY_BREAK case 27: YY_RULE_SETUP #line 135 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET_RECV_SIZE; } YY_BREAK case 28: YY_RULE_SETUP #line 136 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET_SEND_SIZE; } YY_BREAK case 29: YY_RULE_SETUP #line 137 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SORT_HOSTS; } YY_BREAK case 30: YY_RULE_SETUP #line 138 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SUPPORT_CAS; } YY_BREAK case 31: YY_RULE_SETUP #line 139 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPALIVE; } YY_BREAK case 32: YY_RULE_SETUP #line 140 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPIDLE; } YY_BREAK case 33: YY_RULE_SETUP #line 141 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_NODELAY; } YY_BREAK case 34: YY_RULE_SETUP #line 142 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= USE_UDP; } YY_BREAK case 35: YY_RULE_SETUP #line 143 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= USER_DATA; } YY_BREAK case 36: YY_RULE_SETUP #line 144 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= VERIFY_KEY; } YY_BREAK case 37: YY_RULE_SETUP #line 146 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= POOL_MIN; } YY_BREAK case 38: YY_RULE_SETUP #line 147 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= POOL_MAX; } YY_BREAK case 39: YY_RULE_SETUP #line 149 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= NAMESPACE; } YY_BREAK case 40: YY_RULE_SETUP #line 151 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= INCLUDE; } YY_BREAK case 41: YY_RULE_SETUP #line 152 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= RESET; } YY_BREAK case 42: YY_RULE_SETUP #line 153 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= PARSER_DEBUG; } YY_BREAK case 43: YY_RULE_SETUP #line 154 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SERVERS; } YY_BREAK case 44: YY_RULE_SETUP #line 155 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= END; } YY_BREAK case 45: YY_RULE_SETUP #line 156 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= ERROR; } YY_BREAK case 46: YY_RULE_SETUP #line 158 "libmemcached/csl/scanner.l" { return yyextra->previous_token= TRUE; } YY_BREAK case 47: YY_RULE_SETUP #line 159 "libmemcached/csl/scanner.l" { return yyextra->previous_token= FALSE; } YY_BREAK case 48: YY_RULE_SETUP #line 162 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return UNKNOWN_OPTION; } YY_BREAK case 49: YY_RULE_SETUP #line 167 "libmemcached/csl/scanner.l" { return CONSISTENT; } YY_BREAK case 50: YY_RULE_SETUP #line 168 "libmemcached/csl/scanner.l" { return MODULA; } YY_BREAK case 51: YY_RULE_SETUP #line 169 "libmemcached/csl/scanner.l" { return RANDOM; } YY_BREAK case 52: YY_RULE_SETUP #line 171 "libmemcached/csl/scanner.l" { return MD5; } YY_BREAK case 53: YY_RULE_SETUP #line 172 "libmemcached/csl/scanner.l" { return CRC; } YY_BREAK case 54: YY_RULE_SETUP #line 173 "libmemcached/csl/scanner.l" { return FNV1_64; } YY_BREAK case 55: YY_RULE_SETUP #line 174 "libmemcached/csl/scanner.l" { return FNV1A_64; } YY_BREAK case 56: YY_RULE_SETUP #line 175 "libmemcached/csl/scanner.l" { return FNV1_32; } YY_BREAK case 57: YY_RULE_SETUP #line 176 "libmemcached/csl/scanner.l" { return FNV1A_32; } YY_BREAK case 58: YY_RULE_SETUP #line 177 "libmemcached/csl/scanner.l" { return HSIEH; } YY_BREAK case 59: YY_RULE_SETUP #line 178 "libmemcached/csl/scanner.l" { return MURMUR; } YY_BREAK case 60: YY_RULE_SETUP #line 179 "libmemcached/csl/scanner.l" { return JENKINS; } YY_BREAK case 61: YY_RULE_SETUP #line 181 "libmemcached/csl/scanner.l" { yylval->server.port= MEMCACHED_DEFAULT_PORT; yylval->server.weight= 1; yylval->server.c_str= yyextra->set_hostname(yytext, yyleng); if (yylval->server.c_str) yylval->server.size= yyleng; return IPADDRESS; } YY_BREAK case 62: YY_RULE_SETUP #line 190 "libmemcached/csl/scanner.l" { if (yyextra->is_server()) { yylval->server.port= MEMCACHED_DEFAULT_PORT; yylval->server.weight= 1; yylval->server.c_str= yyextra->set_hostname(yytext, yyleng); if (yylval->server.c_str) yylval->server.size= yyleng; return HOSTNAME; } yylval->string.c_str = yytext; yylval->string.size = yyleng; return STRING; } YY_BREAK case 63: /* rule 63 can match eol */ YY_RULE_SETUP #line 208 "libmemcached/csl/scanner.l" { config_get_text(yyscanner)[yyleng -1]= 0; yylval->string.c_str= yytext +1; yylval->string.size= yyleng -2; return QUOTED_STRING; } YY_BREAK case 64: YY_RULE_SETUP #line 215 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return UNKNOWN; } YY_BREAK case 65: YY_RULE_SETUP #line 220 "libmemcached/csl/scanner.l" ECHO; YY_BREAK #line 1964 "libmemcached/csl/scanner.cc" case YY_STATE_EOF(INITIAL): yyterminate(); case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = yyg->yy_hold_char; YY_RESTORE_YY_MORE_OFFSET if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * config_lex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) { /* This was really a NUL. */ yy_state_type yy_next_state; yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( yyscanner ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++yyg->yy_c_buf_p; yy_current_state = yy_next_state; goto yy_match; } else { /* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */ yy_cp = yyg->yy_c_buf_p; goto yy_find_action; } } else switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_END_OF_FILE: { yyg->yy_did_buffer_switch_on_eof = 0; if ( config_wrap(yyscanner ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! yyg->yy_did_buffer_switch_on_eof ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( yyscanner ); yy_cp = yyg->yy_c_buf_p; yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: yyg->yy_c_buf_p = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; yy_current_state = yy_get_previous_state( yyscanner ); yy_cp = yyg->yy_c_buf_p; yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of config_lex */ /* %ok-for-header */ /* %if-c++-only */ /* %not-for-header */ /* %ok-for-header */ /* %endif */ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ /* %if-c-only */ static int yy_get_next_buffer (yyscan_t yyscanner) /* %endif */ /* %if-c++-only */ /* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; register char *source = yyg->yytext_ptr; register int number_to_move, i; int ret_val; if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; else { int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = YY_CURRENT_BUFFER; int yy_c_buf_p_offset = (int) (yyg->yy_c_buf_p - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; else b->yy_buf_size *= 2; b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ config_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); } else /* Can't grow it, we don't own it. */ b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), yyg->yy_n_chars, (size_t) num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } if ( yyg->yy_n_chars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; config_restart(yyin ,yyscanner); } else { ret_val = EOB_ACT_LAST_MATCH; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) config_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); } yyg->yy_n_chars += number_to_move; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ /* %if-c-only */ /* %not-for-header */ static yy_state_type yy_get_previous_state (yyscan_t yyscanner) /* %endif */ /* %if-c++-only */ /* %endif */ { register yy_state_type yy_current_state; register char *yy_cp; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* %% [15.0] code to get the start state into yy_current_state goes here */ yy_current_state = yyg->yy_start; yy_current_state += YY_AT_BOL(); for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { /* %% [16.0] code to find the next state goes here */ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 521 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ /* %if-c-only */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) /* %endif */ /* %if-c++-only */ /* %endif */ { register int yy_is_jam; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */ register char *yy_cp = yyg->yy_c_buf_p; register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 521 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 520); return yy_is_jam ? 0 : yy_current_state; } /* %if-c-only */ /* %endif */ /* %if-c-only */ #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (yyscan_t yyscanner) #else static int input (yyscan_t yyscanner) #endif /* %endif */ /* %if-c++-only */ /* %endif */ { int c; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; *yyg->yy_c_buf_p = yyg->yy_hold_char; if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) /* This was really a NUL. */ *yyg->yy_c_buf_p = '\0'; else { /* need more input */ int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; ++yyg->yy_c_buf_p; switch ( yy_get_next_buffer( yyscanner ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ config_restart(yyin ,yyscanner); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { if ( config_wrap(yyscanner ) ) return EOF; if ( ! yyg->yy_did_buffer_switch_on_eof ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(yyscanner); #else return input(yyscanner); #endif } case EOB_ACT_CONTINUE_SCAN: yyg->yy_c_buf_p = yyg->yytext_ptr + offset; break; } } } c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ yyg->yy_hold_char = *++yyg->yy_c_buf_p; /* %% [19.0] update BOL and yylineno */ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); return c; } /* %if-c-only */ #endif /* ifndef YY_NO_INPUT */ /* %endif */ /** Immediately switch to a different input stream. * @param input_file A readable stream. * @param yyscanner The scanner object. * @note This function does not reset the start condition to @c INITIAL . */ /* %if-c-only */ void config_restart (FILE * input_file , yyscan_t yyscanner) /* %endif */ /* %if-c++-only */ /* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! YY_CURRENT_BUFFER ){ config_ensure_buffer_stack (yyscanner); YY_CURRENT_BUFFER_LVALUE = config__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); } config__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); config__load_buffer_state(yyscanner ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * @param yyscanner The scanner object. */ /* %if-c-only */ void config__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) /* %endif */ /* %if-c++-only */ /* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* TODO. We should be able to replace this entire function body * with * config_pop_buffer_state(); * config_push_buffer_state(new_buffer); */ config_ensure_buffer_stack (yyscanner); if ( YY_CURRENT_BUFFER == new_buffer ) return; if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *yyg->yy_c_buf_p = yyg->yy_hold_char; YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } YY_CURRENT_BUFFER_LVALUE = new_buffer; config__load_buffer_state(yyscanner ); /* We don't actually know whether we did this switch during * EOF (config_wrap()) processing, but the only time this flag * is looked at is after config_wrap() is called, so it's safe * to go ahead and always set it. */ yyg->yy_did_buffer_switch_on_eof = 1; } /* %if-c-only */ static void config__load_buffer_state (yyscan_t yyscanner) /* %endif */ /* %if-c++-only */ /* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; yyg->yy_hold_char = *yyg->yy_c_buf_p; } /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. * @param yyscanner The scanner object. * @return the allocated buffer state. */ /* %if-c-only */ YY_BUFFER_STATE config__create_buffer (FILE * file, int size , yyscan_t yyscanner) /* %endif */ /* %if-c++-only */ /* %endif */ { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) config_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in config__create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) config_alloc(b->yy_buf_size + 2 ,yyscanner ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in config__create_buffer()" ); b->yy_is_our_buffer = 1; config__init_buffer(b,file ,yyscanner); return b; } /** Destroy the buffer. * @param b a buffer created with config__create_buffer() * @param yyscanner The scanner object. */ /* %if-c-only */ void config__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) /* %endif */ /* %if-c++-only */ /* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! b ) return; if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) config_free((void *) b->yy_ch_buf ,yyscanner ); config_free((void *) b ,yyscanner ); } /* %if-c-only */ #ifndef __cplusplus extern int isatty (int ); #endif /* __cplusplus */ /* %endif */ /* %if-c++-only */ /* %endif */ /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a config_restart() or at EOF. */ /* %if-c-only */ static void config__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) /* %endif */ /* %if-c++-only */ /* %endif */ { int oerrno = errno; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; config__flush_buffer(b ,yyscanner); b->yy_input_file = file; b->yy_fill_buffer = 1; /* If b is the current buffer, then config__init_buffer was _probably_ * called from config_restart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ b->yy_bs_lineno = 1; b->yy_bs_column = 0; } /* %if-c-only */ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; /* %endif */ /* %if-c++-only */ /* %endif */ errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * @param yyscanner The scanner object. */ /* %if-c-only */ void config__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) /* %endif */ /* %if-c++-only */ /* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) config__load_buffer_state(yyscanner ); } /* %if-c-or-c++ */ /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. * @param yyscanner The scanner object. */ /* %if-c-only */ void config_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) /* %endif */ /* %if-c++-only */ /* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (new_buffer == NULL) return; config_ensure_buffer_stack(yyscanner); /* This block is copied from config__switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *yyg->yy_c_buf_p = yyg->yy_hold_char; YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } /* Only push if top exists. Otherwise, replace top. */ if (YY_CURRENT_BUFFER) yyg->yy_buffer_stack_top++; YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from config__switch_to_buffer. */ config__load_buffer_state(yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } /* %endif */ /* %if-c-or-c++ */ /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * @param yyscanner The scanner object. */ /* %if-c-only */ void config_pop_buffer_state (yyscan_t yyscanner) /* %endif */ /* %if-c++-only */ /* %endif */ { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!YY_CURRENT_BUFFER) return; config__delete_buffer(YY_CURRENT_BUFFER ,yyscanner); YY_CURRENT_BUFFER_LVALUE = NULL; if (yyg->yy_buffer_stack_top > 0) --yyg->yy_buffer_stack_top; if (YY_CURRENT_BUFFER) { config__load_buffer_state(yyscanner ); yyg->yy_did_buffer_switch_on_eof = 1; } } /* %endif */ /* %if-c-or-c++ */ /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ /* %if-c-only */ static void config_ensure_buffer_stack (yyscan_t yyscanner) /* %endif */ /* %if-c++-only */ /* %endif */ { int num_to_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!yyg->yy_buffer_stack) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ num_to_alloc = 1; yyg->yy_buffer_stack = (struct yy_buffer_state**)config_alloc (num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in config_ensure_buffer_stack()" ); memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); yyg->yy_buffer_stack_max = num_to_alloc; yyg->yy_buffer_stack_top = 0; return; } if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; num_to_alloc = yyg->yy_buffer_stack_max + grow_size; yyg->yy_buffer_stack = (struct yy_buffer_state**)config_realloc (yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in config_ensure_buffer_stack()" ); /* zero only the new slots.*/ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); yyg->yy_buffer_stack_max = num_to_alloc; } } /* %endif */ /* %if-c-only */ /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ YY_BUFFER_STATE config__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; b = (YY_BUFFER_STATE) config_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in config__scan_buffer()" ); b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = 0; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; config__switch_to_buffer(b ,yyscanner ); return b; } /* %endif */ /* %if-c-only */ /** Setup the input buffer state to scan a string. The next call to config_lex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * @param yyscanner The scanner object. * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * config__scan_bytes() instead. */ YY_BUFFER_STATE config__scan_string (yyconst char * yystr , yyscan_t yyscanner) { return config__scan_bytes(yystr,strlen(yystr) ,yyscanner); } /* %endif */ /* %if-c-only */ /** Setup the input buffer state to scan the given bytes. The next call to config_lex() will * scan from a @e copy of @a bytes. * @param bytes the byte buffer to scan * @param len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ YY_BUFFER_STATE config__scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; yy_size_t n; int i; /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) config_alloc(n ,yyscanner ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in config__scan_bytes()" ); for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; b = config__scan_buffer(buf,n ,yyscanner); if ( ! b ) YY_FATAL_ERROR( "bad buffer in config__scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ b->yy_is_our_buffer = 1; return b; } /* %endif */ #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif /* %if-c-only */ static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } /* %endif */ /* %if-c++-only */ /* %endif */ /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = yyg->yy_hold_char; \ yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ yyg->yy_hold_char = *yyg->yy_c_buf_p; \ *yyg->yy_c_buf_p = '\0'; \ yyleng = yyless_macro_arg; \ } \ while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ /* %if-c-only */ /* %if-reentrant */ /** Get the user-defined data for this scanner. * @param yyscanner The scanner object. */ YY_EXTRA_TYPE config_get_extra (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyextra; } /* %endif */ /** Get the current line number. * @param yyscanner The scanner object. */ int config_get_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (! YY_CURRENT_BUFFER) return 0; return yylineno; } /** Get the current column number. * @param yyscanner The scanner object. */ int config_get_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (! YY_CURRENT_BUFFER) return 0; return yycolumn; } /** Get the input stream. * @param yyscanner The scanner object. */ FILE *config_get_in (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyin; } /** Get the output stream. * @param yyscanner The scanner object. */ FILE *config_get_out (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyout; } /** Get the length of the current token. * @param yyscanner The scanner object. */ int config_get_leng (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyleng; } /** Get the current token. * @param yyscanner The scanner object. */ char *config_get_text (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yytext; } /* %if-reentrant */ /** Set the user-defined data. This data is never touched by the scanner. * @param user_defined The data to be associated with this scanner. * @param yyscanner The scanner object. */ void config_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyextra = user_defined ; } /* %endif */ /** Set the current line number. * @param line_number * @param yyscanner The scanner object. */ void config_set_lineno (int line_number , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) yy_fatal_error( "config_set_lineno called with no buffer" , yyscanner); yylineno = line_number; } /** Set the current column. * @param line_number * @param yyscanner The scanner object. */ void config_set_column (int column_no , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) yy_fatal_error( "config_set_column called with no buffer" , yyscanner); yycolumn = column_no; } /** Set the input stream. This does not discard the current * input buffer. * @param in_str A readable stream. * @param yyscanner The scanner object. * @see config__switch_to_buffer */ void config_set_in (FILE * in_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyin = in_str ; } void config_set_out (FILE * out_str , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yyout = out_str ; } int config_get_debug (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yy_flex_debug; } void config_set_debug (int bdebug , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_flex_debug = bdebug ; } /* %endif */ /* %if-reentrant */ /* Accessor methods for yylval and yylloc */ /* %if-bison-bridge */ YYSTYPE * config_get_lval (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yylval; } void config_set_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylval = yylval_param; } /* %endif */ /* User-visible API */ /* config_lex_init is special because it creates the scanner itself, so it is * the ONLY reentrant function that doesn't take the scanner as the last argument. * That's why we explicitly handle the declaration, instead of using our macros. */ int config_lex_init(yyscan_t* ptr_yy_globals) { if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } *ptr_yy_globals = (yyscan_t) config_alloc ( sizeof( struct yyguts_t ), NULL ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; return 1; } /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); return yy_init_globals ( *ptr_yy_globals ); } /* config_lex_init_extra has the same functionality as config_lex_init, but follows the * convention of taking the scanner as the last argument. Note however, that * this is a *pointer* to a scanner, as it will be allocated by this call (and * is the reason, too, why this function also must handle its own declaration). * The user defined value in the first argument will be available to config_alloc in * the yyextra field. */ int config_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) { struct yyguts_t dummy_yyguts; config_set_extra (yy_user_defined, &dummy_yyguts); if (ptr_yy_globals == NULL){ errno = EINVAL; return 1; } *ptr_yy_globals = (yyscan_t) config_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); if (*ptr_yy_globals == NULL){ errno = ENOMEM; return 1; } /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); config_set_extra (yy_user_defined, *ptr_yy_globals); return yy_init_globals ( *ptr_yy_globals ); } /* %endif if-c-only */ /* %if-c-only */ static int yy_init_globals (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Initialization is the same as for the non-reentrant scanner. * This function is called from config_lex_destroy(), so don't allocate here. */ yyg->yy_buffer_stack = 0; yyg->yy_buffer_stack_top = 0; yyg->yy_buffer_stack_max = 0; yyg->yy_c_buf_p = (char *) 0; yyg->yy_init = 0; yyg->yy_start = 0; yyg->yy_start_stack_ptr = 0; yyg->yy_start_stack_depth = 0; yyg->yy_start_stack = NULL; /* Defined in main.c */ #ifdef YY_STDINIT yyin = stdin; yyout = stdout; #else yyin = (FILE *) 0; yyout = (FILE *) 0; #endif /* For future reference: Set errno on error, since we are called by * config_lex_init() */ return 0; } /* %endif */ /* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */ /* config_lex_destroy is for both reentrant and non-reentrant scanners. */ int config_lex_destroy (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ config__delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); YY_CURRENT_BUFFER_LVALUE = NULL; config_pop_buffer_state(yyscanner); } /* Destroy the stack itself. */ config_free(yyg->yy_buffer_stack ,yyscanner); yyg->yy_buffer_stack = NULL; /* Destroy the start condition stack. */ config_free(yyg->yy_start_stack ,yyscanner ); yyg->yy_start_stack = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time * config_lex() is called, initialization will occur. */ yy_init_globals( yyscanner); /* %if-reentrant */ /* Destroy the main struct (reentrant only). */ config_free ( yyscanner , yyscanner ); yyscanner = NULL; /* %endif */ return 0; } /* %endif */ /* * Internal utility routines. */ #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif void *config_alloc (yy_size_t size , yyscan_t yyscanner) { return (void *) malloc( size ); } void *config_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); } void config_free (void * ptr , yyscan_t yyscanner) { free( (char *) ptr ); /* see config_realloc() for (char *) cast */ } /* %if-tables-serialization definitions */ /* %define-yytables The name for this specific scanner's tables. */ #define YYTABLES_NAME "yytables" /* %endif */ /* %ok-for-header */ #line 220 "libmemcached/csl/scanner.l" void Context::init_scanner() { config_lex_init(&scanner); config_set_extra(this,scanner); } void Context::destroy_scanner() { config_lex_destroy(scanner); } libmemcached-1.0.8/libmemcached/csl/parser.yy0000664000076400007640000003316011753573717021457 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached 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. * */ %error-verbose %debug %defines %expect 0 %output "libmemcached/csl/parser.cc" %defines "libmemcached/csl/parser.h" %lex-param { yyscan_t *scanner } %name-prefix="config_" %parse-param { Context *context } %parse-param { yyscan_t *scanner } %pure-parser %require "2.4" %start begin %verbose %{ #include #include #include #include #include #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wold-style-cast" #endif int conf_lex(YYSTYPE* lvalp, void* scanner); #define select_yychar(__context) yychar == UNKNOWN ? ( (__context)->previous_token == END ? UNKNOWN : (__context)->previous_token ) : yychar #define stryytname(__yytokentype) ((__yytokentype) < YYNTOKENS ) ? yytname[(__yytokentype)] : "" #define parser_abort(__context, __error_message) do { (__context)->abort((__error_message), yytokentype(select_yychar(__context)), stryytname(YYTRANSLATE(select_yychar(__context)))); YYABORT; } while (0) // This is bison calling error. inline void __config_error(Context *context, yyscan_t *scanner, const char *error, int last_token, const char *last_token_str) { if (not context->end()) { context->error(error, yytokentype(last_token), last_token_str); } else { context->error(error, yytokentype(last_token), last_token_str); } } #define config_error(__context, __scanner, __error_msg) do { __config_error((__context), (__scanner), (__error_msg), select_yychar(__context), stryytname(YYTRANSLATE(select_yychar(__context)))); } while (0) %} %token COMMENT %token END %token ERROR %token RESET %token PARSER_DEBUG %token INCLUDE %token CONFIGURE_FILE %token EMPTY_LINE %token SERVER %token SOCKET %token SERVERS %token SERVERS_OPTION %token UNKNOWN_OPTION %token UNKNOWN /* All behavior options */ %token BINARY_PROTOCOL %token BUFFER_REQUESTS %token CONNECT_TIMEOUT %token DISTRIBUTION %token HASH %token HASH_WITH_NAMESPACE %token IO_BYTES_WATERMARK %token IO_KEY_PREFETCH %token IO_MSG_WATERMARK %token KETAMA_HASH %token KETAMA_WEIGHTED %token NOREPLY %token NUMBER_OF_REPLICAS %token POLL_TIMEOUT %token RANDOMIZE_REPLICA_READ %token RCV_TIMEOUT %token REMOVE_FAILED_SERVERS %token RETRY_TIMEOUT %token SND_TIMEOUT %token SOCKET_RECV_SIZE %token SOCKET_SEND_SIZE %token SORT_HOSTS %token SUPPORT_CAS %token USER_DATA %token USE_UDP %token VERIFY_KEY %token _TCP_KEEPALIVE %token _TCP_KEEPIDLE %token _TCP_NODELAY /* Callbacks */ %token NAMESPACE /* Pool */ %token POOL_MIN %token POOL_MAX /* Hash types */ %token MD5 %token CRC %token FNV1_64 %token FNV1A_64 %token FNV1_32 %token FNV1A_32 %token HSIEH %token MURMUR %token JENKINS /* Distributions */ %token CONSISTENT %token MODULA %token RANDOM /* Boolean values */ %token TRUE %token FALSE %nonassoc ',' %nonassoc '=' %token FLOAT %token NUMBER %token PORT %token WEIGHT_START %token IPADDRESS %token HOSTNAME %token STRING %token QUOTED_STRING %token FILE_PATH %type behavior_boolean %type behavior_number %type distribution %type hash %type optional_port %type optional_weight %type string %% begin: statement | begin ' ' statement ; statement: expression { } | COMMENT { } | EMPTY_LINE { } | END { context->set_end(); YYACCEPT; } | ERROR { context->rc= MEMCACHED_PARSE_USER_ERROR; parser_abort(context, "ERROR called directly"); } | RESET { memcached_reset(context->memc); } | PARSER_DEBUG { yydebug= 1; } | INCLUDE ' ' string { if ((context->rc= memcached_parse_configure_file(*context->memc, $3.c_str, $3.size)) != MEMCACHED_SUCCESS) { parser_abort(context, "Failed to parse configuration file"); } } ; expression: SERVER HOSTNAME optional_port optional_weight { if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $3, $4))) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "Failed to add server: %s:%u", $2.c_str, uint32_t($3)); parser_abort(context, buffer); } context->unset_server(); } | SERVER IPADDRESS optional_port optional_weight { if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $3, $4))) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "Failed to add server: %s:%u", $2.c_str, uint32_t($3)); parser_abort(context, buffer); } context->unset_server(); } | SOCKET string optional_weight { if (memcached_failed(context->rc= memcached_server_add_unix_socket_with_weight(context->memc, $2.c_str, $3))) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "Failed to add server: %s", $2.c_str); parser_abort(context, buffer); } } | CONFIGURE_FILE string { memcached_set_configuration_file(context->memc, $2.c_str, $2.size); } | POOL_MIN NUMBER { context->memc->configure.initial_pool_size= $2; } | POOL_MAX NUMBER { context->memc->configure.max_pool_size= $2; } | behaviors ; behaviors: NAMESPACE string { if (memcached_callback_get(context->memc, MEMCACHED_CALLBACK_PREFIX_KEY, NULL)) { parser_abort(context, "--NAMESPACE can only be called once"); } if ((context->rc= memcached_set_namespace(context->memc, $2.c_str, $2.size)) != MEMCACHED_SUCCESS) { parser_abort(context, memcached_last_error_message(context->memc)); } } | DISTRIBUTION distribution { // Check to see if DISTRIBUTION has already been set if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, $2)) != MEMCACHED_SUCCESS) { parser_abort(context, "--DISTRIBUTION can only be called once"); } if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, $2)) != MEMCACHED_SUCCESS) { parser_abort(context, memcached_last_error_message(context->memc));; } } | DISTRIBUTION distribution ',' hash { // Check to see if DISTRIBUTION has already been set if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, $2)) != MEMCACHED_SUCCESS) { parser_abort(context, "--DISTRIBUTION can only be called once"); } if ((context->rc= memcached_behavior_set_distribution_hash(context->memc, $4)) != MEMCACHED_SUCCESS) { parser_abort(context, "Unable to set the hash for the DISTRIBUTION requested"); } } | HASH hash { if (context->set_hash($2) == false) { parser_abort(context, "--HASH can only be set once"); } } | behavior_number NUMBER { if ((context->rc= memcached_behavior_set(context->memc, $1, $2)) != MEMCACHED_SUCCESS) { parser_abort(context, "Unable to set behavior"); } } | behavior_boolean { if ((context->rc= memcached_behavior_set(context->memc, $1, true)) != MEMCACHED_SUCCESS) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "Could not set: %s", libmemcached_string_behavior($1)); parser_abort(context, buffer); } } | USER_DATA { } ; behavior_number: REMOVE_FAILED_SERVERS { $$= MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS; } | CONNECT_TIMEOUT { $$= MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT; } | IO_MSG_WATERMARK { $$= MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK; } | IO_BYTES_WATERMARK { $$= MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK; } | IO_KEY_PREFETCH { $$= MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH; } | NUMBER_OF_REPLICAS { $$= MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS; } | POLL_TIMEOUT { $$= MEMCACHED_BEHAVIOR_POLL_TIMEOUT; } | RCV_TIMEOUT { $$= MEMCACHED_BEHAVIOR_RCV_TIMEOUT; } | RETRY_TIMEOUT { $$= MEMCACHED_BEHAVIOR_RETRY_TIMEOUT; } | SND_TIMEOUT { $$= MEMCACHED_BEHAVIOR_SND_TIMEOUT; } | SOCKET_RECV_SIZE { $$= MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE; } | SOCKET_SEND_SIZE { $$= MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE; } ; behavior_boolean: BINARY_PROTOCOL { $$= MEMCACHED_BEHAVIOR_BINARY_PROTOCOL; } | BUFFER_REQUESTS { $$= MEMCACHED_BEHAVIOR_BUFFER_REQUESTS; } | HASH_WITH_NAMESPACE { $$= MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY; } | NOREPLY { $$= MEMCACHED_BEHAVIOR_NOREPLY; } | RANDOMIZE_REPLICA_READ { $$= MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ; } | SORT_HOSTS { $$= MEMCACHED_BEHAVIOR_SORT_HOSTS; } | SUPPORT_CAS { $$= MEMCACHED_BEHAVIOR_SUPPORT_CAS; } | _TCP_NODELAY { $$= MEMCACHED_BEHAVIOR_TCP_NODELAY; } | _TCP_KEEPALIVE { $$= MEMCACHED_BEHAVIOR_TCP_KEEPALIVE; } | _TCP_KEEPIDLE { $$= MEMCACHED_BEHAVIOR_TCP_KEEPIDLE; } | USE_UDP { $$= MEMCACHED_BEHAVIOR_USE_UDP; } | VERIFY_KEY { $$= MEMCACHED_BEHAVIOR_VERIFY_KEY; } optional_port: { $$= MEMCACHED_DEFAULT_PORT;} | PORT { }; ; optional_weight: { $$= 1; } | WEIGHT_START { } ; hash: MD5 { $$= MEMCACHED_HASH_MD5; } | CRC { $$= MEMCACHED_HASH_CRC; } | FNV1_64 { $$= MEMCACHED_HASH_FNV1_64; } | FNV1A_64 { $$= MEMCACHED_HASH_FNV1A_64; } | FNV1_32 { $$= MEMCACHED_HASH_FNV1_32; } | FNV1A_32 { $$= MEMCACHED_HASH_FNV1A_32; } | HSIEH { $$= MEMCACHED_HASH_HSIEH; } | MURMUR { $$= MEMCACHED_HASH_MURMUR; } | JENKINS { $$= MEMCACHED_HASH_JENKINS; } ; string: STRING { $$= $1; } | QUOTED_STRING { $$= $1; } ; distribution: CONSISTENT { $$= MEMCACHED_DISTRIBUTION_CONSISTENT; } | MODULA { $$= MEMCACHED_DISTRIBUTION_MODULA; } | RANDOM { $$= MEMCACHED_DISTRIBUTION_RANDOM; } ; %% void Context::start() { config_parse(this, (void **)scanner); } libmemcached-1.0.8/libmemcached/csl/scanner.l0000664000076400007640000002105711753573717021410 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached 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. * */ %top{ #include #include #include #include #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wold-style-cast" #pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wunused-parameter" #endif #define YY_NO_INPUT #define YY_EXTRA_TYPE Context* } %{ #include #include #define PARAM yyget_extra(yyscanner) #define get_lex_chars(buffer, result, max_size, context) \ { \ if (context->pos >= context->length) \ { \ result= YY_NULL; \ } \ else \ { \ result= (int)(context->length - context->pos); \ (size_t)result > (size_t)max_size ? result= max_size : 0; \ memcpy(buffer, context->buf + context->pos, result); \ context->pos += result; \ } \ } #define YY_INPUT(buffer, result, max_size) get_lex_chars(buffer, result, max_size, PARAM) %} %option 8bit %option bison-bridge %option case-insensitive %option debug %option nounput %option noyywrap %option outfile="libmemcached/csl/scanner.cc" header-file="libmemcached/csl/scanner.h" %option perf-report %option prefix="config_" %option reentrant %% =|,|[ ] { return yytext[0];} [[:digit:]]+ { yylval->number= atoi(yytext); return (NUMBER); } :[[:digit:]]{1,5} { yylval->number= atoi(yytext +1); return PORT; } "/?"[[:digit:]]{1,5} { yylval->number= atoi(yytext +2); return WEIGHT_START; } [\t\r\n] ; /* skip whitespace */ ^#.*$ { return COMMENT; } "--SERVER=" { yyextra->begin= yytext; yyextra->set_server(); return yyextra->previous_token= SERVER; } "--SOCKET=" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET; } "--BINARY-PROTOCOL" { yyextra->begin= yytext; return yyextra->previous_token= BINARY_PROTOCOL; } "--BUFFER-REQUESTS" { yyextra->begin= yytext; return yyextra->previous_token= BUFFER_REQUESTS; } "--CONFIGURE-FILE=" { yyextra->begin= yytext; return yyextra->previous_token= CONFIGURE_FILE; } "--CONNECT-TIMEOUT=" { yyextra->begin= yytext; return yyextra->previous_token= CONNECT_TIMEOUT; } "--DISTRIBUTION=" { yyextra->begin= yytext; return yyextra->previous_token= DISTRIBUTION; } "--HASH-WITH-NAMESPACE" { yyextra->begin= yytext; return yyextra->previous_token= HASH_WITH_NAMESPACE; } "--HASH=" { yyextra->begin= yytext; return yyextra->previous_token= HASH; } "--IO-BYTES-WATERMARK=" { yyextra->begin= yytext; return yyextra->previous_token= IO_BYTES_WATERMARK; } "--IO-KEY-PREFETCH=" { yyextra->begin= yytext; return yyextra->previous_token= IO_KEY_PREFETCH; } "--IO-MSG-WATERMARK=" { yyextra->begin= yytext; return yyextra->previous_token= IO_MSG_WATERMARK; } "--NOREPLY" { yyextra->begin= yytext; return yyextra->previous_token= NOREPLY; } "--NUMBER-OF-REPLICAS=" { yyextra->begin= yytext; return yyextra->previous_token= NUMBER_OF_REPLICAS; } "--POLL-TIMEOUT=" { yyextra->begin= yytext; return yyextra->previous_token= POLL_TIMEOUT; } "--RANDOMIZE-REPLICA-READ" { yyextra->begin= yytext; return yyextra->previous_token= RANDOMIZE_REPLICA_READ; } "--RCV-TIMEOUT=" { yyextra->begin= yytext; return yyextra->previous_token= RCV_TIMEOUT; } "--REMOVE-FAILED-SERVERS=" { yyextra->begin= yytext; return yyextra->previous_token= REMOVE_FAILED_SERVERS; } "--RETRY-TIMEOUT=" { yyextra->begin= yytext; return yyextra->previous_token= RETRY_TIMEOUT; } "--SND-TIMEOUT=" { yyextra->begin= yytext; return yyextra->previous_token= SND_TIMEOUT; } "--SOCKET-RECV-SIZE=" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET_RECV_SIZE; } "--SOCKET-SEND-SIZE=" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET_SEND_SIZE; } "--SORT-HOSTS" { yyextra->begin= yytext; return yyextra->previous_token= SORT_HOSTS; } "--SUPPORT-CAS" { yyextra->begin= yytext; return yyextra->previous_token= SUPPORT_CAS; } "--TCP-KEEPALIVE" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPALIVE; } "--TCP-KEEPIDLE" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPIDLE; } "--TCP-NODELAY" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_NODELAY; } "--USE-UDP" { yyextra->begin= yytext; return yyextra->previous_token= USE_UDP; } "--USER-DATA" { yyextra->begin= yytext; return yyextra->previous_token= USER_DATA; } "--VERIFY-KEY" { yyextra->begin= yytext; return yyextra->previous_token= VERIFY_KEY; } "--POOL-MIN=" { yyextra->begin= yytext; return yyextra->previous_token= POOL_MIN; } "--POOL-MAX=" { yyextra->begin= yytext; return yyextra->previous_token= POOL_MAX; } "--NAMESPACE=" { yyextra->begin= yytext; return yyextra->previous_token= NAMESPACE; } INCLUDE { yyextra->begin= yytext; return yyextra->previous_token= INCLUDE; } RESET { yyextra->begin= yytext; return yyextra->previous_token= RESET; } DEBUG { yyextra->begin= yytext; return yyextra->previous_token= PARSER_DEBUG; } SERVERS { yyextra->begin= yytext; return yyextra->previous_token= SERVERS; } END { yyextra->begin= yytext; return yyextra->previous_token= END; } ERROR { yyextra->begin= yytext; return yyextra->previous_token= ERROR; } TRUE { return yyextra->previous_token= TRUE; } FALSE { return yyextra->previous_token= FALSE; } "--"[[:alnum:]]* { yyextra->begin= yytext; return UNKNOWN_OPTION; } CONSISTENT { return CONSISTENT; } MODULA { return MODULA; } RANDOM { return RANDOM; } MD5 { return MD5; } CRC { return CRC; } FNV1_64 { return FNV1_64; } FNV1A_64 { return FNV1A_64; } FNV1_32 { return FNV1_32; } FNV1A_32 { return FNV1A_32; } HSIEH { return HSIEH; } MURMUR { return MURMUR; } JENKINS { return JENKINS; } (([[:digit:]]{1,3}"."){3}([[:digit:]]{1,3})) { yylval->server.port= MEMCACHED_DEFAULT_PORT; yylval->server.weight= 1; yylval->server.c_str= yyextra->set_hostname(yytext, yyleng); if (yylval->server.c_str) yylval->server.size= yyleng; return IPADDRESS; } [[:alnum:]]["."[:alnum:]_-]+[[:alnum:]] { if (yyextra->is_server()) { yylval->server.port= MEMCACHED_DEFAULT_PORT; yylval->server.weight= 1; yylval->server.c_str= yyextra->set_hostname(yytext, yyleng); if (yylval->server.c_str) yylval->server.size= yyleng; return HOSTNAME; } yylval->string.c_str = yytext; yylval->string.size = yyleng; return STRING; } L?\"(\\.|[^\\"])*\" { yyget_text(yyscanner)[yyleng -1]= 0; yylval->string.c_str= yytext +1; yylval->string.size= yyleng -2; return QUOTED_STRING; } . { yyextra->begin= yytext; return UNKNOWN; } %% void Context::init_scanner() { yylex_init(&scanner); yyset_extra(this, scanner); } void Context::destroy_scanner() { yylex_destroy(scanner); } libmemcached-1.0.8/libmemcached/csl/parser.h0000664000076400007640000000661711753573717021254 0ustar00brianbrian00000000000000/* A Bison parser, made by GNU Bison 2.5. */ /* Bison interface for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { COMMENT = 258, END = 259, ERROR = 260, RESET = 261, PARSER_DEBUG = 262, INCLUDE = 263, CONFIGURE_FILE = 264, EMPTY_LINE = 265, SERVER = 266, SOCKET = 267, SERVERS = 268, SERVERS_OPTION = 269, UNKNOWN_OPTION = 270, UNKNOWN = 271, BINARY_PROTOCOL = 272, BUFFER_REQUESTS = 273, CONNECT_TIMEOUT = 274, DISTRIBUTION = 275, HASH = 276, HASH_WITH_NAMESPACE = 277, IO_BYTES_WATERMARK = 278, IO_KEY_PREFETCH = 279, IO_MSG_WATERMARK = 280, KETAMA_HASH = 281, KETAMA_WEIGHTED = 282, NOREPLY = 283, NUMBER_OF_REPLICAS = 284, POLL_TIMEOUT = 285, RANDOMIZE_REPLICA_READ = 286, RCV_TIMEOUT = 287, REMOVE_FAILED_SERVERS = 288, RETRY_TIMEOUT = 289, SND_TIMEOUT = 290, SOCKET_RECV_SIZE = 291, SOCKET_SEND_SIZE = 292, SORT_HOSTS = 293, SUPPORT_CAS = 294, USER_DATA = 295, USE_UDP = 296, VERIFY_KEY = 297, _TCP_KEEPALIVE = 298, _TCP_KEEPIDLE = 299, _TCP_NODELAY = 300, NAMESPACE = 301, POOL_MIN = 302, POOL_MAX = 303, MD5 = 304, CRC = 305, FNV1_64 = 306, FNV1A_64 = 307, FNV1_32 = 308, FNV1A_32 = 309, HSIEH = 310, MURMUR = 311, JENKINS = 312, CONSISTENT = 313, MODULA = 314, RANDOM = 315, TRUE = 316, FALSE = 317, FLOAT = 318, NUMBER = 319, PORT = 320, WEIGHT_START = 321, IPADDRESS = 322, HOSTNAME = 323, STRING = 324, QUOTED_STRING = 325, FILE_PATH = 326 }; #endif #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif libmemcached-1.0.8/libmemcached/csl/server.h0000664000076400007640000000346411753573717021263 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Configure Scripting Language * * Copyright (C) 2011 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. * */ #pragma once #include #include struct server_t { in_port_t port; uint32_t weight; const char *c_str; size_t size; }; libmemcached-1.0.8/libmemcached/csl/context.h0000664000076400007640000000616211753573717021437 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Configure Scripting Language * * Copyright (C) 2011 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. * */ #pragma once #include #include class Context { public: Context(const char *option_string, size_t option_string_length, memcached_st *memc_arg, memcached_return_t &rc_arg) : previous_token(END), scanner(NULL), begin(NULL), pos(0), memc(NULL), rc(rc_arg), _is_server(false), _end(false), _has_hash(false) { _hostname[0]= 0; buf= option_string; length= option_string_length; memc= memc_arg; init_scanner(); rc= MEMCACHED_SUCCESS; } bool end() { return _end; } void start(); void set_end() { rc= MEMCACHED_SUCCESS; _end= true; } bool set_hash(memcached_hash_t hash); void set_server() { _is_server= true; } void unset_server() { _is_server= false; } bool is_server() const { return _is_server; } const char *set_hostname(const char *str, size_t size); const char *hostname() const { return _hostname; } void abort(const char *, yytokentype, const char *); void error(const char *, yytokentype, const char* ); ~Context() { destroy_scanner(); } yytokentype previous_token; void *scanner; const char *buf; const char *begin; size_t pos; size_t length; memcached_st *memc; memcached_return_t &rc; protected: void init_scanner(); void destroy_scanner(); private: bool _is_server; bool _end; char _hostname[NI_MAXHOST]; bool _has_hash; }; libmemcached-1.0.8/libmemcached/csl/parser.am0000664000076400007640000000111111753573717021402 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root EXTRA_DIST+= libmemcached/csl/parser.yy EXTRA_DIST+= libmemcached/csl/scanner.l libmemcached/csl/parser.h: libmemcached/csl/parser.cc libmemcached/csl/parser.cc: libmemcached/csl/parser.yy libmemcached/csl/scanner.l libmemcached/csl/scanner.h $(AM_V_YACC)$(am__skipyacc) $(YACC) $(YLFLAGS) $(AM_YFLAGS) -o $@ $< libmemcached/csl/scanner.h: libmemcached/csl/scanner.cc libmemcached/csl/scanner.cc: libmemcached/csl/scanner.l libmemcached/csl/parser.yy $(AM_V_GEN)$(LEX) $< libmemcached-1.0.8/libmemcached/get.cc0000664000076400007640000005650011756611200020067 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include /* What happens if no servers exist? */ char *memcached_get(memcached_st *ptr, const char *key, size_t key_length, size_t *value_length, uint32_t *flags, memcached_return_t *error) { return memcached_get_by_key(ptr, NULL, 0, key, key_length, value_length, flags, error); } static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr, const char *group_key, size_t group_key_length, const char * const *keys, const size_t *key_length, size_t number_of_keys, bool mget_mode); char *memcached_get_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, size_t *value_length, uint32_t *flags, memcached_return_t *error) { memcached_return_t unused; if (error == NULL) { error= &unused; } uint64_t query_id= 0; if (ptr) { query_id= ptr->query_id; } /* Request the key */ *error= memcached_mget_by_key_real(ptr, group_key, group_key_length, (const char * const *)&key, &key_length, 1, false); if (ptr) { assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented."); } if (memcached_failed(*error)) { if (ptr) { if (memcached_has_current_error(*ptr)) // Find the most accurate error { *error= memcached_last_error(ptr); } } if (value_length) { *value_length= 0; } return NULL; } char *value= memcached_fetch(ptr, NULL, NULL, value_length, flags, error); assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented."); /* This is for historical reasons */ if (*error == MEMCACHED_END) { *error= MEMCACHED_NOTFOUND; } if (value == NULL) { if (ptr->get_key_failure and *error == MEMCACHED_NOTFOUND) { memcached_result_st key_failure_result; memcached_result_st* result_ptr= memcached_result_create(ptr, &key_failure_result); memcached_return_t rc= ptr->get_key_failure(ptr, key, key_length, result_ptr); /* On all failure drop to returning NULL */ if (rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED) { if (rc == MEMCACHED_BUFFERED) { uint64_t latch; /* We use latch to track the state of the original socket */ latch= memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS); if (latch == 0) { memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1); } rc= memcached_set(ptr, key, key_length, (memcached_result_value(result_ptr)), (memcached_result_length(result_ptr)), 0, (memcached_result_flags(result_ptr))); if (rc == MEMCACHED_BUFFERED and latch == 0) { memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 0); } } else { rc= memcached_set(ptr, key, key_length, (memcached_result_value(result_ptr)), (memcached_result_length(result_ptr)), 0, (memcached_result_flags(result_ptr))); } if (rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED) { *error= rc; *value_length= memcached_result_length(result_ptr); *flags= memcached_result_flags(result_ptr); char *result_value= memcached_string_take_value(&result_ptr->value); memcached_result_free(result_ptr); return result_value; } } memcached_result_free(result_ptr); } assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented."); return NULL; } return value; } memcached_return_t memcached_mget(memcached_st *ptr, const char * const *keys, const size_t *key_length, size_t number_of_keys) { return memcached_mget_by_key(ptr, NULL, 0, keys, key_length, number_of_keys); } static memcached_return_t binary_mget_by_key(memcached_st *ptr, uint32_t master_server_key, bool is_group_key_set, const char * const *keys, const size_t *key_length, size_t number_of_keys, bool mget_mode); static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr, const char *group_key, size_t group_key_length, const char * const *keys, const size_t *key_length, size_t number_of_keys, bool mget_mode) { bool failures_occured_in_sending= false; const char *get_command= "get "; uint8_t get_command_length= 4; unsigned int master_server_key= (unsigned int)-1; /* 0 is a valid server id! */ memcached_return_t rc; if (memcached_failed(rc= initialize_query(ptr, true))) { return rc; } if (memcached_is_udp(ptr)) { return memcached_set_error(*ptr, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT); } LIBMEMCACHED_MEMCACHED_MGET_START(); if (number_of_keys == 0) { return memcached_set_error(*ptr, MEMCACHED_NOTFOUND, MEMCACHED_AT, memcached_literal_param("number_of_keys was zero")); } if (memcached_failed(memcached_key_test(*ptr, keys, key_length, number_of_keys))) { return memcached_last_error(ptr); } bool is_group_key_set= false; if (group_key and group_key_length) { master_server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length); is_group_key_set= true; } /* Here is where we pay for the non-block API. We need to remove any data sitting in the queue before we start our get. It might be optimum to bounce the connection if count > some number. */ for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); if (memcached_server_response_count(instance)) { char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; if (ptr->flags.no_block) { memcached_io_write(instance); } while(memcached_server_response_count(instance)) { (void)memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, &ptr->result); } } } if (memcached_is_binary(ptr)) { return binary_mget_by_key(ptr, master_server_key, is_group_key_set, keys, key_length, number_of_keys, mget_mode); } if (ptr->flags.support_cas) { get_command= "gets "; get_command_length= 5; } /* If a server fails we warn about errors and start all over with sending keys to the server. */ WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS); size_t hosts_connected= 0; for (uint32_t x= 0; x < number_of_keys; x++) { memcached_server_write_instance_st instance; uint32_t server_key; if (is_group_key_set) { server_key= master_server_key; } else { server_key= memcached_generate_hash_with_redistribution(ptr, keys[x], key_length[x]); } instance= memcached_server_instance_fetch(ptr, server_key); libmemcached_io_vector_st vector[]= { { get_command, get_command_length }, { memcached_array_string(ptr->_namespace), memcached_array_size(ptr->_namespace) }, { keys[x], key_length[x] }, { memcached_literal_param(" ") } }; if (memcached_server_response_count(instance) == 0) { rc= memcached_connect(instance); if (memcached_failed(rc)) { memcached_set_error(*instance, rc, MEMCACHED_AT); continue; } hosts_connected++; if ((memcached_io_writev(instance, vector, 4, false)) == false) { failures_occured_in_sending= true; continue; } WATCHPOINT_ASSERT(instance->cursor_active == 0); memcached_server_response_increment(instance); WATCHPOINT_ASSERT(instance->cursor_active == 1); } else { if ((memcached_io_writev(instance, (vector + 1), 3, false)) == false) { memcached_server_response_reset(instance); failures_occured_in_sending= true; continue; } } } if (hosts_connected == 0) { LIBMEMCACHED_MEMCACHED_MGET_END(); if (memcached_failed(rc)) { return rc; } return memcached_set_error(*ptr, MEMCACHED_NO_SERVERS, MEMCACHED_AT); } /* Should we muddle on if some servers are dead? */ bool success_happened= false; for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); if (memcached_server_response_count(instance)) { /* We need to do something about non-connnected hosts in the future */ if ((memcached_io_write(instance, "\r\n", 2, true)) == -1) { failures_occured_in_sending= true; } else { success_happened= true; } } } LIBMEMCACHED_MEMCACHED_MGET_END(); if (failures_occured_in_sending and success_happened) { return MEMCACHED_SOME_ERRORS; } if (success_happened) { return MEMCACHED_SUCCESS; } return MEMCACHED_FAILURE; // Complete failure occurred } memcached_return_t memcached_mget_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char * const *keys, const size_t *key_length, size_t number_of_keys) { return memcached_mget_by_key_real(ptr, group_key, group_key_length, keys, key_length, number_of_keys, true); } memcached_return_t memcached_mget_execute(memcached_st *ptr, const char * const *keys, const size_t *key_length, size_t number_of_keys, memcached_execute_fn *callback, void *context, unsigned int number_of_callbacks) { return memcached_mget_execute_by_key(ptr, NULL, 0, keys, key_length, number_of_keys, callback, context, number_of_callbacks); } memcached_return_t memcached_mget_execute_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char * const *keys, const size_t *key_length, size_t number_of_keys, memcached_execute_fn *callback, void *context, unsigned int number_of_callbacks) { memcached_return_t rc; if (memcached_failed(rc= initialize_query(ptr, false))) { return rc; } if (memcached_is_udp(ptr)) { return memcached_set_error(*ptr, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT); } if (memcached_is_binary(ptr) == false) { return memcached_set_error(*ptr, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT, memcached_literal_param("ASCII protocol is not supported for memcached_mget_execute_by_key()")); } memcached_callback_st *original_callbacks= ptr->callbacks; memcached_callback_st cb= { callback, context, number_of_callbacks }; ptr->callbacks= &cb; rc= memcached_mget_by_key(ptr, group_key, group_key_length, keys, key_length, number_of_keys); ptr->callbacks= original_callbacks; return rc; } static memcached_return_t simple_binary_mget(memcached_st *ptr, uint32_t master_server_key, bool is_group_key_set, const char * const *keys, const size_t *key_length, size_t number_of_keys, bool mget_mode) { memcached_return_t rc= MEMCACHED_NOTFOUND; bool flush= (number_of_keys == 1); /* If a server fails we warn about errors and start all over with sending keys to the server. */ for (uint32_t x= 0; x < number_of_keys; ++x) { uint32_t server_key; if (is_group_key_set) { server_key= master_server_key; } else { server_key= memcached_generate_hash_with_redistribution(ptr, keys[x], key_length[x]); } memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, server_key); if (memcached_server_response_count(instance) == 0) { rc= memcached_connect(instance); if (memcached_failed(rc)) { continue; } } protocol_binary_request_getk request= { }; //= {.bytes= {0}}; request.message.header.request.magic= PROTOCOL_BINARY_REQ; if (mget_mode) { request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETKQ; } else { request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK; } memcached_return_t vk; vk= memcached_validate_key_length(key_length[x], ptr->flags.binary_protocol); if (vk != MEMCACHED_SUCCESS) { if (x > 0) { memcached_io_reset(instance); } return vk; } request.message.header.request.keylen= htons((uint16_t)(key_length[x] + memcached_array_size(ptr->_namespace))); request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; request.message.header.request.bodylen= htonl((uint32_t)( key_length[x] + memcached_array_size(ptr->_namespace))); libmemcached_io_vector_st vector[]= { { request.bytes, sizeof(request.bytes) }, { memcached_array_string(ptr->_namespace), memcached_array_size(ptr->_namespace) }, { keys[x], key_length[x] } }; if (memcached_io_writev(instance, vector, 3, flush) == false) { memcached_server_response_reset(instance); rc= MEMCACHED_SOME_ERRORS; continue; } /* We just want one pending response per server */ memcached_server_response_reset(instance); memcached_server_response_increment(instance); if ((x > 0 and x == ptr->io_key_prefetch) and memcached_flush_buffers(ptr) != MEMCACHED_SUCCESS) { rc= MEMCACHED_SOME_ERRORS; } } if (mget_mode) { /* Send a noop command to flush the buffers */ protocol_binary_request_noop request= {}; //= {.bytes= {0}}; request.message.header.request.magic= PROTOCOL_BINARY_REQ; request.message.header.request.opcode= PROTOCOL_BINARY_CMD_NOOP; request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; for (uint32_t x= 0; x < memcached_server_count(ptr); ++x) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); if (memcached_server_response_count(instance)) { if (memcached_io_write(instance) == false) { memcached_server_response_reset(instance); memcached_io_reset(instance); rc= MEMCACHED_SOME_ERRORS; } if (memcached_io_write(instance, request.bytes, sizeof(request.bytes), true) == -1) { memcached_server_response_reset(instance); memcached_io_reset(instance); rc= MEMCACHED_SOME_ERRORS; } } } } return rc; } static memcached_return_t replication_binary_mget(memcached_st *ptr, uint32_t* hash, bool* dead_servers, const char *const *keys, const size_t *key_length, size_t number_of_keys) { memcached_return_t rc= MEMCACHED_NOTFOUND; uint32_t start= 0; uint64_t randomize_read= memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ); if (randomize_read) { start= (uint32_t)random() % (uint32_t)(ptr->number_of_replicas + 1); } /* Loop for each replica */ for (uint32_t replica= 0; replica <= ptr->number_of_replicas; ++replica) { bool success= true; for (uint32_t x= 0; x < number_of_keys; ++x) { if (hash[x] == memcached_server_count(ptr)) continue; /* Already successfully sent */ uint32_t server= hash[x] + replica; /* In case of randomized reads */ if (randomize_read and ((server + start) <= (hash[x] + ptr->number_of_replicas))) { server+= start; } while (server >= memcached_server_count(ptr)) { server -= memcached_server_count(ptr); } if (dead_servers[server]) { continue; } memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, server); if (memcached_server_response_count(instance) == 0) { rc= memcached_connect(instance); if (memcached_failed(rc)) { memcached_io_reset(instance); dead_servers[server]= true; success= false; continue; } } protocol_binary_request_getk request= {}; request.message.header.request.magic= PROTOCOL_BINARY_REQ; request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK; request.message.header.request.keylen= htons((uint16_t)(key_length[x] + memcached_array_size(ptr->_namespace))); request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; request.message.header.request.bodylen= htonl((uint32_t)(key_length[x] + memcached_array_size(ptr->_namespace))); /* * We need to disable buffering to actually know that the request was * successfully sent to the server (so that we should expect a result * back). It would be nice to do this in buffered mode, but then it * would be complex to handle all error situations if we got to send * some of the messages, and then we failed on writing out some others * and we used the callback interface from memcached_mget_execute so * that we might have processed some of the responses etc. For now, * just make sure we work _correctly_ */ libmemcached_io_vector_st vector[]= { { request.bytes, sizeof(request.bytes) }, { memcached_array_string(ptr->_namespace), memcached_array_size(ptr->_namespace) }, { keys[x], key_length[x] } }; if (memcached_io_writev(instance, vector, 3, true) == false) { memcached_io_reset(instance); dead_servers[server]= true; success= false; continue; } memcached_server_response_increment(instance); hash[x]= memcached_server_count(ptr); } if (success) { break; } } return rc; } static memcached_return_t binary_mget_by_key(memcached_st *ptr, uint32_t master_server_key, bool is_group_key_set, const char * const *keys, const size_t *key_length, size_t number_of_keys, bool mget_mode) { if (ptr->number_of_replicas == 0) { return simple_binary_mget(ptr, master_server_key, is_group_key_set, keys, key_length, number_of_keys, mget_mode); } uint32_t* hash= libmemcached_xvalloc(ptr, number_of_keys, uint32_t); bool* dead_servers= libmemcached_xcalloc(ptr, memcached_server_count(ptr), bool); if (hash == NULL or dead_servers == NULL) { libmemcached_free(ptr, hash); libmemcached_free(ptr, dead_servers); return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } if (is_group_key_set) { for (size_t x= 0; x < number_of_keys; x++) { hash[x]= master_server_key; } } else { for (size_t x= 0; x < number_of_keys; x++) { hash[x]= memcached_generate_hash_with_redistribution(ptr, keys[x], key_length[x]); } } memcached_return_t rc= replication_binary_mget(ptr, hash, dead_servers, keys, key_length, number_of_keys); WATCHPOINT_IFERROR(rc); libmemcached_free(ptr, hash); libmemcached_free(ptr, dead_servers); return MEMCACHED_SUCCESS; } libmemcached-1.0.8/libmemcached/result.h0000664000076400007640000000340711753573717020507 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once void memcached_result_reset_value(memcached_result_st *ptr); libmemcached-1.0.8/libmemcached/encoding_key.h0000664000076400007640000000344411753573717021630 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif memcached_string_t memcached_encoding_key(memcached_st&); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached/error.cc0000664000076400007640000003614511753573717020465 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 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 #include #define MAX_ERROR_LENGTH 2048 struct memcached_error_t { memcached_st *root; uint64_t query_id; struct memcached_error_t *next; memcached_return_t rc; int local_errno; size_t size; char message[MAX_ERROR_LENGTH]; }; static void _set(memcached_server_st& server, memcached_st& memc) { if (server.error_messages && server.error_messages->query_id != server.root->query_id) { memcached_error_free(server); } if (memc.error_messages == NULL) { return; } memcached_error_t *error= libmemcached_xmalloc(&memc, memcached_error_t); if (error == NULL) // Bad business if this happens { return; } memcpy(error, memc.error_messages, sizeof(memcached_error_t)); error->next= server.error_messages; server.error_messages= error; } #if 0 static int error_log_fd= -1; #endif static void _set(memcached_st& memc, memcached_string_t *str, memcached_return_t &rc, const char *at, int local_errno= 0) { if (memc.error_messages && memc.error_messages->query_id != memc.query_id) { memcached_error_free(memc); } // For memory allocation we use our error since it is a bit more specific if (local_errno == ENOMEM and rc == MEMCACHED_ERRNO) { rc= MEMCACHED_MEMORY_ALLOCATION_FAILURE; } if (rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE) { local_errno= ENOMEM; } if (rc == MEMCACHED_ERRNO and not local_errno) { local_errno= errno; rc= MEMCACHED_ERRNO; } if (rc == MEMCACHED_ERRNO and local_errno == ENOTCONN) { rc= MEMCACHED_CONNECTION_FAILURE; } if (local_errno == EINVAL) { rc= MEMCACHED_INVALID_ARGUMENTS; } if (local_errno == ECONNREFUSED) { rc= MEMCACHED_CONNECTION_FAILURE; } memcached_error_t *error= libmemcached_xmalloc(&memc, memcached_error_t); if (error == NULL) // Bad business if this happens { return; } error->root= &memc; error->query_id= memc.query_id; error->rc= rc; error->local_errno= local_errno; const char *errmsg_ptr; char errmsg[MAX_ERROR_LENGTH]; errmsg[0]= 0; errmsg_ptr= errmsg; if (local_errno) { #ifdef STRERROR_R_CHAR_P errmsg_ptr= strerror_r(local_errno, errmsg, sizeof(errmsg)); #else strerror_r(local_errno, errmsg, sizeof(errmsg)); errmsg_ptr= errmsg; #endif } if (str and str->size and local_errno) { error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%lu) %s(%s), %.*s -> %s", long(error->root), memcached_strerror(&memc, rc), errmsg_ptr, memcached_string_printf(*str), at); } else if (local_errno) { error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%lu) %s(%s) -> %s", long(error->root), memcached_strerror(&memc, rc), errmsg_ptr, at); } else if (rc == MEMCACHED_PARSE_ERROR and str and str->size) { error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%lu) %.*s -> %s", long(error->root), int(str->size), str->c_str, at); } else if (str and str->size) { error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%lu) %s, %.*s -> %s", long(error->root), memcached_strerror(&memc, rc), int(str->size), str->c_str, at); } else { error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%lu) %s -> %s", long(error->root), memcached_strerror(&memc, rc), at); } error->next= memc.error_messages; memc.error_messages= error; #if 0 if (error_log_fd == -1) { // unlink("/tmp/libmemcachd.log"); if ((error_log_fd= open("/tmp/libmemcachd.log", O_CREAT | O_WRONLY | O_APPEND, 0644)) < 0) { perror("open"); error_log_fd= -1; } } ::write(error_log_fd, error->message, error->size); ::write(error_log_fd, "\n", 1); #endif } memcached_return_t memcached_set_error(memcached_st& memc, memcached_return_t rc, const char *at, const char *str, size_t length) { assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); memcached_string_t tmp= { str, length }; return memcached_set_error(memc, rc, at, tmp); } memcached_return_t memcached_set_error(memcached_server_st& self, memcached_return_t rc, const char *at, const char *str, size_t length) { assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); assert_msg(rc != MEMCACHED_SOME_ERRORS, "Programmer error, MEMCACHED_SOME_ERRORS was about to be set on a memcached_server_st"); memcached_string_t tmp= { str, length }; return memcached_set_error(self, rc, at, tmp); } memcached_return_t memcached_set_error(memcached_st& memc, memcached_return_t rc, const char *at, memcached_string_t& str) { assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); if (memcached_fatal(rc) == false) { return rc; } _set(memc, &str, rc, at); return rc; } memcached_return_t memcached_set_parser_error(memcached_st& memc, const char *at, const char *format, ...) { va_list args; char buffer[BUFSIZ]; va_start(args, format); int length= vsnprintf(buffer, sizeof(buffer), format, args); va_end(args); return memcached_set_error(memc, MEMCACHED_PARSE_ERROR, at, buffer, length); } memcached_return_t memcached_set_error(memcached_server_st& self, memcached_return_t rc, const char *at, memcached_string_t& str) { assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); assert_msg(rc != MEMCACHED_SOME_ERRORS, "Programmer error, MEMCACHED_SOME_ERRORS was about to be set on a memcached_server_st"); if (memcached_fatal(rc) == false) { return rc; } char hostname_port_message[MAX_ERROR_LENGTH]; int size; if (str.size) { size= snprintf(hostname_port_message, sizeof(hostname_port_message), "%.*s, host: %s:%d", memcached_string_printf(str), self.hostname, int(self.port)); } else { size= snprintf(hostname_port_message, sizeof(hostname_port_message), "host: %s:%d", self.hostname, int(self.port)); } memcached_string_t error_host= { hostname_port_message, size }; assert(self.root); if (self.root == NULL) { return rc; } _set(*self.root, &error_host, rc, at); _set(self, (*self.root)); assert(self.root->error_messages); assert(self.error_messages); return rc; } memcached_return_t memcached_set_error(memcached_server_st& self, memcached_return_t rc, const char *at) { assert_msg(rc != MEMCACHED_SOME_ERRORS, "Programmer error, MEMCACHED_SOME_ERRORS was about to be set on a memcached_server_st"); if (memcached_fatal(rc) == false) { return rc; } char hostname_port[NI_MAXHOST +NI_MAXSERV + sizeof("host : ")]; int size= snprintf(hostname_port, sizeof(hostname_port), "host: %s:%d", self.hostname, int(self.port)); memcached_string_t error_host= { hostname_port, size}; if (self.root == NULL) { return rc; } _set(*self.root, &error_host, rc, at); _set(self, *self.root); return rc; } memcached_return_t memcached_set_error(memcached_st& self, memcached_return_t rc, const char *at) { assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); if (memcached_fatal(rc) == false) { return rc; } _set(self, NULL, rc, at); return rc; } memcached_return_t memcached_set_errno(memcached_st& self, int local_errno, const char *at, const char *str, size_t length) { memcached_string_t tmp= { str, length }; return memcached_set_errno(self, local_errno, at, tmp); } memcached_return_t memcached_set_errno(memcached_server_st& self, int local_errno, const char *at, const char *str, size_t length) { memcached_string_t tmp= { str, length }; return memcached_set_errno(self, local_errno, at, tmp); } memcached_return_t memcached_set_errno(memcached_st& self, int local_errno, const char *at) { if (local_errno == 0) { return MEMCACHED_SUCCESS; } memcached_return_t rc= MEMCACHED_ERRNO; _set(self, NULL, rc, at, local_errno); return rc; } memcached_return_t memcached_set_errno(memcached_st& memc, int local_errno, const char *at, memcached_string_t& str) { if (local_errno == 0) { return MEMCACHED_SUCCESS; } memcached_return_t rc= MEMCACHED_ERRNO; _set(memc, &str, rc, at, local_errno); return rc; } memcached_return_t memcached_set_errno(memcached_server_st& self, int local_errno, const char *at, memcached_string_t& str) { if (local_errno == 0) { return MEMCACHED_SUCCESS; } char hostname_port_message[MAX_ERROR_LENGTH]; int size; if (str.size) { size= snprintf(hostname_port_message, sizeof(hostname_port_message), "%.*s, host: %s:%d", memcached_string_printf(str), self.hostname, int(self.port)); } else { size= snprintf(hostname_port_message, sizeof(hostname_port_message), "host: %s:%d", self.hostname, int(self.port)); } memcached_string_t error_host= { hostname_port_message, size }; memcached_return_t rc= MEMCACHED_ERRNO; if (self.root == NULL) { return rc; } _set(*self.root, &error_host, rc, at, local_errno); _set(self, (*self.root)); return rc; } memcached_return_t memcached_set_errno(memcached_server_st& self, int local_errno, const char *at) { if (local_errno == 0) { return MEMCACHED_SUCCESS; } char hostname_port_message[MAX_ERROR_LENGTH]; int size = snprintf(hostname_port_message, sizeof(hostname_port_message), "host: %s:%d", self.hostname, int(self.port)); memcached_string_t error_host= { hostname_port_message, size }; memcached_return_t rc= MEMCACHED_ERRNO; if (self.root == NULL) { return rc; } _set(*self.root, &error_host, rc, at, local_errno); _set(self, (*self.root)); return rc; } static void _error_print(const memcached_error_t *error) { if (error == NULL) { return; } if (error->size == 0) { fprintf(stderr, "\t%s\n", memcached_strerror(NULL, error->rc) ); } else { fprintf(stderr, "\t%s %s\n", memcached_strerror(NULL, error->rc), error->message); } _error_print(error->next); } void memcached_error_print(const memcached_st *self) { if (self == NULL) { return; } _error_print(self->error_messages); for (uint32_t x= 0; x < memcached_server_count(self); x++) { memcached_server_instance_st instance= memcached_server_instance_by_position(self, x); _error_print(instance->error_messages); } } static void _error_free(memcached_error_t *error) { if (not error) { return; } _error_free(error->next); if (error and error->root) { libmemcached_free(error->root, error); } else if (error) { libmemcached_free(error->root, error); } } void memcached_error_free(memcached_st& self) { _error_free(self.error_messages); self.error_messages= NULL; } void memcached_error_free(memcached_server_st& self) { _error_free(self.error_messages); self.error_messages= NULL; } const char *memcached_last_error_message(memcached_st *memc) { if (memc == NULL) { return memcached_strerror(memc, MEMCACHED_INVALID_ARGUMENTS); } if (memc->error_messages == NULL) { return memcached_strerror(memc, MEMCACHED_SUCCESS); } if (memc->error_messages->size == 0) { return memcached_strerror(memc, memc->error_messages->rc); } return memc->error_messages->message; } bool memcached_has_current_error(memcached_st &memc) { if (memc.error_messages and memc.error_messages->query_id == memc.query_id and memcached_failed(memc.error_messages->rc)) { return true; } return false; } bool memcached_has_current_error(memcached_server_st& server) { return memcached_has_current_error(*(server.root)); } memcached_return_t memcached_last_error(memcached_st *memc) { if (memc == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } if (memc->error_messages == NULL) { return MEMCACHED_SUCCESS; } return memc->error_messages->rc; } int memcached_last_error_errno(memcached_st *memc) { if (memc == NULL) { return 0; } if (memc->error_messages == NULL) { return 0; } return memc->error_messages->local_errno; } const char *memcached_server_error(memcached_server_instance_st server) { if (server == NULL) { return NULL; } if (server->error_messages == NULL) { return memcached_strerror(server->root, MEMCACHED_SUCCESS); } if (server->error_messages->size == 0) { return memcached_strerror(server->root, server->error_messages->rc); } return server->error_messages->message; } memcached_error_t *memcached_error_copy(const memcached_server_st& server) { if (server.error_messages == NULL) { return NULL; } memcached_error_t *error= libmemcached_xmalloc(server.root, memcached_error_t); memcpy(error, server.error_messages, sizeof(memcached_error_t)); error->next= NULL; return error; } memcached_return_t memcached_server_error_return(memcached_server_instance_st ptr) { if (ptr == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } if (ptr and ptr->error_messages) { return ptr->error_messages->rc; } return MEMCACHED_SUCCESS; } libmemcached-1.0.8/libmemcached/string.cc0000664000076400007640000001722511753573717020640 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include inline static memcached_return_t _string_check(memcached_string_st *string, size_t need) { if (need && need > (size_t)(string->current_size - (size_t)(string->end - string->string))) { size_t current_offset= (size_t) (string->end - string->string); /* This is the block multiplier. To keep it larger and surive division errors we must round it up */ size_t adjust= (need - (size_t)(string->current_size - (size_t)(string->end - string->string))) / MEMCACHED_BLOCK_SIZE; adjust++; size_t new_size= sizeof(char) * (size_t)((adjust * MEMCACHED_BLOCK_SIZE) + string->current_size); /* Test for overflow */ if (new_size < need) { char error_message[1024]; int error_message_length= snprintf(error_message, sizeof(error_message),"Needed %ld, got %ld", (long)need, (long)new_size); return memcached_set_error(*string->root, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, error_message, error_message_length); } char *new_value= libmemcached_xrealloc(string->root, string->string, new_size, char); if (new_value == NULL) { return memcached_set_error(*string->root, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); } string->string= new_value; string->end= string->string + current_offset; string->current_size+= (MEMCACHED_BLOCK_SIZE * adjust); } return MEMCACHED_SUCCESS; } static inline void _init_string(memcached_string_st *self) { self->current_size= 0; self->end= self->string= NULL; } memcached_string_st *memcached_string_create(memcached_st *memc, memcached_string_st *self, size_t initial_size) { WATCHPOINT_ASSERT(memc); /* Saving malloc calls :) */ if (self) { WATCHPOINT_ASSERT(self->options.is_initialized == false); memcached_set_allocated(self, false); } else { self= libmemcached_xmalloc(memc, memcached_string_st); if (self == NULL) { return NULL; } memcached_set_allocated(self, true); } self->root= memc; _init_string(self); if (memcached_failed(_string_check(self, initial_size))) { if (memcached_is_allocated(self)) { libmemcached_free(memc, self); } return NULL; } self->options.is_initialized= true; WATCHPOINT_ASSERT(self->string == self->end); return self; } static memcached_return_t memcached_string_append_null(memcached_string_st *string) { if (memcached_failed(_string_check(string, 1))) { return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } *string->end= 0; return MEMCACHED_SUCCESS; } memcached_return_t memcached_string_append_character(memcached_string_st *string, char character) { if (memcached_failed(_string_check(string, 1))) { return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } *string->end= character; string->end++; return MEMCACHED_SUCCESS; } memcached_return_t memcached_string_append(memcached_string_st *string, const char *value, size_t length) { if (memcached_failed(_string_check(string, length))) { return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } WATCHPOINT_ASSERT(length <= string->current_size); WATCHPOINT_ASSERT(string->string); WATCHPOINT_ASSERT(string->end >= string->string); memcpy(string->end, value, length); string->end+= length; return MEMCACHED_SUCCESS; } char *memcached_string_c_copy(memcached_string_st *string) { if (memcached_string_length(string) == 0) { return NULL; } char *c_ptr= static_cast(libmemcached_malloc(string->root, (memcached_string_length(string)+1) * sizeof(char))); if (c_ptr == NULL) { return NULL; } memcpy(c_ptr, memcached_string_value(string), memcached_string_length(string)); c_ptr[memcached_string_length(string)]= 0; return c_ptr; } void memcached_string_reset(memcached_string_st *string) { string->end= string->string; } void memcached_string_free(memcached_string_st& ptr) { memcached_string_free(&ptr); } void memcached_string_free(memcached_string_st *ptr) { if (ptr == NULL) { return; } if (ptr->string) { libmemcached_free(ptr->root, ptr->string); } if (memcached_is_allocated(ptr)) { libmemcached_free(ptr->root, ptr); } else { ptr->options.is_initialized= false; } } memcached_return_t memcached_string_check(memcached_string_st *string, size_t need) { return _string_check(string, need); } bool memcached_string_resize(memcached_string_st& string, const size_t need) { return memcached_success(_string_check(&string, need)); } size_t memcached_string_length(const memcached_string_st *self) { return size_t(self->end -self->string); } size_t memcached_string_length(const memcached_string_st& self) { return size_t(self.end -self.string); } size_t memcached_string_size(const memcached_string_st *self) { return self->current_size; } const char *memcached_string_value(const memcached_string_st *self) { return self->string; } const char *memcached_string_value(const memcached_string_st& self) { return self.string; } char *memcached_string_take_value(memcached_string_st *self) { assert_msg(self, "Invalid memcached_string_st"); // If we fail at adding the null, we copy and move on if (memcached_success(memcached_string_append_null(self))) { return memcached_string_c_copy(self); } char *value= self->string; _init_string(self); return value; } char *memcached_string_value_mutable(const memcached_string_st *self) { return self->string; } char *memcached_string_c_str(memcached_string_st& self) { return self.string; } void memcached_string_set_length(memcached_string_st *self, size_t length) { self->end= self->string +length; } void memcached_string_set_length(memcached_string_st& self, const size_t length) { assert(self.current_size >= length); size_t set_length= length; if (self.current_size > length) { if (memcached_failed(_string_check(&self, length))) { set_length= self.current_size; } } self.end= self.string +set_length; } libmemcached-1.0.8/libmemcached/memcached.cc0000664000076400007640000002545511756611200021223 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include #include #include static inline bool _memcached_init(memcached_st *self) { self->state.is_purging= false; self->state.is_processing_input= false; self->state.is_time_for_rebuild= false; self->flags.auto_eject_hosts= false; self->flags.binary_protocol= false; self->flags.buffer_requests= false; self->flags.hash_with_namespace= false; self->flags.no_block= false; self->flags.reply= true; self->flags.randomize_replica_read= false; self->flags.support_cas= false; self->flags.tcp_nodelay= false; self->flags.use_sort_hosts= false; self->flags.use_udp= false; self->flags.verify_key= false; self->flags.tcp_keepalive= false; self->virtual_bucket= NULL; self->distribution= MEMCACHED_DISTRIBUTION_MODULA; if (hashkit_create(&self->hashkit) == NULL) { return false; } self->server_info.version= 0; self->ketama.continuum= NULL; self->ketama.continuum_count= 0; self->ketama.continuum_points_counter= 0; self->ketama.next_distribution_rebuild= 0; self->ketama.weighted= false; self->number_of_hosts= 0; self->servers= NULL; self->last_disconnected_server= NULL; self->snd_timeout= 0; self->rcv_timeout= 0; self->server_failure_limit= MEMCACHED_SERVER_FAILURE_LIMIT; self->query_id= 1; // 0 is considered invalid /* TODO, Document why we picked these defaults */ self->io_msg_watermark= 500; self->io_bytes_watermark= 65 * 1024; self->tcp_keepidle= 0; self->io_key_prefetch= 0; self->poll_timeout= MEMCACHED_DEFAULT_TIMEOUT; self->connect_timeout= MEMCACHED_DEFAULT_CONNECT_TIMEOUT; self->retry_timeout= MEMCACHED_SERVER_FAILURE_RETRY_TIMEOUT; self->dead_timeout= MEMCACHED_SERVER_FAILURE_DEAD_TIMEOUT; self->send_size= -1; self->recv_size= -1; self->user_data= NULL; self->number_of_replicas= 0; self->allocators= memcached_allocators_return_default(); self->on_clone= NULL; self->on_cleanup= NULL; self->get_key_failure= NULL; self->delete_trigger= NULL; self->callbacks= NULL; self->sasl.callbacks= NULL; self->sasl.is_allocated= false; self->error_messages= NULL; self->_namespace= NULL; self->configure.initial_pool_size= 1; self->configure.max_pool_size= 1; self->configure.version= -1; self->configure.filename= NULL; return true; } static void __memcached_free(memcached_st *ptr, bool release_st) { /* If we have anything open, lets close it now */ send_quit(ptr); memcached_server_list_free(memcached_server_list(ptr)); memcached_result_free(&ptr->result); memcached_virtual_bucket_free(ptr); memcached_server_free(ptr->last_disconnected_server); if (ptr->on_cleanup) { ptr->on_cleanup(ptr); } libmemcached_free(ptr, ptr->ketama.continuum); memcached_array_free(ptr->_namespace); ptr->_namespace= NULL; memcached_error_free(*ptr); if (LIBMEMCACHED_WITH_SASL_SUPPORT and ptr->sasl.callbacks) { memcached_destroy_sasl_auth_data(ptr); } if (release_st) { memcached_array_free(ptr->configure.filename); ptr->configure.filename= NULL; } hashkit_free(&ptr->hashkit); if (memcached_is_allocated(ptr) and release_st) { libmemcached_free(ptr, ptr); } } memcached_st *memcached_create(memcached_st *ptr) { if (ptr) { ptr->options.is_allocated= false; } else { ptr= (memcached_st *)libmemcached_xmalloc(NULL, memcached_st); if (ptr == NULL) { return NULL; /* MEMCACHED_MEMORY_ALLOCATION_FAILURE */ } ptr->options.is_allocated= true; } if (_memcached_init(ptr) == false) { memcached_free(ptr); return NULL; } if (memcached_result_create(ptr, &ptr->result) == NULL) { memcached_free(ptr); return NULL; } WATCHPOINT_ASSERT_INITIALIZED(&ptr->result); return ptr; } memcached_st *memcached(const char *string, size_t length) { if (length == 0 and string) { return NULL; } if (length and string == NULL) { return NULL; } if (length == 0) { if (bool(getenv("LIBMEMCACHED"))) { string= getenv("LIBMEMCACHED"); length= string ? strlen(string) : 0; } } memcached_st *memc= memcached_create(NULL); if (memc == NULL) { return NULL; } if (length == 0 or string == NULL) { return memc; } memcached_return_t rc= memcached_parse_configuration(memc, string, length); if (memcached_success(rc) and memcached_parse_filename(memc)) { rc= memcached_parse_configure_file(*memc, memcached_parse_filename(memc), memcached_parse_filename_length(memc)); } if (memcached_failed(rc)) { memcached_free(memc); return NULL; } return memc; } memcached_return_t memcached_reset(memcached_st *ptr) { WATCHPOINT_ASSERT(ptr); if (ptr == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } bool stored_is_allocated= memcached_is_allocated(ptr); uint64_t query_id= ptr->query_id; __memcached_free(ptr, false); memcached_create(ptr); memcached_set_allocated(ptr, stored_is_allocated); ptr->query_id= query_id; if (ptr->configure.filename) { return memcached_parse_configure_file(*ptr, memcached_param_array(ptr->configure.filename)); } return MEMCACHED_SUCCESS; } void memcached_servers_reset(memcached_st *self) { if (self) { memcached_server_list_free(memcached_server_list(self)); memcached_server_list_set(self, NULL); self->number_of_hosts= 0; memcached_server_free(self->last_disconnected_server); self->last_disconnected_server= NULL; } } void memcached_reset_last_disconnected_server(memcached_st *self) { if (self) { memcached_server_free(self->last_disconnected_server); self->last_disconnected_server= NULL; } } void memcached_free(memcached_st *ptr) { if (ptr) { __memcached_free(ptr, true); } } /* clone is the destination, while source is the structure to clone. If source is NULL the call is the same as if a memcached_create() was called. */ memcached_st *memcached_clone(memcached_st *clone, const memcached_st *source) { if (source == NULL) { return memcached_create(clone); } if (clone and memcached_is_allocated(clone)) { return NULL; } memcached_st *new_clone= memcached_create(clone); if (new_clone == NULL) { return NULL; } new_clone->flags= source->flags; new_clone->send_size= source->send_size; new_clone->recv_size= source->recv_size; new_clone->poll_timeout= source->poll_timeout; new_clone->connect_timeout= source->connect_timeout; new_clone->retry_timeout= source->retry_timeout; new_clone->dead_timeout= source->dead_timeout; new_clone->distribution= source->distribution; if (hashkit_clone(&new_clone->hashkit, &source->hashkit) == NULL) { memcached_free(new_clone); return NULL; } new_clone->user_data= source->user_data; new_clone->snd_timeout= source->snd_timeout; new_clone->rcv_timeout= source->rcv_timeout; new_clone->on_clone= source->on_clone; new_clone->on_cleanup= source->on_cleanup; new_clone->allocators= source->allocators; new_clone->get_key_failure= source->get_key_failure; new_clone->delete_trigger= source->delete_trigger; new_clone->server_failure_limit= source->server_failure_limit; new_clone->io_msg_watermark= source->io_msg_watermark; new_clone->io_bytes_watermark= source->io_bytes_watermark; new_clone->io_key_prefetch= source->io_key_prefetch; new_clone->number_of_replicas= source->number_of_replicas; new_clone->tcp_keepidle= source->tcp_keepidle; if (memcached_server_count(source)) { if (memcached_failed(memcached_push(new_clone, source))) { return NULL; } } new_clone->_namespace= memcached_array_clone(new_clone, source->_namespace); new_clone->configure.filename= memcached_array_clone(new_clone, source->_namespace); new_clone->configure.version= source->configure.version; if (LIBMEMCACHED_WITH_SASL_SUPPORT and source->sasl.callbacks) { if (memcached_failed(memcached_clone_sasl(new_clone, source))) { memcached_free(new_clone); return NULL; } } if (memcached_failed(run_distribution(new_clone))) { memcached_free(new_clone); return NULL; } if (source->on_clone) { source->on_clone(new_clone, source); } return new_clone; } void *memcached_get_user_data(const memcached_st *ptr) { if (ptr == NULL) { return NULL; } return ptr->user_data; } void *memcached_set_user_data(memcached_st *ptr, void *data) { if (ptr == NULL) { return NULL; } void *ret= ptr->user_data; ptr->user_data= data; return ret; } memcached_return_t memcached_push(memcached_st *destination, const memcached_st *source) { return memcached_server_push(destination, source->servers); } memcached_server_write_instance_st memcached_server_instance_fetch(memcached_st *ptr, uint32_t server_key) { if (ptr == NULL) { return NULL; } return &ptr->servers[server_key]; } memcached_server_instance_st memcached_server_instance_by_position(const memcached_st *ptr, uint32_t server_key) { if (ptr == NULL) { return NULL; } return &ptr->servers[server_key]; } uint64_t memcached_query_id(const memcached_st *self) { if (self == NULL) { return 0; } return self->query_id; } libmemcached-1.0.8/libmemcached/dump.cc0000664000076400007640000001353611753573717020300 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ /* We use this to dump all keys. At this point we only support a callback method. This could be optimized by first calling items and finding active slabs. For the moment though we just loop through all slabs on servers and "grab" the keys. */ #include static memcached_return_t ascii_dump(memcached_st *memc, memcached_dump_fn *callback, void *context, uint32_t number_of_callbacks) { /* MAX_NUMBER_OF_SLAB_CLASSES is defined to 200 in Memcached 1.4.10 */ for (uint32_t x= 0; x < 200; x++) { char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; int buffer_length= snprintf(buffer, sizeof(buffer), "%u", x); if (size_t(buffer_length) >= sizeof(buffer) or buffer_length < 0) { return memcached_set_error(*memc, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)")); } // @NOTE the hard coded zero means "no limit" libmemcached_io_vector_st vector[]= { { memcached_literal_param("stats cachedump ") }, { buffer, buffer_length }, { memcached_literal_param(" 0\r\n") } }; // Send message to all servers for (uint32_t server_key= 0; server_key < memcached_server_count(memc); server_key++) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc, server_key); memcached_return_t vdo_rc; if (memcached_success((vdo_rc= memcached_vdo(instance, vector, 3, true)))) { // We have sent the message to the server successfully } else { return vdo_rc; } } // Collect the returned items memcached_server_write_instance_st instance; while ((instance= memcached_io_get_readable_server(memc))) { memcached_return_t response_rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL); if (response_rc == MEMCACHED_ITEM) { char *string_ptr, *end_ptr; string_ptr= buffer; string_ptr+= 5; /* Move past ITEM */ for (end_ptr= string_ptr; isgraph(*end_ptr); end_ptr++) {} ; char *key= string_ptr; key[(size_t)(end_ptr-string_ptr)]= 0; for (uint32_t callback_counter= 0; callback_counter < number_of_callbacks; callback_counter++) { memcached_return_t callback_rc= (*callback[callback_counter])(memc, key, (size_t)(end_ptr-string_ptr), context); if (callback_rc != MEMCACHED_SUCCESS) { // @todo build up a message for the error from the value memcached_set_error(*instance, callback_rc, MEMCACHED_AT); break; } } } else if (response_rc == MEMCACHED_END) { // All items have been returned } else if (response_rc == MEMCACHED_SERVER_ERROR or response_rc == MEMCACHED_CLIENT_ERROR or response_rc == MEMCACHED_ERROR) { /* If we try to request stats cachedump for a slab class that is too big * the server will return an incorrect error message: * "MEMCACHED_SERVER_ERROR failed to allocate memory" * This isn't really a fatal error, so let's just skip it. I want to * fix the return value from the memcached server to a CLIENT_ERROR, * so let's add support for that as well right now. */ assert(response_rc == MEMCACHED_SUCCESS); // Just fail return response_rc; } else { // IO error of some sort must have occurred return response_rc; } } } return memcached_has_current_error(*memc) ? MEMCACHED_SOME_ERRORS : MEMCACHED_SUCCESS; } memcached_return_t memcached_dump(memcached_st *ptr, memcached_dump_fn *callback, void *context, uint32_t number_of_callbacks) { memcached_return_t rc; if (memcached_failed(rc= initialize_query(ptr, true))) { return rc; } /* No support for Binary protocol yet @todo Fix this so that we just flush, switch to ascii, and then go back to binary. */ if (memcached_is_binary(ptr)) { return memcached_set_error(*ptr, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT, memcached_literal_param("Binary protocol is not supported for memcached_dump()")); } return ascii_dump(ptr, callback, context, number_of_callbacks); } libmemcached-1.0.8/libmemcached/libmemcached_probes.d0000664000076400007640000000173311753573717023134 0ustar00brianbrian00000000000000provider libmemcached { probe memcached_delete_start(); probe memcached_delete_end(); probe memcached_increment_with_initial_start(); probe memcached_increment_with_initial_end(); probe memcached_decrement_with_initial_start(); probe memcached_decrement_with_initial_end(); probe memcached_increment_start(); probe memcached_increment_end(); probe memcached_decrement_start(); probe memcached_decrement_end(); probe memcached_flush_start(); probe memcached_flush_end(); probe memcached_set_start(); probe memcached_set_end(); probe memcached_add_start(); probe memcached_add_end(); probe memcached_replace_start(); probe memcached_replace_end(); probe memcached_get_start(); probe memcached_get_end(); probe memcached_touch_start(); probe memcached_touch_end(); probe memcached_mget_start(); probe memcached_mget_end(); probe memcached_connect_start(); probe memcached_connect_end(); probe memcached_server_add_start(); probe memcached_server_add_end(); }; libmemcached-1.0.8/libmemcached/flush.cc0000664000076400007640000001317011753573717020446 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 static memcached_return_t memcached_flush_binary(memcached_st *ptr, time_t expiration, const bool reply) { protocol_binary_request_flush request= {}; request.message.header.request.magic= (uint8_t)PROTOCOL_BINARY_REQ; request.message.header.request.opcode= PROTOCOL_BINARY_CMD_FLUSH; request.message.header.request.extlen= 4; request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; request.message.header.request.bodylen= htonl(request.message.header.request.extlen); request.message.body.expiration= htonl((uint32_t) expiration); memcached_return_t rc= MEMCACHED_SUCCESS; for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); if (reply) { request.message.header.request.opcode= PROTOCOL_BINARY_CMD_FLUSH; } else { request.message.header.request.opcode= PROTOCOL_BINARY_CMD_FLUSHQ; } libmemcached_io_vector_st vector[]= { { NULL, 0 }, { request.bytes, sizeof(request.bytes) } }; memcached_return_t rrc; if (memcached_failed(rrc= memcached_vdo(instance, vector, 2, true))) { if (instance->error_messages == NULL or instance->root->error_messages == NULL) { memcached_set_error(*instance, rrc, MEMCACHED_AT); } memcached_io_reset(instance); rc= MEMCACHED_SOME_ERRORS; } } for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); if (memcached_server_response_count(instance) > 0) { (void)memcached_response(instance, NULL, 0, NULL); } } return rc; } static memcached_return_t memcached_flush_textual(memcached_st *ptr, time_t expiration, const bool reply) { char buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; int send_length= 0; if (expiration) { send_length= snprintf(buffer, sizeof(buffer), "%llu", (unsigned long long)expiration); } if (size_t(send_length) >= sizeof(buffer) or send_length < 0) { return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)")); } memcached_return_t rc= MEMCACHED_SUCCESS; for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); libmemcached_io_vector_st vector[]= { { NULL, 0 }, { memcached_literal_param("flush_all ") }, { buffer, send_length }, { " noreply", reply ? 0 : memcached_literal_param_size(" noreply") }, { memcached_literal_param("\r\n") } }; memcached_return_t rrc= memcached_vdo(instance, vector, 5, true); if (memcached_success(rrc) and reply == true) { char response_buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; rrc= memcached_response(instance, response_buffer, sizeof(response_buffer), NULL); } if (memcached_failed(rrc)) { // If an error has already been reported, then don't add to it if (instance->error_messages == NULL or instance->root->error_messages == NULL) { memcached_set_error(*instance, rrc, MEMCACHED_AT); } rc= MEMCACHED_SOME_ERRORS; } } return rc; } memcached_return_t memcached_flush(memcached_st *ptr, time_t expiration) { memcached_return_t rc; if (memcached_failed(rc= initialize_query(ptr, true))) { return rc; } bool reply= memcached_is_replying(ptr); LIBMEMCACHED_MEMCACHED_FLUSH_START(); if (memcached_is_binary(ptr)) { rc= memcached_flush_binary(ptr, expiration, reply); } else { rc= memcached_flush_textual(ptr, expiration, reply); } LIBMEMCACHED_MEMCACHED_FLUSH_END(); return rc; } libmemcached-1.0.8/libmemcached/backtrace.hpp0000664000076400007640000000330711753573717021447 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * libmcachedd client library. * * Copyright (C) 2011 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. * */ #pragma once void custom_backtrace(void); libmemcached-1.0.8/libmemcached/quit.hpp0000664000076400007640000000336311753573717020514 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once void memcached_quit_server(memcached_server_st *ptr, bool io_death); void send_quit(memcached_st *ptr); libmemcached-1.0.8/libmemcached/assert.hpp0000664000076400007640000000410411753573717021025 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * libmcachedd client library. * * Copyright (C) 2011 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. * */ #pragma once #include #include #ifdef NDEBUG #define assert_msg(__expr, __mesg) (void)(__expr); (void)(__mesg); #else #define assert_msg(__expr, __mesg) \ do \ { \ if (not (__expr)) \ { \ fprintf(stderr, "\n%s:%d Assertion \"%s\" failed for function \"%s\" likely for %s\n", __FILE__, __LINE__, #__expr, __func__, (#__mesg));\ custom_backtrace(); \ abort(); \ } \ } while (0) #endif libmemcached-1.0.8/libmemcached/delete.cc0000664000076400007640000001700111753573717020564 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include #include memcached_return_t memcached_delete(memcached_st *memc, const char *key, size_t key_length, time_t expiration) { return memcached_delete_by_key(memc, key, key_length, key, key_length, expiration); } static inline memcached_return_t ascii_delete(memcached_server_write_instance_st instance, uint32_t , const char *key, const size_t key_length, const bool reply, const bool is_buffering) { libmemcached_io_vector_st vector[]= { { NULL, 0 }, { memcached_literal_param("delete ") }, { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) }, { key, key_length }, { " noreply", reply ? 0 : memcached_literal_param_size(" noreply") }, { memcached_literal_param("\r\n") } }; /* Send command header, only flush if we are NOT buffering */ return memcached_vdo(instance, vector, 6, is_buffering ? false : true); } static inline memcached_return_t binary_delete(memcached_server_write_instance_st instance, uint32_t server_key, const char *key, const size_t key_length, const bool reply, const bool is_buffering) { protocol_binary_request_delete request= {}; bool should_flush= is_buffering ? false : true; request.message.header.request.magic= PROTOCOL_BINARY_REQ; if (reply) { request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETE; } else { request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETEQ; } request.message.header.request.keylen= htons(uint16_t(key_length + memcached_array_size(instance->root->_namespace))); request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; request.message.header.request.bodylen= htonl(uint32_t(key_length + memcached_array_size(instance->root->_namespace))); libmemcached_io_vector_st vector[]= { { NULL, 0 }, { request.bytes, sizeof(request.bytes) }, { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) }, { key, key_length } }; memcached_return_t rc; if (memcached_fatal(rc= memcached_vdo(instance, vector, 4, should_flush))) { memcached_io_reset(instance); } if (memcached_has_replicas(instance)) { request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETEQ; for (uint32_t x= 0; x < memcached_has_replicas(instance); ++x) { ++server_key; if (server_key == memcached_server_count(instance->root)) { server_key= 0; } memcached_server_write_instance_st replica= memcached_server_instance_fetch(instance->root, server_key); if (memcached_fatal(memcached_vdo(replica, vector, 4, should_flush))) { memcached_io_reset(replica); } else { memcached_server_response_decrement(replica); } } } return rc; } memcached_return_t memcached_delete_by_key(memcached_st *memc, const char *group_key, size_t group_key_length, const char *key, size_t key_length, time_t expiration) { LIBMEMCACHED_MEMCACHED_DELETE_START(); memcached_return_t rc; if (memcached_fatal(rc= initialize_query(memc, true))) { return rc; } if (memcached_fatal(rc= memcached_key_test(*memc, (const char **)&key, &key_length, 1))) { return memcached_last_error(memc); } if (expiration) { return memcached_set_error(*memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Memcached server version does not allow expiration of deleted items")); } uint32_t server_key= memcached_generate_hash_with_redistribution(memc, group_key, group_key_length); memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc, server_key); bool is_buffering= memcached_is_buffering(instance->root); bool is_replying= memcached_is_replying(instance->root); // If a delete trigger exists, we need a response, so no buffering/noreply if (memc->delete_trigger) { if (is_buffering) { return memcached_set_error(*memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Delete triggers cannot be used if buffering is enabled")); } if (is_replying == false) { return memcached_set_error(*memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Delete triggers cannot be used if MEMCACHED_BEHAVIOR_NOREPLY is set")); } } if (memcached_is_binary(memc)) { rc= binary_delete(instance, server_key, key, key_length, is_replying, is_buffering); } else { rc= ascii_delete(instance, server_key, key, key_length, is_replying, is_buffering); } if (rc == MEMCACHED_SUCCESS) { if (is_buffering == true) { rc= MEMCACHED_BUFFERED; } else if (is_replying == false) { rc= MEMCACHED_SUCCESS; } else { char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL); if (rc == MEMCACHED_DELETED) { rc= MEMCACHED_SUCCESS; if (memc->delete_trigger) { memc->delete_trigger(memc, key, key_length); } } } } LIBMEMCACHED_MEMCACHED_DELETE_END(); return rc; } libmemcached-1.0.8/libmemcached/initialize_query.cc0000664000076400007640000000463311756611200022676 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 memcached_return_t initialize_query(memcached_st *self, bool increment_query_id) { if (self == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } if (increment_query_id) { self->query_id++; } if (self->state.is_time_for_rebuild) { memcached_reset(self); } if (memcached_server_count(self) == 0) { return memcached_set_error(*self, MEMCACHED_NO_SERVERS, MEMCACHED_AT); } memcached_error_free(*self); memcached_result_reset(&self->result); return MEMCACHED_SUCCESS; } memcached_return_t initialize_const_query(const memcached_st *self) { if (self == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } if (memcached_server_count(self) == 0) { return MEMCACHED_NO_SERVERS; } return MEMCACHED_SUCCESS; } libmemcached-1.0.8/libmemcached/verbosity.cc0000664000076400007640000000677211753573717021365 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #include struct context_st { size_t length; const char *buffer; }; static memcached_return_t _set_verbosity(const memcached_st *, const memcached_server_st *server, void *context) { libmemcached_io_vector_st *vector= (libmemcached_io_vector_st *)context; memcached_st local_memc; memcached_st *memc_ptr= memcached_create(&local_memc); memcached_return_t rc= memcached_server_add(memc_ptr, memcached_server_name(server), memcached_server_port(server)); if (rc == MEMCACHED_SUCCESS) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc_ptr, 0); rc= memcached_vdo(instance, vector, 4, true); if (rc == MEMCACHED_SUCCESS) { char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; rc= memcached_response(instance, buffer, sizeof(buffer), NULL); } } memcached_free(memc_ptr); return rc; } memcached_return_t memcached_verbosity(memcached_st *ptr, uint32_t verbosity) { memcached_return_t rc; if (memcached_failed(rc= initialize_query(ptr, false))) { return rc; } memcached_server_fn callbacks[1]; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; int send_length= snprintf(buffer, sizeof(buffer), "%u", verbosity); if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE or send_length < 0) { return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)")); } libmemcached_io_vector_st vector[]= { { NULL, 0 }, { memcached_literal_param("verbosity ") }, { buffer, send_length }, { memcached_literal_param("\r\n") } }; callbacks[0]= _set_verbosity; return memcached_server_cursor(ptr, callbacks, vector, 1); } libmemcached-1.0.8/libmemcached/hash.hpp0000664000076400007640000000346311753573717020456 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once uint32_t memcached_generate_hash_with_redistribution(memcached_st *ptr, const char *key, size_t key_length); libmemcached-1.0.8/libmemcached/byteorder.h0000664000076400007640000000357411753573717021175 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_LOCAL uint64_t memcached_ntohll(uint64_t); LIBMEMCACHED_LOCAL uint64_t memcached_htonll(uint64_t); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached/strerror.cc0000664000076400007640000001244711753573717021215 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include const char *memcached_strerror(memcached_st *, memcached_return_t rc) { switch (rc) { case MEMCACHED_SUCCESS: return "SUCCESS"; case MEMCACHED_FAILURE: return "FAILURE"; case MEMCACHED_HOST_LOOKUP_FAILURE: // getaddrinfo only return "getaddrinfo() or getnameinfo() HOSTNAME LOOKUP FAILURE"; case MEMCACHED_CONNECTION_FAILURE: return "CONNECTION FAILURE"; case MEMCACHED_CONNECTION_BIND_FAILURE: // DEPRECATED, see MEMCACHED_HOST_LOOKUP_FAILURE return "CONNECTION BIND FAILURE"; case MEMCACHED_READ_FAILURE: return "READ FAILURE"; case MEMCACHED_UNKNOWN_READ_FAILURE: return "UNKNOWN READ FAILURE"; case MEMCACHED_PROTOCOL_ERROR: return "PROTOCOL ERROR"; case MEMCACHED_CLIENT_ERROR: return "CLIENT ERROR"; case MEMCACHED_SERVER_ERROR: return "SERVER ERROR"; case MEMCACHED_WRITE_FAILURE: return "WRITE FAILURE"; case MEMCACHED_ERROR: return "ERROR was returned by server"; case MEMCACHED_DATA_EXISTS: return "CONNECTION DATA EXISTS"; case MEMCACHED_DATA_DOES_NOT_EXIST: return "CONNECTION DATA DOES NOT EXIST"; case MEMCACHED_NOTSTORED: return "NOT STORED"; case MEMCACHED_STORED: return "STORED"; case MEMCACHED_NOTFOUND: return "NOT FOUND"; case MEMCACHED_MEMORY_ALLOCATION_FAILURE: return "MEMORY ALLOCATION FAILURE"; case MEMCACHED_PARTIAL_READ: return "PARTIAL READ"; case MEMCACHED_SOME_ERRORS: return "SOME ERRORS WERE REPORTED"; case MEMCACHED_NO_SERVERS: return "NO SERVERS DEFINED"; case MEMCACHED_END: return "SERVER END"; case MEMCACHED_DELETED: return "SERVER DELETE"; case MEMCACHED_VALUE: return "SERVER VALUE"; case MEMCACHED_STAT: return "STAT VALUE"; case MEMCACHED_ITEM: return "ITEM VALUE"; case MEMCACHED_ERRNO: return "SYSTEM ERROR"; case MEMCACHED_FAIL_UNIX_SOCKET: return "COULD NOT OPEN UNIX SOCKET"; case MEMCACHED_NOT_SUPPORTED: return "ACTION NOT SUPPORTED"; case MEMCACHED_FETCH_NOTFINISHED: return "FETCH WAS NOT COMPLETED"; case MEMCACHED_NO_KEY_PROVIDED: return "A KEY LENGTH OF ZERO WAS PROVIDED"; case MEMCACHED_BUFFERED: return "ACTION QUEUED"; case MEMCACHED_TIMEOUT: return "A TIMEOUT OCCURRED"; case MEMCACHED_BAD_KEY_PROVIDED: return "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"; case MEMCACHED_INVALID_HOST_PROTOCOL: return "THE HOST TRANSPORT PROTOCOL DOES NOT MATCH THAT OF THE CLIENT"; case MEMCACHED_SERVER_MARKED_DEAD: return "SERVER IS MARKED DEAD"; case MEMCACHED_UNKNOWN_STAT_KEY: return "ENCOUNTERED AN UNKNOWN STAT KEY"; case MEMCACHED_E2BIG: return "ITEM TOO BIG"; case MEMCACHED_INVALID_ARGUMENTS: return "INVALID ARGUMENTS"; case MEMCACHED_KEY_TOO_BIG: return "KEY RETURNED FROM SERVER WAS TOO LARGE"; case MEMCACHED_AUTH_PROBLEM: return "FAILED TO SEND AUTHENTICATION TO SERVER"; case MEMCACHED_AUTH_FAILURE: return "AUTHENTICATION FAILURE"; case MEMCACHED_AUTH_CONTINUE: return "CONTINUE AUTHENTICATION"; case MEMCACHED_PARSE_ERROR: return "ERROR OCCURED WHILE PARSING"; case MEMCACHED_PARSE_USER_ERROR: return "USER INITIATED ERROR OCCURED WHILE PARSING"; case MEMCACHED_DEPRECATED: return "DEPRECATED"; case MEMCACHED_IN_PROGRESS: return "OPERATION IN PROCESS"; case MEMCACHED_SERVER_TEMPORARILY_DISABLED: return "SERVER HAS FAILED AND IS DISABLED UNTIL TIMED RETRY"; case MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE: return "SERVER FAILED TO ALLOCATE OBJECT"; default: case MEMCACHED_MAXIMUM_RETURN: return "INVALID memcached_return_t"; } } libmemcached-1.0.8/libmemcached/continuum.hpp0000664000076400007640000000344111753573717021550 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once /* string value */ struct memcached_continuum_item_st { uint32_t index; uint32_t value; }; libmemcached-1.0.8/libmemcached/behavior.cc0000664000076400007640000005236411753573717021134 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include #include #include #include #include /* This function is used to modify the behavior of running client. We quit all connections so we can reset the sockets. */ memcached_return_t memcached_behavior_set(memcached_st *ptr, const memcached_behavior_t flag, uint64_t data) { if (ptr == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } switch (flag) { case MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS: ptr->number_of_replicas= (uint32_t)data; break; case MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK: ptr->io_msg_watermark= (uint32_t) data; break; case MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK: ptr->io_bytes_watermark= (uint32_t)data; break; case MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH: ptr->io_key_prefetch = (uint32_t)data; break; case MEMCACHED_BEHAVIOR_SND_TIMEOUT: ptr->snd_timeout= (int32_t)data; break; case MEMCACHED_BEHAVIOR_RCV_TIMEOUT: ptr->rcv_timeout= (int32_t)data; break; case MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS: ptr->flags.auto_eject_hosts= bool(data); case MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT: if (data == 0) { return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT requires a value greater then zero.")); } ptr->server_failure_limit= uint32_t(data); break; case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL: send_quit(ptr); // We need t shutdown all of the connections to make sure we do the correct protocol if (data) { ptr->flags.verify_key= false; } ptr->flags.binary_protocol= bool(data); break; case MEMCACHED_BEHAVIOR_SUPPORT_CAS: ptr->flags.support_cas= bool(data); break; case MEMCACHED_BEHAVIOR_NO_BLOCK: ptr->flags.no_block= bool(data); send_quit(ptr); break; case MEMCACHED_BEHAVIOR_BUFFER_REQUESTS: if (memcached_is_udp(ptr)) { return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("MEMCACHED_BEHAVIOR_BUFFER_REQUESTS cannot be set while MEMCACHED_BEHAVIOR_USE_UDP is enabled.")); } ptr->flags.buffer_requests= bool(data); send_quit(ptr); break; case MEMCACHED_BEHAVIOR_USE_UDP: send_quit(ptr); // We need t shutdown all of the connections to make sure we do the correct protocol ptr->flags.use_udp= bool(data); if (bool(data)) { ptr->flags.reply= false; ptr->flags.buffer_requests= false; } else { ptr->flags.reply= true; } break; case MEMCACHED_BEHAVIOR_TCP_NODELAY: ptr->flags.tcp_nodelay= bool(data); send_quit(ptr); break; case MEMCACHED_BEHAVIOR_TCP_KEEPALIVE: ptr->flags.tcp_keepalive= bool(data); send_quit(ptr); break; case MEMCACHED_BEHAVIOR_DISTRIBUTION: return memcached_behavior_set_distribution(ptr, (memcached_server_distribution_t)data); case MEMCACHED_BEHAVIOR_KETAMA: { if (data) // Turn on { return memcached_behavior_set_distribution(ptr, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA); } return memcached_behavior_set_distribution(ptr, MEMCACHED_DISTRIBUTION_MODULA); } case MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED: { (void)memcached_behavior_set_key_hash(ptr, MEMCACHED_HASH_MD5); (void)memcached_behavior_set_distribution_hash(ptr, MEMCACHED_HASH_MD5); ptr->ketama.weighted= bool(data); /** @note We try to keep the same distribution going. This should be deprecated and rewritten. */ return memcached_behavior_set_distribution(ptr, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA); } case MEMCACHED_BEHAVIOR_HASH: return memcached_behavior_set_key_hash(ptr, (memcached_hash_t)(data)); case MEMCACHED_BEHAVIOR_KETAMA_HASH: return memcached_behavior_set_distribution_hash(ptr, (memcached_hash_t)(data)); case MEMCACHED_BEHAVIOR_CACHE_LOOKUPS: return memcached_set_error(*ptr, MEMCACHED_DEPRECATED, MEMCACHED_AT, memcached_literal_param("MEMCACHED_BEHAVIOR_CACHE_LOOKUPS has been deprecated.")); case MEMCACHED_BEHAVIOR_VERIFY_KEY: if (ptr->flags.binary_protocol) { return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("MEMCACHED_BEHAVIOR_VERIFY_KEY if the binary protocol has been enabled.")); } ptr->flags.verify_key= bool(data); break; case MEMCACHED_BEHAVIOR_SORT_HOSTS: { ptr->flags.use_sort_hosts= bool(data); return run_distribution(ptr); } case MEMCACHED_BEHAVIOR_POLL_TIMEOUT: ptr->poll_timeout= (int32_t)data; break; case MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT: ptr->connect_timeout= (int32_t)data; break; case MEMCACHED_BEHAVIOR_RETRY_TIMEOUT: if (data == 0) { return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("MEMCACHED_BEHAVIOR_RETRY_TIMEOUT requires a value greater then zero.")); } ptr->retry_timeout= int32_t(data); break; case MEMCACHED_BEHAVIOR_DEAD_TIMEOUT: ptr->dead_timeout= int32_t(data); break; case MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE: ptr->send_size= (int32_t)data; send_quit(ptr); break; case MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE: ptr->recv_size= (int32_t)data; send_quit(ptr); break; case MEMCACHED_BEHAVIOR_TCP_KEEPIDLE: ptr->tcp_keepidle= (uint32_t)data; send_quit(ptr); break; case MEMCACHED_BEHAVIOR_USER_DATA: return memcached_set_error(*ptr, MEMCACHED_DEPRECATED, MEMCACHED_AT, memcached_literal_param("MEMCACHED_BEHAVIOR_USER_DATA deprecated.")); case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY: ptr->flags.hash_with_namespace= bool(data); break; case MEMCACHED_BEHAVIOR_NOREPLY: if (memcached_is_udp(ptr) and bool(data) == false) { return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("MEMCACHED_BEHAVIOR_NOREPLY cannot be disabled while MEMCACHED_BEHAVIOR_USE_UDP is enabled.")); } // We reverse the logic here to make it easier to understand throughout the // code. ptr->flags.reply= bool(data) ? false : true; break; case MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS: ptr->flags.auto_eject_hosts= bool(data); break; case MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ: srandom((uint32_t) time(NULL)); ptr->flags.randomize_replica_read= bool(data); break; case MEMCACHED_BEHAVIOR_CORK: return memcached_set_error(*ptr, MEMCACHED_DEPRECATED, MEMCACHED_AT, memcached_literal_param("MEMCACHED_BEHAVIOR_CORK is now incorporated into the driver by default.")); case MEMCACHED_BEHAVIOR_LOAD_FROM_FILE: return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("MEMCACHED_BEHAVIOR_LOAD_FROM_FILE can not be set with memcached_behavior_set()")); case MEMCACHED_BEHAVIOR_MAX: default: /* Shouldn't get here */ assert_msg(0, "Invalid behavior passed to memcached_behavior_set()"); return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid behavior passed to memcached_behavior_set()")); } return MEMCACHED_SUCCESS; } bool _is_auto_eject_host(const memcached_st *ptr) { return ptr->flags.auto_eject_hosts; } uint64_t memcached_behavior_get(memcached_st *ptr, const memcached_behavior_t flag) { if (ptr == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } switch (flag) { case MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS: return ptr->number_of_replicas; case MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK: return ptr->io_msg_watermark; case MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK: return ptr->io_bytes_watermark; case MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH: return ptr->io_key_prefetch; case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL: return ptr->flags.binary_protocol; case MEMCACHED_BEHAVIOR_SUPPORT_CAS: return ptr->flags.support_cas; case MEMCACHED_BEHAVIOR_CACHE_LOOKUPS: return true; case MEMCACHED_BEHAVIOR_NO_BLOCK: return ptr->flags.no_block; case MEMCACHED_BEHAVIOR_BUFFER_REQUESTS: return ptr->flags.buffer_requests; case MEMCACHED_BEHAVIOR_USE_UDP: return memcached_is_udp(ptr); case MEMCACHED_BEHAVIOR_TCP_NODELAY: return ptr->flags.tcp_nodelay; case MEMCACHED_BEHAVIOR_VERIFY_KEY: return ptr->flags.verify_key; case MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED: return ptr->ketama.weighted; case MEMCACHED_BEHAVIOR_DISTRIBUTION: return ptr->distribution; case MEMCACHED_BEHAVIOR_KETAMA: return (ptr->distribution == MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA) ? (uint64_t) 1 : 0; case MEMCACHED_BEHAVIOR_HASH: return hashkit_get_function(&ptr->hashkit); case MEMCACHED_BEHAVIOR_KETAMA_HASH: return hashkit_get_function(&ptr->hashkit); case MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS: case MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT: return ptr->server_failure_limit; case MEMCACHED_BEHAVIOR_SORT_HOSTS: return ptr->flags.use_sort_hosts; case MEMCACHED_BEHAVIOR_POLL_TIMEOUT: return (uint64_t)ptr->poll_timeout; case MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT: return (uint64_t)ptr->connect_timeout; case MEMCACHED_BEHAVIOR_RETRY_TIMEOUT: return (uint64_t)ptr->retry_timeout; case MEMCACHED_BEHAVIOR_DEAD_TIMEOUT: return uint64_t(ptr->dead_timeout); case MEMCACHED_BEHAVIOR_SND_TIMEOUT: return (uint64_t)ptr->snd_timeout; case MEMCACHED_BEHAVIOR_RCV_TIMEOUT: return (uint64_t)ptr->rcv_timeout; case MEMCACHED_BEHAVIOR_TCP_KEEPIDLE: return (uint64_t)ptr->tcp_keepidle; case MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE: { int sock_size= 0; socklen_t sock_length= sizeof(int); if (ptr->send_size != -1) // If value is -1 then we are using the default { return (uint64_t) ptr->send_size; } memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, 0); if (instance) // If we have an instance we test, otherwise we just set and pray { /* REFACTOR */ /* We just try the first host, and if it is down we return zero */ if (memcached_failed(memcached_connect(instance))) { return 0; } if (memcached_failed(memcached_io_wait_for_write(instance))) { return 0; } if (getsockopt(instance->fd, SOL_SOCKET, SO_SNDBUF, &sock_size, &sock_length) < 0) { memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT); return 0; /* Zero means error */ } } return (uint64_t) sock_size; } case MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE: { int sock_size= 0; socklen_t sock_length= sizeof(int); if (ptr->recv_size != -1) // If value is -1 then we are using the default return (uint64_t) ptr->recv_size; memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, 0); /** @note REFACTOR */ if (instance) { /* We just try the first host, and if it is down we return zero */ if (memcached_failed(memcached_connect(instance))) { return 0; } if (memcached_failed(memcached_io_wait_for_write(instance))) { return 0; } if (getsockopt(instance->fd, SOL_SOCKET, SO_RCVBUF, &sock_size, &sock_length) < 0) { memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT); return 0; /* Zero means error */ } } return (uint64_t) sock_size; } case MEMCACHED_BEHAVIOR_USER_DATA: memcached_set_error(*ptr, MEMCACHED_DEPRECATED, MEMCACHED_AT, memcached_literal_param("MEMCACHED_BEHAVIOR_USER_DATA deprecated.")); return 0; case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY: return ptr->flags.hash_with_namespace; case MEMCACHED_BEHAVIOR_NOREPLY: return ptr->flags.reply ? false : true; case MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS: return ptr->flags.auto_eject_hosts; case MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ: return ptr->flags.randomize_replica_read; case MEMCACHED_BEHAVIOR_CORK: #ifdef HAVE_MSG_MORE return true; #else return false; #endif case MEMCACHED_BEHAVIOR_TCP_KEEPALIVE: return ptr->flags.tcp_keepalive; case MEMCACHED_BEHAVIOR_LOAD_FROM_FILE: return bool(memcached_parse_filename(ptr)); case MEMCACHED_BEHAVIOR_MAX: default: assert_msg(0, "Invalid behavior passed to memcached_behavior_set()"); return 0; } /* NOTREACHED */ } memcached_return_t memcached_behavior_set_distribution(memcached_st *ptr, memcached_server_distribution_t type) { if (type < MEMCACHED_DISTRIBUTION_CONSISTENT_MAX) { if (MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED) { ptr->ketama.weighted= true; } else { ptr->ketama.weighted= false; } ptr->distribution= type; return run_distribution(ptr); } return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid memcached_server_distribution_t")); } memcached_server_distribution_t memcached_behavior_get_distribution(memcached_st *ptr) { return ptr->distribution; } memcached_return_t memcached_behavior_set_key_hash(memcached_st *ptr, memcached_hash_t type) { if (hashkit_success(hashkit_set_function(&ptr->hashkit, (hashkit_hash_algorithm_t)type))) { return MEMCACHED_SUCCESS; } return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid memcached_hash_t()")); } memcached_hash_t memcached_behavior_get_key_hash(memcached_st *ptr) { return (memcached_hash_t)hashkit_get_function(&ptr->hashkit); } memcached_return_t memcached_behavior_set_distribution_hash(memcached_st *ptr, memcached_hash_t type) { if (hashkit_success(hashkit_set_distribution_function(&ptr->hashkit, (hashkit_hash_algorithm_t)type))) return MEMCACHED_SUCCESS; return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid memcached_hash_t()")); } memcached_hash_t memcached_behavior_get_distribution_hash(memcached_st *ptr) { return (memcached_hash_t)hashkit_get_function(&ptr->hashkit); } const char *libmemcached_string_behavior(const memcached_behavior_t flag) { switch (flag) { case MEMCACHED_BEHAVIOR_NO_BLOCK: return "MEMCACHED_BEHAVIOR_NO_BLOCK"; case MEMCACHED_BEHAVIOR_TCP_NODELAY: return "MEMCACHED_BEHAVIOR_TCP_NODELAY"; case MEMCACHED_BEHAVIOR_HASH: return "MEMCACHED_BEHAVIOR_HASH"; case MEMCACHED_BEHAVIOR_KETAMA: return "MEMCACHED_BEHAVIOR_KETAMA"; case MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE: return "MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE"; case MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE: return "MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE"; case MEMCACHED_BEHAVIOR_CACHE_LOOKUPS: return "MEMCACHED_BEHAVIOR_CACHE_LOOKUPS"; case MEMCACHED_BEHAVIOR_SUPPORT_CAS: return "MEMCACHED_BEHAVIOR_SUPPORT_CAS"; case MEMCACHED_BEHAVIOR_POLL_TIMEOUT: return "MEMCACHED_BEHAVIOR_POLL_TIMEOUT"; case MEMCACHED_BEHAVIOR_DISTRIBUTION: return "MEMCACHED_BEHAVIOR_DISTRIBUTION"; case MEMCACHED_BEHAVIOR_BUFFER_REQUESTS: return "MEMCACHED_BEHAVIOR_BUFFER_REQUESTS"; case MEMCACHED_BEHAVIOR_USER_DATA: return "MEMCACHED_BEHAVIOR_USER_DATA"; case MEMCACHED_BEHAVIOR_SORT_HOSTS: return "MEMCACHED_BEHAVIOR_SORT_HOSTS"; case MEMCACHED_BEHAVIOR_VERIFY_KEY: return "MEMCACHED_BEHAVIOR_VERIFY_KEY"; case MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT: return "MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT"; case MEMCACHED_BEHAVIOR_RETRY_TIMEOUT: return "MEMCACHED_BEHAVIOR_RETRY_TIMEOUT"; case MEMCACHED_BEHAVIOR_DEAD_TIMEOUT: return "MEMCACHED_BEHAVIOR_DEAD_TIMEOUT"; case MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED: return "MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED"; case MEMCACHED_BEHAVIOR_KETAMA_HASH: return "MEMCACHED_BEHAVIOR_KETAMA_HASH"; case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL: return "MEMCACHED_BEHAVIOR_BINARY_PROTOCOL"; case MEMCACHED_BEHAVIOR_SND_TIMEOUT: return "MEMCACHED_BEHAVIOR_SND_TIMEOUT"; case MEMCACHED_BEHAVIOR_RCV_TIMEOUT: return "MEMCACHED_BEHAVIOR_RCV_TIMEOUT"; case MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT: return "MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT"; case MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK: return "MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK"; case MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK: return "MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK"; case MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH: return "MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH"; case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY: return "MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY"; case MEMCACHED_BEHAVIOR_NOREPLY: return "MEMCACHED_BEHAVIOR_NOREPLY"; case MEMCACHED_BEHAVIOR_USE_UDP: return "MEMCACHED_BEHAVIOR_USE_UDP"; case MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS: return "MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS"; case MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS: return "MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS"; case MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS: return "MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS"; case MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ: return "MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ"; case MEMCACHED_BEHAVIOR_CORK: return "MEMCACHED_BEHAVIOR_CORK"; case MEMCACHED_BEHAVIOR_TCP_KEEPALIVE: return "MEMCACHED_BEHAVIOR_TCP_KEEPALIVE"; case MEMCACHED_BEHAVIOR_TCP_KEEPIDLE: return "MEMCACHED_BEHAVIOR_TCP_KEEPIDLE"; case MEMCACHED_BEHAVIOR_LOAD_FROM_FILE: return "MEMCACHED_BEHAVIOR_LOAD_FROM_FILE"; default: case MEMCACHED_BEHAVIOR_MAX: return "INVALID memcached_behavior_t"; } } const char *libmemcached_string_distribution(const memcached_server_distribution_t flag) { switch (flag) { case MEMCACHED_DISTRIBUTION_MODULA: return "MEMCACHED_DISTRIBUTION_MODULA"; case MEMCACHED_DISTRIBUTION_CONSISTENT: return "MEMCACHED_DISTRIBUTION_CONSISTENT"; case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA: return "MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA"; case MEMCACHED_DISTRIBUTION_RANDOM: return "MEMCACHED_DISTRIBUTION_RANDOM"; case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY: return "MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY"; case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED: return "MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED"; case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: return "MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET"; default: case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX: return "INVALID memcached_server_distribution_t"; } } memcached_return_t memcached_bucket_set(memcached_st *self, const uint32_t *host_map, const uint32_t *forward_map, const uint32_t buckets, const uint32_t replicas) { memcached_return_t rc; if (self == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } if (host_map == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } memcached_server_distribution_t old= memcached_behavior_get_distribution(self); if (memcached_failed(rc =memcached_behavior_set_distribution(self, MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET))) { return rc; } if (memcached_failed(rc= memcached_virtual_bucket_create(self, host_map, forward_map, buckets, replicas))) { memcached_behavior_set_distribution(self, old); } return rc; } libmemcached-1.0.8/libmemcached/allocators.cc0000664000076400007640000001121111753573717021462 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include void _libmemcached_free(const memcached_st*, void *mem, void*) { if (mem) { std::free(mem); } } void *_libmemcached_malloc(const memcached_st *, size_t size, void *) { return std::malloc(size); } void *_libmemcached_realloc(const memcached_st*, void *mem, size_t size, void *) { return std::realloc(mem, size); } void *_libmemcached_calloc(const memcached_st *self, size_t nelem, size_t size, void *context) { if (self->allocators.malloc != _libmemcached_malloc) { void *ret = _libmemcached_malloc(self, nelem * size, context); if (ret == NULL) { memset(ret, 0, nelem * size); } return ret; } return std::calloc(nelem, size); } struct memcached_allocator_t memcached_allocators_return_default(void) { static struct memcached_allocator_t global_default_allocator= { _libmemcached_calloc, _libmemcached_free, _libmemcached_malloc, _libmemcached_realloc, 0 }; return global_default_allocator; } memcached_return_t memcached_set_memory_allocators(memcached_st *self, memcached_malloc_fn mem_malloc, memcached_free_fn mem_free, memcached_realloc_fn mem_realloc, memcached_calloc_fn mem_calloc, void *context) { if (self == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } /* All should be set, or none should be set */ if (mem_malloc == NULL and mem_free == NULL and mem_realloc == NULL and mem_calloc == NULL) { self->allocators= memcached_allocators_return_default(); } else if (mem_malloc == NULL or mem_free == NULL or mem_realloc == NULL or mem_calloc == NULL) { return memcached_set_error(*self, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("NULL parameter provided for one or more allocators")); } else { self->allocators.malloc= mem_malloc; self->allocators.free= mem_free; self->allocators.realloc= mem_realloc; self->allocators.calloc= mem_calloc; self->allocators.context= context; } return MEMCACHED_SUCCESS; } void *memcached_get_memory_allocators_context(const memcached_st *self) { return self->allocators.context; } void memcached_get_memory_allocators(const memcached_st *self, memcached_malloc_fn *mem_malloc, memcached_free_fn *mem_free, memcached_realloc_fn *mem_realloc, memcached_calloc_fn *mem_calloc) { if (self == NULL) { return; } if (mem_malloc) { *mem_malloc= self->allocators.malloc; } if (mem_free) { *mem_free= self->allocators.free; } if (mem_realloc) { *mem_realloc= self->allocators.realloc; } if (mem_calloc) { *mem_calloc= self->allocators.calloc; } } libmemcached-1.0.8/libmemcached/connect.hpp0000664000076400007640000000345411753573717021164 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once memcached_return_t memcached_connect_try(memcached_server_write_instance_st ptr); memcached_return_t memcached_connect(memcached_server_write_instance_st ptr); libmemcached-1.0.8/libmemcached/server.cc0000664000076400007640000002333311753573717020635 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ /* This is a partial implementation for fetching/creating memcached_server_st objects. */ #include static inline void _server_init(memcached_server_st *self, memcached_st *root, const memcached_string_t& hostname, in_port_t port, uint32_t weight, memcached_connection_t type) { self->options.is_shutting_down= false; self->options.is_dead= false; self->number_of_hosts= 0; self->cursor_active= 0; self->port= port; self->fd= INVALID_SOCKET; self->io_bytes_sent= 0; self->server_failure_counter= 0; self->server_failure_counter_query_id= 0; self->weight= weight ? weight : 1; // 1 is the default weight value self->io_wait_count.read= 0; self->io_wait_count.write= 0; self->io_wait_count.timeouts= 0; self->major_version= UINT8_MAX; self->micro_version= UINT8_MAX; self->minor_version= UINT8_MAX; self->type= type; self->error_messages= NULL; self->read_ptr= self->read_buffer; self->read_buffer_length= 0; self->read_data_length= 0; self->write_buffer_offset= 0; self->address_info= NULL; self->address_info_next= NULL; self->state= MEMCACHED_SERVER_STATE_NEW; self->next_retry= 0; self->root= root; if (root) { self->version= ++root->server_info.version; } else { self->version= UINT_MAX; } self->limit_maxbytes= 0; memcpy(self->hostname, hostname.c_str, hostname.size); self->hostname[hostname.size]= 0; } static memcached_server_st *_server_create(memcached_server_st *self, const memcached_st *memc) { if (self == NULL) { self= libmemcached_xmalloc(memc, struct memcached_server_st); if (self == NULL) { return NULL; /* MEMCACHED_MEMORY_ALLOCATION_FAILURE */ } self->options.is_allocated= true; } else { self->options.is_allocated= false; } self->options.is_initialized= true; return self; } memcached_server_st *__server_create_with(memcached_st *memc, memcached_server_write_instance_st self, const memcached_string_t& hostname, const in_port_t port, uint32_t weight, const memcached_connection_t type) { if (memcached_is_valid_servername(hostname) == false) { memcached_set_error(*memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid hostname provided")); return NULL; } self= _server_create(self, memc); if (self == NULL) { return NULL; } _server_init(self, const_cast(memc), hostname, port, weight, type); if (memc and memcached_is_udp(memc)) { self->write_buffer_offset= UDP_DATAGRAM_HEADER_LENGTH; memcached_io_init_udp_header(self, 0); } if (memc) { memcached_connect_try(self); } return self; } void __server_free(memcached_server_st *self) { memcached_quit_server(self, false); if (self->address_info) { freeaddrinfo(self->address_info); self->address_info= NULL; self->address_info_next= NULL; } memcached_error_free(*self); if (memcached_is_allocated(self)) { libmemcached_free(self->root, self); } else { self->options.is_initialized= false; } } void memcached_server_free(memcached_server_st *self) { if (self == NULL) { return; } if (memcached_server_list_count(self)) { memcached_server_list_free(self); return; } __server_free(self); } /* If we do not have a valid object to clone from, we toss an error. */ memcached_server_st *memcached_server_clone(memcached_server_st *destination, memcached_server_st *source) { /* We just do a normal create if source is missing */ if (source == NULL) { return NULL; } memcached_string_t hostname= { memcached_string_make_from_cstr(source->hostname) }; destination= __server_create_with(source->root, destination, hostname, source->port, source->weight, source->type); return destination; } memcached_return_t memcached_server_cursor(const memcached_st *ptr, const memcached_server_fn *callback, void *context, uint32_t number_of_callbacks) { memcached_return_t rc; if (memcached_failed(rc= initialize_const_query(ptr))) { return rc; } size_t errors= 0; for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { memcached_server_instance_st instance= memcached_server_instance_by_position(ptr, x); for (uint32_t y= 0; y < number_of_callbacks; y++) { memcached_return_t ret= (*callback[y])(ptr, instance, context); if (memcached_failed(ret)) { errors++; continue; } } } return errors ? MEMCACHED_SOME_ERRORS : MEMCACHED_SUCCESS; } memcached_return_t memcached_server_execute(memcached_st *ptr, memcached_server_execute_fn callback, void *context) { if (callback == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } bool some_errors= false;; for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); memcached_return_t rc= (*callback)(ptr, instance, context); if (rc == MEMCACHED_INVALID_ARGUMENTS) { return rc; } else if (memcached_fatal(rc)) { some_errors= true; } } (void)some_errors; return MEMCACHED_SUCCESS; } memcached_server_instance_st memcached_server_by_key(memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error) { memcached_return_t unused; if (not error) { error= &unused; } memcached_return_t rc; if (memcached_failed(rc= initialize_const_query(ptr))) { *error= rc; return NULL; } if (memcached_failed((memcached_key_test(*ptr, (const char **)&key, &key_length, 1)))) { *error= memcached_last_error(ptr); return NULL; } uint32_t server_key= memcached_generate_hash(ptr, key, key_length); return memcached_server_instance_by_position(ptr, server_key); } void memcached_server_error_reset(memcached_server_st *self) { WATCHPOINT_ASSERT(self); if (self == NULL) { return; } memcached_error_free(*self); } memcached_server_instance_st memcached_server_get_last_disconnect(const memcached_st *self) { WATCHPOINT_ASSERT(self); if (self == NULL) { return 0; } return self->last_disconnected_server; } uint32_t memcached_servers_set_count(memcached_server_st *servers, uint32_t count) { WATCHPOINT_ASSERT(servers); if (servers == NULL) { return 0; } return servers->number_of_hosts= count; } uint32_t memcached_server_count(const memcached_st *self) { WATCHPOINT_ASSERT(self); if (self == NULL) return 0; return self->number_of_hosts; } const char *memcached_server_name(const memcached_server_instance_st self) { WATCHPOINT_ASSERT(self); if (self == NULL) return NULL; return self->hostname; } in_port_t memcached_server_port(const memcached_server_instance_st self) { WATCHPOINT_ASSERT(self); if (self == NULL) return 0; return self->port; } uint32_t memcached_server_response_count(const memcached_server_instance_st self) { WATCHPOINT_ASSERT(self); if (self == NULL) return 0; return self->cursor_active; } const char *memcached_server_type(const memcached_server_instance_st ptr) { if (ptr) { switch (ptr->type) { case MEMCACHED_CONNECTION_TCP: return "TCP"; case MEMCACHED_CONNECTION_UDP: return "UDP"; case MEMCACHED_CONNECTION_UNIX_SOCKET: return "SOCKET"; } } return "UNKNOWN"; } libmemcached-1.0.8/libmemcached/array.c0000664000076400007640000000657311753573717020311 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 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 #include #include struct memcached_array_st { struct memcached_st *root; size_t size; char c_str[]; }; memcached_array_st *memcached_array_clone(struct memcached_st *memc, const memcached_array_st *original) { if (not original) return NULL; return memcached_strcpy(memc, original->c_str, original->size); } memcached_array_st *memcached_strcpy(struct memcached_st *memc, const char *str, size_t str_length) { assert(memc); assert(str); assert(str_length); memcached_array_st *array= (struct memcached_array_st *)libmemcached_malloc(memc, sizeof(struct memcached_array_st) +str_length +1); if (not array) return NULL; array->root= memc; array->size= str_length; // We don't count the NULL ending memcpy(array->c_str, str, str_length); array->c_str[str_length]= 0; return array; } bool memcached_array_is_null(memcached_array_st *array) { assert(array); assert(array->root); if (not array) return false; if (array->size and array->c_str) return false; assert(not array->size and not array->c_str); return true; } memcached_string_t memcached_array_to_string(memcached_array_st *array) { assert(array); assert(array->c_str); assert(array->size); memcached_string_t tmp; tmp.c_str= array->c_str; tmp.size= array->size; return tmp; } void memcached_array_free(memcached_array_st *array) { if (not array) return; WATCHPOINT_ASSERT(array->root); libmemcached_free(array->root, array); } size_t memcached_array_size(memcached_array_st *array) { if (not array) return 0; return array->size; } const char *memcached_array_string(memcached_array_st *array) { if (not array) return NULL; return array->c_str; } libmemcached-1.0.8/libmemcached/array.h0000664000076400007640000000540311753573717020305 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_LOCAL memcached_array_st *memcached_array_clone(struct memcached_st *memc, const memcached_array_st *original); LIBMEMCACHED_LOCAL memcached_array_st *memcached_strcpy(struct memcached_st *memc, const char *str, size_t str_length); LIBMEMCACHED_LOCAL void memcached_array_free(memcached_array_st *array); LIBMEMCACHED_LOCAL size_t memcached_array_size(memcached_array_st *array); LIBMEMCACHED_LOCAL const char *memcached_array_string(memcached_array_st *array); LIBMEMCACHED_LOCAL memcached_string_t memcached_array_to_string(memcached_array_st *array); LIBMEMCACHED_LOCAL bool memcached_array_is_null(memcached_array_st *array); #ifdef __cplusplus } // extern "C" #endif #ifdef __cplusplus #define memcached_print_array(X) static_cast(memcached_array_size(X)), memcached_array_string(X) #define memcached_param_array(X) memcached_array_string(X), memcached_array_size(X) #else #define memcached_print_array(X) (int)memcached_array_size((X)), memcached_array_string((X)) #define memcached_param_array(X) memcached_array_string(X), memcached_array_size(X) #endif libmemcached-1.0.8/libmemcached/touch.cc0000664000076400007640000001403711753573717020452 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include #include static memcached_return_t ascii_touch(memcached_server_write_instance_st instance, const char *key, size_t key_length, time_t expiration) { char expiration_buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; int expiration_buffer_length= snprintf(expiration_buffer, sizeof(expiration_buffer), " %llu", (unsigned long long)expiration); if (size_t(expiration_buffer_length) >= sizeof(expiration_buffer) or expiration_buffer_length < 0) { return memcached_set_error(*instance, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("snprintf(MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH)")); } libmemcached_io_vector_st vector[]= { { NULL, 0 }, { memcached_literal_param("touch ") }, { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) }, { key, key_length }, { expiration_buffer, expiration_buffer_length }, { memcached_literal_param("\r\n") } }; memcached_return_t rc; if (memcached_failed(rc= memcached_vdo(instance, vector, 6, true))) { memcached_io_reset(instance); return memcached_set_error(*instance, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT); } return rc; } static memcached_return_t binary_touch(memcached_server_write_instance_st instance, const char *key, size_t key_length, time_t expiration) { protocol_binary_request_touch request= {}; //{.bytes= {0}}; request.message.header.request.magic= PROTOCOL_BINARY_REQ; request.message.header.request.opcode= PROTOCOL_BINARY_CMD_TOUCH; request.message.header.request.extlen= 4; request.message.header.request.keylen= htons((uint16_t)(key_length +memcached_array_size(instance->root->_namespace))); request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; request.message.header.request.bodylen= htonl((uint32_t)(key_length +memcached_array_size(instance->root->_namespace) +request.message.header.request.extlen)); request.message.body.expiration= htonl((uint32_t) expiration); libmemcached_io_vector_st vector[]= { { NULL, 0 }, { request.bytes, sizeof(request.bytes) }, { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) }, { key, key_length } }; memcached_return_t rc; if (memcached_failed(rc= memcached_vdo(instance, vector, 4, true))) { memcached_io_reset(instance); return memcached_set_error(*instance, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT); } return rc; } memcached_return_t memcached_touch(memcached_st *ptr, const char *key, size_t key_length, time_t expiration) { return memcached_touch_by_key(ptr, key, key_length, key, key_length, expiration); } memcached_return_t memcached_touch_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, time_t expiration) { LIBMEMCACHED_MEMCACHED_TOUCH_START(); memcached_return_t rc; if (memcached_failed(rc= initialize_query(ptr, true))) { return rc; } if (memcached_failed(rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol))) { return rc; } uint32_t server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length); memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, server_key); if (ptr->flags.binary_protocol) { rc= binary_touch(instance, key, key_length, expiration); } else { rc= ascii_touch(instance, key, key_length, expiration); } if (memcached_failed(rc)) { return memcached_set_error(*instance, rc, MEMCACHED_AT, memcached_literal_param("Error occcured while writing touch command to server")); } char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; rc= memcached_response(instance, buffer, sizeof(buffer), NULL); if (rc == MEMCACHED_SUCCESS or rc == MEMCACHED_NOTFOUND) { return rc; } return memcached_set_error(*instance, rc, MEMCACHED_AT, memcached_literal_param("Error occcured while reading response")); } libmemcached-1.0.8/libmemcached/namespace.cc0000664000076400007640000000654411753573717021270 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 #include memcached_return_t memcached_set_namespace(memcached_st *self, const char *key, size_t key_length) { assert_msg(self, "A NULL memcached_st was used"); if (key and key_length == 0) { WATCHPOINT_ASSERT(key_length); return memcached_set_error(*self, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid namespace, namespace string had value but length was 0")); } else if (key_length and key == NULL) { WATCHPOINT_ASSERT(key); return memcached_set_error(*self, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid namespace, namespace string length was > 1 but namespace string was null ")); } else if (key and key_length) { bool orig= self->flags.verify_key; self->flags.verify_key= true; if (memcached_failed(memcached_key_test(*self, (const char **)&key, &key_length, 1))) { self->flags.verify_key= orig; return memcached_last_error(self); } self->flags.verify_key= orig; if ((key_length > MEMCACHED_PREFIX_KEY_MAX_SIZE -1)) { return memcached_set_error(*self, MEMCACHED_KEY_TOO_BIG, MEMCACHED_AT); } memcached_array_free(self->_namespace); self->_namespace= memcached_strcpy(self, key, key_length); if (not self->_namespace) { return memcached_set_error(*self, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); } } else { memcached_array_free(self->_namespace); self->_namespace= NULL; } return MEMCACHED_SUCCESS; } const char * memcached_get_namespace(memcached_st *self) { if (self->_namespace == NULL) { return NULL; } return memcached_array_string(self->_namespace); } libmemcached-1.0.8/libmemcachedprotocol-0.0/0000775000076400007640000000000011757025117021057 5ustar00brianbrian00000000000000libmemcached-1.0.8/libmemcachedprotocol-0.0/binary.h0000664000076400007640000006233211753573717022534 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright (c) <2008>, Sun Microsystems, Inc. * 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. * * Neither the name of the nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY SUN MICROSYSTEMS, INC. ``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 SUN MICROSYSTEMS, INC. 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. */ /* * Summary: Constants used by to implement the binary protocol. * * Copy: See Copyright for the status of this software. * * Author: Trond Norbye */ #ifndef PROTOCOL_BINARY_H #define PROTOCOL_BINARY_H #include /** * \addtogroup Protocol * @{ */ /** * This file contains definitions of the constants and packet formats * defined in the binary specification. Please note that you _MUST_ remember * to convert each multibyte field to / from network byte order to / from * host order. */ #ifdef __cplusplus extern "C" { #endif /** * Definition of the legal "magic" values used in a packet. * See section 3.1 Magic byte */ typedef enum { PROTOCOL_BINARY_REQ = 0x80, PROTOCOL_BINARY_RES = 0x81 } protocol_binary_magic; /** * Definition of the valid response status numbers. * See section 3.2 Response Status */ typedef enum { PROTOCOL_BINARY_RESPONSE_SUCCESS = 0x00, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT = 0x01, PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS = 0x02, PROTOCOL_BINARY_RESPONSE_E2BIG = 0x03, PROTOCOL_BINARY_RESPONSE_EINVAL = 0x04, PROTOCOL_BINARY_RESPONSE_NOT_STORED = 0x05, PROTOCOL_BINARY_RESPONSE_DELTA_BADVAL = 0x06, PROTOCOL_BINARY_RESPONSE_NOT_MY_VBUCKET = 0x07, PROTOCOL_BINARY_RESPONSE_AUTH_ERROR = 0x20, PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE = 0x21, PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND = 0x81, PROTOCOL_BINARY_RESPONSE_ENOMEM = 0x82, PROTOCOL_BINARY_RESPONSE_NOT_SUPPORTED = 0x83, PROTOCOL_BINARY_RESPONSE_EINTERNAL = 0x84, PROTOCOL_BINARY_RESPONSE_EBUSY = 0x85, PROTOCOL_BINARY_RESPONSE_ETMPFAIL = 0x86 } protocol_binary_response_status; /** * Defintion of the different command opcodes. * See section 3.3 Command Opcodes */ typedef enum { PROTOCOL_BINARY_CMD_GET = 0x00, PROTOCOL_BINARY_CMD_SET = 0x01, PROTOCOL_BINARY_CMD_ADD = 0x02, PROTOCOL_BINARY_CMD_REPLACE = 0x03, PROTOCOL_BINARY_CMD_DELETE = 0x04, PROTOCOL_BINARY_CMD_INCREMENT = 0x05, PROTOCOL_BINARY_CMD_DECREMENT = 0x06, PROTOCOL_BINARY_CMD_QUIT = 0x07, PROTOCOL_BINARY_CMD_FLUSH = 0x08, PROTOCOL_BINARY_CMD_GETQ = 0x09, PROTOCOL_BINARY_CMD_NOOP = 0x0a, PROTOCOL_BINARY_CMD_VERSION = 0x0b, PROTOCOL_BINARY_CMD_GETK = 0x0c, PROTOCOL_BINARY_CMD_GETKQ = 0x0d, PROTOCOL_BINARY_CMD_APPEND = 0x0e, PROTOCOL_BINARY_CMD_PREPEND = 0x0f, PROTOCOL_BINARY_CMD_STAT = 0x10, PROTOCOL_BINARY_CMD_SETQ = 0x11, PROTOCOL_BINARY_CMD_ADDQ = 0x12, PROTOCOL_BINARY_CMD_REPLACEQ = 0x13, PROTOCOL_BINARY_CMD_DELETEQ = 0x14, PROTOCOL_BINARY_CMD_INCREMENTQ = 0x15, PROTOCOL_BINARY_CMD_DECREMENTQ = 0x16, PROTOCOL_BINARY_CMD_QUITQ = 0x17, PROTOCOL_BINARY_CMD_FLUSHQ = 0x18, PROTOCOL_BINARY_CMD_APPENDQ = 0x19, PROTOCOL_BINARY_CMD_PREPENDQ = 0x1a, PROTOCOL_BINARY_CMD_VERBOSITY = 0x1b, PROTOCOL_BINARY_CMD_TOUCH = 0x1c, PROTOCOL_BINARY_CMD_GAT = 0x1d, PROTOCOL_BINARY_CMD_GATQ = 0x1e, PROTOCOL_BINARY_CMD_GATK = 0x23, PROTOCOL_BINARY_CMD_GATKQ = 0x24, PROTOCOL_BINARY_CMD_SASL_LIST_MECHS = 0x20, PROTOCOL_BINARY_CMD_SASL_AUTH = 0x21, PROTOCOL_BINARY_CMD_SASL_STEP = 0x22, /* These commands are used for range operations and exist within * this header for use in other projects. Range operations are * not expected to be implemented in the memcached server itself. */ PROTOCOL_BINARY_CMD_RGET = 0x30, PROTOCOL_BINARY_CMD_RSET = 0x31, PROTOCOL_BINARY_CMD_RSETQ = 0x32, PROTOCOL_BINARY_CMD_RAPPEND = 0x33, PROTOCOL_BINARY_CMD_RAPPENDQ = 0x34, PROTOCOL_BINARY_CMD_RPREPEND = 0x35, PROTOCOL_BINARY_CMD_RPREPENDQ = 0x36, PROTOCOL_BINARY_CMD_RDELETE = 0x37, PROTOCOL_BINARY_CMD_RDELETEQ = 0x38, PROTOCOL_BINARY_CMD_RINCR = 0x39, PROTOCOL_BINARY_CMD_RINCRQ = 0x3a, PROTOCOL_BINARY_CMD_RDECR = 0x3b, PROTOCOL_BINARY_CMD_RDECRQ = 0x3c, /* End Range operations */ /* VBucket commands */ PROTOCOL_BINARY_CMD_SET_VBUCKET = 0x3d, PROTOCOL_BINARY_CMD_GET_VBUCKET = 0x3e, PROTOCOL_BINARY_CMD_DEL_VBUCKET = 0x3f, /* End VBucket commands */ /* TAP commands */ PROTOCOL_BINARY_CMD_TAP_CONNECT = 0x40, PROTOCOL_BINARY_CMD_TAP_MUTATION = 0x41, PROTOCOL_BINARY_CMD_TAP_DELETE = 0x42, PROTOCOL_BINARY_CMD_TAP_FLUSH = 0x43, PROTOCOL_BINARY_CMD_TAP_OPAQUE = 0x44, PROTOCOL_BINARY_CMD_TAP_VBUCKET_SET = 0x45, PROTOCOL_BINARY_CMD_TAP_CHECKPOINT_START = 0x46, PROTOCOL_BINARY_CMD_TAP_CHECKPOINT_END = 0x47, /* End TAP */ PROTOCOL_BINARY_CMD_LAST_RESERVED = 0xef, /* Scrub the data */ PROTOCOL_BINARY_CMD_SCRUB = 0xf0 } protocol_binary_command; /** * Definition of the data types in the packet * See section 3.4 Data Types */ typedef enum { PROTOCOL_BINARY_RAW_BYTES = 0x00 } protocol_binary_datatypes; /** * Definition of the header structure for a request packet. * See section 2 */ typedef union { struct { uint8_t magic; uint8_t opcode; uint16_t keylen; uint8_t extlen; uint8_t datatype; uint16_t vbucket; uint32_t bodylen; uint32_t opaque; uint64_t cas; } request; uint8_t bytes[24]; } protocol_binary_request_header; /** * Definition of the header structure for a response packet. * See section 2 */ typedef union { struct { uint8_t magic; uint8_t opcode; uint16_t keylen; uint8_t extlen; uint8_t datatype; uint16_t status; uint32_t bodylen; uint32_t opaque; uint64_t cas; } response; uint8_t bytes[24]; } protocol_binary_response_header; /** * Definition of a request-packet containing no extras */ union protocol_binary_request_no_extras { struct { protocol_binary_request_header header; } message; uint8_t bytes[sizeof(protocol_binary_request_header)]; }; typedef union protocol_binary_request_no_extras protocol_binary_request_no_extras; /** * Definition of a response-packet containing no extras */ typedef union { struct { protocol_binary_response_header header; } message; uint8_t bytes[sizeof(protocol_binary_response_header)]; } protocol_binary_response_no_extras; /** * Definition of the packet used by the get, getq, getk and getkq command. * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_get; typedef protocol_binary_request_no_extras protocol_binary_request_getq; typedef protocol_binary_request_no_extras protocol_binary_request_getk; typedef protocol_binary_request_no_extras protocol_binary_request_getkq; /** * Definition of the packet returned from a successful get, getq, getk and * getkq. * See section 4 */ typedef union { struct { protocol_binary_response_header header; struct { uint32_t flags; } body; } message; uint8_t bytes[sizeof(protocol_binary_response_header) + 4]; } protocol_binary_response_get; typedef protocol_binary_response_get protocol_binary_response_getq; typedef protocol_binary_response_get protocol_binary_response_getk; typedef protocol_binary_response_get protocol_binary_response_getkq; /** * Definition of the packet used by the delete command * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_delete; /** * Definition of the packet returned by the delete command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_delete; /** * Definition of the packet used by the flush command * See section 4 * Please note that the expiration field is optional, so remember to see * check the header.bodysize to see if it is present. */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_flush; /** * Definition of the packet returned by the flush command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_flush; /** * Definition of the packet used by set, add and replace * See section 4 */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t flags; uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 8]; } protocol_binary_request_set; typedef protocol_binary_request_set protocol_binary_request_add; typedef protocol_binary_request_set protocol_binary_request_replace; /** * Definition of the packet returned by set, add and replace * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_set; typedef protocol_binary_response_no_extras protocol_binary_response_add; typedef protocol_binary_response_no_extras protocol_binary_response_replace; /** * Definition of the noop packet * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_noop; /** * Definition of the packet returned by the noop command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_noop; /** * Definition of the structure used by the increment and decrement * command. * See section 4 */ typedef union { struct { protocol_binary_request_header header; struct { uint64_t delta; uint64_t initial; uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 20]; } protocol_binary_request_incr; typedef protocol_binary_request_incr protocol_binary_request_decr; /** * Definition of the response from an incr or decr command * command. * See section 4 */ typedef union { struct { protocol_binary_response_header header; struct { uint64_t value; } body; } message; uint8_t bytes[sizeof(protocol_binary_response_header) + 8]; } protocol_binary_response_incr; typedef protocol_binary_response_incr protocol_binary_response_decr; /** * Definition of the quit * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_quit; /** * Definition of the packet returned by the quit command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_quit; /** * Definition of the packet used by append and prepend command * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_append; typedef protocol_binary_request_no_extras protocol_binary_request_prepend; /** * Definition of the packet returned from a successful append or prepend * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_append; typedef protocol_binary_response_no_extras protocol_binary_response_prepend; /** * Definition of the packet used by the version command * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_version; /** * Definition of the packet returned from a successful version command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_version; /** * Definition of the packet used by the stats command. * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_stats; /** * Definition of the packet returned from a successful stats command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_stats; /** * Definition of the packet used by the verbosity command */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t level; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_verbosity; /** * Definition of the packet returned from the verbosity command */ typedef protocol_binary_response_no_extras protocol_binary_response_verbosity; /** * Definition of the packet used by the touch command. */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_touch; /** * Definition of the packet returned from the touch command */ typedef protocol_binary_response_no_extras protocol_binary_response_touch; /** * Definition of the packet used by the GAT(Q) command. */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_gat; typedef protocol_binary_request_gat protocol_binary_request_gatq; /** * Definition of the packet returned from the GAT(Q) */ typedef protocol_binary_response_get protocol_binary_response_gat; typedef protocol_binary_response_get protocol_binary_response_gatq; /** * Definition of a request for a range operation. * See http://code.google.com/p/memcached/wiki/RangeOps * * These types are used for range operations and exist within * this header for use in other projects. Range operations are * not expected to be implemented in the memcached server itself. */ typedef union { struct { protocol_binary_response_header header; struct { uint16_t size; uint8_t reserved; uint8_t flags; uint32_t max_results; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_rangeop; typedef protocol_binary_request_rangeop protocol_binary_request_rget; typedef protocol_binary_request_rangeop protocol_binary_request_rset; typedef protocol_binary_request_rangeop protocol_binary_request_rsetq; typedef protocol_binary_request_rangeop protocol_binary_request_rappend; typedef protocol_binary_request_rangeop protocol_binary_request_rappendq; typedef protocol_binary_request_rangeop protocol_binary_request_rprepend; typedef protocol_binary_request_rangeop protocol_binary_request_rprependq; typedef protocol_binary_request_rangeop protocol_binary_request_rdelete; typedef protocol_binary_request_rangeop protocol_binary_request_rdeleteq; typedef protocol_binary_request_rangeop protocol_binary_request_rincr; typedef protocol_binary_request_rangeop protocol_binary_request_rincrq; typedef protocol_binary_request_rangeop protocol_binary_request_rdecr; typedef protocol_binary_request_rangeop protocol_binary_request_rdecrq; /** * Definition of tap commands * See To be written * */ typedef union { struct { protocol_binary_request_header header; struct { /** * flags is a bitmask used to set properties for the * the connection. Please In order to be forward compatible * you should set all undefined bits to 0. * * If the bit require extra userdata, it will be stored * in the user-data field of the body (passed to the engine * as enginespeciffic). That means that when you parse the * flags and the engine-specific data, you have to work your * way from bit 0 and upwards to find the correct offset for * the data. * */ uint32_t flags; /** * Backfill age * * By using this flag you can limit the amount of data being * transmitted. If you don't specify a backfill age, the * server will transmit everything it contains. * * The first 8 bytes in the engine specific data contains * the oldest entry (from epoc) you're interested in. * Specifying a time in the future (for the server you are * connecting to), will cause it to start streaming current * changes. */ #define TAP_CONNECT_FLAG_BACKFILL 0x01 /** * Dump will cause the server to send the data stored on the * server, but disconnect when the keys stored in the server * are transmitted. */ #define TAP_CONNECT_FLAG_DUMP 0x02 /** * The body contains a list of 16 bits words in network byte * order specifying the vbucket ids to monitor. The first 16 * bit word contains the number of buckets. The number of 0 * means "all buckets" */ #define TAP_CONNECT_FLAG_LIST_VBUCKETS 0x04 /** * The responsibility of the vbuckets is to be transferred * over to the caller when all items are transferred. */ #define TAP_CONNECT_FLAG_TAKEOVER_VBUCKETS 0x08 /** * The tap consumer supports ack'ing of tap messages */ #define TAP_CONNECT_SUPPORT_ACK 0x10 /** * The tap consumer would prefer to just get the keys * back. If the engine supports this it will set * the TAP_FLAG_NO_VALUE flag in each of the * tap packets returned. */ #define TAP_CONNECT_REQUEST_KEYS_ONLY 0x20 /** * The body contains a list of (vbucket_id, last_checkpoint_id) * pairs. This provides the checkpoint support in TAP streams. * The last checkpoint id represents the last checkpoint that * was successfully persisted. */ #define TAP_CONNECT_CHECKPOINT 0x40 /** * The tap consumer is a registered tap client, which means that * the tap server will maintain its checkpoint cursor permanently. */ #define TAP_CONNECT_REGISTERED_CLIENT 0x80 } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_tap_connect; typedef union { struct { protocol_binary_request_header header; struct { struct { uint16_t enginespecific_length; /* * The flag section support the following flags */ /** * Request that the consumer send a response packet * for this packet. The opaque field must be preserved * in the response. */ #define TAP_FLAG_ACK 0x01 /** * The value for the key is not included in the packet */ #define TAP_FLAG_NO_VALUE 0x02 uint16_t flags; uint8_t ttl; uint8_t res1; uint8_t res2; uint8_t res3; } tap; struct { uint32_t flags; uint32_t expiration; } item; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 16]; } protocol_binary_request_tap_mutation; typedef union { struct { protocol_binary_request_header header; struct { struct { uint16_t enginespecific_length; /** * See the definition of the flags for * protocol_binary_request_tap_mutation for a description * of the available flags. */ uint16_t flags; uint8_t ttl; uint8_t res1; uint8_t res2; uint8_t res3; } tap; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 8]; } protocol_binary_request_tap_no_extras; typedef protocol_binary_request_tap_no_extras protocol_binary_request_tap_delete; typedef protocol_binary_request_tap_no_extras protocol_binary_request_tap_flush; typedef protocol_binary_request_tap_no_extras protocol_binary_request_tap_opaque; typedef protocol_binary_request_tap_no_extras protocol_binary_request_tap_vbucket_set; /** * Definition of the packet used by the scrub. */ typedef protocol_binary_request_no_extras protocol_binary_request_scrub; /** * Definition of the packet returned from scrub. */ typedef protocol_binary_response_no_extras protocol_binary_response_scrub; /** * Definition of the packet used by set vbucket */ typedef union { struct { protocol_binary_request_header header; struct { vbucket_state_t state; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + sizeof(vbucket_state_t)]; } protocol_binary_request_set_vbucket; /** * Definition of the packet returned from set vbucket */ typedef protocol_binary_response_no_extras protocol_binary_response_set_vbucket; /** * Definition of the packet used by del vbucket */ typedef protocol_binary_request_no_extras protocol_binary_request_del_vbucket; /** * Definition of the packet returned from del vbucket */ typedef protocol_binary_response_no_extras protocol_binary_response_del_vbucket; /** * Definition of the packet used by get vbucket */ typedef protocol_binary_request_no_extras protocol_binary_request_get_vbucket; /** * Definition of the packet returned from get vbucket */ typedef union { struct { protocol_binary_response_header header; struct { vbucket_state_t state; } body; } message; uint8_t bytes[sizeof(protocol_binary_response_header) + sizeof(vbucket_state_t)]; } protocol_binary_response_get_vbucket; /** * @} */ #ifdef __cplusplus } #endif #endif /* PROTOCOL_BINARY_H */ libmemcached-1.0.8/libmemcachedprotocol-0.0/include.am0000664000076400007640000000044711753573717023040 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root nobase_include_HEADERS+= \ libmemcachedprotocol-0.0/binary.h \ libmemcachedprotocol-0.0/callback.h \ libmemcachedprotocol-0.0/handler.h \ libmemcachedprotocol-0.0/vbucket.h libmemcached-1.0.8/libmemcachedprotocol-0.0/vbucket.h0000664000076400007640000000426611753573717022715 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif typedef enum { vbucket_state_active = 1, /**< Actively servicing a vbucket. */ vbucket_state_replica, /**< Servicing a vbucket as a replica only. */ vbucket_state_pending, /**< Pending active. */ vbucket_state_dead /**< Not in use, pending deletion. */ } vbucket_state_t; #define is_valid_vbucket_state_t(state) \ (state == vbucket_state_active || \ state == vbucket_state_replica || \ state == vbucket_state_pending || \ state == vbucket_state_dead) #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcachedprotocol-0.0/handler.h0000664000076400007640000001606611753573717022670 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: Definition of the callback interface to the protocol handler * * Author: Trond Norbye * */ #pragma once #include #if !defined(__cplusplus) # include #endif #include #include #include #include /* Forward declarations */ /* * You should only access memcached_protocol_st from one thread!, * and never assume anything about the internal layout / sizes of the * structures. */ typedef struct memcached_protocol_st memcached_protocol_st; typedef struct memcached_protocol_client_st memcached_protocol_client_st; #ifdef __cplusplus extern "C" { #endif /** * Function the protocol handler should call to receive data. * This function should behave exactly like read(2) * * @param cookie a cookie used to represent a given client * @param fd the filedescriptor associated with the client * @param buf destination buffer * @param nbuf number of bytes to receive * @return the number of bytes copied into buf * or -1 upon error (errno should contain more information) */ typedef ssize_t (*memcached_protocol_recv_func)(const void *cookie, memcached_socket_t fd, void *buf, size_t nbuf); /** * Function the protocol handler should call to send data. * This function should behave exactly like write(2) * * @param cookie a cookie used to represent a given client * @param fd the filedescriptor associated with the client * @param buf the source buffer * @param nbuf number of bytes to send * @return the number of bytes sent * or -1 upon error (errno should contain more information) */ typedef ssize_t (*memcached_protocol_send_func)(const void *cookie, memcached_socket_t fd, const void *buf, size_t nbuf); /** * Create an instance of the protocol handler * * @return NULL if allocation of an instance fails */ LIBMEMCACHED_API memcached_protocol_st *memcached_protocol_create_instance(void); /** * Get the callbacks associated with a protocol handler instance * @return the callbacks currently used */ LIBMEMCACHED_API memcached_binary_protocol_callback_st *memcached_binary_protocol_get_callbacks(memcached_protocol_st *instance); /** * Set the callbacks to be used by the given protocol handler instance * @param instance the instance to update * @param callback the callbacks to use */ LIBMEMCACHED_API void memcached_binary_protocol_set_callbacks(memcached_protocol_st *instance, memcached_binary_protocol_callback_st *callback); /** * Should the library inspect the packages being sent and received and verify * that they are according to the specification? If it encounters an invalid * packet, it will return an EINVAL packet. * * @param instance the instance to update * @param enable true if you want the library to check packages, false otherwise */ LIBMEMCACHED_API void memcached_binary_protocol_set_pedantic(memcached_protocol_st *instance, bool enable); /** * Is the library inpecting each package? * @param instance the instance to check * @return true it the library is inspecting each package, false otherwise */ LIBMEMCACHED_API bool memcached_binary_protocol_get_pedantic(memcached_protocol_st *instance); /** * Destroy an instance of the protocol handler * * @param instance The instance to destroy */ LIBMEMCACHED_API void memcached_protocol_destroy_instance(memcached_protocol_st *instance); /** * Set the IO functions used by the instance to send and receive data. The * functions should behave like recv(3socket) and send(3socket). * * @param instance the instance to specify the IO functions for * @param recv the function to call for reciving data * @param send the function to call for sending data */ LIBMEMCACHED_API void memached_protocol_set_io_functions(memcached_protocol_st *instance, memcached_protocol_recv_func recv, memcached_protocol_send_func send); /** * Create a new client instance and associate it with a socket * @param instance the protocol instance to bind the client to * @param sock the client socket * @return NULL if allocation fails, otherwise an instance */ LIBMEMCACHED_API memcached_protocol_client_st *memcached_protocol_create_client(memcached_protocol_st *instance, memcached_socket_t sock); /** * Destroy a client handle. * The caller needs to close the socket accociated with the client * before calling this function. This function invalidates the * client memory area. * * @param client the client to destroy */ LIBMEMCACHED_API void memcached_protocol_client_destroy(memcached_protocol_client_st *client); LIBMEMCACHED_API void memcached_protocol_client_set_verbose(struct memcached_protocol_client_st *client, bool arg); /** * Error event means that the client encountered an error with the * connection so you should shut it down */ #define MEMCACHED_PROTOCOL_ERROR_EVENT 1 /** * Please notify when there is more data available to read */ #define MEMCACHED_PROTOCOL_READ_EVENT 2 /** * Please notify when it is possible to send more data */ #define MEMCACHED_PROTOCOL_WRITE_EVENT 4 /** * Backed paused the execution for this client */ #define MEMCACHED_PROTOCOL_PAUSE_EVENT 8 /** * The different events the client is interested in. This is a bitmask of * the constants defined above. */ typedef uint32_t memcached_protocol_event_t; /** * Let the client do some work. This might involve reading / sending data * to/from the client, or perform callbacks to execute a command. * @param client the client structure to work on * @return The next event the protocol handler will be notified for */ LIBMEMCACHED_API memcached_protocol_event_t memcached_protocol_client_work(memcached_protocol_client_st *client); /** * Get the socket attached to a client handle * @param client the client to query * @return the socket handle */ LIBMEMCACHED_API memcached_socket_t memcached_protocol_client_get_socket(memcached_protocol_client_st *client); /** * Get the error id socket attached to a client handle * @param client the client to query for an error code * @return the OS error code from the client */ LIBMEMCACHED_API int memcached_protocol_client_get_errno(memcached_protocol_client_st *client); /** * Get a raw response handler for the given cookie * @param cookie the cookie passed along into the callback * @return the raw reponse handler you may use if you find * the generic callback too limiting */ LIBMEMCACHED_API memcached_binary_protocol_raw_response_handler memcached_binary_protocol_get_raw_response_handler(const void *cookie); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcachedprotocol-0.0/callback.h0000664000076400007640000004200311753573717022775 0ustar00brianbrian00000000000000/* * Summary: Definition of the callback interface * * Copy: See Copyright for the status of this software. * * Author: Trond Norbye */ #pragma once /** * Callback to send data back from a successful GET/GETQ/GETK/GETKQ command * * @param cookie Just pass along the cookie supplied in the callback * @param key What to insert as key in the reply * @param keylen The length of the key * @param body What to store in the body of the package * @param bodylen The number of bytes of the body * @param flags The flags stored with the item * @param cas The CAS value to insert into the response (should be 0 * if you don't care) */ typedef protocol_binary_response_status (*memcached_binary_protocol_get_response_handler)(const void *cookie, const void *key, uint16_t keylen, const void *body, uint32_t bodylen, uint32_t flags, uint64_t cas); /** * Callback to send data back from a STAT command * * @param cookie Just pass along the cookie supplied in the callback * @param key What to insert as key in the reply * @param keylen The length of the key * @param body What to store in the body of the package * @param bodylen The number of bytes of the body */ typedef protocol_binary_response_status (*memcached_binary_protocol_stat_response_handler)(const void *cookie, const void *key, uint16_t keylen, const void *body, uint32_t bodylen); /** * Callback to send data back from a VERSION command * * @param cookie Just pass along the cookie supplied in the callback * @param text The version string * @param length The number of bytes in the version string */ typedef protocol_binary_response_status (*memcached_binary_protocol_version_response_handler)(const void *cookie, const void *text, uint32_t length); /** * In the low level interface you need to format the response * packet yourself (giving you complete freedom :-) * * @param cookie Just pass along the cookie supplied in the callback * @param request Pointer to the request packet you are sending a reply to * @param response Pointer to the response packet to send * */ typedef protocol_binary_response_status (*memcached_binary_protocol_raw_response_handler)(const void *cookie, protocol_binary_request_header *request, protocol_binary_response_header *response); /** * In the low lever interface you have to do most of the work by * yourself, but it also gives you a lot of freedom :-) * @param cookie identification for this connection, just pass it along to * the response handler * @param header the command received over the wire. Never try to access * anything outside the command. * @param resonse_handler call this function to send data back to the client */ typedef protocol_binary_response_status (*memcached_binary_protocol_command_handler)(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler); /** * The raw interface to the packets is implemented in version 0. It contains * just an array with command handlers. The inxed in the array is the * com code. */ typedef struct { memcached_binary_protocol_command_handler comcode[256]; } memcached_binary_protocol_callback_v0_st; /** * The first version of the callback struct containing all of the * documented commands in the initial release of the binary protocol * (aka. memcached 1.4.0). * * You might miss the Q commands (addq etc) but the response function * knows how to deal with them so you don't need to worry about that :-) */ typedef struct { /** * Add an item to the cache * @param cookie id of the client receiving the command * @param key the key to add * @param len the length of the key * @param val the value to store for the key (may be NIL) * @param vallen the length of the data * @param flags the flags to store with the key * @param exptime the expiry time for the key-value pair * @param cas the resulting cas for the add operation (if success) */ protocol_binary_response_status (*add)(const void *cookie, const void *key, uint16_t keylen, const void* val, uint32_t vallen, uint32_t flags, uint32_t exptime, uint64_t *cas); /** * Append data to an existing key-value pair. * * @param cookie id of the client receiving the command * @param key the key to add data to * @param len the length of the key * @param val the value to append to the value * @param vallen the length of the data * @param cas the CAS in the request * @param result_cas the resulting cas for the append operation * */ protocol_binary_response_status (*append)(const void *cookie, const void *key, uint16_t keylen, const void* val, uint32_t vallen, uint64_t cas, uint64_t *result_cas); /** * Decrement the value for a key * * @param cookie id of the client receiving the command * @param key the key to decrement the value for * @param len the length of the key * @param delta the amount to decrement * @param initial initial value to store (if the key doesn't exist) * @param expiration expiration time for the object (if the key doesn't exist) * @param cas the CAS in the request * @param result the result from the decrement * @param result_cas the cas of the item * */ protocol_binary_response_status (*decrement)(const void *cookie, const void *key, uint16_t keylen, uint64_t delta, uint64_t initial, uint32_t expiration, uint64_t *result, uint64_t *result_cas); /** * Delete an existing key * * @param cookie id of the client receiving the command * @param key the key to delete_object * @param len the length of the key * @param cas the CAS in the request */ protocol_binary_response_status (*delete_object)(const void *cookie, const void *key, uint16_t keylen, uint64_t cas); /** * Flush the cache * * @param cookie id of the client receiving the command * @param when when the cache should be flushed (0 == immediately) */ protocol_binary_response_status (*flush_object)(const void *cookie, uint32_t when); /** * Get a key-value pair * * @param cookie id of the client receiving the command * @param key the key to get * @param len the length of the key * @param response_handler to send the result back to the client */ protocol_binary_response_status (*get)(const void *cookie, const void *key, uint16_t keylen, memcached_binary_protocol_get_response_handler response_handler); /** * Increment the value for a key * * @param cookie id of the client receiving the command * @param key the key to increment the value on * @param len the length of the key * @param delta the amount to increment * @param initial initial value to store (if the key doesn't exist) * @param expiration expiration time for the object (if the key doesn't exist) * @param cas the CAS in the request * @param result the result from the decrement * @param result_cas the cas of the item * */ protocol_binary_response_status (*increment)(const void *cookie, const void *key, uint16_t keylen, uint64_t delta, uint64_t initial, uint32_t expiration, uint64_t *result, uint64_t *result_cas); /** * The noop command was received. This is just a notification callback (the * response is automatically created). * * @param cookie id of the client receiving the command */ protocol_binary_response_status (*noop)(const void *cookie); /** * Prepend data to an existing key-value pair. * * @param cookie id of the client receiving the command * @param key the key to prepend data to * @param len the length of the key * @param val the value to prepend to the value * @param vallen the length of the data * @param cas the CAS in the request * @param result-cas the cas id of the item * */ protocol_binary_response_status (*prepend)(const void *cookie, const void *key, uint16_t keylen, const void* val, uint32_t vallen, uint64_t cas, uint64_t *result_cas); /** * The quit command was received. This is just a notification callback (the * response is automatically created). * * @param cookie id of the client receiving the command */ protocol_binary_response_status (*quit)(const void *cookie); /** * Replace an existing item to the cache * * @param cookie id of the client receiving the command * @param key the key to replace the content for * @param len the length of the key * @param val the value to store for the key (may be NIL) * @param vallen the length of the data * @param flags the flags to store with the key * @param exptime the expiry time for the key-value pair * @param cas the cas id in the request * @param result_cas the cas id of the item */ protocol_binary_response_status (*replace)(const void *cookie, const void *key, uint16_t keylen, const void* val, uint32_t vallen, uint32_t flags, uint32_t exptime, uint64_t cas, uint64_t *result_cas); /** * Set a key-value pair in the cache * * @param cookie id of the client receiving the command * @param key the key to insert * @param len the length of the key * @param val the value to store for the key (may be NIL) * @param vallen the length of the data * @param flags the flags to store with the key * @param exptime the expiry time for the key-value pair * @param cas the cas id in the request * @param result_cas the cas id of the new item */ protocol_binary_response_status (*set)(const void *cookie, const void *key, uint16_t keylen, const void* val, uint32_t vallen, uint32_t flags, uint32_t exptime, uint64_t cas, uint64_t *result_cas); /** * Get status information * * @param cookie id of the client receiving the command * @param key the key to get status for (or NIL to request all status). * Remember to insert the terminating packet if multiple * packets should be returned. * @param keylen the length of the key * @param response_handler to send the result back to the client, but * don't send reply on success! * */ protocol_binary_response_status (*stat)(const void *cookie, const void *key, uint16_t keylen, memcached_binary_protocol_stat_response_handler response_handler); /** * Get the version information * * @param cookie id of the client receiving the command * @param response_handler to send the result back to the client, but * don't send reply on success! * */ protocol_binary_response_status (*version)(const void *cookie, memcached_binary_protocol_version_response_handler response_handler); } memcached_binary_protocol_callback_v1_st; /** * The version numbers for the different callback structures. */ typedef enum { /** Version 0 is a lowlevel interface that tries to maximize your freedom */ MEMCACHED_PROTOCOL_HANDLER_V0= 0, /** * Version 1 abstracts more of the protocol details, and let you work at * a logical level */ MEMCACHED_PROTOCOL_HANDLER_V1= 1 } memcached_protocol_interface_version_t; /** * Definition of the protocol callback structure. */ typedef struct { /** * The interface version you provide callbacks for. */ memcached_protocol_interface_version_t interface_version; /** * Callback fired just before the command will be executed. * * @param cookie id of the client receiving the command * @param header the command header as received on the wire. If you look * at the content you must ensure that you don't * try to access beyond the end of the message. */ void (*pre_execute)(const void *cookie, protocol_binary_request_header *header); /** * Callback fired just after the command was exected (please note * that the data transfer back to the client is not finished at this * time). * * @param cookie id of the client receiving the command * @param header the command header as received on the wire. If you look * at the content you must ensure that you don't * try to access beyond the end of the message. */ void (*post_execute)(const void *cookie, protocol_binary_request_header *header); /** * Callback fired if no specialized callback is registered for this * specific command code. * * @param cookie id of the client receiving the command * @param header the command header as received on the wire. You must * ensure that you don't try to access beyond the end of the * message. * @param response_handler The response handler to send data back. */ protocol_binary_response_status (*unknown)(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler); /** * The different interface levels we support. A pointer is used so the * size of the structure is fixed. You must ensure that the memory area * passed as the pointer is valid as long as you use the protocol handler. */ union { memcached_binary_protocol_callback_v0_st v0; /** * The first version of the callback struct containing all of the * documented commands in the initial release of the binary protocol * (aka. memcached 1.4.0). */ memcached_binary_protocol_callback_v1_st v1; } interface; } memcached_binary_protocol_callback_st; libmemcached-1.0.8/aclocal.m40000664000076400007640000011373111756761702016261 0ustar00brianbrian00000000000000# generated automatically by aclocal 1.11.1 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, [m4_warning([this file was generated for autoconf 2.68. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.11.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.11.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 10 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_PROG_CC_C_O # -------------- # Like AC_PROG_CC_C_O, but changed for automake. AC_DEFUN([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC_C_O])dnl AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi dnl Make sure AC_PROG_CC is never called again, or it will override our dnl setting of CC. m4_define([AC_PROG_CC], [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])]) ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # ------------------------------ # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ---------------------------------- # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # (`yes' being less verbose, `no' or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [ --enable-silent-rules less verbose build output (undo: `make V=1') --disable-silent-rules verbose build output (undo: `make V=0')]) case $enable_silent_rules in yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([m4/ax_check_library.m4]) m4_include([m4/ax_compiler_vendor.m4]) m4_include([m4/ax_cxx_gcc_abi_demangle.m4]) m4_include([m4/ax_cxx_header_stdcxx_98.m4]) m4_include([m4/ax_pthread.m4]) m4_include([m4/ax_sasl.m4]) m4_include([m4/ax_with_prog.m4]) m4_include([m4/bottom.m4]) m4_include([m4/byteorder.m4]) m4_include([m4/deprecated.m4]) m4_include([m4/fnv.m4]) m4_include([m4/have_cinttypes.m4]) m4_include([m4/have_cstdint.m4]) m4_include([m4/hsieh.m4]) m4_include([m4/lib-prefix.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) m4_include([m4/memaslap.m4]) m4_include([m4/murmur.m4]) m4_include([m4/pandora_64bit.m4]) m4_include([m4/pandora_canonical.m4]) m4_include([m4/pandora_check_compiler_version.m4]) m4_include([m4/pandora_clock_gettime.m4]) m4_include([m4/pandora_enable_dtrace.m4]) m4_include([m4/pandora_extensions.m4]) m4_include([m4/pandora_have_better_malloc.m4]) m4_include([m4/pandora_have_gcc_atomics.m4]) m4_include([m4/pandora_header_assert.m4]) m4_include([m4/pandora_optimize.m4]) m4_include([m4/pandora_platform.m4]) m4_include([m4/pandora_use_pipe.m4]) m4_include([m4/pandora_vc_build.m4]) m4_include([m4/pandora_version.m4]) m4_include([m4/pandora_warnings.m4]) m4_include([m4/protocol_binary.m4]) m4_include([m4/setsockopt.m4]) m4_include([m4/socket_send_flags.m4]) m4_include([m4/visibility.m4]) libmemcached-1.0.8/libmemcached-1.0/0000775000076400007640000000000011757025117017276 5ustar00brianbrian00000000000000libmemcached-1.0.8/libmemcached-1.0/auto.h0000664000076400007640000001304311753573717020432 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_return_t memcached_increment(memcached_st *ptr, const char *key, size_t key_length, uint32_t offset, uint64_t *value); LIBMEMCACHED_API memcached_return_t memcached_decrement(memcached_st *ptr, const char *key, size_t key_length, uint32_t offset, uint64_t *value); LIBMEMCACHED_API memcached_return_t memcached_increment_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t *value); LIBMEMCACHED_API memcached_return_t memcached_decrement_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t *value); LIBMEMCACHED_API memcached_return_t memcached_increment_with_initial(memcached_st *ptr, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value); LIBMEMCACHED_API memcached_return_t memcached_decrement_with_initial(memcached_st *ptr, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value); LIBMEMCACHED_API memcached_return_t memcached_increment_with_initial_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value); LIBMEMCACHED_API memcached_return_t memcached_decrement_with_initial_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/analyze.h0000664000076400007640000000413411753573717021126 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_analysis_st *memcached_analyze(memcached_st *memc, memcached_stat_st *memc_stat, memcached_return_t *error); LIBMEMCACHED_API void memcached_analyze_free(memcached_analysis_st *); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/struct/0000775000076400007640000000000011757025117020622 5ustar00brianbrian00000000000000libmemcached-1.0.8/libmemcached-1.0/struct/analysis.h0000664000076400007640000000370611753573717022636 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once struct memcached_analysis_st { memcached_st *root; uint32_t average_item_size; uint32_t longest_uptime; uint32_t least_free_server; uint32_t most_consumed_server; uint32_t oldest_server; double pool_hit_ratio; uint64_t most_used_bytes; uint64_t least_remaining_bytes; }; libmemcached-1.0.8/libmemcached-1.0/struct/include.am0000664000076400007640000000075111753573717022601 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root nobase_include_HEADERS+= \ libmemcached-1.0/struct/allocator.h \ libmemcached-1.0/struct/analysis.h \ libmemcached-1.0/struct/callback.h \ libmemcached-1.0/struct/memcached.h \ libmemcached-1.0/struct/result.h \ libmemcached-1.0/struct/sasl.h \ libmemcached-1.0/struct/server.h \ libmemcached-1.0/struct/stat.h \ libmemcached-1.0/struct/string.h libmemcached-1.0.8/libmemcached-1.0/struct/memcached.h0000664000076400007640000000771611753573717022726 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once struct memcached_st { /** @note these are static and should not change without a call to behavior. */ struct { bool is_purging:1; bool is_processing_input:1; bool is_time_for_rebuild:1; } state; struct { // Everything below here is pretty static. bool auto_eject_hosts:1; bool binary_protocol:1; bool buffer_requests:1; bool hash_with_namespace:1; bool no_block:1; // Don't block bool reply:1; bool randomize_replica_read:1; bool support_cas:1; bool tcp_nodelay:1; bool use_sort_hosts:1; bool use_udp:1; bool verify_key:1; bool tcp_keepalive:1; bool is_aes:1; } flags; memcached_server_distribution_t distribution; hashkit_st hashkit; struct { unsigned int version; } server_info; uint32_t number_of_hosts; memcached_server_st *servers; memcached_server_st *last_disconnected_server; int32_t snd_timeout; int32_t rcv_timeout; uint32_t server_failure_limit; uint32_t io_msg_watermark; uint32_t io_bytes_watermark; uint32_t io_key_prefetch; uint32_t tcp_keepidle; int32_t poll_timeout; int32_t connect_timeout; // How long we will wait on connect() before we will timeout int32_t retry_timeout; int32_t dead_timeout; int send_size; int recv_size; void *user_data; uint64_t query_id; uint32_t number_of_replicas; memcached_result_st result; struct { bool weighted; uint32_t continuum_count; // Ketama uint32_t continuum_points_counter; // Ketama time_t next_distribution_rebuild; // Ketama memcached_continuum_item_st *continuum; // Ketama } ketama; struct memcached_virtual_bucket_t *virtual_bucket; struct memcached_allocator_t allocators; memcached_clone_fn on_clone; memcached_cleanup_fn on_cleanup; memcached_trigger_key_fn get_key_failure; memcached_trigger_delete_key_fn delete_trigger; memcached_callback_st *callbacks; struct memcached_sasl_st sasl; struct memcached_error_t *error_messages; struct memcached_array_st *_namespace; struct { uint32_t initial_pool_size; uint32_t max_pool_size; int32_t version; // This is used by pool and others to determine if the memcached_st is out of date. struct memcached_array_st *filename; } configure; struct { bool is_allocated:1; } options; }; libmemcached-1.0.8/libmemcached-1.0/struct/stat.h0000664000076400007640000000506611753573717021767 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once struct memcached_stat_st { unsigned long connection_structures; unsigned long curr_connections; unsigned long curr_items; pid_t pid; unsigned long pointer_size; unsigned long rusage_system_microseconds; unsigned long rusage_system_seconds; unsigned long rusage_user_microseconds; unsigned long rusage_user_seconds; unsigned long threads; unsigned long time; unsigned long total_connections; unsigned long total_items; unsigned long uptime; unsigned long long bytes; unsigned long long bytes_read; unsigned long long bytes_written; unsigned long long cmd_get; unsigned long long cmd_set; unsigned long long evictions; unsigned long long get_hits; unsigned long long get_misses; unsigned long long limit_maxbytes; char version[MEMCACHED_VERSION_STRING_LENGTH]; void *__future; // @todo create a new structure to place here for future usage memcached_st *root; }; libmemcached-1.0.8/libmemcached-1.0/struct/allocator.h0000664000076400007640000000351511753573717022771 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once struct memcached_allocator_t { memcached_calloc_fn calloc; memcached_free_fn free; memcached_malloc_fn malloc; memcached_realloc_fn realloc; void *context; }; libmemcached-1.0.8/libmemcached-1.0/struct/result.h0000664000076400007640000000403311753573717022323 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once struct memcached_result_st { uint32_t item_flags; time_t item_expiration; size_t key_length; uint64_t item_cas; struct memcached_st *root; memcached_string_st value; uint64_t numeric_value; uint64_t count; char item_key[MEMCACHED_MAX_KEY]; struct { bool is_allocated:1; bool is_initialized:1; } options; /* Add result callback function */ }; libmemcached-1.0.8/libmemcached-1.0/struct/server.h0000664000076400007640000000663211753573717022322 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #ifndef WIN32 #include #endif #ifdef NI_MAXHOST #define MEMCACHED_NI_MAXHOST NI_MAXHOST #else #define MEMCACHED_NI_MAXHOST 1025 #endif #ifdef NI_MAXSERV #define MEMCACHED_NI_MAXSERV NI_MAXSERV #else #define MEMCACHED_NI_MAXSERV 32 #endif enum memcached_server_state_t { MEMCACHED_SERVER_STATE_NEW, // fd == -1, no address lookup has been done MEMCACHED_SERVER_STATE_ADDRINFO, // ADDRRESS information has been gathered MEMCACHED_SERVER_STATE_IN_PROGRESS, MEMCACHED_SERVER_STATE_CONNECTED, MEMCACHED_SERVER_STATE_IN_TIMEOUT }; struct memcached_server_st { struct { bool is_allocated:1; bool is_initialized:1; bool is_shutting_down:1; bool is_dead:1; } options; uint32_t number_of_hosts; uint32_t cursor_active; in_port_t port; memcached_socket_t fd; uint32_t io_bytes_sent; /* # bytes sent since last read */ uint32_t server_failure_counter; uint64_t server_failure_counter_query_id; uint32_t weight; uint32_t version; enum memcached_server_state_t state; struct { uint32_t read; uint32_t write; uint32_t timeouts; } io_wait_count; uint8_t major_version; // Default definition of UINT8_MAX means that it has not been set. uint8_t micro_version; // ditto, and note that this is the third, not second version bit uint8_t minor_version; // ditto memcached_connection_t type; char *read_ptr; size_t read_buffer_length; size_t read_data_length; size_t write_buffer_offset; struct addrinfo *address_info; struct addrinfo *address_info_next; time_t next_retry; struct memcached_st *root; uint64_t limit_maxbytes; struct memcached_error_t *error_messages; char read_buffer[MEMCACHED_MAX_BUFFER]; char write_buffer[MEMCACHED_MAX_BUFFER]; char hostname[MEMCACHED_NI_MAXHOST]; }; libmemcached-1.0.8/libmemcached-1.0/struct/string.h0000664000076400007640000000417311753573717022320 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once /** Strings are always under our control so we make some assumptions about them. 1) is_initialized is always valid. 2) A string once intialized will always be, until free where we unset this flag. 3) A string always has a root. */ struct memcached_string_st { char *end; char *string; size_t current_size; struct memcached_st *root; struct { bool is_allocated:1; bool is_initialized:1; } options; }; libmemcached-1.0.8/libmemcached-1.0/struct/sasl.h0000664000076400007640000000374311753573717021756 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT #include #else #define sasl_callback_t void #endif #pragma once struct memcached_sasl_st { sasl_callback_t *callbacks; /* ** Did we allocate data inside the callbacks, or did the user ** supply that. */ bool is_allocated; }; libmemcached-1.0.8/libmemcached-1.0/struct/callback.h0000664000076400007640000000343011753573717022541 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once struct memcached_callback_st { memcached_execute_fn *callback; void *context; uint32_t number_of_callback; }; libmemcached-1.0.8/libmemcached-1.0/include.am0000664000076400007640000000337211753573717021257 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root EXTRA_DIST+= \ libmemcached-1.0/configure.h.in include libmemcached-1.0/struct/include.am include libmemcached-1.0/types/include.am # Tests for this version of the interface include libmemcached-1.0/t/include.am nobase_include_HEADERS+= \ libmemcached-1.0/alloc.h \ libmemcached-1.0/allocators.h \ libmemcached-1.0/analyze.h \ libmemcached-1.0/auto.h \ libmemcached-1.0/basic_string.h \ libmemcached-1.0/behavior.h \ libmemcached-1.0/callback.h \ libmemcached-1.0/callbacks.h \ libmemcached-1.0/configure.h \ libmemcached-1.0/defaults.h \ libmemcached-1.0/delete.h \ libmemcached-1.0/deprecated_types.h \ libmemcached-1.0/dump.h \ libmemcached-1.0/encoding_key.h \ libmemcached-1.0/error.h \ libmemcached-1.0/exception.hpp \ libmemcached-1.0/exist.h \ libmemcached-1.0/fetch.h \ libmemcached-1.0/flush.h \ libmemcached-1.0/flush_buffers.h \ libmemcached-1.0/get.h \ libmemcached-1.0/hash.h \ libmemcached-1.0/limits.h \ libmemcached-1.0/memcached.h \ libmemcached-1.0/memcached.hpp \ libmemcached-1.0/options.h \ libmemcached-1.0/parse.h \ libmemcached-1.0/platform.h \ libmemcached-1.0/quit.h \ libmemcached-1.0/result.h \ libmemcached-1.0/return.h \ libmemcached-1.0/sasl.h \ libmemcached-1.0/server.h \ libmemcached-1.0/server_list.h \ libmemcached-1.0/stats.h \ libmemcached-1.0/storage.h \ libmemcached-1.0/strerror.h \ libmemcached-1.0/touch.h \ libmemcached-1.0/triggers.h \ libmemcached-1.0/types.h \ libmemcached-1.0/verbosity.h \ libmemcached-1.0/version.h \ libmemcached-1.0/visibility.h libmemcached-1.0.8/libmemcached-1.0/exist.h0000664000076400007640000000376011753573717020623 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once LIBMEMCACHED_API memcached_return_t memcached_exist(memcached_st *memc, const char *key, size_t key_length); LIBMEMCACHED_API memcached_return_t memcached_exist_by_key(memcached_st *memc, const char *group_key, size_t group_key_length, const char *key, size_t key_length); libmemcached-1.0.8/libmemcached-1.0/dump.h0000664000076400007640000000363611753573717020436 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_return_t memcached_dump(memcached_st *ptr, memcached_dump_fn *function, void *context, uint32_t number_of_callbacks); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/delete.h0000664000076400007640000000434411753573717020730 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_return_t memcached_delete(memcached_st *ptr, const char *key, size_t key_length, time_t expiration); LIBMEMCACHED_API memcached_return_t memcached_delete_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, time_t expiration); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/touch.h0000664000076400007640000000440111753573717020602 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_return_t memcached_touch(memcached_st *ptr, const char *key, size_t key_length, time_t expiration); LIBMEMCACHED_API memcached_return_t memcached_touch_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, time_t expiration); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/verbosity.h0000664000076400007640000000354711753573717021520 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_return_t memcached_verbosity(memcached_st *ptr, uint32_t verbosity); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/configure.h.in0000664000076400007640000000365711753573717022062 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-2009 Brian Aker, Trond Norbye 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif @DEPRECATED@ @LIBMEMCACHED_WITH_SASL_SUPPORT@ #define LIBMEMCACHED_VERSION_STRING "@VERSION@" #define LIBMEMCACHED_VERSION_HEX @PANDORA_HEX_VERSION@ #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/limits.h0000664000076400007640000000373211753573717020767 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #define MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH 20 #define MEMCACHED_MAX_BUFFER 8196 #define MEMCACHED_MAX_HOST_SORT_LENGTH 86 /* Used for Ketama */ #define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */ #define MEMCACHED_PREFIX_KEY_MAX_SIZE 128 #define MEMCACHED_VERSION_STRING_LENGTH 24 libmemcached-1.0.8/libmemcached-1.0/hash.h0000664000076400007640000000454011753573717020407 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif /* The two public hash bits */ LIBMEMCACHED_API uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash_t hash_algorithm); LIBMEMCACHED_API const hashkit_st *memcached_get_hashkit(const memcached_st *ptr); LIBMEMCACHED_API memcached_return_t memcached_set_hashkit(memcached_st *ptr, hashkit_st *hashk); LIBMEMCACHED_API uint32_t memcached_generate_hash(const memcached_st *ptr, const char *key, size_t key_length); LIBMEMCACHED_API void memcached_autoeject(memcached_st *ptr); LIBMEMCACHED_API const char * libmemcached_string_hash(memcached_hash_t type); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/parse.h0000664000076400007640000000065011753573717020574 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2010 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: Work with fetching results * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_server_list_st memcached_servers_parse(const char *server_strings); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/server_list.h0000664000076400007640000000561211753573717022026 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif /* Server List Public functions */ LIBMEMCACHED_API void memcached_server_list_free(memcached_server_list_st ptr); LIBMEMCACHED_API memcached_return_t memcached_server_push(memcached_st *ptr, const memcached_server_list_st list); LIBMEMCACHED_API memcached_server_list_st memcached_server_list_append(memcached_server_list_st ptr, const char *hostname, in_port_t port, memcached_return_t *error); LIBMEMCACHED_API memcached_server_list_st memcached_server_list_append_with_weight(memcached_server_list_st ptr, const char *hostname, in_port_t port, uint32_t weight, memcached_return_t *error); LIBMEMCACHED_API uint32_t memcached_server_list_count(const memcached_server_list_st ptr); #ifdef __cplusplus } // extern "C" #endif libmemcached-1.0.8/libmemcached-1.0/alloc.h0000664000076400007640000000424411753573717020557 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif /** Memory allocation functions. */ typedef void (*memcached_free_fn)(const memcached_st *ptr, void *mem, void *context); typedef void *(*memcached_malloc_fn)(const memcached_st *ptr, const size_t size, void *context); typedef void *(*memcached_realloc_fn)(const memcached_st *ptr, void *mem, const size_t size, void *context); typedef void *(*memcached_calloc_fn)(const memcached_st *ptr, size_t nelem, const size_t elsize, void *context); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/error.h0000664000076400007640000000432411753573717020615 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * LibMemcached * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API const char *memcached_last_error_message(memcached_st *); LIBMEMCACHED_API void memcached_error_print(const memcached_st *); LIBMEMCACHED_API memcached_return_t memcached_last_error(memcached_st *); LIBMEMCACHED_API int memcached_last_error_errno(memcached_st *); LIBMEMCACHED_API const char *memcached_server_error(memcached_server_instance_st ptr); LIBMEMCACHED_API memcached_return_t memcached_server_error_return(memcached_server_instance_st ptr); #ifdef __cplusplus } // extern "C" #endif libmemcached-1.0.8/libmemcached-1.0/exception.hpp0000664000076400007640000000221611753573717022020 0ustar00brianbrian00000000000000/* * Summary: Exceptions for the C++ interface * * Copy: See Copyright for the status of this software. * */ /** * @file * @brief Exception declarations */ #pragma once #include #include namespace memcache { class Exception : public std::runtime_error { public: Exception(const std::string& msg, int in_errno) : std::runtime_error(msg), _errno(in_errno) {} Exception(const char *msg, int in_errno) : std::runtime_error(std::string(msg)), _errno(in_errno) {} virtual ~Exception() throw() {} int getErrno() const { return _errno; } private: int _errno; }; class Warning : public Exception { public: Warning(const std::string& msg, int in_errno) : Exception(msg, in_errno) {} Warning(const char *msg, int in_errno) : Exception(msg, in_errno) {} }; class Error : public Exception { public: Error(const std::string& msg, int in_errno) : Exception(msg, in_errno) {} Error(const char *msg, int in_errno) : Exception(msg, in_errno) {} virtual ~Error() throw() {} }; } /* namespace libmemcached */ libmemcached-1.0.8/libmemcached-1.0/flush_buffers.h0000664000076400007640000000352611753573717022324 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_return_t memcached_flush_buffers(memcached_st *mem); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/options.h0000664000076400007640000000361011753573717021154 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_return_t libmemcached_check_configuration(const char *option_string, size_t length, char *error_buffer, size_t error_buffer_size); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/t/0000775000076400007640000000000011757025120017533 5ustar00brianbrian00000000000000libmemcached-1.0.8/libmemcached-1.0/t/c_test.c0000664000076400007640000000405711753573717021206 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached C test app * * Copyright (C) 2011 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. * */ /* * @file @brief C dummy test, aka testing C linking, etc */ #include #include int main(void) { (void)memcached_success(MEMCACHED_SUCCESS); (void)memcached_failed(MEMCACHED_SUCCESS); (void)memcached_continue(MEMCACHED_SUCCESS); memcached_st *memc= memcached_create(NULL); if (memc == NULL) { return EXIT_FAILURE; } memcached_free(memc); return EXIT_SUCCESS; } libmemcached-1.0.8/libmemcached-1.0/t/include.am0000664000076400007640000000247211753573717021522 0ustar00brianbrian00000000000000# vim:ft=automake # Copyright (C) 2011 Data Differential # All rights reserved. # # Use and distribution licensed under the BSD license. See # the COPYING file in the parent directory for full text. # # included from Top Level Makefile.am # All paths should be given relative to the root LIBMEMCACHED_1_0_TEST_PATH= libmemcached-1.0/t # 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 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 libmemcached-1.0.8/libmemcached-1.0/t/cc_test.cc0000664000076400007640000000406311753573717021511 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached C++ test app * * Copyright (C) 2011 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. * */ /* * @file @brief C dummy test, aka testing C linking, etc */ #include #include int main(void) { (void)memcached_success(MEMCACHED_SUCCESS); (void)memcached_failed(MEMCACHED_SUCCESS); (void)memcached_continue(MEMCACHED_SUCCESS); memcached_st *memc= memcached_create(NULL); if (memc == NULL) { return EXIT_FAILURE; } memcached_free(memc); return EXIT_SUCCESS; } libmemcached-1.0.8/libmemcached-1.0/t/c_sasl_test.c0000664000076400007640000000373611753573717022233 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached C sasl test app * * Copyright (C) 2011 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. * */ /* * @file @brief C dummy test, aka testing C linking, etc */ #include #ifdef HAVE_SASL_SASL_H #include #endif #include int main(void) { memcached_st *memc= memcached_create(NULL); if (memc == NULL) { return EXIT_FAILURE; } memcached_free(memc); return EXIT_SUCCESS; } libmemcached-1.0.8/libmemcached-1.0/callbacks.h0000664000076400007640000000444311753573717021405 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif typedef memcached_return_t (*memcached_execute_fn)(const memcached_st *ptr, memcached_result_st *result, void *context); typedef memcached_return_t (*memcached_server_fn)(const memcached_st *ptr, memcached_server_instance_st server, void *context); typedef memcached_return_t (*memcached_stat_fn)(memcached_server_instance_st server, const char *key, size_t key_length, const char *value, size_t value_length, void *context); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/triggers.h0000664000076400007640000000520511753573717021311 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif typedef memcached_return_t (*memcached_clone_fn)(memcached_st *destination, const memcached_st *source); typedef memcached_return_t (*memcached_cleanup_fn)(const memcached_st *ptr); /** Trigger functions. */ typedef memcached_return_t (*memcached_trigger_key_fn)(const memcached_st *ptr, const char *key, size_t key_length, memcached_result_st *result); typedef memcached_return_t (*memcached_trigger_delete_key_fn)(const memcached_st *ptr, const char *key, size_t key_length); typedef memcached_return_t (*memcached_dump_fn)(const memcached_st *ptr, const char *key, size_t key_length, void *context); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/memcached.h0000664000076400007640000001266711753573717021403 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once /* This seems to be required for older compilers @note http://stackoverflow.com/questions/8132399/how-to-printf-uint64-t */ #ifndef __STDC_FORMAT_MACROS # define __STDC_FORMAT_MACROS #endif #ifdef __cplusplus # include # include # include #else # include # include # include # include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // Everything above this line must be in the order specified. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API void memcached_servers_reset(memcached_st *ptr); LIBMEMCACHED_API memcached_st *memcached_create(memcached_st *ptr); LIBMEMCACHED_API memcached_st *memcached(const char *string, size_t string_length); LIBMEMCACHED_API void memcached_free(memcached_st *ptr); LIBMEMCACHED_API memcached_return_t memcached_reset(memcached_st *ptr); LIBMEMCACHED_API void memcached_reset_last_disconnected_server(memcached_st *ptr); LIBMEMCACHED_API memcached_st *memcached_clone(memcached_st *clone, const memcached_st *ptr); LIBMEMCACHED_API void *memcached_get_user_data(const memcached_st *ptr); LIBMEMCACHED_API void *memcached_set_user_data(memcached_st *ptr, void *data); LIBMEMCACHED_API memcached_return_t memcached_push(memcached_st *destination, const memcached_st *source); LIBMEMCACHED_API memcached_server_instance_st memcached_server_instance_by_position(const memcached_st *ptr, uint32_t server_key); LIBMEMCACHED_API uint32_t memcached_server_count(const memcached_st *); LIBMEMCACHED_API uint64_t memcached_query_id(const memcached_st *); #ifdef __cplusplus } // extern "C" #endif libmemcached-1.0.8/libmemcached-1.0/fetch.h0000664000076400007640000000404511753573717020555 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_return_t memcached_fetch_execute(memcached_st *ptr, memcached_execute_fn *callback, void *context, uint32_t number_of_callbacks); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/stats.h0000664000076400007640000000524411753573717020624 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API void memcached_stat_free(const memcached_st *, memcached_stat_st *); LIBMEMCACHED_API memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return_t *error); LIBMEMCACHED_API memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat, char *args, const char *hostname, in_port_t port); LIBMEMCACHED_API char *memcached_stat_get_value(const memcached_st *ptr, memcached_stat_st *memc_stat, const char *key, memcached_return_t *error); LIBMEMCACHED_API char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_stat, memcached_return_t *error); LIBMEMCACHED_API memcached_return_t memcached_stat_execute(memcached_st *memc, const char *args, memcached_stat_fn func, void *context); #ifdef __cplusplus } // extern "C" #endif libmemcached-1.0.8/libmemcached-1.0/platform.h0000664000076400007640000000373411753573717021314 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #ifdef WIN32 #include #include typedef short in_port_t; typedef SOCKET memcached_socket_t; #else typedef int memcached_socket_t; #include #include #include #include #include #include #endif /* WIN32 */ libmemcached-1.0.8/libmemcached-1.0/behavior.h0000664000076400007640000000625411753573717021267 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_return_t memcached_behavior_set(memcached_st *ptr, const memcached_behavior_t flag, uint64_t data); LIBMEMCACHED_API uint64_t memcached_behavior_get(memcached_st *ptr, const memcached_behavior_t flag); LIBMEMCACHED_API memcached_return_t memcached_behavior_set_distribution(memcached_st *ptr, memcached_server_distribution_t type); LIBMEMCACHED_API memcached_server_distribution_t memcached_behavior_get_distribution(memcached_st *ptr); LIBMEMCACHED_API memcached_return_t memcached_behavior_set_key_hash(memcached_st *ptr, memcached_hash_t type); LIBMEMCACHED_API memcached_hash_t memcached_behavior_get_key_hash(memcached_st *ptr); LIBMEMCACHED_API memcached_return_t memcached_behavior_set_distribution_hash(memcached_st *ptr, memcached_hash_t type); LIBMEMCACHED_API memcached_hash_t memcached_behavior_get_distribution_hash(memcached_st *ptr); LIBMEMCACHED_API const char *libmemcached_string_behavior(const memcached_behavior_t flag); LIBMEMCACHED_API const char *libmemcached_string_distribution(const memcached_server_distribution_t flag); LIBMEMCACHED_API memcached_return_t memcached_bucket_set(memcached_st *self, const uint32_t *host_map, const uint32_t *forward_map, const uint32_t buckets, const uint32_t replicas); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/types.h0000664000076400007640000000620111753573717020624 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #ifdef __cplusplus struct memcached_st; struct memcached_stat_st; struct memcached_analysis_st; struct memcached_result_st; struct memcached_array_st; struct memcached_error_t; // All of the flavors of memcache_server_st struct memcached_server_st; typedef const struct memcached_server_st *memcached_server_instance_st; typedef struct memcached_server_st *memcached_server_list_st; struct memcached_callback_st; // The following two structures are internal, and never exposed to users. struct memcached_string_st; struct memcached_string_t; struct memcached_continuum_item_st; #else typedef struct memcached_st memcached_st; typedef struct memcached_stat_st memcached_stat_st; typedef struct memcached_analysis_st memcached_analysis_st; typedef struct memcached_result_st memcached_result_st; typedef struct memcached_array_st memcached_array_st; typedef struct memcached_error_t memcached_error_t; // All of the flavors of memcache_server_st typedef struct memcached_server_st memcached_server_st; typedef const struct memcached_server_st *memcached_server_instance_st; typedef struct memcached_server_st *memcached_server_list_st; typedef struct memcached_callback_st memcached_callback_st; // The following two structures are internal, and never exposed to users. typedef struct memcached_string_st memcached_string_st; typedef struct memcached_string_t memcached_string_t; typedef struct memcached_continuum_item_st memcached_continuum_item_st; #endif libmemcached-1.0.8/libmemcached-1.0/memcached.hpp0000664000076400007640000006735511756611200021726 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011-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. * */ /* * Summary: C++ interface for memcached server * * Copy: See Copyright for the status of this software. * * Authors: Padraig O'Sullivan * Patrick Galbraith */ /** * @file memcached.hpp * @brief Libmemcached C++ interface */ #pragma once #include #if 0 #include #endif #include #include #include #include #include namespace memcache { /** * This is the core memcached library (if later, other objects * are needed, they will be created from this class). */ class Memcache { public: Memcache() { memc= memcached("", 0); } Memcache(const std::string &config) { memc= memcached(config.c_str(), config.size()); } Memcache(const std::string &hostname, in_port_t port) { memc= memcached("", 0); if (memc) { memcached_server_add(memc, hostname.c_str(), port); } } Memcache(memcached_st *clone) { memc= memcached_clone(NULL, clone); } Memcache(const Memcache &rhs) { memc= memcached_clone(NULL, rhs.getImpl()); } Memcache &operator=(const Memcache &rhs) { if (this != &rhs) { memcached_free(memc); memc= memcached_clone(NULL, rhs.getImpl()); } return *this; } ~Memcache() { memcached_free(memc); } /** * Get the internal memcached_st * */ const memcached_st *getImpl() const { return memc; } /** * Return an error string for the given return structure. * * @param[in] rc a memcached_return_t structure * @return error string corresponding to given return code in the library. */ const std::string getError(memcached_return_t rc) const { /* first parameter to strerror is unused */ return memcached_strerror(NULL, rc); } bool error(std::string& error_message) const { if (memcached_failed(memcached_last_error(memc))) { error_message+= memcached_last_error_message(memc); return true; } return false; } bool error() const { if (memcached_failed(memcached_last_error(memc))) { return true; } return false; } bool error(memcached_return_t& arg) const { arg= memcached_last_error(memc); return memcached_failed(arg); } bool setBehavior(memcached_behavior_t flag, uint64_t data) { return (memcached_success(memcached_behavior_set(memc, flag, data))); } uint64_t getBehavior(memcached_behavior_t flag) { return memcached_behavior_get(memc, flag); } /** * Configure the memcache object * * @param[in] in_config configuration * @return true on success; false otherwise */ bool configure(const std::string &configuration) { memcached_st *new_memc= memcached(configuration.c_str(), configuration.size()); if (new_memc) { memcached_free(memc); memc= new_memc; return true; } return false; } /** * Add a server to the list of memcached servers to use. * * @param[in] server_name name of the server to add * @param[in] port port number of server to add * @return true on success; false otherwise */ bool addServer(const std::string &server_name, in_port_t port) { return memcached_success(memcached_server_add(memc, server_name.c_str(), port)); } /** * Remove a server from the list of memcached servers to use. * * @param[in] server_name name of the server to remove * @param[in] port port number of server to remove * @return true on success; false otherwise */ bool removeServer(const std::string &server_name, in_port_t port) { std::string tmp_str; std::ostringstream strstm; tmp_str.append(","); tmp_str.append(server_name); tmp_str.append(":"); strstm << port; tmp_str.append(strstm.str()); //memcached_return_t rc= memcached_server_remove(server); return false; } /** * Fetches an individual value from the server. mget() must always * be called before using this method. * * @param[in] key key of object to fetch * @param[out] ret_val store returned object in this vector * @return a memcached return structure */ memcached_return_t fetch(std::string &key, std::vector &ret_val, uint32_t &flags, uint64_t &cas_value) { memcached_return_t rc; memcached_result_st *result; if ((result= memcached_fetch_result(memc, NULL, &rc))) { // Key key.assign(memcached_result_key_value(result), memcached_result_key_length(result)); // Actual value, null terminated ret_val.reserve(memcached_result_length(result) +1); ret_val.assign(memcached_result_value(result), memcached_result_value(result) +memcached_result_length(result)); // Misc flags= memcached_result_flags(result); cas_value= memcached_result_cas(result); } memcached_result_free(result); return rc; } memcached_return_t fetch(std::string &key, std::vector &ret_val) { uint32_t flags= 0; uint64_t cas_value= 0; return fetch(key, ret_val, flags, cas_value); } /** * Fetches an individual value from the server. * * @param[in] key key of object whose value to get * @param[out] ret_val object that is retrieved is stored in * this vector * @return true on success; false otherwise */ bool get(const std::string &key, std::vector &ret_val) { uint32_t flags= 0; memcached_return_t rc; size_t value_length= 0; char *value= memcached_get(memc, key.c_str(), key.length(), &value_length, &flags, &rc); if (value != NULL && ret_val.empty()) { ret_val.reserve(value_length); ret_val.assign(value, value +value_length); free(value); return true; } return false; } /** * Fetches an individual from a server which is specified by * the master_key parameter that is used for determining which * server an object was stored in if key partitioning was * used for storage. * * @param[in] master_key key that specifies server object is stored on * @param[in] key key of object whose value to get * @param[out] ret_val object that is retrieved is stored in * this vector * @return true on success; false otherwise */ bool getByKey(const std::string &master_key, const std::string &key, std::vector &ret_val) { uint32_t flags= 0; memcached_return_t rc; size_t value_length= 0; char *value= memcached_get_by_key(memc, master_key.c_str(), master_key.length(), key.c_str(), key.length(), &value_length, &flags, &rc); if (value) { ret_val.reserve(value_length); ret_val.assign(value, value +value_length); free(value); return true; } return false; } /** * Selects multiple keys at once. This method always * works asynchronously. * * @param[in] keys vector of keys to select * @return true if all keys are found */ bool mget(const std::vector& keys) { std::vector real_keys; std::vector key_len; /* * Construct an array which will contain the length * of each of the strings in the input vector. Also, to * interface with the memcached C API, we need to convert * the vector of std::string's to a vector of char *. */ real_keys.reserve(keys.size()); key_len.reserve(keys.size()); std::vector::const_iterator it= keys.begin(); while (it != keys.end()) { real_keys.push_back(const_cast((*it).c_str())); key_len.push_back((*it).length()); ++it; } /* * If the std::vector of keys is empty then we cannot * call memcached_mget as we will get undefined behavior. */ if (not real_keys.empty()) { return memcached_success(memcached_mget(memc, &real_keys[0], &key_len[0], real_keys.size())); } return false; } /** * Writes an object to the server. If the object already exists, it will * overwrite the existing object. This method always returns true * when using non-blocking mode unless a network error occurs. * * @param[in] key key of object to write to server * @param[in] value value of object to write to server * @param[in] expiration time to keep the object stored in the server for * @param[in] flags flags to store with the object * @return true on succcess; false otherwise */ bool set(const std::string &key, const std::vector &value, time_t expiration, uint32_t flags) { memcached_return_t rc= memcached_set(memc, key.c_str(), key.length(), &value[0], value.size(), expiration, flags); return memcached_success(rc); } /** * Writes an object to a server specified by the master_key parameter. * If the object already exists, it will overwrite the existing object. * * @param[in] master_key key that specifies server to write to * @param[in] key key of object to write to server * @param[in] value value of object to write to server * @param[in] expiration time to keep the object stored in the server for * @param[in] flags flags to store with the object * @return true on succcess; false otherwise */ bool setByKey(const std::string& master_key, const std::string& key, const std::vector &value, time_t expiration, uint32_t flags) { return memcached_success(memcached_set_by_key(memc, master_key.c_str(), master_key.length(), key.c_str(), key.length(), &value[0], value.size(), expiration, flags)); } /** * Writes a list of objects to the server. Objects are specified by * 2 vectors - 1 vector of keys and 1 vector of values. * * @param[in] keys vector of keys of objects to write to server * @param[in] values vector of values of objects to write to server * @param[in] expiration time to keep the objects stored in server for * @param[in] flags flags to store with the objects * @return true on success; false otherwise */ bool setAll(const std::vector& keys, const std::vector< std::vector *>& values, time_t expiration, uint32_t flags) { bool retval= true; std::vector::const_iterator key_it= keys.begin(); std::vector< std::vector *>::const_iterator val_it= values.begin(); while (key_it != keys.end()) { retval= set((*key_it), *(*val_it), expiration, flags); if (retval == false) { return retval; } ++key_it; ++val_it; } return retval; } /** * Writes a list of objects to the server. Objects are specified by * a map of keys to values. * * @param[in] key_value_map map of keys and values to store in server * @param[in] expiration time to keep the objects stored in server for * @param[in] flags flags to store with the objects * @return true on success; false otherwise */ bool setAll(const std::map >& key_value_map, time_t expiration, uint32_t flags) { bool retval= true; std::map >::const_iterator it= key_value_map.begin(); while (it != key_value_map.end()) { retval= set(it->first, it->second, expiration, flags); if (retval == false) { // We should tell the user what the key that failed was return false; } ++it; } return true; } /** * Increment the value of the object associated with the specified * key by the offset given. The resulting value is saved in the value * parameter. * * @param[in] key key of object in server whose value to increment * @param[in] offset amount to increment object's value by * @param[out] value store the result of the increment here * @return true on success; false otherwise */ bool increment(const std::string& key, uint32_t offset, uint64_t *value) { return memcached_success(memcached_increment(memc, key.c_str(), key.length(), offset, value)); } /** * Decrement the value of the object associated with the specified * key by the offset given. The resulting value is saved in the value * parameter. * * @param[in] key key of object in server whose value to decrement * @param[in] offset amount to increment object's value by * @param[out] value store the result of the decrement here * @return true on success; false otherwise */ bool decrement(const std::string& key, uint32_t offset, uint64_t *value) { return memcached_success(memcached_decrement(memc, key.c_str(), key.length(), offset, value)); } /** * Add an object with the specified key and value to the server. This * function returns false if the object already exists on the server. * * @param[in] key key of object to add * @param[in] value of object to add * @return true on success; false otherwise */ bool add(const std::string& key, const std::vector& value) { return memcached_success(memcached_add(memc, key.c_str(), key.length(), &value[0], value.size(), 0, 0)); } /** * Add an object with the specified key and value to the server. This * function returns false if the object already exists on the server. The * server to add the object to is specified by the master_key parameter. * * @param[in[ master_key key of server to add object to * @param[in] key key of object to add * @param[in] value of object to add * @return true on success; false otherwise */ bool addByKey(const std::string& master_key, const std::string& key, const std::vector& value) { return memcached_success(memcached_add_by_key(memc, master_key.c_str(), master_key.length(), key.c_str(), key.length(), &value[0], value.size(), 0, 0)); } /** * Replaces an object on the server. This method only succeeds * if the object is already present on the server. * * @param[in] key key of object to replace * @param[in[ value value to replace object with * @return true on success; false otherwise */ bool replace(const std::string& key, const std::vector& value) { return memcached_success(memcached_replace(memc, key.c_str(), key.length(), &value[0], value.size(), 0, 0)); } /** * Replaces an object on the server. This method only succeeds * if the object is already present on the server. The server * to replace the object on is specified by the master_key param. * * @param[in] master_key key of server to replace object on * @param[in] key key of object to replace * @param[in[ value value to replace object with * @return true on success; false otherwise */ bool replaceByKey(const std::string& master_key, const std::string& key, const std::vector& value) { return memcached_success(memcached_replace_by_key(memc, master_key.c_str(), master_key.length(), key.c_str(), key.length(), &value[0], value.size(), 0, 0)); } /** * Places a segment of data before the last piece of data stored. * * @param[in] key key of object whose value we will prepend data to * @param[in] value data to prepend to object's value * @return true on success; false otherwise */ bool prepend(const std::string& key, const std::vector& value) { return memcached_success(memcached_prepend(memc, key.c_str(), key.length(), &value[0], value.size(), 0, 0)); } /** * Places a segment of data before the last piece of data stored. The * server on which the object where we will be prepending data is stored * on is specified by the master_key parameter. * * @param[in] master_key key of server where object is stored * @param[in] key key of object whose value we will prepend data to * @param[in] value data to prepend to object's value * @return true on success; false otherwise */ bool prependByKey(const std::string& master_key, const std::string& key, const std::vector& value) { return memcached_success(memcached_prepend_by_key(memc, master_key.c_str(), master_key.length(), key.c_str(), key.length(), &value[0], value.size(), 0, 0)); } /** * Places a segment of data at the end of the last piece of data stored. * * @param[in] key key of object whose value we will append data to * @param[in] value data to append to object's value * @return true on success; false otherwise */ bool append(const std::string& key, const std::vector& value) { return memcached_success(memcached_append(memc, key.c_str(), key.length(), &value[0], value.size(), 0, 0)); } /** * Places a segment of data at the end of the last piece of data stored. The * server on which the object where we will be appending data is stored * on is specified by the master_key parameter. * * @param[in] master_key key of server where object is stored * @param[in] key key of object whose value we will append data to * @param[in] value data to append to object's value * @return true on success; false otherwise */ bool appendByKey(const std::string& master_key, const std::string& key, const std::vector &value) { return memcached_success(memcached_append_by_key(memc, master_key.c_str(), master_key.length(), key.c_str(), key.length(), &value[0], value.size(), 0, 0)); } /** * Overwrite data in the server as long as the cas_arg value * is still the same in the server. * * @param[in] key key of object in server * @param[in] value value to store for object in server * @param[in] cas_arg "cas" value */ bool cas(const std::string& key, const std::vector& value, uint64_t cas_arg) { return memcached_success(memcached_cas(memc, key.c_str(), key.length(), &value[0], value.size(), 0, 0, cas_arg)); } /** * Overwrite data in the server as long as the cas_arg value * is still the same in the server. The server to use is * specified by the master_key parameter. * * @param[in] master_key specifies server to operate on * @param[in] key key of object in server * @param[in] value value to store for object in server * @param[in] cas_arg "cas" value */ bool casByKey(const std::string& master_key, const std::string& key, const std::vector &value, uint64_t cas_arg) { return memcached_success(memcached_cas_by_key(memc, master_key.c_str(), master_key.length(), key.c_str(), key.length(), &value[0], value.size(), 0, 0, cas_arg)); } /** * Delete an object from the server specified by the key given. * * @param[in] key key of object to delete * @return true on success; false otherwise */ bool remove(const std::string& key) { return memcached_success(memcached_delete(memc, key.c_str(), key.length(), 0)); } /** * Delete an object from the server specified by the key given. * * @param[in] key key of object to delete * @param[in] expiration time to delete the object after * @return true on success; false otherwise */ bool remove(const std::string& key, time_t expiration) { return memcached_success(memcached_delete(memc, key.c_str(), key.length(), expiration)); } /** * Delete an object from the server specified by the key given. * * @param[in] master_key specifies server to remove object from * @param[in] key key of object to delete * @return true on success; false otherwise */ bool removeByKey(const std::string& master_key, const std::string& key) { return memcached_success(memcached_delete_by_key(memc, master_key.c_str(), master_key.length(), key.c_str(), key.length(), 0)); } /** * Delete an object from the server specified by the key given. * * @param[in] master_key specifies server to remove object from * @param[in] key key of object to delete * @param[in] expiration time to delete the object after * @return true on success; false otherwise */ bool removeByKey(const std::string& master_key, const std::string& key, time_t expiration) { return memcached_success(memcached_delete_by_key(memc, master_key.c_str(), master_key.length(), key.c_str(), key.length(), expiration)); } /** * Wipe the contents of memcached servers. * * @param[in] expiration time to wait until wiping contents of * memcached servers * @return true on success; false otherwise */ bool flush(time_t expiration= 0) { return memcached_success(memcached_flush(memc, expiration)); } /** * Get the library version string. * @return std::string containing a copy of the library version string. */ const std::string libVersion() const { const char *ver= memcached_lib_version(); const std::string version(ver); return version; } /** * Retrieve memcached statistics. Populate a std::map with the retrieved * stats. Each server will map to another std::map of the key:value stats. * * @param[out] stats_map a std::map to be populated with the memcached * stats * @return true on success; false otherwise */ bool getStats(std::map< std::string, std::map >& stats_map) { memcached_return_t rc; memcached_stat_st *stats= memcached_stat(memc, NULL, &rc); if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_SOME_ERRORS) { return false; } uint32_t server_count= memcached_server_count(memc); /* * For each memcached server, construct a std::map for its stats and add * it to the std::map of overall stats. */ for (uint32_t x= 0; x < server_count; x++) { memcached_server_instance_st instance= memcached_server_instance_by_position(memc, x); std::ostringstream strstm; std::string server_name(memcached_server_name(instance)); server_name.append(":"); strstm << memcached_server_port(instance); server_name.append(strstm.str()); std::map server_stats; char **list= memcached_stat_get_keys(memc, &stats[x], &rc); for (char** ptr= list; *ptr; ptr++) { char *value= memcached_stat_get_value(memc, &stats[x], *ptr, &rc); server_stats[*ptr]= value; free(value); } stats_map[server_name]= server_stats; free(list); } memcached_stat_free(memc, stats); return true; } private: memcached_st *memc; }; } libmemcached-1.0.8/libmemcached-1.0/defaults.h0000664000076400007640000000447011753573717021275 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once /* Public defines */ #define MEMCACHED_DEFAULT_PORT 11211 #define MEMCACHED_POINTS_PER_SERVER 100 #define MEMCACHED_POINTS_PER_SERVER_KETAMA 160 #define MEMCACHED_CONTINUUM_SIZE MEMCACHED_POINTS_PER_SERVER*100 /* This would then set max hosts to 100 */ #define MEMCACHED_STRIDE 4 #define MEMCACHED_DEFAULT_TIMEOUT 5000 #define MEMCACHED_DEFAULT_CONNECT_TIMEOUT 4000 #define MEMCACHED_CONTINUUM_ADDITION 10 /* How many extra slots we should build for in the continuum */ #define MEMCACHED_EXPIRATION_NOT_ADD 0xffffffffU #define MEMCACHED_SERVER_FAILURE_LIMIT 5 #define MEMCACHED_SERVER_FAILURE_RETRY_TIMEOUT 2 #define MEMCACHED_SERVER_FAILURE_DEAD_TIMEOUT 0 libmemcached-1.0.8/libmemcached-1.0/storage.h0000664000076400007640000001452211753573717021131 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif /* All of the functions for adding data to the server */ LIBMEMCACHED_API memcached_return_t memcached_set(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API memcached_return_t memcached_add(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API memcached_return_t memcached_replace(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API memcached_return_t memcached_append(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API memcached_return_t memcached_prepend(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API memcached_return_t memcached_cas(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags, uint64_t cas); LIBMEMCACHED_API memcached_return_t memcached_set_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API memcached_return_t memcached_add_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API memcached_return_t memcached_replace_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API memcached_return_t memcached_prepend_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API memcached_return_t memcached_append_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API memcached_return_t memcached_cas_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags, uint64_t cas); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/get.h0000664000076400007640000001121111753573717020234 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif /* Public defines */ LIBMEMCACHED_API char *memcached_get(memcached_st *ptr, const char *key, size_t key_length, size_t *value_length, uint32_t *flags, memcached_return_t *error); LIBMEMCACHED_API memcached_return_t memcached_mget(memcached_st *ptr, const char * const *keys, const size_t *key_length, size_t number_of_keys); LIBMEMCACHED_API char *memcached_get_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *key, size_t key_length, size_t *value_length, uint32_t *flags, memcached_return_t *error); LIBMEMCACHED_API memcached_return_t memcached_mget_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char * const *keys, const size_t *key_length, const size_t number_of_keys); LIBMEMCACHED_API char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, size_t *value_length, uint32_t *flags, memcached_return_t *error); LIBMEMCACHED_API memcached_result_st *memcached_fetch_result(memcached_st *ptr, memcached_result_st *result, memcached_return_t *error); LIBMEMCACHED_API memcached_return_t memcached_mget_execute(memcached_st *ptr, const char * const *keys, const size_t *key_length, const size_t number_of_keys, memcached_execute_fn *callback, void *context, const uint32_t number_of_callbacks); LIBMEMCACHED_API memcached_return_t memcached_mget_execute_by_key(memcached_st *ptr, const char *group_key, size_t group_key_length, const char * const *keys, const size_t *key_length, size_t number_of_keys, memcached_execute_fn *callback, void *context, const uint32_t number_of_callbacks); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/quit.h0000664000076400007640000000347711753573717020456 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API void memcached_quit(memcached_st *ptr); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/result.h0000664000076400007640000000566111753573717021007 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 #pragma once #ifdef __cplusplus extern "C" { #endif /* Result Struct */ LIBMEMCACHED_API void memcached_result_free(memcached_result_st *result); LIBMEMCACHED_API void memcached_result_reset(memcached_result_st *ptr); LIBMEMCACHED_API memcached_result_st *memcached_result_create(const memcached_st *ptr, memcached_result_st *result); LIBMEMCACHED_API const char *memcached_result_key_value(const memcached_result_st *self); LIBMEMCACHED_API size_t memcached_result_key_length(const memcached_result_st *self); LIBMEMCACHED_API const char *memcached_result_value(const memcached_result_st *self); LIBMEMCACHED_API size_t memcached_result_length(const memcached_result_st *self); LIBMEMCACHED_API uint32_t memcached_result_flags(const memcached_result_st *self); LIBMEMCACHED_API uint64_t memcached_result_cas(const memcached_result_st *self); LIBMEMCACHED_API memcached_return_t memcached_result_set_value(memcached_result_st *ptr, const char *value, size_t length); LIBMEMCACHED_API void memcached_result_set_flags(memcached_result_st *self, uint32_t flags); LIBMEMCACHED_API void memcached_result_set_expiration(memcached_result_st *self, time_t expiration); #ifdef __cplusplus } // extern "C" #endif libmemcached-1.0.8/libmemcached-1.0/encoding_key.h0000664000076400007640000000353111753573717022121 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_return_t memcached_set_encoding_key(memcached_st*, const char *str, size_t length); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/configure.h0000664000076400007640000000363411756761746021454 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-2009 Brian Aker, Trond Norbye 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif #define LIBMEMCACHED_WITH_SASL_SUPPORT 0 #define LIBMEMCACHED_VERSION_STRING "1.0.8" #define LIBMEMCACHED_VERSION_HEX 0x01000008 #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/allocators.h0000664000076400007640000000525311753573717021631 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_return_t memcached_set_memory_allocators(memcached_st *ptr, memcached_malloc_fn mem_malloc, memcached_free_fn mem_free, memcached_realloc_fn mem_realloc, memcached_calloc_fn mem_calloc, void *context); LIBMEMCACHED_API void memcached_get_memory_allocators(const memcached_st *ptr, memcached_malloc_fn *mem_malloc, memcached_free_fn *mem_free, memcached_realloc_fn *mem_realloc, memcached_calloc_fn *mem_calloc); LIBMEMCACHED_API void *memcached_get_memory_allocators_context(const memcached_st *ptr); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/basic_string.h0000664000076400007640000000402411753573717022130 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once // No assumptions of NULL should be made struct memcached_string_t { const char *c_str; size_t size; }; #define memcached_size(X) (X).size; #define memcached_c_str(X) (X).c_str; #define memcached_string_param(X) (X).c_str, (X).size #ifdef __cplusplus #define memcached_string_printf(X) int((X).size), (X).c_str #else #define memcached_string_printf(X) (int)((X).size), (X).c_str #endif libmemcached-1.0.8/libmemcached-1.0/server.h0000664000076400007640000001065111753573717020772 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #include #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_return_t memcached_server_cursor(const memcached_st *ptr, const memcached_server_fn *callback, void *context, uint32_t number_of_callbacks); LIBMEMCACHED_API memcached_server_instance_st memcached_server_by_key(memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error); LIBMEMCACHED_API void memcached_server_error_reset(memcached_server_st *ptr); LIBMEMCACHED_API void memcached_server_free(memcached_server_st *ptr); LIBMEMCACHED_API memcached_server_instance_st memcached_server_get_last_disconnect(const memcached_st *ptr); LIBMEMCACHED_API memcached_return_t memcached_server_add_udp(memcached_st *ptr, const char *hostname, in_port_t port); LIBMEMCACHED_API memcached_return_t memcached_server_add_unix_socket(memcached_st *ptr, const char *filename); LIBMEMCACHED_API memcached_return_t memcached_server_add(memcached_st *ptr, const char *hostname, in_port_t port); LIBMEMCACHED_API memcached_return_t memcached_server_add_udp_with_weight(memcached_st *ptr, const char *hostname, in_port_t port, uint32_t weight); LIBMEMCACHED_API memcached_return_t memcached_server_add_unix_socket_with_weight(memcached_st *ptr, const char *filename, uint32_t weight); LIBMEMCACHED_API memcached_return_t memcached_server_add_with_weight(memcached_st *ptr, const char *hostname, in_port_t port, uint32_t weight); /** Operations on Single Servers. */ LIBMEMCACHED_API uint32_t memcached_server_response_count(const memcached_server_instance_st self); LIBMEMCACHED_API const char *memcached_server_name(const memcached_server_instance_st self); LIBMEMCACHED_API in_port_t memcached_server_port(const memcached_server_instance_st self); LIBMEMCACHED_API const char *memcached_server_type(const memcached_server_instance_st ptr); #ifdef __cplusplus } // extern "C" #endif libmemcached-1.0.8/libmemcached-1.0/deprecated_types.h0000664000076400007640000000501111753573717023002 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ /* * Warning, none of these should ever be used. */ #pragma once /** @note The following definitions are just here for backwards compatibility. */ typedef memcached_return_t memcached_return; typedef memcached_server_distribution_t memcached_server_distribution; typedef memcached_behavior_t memcached_behavior; typedef memcached_callback_t memcached_callback; typedef memcached_hash_t memcached_hash; typedef memcached_connection_t memcached_connection; typedef memcached_clone_fn memcached_clone_func; typedef memcached_cleanup_fn memcached_cleanup_func; typedef memcached_execute_fn memcached_execute_function; typedef memcached_server_fn memcached_server_function; typedef memcached_trigger_key_fn memcached_trigger_key; typedef memcached_trigger_delete_key_fn memcached_trigger_delete_key; typedef memcached_dump_fn memcached_dump_func; libmemcached-1.0.8/libmemcached-1.0/visibility.h0000664000076400007640000000400211753573717021644 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: Interface for memcached server. * * Author: Trond Norbye * */ /** * @file * @brief Visibility control macros */ #pragma once /** * * LIBMEMCACHED_API is used for the public API symbols. It either DLL imports or * DLL exports (or does nothing for static build). * * LIBMEMCACHED_LOCAL is used for non-api symbols. */ #if defined(BUILDING_LIBMEMCACHEDINTERNAL) # if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY # define LIBMEMCACHED_API __attribute__ ((visibility("default"))) # define LIBMEMCACHED_LOCAL __attribute__ ((visibility("default"))) # elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550) # define LIBMEMCACHED_API __global # define LIBMEMCACHED_LOCAL __global # elif defined(_MSC_VER) # define LIBMEMCACHED_API extern __declspec(dllexport) # define LIBMEMCACHED_LOCAL extern __declspec(dllexport) # else # define LIBMEMCACHED_API # define LIBMEMCACHED_LOCAL # endif #else # if defined(BUILDING_LIBMEMCACHED) # if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY # define LIBMEMCACHED_API __attribute__ ((visibility("default"))) # define LIBMEMCACHED_LOCAL __attribute__ ((visibility("hidden"))) # elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550) # define LIBMEMCACHED_API __global # define LIBMEMCACHED_LOCAL __hidden # elif defined(_MSC_VER) # define LIBMEMCACHED_API extern __declspec(dllexport) # define LIBMEMCACHED_LOCAL # else # define LIBMEMCACHED_API # define LIBMEMCACHED_LOCAL # endif /* defined(HAVE_VISIBILITY) */ # else /* defined(BUILDING_LIBMEMCACHED) */ # if defined(_MSC_VER) # define LIBMEMCACHED_API extern __declspec(dllimport) # define LIBMEMCACHED_LOCAL # else # define LIBMEMCACHED_API # define LIBMEMCACHED_LOCAL # endif /* defined(_MSC_VER) */ # endif /* defined(BUILDING_LIBMEMCACHED) */ #endif /* defined(BUILDING_LIBMEMCACHEDINTERNAL) */ libmemcached-1.0.8/libmemcached-1.0/strerror.h0000664000076400007640000000354211753573717021347 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API const char *memcached_strerror(memcached_st *ptr, memcached_return_t rc); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/types/0000775000076400007640000000000011757025117020442 5ustar00brianbrian00000000000000libmemcached-1.0.8/libmemcached-1.0/types/include.am0000664000076400007640000000044311753573717022417 0ustar00brianbrian00000000000000# vim:ft=automake nobase_include_HEADERS+= \ libmemcached-1.0/types/behavior.h \ libmemcached-1.0/types/callback.h \ libmemcached-1.0/types/connection.h \ libmemcached-1.0/types/hash.h \ libmemcached-1.0/types/return.h \ libmemcached-1.0/types/server_distribution.h libmemcached-1.0.8/libmemcached-1.0/types/hash.h0000664000076400007640000000407011753573717021551 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once enum memcached_hash_t { MEMCACHED_HASH_DEFAULT= 0, MEMCACHED_HASH_MD5, MEMCACHED_HASH_CRC, MEMCACHED_HASH_FNV1_64, MEMCACHED_HASH_FNV1A_64, MEMCACHED_HASH_FNV1_32, MEMCACHED_HASH_FNV1A_32, MEMCACHED_HASH_HSIEH, MEMCACHED_HASH_MURMUR, MEMCACHED_HASH_JENKINS, MEMCACHED_HASH_CUSTOM, MEMCACHED_HASH_MAX }; #ifndef __cplusplus typedef enum memcached_hash_t memcached_hash_t; #endif libmemcached-1.0.8/libmemcached-1.0/types/behavior.h0000664000076400007640000000614311753573717022430 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once enum memcached_behavior_t { MEMCACHED_BEHAVIOR_NO_BLOCK, MEMCACHED_BEHAVIOR_TCP_NODELAY, MEMCACHED_BEHAVIOR_HASH, MEMCACHED_BEHAVIOR_KETAMA, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, MEMCACHED_BEHAVIOR_CACHE_LOOKUPS, MEMCACHED_BEHAVIOR_SUPPORT_CAS, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, MEMCACHED_BEHAVIOR_DISTRIBUTION, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, MEMCACHED_BEHAVIOR_USER_DATA, MEMCACHED_BEHAVIOR_SORT_HOSTS, MEMCACHED_BEHAVIOR_VERIFY_KEY, MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, MEMCACHED_BEHAVIOR_SND_TIMEOUT, MEMCACHED_BEHAVIOR_RCV_TIMEOUT, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK, MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK, MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH, MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY, MEMCACHED_BEHAVIOR_NOREPLY, MEMCACHED_BEHAVIOR_USE_UDP, MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ, MEMCACHED_BEHAVIOR_CORK, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE, MEMCACHED_BEHAVIOR_TCP_KEEPIDLE, MEMCACHED_BEHAVIOR_LOAD_FROM_FILE, MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS, MEMCACHED_BEHAVIOR_DEAD_TIMEOUT, MEMCACHED_BEHAVIOR_MAX }; #ifndef __cplusplus typedef enum memcached_behavior_t memcached_behavior_t; #endif libmemcached-1.0.8/libmemcached-1.0/types/server_distribution.h0000664000076400007640000000417311753573717024737 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once enum memcached_server_distribution_t { MEMCACHED_DISTRIBUTION_MODULA, MEMCACHED_DISTRIBUTION_CONSISTENT, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA, MEMCACHED_DISTRIBUTION_RANDOM, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY, MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED, MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET, MEMCACHED_DISTRIBUTION_CONSISTENT_MAX }; #ifndef __cplusplus typedef enum memcached_server_distribution_t memcached_server_distribution_t; #endif libmemcached-1.0.8/libmemcached-1.0/types/return.h0000664000076400007640000000655411753573717022156 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once enum memcached_return_t { MEMCACHED_SUCCESS, MEMCACHED_FAILURE, MEMCACHED_HOST_LOOKUP_FAILURE, // getaddrinfo() and getnameinfo() only MEMCACHED_CONNECTION_FAILURE, MEMCACHED_CONNECTION_BIND_FAILURE, // DEPRECATED, see MEMCACHED_HOST_LOOKUP_FAILURE MEMCACHED_WRITE_FAILURE, MEMCACHED_READ_FAILURE, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_PROTOCOL_ERROR, MEMCACHED_CLIENT_ERROR, MEMCACHED_SERVER_ERROR, // Server returns "SERVER_ERROR" MEMCACHED_ERROR, // Server returns "ERROR" MEMCACHED_DATA_EXISTS, MEMCACHED_DATA_DOES_NOT_EXIST, MEMCACHED_NOTSTORED, MEMCACHED_STORED, MEMCACHED_NOTFOUND, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_PARTIAL_READ, MEMCACHED_SOME_ERRORS, MEMCACHED_NO_SERVERS, MEMCACHED_END, MEMCACHED_DELETED, MEMCACHED_VALUE, MEMCACHED_STAT, MEMCACHED_ITEM, MEMCACHED_ERRNO, MEMCACHED_FAIL_UNIX_SOCKET, // DEPRECATED MEMCACHED_NOT_SUPPORTED, MEMCACHED_NO_KEY_PROVIDED, /* Deprecated. Use MEMCACHED_BAD_KEY_PROVIDED! */ MEMCACHED_FETCH_NOTFINISHED, MEMCACHED_TIMEOUT, MEMCACHED_BUFFERED, MEMCACHED_BAD_KEY_PROVIDED, MEMCACHED_INVALID_HOST_PROTOCOL, MEMCACHED_SERVER_MARKED_DEAD, MEMCACHED_UNKNOWN_STAT_KEY, MEMCACHED_E2BIG, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_KEY_TOO_BIG, MEMCACHED_AUTH_PROBLEM, MEMCACHED_AUTH_FAILURE, MEMCACHED_AUTH_CONTINUE, MEMCACHED_PARSE_ERROR, MEMCACHED_PARSE_USER_ERROR, MEMCACHED_DEPRECATED, MEMCACHED_IN_PROGRESS, MEMCACHED_SERVER_TEMPORARILY_DISABLED, MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE, MEMCACHED_MAXIMUM_RETURN, /* Always add new error code before */ MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE= MEMCACHED_ERROR }; #ifndef __cplusplus typedef enum memcached_return_t memcached_return_t; #endif libmemcached-1.0.8/libmemcached-1.0/types/connection.h0000664000076400007640000000357111753573717022772 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once enum memcached_connection_t { MEMCACHED_CONNECTION_TCP, MEMCACHED_CONNECTION_UDP, MEMCACHED_CONNECTION_UNIX_SOCKET }; #ifndef __cplusplus typedef enum memcached_connection_t memcached_connection_t; #endif libmemcached-1.0.8/libmemcached-1.0/types/callback.h0000664000076400007640000000413411753573717022363 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once enum memcached_callback_t { MEMCACHED_CALLBACK_PREFIX_KEY = 0, MEMCACHED_CALLBACK_USER_DATA = 1, MEMCACHED_CALLBACK_CLEANUP_FUNCTION = 2, MEMCACHED_CALLBACK_CLONE_FUNCTION = 3, MEMCACHED_CALLBACK_GET_FAILURE = 7, MEMCACHED_CALLBACK_DELETE_TRIGGER = 8, MEMCACHED_CALLBACK_MAX, MEMCACHED_CALLBACK_NAMESPACE= MEMCACHED_CALLBACK_PREFIX_KEY }; #ifndef __cplusplus typedef enum memcached_callback_t memcached_callback_t; #endif libmemcached-1.0.8/libmemcached-1.0/return.h0000664000076400007640000000576211753573717021012 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once static inline bool memcached_success(memcached_return_t rc) { return (rc == MEMCACHED_BUFFERED || rc == MEMCACHED_DELETED || rc == MEMCACHED_END || rc == MEMCACHED_ITEM || rc == MEMCACHED_STAT || rc == MEMCACHED_STORED || rc == MEMCACHED_SUCCESS || rc == MEMCACHED_VALUE); } static inline bool memcached_failed(memcached_return_t rc) { return (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_END && rc != MEMCACHED_STORED && rc != MEMCACHED_STAT && rc != MEMCACHED_DELETED && rc != MEMCACHED_BUFFERED && rc != MEMCACHED_VALUE); } static inline bool memcached_fatal(memcached_return_t rc) { return ( rc != MEMCACHED_BUFFERED && rc != MEMCACHED_DATA_EXISTS && rc != MEMCACHED_DELETED && rc != MEMCACHED_E2BIG && rc != MEMCACHED_END && rc != MEMCACHED_ITEM && rc != MEMCACHED_ERROR && rc != MEMCACHED_NOTFOUND && rc != MEMCACHED_NOTSTORED && rc != MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE && rc != MEMCACHED_STAT && rc != MEMCACHED_STORED && rc != MEMCACHED_SUCCESS && rc != MEMCACHED_VALUE); } #define memcached_continue(__memcached_return_t) ((__memcached_return_t) == MEMCACHED_IN_PROGRESS) libmemcached-1.0.8/libmemcached-1.0/version.h0000664000076400007640000000361411753573717021152 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_return_t memcached_version(memcached_st *ptr); LIBMEMCACHED_API const char * memcached_lib_version(void); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/flush.h0000664000076400007640000000354111753573717020605 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_return_t memcached_flush(memcached_st *ptr, time_t expiration); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcached-1.0/sasl.h0000664000076400007640000000474511753573717020435 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT #include #else #define sasl_callback_t void #endif #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API void memcached_set_sasl_callbacks(memcached_st *ptr, const sasl_callback_t *callbacks); LIBMEMCACHED_API memcached_return_t memcached_set_sasl_auth_data(memcached_st *ptr, const char *username, const char *password); LIBMEMCACHED_API memcached_return_t memcached_destroy_sasl_auth_data(memcached_st *ptr); LIBMEMCACHED_API sasl_callback_t *memcached_get_sasl_callbacks(memcached_st *ptr); #ifdef __cplusplus } #endif #include libmemcached-1.0.8/libmemcached-1.0/callback.h0000664000076400007640000000423111753573717021215 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API memcached_return_t memcached_callback_set(memcached_st *ptr, const memcached_callback_t flag, const void *data); LIBMEMCACHED_API void *memcached_callback_get(memcached_st *ptr, const memcached_callback_t flag, memcached_return_t *error); #ifdef __cplusplus } #endif libmemcached-1.0.8/memcached/0000775000076400007640000000000011757025120016305 5ustar00brianbrian00000000000000libmemcached-1.0.8/memcached/util.h0000664000076400007640000000162011753573717017452 0ustar00brianbrian00000000000000/* * Wrappers around strtoull/strtoll that are safer and easier to * use. For tests and assumptions, see internal_tests.c. * * str a NULL-terminated base decimal 10 unsigned integer * out out parameter, if conversion succeeded * * returns true if conversion succeeded. */ bool safe_strtoull(const char *str, uint64_t *out); bool safe_strtoll(const char *str, int64_t *out); bool safe_strtoul(const char *str, uint32_t *out); bool safe_strtol(const char *str, int32_t *out); #ifndef HAVE_HTONLL extern uint64_t htonll(uint64_t); extern uint64_t ntohll(uint64_t); #endif #ifdef __GCC # define __gcc_attribute__ __attribute__ #else # define __gcc_attribute__(x) #endif /** * Vararg variant of perror that makes for more useful error messages * when reporting with parameters. * * @param fmt a printf format */ void vperror(const char *fmt, ...) __gcc_attribute__ ((format (printf, 1, 2))); libmemcached-1.0.8/memcached/slabs.c0000664000076400007640000006243011753573717017602 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Slabs memory allocation, based on powers-of-N. Slabs are up to 1MB in size * and are divided into chunks. The chunk sizes start off at the size of the * "item" structure plus space for a small key and value. They increase by * a multiplier factor from there, up to half the maximum slab size. The last * slab size is always 1MB, since that's the maximum item size allowed by the * memcached protocol. */ #include "memcached.h" #include #include #include #include #include #include #include #include #include #include #include #include /* powers-of-N allocation structures */ typedef struct { unsigned int size; /* sizes of items */ unsigned int perslab; /* how many items per slab */ void *slots; /* list of item ptrs */ unsigned int sl_curr; /* total free items in list */ void *end_page_ptr; /* pointer to next free item at end of page, or 0 */ unsigned int end_page_free; /* number of items remaining at end of last alloced page */ unsigned int slabs; /* how many slabs were allocated for this class */ void **slab_list; /* array of slab pointers */ unsigned int list_size; /* size of prev array */ unsigned int killing; /* index+1 of dying slab, or zero if none */ size_t requested; /* The number of requested bytes */ } slabclass_t; static slabclass_t slabclass[MAX_NUMBER_OF_SLAB_CLASSES]; static size_t mem_limit = 0; static size_t mem_malloced = 0; static int power_largest; static void *mem_base = NULL; static void *mem_current = NULL; static size_t mem_avail = 0; /** * Access to the slab allocator is protected by this lock */ static pthread_mutex_t slabs_lock = PTHREAD_MUTEX_INITIALIZER; /* * Forward Declarations */ static int do_slabs_newslab(const unsigned int id); static void *memory_allocate(size_t size); #ifndef DONT_PREALLOC_SLABS /* Preallocate as many slab pages as possible (called from slabs_init) on start-up, so users don't get confused out-of-memory errors when they do have free (in-slab) space, but no space to make new slabs. if maxslabs is 18 (POWER_LARGEST - POWER_SMALLEST + 1), then all slab types can be made. if max memory is less than 18 MB, only the smaller ones will be made. */ static void slabs_preallocate (const unsigned int maxslabs); #endif /* * Figures out which slab class (chunk size) is required to store an item of * a given size. * * Given object size, return id to use when allocating/freeing memory for object * 0 means error: can't store such a large object */ unsigned int slabs_clsid(const size_t size) { int res = POWER_SMALLEST; if (size == 0) return 0; while (size > slabclass[res].size) if (res++ == power_largest) /* won't fit in the biggest slab */ return 0; return res; } /** * Determines the chunk sizes and initializes the slab class descriptors * accordingly. */ void slabs_init(const size_t limit, const double factor, const bool prealloc) { int i = POWER_SMALLEST - 1; unsigned int size = sizeof(item) + settings.chunk_size; mem_limit = limit; if (prealloc) { /* Allocate everything in a big chunk with malloc */ mem_base = malloc(mem_limit); if (mem_base != NULL) { mem_current = mem_base; mem_avail = mem_limit; } else { fprintf(stderr, "Warning: Failed to allocate requested memory in" " one large chunk.\nWill allocate in smaller chunks\n"); } } memset(slabclass, 0, sizeof(slabclass)); while (++i < POWER_LARGEST && size <= settings.item_size_max / factor) { /* Make sure items are always n-byte aligned */ if (size % CHUNK_ALIGN_BYTES) size += CHUNK_ALIGN_BYTES - (size % CHUNK_ALIGN_BYTES); slabclass[i].size = size; slabclass[i].perslab = settings.item_size_max / slabclass[i].size; size *= factor; if (settings.verbose > 1) { fprintf(stderr, "slab class %3d: chunk size %9u perslab %7u\n", i, slabclass[i].size, slabclass[i].perslab); } } power_largest = i; slabclass[power_largest].size = settings.item_size_max; slabclass[power_largest].perslab = 1; if (settings.verbose > 1) { fprintf(stderr, "slab class %3d: chunk size %9u perslab %7u\n", i, slabclass[i].size, slabclass[i].perslab); } /* for the test suite: faking of how much we've already malloc'd */ { char *t_initial_malloc = getenv("T_MEMD_INITIAL_MALLOC"); if (t_initial_malloc) { mem_malloced = (size_t)atol(t_initial_malloc); } } #ifndef DONT_PREALLOC_SLABS { char *pre_alloc = getenv("T_MEMD_SLABS_ALLOC"); if (pre_alloc == NULL || atoi(pre_alloc) != 0) { slabs_preallocate(power_largest); } } #endif } #ifndef DONT_PREALLOC_SLABS static void slabs_preallocate (const unsigned int maxslabs) { int i; unsigned int prealloc = 0; /* pre-allocate a 1MB slab in every size class so people don't get confused by non-intuitive "SERVER_ERROR out of memory" messages. this is the most common question on the mailing list. if you really don't want this, you can rebuild without these three lines. */ for (i = POWER_SMALLEST; i <= POWER_LARGEST; i++) { if (++prealloc > maxslabs) return; do_slabs_newslab(i); } } #endif static int grow_slab_list (const unsigned int id) { slabclass_t *p = &slabclass[id]; if (p->slabs == p->list_size) { size_t new_size = (p->list_size != 0) ? p->list_size * 2 : 16; void *new_list = realloc(p->slab_list, new_size * sizeof(void *)); if (new_list == 0) return 0; p->list_size = new_size; p->slab_list = new_list; } return 1; } #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wsign-compare" #endif static int do_slabs_newslab(const unsigned int id) { slabclass_t *p = &slabclass[id]; int len = settings.slab_reassign ? settings.item_size_max : p->size * p->perslab; char *ptr; if ((mem_limit && mem_malloced + len > mem_limit && p->slabs > 0) || (grow_slab_list(id) == 0) || ((ptr = memory_allocate((size_t)len)) == 0)) { MEMCACHED_SLABS_SLABCLASS_ALLOCATE_FAILED(id); return 0; } memset(ptr, 0, (size_t)len); p->end_page_ptr = ptr; p->end_page_free = p->perslab; p->slab_list[p->slabs++] = ptr; mem_malloced += len; MEMCACHED_SLABS_SLABCLASS_ALLOCATE(id); return 1; } /*@null@*/ static void *do_slabs_alloc(const size_t size, unsigned int id) { slabclass_t *p; void *ret = NULL; item *it = NULL; if (id < POWER_SMALLEST || id > power_largest) { MEMCACHED_SLABS_ALLOCATE_FAILED(size, 0); return NULL; } p = &slabclass[id]; assert(p->sl_curr == 0 || ((item *)p->slots)->slabs_clsid == 0); #ifdef USE_SYSTEM_MALLOC if (mem_limit && mem_malloced + size > mem_limit) { MEMCACHED_SLABS_ALLOCATE_FAILED(size, id); return 0; } mem_malloced += size; ret = malloc(size); MEMCACHED_SLABS_ALLOCATE(size, id, 0, ret); return ret; #endif /* fail unless we have space at the end of a recently allocated page, we have something on our freelist, or we could allocate a new page */ if (! (p->end_page_ptr != 0 || p->sl_curr != 0 || do_slabs_newslab(id) != 0)) { /* We don't have more memory available */ ret = NULL; } else if (p->sl_curr != 0) { /* return off our freelist */ it = (item *)p->slots; p->slots = it->next; if (it->next) it->next->prev = 0; p->sl_curr--; ret = (void *)it; } else { /* if we recently allocated a whole page, return from that */ assert(p->end_page_ptr != NULL); ret = p->end_page_ptr; if (--p->end_page_free != 0) { p->end_page_ptr = ((caddr_t)p->end_page_ptr) + p->size; } else { p->end_page_ptr = 0; } } if (ret) { p->requested += size; MEMCACHED_SLABS_ALLOCATE(size, id, p->size, ret); } else { MEMCACHED_SLABS_ALLOCATE_FAILED(size, id); } return ret; } static void do_slabs_free(void *ptr, const size_t size, unsigned int id) { slabclass_t *p; item *it; assert(((item *)ptr)->slabs_clsid == 0); assert(id >= POWER_SMALLEST && id <= power_largest); if (id < POWER_SMALLEST || id > power_largest) return; MEMCACHED_SLABS_FREE(size, id, ptr); p = &slabclass[id]; #ifdef USE_SYSTEM_MALLOC mem_malloced -= size; free(ptr); return; #endif it = (item *)ptr; it->it_flags |= ITEM_SLABBED; it->prev = 0; it->next = p->slots; if (it->next) it->next->prev = it; p->slots = it; p->sl_curr++; p->requested -= size; return; } static int nz_strcmp(int nzlength, const char *nz, const char *z) { int zlength=strlen(z); return (zlength == nzlength) && (strncmp(nz, z, zlength) == 0) ? 0 : -1; } bool get_stats(const char *stat_type, int nkey, ADD_STAT add_stats, void *c) { bool ret = true; if (add_stats != NULL) { if (!stat_type) { /* prepare general statistics for the engine */ STATS_LOCK(); APPEND_STAT("bytes", "%llu", (unsigned long long)stats.curr_bytes); APPEND_STAT("curr_items", "%u", stats.curr_items); APPEND_STAT("total_items", "%u", stats.total_items); APPEND_STAT("evictions", "%llu", (unsigned long long)stats.evictions); APPEND_STAT("reclaimed", "%llu", (unsigned long long)stats.reclaimed); STATS_UNLOCK(); } else if (nz_strcmp(nkey, stat_type, "items") == 0) { item_stats(add_stats, c); } else if (nz_strcmp(nkey, stat_type, "slabs") == 0) { slabs_stats(add_stats, c); } else if (nz_strcmp(nkey, stat_type, "sizes") == 0) { item_stats_sizes(add_stats, c); } else { ret = false; } } else { ret = false; } return ret; } /*@null@*/ static void do_slabs_stats(ADD_STAT add_stats, void *c) { int i, total; /* Get the per-thread stats which contain some interesting aggregates */ struct thread_stats thread_stats; threadlocal_stats_aggregate(&thread_stats); total = 0; for(i = POWER_SMALLEST; i <= power_largest; i++) { slabclass_t *p = &slabclass[i]; if (p->slabs != 0) { uint32_t perslab, slabs; slabs = p->slabs; perslab = p->perslab; char key_str[STAT_KEY_LEN]; char val_str[STAT_VAL_LEN]; int klen = 0, vlen = 0; APPEND_NUM_STAT(i, "chunk_size", "%u", p->size); APPEND_NUM_STAT(i, "chunks_per_page", "%u", perslab); APPEND_NUM_STAT(i, "total_pages", "%u", slabs); APPEND_NUM_STAT(i, "total_chunks", "%u", slabs * perslab); APPEND_NUM_STAT(i, "used_chunks", "%u", slabs*perslab - p->sl_curr - p->end_page_free); APPEND_NUM_STAT(i, "free_chunks", "%u", p->sl_curr); APPEND_NUM_STAT(i, "free_chunks_end", "%u", p->end_page_free); APPEND_NUM_STAT(i, "mem_requested", "%llu", (unsigned long long)p->requested); APPEND_NUM_STAT(i, "get_hits", "%llu", (unsigned long long)thread_stats.slab_stats[i].get_hits); APPEND_NUM_STAT(i, "cmd_set", "%llu", (unsigned long long)thread_stats.slab_stats[i].set_cmds); APPEND_NUM_STAT(i, "delete_hits", "%llu", (unsigned long long)thread_stats.slab_stats[i].delete_hits); APPEND_NUM_STAT(i, "incr_hits", "%llu", (unsigned long long)thread_stats.slab_stats[i].incr_hits); APPEND_NUM_STAT(i, "decr_hits", "%llu", (unsigned long long)thread_stats.slab_stats[i].decr_hits); APPEND_NUM_STAT(i, "cas_hits", "%llu", (unsigned long long)thread_stats.slab_stats[i].cas_hits); APPEND_NUM_STAT(i, "cas_badval", "%llu", (unsigned long long)thread_stats.slab_stats[i].cas_badval); APPEND_NUM_STAT(i, "touch_hits", "%llu", (unsigned long long)thread_stats.slab_stats[i].touch_hits); total++; } } /* add overall slab stats and append terminator */ APPEND_STAT("active_slabs", "%d", total); APPEND_STAT("total_malloced", "%llu", (unsigned long long)mem_malloced); add_stats(NULL, 0, NULL, 0, c); } static void *memory_allocate(size_t size) { void *ret; if (mem_base == NULL) { /* We are not using a preallocated large memory chunk */ ret = malloc(size); } else { ret = mem_current; if (size > mem_avail) { return NULL; } /* mem_current pointer _must_ be aligned!!! */ if (size % CHUNK_ALIGN_BYTES) { size += CHUNK_ALIGN_BYTES - (size % CHUNK_ALIGN_BYTES); } mem_current = ((char*)mem_current) + size; if (size < mem_avail) { mem_avail -= size; } else { mem_avail = 0; } } return ret; } void *slabs_alloc(size_t size, unsigned int id) { void *ret; pthread_mutex_lock(&slabs_lock); ret = do_slabs_alloc(size, id); pthread_mutex_unlock(&slabs_lock); return ret; } void slabs_free(void *ptr, size_t size, unsigned int id) { pthread_mutex_lock(&slabs_lock); do_slabs_free(ptr, size, id); pthread_mutex_unlock(&slabs_lock); } void slabs_stats(ADD_STAT add_stats, void *c) { pthread_mutex_lock(&slabs_lock); do_slabs_stats(add_stats, c); pthread_mutex_unlock(&slabs_lock); } void slabs_adjust_mem_requested(unsigned int id, size_t old, size_t ntotal) { pthread_mutex_lock(&slabs_lock); slabclass_t *p; if (id < POWER_SMALLEST || id > power_largest) { fprintf(stderr, "Internal error! Invalid slab class\n"); abort(); } p = &slabclass[id]; p->requested = p->requested - old + ntotal; pthread_mutex_unlock(&slabs_lock); } static pthread_cond_t maintenance_cond = PTHREAD_COND_INITIALIZER; static volatile int do_run_slab_thread = 1; #define DEFAULT_SLAB_BULK_CHECK 1 int slab_bulk_check = DEFAULT_SLAB_BULK_CHECK; static int slab_rebalance_start(void) { slabclass_t *s_cls; slabclass_t *d_cls; int no_go = 0; pthread_mutex_lock(&cache_lock); pthread_mutex_lock(&slabs_lock); if (slab_rebal.s_clsid < POWER_SMALLEST || slab_rebal.s_clsid > power_largest || slab_rebal.d_clsid < POWER_SMALLEST || slab_rebal.d_clsid > power_largest || slab_rebal.s_clsid == slab_rebal.d_clsid) no_go = -2; s_cls = &slabclass[slab_rebal.s_clsid]; d_cls = &slabclass[slab_rebal.d_clsid]; if (d_cls->end_page_ptr || s_cls->end_page_ptr || !grow_slab_list(slab_rebal.d_clsid)) { no_go = -1; } if (s_cls->slabs < 2) no_go = -3; if (no_go != 0) { pthread_mutex_unlock(&slabs_lock); pthread_mutex_unlock(&cache_lock); return no_go; /* Should use a wrapper function... */ } s_cls->killing = 1; slab_rebal.slab_start = s_cls->slab_list[s_cls->killing - 1]; slab_rebal.slab_end = (char *)slab_rebal.slab_start + (s_cls->size * s_cls->perslab); slab_rebal.slab_pos = slab_rebal.slab_start; slab_rebal.done = 0; /* Also tells do_item_get to search for items in this slab */ slab_rebalance_signal = 2; if (settings.verbose > 1) { fprintf(stderr, "Started a slab rebalance\n"); } pthread_mutex_unlock(&slabs_lock); pthread_mutex_unlock(&cache_lock); STATS_LOCK(); stats.slab_reassign_running = true; STATS_UNLOCK(); return 0; } enum move_status { MOVE_PASS=0, MOVE_DONE, MOVE_BUSY }; /* refcount == 0 is safe since nobody can incr while cache_lock is held. * refcount != 0 is impossible since flags/etc can be modified in other * threads. instead, note we found a busy one and bail. logic in do_item_get * will prevent busy items from continuing to be busy */ static int slab_rebalance_move(void) { slabclass_t *s_cls; int x; int was_busy = 0; int refcount = 0; enum move_status status = MOVE_PASS; pthread_mutex_lock(&cache_lock); pthread_mutex_lock(&slabs_lock); s_cls = &slabclass[slab_rebal.s_clsid]; for (x = 0; x < slab_bulk_check; x++) { item *it = slab_rebal.slab_pos; status = MOVE_PASS; if (it->slabs_clsid != 255) { refcount = refcount_incr(&it->refcount); if (refcount == 1) { /* item is unlinked, unused */ if (it->it_flags & ITEM_SLABBED) { /* remove from slab freelist */ if (s_cls->slots == it) { s_cls->slots = it->next; } if (it->next) it->next->prev = it->prev; if (it->prev) it->prev->next = it->next; s_cls->sl_curr--; status = MOVE_DONE; } else { status = MOVE_BUSY; } } else if (refcount == 2) { /* item is linked but not busy */ if ((it->it_flags & ITEM_LINKED) != 0) { do_item_unlink_nolock(it, hash(ITEM_key(it), it->nkey, 0)); status = MOVE_DONE; } else { /* refcount == 1 + !ITEM_LINKED means the item is being * uploaded to, or was just unlinked but hasn't been freed * yet. Let it bleed off on its own and try again later */ status = MOVE_BUSY; } } else { if (settings.verbose > 2) { fprintf(stderr, "Slab reassign hit a busy item: refcount: %d (%d -> %d)\n", it->refcount, slab_rebal.s_clsid, slab_rebal.d_clsid); } status = MOVE_BUSY; } } switch (status) { case MOVE_DONE: it->refcount = 0; it->it_flags = 0; it->slabs_clsid = 255; break; case MOVE_BUSY: slab_rebal.busy_items++; was_busy++; refcount_decr(&it->refcount); break; case MOVE_PASS: break; default: assert(false); abort(); } slab_rebal.slab_pos = (char *)slab_rebal.slab_pos + s_cls->size; if (slab_rebal.slab_pos >= slab_rebal.slab_end) break; } if (slab_rebal.slab_pos >= slab_rebal.slab_end) { /* Some items were busy, start again from the top */ if (slab_rebal.busy_items) { slab_rebal.slab_pos = slab_rebal.slab_start; slab_rebal.busy_items = 0; } else { slab_rebal.done++; } } pthread_mutex_unlock(&slabs_lock); pthread_mutex_unlock(&cache_lock); return was_busy; } static void slab_rebalance_finish(void) { slabclass_t *s_cls; slabclass_t *d_cls; pthread_mutex_lock(&cache_lock); pthread_mutex_lock(&slabs_lock); s_cls = &slabclass[slab_rebal.s_clsid]; d_cls = &slabclass[slab_rebal.d_clsid]; /* At this point the stolen slab is completely clear */ s_cls->slab_list[s_cls->killing - 1] = s_cls->slab_list[s_cls->slabs - 1]; s_cls->slabs--; s_cls->killing = 0; memset(slab_rebal.slab_start, 0, (size_t)settings.item_size_max); d_cls->slab_list[d_cls->slabs++] = slab_rebal.slab_start; d_cls->end_page_ptr = slab_rebal.slab_start; d_cls->end_page_free = d_cls->perslab; slab_rebal.done = 0; slab_rebal.s_clsid = 0; slab_rebal.d_clsid = 0; slab_rebal.slab_start = NULL; slab_rebal.slab_end = NULL; slab_rebal.slab_pos = NULL; slab_rebalance_signal = 0; pthread_mutex_unlock(&slabs_lock); pthread_mutex_unlock(&cache_lock); STATS_LOCK(); stats.slab_reassign_running = false; stats.slabs_moved++; STATS_UNLOCK(); if (settings.verbose > 1) { fprintf(stderr, "finished a slab move\n"); } } /* Return 1 means a decision was reached. * Move to its own thread (created/destroyed as needed) once automover is more * complex. */ static int slab_automove_decision(int *src, int *dst) { static uint64_t evicted_old[POWER_LARGEST]; static unsigned int slab_zeroes[POWER_LARGEST]; static unsigned int slab_winner = 0; static unsigned int slab_wins = 0; uint64_t evicted_new[POWER_LARGEST]; uint64_t evicted_diff = 0; uint64_t evicted_max = 0; unsigned int highest_slab = 0; unsigned int total_pages[POWER_LARGEST]; int i; int source = 0; int dest = 0; static rel_time_t next_run; /* Run less frequently than the slabmove tester. */ if (current_time >= next_run) { next_run = current_time + 10; } else { return 0; } item_stats_evictions(evicted_new); pthread_mutex_lock(&cache_lock); for (i = POWER_SMALLEST; i < power_largest; i++) { total_pages[i] = slabclass[i].slabs; } pthread_mutex_unlock(&cache_lock); /* Find a candidate source; something with zero evicts 3+ times */ for (i = POWER_SMALLEST; i < power_largest; i++) { evicted_diff = evicted_new[i] - evicted_old[i]; if (evicted_diff == 0 && total_pages[i] > 2) { slab_zeroes[i]++; if (source == 0 && slab_zeroes[i] >= 3) source = i; } else { slab_zeroes[i] = 0; if (evicted_diff > evicted_max) { evicted_max = evicted_diff; highest_slab = i; } } evicted_old[i] = evicted_new[i]; } /* Pick a valid destination */ if (slab_winner != 0 && slab_winner == highest_slab) { slab_wins++; if (slab_wins >= 3) dest = slab_winner; } else { slab_wins = 1; slab_winner = highest_slab; } if (source && dest) { *src = source; *dst = dest; return 1; } return 0; } #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wunused-parameter" #endif /* Slab rebalancer thread. * Does not use spinlocks since it is not timing sensitive. Burn less CPU and * go to sleep if locks are contended */ static void *slab_maintenance_thread(void *arg) { int was_busy = 0; int src, dest; while (do_run_slab_thread) { if (slab_rebalance_signal == 1) { if (slab_rebalance_start() < 0) { /* Handle errors with more specifity as required. */ slab_rebalance_signal = 0; } } else if (slab_rebalance_signal && slab_rebal.slab_start != NULL) { /* If we have a decision to continue, continue it */ was_busy = slab_rebalance_move(); } else if (settings.slab_automove && slab_automove_decision(&src, &dest) == 1) { /* Blind to the return codes. It will retry on its own */ slabs_reassign(src, dest); } if (slab_rebal.done) { slab_rebalance_finish(); } /* Sleep a bit if no work to do, or waiting on busy objects */ if (was_busy || !slab_rebalance_signal) sleep(1); } return NULL; } static enum reassign_result_type do_slabs_reassign(int src, int dst) { if (slab_rebalance_signal != 0) return REASSIGN_RUNNING; if (src == dst) return REASSIGN_SRC_DST_SAME; if (src < POWER_SMALLEST || src > power_largest || dst < POWER_SMALLEST || dst > power_largest) return REASSIGN_BADCLASS; if (slabclass[src].slabs < 2) return REASSIGN_NOSPARE; if (slabclass[dst].end_page_ptr) return REASSIGN_DEST_NOT_FULL; if (slabclass[src].end_page_ptr) return REASSIGN_SRC_NOT_SAFE; slab_rebal.s_clsid = src; slab_rebal.d_clsid = dst; slab_rebalance_signal = 1; return REASSIGN_OK; } enum reassign_result_type slabs_reassign(int src, int dst) { enum reassign_result_type ret; mutex_lock(&slabs_lock); ret = do_slabs_reassign(src, dst); pthread_mutex_unlock(&slabs_lock); return ret; } static pthread_t maintenance_tid; int start_slab_maintenance_thread(void) { int ret; slab_rebalance_signal = 0; slab_rebal.slab_start = NULL; char *env = getenv("MEMCACHED_SLAB_BULK_CHECK"); if (env != NULL) { slab_bulk_check = atoi(env); if (slab_bulk_check == 0) { slab_bulk_check = DEFAULT_SLAB_BULK_CHECK; } } if ((ret = pthread_create(&maintenance_tid, NULL, slab_maintenance_thread, NULL)) != 0) { fprintf(stderr, "Can't create thread: %s\n", strerror(ret)); return -1; } return 0; } void stop_slab_maintenance_thread(void) { mutex_lock(&cache_lock); do_run_slab_thread = 0; pthread_cond_signal(&maintenance_cond); pthread_mutex_unlock(&cache_lock); /* Wait for the maintenance thread to stop */ pthread_join(maintenance_tid, NULL); } libmemcached-1.0.8/memcached/include.am0000664000076400007640000000243511756366131020264 0ustar00brianbrian00000000000000# vim:ft=automake noinst_HEADERS+= memcached/assoc.h noinst_HEADERS+= memcached/cache.h noinst_HEADERS+= memcached/hash.h noinst_HEADERS+= memcached/items.h noinst_HEADERS+= memcached/memcached.h noinst_HEADERS+= memcached/protocol_binary.h noinst_HEADERS+= memcached/sasl_defs.h noinst_HEADERS+= memcached/slabs.h noinst_HEADERS+= memcached/stats.h noinst_HEADERS+= memcached/trace.h noinst_HEADERS+= memcached/util.h memcached_memcached_CFLAGS= memcached_memcached_LDADD= memcached_memcached_SOURCES= memcached_memcached_SOURCES+= memcached_memcached_SOURCES+= memcached/assoc.c memcached_memcached_SOURCES+= memcached/cache.c memcached_memcached_SOURCES+= memcached/daemon.c memcached_memcached_SOURCES+= memcached/hash.c memcached_memcached_SOURCES+= memcached/items.c memcached_memcached_SOURCES+= memcached/memcached.c memcached_memcached_SOURCES+= memcached/slabs.c memcached_memcached_SOURCES+= memcached/stats.c memcached_memcached_SOURCES+= memcached/thread.c memcached_memcached_SOURCES+= memcached/trace.h memcached_memcached_SOURCES+= memcached/util.c memcached_memcached_CFLAGS+= ${PTHREAD_CFLAGS} memcached_memcached_CFLAGS+= -DHAVE_CONFIG_H -std=c99 memcached_memcached_LDADD+= $(LIBEVENT_LDFLAGS) memcached_memcached_LDADD+= ${PTHREAD_LIBS} noinst_PROGRAMS+= memcached/memcached libmemcached-1.0.8/memcached/memcached.c0000664000076400007640000052303111753573717020403 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * memcached - memory caching daemon * * http://www.danga.com/memcached/ * * Copyright 2003 Danga Interactive, Inc. All rights reserved. * * Use and distribution licensed under the BSD license. See * the LICENSE file for full text. * * Authors: * Anatoly Vorobey * Brad Fitzpatrick */ #include "memcached.h" #include #include #include #include #include #include #include #include /* some POSIX systems need the following definition * to get mlockall flags out of sys/mman.h. */ #ifndef _P1003_1B_VISIBLE #define _P1003_1B_VISIBLE #endif /* need this to get IOV_MAX on some platforms. */ #ifndef __need_IOV_MAX #define __need_IOV_MAX #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* FreeBSD 4.x doesn't have IOV_MAX exposed. */ #ifndef IOV_MAX #if defined(__FreeBSD__) || defined(__APPLE__) # define IOV_MAX 1024 #endif #endif /* * forward declarations */ static void drive_machine(conn *c); static int new_socket(struct addrinfo *ai); static int try_read_command(conn *c); enum try_read_result { READ_DATA_RECEIVED, READ_NO_DATA_RECEIVED, READ_ERROR, /** an error occured (on the socket) (or client closed connection) */ READ_MEMORY_ERROR /** failed to allocate more memory */ }; static enum try_read_result try_read_network(conn *c); static enum try_read_result try_read_udp(conn *c); static void conn_set_state(conn *c, enum conn_states state); /* stats */ static void stats_init(void); static void server_stats(ADD_STAT add_stats, conn *c); static void process_stat_settings(ADD_STAT add_stats, void *c); /* defaults */ static void settings_init(void); /* event handling, network IO */ static void event_handler(const int fd, const short which, void *arg); static void conn_close(conn *c); static void conn_init(void); static bool update_event(conn *c, const int new_flags); static void complete_nread(conn *c); static void process_command(conn *c, char *command); static void write_and_free(conn *c, char *buf, int bytes); static int ensure_iov_space(conn *c); static int add_iov(conn *c, const void *buf, int len); static int add_msghdr(conn *c); static void conn_free(conn *c); /** exported globals **/ struct stats stats; struct settings settings; time_t process_started; /* when the process was started */ struct slab_rebalance slab_rebal; volatile int slab_rebalance_signal; /** file scope variables **/ static conn *listen_conn = NULL; static struct event_base *main_base; enum transmit_result { TRANSMIT_COMPLETE, /** All done writing. */ TRANSMIT_INCOMPLETE, /** More data remaining to write. */ TRANSMIT_SOFT_ERROR, /** Can't write any more right now. */ TRANSMIT_HARD_ERROR /** Can't write (c->state is set to conn_closing) */ }; static enum transmit_result transmit(conn *c); /* This reduces the latency without adding lots of extra wiring to be able to * notify the listener thread of when to listen again. * Also, the clock timer could be broken out into its own thread and we * can block the listener via a condition. */ static volatile bool allow_new_conns = true; static struct event maxconnsevent; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wunused-parameter" #endif static void maxconns_handler(const int fd, const short which, void *arg) { struct timeval t = {.tv_sec = 0, .tv_usec = 10000}; if (fd == -42 || allow_new_conns == false) { /* reschedule in 10ms if we need to keep polling */ evtimer_set(&maxconnsevent, maxconns_handler, 0); event_base_set(main_base, &maxconnsevent); evtimer_add(&maxconnsevent, &t); } else { evtimer_del(&maxconnsevent); accept_new_conns(true); } } #define REALTIME_MAXDELTA 60*60*24*30 /* * given time value that's either unix time or delta from current unix time, return * unix time. Use the fact that delta can't exceed one month (and real time value can't * be that low). */ static rel_time_t realtime(const time_t exptime) { /* no. of seconds in 30 days - largest possible delta exptime */ if (exptime == 0) return 0; /* 0 means never expire */ if (exptime > REALTIME_MAXDELTA) { /* if item expiration is at/before the server started, give it an expiration time of 1 second after the server started. (because 0 means don't expire). without this, we'd underflow and wrap around to some large value way in the future, effectively making items expiring in the past really expiring never */ if (exptime <= process_started) return (rel_time_t)1; return (rel_time_t)(exptime - process_started); } else { return (rel_time_t)(exptime + current_time); } } static void stats_init(void) { stats.curr_items = stats.total_items = stats.curr_conns = stats.total_conns = stats.conn_structs = 0; stats.get_cmds = stats.set_cmds = stats.get_hits = stats.get_misses = stats.evictions = stats.reclaimed = 0; stats.touch_cmds = stats.touch_misses = stats.touch_hits = stats.rejected_conns = 0; stats.curr_bytes = stats.listen_disabled_num = 0; stats.hash_power_level = stats.hash_bytes = stats.hash_is_expanding = 0; stats.expired_unfetched = stats.evicted_unfetched = 0; stats.slabs_moved = 0; stats.accepting_conns = true; /* assuming we start in this state. */ stats.slab_reassign_running = false; /* make the time we started always be 2 seconds before we really did, so time(0) - time.started is never zero. if so, things like 'settings.oldest_live' which act as booleans as well as values are now false in boolean context... */ process_started = time(0) - 2; stats_prefix_init(); } static void stats_reset(void) { STATS_LOCK(); stats.total_items = stats.total_conns = 0; stats.rejected_conns = 0; stats.evictions = 0; stats.reclaimed = 0; stats.listen_disabled_num = 0; stats_prefix_clear(); STATS_UNLOCK(); threadlocal_stats_reset(); item_stats_reset(); } static void settings_init(void) { settings.use_cas = true; settings.access = 0700; settings.port = 11211; settings.udpport = 11211; /* By default this string should be NULL for getaddrinfo() */ settings.inter = NULL; settings.maxbytes = 64 * 1024 * 1024; /* default is 64MB */ settings.maxconns = 1024; /* to limit connections-related memory to about 5MB */ settings.verbose = 0; settings.oldest_live = 0; settings.evict_to_free = 1; /* push old items out of cache when memory runs out */ settings.socketpath = NULL; /* by default, not using a unix socket */ settings.factor = 1.25; settings.chunk_size = 48; /* space for a modest key and value */ settings.num_threads = 4; /* N workers */ settings.num_threads_per_udp = 0; settings.prefix_delimiter = ':'; settings.detail_enabled = 0; settings.reqs_per_event = 20; settings.backlog = 1024; settings.binding_protocol = negotiating_prot; settings.item_size_max = 1024 * 1024; /* The famous 1MB upper limit. */ settings.maxconns_fast = false; settings.hashpower_init = 0; settings.slab_reassign = false; settings.slab_automove = false; } /* * Adds a message header to a connection. * * Returns 0 on success, -1 on out-of-memory. */ static int add_msghdr(conn *c) { struct msghdr *msg; assert(c != NULL); if (c->msgsize == c->msgused) { msg = realloc(c->msglist, c->msgsize * 2 * sizeof(struct msghdr)); if (! msg) return -1; c->msglist = msg; c->msgsize *= 2; } msg = c->msglist + c->msgused; /* this wipes msg_iovlen, msg_control, msg_controllen, and msg_flags, the last 3 of which aren't defined on solaris: */ memset(msg, 0, sizeof(struct msghdr)); msg->msg_iov = &c->iov[c->iovused]; if (c->request_addr_size > 0) { msg->msg_name = &c->request_addr; msg->msg_namelen = c->request_addr_size; } c->msgbytes = 0; c->msgused++; if (IS_UDP(c->transport)) { /* Leave room for the UDP header, which we'll fill in later. */ return add_iov(c, NULL, UDP_HEADER_SIZE); } return 0; } /* * Free list management for connections. */ static conn **freeconns; static int freetotal; static int freecurr; /* Lock for connection freelist */ static pthread_mutex_t conn_lock = PTHREAD_MUTEX_INITIALIZER; static void conn_init(void) { freetotal = 200; freecurr = 0; if ((freeconns = calloc(freetotal, sizeof(conn *))) == NULL) { fprintf(stderr, "Failed to allocate connection structures\n"); } return; } /* * Returns a connection from the freelist, if any. */ conn *conn_from_freelist() { conn *c; pthread_mutex_lock(&conn_lock); if (freecurr > 0) { c = freeconns[--freecurr]; } else { c = NULL; } pthread_mutex_unlock(&conn_lock); return c; } /* * Adds a connection to the freelist. 0 = success. */ bool conn_add_to_freelist(conn *c) { bool ret = true; pthread_mutex_lock(&conn_lock); if (freecurr < freetotal) { freeconns[freecurr++] = c; ret = false; } else { /* try to enlarge free connections array */ size_t newsize = freetotal * 2; conn **new_freeconns = realloc(freeconns, sizeof(conn *) * newsize); if (new_freeconns) { freetotal = newsize; freeconns = new_freeconns; freeconns[freecurr++] = c; ret = false; } } pthread_mutex_unlock(&conn_lock); return ret; } static const char *prot_text(enum protocol prot) { const char *rv = "unknown"; switch(prot) { case ascii_prot: rv = "ascii"; break; case binary_prot: rv = "binary"; break; case negotiating_prot: rv = "auto-negotiate"; break; default: abort(); } return rv; } conn *conn_new(const int sfd, enum conn_states init_state, const int event_flags, const int read_buffer_size, enum network_transport transport, struct event_base *base) { conn *c = conn_from_freelist(); if (NULL == c) { if (!(c = (conn *)calloc(1, sizeof(conn)))) { fprintf(stderr, "calloc()\n"); return NULL; } MEMCACHED_CONN_CREATE(c); c->rbuf = c->wbuf = 0; c->ilist = 0; c->suffixlist = 0; c->iov = 0; c->msglist = 0; c->hdrbuf = 0; c->rsize = read_buffer_size; c->wsize = DATA_BUFFER_SIZE; c->isize = ITEM_LIST_INITIAL; c->suffixsize = SUFFIX_LIST_INITIAL; c->iovsize = IOV_LIST_INITIAL; c->msgsize = MSG_LIST_INITIAL; c->hdrsize = 0; c->rbuf = (char *)malloc((size_t)c->rsize); c->wbuf = (char *)malloc((size_t)c->wsize); c->ilist = (item **)malloc(sizeof(item *) * c->isize); c->suffixlist = (char **)malloc(sizeof(char *) * c->suffixsize); c->iov = (struct iovec *)malloc(sizeof(struct iovec) * c->iovsize); c->msglist = (struct msghdr *)malloc(sizeof(struct msghdr) * c->msgsize); if (c->rbuf == 0 || c->wbuf == 0 || c->ilist == 0 || c->iov == 0 || c->msglist == 0 || c->suffixlist == 0) { conn_free(c); fprintf(stderr, "malloc()\n"); return NULL; } STATS_LOCK(); stats.conn_structs++; STATS_UNLOCK(); } c->transport = transport; c->protocol = settings.binding_protocol; /* unix socket mode doesn't need this, so zeroed out. but why * is this done for every command? presumably for UDP * mode. */ if (!settings.socketpath) { c->request_addr_size = sizeof(c->request_addr); } else { c->request_addr_size = 0; } if (settings.verbose > 1) { if (init_state == conn_listening) { fprintf(stderr, "<%d server listening (%s)\n", sfd, prot_text(c->protocol)); } else if (IS_UDP(transport)) { fprintf(stderr, "<%d server listening (udp)\n", sfd); } else if (c->protocol == negotiating_prot) { fprintf(stderr, "<%d new auto-negotiating client connection\n", sfd); } else if (c->protocol == ascii_prot) { fprintf(stderr, "<%d new ascii client connection.\n", sfd); } else if (c->protocol == binary_prot) { fprintf(stderr, "<%d new binary client connection.\n", sfd); } else { fprintf(stderr, "<%d new unknown (%d) client connection\n", sfd, c->protocol); assert(false); } } c->sfd = sfd; c->state = init_state; c->rlbytes = 0; c->cmd = -1; c->rbytes = c->wbytes = 0; c->wcurr = c->wbuf; c->rcurr = c->rbuf; c->ritem = 0; c->icurr = c->ilist; c->suffixcurr = c->suffixlist; c->ileft = 0; c->suffixleft = 0; c->iovused = 0; c->msgcurr = 0; c->msgused = 0; c->write_and_go = init_state; c->write_and_free = 0; c->item = 0; c->noreply = false; event_set(&c->event, sfd, event_flags, event_handler, (void *)c); event_base_set(base, &c->event); c->ev_flags = event_flags; if (event_add(&c->event, 0) == -1) { if (conn_add_to_freelist(c)) { conn_free(c); } perror("event_add"); return NULL; } STATS_LOCK(); stats.curr_conns++; stats.total_conns++; STATS_UNLOCK(); MEMCACHED_CONN_ALLOCATE(c->sfd); return c; } static void conn_cleanup(conn *c) { assert(c != NULL); if (c->item) { item_remove(c->item); c->item = 0; } if (c->ileft != 0) { for (; c->ileft > 0; c->ileft--,c->icurr++) { item_remove(*(c->icurr)); } } if (c->suffixleft != 0) { for (; c->suffixleft > 0; c->suffixleft--, c->suffixcurr++) { cache_free(c->thread->suffix_cache, *(c->suffixcurr)); } } if (c->write_and_free) { free(c->write_and_free); c->write_and_free = 0; } if (c->sasl_conn) { assert(settings.sasl); sasl_dispose(&c->sasl_conn); c->sasl_conn = NULL; } if (IS_UDP(c->transport)) { conn_set_state(c, conn_read); } } /* * Frees a connection. */ void conn_free(conn *c) { if (c) { MEMCACHED_CONN_DESTROY(c); if (c->hdrbuf) free(c->hdrbuf); if (c->msglist) free(c->msglist); if (c->rbuf) free(c->rbuf); if (c->wbuf) free(c->wbuf); if (c->ilist) free(c->ilist); if (c->suffixlist) free(c->suffixlist); if (c->iov) free(c->iov); free(c); } } static void conn_close(conn *c) { assert(c != NULL); /* delete the event, the socket and the conn */ event_del(&c->event); if (settings.verbose > 1) fprintf(stderr, "<%d connection closed.\n", c->sfd); MEMCACHED_CONN_RELEASE(c->sfd); close(c->sfd); pthread_mutex_lock(&conn_lock); allow_new_conns = true; pthread_mutex_unlock(&conn_lock); conn_cleanup(c); /* if the connection has big buffers, just free it */ if (c->rsize > READ_BUFFER_HIGHWAT || conn_add_to_freelist(c)) { conn_free(c); } STATS_LOCK(); stats.curr_conns--; STATS_UNLOCK(); return; } /* * Shrinks a connection's buffers if they're too big. This prevents * periodic large "get" requests from permanently chewing lots of server * memory. * * This should only be called in between requests since it can wipe output * buffers! */ static void conn_shrink(conn *c) { assert(c != NULL); if (IS_UDP(c->transport)) return; if (c->rsize > READ_BUFFER_HIGHWAT && c->rbytes < DATA_BUFFER_SIZE) { char *newbuf; if (c->rcurr != c->rbuf) memmove(c->rbuf, c->rcurr, (size_t)c->rbytes); newbuf = (char *)realloc((void *)c->rbuf, DATA_BUFFER_SIZE); if (newbuf) { c->rbuf = newbuf; c->rsize = DATA_BUFFER_SIZE; } /* TODO check other branch... */ c->rcurr = c->rbuf; } if (c->isize > ITEM_LIST_HIGHWAT) { item **newbuf = (item**) realloc((void *)c->ilist, ITEM_LIST_INITIAL * sizeof(c->ilist[0])); if (newbuf) { c->ilist = newbuf; c->isize = ITEM_LIST_INITIAL; } /* TODO check error condition? */ } if (c->msgsize > MSG_LIST_HIGHWAT) { struct msghdr *newbuf = (struct msghdr *) realloc((void *)c->msglist, MSG_LIST_INITIAL * sizeof(c->msglist[0])); if (newbuf) { c->msglist = newbuf; c->msgsize = MSG_LIST_INITIAL; } /* TODO check error condition? */ } if (c->iovsize > IOV_LIST_HIGHWAT) { struct iovec *newbuf = (struct iovec *) realloc((void *)c->iov, IOV_LIST_INITIAL * sizeof(c->iov[0])); if (newbuf) { c->iov = newbuf; c->iovsize = IOV_LIST_INITIAL; } /* TODO check return value */ } } /** * Convert a state name to a human readable form. */ static const char *state_text(enum conn_states state) { const char* const statenames[] = { "conn_listening", "conn_new_cmd", "conn_waiting", "conn_read", "conn_parse_cmd", "conn_write", "conn_nread", "conn_swallow", "conn_closing", "conn_mwrite" }; return statenames[state]; } #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wtype-limits" #endif /* * Sets a connection's current state in the state machine. Any special * processing that needs to happen on certain state transitions can * happen here. */ static void conn_set_state(conn *c, enum conn_states state) { assert(c != NULL); assert(state >= conn_listening && state < conn_max_state); if (state != c->state) { if (settings.verbose > 2) { fprintf(stderr, "%d: going from %s to %s\n", c->sfd, state_text(c->state), state_text(state)); } if (state == conn_write || state == conn_mwrite) { MEMCACHED_PROCESS_COMMAND_END(c->sfd, c->wbuf, c->wbytes); } c->state = state; } } /* * Ensures that there is room for another struct iovec in a connection's * iov list. * * Returns 0 on success, -1 on out-of-memory. */ static int ensure_iov_space(conn *c) { assert(c != NULL); if (c->iovused >= c->iovsize) { int i, iovnum; struct iovec *new_iov = (struct iovec *)realloc(c->iov, (c->iovsize * 2) * sizeof(struct iovec)); if (! new_iov) return -1; c->iov = new_iov; c->iovsize *= 2; /* Point all the msghdr structures at the new list. */ for (i = 0, iovnum = 0; i < c->msgused; i++) { c->msglist[i].msg_iov = &c->iov[iovnum]; iovnum += c->msglist[i].msg_iovlen; } } return 0; } /* * Adds data to the list of pending data that will be written out to a * connection. * * Returns 0 on success, -1 on out-of-memory. */ static int add_iov(conn *c, const void *buf, int len) { struct msghdr *m; int leftover; bool limit_to_mtu; assert(c != NULL); do { m = &c->msglist[c->msgused - 1]; /* * Limit UDP packets, and the first payloads of TCP replies, to * UDP_MAX_PAYLOAD_SIZE bytes. */ limit_to_mtu = IS_UDP(c->transport) || (1 == c->msgused); /* We may need to start a new msghdr if this one is full. */ if (m->msg_iovlen == IOV_MAX || (limit_to_mtu && c->msgbytes >= UDP_MAX_PAYLOAD_SIZE)) { add_msghdr(c); m = &c->msglist[c->msgused - 1]; } if (ensure_iov_space(c) != 0) return -1; /* If the fragment is too big to fit in the datagram, split it up */ if (limit_to_mtu && len + c->msgbytes > UDP_MAX_PAYLOAD_SIZE) { leftover = len + c->msgbytes - UDP_MAX_PAYLOAD_SIZE; len -= leftover; } else { leftover = 0; } m = &c->msglist[c->msgused - 1]; m->msg_iov[m->msg_iovlen].iov_base = (void *)buf; m->msg_iov[m->msg_iovlen].iov_len = len; c->msgbytes += len; c->iovused++; m->msg_iovlen++; buf = ((char *)buf) + len; len = leftover; } while (leftover > 0); return 0; } /* * Constructs a set of UDP headers and attaches them to the outgoing messages. */ static int build_udp_headers(conn *c) { int i; unsigned char *hdr; assert(c != NULL); if (c->msgused > c->hdrsize) { void *new_hdrbuf; if (c->hdrbuf) new_hdrbuf = realloc(c->hdrbuf, c->msgused * 2 * UDP_HEADER_SIZE); else new_hdrbuf = malloc(c->msgused * 2 * UDP_HEADER_SIZE); if (! new_hdrbuf) return -1; c->hdrbuf = (unsigned char *)new_hdrbuf; c->hdrsize = c->msgused * 2; } hdr = c->hdrbuf; for (i = 0; i < c->msgused; i++) { c->msglist[i].msg_iov[0].iov_base = (void*)hdr; c->msglist[i].msg_iov[0].iov_len = UDP_HEADER_SIZE; *hdr++ = c->request_id / 256; *hdr++ = c->request_id % 256; *hdr++ = i / 256; *hdr++ = i % 256; *hdr++ = c->msgused / 256; *hdr++ = c->msgused % 256; *hdr++ = 0; *hdr++ = 0; assert((void *) hdr == (caddr_t)c->msglist[i].msg_iov[0].iov_base + UDP_HEADER_SIZE); } return 0; } #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wsign-compare" #endif static void out_string(conn *c, const char *str) { size_t len; assert(c != NULL); if (c->noreply) { if (settings.verbose > 1) fprintf(stderr, ">%d NOREPLY %s\n", c->sfd, str); c->noreply = false; conn_set_state(c, conn_new_cmd); return; } if (settings.verbose > 1) fprintf(stderr, ">%d %s\n", c->sfd, str); /* Nuke a partial output... */ c->msgcurr = 0; c->msgused = 0; c->iovused = 0; add_msghdr(c); len = strlen(str); if ((len + 2) > c->wsize) { /* ought to be always enough. just fail for simplicity */ str = "SERVER_ERROR output line too long"; len = strlen(str); } memcpy(c->wbuf, str, len); memcpy(c->wbuf + len, "\r\n", 2); c->wbytes = len + 2; c->wcurr = c->wbuf; conn_set_state(c, conn_write); c->write_and_go = conn_new_cmd; return; } /* * we get here after reading the value in set/add/replace commands. The command * has been stored in c->cmd, and the item is ready in c->item. */ static void complete_nread_ascii(conn *c) { assert(c != NULL); item *it = c->item; int comm = c->cmd; enum store_item_type ret; pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.slab_stats[it->slabs_clsid].set_cmds++; pthread_mutex_unlock(&c->thread->stats.mutex); if (strncmp(ITEM_data(it) + it->nbytes - 2, "\r\n", 2) != 0) { out_string(c, "CLIENT_ERROR bad data chunk"); } else { ret = store_item(it, comm, c); #ifdef ENABLE_DTRACE uint64_t cas = ITEM_get_cas(it); switch (c->cmd) { case NREAD_ADD: MEMCACHED_COMMAND_ADD(c->sfd, ITEM_key(it), it->nkey, (ret == 1) ? it->nbytes : -1, cas); break; case NREAD_REPLACE: MEMCACHED_COMMAND_REPLACE(c->sfd, ITEM_key(it), it->nkey, (ret == 1) ? it->nbytes : -1, cas); break; case NREAD_APPEND: MEMCACHED_COMMAND_APPEND(c->sfd, ITEM_key(it), it->nkey, (ret == 1) ? it->nbytes : -1, cas); break; case NREAD_PREPEND: MEMCACHED_COMMAND_PREPEND(c->sfd, ITEM_key(it), it->nkey, (ret == 1) ? it->nbytes : -1, cas); break; case NREAD_SET: MEMCACHED_COMMAND_SET(c->sfd, ITEM_key(it), it->nkey, (ret == 1) ? it->nbytes : -1, cas); break; case NREAD_CAS: MEMCACHED_COMMAND_CAS(c->sfd, ITEM_key(it), it->nkey, it->nbytes, cas); break; } #endif switch (ret) { case STORED: out_string(c, "STORED"); break; case EXISTS: out_string(c, "EXISTS"); break; case NOT_FOUND: out_string(c, "NOT_FOUND"); break; case NOT_STORED: out_string(c, "NOT_STORED"); break; default: out_string(c, "SERVER_ERROR Unhandled storage type."); } } item_remove(c->item); /* release the c->item reference */ c->item = 0; } /** * get a pointer to the start of the request struct for the current command */ static void* binary_get_request(conn *c) { char *ret = c->rcurr; ret -= (sizeof(c->binary_header) + c->binary_header.request.keylen + c->binary_header.request.extlen); assert(ret >= c->rbuf); return ret; } /** * get a pointer to the key in this request */ static char* binary_get_key(conn *c) { return c->rcurr - (c->binary_header.request.keylen); } static void add_bin_header(conn *c, uint16_t err, uint8_t hdr_len, uint16_t key_len, uint32_t body_len) { protocol_binary_response_header* header; assert(c); c->msgcurr = 0; c->msgused = 0; c->iovused = 0; if (add_msghdr(c) != 0) { /* XXX: out_string is inappropriate here */ out_string(c, "SERVER_ERROR out of memory"); return; } header = (protocol_binary_response_header *)c->wbuf; header->response.magic = (uint8_t)PROTOCOL_BINARY_RES; header->response.opcode = c->binary_header.request.opcode; header->response.keylen = (uint16_t)htons(key_len); header->response.extlen = (uint8_t)hdr_len; header->response.datatype = (uint8_t)PROTOCOL_BINARY_RAW_BYTES; header->response.status = (uint16_t)htons(err); header->response.bodylen = htonl(body_len); header->response.opaque = c->opaque; header->response.cas = htonll(c->cas); if (settings.verbose > 1) { int ii; fprintf(stderr, ">%d Writing bin response:", c->sfd); for (ii = 0; ii < sizeof(header->bytes); ++ii) { if (ii % 4 == 0) { fprintf(stderr, "\n>%d ", c->sfd); } fprintf(stderr, " 0x%02x", header->bytes[ii]); } fprintf(stderr, "\n"); } add_iov(c, c->wbuf, sizeof(header->response)); } static void write_bin_error(conn *c, protocol_binary_response_status err, int swallow) { const char *errstr = "Unknown error"; size_t len; switch (err) { case PROTOCOL_BINARY_RESPONSE_ENOMEM: errstr = "Out of memory"; break; case PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND: errstr = "Unknown command"; break; case PROTOCOL_BINARY_RESPONSE_KEY_ENOENT: errstr = "Not found"; break; case PROTOCOL_BINARY_RESPONSE_EINVAL: errstr = "Invalid arguments"; break; case PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS: errstr = "Data exists for key."; break; case PROTOCOL_BINARY_RESPONSE_E2BIG: errstr = "Too large."; break; case PROTOCOL_BINARY_RESPONSE_DELTA_BADVAL: errstr = "Non-numeric server-side value for incr or decr"; break; case PROTOCOL_BINARY_RESPONSE_NOT_STORED: errstr = "Not stored."; break; case PROTOCOL_BINARY_RESPONSE_AUTH_ERROR: errstr = "Auth failure."; break; case PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE: assert(false); case PROTOCOL_BINARY_RESPONSE_SUCCESS: assert(false); default: assert(false); errstr = "UNHANDLED ERROR"; fprintf(stderr, ">%d UNHANDLED ERROR: %d\n", c->sfd, err); } if (settings.verbose > 1) { fprintf(stderr, ">%d Writing an error: %s\n", c->sfd, errstr); } len = strlen(errstr); add_bin_header(c, err, 0, 0, len); if (len > 0) { add_iov(c, errstr, len); } conn_set_state(c, conn_mwrite); if(swallow > 0) { c->sbytes = swallow; c->write_and_go = conn_swallow; } else { c->write_and_go = conn_new_cmd; } } /* Form and send a response to a command over the binary protocol */ static void write_bin_response(conn *c, const void *d, int hlen, int keylen, int dlen) { if (!c->noreply || c->cmd == PROTOCOL_BINARY_CMD_GET || c->cmd == PROTOCOL_BINARY_CMD_GETK) { add_bin_header(c, 0, hlen, keylen, dlen); if(dlen > 0) { add_iov(c, d, dlen); } conn_set_state(c, conn_mwrite); c->write_and_go = conn_new_cmd; } else { conn_set_state(c, conn_new_cmd); } } static void complete_incr_bin(conn *c) { item *it; char *key; size_t nkey; /* Weird magic in add_delta forces me to pad here */ char tmpbuf[INCR_MAX_STORAGE_LEN]; uint64_t cas = 0; protocol_binary_response_incr* rsp = (protocol_binary_response_incr*)c->wbuf; protocol_binary_request_incr* req = binary_get_request(c); assert(c != NULL); assert(c->wsize >= sizeof(*rsp)); /* fix byteorder in the request */ req->message.body.delta = ntohll(req->message.body.delta); req->message.body.initial = ntohll(req->message.body.initial); req->message.body.expiration = ntohl(req->message.body.expiration); key = binary_get_key(c); nkey = c->binary_header.request.keylen; if (settings.verbose > 1) { int i; fprintf(stderr, "incr "); for (i = 0; i < nkey; i++) { fprintf(stderr, "%c", key[i]); } fprintf(stderr, " %lld, %llu, %d\n", (long long)req->message.body.delta, (long long)req->message.body.initial, req->message.body.expiration); } if (c->binary_header.request.cas != 0) { cas = c->binary_header.request.cas; } switch(add_delta(c, key, nkey, c->cmd == PROTOCOL_BINARY_CMD_INCREMENT, req->message.body.delta, tmpbuf, &cas)) { case OK: rsp->message.body.value = htonll(strtoull(tmpbuf, NULL, 10)); if (cas) { c->cas = cas; } write_bin_response(c, &rsp->message.body, 0, 0, sizeof(rsp->message.body.value)); break; case NON_NUMERIC: write_bin_error(c, PROTOCOL_BINARY_RESPONSE_DELTA_BADVAL, 0); break; case EOM: write_bin_error(c, PROTOCOL_BINARY_RESPONSE_ENOMEM, 0); break; case DELTA_ITEM_NOT_FOUND: if (req->message.body.expiration != 0xffffffff) { /* Save some room for the response */ rsp->message.body.value = htonll(req->message.body.initial); it = item_alloc(key, nkey, 0, realtime(req->message.body.expiration), INCR_MAX_STORAGE_LEN); if (it != NULL) { snprintf(ITEM_data(it), INCR_MAX_STORAGE_LEN, "%llu", (unsigned long long)req->message.body.initial); if (store_item(it, NREAD_ADD, c)) { c->cas = ITEM_get_cas(it); write_bin_response(c, &rsp->message.body, 0, 0, sizeof(rsp->message.body.value)); } else { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_NOT_STORED, 0); } item_remove(it); /* release our reference */ } else { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_ENOMEM, 0); } } else { pthread_mutex_lock(&c->thread->stats.mutex); if (c->cmd == PROTOCOL_BINARY_CMD_INCREMENT) { c->thread->stats.incr_misses++; } else { c->thread->stats.decr_misses++; } pthread_mutex_unlock(&c->thread->stats.mutex); write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0); } break; case DELTA_ITEM_CAS_MISMATCH: write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS, 0); break; default: assert(0); abort(); } } static void complete_update_bin(conn *c) { protocol_binary_response_status eno = PROTOCOL_BINARY_RESPONSE_EINVAL; enum store_item_type ret = NOT_STORED; assert(c != NULL); item *it = c->item; pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.slab_stats[it->slabs_clsid].set_cmds++; pthread_mutex_unlock(&c->thread->stats.mutex); /* We don't actually receive the trailing two characters in the bin * protocol, so we're going to just set them here */ *(ITEM_data(it) + it->nbytes - 2) = '\r'; *(ITEM_data(it) + it->nbytes - 1) = '\n'; ret = store_item(it, c->cmd, c); #ifdef ENABLE_DTRACE uint64_t cas = ITEM_get_cas(it); switch (c->cmd) { case NREAD_ADD: MEMCACHED_COMMAND_ADD(c->sfd, ITEM_key(it), it->nkey, (ret == STORED) ? it->nbytes : -1, cas); break; case NREAD_REPLACE: MEMCACHED_COMMAND_REPLACE(c->sfd, ITEM_key(it), it->nkey, (ret == STORED) ? it->nbytes : -1, cas); break; case NREAD_APPEND: MEMCACHED_COMMAND_APPEND(c->sfd, ITEM_key(it), it->nkey, (ret == STORED) ? it->nbytes : -1, cas); break; case NREAD_PREPEND: MEMCACHED_COMMAND_PREPEND(c->sfd, ITEM_key(it), it->nkey, (ret == STORED) ? it->nbytes : -1, cas); break; case NREAD_SET: MEMCACHED_COMMAND_SET(c->sfd, ITEM_key(it), it->nkey, (ret == STORED) ? it->nbytes : -1, cas); break; } #endif switch (ret) { case STORED: /* Stored */ write_bin_response(c, NULL, 0, 0, 0); break; case EXISTS: write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS, 0); break; case NOT_FOUND: write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0); break; case NOT_STORED: if (c->cmd == NREAD_ADD) { eno = PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; } else if(c->cmd == NREAD_REPLACE) { eno = PROTOCOL_BINARY_RESPONSE_KEY_ENOENT; } else { eno = PROTOCOL_BINARY_RESPONSE_NOT_STORED; } write_bin_error(c, eno, 0); default: assert(false); abort(); } item_remove(c->item); /* release the c->item reference */ c->item = 0; } static void process_bin_touch(conn *c) { item *it; protocol_binary_response_get* rsp = (protocol_binary_response_get*)c->wbuf; char* key = binary_get_key(c); size_t nkey = c->binary_header.request.keylen; protocol_binary_request_touch *t = (void *)&c->binary_header; uint32_t exptime = ntohl(t->message.body.expiration); if (settings.verbose > 1) { int ii; /* May be GAT/GATQ/etc */ fprintf(stderr, "<%d TOUCH ", c->sfd); for (ii = 0; ii < nkey; ++ii) { fprintf(stderr, "%c", key[ii]); } fprintf(stderr, "\n"); } it = item_touch(key, nkey, realtime(exptime)); if (it) { /* the length has two unnecessary bytes ("\r\n") */ uint16_t keylen = 0; uint32_t bodylen = sizeof(rsp->message.body) + (it->nbytes - 2); item_update(it); pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.touch_cmds++; c->thread->stats.slab_stats[it->slabs_clsid].touch_hits++; pthread_mutex_unlock(&c->thread->stats.mutex); MEMCACHED_COMMAND_TOUCH(c->sfd, ITEM_key(it), it->nkey, it->nbytes, ITEM_get_cas(it)); if (c->cmd == PROTOCOL_BINARY_CMD_TOUCH) { bodylen -= it->nbytes - 2; } else if (c->cmd == PROTOCOL_BINARY_CMD_GATK) { bodylen += nkey; keylen = nkey; } add_bin_header(c, 0, sizeof(rsp->message.body), keylen, bodylen); rsp->message.header.response.cas = htonll(ITEM_get_cas(it)); // add the flags rsp->message.body.flags = htonl(strtoul(ITEM_suffix(it), NULL, 10)); add_iov(c, &rsp->message.body, sizeof(rsp->message.body)); if (c->cmd == PROTOCOL_BINARY_CMD_GATK) { add_iov(c, ITEM_key(it), nkey); } /* Add the data minus the CRLF */ if (c->cmd != PROTOCOL_BINARY_CMD_TOUCH) { add_iov(c, ITEM_data(it), it->nbytes - 2); } conn_set_state(c, conn_mwrite); c->write_and_go = conn_new_cmd; /* Remember this command so we can garbage collect it later */ c->item = it; } else { pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.touch_cmds++; c->thread->stats.touch_misses++; pthread_mutex_unlock(&c->thread->stats.mutex); MEMCACHED_COMMAND_TOUCH(c->sfd, key, nkey, -1, 0); if (c->noreply) { conn_set_state(c, conn_new_cmd); } else { if (c->cmd == PROTOCOL_BINARY_CMD_GATK) { char *ofs = c->wbuf + sizeof(protocol_binary_response_header); add_bin_header(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0, nkey, nkey); memcpy(ofs, key, nkey); add_iov(c, ofs, nkey); conn_set_state(c, conn_mwrite); c->write_and_go = conn_new_cmd; } else { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0); } } } if (settings.detail_enabled) { stats_prefix_record_get(key, nkey, NULL != it); } } static void process_bin_get(conn *c) { item *it; protocol_binary_response_get* rsp = (protocol_binary_response_get*)c->wbuf; char* key = binary_get_key(c); size_t nkey = c->binary_header.request.keylen; if (settings.verbose > 1) { int ii; fprintf(stderr, "<%d GET ", c->sfd); for (ii = 0; ii < nkey; ++ii) { fprintf(stderr, "%c", key[ii]); } fprintf(stderr, "\n"); } it = item_get(key, nkey); if (it) { /* the length has two unnecessary bytes ("\r\n") */ uint16_t keylen = 0; uint32_t bodylen = sizeof(rsp->message.body) + (it->nbytes - 2); item_update(it); pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.get_cmds++; c->thread->stats.slab_stats[it->slabs_clsid].get_hits++; pthread_mutex_unlock(&c->thread->stats.mutex); MEMCACHED_COMMAND_GET(c->sfd, ITEM_key(it), it->nkey, it->nbytes, ITEM_get_cas(it)); if (c->cmd == PROTOCOL_BINARY_CMD_GETK) { bodylen += nkey; keylen = nkey; } add_bin_header(c, 0, sizeof(rsp->message.body), keylen, bodylen); rsp->message.header.response.cas = htonll(ITEM_get_cas(it)); // add the flags rsp->message.body.flags = htonl(strtoul(ITEM_suffix(it), NULL, 10)); add_iov(c, &rsp->message.body, sizeof(rsp->message.body)); if (c->cmd == PROTOCOL_BINARY_CMD_GETK) { add_iov(c, ITEM_key(it), nkey); } /* Add the data minus the CRLF */ add_iov(c, ITEM_data(it), it->nbytes - 2); conn_set_state(c, conn_mwrite); c->write_and_go = conn_new_cmd; /* Remember this command so we can garbage collect it later */ c->item = it; } else { pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.get_cmds++; c->thread->stats.get_misses++; pthread_mutex_unlock(&c->thread->stats.mutex); MEMCACHED_COMMAND_GET(c->sfd, key, nkey, -1, 0); if (c->noreply) { conn_set_state(c, conn_new_cmd); } else { if (c->cmd == PROTOCOL_BINARY_CMD_GETK) { char *ofs = c->wbuf + sizeof(protocol_binary_response_header); add_bin_header(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0, nkey, nkey); memcpy(ofs, key, nkey); add_iov(c, ofs, nkey); conn_set_state(c, conn_mwrite); c->write_and_go = conn_new_cmd; } else { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0); } } } if (settings.detail_enabled) { stats_prefix_record_get(key, nkey, NULL != it); } } #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #endif static void append_bin_stats(const char *key, const uint16_t klen, const char *val, const uint32_t vlen, conn *c) { char *buf = c->stats.buffer + c->stats.offset; uint32_t bodylen = klen + vlen; protocol_binary_response_header header = { .response.magic = (uint8_t)PROTOCOL_BINARY_RES, .response.opcode = (uint8_t)PROTOCOL_BINARY_CMD_STAT, .response.keylen = (uint16_t)htons(klen), .response.extlen = (uint8_t)0, .response.datatype = (uint8_t)PROTOCOL_BINARY_RAW_BYTES, .response.status = (uint16_t)0, .response.bodylen = htonl(bodylen), .response.opaque = c->opaque, .response.cas = (uint64_t)0 }; memcpy(buf, header.bytes, sizeof(header.response)); buf += sizeof(header.response); if (klen > 0) { memcpy(buf, key, klen); buf += klen; if (vlen > 0) { memcpy(buf, val, vlen); } } c->stats.offset += sizeof(header.response) + bodylen; } static void append_ascii_stats(const char *key, const uint16_t klen, const char *val, const uint32_t vlen, conn *c) { char *pos = c->stats.buffer + c->stats.offset; uint32_t nbytes = 0; int remaining = c->stats.size - c->stats.offset; int room = remaining - 1; if (klen == 0 && vlen == 0) { nbytes = snprintf(pos, room, "END\r\n"); } else if (vlen == 0) { nbytes = snprintf(pos, room, "STAT %s\r\n", key); } else { nbytes = snprintf(pos, room, "STAT %s %s\r\n", key, val); } c->stats.offset += nbytes; } static bool grow_stats_buf(conn *c, size_t needed) { size_t nsize = c->stats.size; size_t available = nsize - c->stats.offset; bool rv = true; /* Special case: No buffer -- need to allocate fresh */ if (c->stats.buffer == NULL) { nsize = 1024; available = c->stats.size = c->stats.offset = 0; } while (needed > available) { assert(nsize > 0); nsize = nsize << 1; available = nsize - c->stats.offset; } if (nsize != c->stats.size) { char *ptr = realloc(c->stats.buffer, nsize); if (ptr) { c->stats.buffer = ptr; c->stats.size = nsize; } else { rv = false; } } return rv; } static void append_stats(const char *key, const uint16_t klen, const char *val, const uint32_t vlen, const void *cookie) { /* value without a key is invalid */ if (klen == 0 && vlen > 0) { return ; } conn *c = (conn*)cookie; if (c->protocol == binary_prot) { size_t needed = vlen + klen + sizeof(protocol_binary_response_header); if (!grow_stats_buf(c, needed)) { return ; } append_bin_stats(key, klen, val, vlen, c); } else { size_t needed = vlen + klen + 10; // 10 == "STAT = \r\n" if (!grow_stats_buf(c, needed)) { return ; } append_ascii_stats(key, klen, val, vlen, c); } assert(c->stats.offset <= c->stats.size); } static void process_bin_stat(conn *c) { char *subcommand = binary_get_key(c); size_t nkey = c->binary_header.request.keylen; if (settings.verbose > 1) { int ii; fprintf(stderr, "<%d STATS ", c->sfd); for (ii = 0; ii < nkey; ++ii) { fprintf(stderr, "%c", subcommand[ii]); } fprintf(stderr, "\n"); } if (nkey == 0) { /* request all statistics */ server_stats(&append_stats, c); (void)get_stats(NULL, 0, &append_stats, c); } else if (strncmp(subcommand, "reset", 5) == 0) { stats_reset(); } else if (strncmp(subcommand, "settings", 8) == 0) { process_stat_settings(&append_stats, c); } else if (strncmp(subcommand, "detail", 6) == 0) { char *subcmd_pos = subcommand + 6; if (strncmp(subcmd_pos, " dump", 5) == 0) { int len; char *dump_buf = stats_prefix_dump(&len); if (dump_buf == NULL || len <= 0) { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_ENOMEM, 0); return ; } else { append_stats("detailed", strlen("detailed"), dump_buf, len, c); free(dump_buf); } } else if (strncmp(subcmd_pos, " on", 3) == 0) { settings.detail_enabled = 1; } else if (strncmp(subcmd_pos, " off", 4) == 0) { settings.detail_enabled = 0; } else { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0); return; } } else { if (get_stats(subcommand, nkey, &append_stats, c)) { if (c->stats.buffer == NULL) { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_ENOMEM, 0); } else { write_and_free(c, c->stats.buffer, c->stats.offset); c->stats.buffer = NULL; } } else { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0); } return; } /* Append termination package and start the transfer */ append_stats(NULL, 0, NULL, 0, c); if (c->stats.buffer == NULL) { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_ENOMEM, 0); } else { write_and_free(c, c->stats.buffer, c->stats.offset); c->stats.buffer = NULL; } } static void bin_read_key(conn *c, enum bin_substates next_substate, int extra) { assert(c); c->substate = next_substate; c->rlbytes = c->keylen + extra; /* Ok... do we have room for the extras and the key in the input buffer? */ ptrdiff_t offset = c->rcurr + sizeof(protocol_binary_request_header) - c->rbuf; if (c->rlbytes > c->rsize - offset) { size_t nsize = c->rsize; size_t size = c->rlbytes + sizeof(protocol_binary_request_header); while (size > nsize) { nsize *= 2; } if (nsize != c->rsize) { if (settings.verbose > 1) { fprintf(stderr, "%d: Need to grow buffer from %lu to %lu\n", c->sfd, (unsigned long)c->rsize, (unsigned long)nsize); } char *newm = realloc(c->rbuf, nsize); if (newm == NULL) { if (settings.verbose) { fprintf(stderr, "%d: Failed to grow buffer.. closing connection\n", c->sfd); } conn_set_state(c, conn_closing); return; } c->rbuf= newm; /* rcurr should point to the same offset in the packet */ c->rcurr = c->rbuf + offset - sizeof(protocol_binary_request_header); c->rsize = nsize; } if (c->rbuf != c->rcurr) { memmove(c->rbuf, c->rcurr, c->rbytes); c->rcurr = c->rbuf; if (settings.verbose > 1) { fprintf(stderr, "%d: Repack input buffer\n", c->sfd); } } } /* preserve the header in the buffer.. */ c->ritem = c->rcurr + sizeof(protocol_binary_request_header); conn_set_state(c, conn_nread); } /* Just write an error message and disconnect the client */ static void handle_binary_protocol_error(conn *c) { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_EINVAL, 0); if (settings.verbose) { fprintf(stderr, "Protocol error (opcode %02x), close connection %d\n", c->binary_header.request.opcode, c->sfd); } c->write_and_go = conn_closing; } static void init_sasl_conn(conn *c) { assert(c); /* should something else be returned? */ if (!settings.sasl) return; if (!c->sasl_conn) { int result=sasl_server_new("memcached", NULL, my_sasl_hostname[0] ? my_sasl_hostname : NULL, NULL, NULL, NULL, 0, &c->sasl_conn); if (result != SASL_OK) { if (settings.verbose) { fprintf(stderr, "Failed to initialize SASL conn.\n"); } c->sasl_conn = NULL; } } } static void bin_list_sasl_mechs(conn *c) { // Guard against a disabled SASL. if (!settings.sasl) { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND, c->binary_header.request.bodylen - c->binary_header.request.keylen); return; } init_sasl_conn(c); const char *result_string = NULL; unsigned int string_length = 0; int result=sasl_listmech(c->sasl_conn, NULL, "", /* What to prepend the string with */ " ", /* What to separate mechanisms with */ "", /* What to append to the string */ &result_string, &string_length, NULL); if (result != SASL_OK) { /* Perhaps there's a better error for this... */ if (settings.verbose) { fprintf(stderr, "Failed to list SASL mechanisms.\n"); } write_bin_error(c, PROTOCOL_BINARY_RESPONSE_AUTH_ERROR, 0); return; } write_bin_response(c, (char*)result_string, 0, 0, string_length); } static void process_bin_sasl_auth(conn *c) { // Guard for handling disabled SASL on the server. if (!settings.sasl) { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND, c->binary_header.request.bodylen - c->binary_header.request.keylen); return; } assert(c->binary_header.request.extlen == 0); int nkey = c->binary_header.request.keylen; int vlen = c->binary_header.request.bodylen - nkey; if (nkey > MAX_SASL_MECH_LEN) { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_EINVAL, vlen); c->write_and_go = conn_swallow; return; } char *key = binary_get_key(c); assert(key); item *it = item_alloc(key, nkey, 0, 0, vlen); if (it == 0) { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_ENOMEM, vlen); c->write_and_go = conn_swallow; return; } c->item = it; c->ritem = ITEM_data(it); c->rlbytes = vlen; conn_set_state(c, conn_nread); c->substate = bin_reading_sasl_auth_data; } static void process_bin_complete_sasl_auth(conn *c) { assert(settings.sasl); const char *out = NULL; unsigned int outlen = 0; assert(c->item); init_sasl_conn(c); int nkey = c->binary_header.request.keylen; int vlen = c->binary_header.request.bodylen - nkey; char mech[nkey+1]; memcpy(mech, ITEM_key((item*)c->item), nkey); mech[nkey] = 0x00; if (settings.verbose) fprintf(stderr, "mech: ``%s'' with %d bytes of data\n", mech, vlen); const char *challenge = vlen == 0 ? NULL : ITEM_data((item*) c->item); int result=-1; switch (c->cmd) { case PROTOCOL_BINARY_CMD_SASL_AUTH: result = sasl_server_start(c->sasl_conn, mech, challenge, vlen, &out, &outlen); break; case PROTOCOL_BINARY_CMD_SASL_STEP: result = sasl_server_step(c->sasl_conn, challenge, vlen, &out, &outlen); break; default: assert(false); /* CMD should be one of the above */ /* This code is pretty much impossible, but makes the compiler happier */ if (settings.verbose) { fprintf(stderr, "Unhandled command %d with challenge %s\n", c->cmd, challenge); } break; } item_unlink(c->item); if (settings.verbose) { fprintf(stderr, "sasl result code: %d\n", result); } switch(result) { case SASL_OK: write_bin_response(c, "Authenticated", 0, 0, strlen("Authenticated")); pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.auth_cmds++; pthread_mutex_unlock(&c->thread->stats.mutex); break; case SASL_CONTINUE: add_bin_header(c, PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE, 0, 0, outlen); if(outlen > 0) { add_iov(c, out, outlen); } conn_set_state(c, conn_mwrite); c->write_and_go = conn_new_cmd; break; default: if (settings.verbose) fprintf(stderr, "Unknown sasl response: %d\n", result); write_bin_error(c, PROTOCOL_BINARY_RESPONSE_AUTH_ERROR, 0); pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.auth_cmds++; c->thread->stats.auth_errors++; pthread_mutex_unlock(&c->thread->stats.mutex); } } static bool authenticated(conn *c) { assert(settings.sasl); bool rv = false; switch (c->cmd) { case PROTOCOL_BINARY_CMD_SASL_LIST_MECHS: /* FALLTHROUGH */ case PROTOCOL_BINARY_CMD_SASL_AUTH: /* FALLTHROUGH */ case PROTOCOL_BINARY_CMD_SASL_STEP: /* FALLTHROUGH */ case PROTOCOL_BINARY_CMD_VERSION: /* FALLTHROUGH */ rv = true; break; default: if (c->sasl_conn) { const void *uname = NULL; sasl_getprop(c->sasl_conn, SASL_USERNAME, &uname); rv = uname != NULL; } } if (settings.verbose > 1) { fprintf(stderr, "authenticated() in cmd 0x%02x is %s\n", c->cmd, rv ? "true" : "false"); } return rv; } static void dispatch_bin_command(conn *c) { int protocol_error = 0; int extlen = c->binary_header.request.extlen; int keylen = c->binary_header.request.keylen; uint32_t bodylen = c->binary_header.request.bodylen; if (settings.sasl && !authenticated(c)) { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_AUTH_ERROR, 0); c->write_and_go = conn_closing; return; } MEMCACHED_PROCESS_COMMAND_START(c->sfd, c->rcurr, c->rbytes); c->noreply = true; /* binprot supports 16bit keys, but internals are still 8bit */ if (keylen > KEY_MAX_LENGTH) { handle_binary_protocol_error(c); return; } switch (c->cmd) { case PROTOCOL_BINARY_CMD_SETQ: c->cmd = PROTOCOL_BINARY_CMD_SET; break; case PROTOCOL_BINARY_CMD_ADDQ: c->cmd = PROTOCOL_BINARY_CMD_ADD; break; case PROTOCOL_BINARY_CMD_REPLACEQ: c->cmd = PROTOCOL_BINARY_CMD_REPLACE; break; case PROTOCOL_BINARY_CMD_DELETEQ: c->cmd = PROTOCOL_BINARY_CMD_DELETE; break; case PROTOCOL_BINARY_CMD_INCREMENTQ: c->cmd = PROTOCOL_BINARY_CMD_INCREMENT; break; case PROTOCOL_BINARY_CMD_DECREMENTQ: c->cmd = PROTOCOL_BINARY_CMD_DECREMENT; break; case PROTOCOL_BINARY_CMD_QUITQ: c->cmd = PROTOCOL_BINARY_CMD_QUIT; break; case PROTOCOL_BINARY_CMD_FLUSHQ: c->cmd = PROTOCOL_BINARY_CMD_FLUSH; break; case PROTOCOL_BINARY_CMD_APPENDQ: c->cmd = PROTOCOL_BINARY_CMD_APPEND; break; case PROTOCOL_BINARY_CMD_PREPENDQ: c->cmd = PROTOCOL_BINARY_CMD_PREPEND; break; case PROTOCOL_BINARY_CMD_GETQ: c->cmd = PROTOCOL_BINARY_CMD_GET; break; case PROTOCOL_BINARY_CMD_GETKQ: c->cmd = PROTOCOL_BINARY_CMD_GETK; break; case PROTOCOL_BINARY_CMD_GATQ: c->cmd = PROTOCOL_BINARY_CMD_GAT; break; case PROTOCOL_BINARY_CMD_GATKQ: c->cmd = PROTOCOL_BINARY_CMD_GAT; break; default: c->noreply = false; } switch (c->cmd) { case PROTOCOL_BINARY_CMD_VERSION: if (extlen == 0 && keylen == 0 && bodylen == 0) { write_bin_response(c, RVERSION, 0, 0, strlen(RVERSION)); } else { protocol_error = 1; } break; case PROTOCOL_BINARY_CMD_FLUSH: if (keylen == 0 && bodylen == extlen && (extlen == 0 || extlen == 4)) { bin_read_key(c, bin_read_flush_exptime, extlen); } else { protocol_error = 1; } break; case PROTOCOL_BINARY_CMD_NOOP: if (extlen == 0 && keylen == 0 && bodylen == 0) { write_bin_response(c, NULL, 0, 0, 0); } else { protocol_error = 1; } break; case PROTOCOL_BINARY_CMD_SET: /* FALLTHROUGH */ case PROTOCOL_BINARY_CMD_ADD: /* FALLTHROUGH */ case PROTOCOL_BINARY_CMD_REPLACE: if (extlen == 8 && keylen != 0 && bodylen >= (keylen + 8)) { bin_read_key(c, bin_reading_set_header, 8); } else { protocol_error = 1; } break; case PROTOCOL_BINARY_CMD_GETQ: /* FALLTHROUGH */ case PROTOCOL_BINARY_CMD_GET: /* FALLTHROUGH */ case PROTOCOL_BINARY_CMD_GETKQ: /* FALLTHROUGH */ case PROTOCOL_BINARY_CMD_GETK: if (extlen == 0 && bodylen == keylen && keylen > 0) { bin_read_key(c, bin_reading_get_key, 0); } else { protocol_error = 1; } break; case PROTOCOL_BINARY_CMD_DELETE: if (keylen > 0 && extlen == 0 && bodylen == keylen) { bin_read_key(c, bin_reading_del_header, extlen); } else { protocol_error = 1; } break; case PROTOCOL_BINARY_CMD_INCREMENT: case PROTOCOL_BINARY_CMD_DECREMENT: if (keylen > 0 && extlen == 20 && bodylen == (keylen + extlen)) { bin_read_key(c, bin_reading_incr_header, 20); } else { protocol_error = 1; } break; case PROTOCOL_BINARY_CMD_APPEND: case PROTOCOL_BINARY_CMD_PREPEND: if (keylen > 0 && extlen == 0) { bin_read_key(c, bin_reading_set_header, 0); } else { protocol_error = 1; } break; case PROTOCOL_BINARY_CMD_STAT: if (extlen == 0) { bin_read_key(c, bin_reading_stat, 0); } else { protocol_error = 1; } break; case PROTOCOL_BINARY_CMD_QUIT: if (keylen == 0 && extlen == 0 && bodylen == 0) { write_bin_response(c, NULL, 0, 0, 0); c->write_and_go = conn_closing; if (c->noreply) { conn_set_state(c, conn_closing); } } else { protocol_error = 1; } break; case PROTOCOL_BINARY_CMD_SASL_LIST_MECHS: if (extlen == 0 && keylen == 0 && bodylen == 0) { bin_list_sasl_mechs(c); } else { protocol_error = 1; } break; case PROTOCOL_BINARY_CMD_SASL_AUTH: case PROTOCOL_BINARY_CMD_SASL_STEP: if (extlen == 0 && keylen != 0) { bin_read_key(c, bin_reading_sasl_auth, 0); } else { protocol_error = 1; } break; case PROTOCOL_BINARY_CMD_TOUCH: case PROTOCOL_BINARY_CMD_GAT: case PROTOCOL_BINARY_CMD_GATQ: case PROTOCOL_BINARY_CMD_GATK: case PROTOCOL_BINARY_CMD_GATKQ: if (extlen == 4 && keylen != 0) { bin_read_key(c, bin_reading_touch_key, 4); } else { protocol_error = 1; } break; default: write_bin_error(c, PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND, bodylen); } if (protocol_error) handle_binary_protocol_error(c); } static void process_bin_update(conn *c) { char *key; int nkey; int vlen; item *it; protocol_binary_request_set* req = binary_get_request(c); assert(c != NULL); key = binary_get_key(c); nkey = c->binary_header.request.keylen; /* fix byteorder in the request */ req->message.body.flags = ntohl(req->message.body.flags); req->message.body.expiration = ntohl(req->message.body.expiration); vlen = c->binary_header.request.bodylen - (nkey + c->binary_header.request.extlen); if (settings.verbose > 1) { int ii; if (c->cmd == PROTOCOL_BINARY_CMD_ADD) { fprintf(stderr, "<%d ADD ", c->sfd); } else if (c->cmd == PROTOCOL_BINARY_CMD_SET) { fprintf(stderr, "<%d SET ", c->sfd); } else { fprintf(stderr, "<%d REPLACE ", c->sfd); } for (ii = 0; ii < nkey; ++ii) { fprintf(stderr, "%c", key[ii]); } fprintf(stderr, " Value len is %d", vlen); fprintf(stderr, "\n"); } if (settings.detail_enabled) { stats_prefix_record_set(key, nkey); } it = item_alloc(key, nkey, req->message.body.flags, realtime(req->message.body.expiration), vlen+2); if (it == 0) { if (! item_size_ok(nkey, req->message.body.flags, vlen + 2)) { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_E2BIG, vlen); } else { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_ENOMEM, vlen); } /* Avoid stale data persisting in cache because we failed alloc. * Unacceptable for SET. Anywhere else too? */ if (c->cmd == PROTOCOL_BINARY_CMD_SET) { it = item_get(key, nkey); if (it) { item_unlink(it); item_remove(it); } } /* swallow the data line */ c->write_and_go = conn_swallow; return; } ITEM_set_cas(it, c->binary_header.request.cas); switch (c->cmd) { case PROTOCOL_BINARY_CMD_ADD: c->cmd = NREAD_ADD; break; case PROTOCOL_BINARY_CMD_SET: c->cmd = NREAD_SET; break; case PROTOCOL_BINARY_CMD_REPLACE: c->cmd = NREAD_REPLACE; break; default: assert(0); } if (ITEM_get_cas(it) != 0) { c->cmd = NREAD_CAS; } c->item = it; c->ritem = ITEM_data(it); c->rlbytes = vlen; conn_set_state(c, conn_nread); c->substate = bin_read_set_value; } static void process_bin_append_prepend(conn *c) { char *key; int nkey; int vlen; item *it; assert(c != NULL); key = binary_get_key(c); nkey = c->binary_header.request.keylen; vlen = c->binary_header.request.bodylen - nkey; if (settings.verbose > 1) { fprintf(stderr, "Value len is %d\n", vlen); } if (settings.detail_enabled) { stats_prefix_record_set(key, nkey); } it = item_alloc(key, nkey, 0, 0, vlen+2); if (it == 0) { if (! item_size_ok(nkey, 0, vlen + 2)) { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_E2BIG, vlen); } else { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_ENOMEM, vlen); } /* swallow the data line */ c->write_and_go = conn_swallow; return; } ITEM_set_cas(it, c->binary_header.request.cas); switch (c->cmd) { case PROTOCOL_BINARY_CMD_APPEND: c->cmd = NREAD_APPEND; break; case PROTOCOL_BINARY_CMD_PREPEND: c->cmd = NREAD_PREPEND; break; default: assert(0); } c->item = it; c->ritem = ITEM_data(it); c->rlbytes = vlen; conn_set_state(c, conn_nread); c->substate = bin_read_set_value; } static void process_bin_flush(conn *c) { time_t exptime = 0; protocol_binary_request_flush* req = binary_get_request(c); if (c->binary_header.request.extlen == sizeof(req->message.body)) { exptime = ntohl(req->message.body.expiration); } if (exptime > 0) { settings.oldest_live = realtime(exptime) - 1; } else { settings.oldest_live = current_time - 1; } item_flush_expired(); pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.flush_cmds++; pthread_mutex_unlock(&c->thread->stats.mutex); write_bin_response(c, NULL, 0, 0, 0); } static void process_bin_delete(conn *c) { item *it; protocol_binary_request_delete* req = binary_get_request(c); char* key = binary_get_key(c); size_t nkey = c->binary_header.request.keylen; assert(c != NULL); if (settings.verbose > 1) { fprintf(stderr, "Deleting %s\n", key); } if (settings.detail_enabled) { stats_prefix_record_delete(key, nkey); } it = item_get(key, nkey); if (it) { uint64_t cas = ntohll(req->message.header.request.cas); if (cas == 0 || cas == ITEM_get_cas(it)) { MEMCACHED_COMMAND_DELETE(c->sfd, ITEM_key(it), it->nkey); pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.slab_stats[it->slabs_clsid].delete_hits++; pthread_mutex_unlock(&c->thread->stats.mutex); item_unlink(it); write_bin_response(c, NULL, 0, 0, 0); } else { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS, 0); } item_remove(it); /* release our reference */ } else { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0); pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.delete_misses++; pthread_mutex_unlock(&c->thread->stats.mutex); } } static void complete_nread_binary(conn *c) { assert(c != NULL); assert(c->cmd >= 0); switch(c->substate) { case bin_reading_set_header: if (c->cmd == PROTOCOL_BINARY_CMD_APPEND || c->cmd == PROTOCOL_BINARY_CMD_PREPEND) { process_bin_append_prepend(c); } else { process_bin_update(c); } break; case bin_read_set_value: complete_update_bin(c); break; case bin_reading_get_key: process_bin_get(c); break; case bin_reading_touch_key: process_bin_touch(c); break; case bin_reading_stat: process_bin_stat(c); break; case bin_reading_del_header: process_bin_delete(c); break; case bin_reading_incr_header: complete_incr_bin(c); break; case bin_read_flush_exptime: process_bin_flush(c); break; case bin_reading_sasl_auth: process_bin_sasl_auth(c); break; case bin_reading_sasl_auth_data: process_bin_complete_sasl_auth(c); break; case bin_reading_cas_header: assert(0); case bin_no_state: assert(0); default: fprintf(stderr, "Not handling substate %d\n", c->substate); assert(0); } } static void reset_cmd_handler(conn *c) { c->cmd = -1; c->substate = bin_no_state; if(c->item != NULL) { item_remove(c->item); c->item = NULL; } conn_shrink(c); if (c->rbytes > 0) { conn_set_state(c, conn_parse_cmd); } else { conn_set_state(c, conn_waiting); } } static void complete_nread(conn *c) { assert(c != NULL); assert(c->protocol == ascii_prot || c->protocol == binary_prot); if (c->protocol == ascii_prot) { complete_nread_ascii(c); } else if (c->protocol == binary_prot) { complete_nread_binary(c); } } /* * Stores an item in the cache according to the semantics of one of the set * commands. In threaded mode, this is protected by the cache lock. * * Returns the state of storage. */ enum store_item_type do_store_item(item *it, int comm, conn *c, const uint32_t hv) { char *key = ITEM_key(it); item *old_it = do_item_get(key, it->nkey, hv); enum store_item_type stored = NOT_STORED; item *new_it = NULL; int flags; if (old_it != NULL && comm == NREAD_ADD) { /* add only adds a nonexistent item, but promote to head of LRU */ do_item_update(old_it); } else if (!old_it && (comm == NREAD_REPLACE || comm == NREAD_APPEND || comm == NREAD_PREPEND)) { /* replace only replaces an existing value; don't store */ } else if (comm == NREAD_CAS) { /* validate cas operation */ if(old_it == NULL) { // LRU expired stored = NOT_FOUND; pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.cas_misses++; pthread_mutex_unlock(&c->thread->stats.mutex); } else if (ITEM_get_cas(it) == ITEM_get_cas(old_it)) { // cas validates // it and old_it may belong to different classes. // I'm updating the stats for the one that's getting pushed out pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.slab_stats[old_it->slabs_clsid].cas_hits++; pthread_mutex_unlock(&c->thread->stats.mutex); item_replace(old_it, it, hv); stored = STORED; } else { pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.slab_stats[old_it->slabs_clsid].cas_badval++; pthread_mutex_unlock(&c->thread->stats.mutex); if(settings.verbose > 1) { fprintf(stderr, "CAS: failure: expected %llu, got %llu\n", (unsigned long long)ITEM_get_cas(old_it), (unsigned long long)ITEM_get_cas(it)); } stored = EXISTS; } } else { /* * Append - combine new and old record into single one. Here it's * atomic and thread-safe. */ if (comm == NREAD_APPEND || comm == NREAD_PREPEND) { /* * Validate CAS */ if (ITEM_get_cas(it) != 0) { // CAS much be equal if (ITEM_get_cas(it) != ITEM_get_cas(old_it)) { stored = EXISTS; } } if (stored == NOT_STORED) { /* we have it and old_it here - alloc memory to hold both */ /* flags was already lost - so recover them from ITEM_suffix(it) */ flags = (int) strtol(ITEM_suffix(old_it), (char **) NULL, 10); new_it = item_alloc(key, it->nkey, flags, old_it->exptime, it->nbytes + old_it->nbytes - 2 /* CRLF */); if (new_it == NULL) { /* SERVER_ERROR out of memory */ if (old_it != NULL) do_item_remove(old_it); return NOT_STORED; } /* copy data from it and old_it to new_it */ if (comm == NREAD_APPEND) { memcpy(ITEM_data(new_it), ITEM_data(old_it), old_it->nbytes); memcpy(ITEM_data(new_it) + old_it->nbytes - 2 /* CRLF */, ITEM_data(it), it->nbytes); } else { /* NREAD_PREPEND */ memcpy(ITEM_data(new_it), ITEM_data(it), it->nbytes); memcpy(ITEM_data(new_it) + it->nbytes - 2 /* CRLF */, ITEM_data(old_it), old_it->nbytes); } it = new_it; } } if (stored == NOT_STORED) { if (old_it != NULL) item_replace(old_it, it, hv); else do_item_link(it, hv); c->cas = ITEM_get_cas(it); stored = STORED; } } if (old_it != NULL) do_item_remove(old_it); /* release our reference */ if (new_it != NULL) do_item_remove(new_it); if (stored == STORED) { c->cas = ITEM_get_cas(it); } return stored; } typedef struct token_s { char *value; size_t length; } token_t; #define COMMAND_TOKEN 0 #define SUBCOMMAND_TOKEN 1 #define KEY_TOKEN 1 #define MAX_TOKENS 8 /* * Tokenize the command string by replacing whitespace with '\0' and update * the token array tokens with pointer to start of each token and length. * Returns total number of tokens. The last valid token is the terminal * token (value points to the first unprocessed character of the string and * length zero). * * Usage example: * * while(tokenize_command(command, ncommand, tokens, max_tokens) > 0) { * for(int ix = 0; tokens[ix].length != 0; ix++) { * ... * } * ncommand = tokens[ix].value - command; * command = tokens[ix].value; * } */ static size_t tokenize_command(char *command, token_t *tokens, const size_t max_tokens) { char *s, *e; size_t ntokens = 0; size_t len = strlen(command); unsigned int i = 0; assert(command != NULL && tokens != NULL && max_tokens > 1); s = e = command; for (i = 0; i < len; i++) { if (*e == ' ') { if (s != e) { tokens[ntokens].value = s; tokens[ntokens].length = e - s; ntokens++; *e = '\0'; if (ntokens == max_tokens - 1) { e++; s = e; /* so we don't add an extra token */ break; } } s = e + 1; } e++; } if (s != e) { tokens[ntokens].value = s; tokens[ntokens].length = e - s; ntokens++; } /* * If we scanned the whole string, the terminal value pointer is null, * otherwise it is the first unprocessed character. */ tokens[ntokens].value = *e == '\0' ? NULL : e; tokens[ntokens].length = 0; ntokens++; return ntokens; } /* set up a connection to write a buffer then free it, used for stats */ static void write_and_free(conn *c, char *buf, int bytes) { if (buf) { c->write_and_free = buf; c->wcurr = buf; c->wbytes = bytes; conn_set_state(c, conn_write); c->write_and_go = conn_new_cmd; } else { out_string(c, "SERVER_ERROR out of memory writing stats"); } } static inline bool set_noreply_maybe(conn *c, token_t *tokens, size_t ntokens) { int noreply_index = ntokens - 2; /* NOTE: this function is not the first place where we are going to send the reply. We could send it instead from process_command() if the request line has wrong number of tokens. However parsing malformed line for "noreply" option is not reliable anyway, so it can't be helped. */ if (tokens[noreply_index].value && strcmp(tokens[noreply_index].value, "noreply") == 0) { c->noreply = true; } return c->noreply; } void append_stat(const char *name, ADD_STAT add_stats, conn *c, const char *fmt, ...) { char val_str[STAT_VAL_LEN]; int vlen; va_list ap; assert(name); assert(add_stats); assert(c); assert(fmt); va_start(ap, fmt); vlen = vsnprintf(val_str, sizeof(val_str) - 1, fmt, ap); va_end(ap); add_stats(name, strlen(name), val_str, vlen, c); } inline static void process_stats_detail(conn *c, const char *command) { assert(c != NULL); if (strcmp(command, "on") == 0) { settings.detail_enabled = 1; out_string(c, "OK"); } else if (strcmp(command, "off") == 0) { settings.detail_enabled = 0; out_string(c, "OK"); } else if (strcmp(command, "dump") == 0) { int len; char *stats = stats_prefix_dump(&len); write_and_free(c, stats, len); } else { out_string(c, "CLIENT_ERROR usage: stats detail on|off|dump"); } } /* return server specific stats only */ static void server_stats(ADD_STAT add_stats, conn *c) { pid_t pid = getpid(); rel_time_t now = current_time; struct thread_stats thread_stats; threadlocal_stats_aggregate(&thread_stats); struct slab_stats slab_stats; slab_stats_aggregate(&thread_stats, &slab_stats); #ifndef WIN32 struct rusage usage; getrusage(RUSAGE_SELF, &usage); #endif /* !WIN32 */ STATS_LOCK(); APPEND_STAT("pid", "%lu", (long)pid); APPEND_STAT("uptime", "%u", now); APPEND_STAT("time", "%ld", now + (long)process_started); APPEND_STAT("version", "%s", RVERSION); APPEND_STAT("libevent", "%s", event_get_version()); APPEND_STAT("pointer_size", "%d", (int)(8 * sizeof(void *))); #ifndef WIN32 append_stat("rusage_user", add_stats, c, "%ld.%06ld", (long)usage.ru_utime.tv_sec, (long)usage.ru_utime.tv_usec); append_stat("rusage_system", add_stats, c, "%ld.%06ld", (long)usage.ru_stime.tv_sec, (long)usage.ru_stime.tv_usec); #endif /* !WIN32 */ APPEND_STAT("curr_connections", "%u", stats.curr_conns - 1); APPEND_STAT("total_connections", "%u", stats.total_conns); if (settings.maxconns_fast) { APPEND_STAT("rejected_connections", "%llu", (unsigned long long)stats.rejected_conns); } APPEND_STAT("connection_structures", "%u", stats.conn_structs); APPEND_STAT("reserved_fds", "%u", stats.reserved_fds); APPEND_STAT("cmd_get", "%llu", (unsigned long long)thread_stats.get_cmds); APPEND_STAT("cmd_set", "%llu", (unsigned long long)slab_stats.set_cmds); APPEND_STAT("cmd_flush", "%llu", (unsigned long long)thread_stats.flush_cmds); APPEND_STAT("cmd_touch", "%llu", (unsigned long long)thread_stats.touch_cmds); APPEND_STAT("get_hits", "%llu", (unsigned long long)slab_stats.get_hits); APPEND_STAT("get_misses", "%llu", (unsigned long long)thread_stats.get_misses); APPEND_STAT("delete_misses", "%llu", (unsigned long long)thread_stats.delete_misses); APPEND_STAT("delete_hits", "%llu", (unsigned long long)slab_stats.delete_hits); APPEND_STAT("incr_misses", "%llu", (unsigned long long)thread_stats.incr_misses); APPEND_STAT("incr_hits", "%llu", (unsigned long long)slab_stats.incr_hits); APPEND_STAT("decr_misses", "%llu", (unsigned long long)thread_stats.decr_misses); APPEND_STAT("decr_hits", "%llu", (unsigned long long)slab_stats.decr_hits); APPEND_STAT("cas_misses", "%llu", (unsigned long long)thread_stats.cas_misses); APPEND_STAT("cas_hits", "%llu", (unsigned long long)slab_stats.cas_hits); APPEND_STAT("cas_badval", "%llu", (unsigned long long)slab_stats.cas_badval); APPEND_STAT("touch_hits", "%llu", (unsigned long long)slab_stats.touch_hits); APPEND_STAT("touch_misses", "%llu", (unsigned long long)thread_stats.touch_misses); APPEND_STAT("auth_cmds", "%llu", (unsigned long long)thread_stats.auth_cmds); APPEND_STAT("auth_errors", "%llu", (unsigned long long)thread_stats.auth_errors); APPEND_STAT("bytes_read", "%llu", (unsigned long long)thread_stats.bytes_read); APPEND_STAT("bytes_written", "%llu", (unsigned long long)thread_stats.bytes_written); APPEND_STAT("limit_maxbytes", "%llu", (unsigned long long)settings.maxbytes); APPEND_STAT("accepting_conns", "%u", stats.accepting_conns); APPEND_STAT("listen_disabled_num", "%llu", (unsigned long long)stats.listen_disabled_num); APPEND_STAT("threads", "%d", settings.num_threads); APPEND_STAT("conn_yields", "%llu", (unsigned long long)thread_stats.conn_yields); APPEND_STAT("hash_power_level", "%u", stats.hash_power_level); APPEND_STAT("hash_bytes", "%llu", (unsigned long long)stats.hash_bytes); APPEND_STAT("hash_is_expanding", "%u", stats.hash_is_expanding); APPEND_STAT("expired_unfetched", "%llu", stats.expired_unfetched); APPEND_STAT("evicted_unfetched", "%llu", stats.evicted_unfetched); if (settings.slab_reassign) { APPEND_STAT("slab_reassign_running", "%u", stats.slab_reassign_running); APPEND_STAT("slabs_moved", "%llu", stats.slabs_moved); } STATS_UNLOCK(); } static void process_stat_settings(ADD_STAT add_stats, void *c) { assert(add_stats); APPEND_STAT("maxbytes", "%u", (unsigned int)settings.maxbytes); APPEND_STAT("maxconns", "%d", settings.maxconns); APPEND_STAT("tcpport", "%d", settings.port); APPEND_STAT("udpport", "%d", settings.udpport); APPEND_STAT("inter", "%s", settings.inter ? settings.inter : "NULL"); APPEND_STAT("verbosity", "%d", settings.verbose); APPEND_STAT("oldest", "%lu", (unsigned long)settings.oldest_live); APPEND_STAT("evictions", "%s", settings.evict_to_free ? "on" : "off"); APPEND_STAT("domain_socket", "%s", settings.socketpath ? settings.socketpath : "NULL"); APPEND_STAT("umask", "%o", settings.access); APPEND_STAT("growth_factor", "%.2f", settings.factor); APPEND_STAT("chunk_size", "%d", settings.chunk_size); APPEND_STAT("num_threads", "%d", settings.num_threads); APPEND_STAT("num_threads_per_udp", "%d", settings.num_threads_per_udp); APPEND_STAT("stat_key_prefix", "%c", settings.prefix_delimiter); APPEND_STAT("detail_enabled", "%s", settings.detail_enabled ? "yes" : "no"); APPEND_STAT("reqs_per_event", "%d", settings.reqs_per_event); APPEND_STAT("cas_enabled", "%s", settings.use_cas ? "yes" : "no"); APPEND_STAT("tcp_backlog", "%d", settings.backlog); APPEND_STAT("binding_protocol", "%s", prot_text(settings.binding_protocol)); APPEND_STAT("auth_enabled_sasl", "%s", settings.sasl ? "yes" : "no"); APPEND_STAT("item_size_max", "%d", settings.item_size_max); APPEND_STAT("maxconns_fast", "%s", settings.maxconns_fast ? "yes" : "no"); APPEND_STAT("hashpower_init", "%d", settings.hashpower_init); APPEND_STAT("slab_reassign", "%s", settings.slab_reassign ? "yes" : "no"); APPEND_STAT("slab_automove", "%s", settings.slab_automove ? "yes" : "no"); } static void process_stat(conn *c, token_t *tokens, const size_t ntokens) { const char *subcommand = tokens[SUBCOMMAND_TOKEN].value; assert(c != NULL); if (ntokens < 2) { out_string(c, "CLIENT_ERROR bad command line"); return; } if (ntokens == 2) { server_stats(&append_stats, c); (void)get_stats(NULL, 0, &append_stats, c); } else if (strcmp(subcommand, "reset") == 0) { stats_reset(); out_string(c, "RESET"); return ; } else if (strcmp(subcommand, "detail") == 0) { /* NOTE: how to tackle detail with binary? */ if (ntokens < 4) process_stats_detail(c, ""); /* outputs the error message */ else process_stats_detail(c, tokens[2].value); /* Output already generated */ return ; } else if (strcmp(subcommand, "settings") == 0) { process_stat_settings(&append_stats, c); } else if (strcmp(subcommand, "cachedump") == 0) { char *buf; unsigned int bytes, id, limit = 0; if (ntokens < 5) { out_string(c, "CLIENT_ERROR bad command line"); return; } if (!safe_strtoul(tokens[2].value, &id) || !safe_strtoul(tokens[3].value, &limit)) { out_string(c, "CLIENT_ERROR bad command line format"); return; } if (id >= POWER_LARGEST) { out_string(c, "CLIENT_ERROR Illegal slab id"); return; } buf = item_cachedump(id, limit, &bytes); write_and_free(c, buf, bytes); return ; } else { /* getting here means that the subcommand is either engine specific or is invalid. query the engine and see. */ if (get_stats(subcommand, strlen(subcommand), &append_stats, c)) { if (c->stats.buffer == NULL) { out_string(c, "SERVER_ERROR out of memory writing stats"); } else { write_and_free(c, c->stats.buffer, c->stats.offset); c->stats.buffer = NULL; } } else { out_string(c, "ERROR"); } return ; } /* append terminator and start the transfer */ append_stats(NULL, 0, NULL, 0, c); if (c->stats.buffer == NULL) { out_string(c, "SERVER_ERROR out of memory writing stats"); } else { write_and_free(c, c->stats.buffer, c->stats.offset); c->stats.buffer = NULL; } } #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wunused-but-set-parameter" #endif /* ntokens is overwritten here... shrug.. */ static inline void process_get_command(conn *c, token_t *tokens, size_t ntokens, bool return_cas) { char *key; size_t nkey; int i = 0; item *it; token_t *key_token = &tokens[KEY_TOKEN]; char *suffix; assert(c != NULL); do { while(key_token->length != 0) { key = key_token->value; nkey = key_token->length; if(nkey > KEY_MAX_LENGTH) { out_string(c, "CLIENT_ERROR bad command line format"); return; } it = item_get(key, nkey); if (settings.detail_enabled) { stats_prefix_record_get(key, nkey, NULL != it); } if (it) { if (i >= c->isize) { item **new_list = realloc(c->ilist, sizeof(item *) * c->isize * 2); if (new_list) { c->isize *= 2; c->ilist = new_list; } else { item_remove(it); break; } } /* * Construct the response. Each hit adds three elements to the * outgoing data list: * "VALUE " * key * " " + flags + " " + data length + "\r\n" + data (with \r\n) */ if (return_cas) { MEMCACHED_COMMAND_GET(c->sfd, ITEM_key(it), it->nkey, it->nbytes, ITEM_get_cas(it)); /* Goofy mid-flight realloc. */ if (i >= c->suffixsize) { char **new_suffix_list = realloc(c->suffixlist, sizeof(char *) * c->suffixsize * 2); if (new_suffix_list) { c->suffixsize *= 2; c->suffixlist = new_suffix_list; } else { item_remove(it); break; } } suffix = cache_alloc(c->thread->suffix_cache); if (suffix == NULL) { out_string(c, "SERVER_ERROR out of memory making CAS suffix"); item_remove(it); return; } *(c->suffixlist + i) = suffix; int suffix_len = snprintf(suffix, SUFFIX_SIZE, " %llu\r\n", (unsigned long long)ITEM_get_cas(it)); if (add_iov(c, "VALUE ", 6) != 0 || add_iov(c, ITEM_key(it), it->nkey) != 0 || add_iov(c, ITEM_suffix(it), it->nsuffix - 2) != 0 || add_iov(c, suffix, suffix_len) != 0 || add_iov(c, ITEM_data(it), it->nbytes) != 0) { item_remove(it); break; } } else { MEMCACHED_COMMAND_GET(c->sfd, ITEM_key(it), it->nkey, it->nbytes, ITEM_get_cas(it)); if (add_iov(c, "VALUE ", 6) != 0 || add_iov(c, ITEM_key(it), it->nkey) != 0 || add_iov(c, ITEM_suffix(it), it->nsuffix + it->nbytes) != 0) { item_remove(it); break; } } if (settings.verbose > 1) fprintf(stderr, ">%d sending key %s\n", c->sfd, ITEM_key(it)); /* item_get() has incremented it->refcount for us */ pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.slab_stats[it->slabs_clsid].get_hits++; c->thread->stats.get_cmds++; pthread_mutex_unlock(&c->thread->stats.mutex); item_update(it); *(c->ilist + i) = it; i++; } else { pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.get_misses++; c->thread->stats.get_cmds++; pthread_mutex_unlock(&c->thread->stats.mutex); MEMCACHED_COMMAND_GET(c->sfd, key, nkey, -1, 0); } key_token++; } /* * If the command string hasn't been fully processed, get the next set * of tokens. */ if(key_token->value != NULL) { ntokens = tokenize_command(key_token->value, tokens, MAX_TOKENS); key_token = tokens; } } while(key_token->value != NULL); c->icurr = c->ilist; c->ileft = i; if (return_cas) { c->suffixcurr = c->suffixlist; c->suffixleft = i; } if (settings.verbose > 1) fprintf(stderr, ">%d END\n", c->sfd); /* If the loop was terminated because of out-of-memory, it is not reliable to add END\r\n to the buffer, because it might not end in \r\n. So we send SERVER_ERROR instead. */ if (key_token->value != NULL || add_iov(c, "END\r\n", 5) != 0 || (IS_UDP(c->transport) && build_udp_headers(c) != 0)) { out_string(c, "SERVER_ERROR out of memory writing get response"); } else { conn_set_state(c, conn_mwrite); c->msgcurr = 0; } return; } static void process_update_command(conn *c, token_t *tokens, const size_t ntokens, int comm, bool handle_cas) { char *key; size_t nkey; unsigned int flags; int32_t exptime_int = 0; time_t exptime; int vlen; uint64_t req_cas_id=0; item *it; assert(c != NULL); set_noreply_maybe(c, tokens, ntokens); if (tokens[KEY_TOKEN].length > KEY_MAX_LENGTH) { out_string(c, "CLIENT_ERROR bad command line format"); return; } key = tokens[KEY_TOKEN].value; nkey = tokens[KEY_TOKEN].length; if (! (safe_strtoul(tokens[2].value, (uint32_t *)&flags) && safe_strtol(tokens[3].value, &exptime_int) && safe_strtol(tokens[4].value, (int32_t *)&vlen))) { out_string(c, "CLIENT_ERROR bad command line format"); return; } /* Ubuntu 8.04 breaks when I pass exptime to safe_strtol */ exptime = exptime_int; /* Negative exptimes can underflow and end up immortal. realtime() will immediately expire values that are greater than REALTIME_MAXDELTA, but less than process_started, so lets aim for that. */ if (exptime < 0) exptime = REALTIME_MAXDELTA + 1; // does cas value exist? if (handle_cas) { if (!safe_strtoull(tokens[5].value, &req_cas_id)) { out_string(c, "CLIENT_ERROR bad command line format"); return; } } vlen += 2; if (vlen < 0 || vlen - 2 < 0) { out_string(c, "CLIENT_ERROR bad command line format"); return; } if (settings.detail_enabled) { stats_prefix_record_set(key, nkey); } it = item_alloc(key, nkey, flags, realtime(exptime), vlen); if (it == 0) { if (! item_size_ok(nkey, flags, vlen)) out_string(c, "SERVER_ERROR object too large for cache"); else out_string(c, "SERVER_ERROR out of memory storing object"); /* swallow the data line */ c->write_and_go = conn_swallow; c->sbytes = vlen; /* Avoid stale data persisting in cache because we failed alloc. * Unacceptable for SET. Anywhere else too? */ if (comm == NREAD_SET) { it = item_get(key, nkey); if (it) { item_unlink(it); item_remove(it); } } return; } ITEM_set_cas(it, req_cas_id); c->item = it; c->ritem = ITEM_data(it); c->rlbytes = it->nbytes; c->cmd = comm; conn_set_state(c, conn_nread); } static void process_touch_command(conn *c, token_t *tokens, const size_t ntokens) { char *key; size_t nkey; int32_t exptime_int = 0; item *it; assert(c != NULL); set_noreply_maybe(c, tokens, ntokens); if (tokens[KEY_TOKEN].length > KEY_MAX_LENGTH) { out_string(c, "CLIENT_ERROR bad command line format"); return; } key = tokens[KEY_TOKEN].value; nkey = tokens[KEY_TOKEN].length; if (!safe_strtol(tokens[2].value, &exptime_int)) { out_string(c, "CLIENT_ERROR invalid exptime argument"); return; } it = item_touch(key, nkey, realtime(exptime_int)); if (it) { item_update(it); pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.touch_cmds++; c->thread->stats.slab_stats[it->slabs_clsid].touch_hits++; pthread_mutex_unlock(&c->thread->stats.mutex); out_string(c, "TOUCHED"); item_remove(it); } else { pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.touch_cmds++; c->thread->stats.touch_misses++; pthread_mutex_unlock(&c->thread->stats.mutex); out_string(c, "NOT_FOUND"); } } static void process_arithmetic_command(conn *c, token_t *tokens, const size_t ntokens, const bool incr) { char temp[INCR_MAX_STORAGE_LEN]; uint64_t delta; char *key; size_t nkey; assert(c != NULL); set_noreply_maybe(c, tokens, ntokens); if (tokens[KEY_TOKEN].length > KEY_MAX_LENGTH) { out_string(c, "CLIENT_ERROR bad command line format"); return; } key = tokens[KEY_TOKEN].value; nkey = tokens[KEY_TOKEN].length; if (!safe_strtoull(tokens[2].value, &delta)) { out_string(c, "CLIENT_ERROR invalid numeric delta argument"); return; } switch(add_delta(c, key, nkey, incr, delta, temp, NULL)) { case OK: out_string(c, temp); break; case NON_NUMERIC: out_string(c, "CLIENT_ERROR cannot increment or decrement non-numeric value"); break; case EOM: out_string(c, "SERVER_ERROR out of memory"); break; case DELTA_ITEM_NOT_FOUND: pthread_mutex_lock(&c->thread->stats.mutex); if (incr) { c->thread->stats.incr_misses++; } else { c->thread->stats.decr_misses++; } pthread_mutex_unlock(&c->thread->stats.mutex); out_string(c, "NOT_FOUND"); break; case DELTA_ITEM_CAS_MISMATCH: break; /* Should never get here */ default: assert(false); abort(); } } /* * adds a delta value to a numeric item. * * c connection requesting the operation * it item to adjust * incr true to increment value, false to decrement * delta amount to adjust value by * buf buffer for response string * * returns a response string to send back to the client. */ enum delta_result_type do_add_delta(conn *c, const char *key, const size_t nkey, const bool incr, const int64_t delta, char *buf, uint64_t *cas, const uint32_t hv) { char *ptr; uint64_t value; int res; item *it; it = do_item_get(key, nkey, hv); if (!it) { return DELTA_ITEM_NOT_FOUND; } if (cas != NULL && *cas != 0 && ITEM_get_cas(it) != *cas) { do_item_remove(it); return DELTA_ITEM_CAS_MISMATCH; } ptr = ITEM_data(it); if (!safe_strtoull(ptr, &value)) { do_item_remove(it); return NON_NUMERIC; } if (incr) { value += delta; MEMCACHED_COMMAND_INCR(c->sfd, ITEM_key(it), it->nkey, value); } else { if(delta > value) { value = 0; } else { value -= delta; } MEMCACHED_COMMAND_DECR(c->sfd, ITEM_key(it), it->nkey, value); } pthread_mutex_lock(&c->thread->stats.mutex); if (incr) { c->thread->stats.slab_stats[it->slabs_clsid].incr_hits++; } else { c->thread->stats.slab_stats[it->slabs_clsid].decr_hits++; } pthread_mutex_unlock(&c->thread->stats.mutex); snprintf(buf, INCR_MAX_STORAGE_LEN, "%llu", (unsigned long long)value); res = strlen(buf); if (res + 2 > it->nbytes || it->refcount != 1) { /* need to realloc */ item *new_it; new_it = item_alloc(ITEM_key(it), it->nkey, atoi(ITEM_suffix(it) + 1), it->exptime, res + 2 ); if (new_it == 0) { do_item_remove(it); return EOM; } memcpy(ITEM_data(new_it), buf, res); memcpy(ITEM_data(new_it) + res, "\r\n", 2); item_replace(it, new_it, hv); // Overwrite the older item's CAS with our new CAS since we're // returning the CAS of the old item below. ITEM_set_cas(it, (settings.use_cas) ? ITEM_get_cas(new_it) : 0); do_item_remove(new_it); /* release our reference */ } else { /* replace in-place */ /* When changing the value without replacing the item, we need to update the CAS on the existing item. */ mutex_lock(&cache_lock); /* FIXME */ ITEM_set_cas(it, (settings.use_cas) ? get_cas_id() : 0); pthread_mutex_unlock(&cache_lock); memcpy(ITEM_data(it), buf, res); memset(ITEM_data(it) + res, ' ', it->nbytes - res - 2); do_item_update(it); } if (cas) { *cas = ITEM_get_cas(it); /* swap the incoming CAS value */ } do_item_remove(it); /* release our reference */ return OK; } static void process_delete_command(conn *c, token_t *tokens, const size_t ntokens) { char *key; size_t nkey; item *it; assert(c != NULL); if (ntokens > 3) { bool hold_is_zero = strcmp(tokens[KEY_TOKEN+1].value, "0") == 0; bool sets_noreply = set_noreply_maybe(c, tokens, ntokens); bool valid = (ntokens == 4 && (hold_is_zero || sets_noreply)) || (ntokens == 5 && hold_is_zero && sets_noreply); if (!valid) { out_string(c, "CLIENT_ERROR bad command line format. " "Usage: delete [noreply]"); return; } } key = tokens[KEY_TOKEN].value; nkey = tokens[KEY_TOKEN].length; if(nkey > KEY_MAX_LENGTH) { out_string(c, "CLIENT_ERROR bad command line format"); return; } if (settings.detail_enabled) { stats_prefix_record_delete(key, nkey); } it = item_get(key, nkey); if (it) { MEMCACHED_COMMAND_DELETE(c->sfd, ITEM_key(it), it->nkey); pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.slab_stats[it->slabs_clsid].delete_hits++; pthread_mutex_unlock(&c->thread->stats.mutex); item_unlink(it); item_remove(it); /* release our reference */ out_string(c, "DELETED"); } else { pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.delete_misses++; pthread_mutex_unlock(&c->thread->stats.mutex); out_string(c, "NOT_FOUND"); } } static void process_verbosity_command(conn *c, token_t *tokens, const size_t ntokens) { unsigned int level; assert(c != NULL); set_noreply_maybe(c, tokens, ntokens); level = strtoul(tokens[1].value, NULL, 10); settings.verbose = level > MAX_VERBOSITY_LEVEL ? MAX_VERBOSITY_LEVEL : level; out_string(c, "OK"); return; } static void process_slabs_automove_command(conn *c, token_t *tokens, const size_t ntokens) { unsigned int level; assert(c != NULL); set_noreply_maybe(c, tokens, ntokens); level = strtoul(tokens[2].value, NULL, 10); if (level == 0) { settings.slab_automove = false; } else if (level == 1) { settings.slab_automove = true; } else { out_string(c, "ERROR"); return; } out_string(c, "OK"); return; } static void process_command(conn *c, char *command) { token_t tokens[MAX_TOKENS]; size_t ntokens; int comm; assert(c != NULL); MEMCACHED_PROCESS_COMMAND_START(c->sfd, c->rcurr, c->rbytes); if (settings.verbose > 1) fprintf(stderr, "<%d %s\n", c->sfd, command); /* * for commands set/add/replace, we build an item and read the data * directly into it, then continue in nread_complete(). */ c->msgcurr = 0; c->msgused = 0; c->iovused = 0; if (add_msghdr(c) != 0) { out_string(c, "SERVER_ERROR out of memory preparing response"); return; } ntokens = tokenize_command(command, tokens, MAX_TOKENS); if (ntokens >= 3 && ((strcmp(tokens[COMMAND_TOKEN].value, "get") == 0) || (strcmp(tokens[COMMAND_TOKEN].value, "bget") == 0))) { process_get_command(c, tokens, ntokens, false); } else if ((ntokens == 6 || ntokens == 7) && ((strcmp(tokens[COMMAND_TOKEN].value, "add") == 0 && (comm = NREAD_ADD)) || (strcmp(tokens[COMMAND_TOKEN].value, "set") == 0 && (comm = NREAD_SET)) || (strcmp(tokens[COMMAND_TOKEN].value, "replace") == 0 && (comm = NREAD_REPLACE)) || (strcmp(tokens[COMMAND_TOKEN].value, "prepend") == 0 && (comm = NREAD_PREPEND)) || (strcmp(tokens[COMMAND_TOKEN].value, "append") == 0 && (comm = NREAD_APPEND)) )) { process_update_command(c, tokens, ntokens, comm, false); } else if ((ntokens == 7 || ntokens == 8) && (strcmp(tokens[COMMAND_TOKEN].value, "cas") == 0 && (comm = NREAD_CAS))) { process_update_command(c, tokens, ntokens, comm, true); } else if ((ntokens == 4 || ntokens == 5) && (strcmp(tokens[COMMAND_TOKEN].value, "incr") == 0)) { process_arithmetic_command(c, tokens, ntokens, 1); } else if (ntokens >= 3 && (strcmp(tokens[COMMAND_TOKEN].value, "gets") == 0)) { process_get_command(c, tokens, ntokens, true); } else if ((ntokens == 4 || ntokens == 5) && (strcmp(tokens[COMMAND_TOKEN].value, "decr") == 0)) { process_arithmetic_command(c, tokens, ntokens, 0); } else if (ntokens >= 3 && ntokens <= 5 && (strcmp(tokens[COMMAND_TOKEN].value, "delete") == 0)) { process_delete_command(c, tokens, ntokens); } else if ((ntokens == 4 || ntokens == 5) && (strcmp(tokens[COMMAND_TOKEN].value, "touch") == 0)) { process_touch_command(c, tokens, ntokens); } else if (ntokens >= 2 && (strcmp(tokens[COMMAND_TOKEN].value, "stats") == 0)) { process_stat(c, tokens, ntokens); } else if (ntokens >= 2 && ntokens <= 4 && (strcmp(tokens[COMMAND_TOKEN].value, "flush_all") == 0)) { time_t exptime = 0; set_noreply_maybe(c, tokens, ntokens); pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.flush_cmds++; pthread_mutex_unlock(&c->thread->stats.mutex); if(ntokens == (c->noreply ? 3 : 2)) { settings.oldest_live = current_time - 1; item_flush_expired(); out_string(c, "OK"); return; } exptime = strtol(tokens[1].value, NULL, 10); if(errno == ERANGE) { out_string(c, "CLIENT_ERROR bad command line format"); return; } /* If exptime is zero realtime() would return zero too, and realtime(exptime) - 1 would overflow to the max unsigned value. So we process exptime == 0 the same way we do when no delay is given at all. */ if (exptime > 0) settings.oldest_live = realtime(exptime) - 1; else /* exptime == 0 */ settings.oldest_live = current_time - 1; item_flush_expired(); out_string(c, "OK"); return; } else if (ntokens == 2 && (strcmp(tokens[COMMAND_TOKEN].value, "version") == 0)) { out_string(c, "VERSION " RVERSION); } else if (ntokens == 2 && (strcmp(tokens[COMMAND_TOKEN].value, "quit") == 0)) { conn_set_state(c, conn_closing); } else if (ntokens > 1 && strcmp(tokens[COMMAND_TOKEN].value, "slabs") == 0) { if (ntokens == 5 && strcmp(tokens[COMMAND_TOKEN + 1].value, "reassign") == 0) { int src, dst, rv; if (settings.slab_reassign == false) { out_string(c, "CLIENT_ERROR slab reassignment disabled"); return; } src = strtol(tokens[2].value, NULL, 10); dst = strtol(tokens[3].value, NULL, 10); if (errno == ERANGE) { out_string(c, "CLIENT_ERROR bad command line format"); return; } rv = slabs_reassign(src, dst); switch (rv) { case REASSIGN_OK: out_string(c, "OK"); break; case REASSIGN_RUNNING: out_string(c, "BUSY currently processing reassign request"); break; case REASSIGN_BADCLASS: out_string(c, "BADCLASS invalid src or dst class id"); break; case REASSIGN_NOSPARE: out_string(c, "NOSPARE source class has no spare pages"); break; case REASSIGN_DEST_NOT_FULL: out_string(c, "NOTFULL dest class has spare memory"); break; case REASSIGN_SRC_NOT_SAFE: out_string(c, "UNSAFE src class is in an unsafe state"); break; case REASSIGN_SRC_DST_SAME: out_string(c, "SAME src and dst class are identical"); break; default: assert(false); abort(); } return; } else if (ntokens == 4 && (strcmp(tokens[COMMAND_TOKEN + 1].value, "automove") == 0)) { process_slabs_automove_command(c, tokens, ntokens); } else { out_string(c, "ERROR"); } } else if ((ntokens == 3 || ntokens == 4) && (strcmp(tokens[COMMAND_TOKEN].value, "verbosity") == 0)) { process_verbosity_command(c, tokens, ntokens); } else { out_string(c, "ERROR"); } return; } /* * if we have a complete line in the buffer, process it. */ static int try_read_command(conn *c) { assert(c != NULL); assert(c->rcurr <= (c->rbuf + c->rsize)); assert(c->rbytes > 0); if (c->protocol == negotiating_prot || c->transport == udp_transport) { if ((unsigned char)c->rbuf[0] == (unsigned char)PROTOCOL_BINARY_REQ) { c->protocol = binary_prot; } else { c->protocol = ascii_prot; } if (settings.verbose > 1) { fprintf(stderr, "%d: Client using the %s protocol\n", c->sfd, prot_text(c->protocol)); } } if (c->protocol == binary_prot) { /* Do we have the complete packet header? */ if (c->rbytes < sizeof(c->binary_header)) { /* need more data! */ return 0; } else { #ifdef NEED_ALIGN if (((long)(c->rcurr)) % 8 != 0) { /* must realign input buffer */ memmove(c->rbuf, c->rcurr, c->rbytes); c->rcurr = c->rbuf; if (settings.verbose > 1) { fprintf(stderr, "%d: Realign input buffer\n", c->sfd); } } #endif protocol_binary_request_header* req; req = (protocol_binary_request_header*)c->rcurr; if (settings.verbose > 1) { /* Dump the packet before we convert it to host order */ int ii; fprintf(stderr, "<%d Read binary protocol data:", c->sfd); for (ii = 0; ii < sizeof(req->bytes); ++ii) { if (ii % 4 == 0) { fprintf(stderr, "\n<%d ", c->sfd); } fprintf(stderr, " 0x%02x", req->bytes[ii]); } fprintf(stderr, "\n"); } c->binary_header = *req; c->binary_header.request.keylen = ntohs(req->request.keylen); c->binary_header.request.bodylen = ntohl(req->request.bodylen); c->binary_header.request.cas = ntohll(req->request.cas); if (c->binary_header.request.magic != PROTOCOL_BINARY_REQ) { if (settings.verbose) { fprintf(stderr, "Invalid magic: %x\n", c->binary_header.request.magic); } conn_set_state(c, conn_closing); return -1; } c->msgcurr = 0; c->msgused = 0; c->iovused = 0; if (add_msghdr(c) != 0) { out_string(c, "SERVER_ERROR out of memory"); return 0; } c->cmd = c->binary_header.request.opcode; c->keylen = c->binary_header.request.keylen; c->opaque = c->binary_header.request.opaque; /* clear the returned cas value */ c->cas = 0; dispatch_bin_command(c); c->rbytes -= sizeof(c->binary_header); c->rcurr += sizeof(c->binary_header); } } else { char *el, *cont; if (c->rbytes == 0) return 0; el = memchr(c->rcurr, '\n', c->rbytes); if (!el) { if (c->rbytes > 1024) { /* * We didn't have a '\n' in the first k. This _has_ to be a * large multiget, if not we should just nuke the connection. */ char *ptr = c->rcurr; while (*ptr == ' ') { /* ignore leading whitespaces */ ++ptr; } if (ptr - c->rcurr > 100 || (strncmp(ptr, "get ", 4) && strncmp(ptr, "gets ", 5))) { conn_set_state(c, conn_closing); return 1; } } return 0; } cont = el + 1; if ((el - c->rcurr) > 1 && *(el - 1) == '\r') { el--; } *el = '\0'; assert(cont <= (c->rcurr + c->rbytes)); process_command(c, c->rcurr); c->rbytes -= (cont - c->rcurr); c->rcurr = cont; assert(c->rcurr <= (c->rbuf + c->rsize)); } return 1; } /* * read a UDP request. */ static enum try_read_result try_read_udp(conn *c) { int res; assert(c != NULL); c->request_addr_size = sizeof(c->request_addr); res = recvfrom(c->sfd, c->rbuf, c->rsize, 0, &c->request_addr, &c->request_addr_size); if (res > 8) { unsigned char *buf = (unsigned char *)c->rbuf; pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.bytes_read += res; pthread_mutex_unlock(&c->thread->stats.mutex); /* Beginning of UDP packet is the request ID; save it. */ c->request_id = buf[0] * 256 + buf[1]; /* If this is a multi-packet request, drop it. */ if (buf[4] != 0 || buf[5] != 1) { out_string(c, "SERVER_ERROR multi-packet request not supported"); return READ_NO_DATA_RECEIVED; } /* Don't care about any of the rest of the header. */ res -= 8; memmove(c->rbuf, c->rbuf + 8, res); c->rbytes = res; c->rcurr = c->rbuf; return READ_DATA_RECEIVED; } return READ_NO_DATA_RECEIVED; } /* * read from network as much as we can, handle buffer overflow and connection * close. * before reading, move the remaining incomplete fragment of a command * (if any) to the beginning of the buffer. * * To protect us from someone flooding a connection with bogus data causing * the connection to eat up all available memory, break out and start looking * at the data I've got after a number of reallocs... * * @return enum try_read_result */ static enum try_read_result try_read_network(conn *c) { enum try_read_result gotdata = READ_NO_DATA_RECEIVED; int res; int num_allocs = 0; assert(c != NULL); if (c->rcurr != c->rbuf) { if (c->rbytes != 0) /* otherwise there's nothing to copy */ memmove(c->rbuf, c->rcurr, c->rbytes); c->rcurr = c->rbuf; } while (1) { if (c->rbytes >= c->rsize) { if (num_allocs == 4) { return gotdata; } ++num_allocs; char *new_rbuf = realloc(c->rbuf, c->rsize * 2); if (!new_rbuf) { if (settings.verbose > 0) fprintf(stderr, "Couldn't realloc input buffer\n"); c->rbytes = 0; /* ignore what we read */ out_string(c, "SERVER_ERROR out of memory reading request"); c->write_and_go = conn_closing; return READ_MEMORY_ERROR; } c->rcurr = c->rbuf = new_rbuf; c->rsize *= 2; } int avail = c->rsize - c->rbytes; res = read(c->sfd, c->rbuf + c->rbytes, avail); if (res > 0) { pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.bytes_read += res; pthread_mutex_unlock(&c->thread->stats.mutex); gotdata = READ_DATA_RECEIVED; c->rbytes += res; if (res == avail) { continue; } else { break; } } if (res == 0) { return READ_ERROR; } if (res == -1) { if (errno == EAGAIN || errno == EWOULDBLOCK) { break; } return READ_ERROR; } } return gotdata; } static bool update_event(conn *c, const int new_flags) { assert(c != NULL); struct event_base *base = c->event.ev_base; if (c->ev_flags == new_flags) return true; if (event_del(&c->event) == -1) return false; event_set(&c->event, c->sfd, new_flags, event_handler, (void *)c); event_base_set(base, &c->event); c->ev_flags = new_flags; if (event_add(&c->event, 0) == -1) return false; return true; } /* * Sets whether we are listening for new connections or not. */ void do_accept_new_conns(const bool do_accept) { conn *next; for (next = listen_conn; next; next = next->next) { if (do_accept) { update_event(next, EV_READ | EV_PERSIST); if (listen(next->sfd, settings.backlog) != 0) { perror("listen"); } } else { update_event(next, 0); if (listen(next->sfd, 0) != 0) { perror("listen"); } } } if (do_accept) { STATS_LOCK(); stats.accepting_conns = true; STATS_UNLOCK(); } else { STATS_LOCK(); stats.accepting_conns = false; stats.listen_disabled_num++; STATS_UNLOCK(); allow_new_conns = false; maxconns_handler(-42, 0, 0); } } /* * Transmit the next chunk of data from our list of msgbuf structures. * * Returns: * TRANSMIT_COMPLETE All done writing. * TRANSMIT_INCOMPLETE More data remaining to write. * TRANSMIT_SOFT_ERROR Can't write any more right now. * TRANSMIT_HARD_ERROR Can't write (c->state is set to conn_closing) */ static enum transmit_result transmit(conn *c) { assert(c != NULL); if (c->msgcurr < c->msgused && c->msglist[c->msgcurr].msg_iovlen == 0) { /* Finished writing the current msg; advance to the next. */ c->msgcurr++; } if (c->msgcurr < c->msgused) { ssize_t res; struct msghdr *m = &c->msglist[c->msgcurr]; res = sendmsg(c->sfd, m, 0); if (res > 0) { pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.bytes_written += res; pthread_mutex_unlock(&c->thread->stats.mutex); /* We've written some of the data. Remove the completed iovec entries from the list of pending writes. */ while (m->msg_iovlen > 0 && res >= m->msg_iov->iov_len) { res -= m->msg_iov->iov_len; m->msg_iovlen--; m->msg_iov++; } /* Might have written just part of the last iovec entry; adjust it so the next write will do the rest. */ if (res > 0) { m->msg_iov->iov_base = (caddr_t)m->msg_iov->iov_base + res; m->msg_iov->iov_len -= res; } return TRANSMIT_INCOMPLETE; } if (res == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) { if (!update_event(c, EV_WRITE | EV_PERSIST)) { if (settings.verbose > 0) fprintf(stderr, "Couldn't update event\n"); conn_set_state(c, conn_closing); return TRANSMIT_HARD_ERROR; } return TRANSMIT_SOFT_ERROR; } /* if res == 0 or res == -1 and error is not EAGAIN or EWOULDBLOCK, we have a real error, on which we close the connection */ if (settings.verbose > 0) perror("Failed to write, and not due to blocking"); if (IS_UDP(c->transport)) conn_set_state(c, conn_read); else conn_set_state(c, conn_closing); return TRANSMIT_HARD_ERROR; } else { return TRANSMIT_COMPLETE; } } static void drive_machine(conn *c) { bool stop = false; int sfd, flags = 1; socklen_t addrlen; struct sockaddr_storage addr; int nreqs = settings.reqs_per_event; int res; const char *str; assert(c != NULL); while (!stop) { switch(c->state) { case conn_listening: addrlen = sizeof(addr); if ((sfd = accept(c->sfd, (struct sockaddr *)&addr, &addrlen)) == -1) { if (errno == EAGAIN || errno == EWOULDBLOCK) { /* these are transient, so don't log anything */ stop = true; } else if (errno == EMFILE) { if (settings.verbose > 0) fprintf(stderr, "Too many open connections\n"); accept_new_conns(false); stop = true; } else { perror("accept()"); stop = true; } break; } if ((flags = fcntl(sfd, F_GETFL, 0)) < 0 || fcntl(sfd, F_SETFL, flags | O_NONBLOCK) < 0) { perror("setting O_NONBLOCK"); close(sfd); break; } if (settings.maxconns_fast && stats.curr_conns + stats.reserved_fds >= settings.maxconns - 1) { str = "ERROR Too many open connections\r\n"; res = write(sfd, str, strlen(str)); close(sfd); STATS_LOCK(); stats.rejected_conns++; STATS_UNLOCK(); } else { dispatch_conn_new(sfd, conn_new_cmd, EV_READ | EV_PERSIST, DATA_BUFFER_SIZE, tcp_transport); } stop = true; break; case conn_waiting: if (!update_event(c, EV_READ | EV_PERSIST)) { if (settings.verbose > 0) fprintf(stderr, "Couldn't update event\n"); conn_set_state(c, conn_closing); break; } conn_set_state(c, conn_read); stop = true; break; case conn_read: res = IS_UDP(c->transport) ? try_read_udp(c) : try_read_network(c); switch (res) { case READ_NO_DATA_RECEIVED: conn_set_state(c, conn_waiting); break; case READ_DATA_RECEIVED: conn_set_state(c, conn_parse_cmd); break; case READ_ERROR: conn_set_state(c, conn_closing); break; case READ_MEMORY_ERROR: /* Failed to allocate more memory */ /* State already set by try_read_network */ break; default: assert(false); abort(); } break; case conn_parse_cmd : if (try_read_command(c) == 0) { /* wee need more data! */ conn_set_state(c, conn_waiting); } break; case conn_new_cmd: /* Only process nreqs at a time to avoid starving other connections */ --nreqs; if (nreqs >= 0) { reset_cmd_handler(c); } else { pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.conn_yields++; pthread_mutex_unlock(&c->thread->stats.mutex); if (c->rbytes > 0) { /* We have already read in data into the input buffer, so libevent will most likely not signal read events on the socket (unless more data is available. As a hack we should just put in a request to write data, because that should be possible ;-) */ if (!update_event(c, EV_WRITE | EV_PERSIST)) { if (settings.verbose > 0) fprintf(stderr, "Couldn't update event\n"); conn_set_state(c, conn_closing); } } stop = true; } break; case conn_nread: if (c->rlbytes == 0) { complete_nread(c); break; } /* first check if we have leftovers in the conn_read buffer */ if (c->rbytes > 0) { int tocopy = c->rbytes > c->rlbytes ? c->rlbytes : c->rbytes; if (c->ritem != c->rcurr) { memmove(c->ritem, c->rcurr, tocopy); } c->ritem += tocopy; c->rlbytes -= tocopy; c->rcurr += tocopy; c->rbytes -= tocopy; if (c->rlbytes == 0) { break; } } /* now try reading from the socket */ res = read(c->sfd, c->ritem, c->rlbytes); if (res > 0) { pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.bytes_read += res; pthread_mutex_unlock(&c->thread->stats.mutex); if (c->rcurr == c->ritem) { c->rcurr += res; } c->ritem += res; c->rlbytes -= res; break; } if (res == 0) { /* end of stream */ conn_set_state(c, conn_closing); break; } if (res == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) { if (!update_event(c, EV_READ | EV_PERSIST)) { if (settings.verbose > 0) fprintf(stderr, "Couldn't update event\n"); conn_set_state(c, conn_closing); break; } stop = true; break; } /* otherwise we have a real error, on which we close the connection */ if (settings.verbose > 0) { fprintf(stderr, "Failed to read, and not due to blocking:\n" "errno: %d %s \n" "rcurr=%lx ritem=%lx rbuf=%lx rlbytes=%d rsize=%d\n", errno, strerror(errno), (long)c->rcurr, (long)c->ritem, (long)c->rbuf, (int)c->rlbytes, (int)c->rsize); } conn_set_state(c, conn_closing); break; case conn_swallow: /* we are reading sbytes and throwing them away */ if (c->sbytes == 0) { conn_set_state(c, conn_new_cmd); break; } /* first check if we have leftovers in the conn_read buffer */ if (c->rbytes > 0) { int tocopy = c->rbytes > c->sbytes ? c->sbytes : c->rbytes; c->sbytes -= tocopy; c->rcurr += tocopy; c->rbytes -= tocopy; break; } /* now try reading from the socket */ res = read(c->sfd, c->rbuf, c->rsize > c->sbytes ? c->sbytes : c->rsize); if (res > 0) { pthread_mutex_lock(&c->thread->stats.mutex); c->thread->stats.bytes_read += res; pthread_mutex_unlock(&c->thread->stats.mutex); c->sbytes -= res; break; } if (res == 0) { /* end of stream */ conn_set_state(c, conn_closing); break; } if (res == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) { if (!update_event(c, EV_READ | EV_PERSIST)) { if (settings.verbose > 0) fprintf(stderr, "Couldn't update event\n"); conn_set_state(c, conn_closing); break; } stop = true; break; } /* otherwise we have a real error, on which we close the connection */ if (settings.verbose > 0) fprintf(stderr, "Failed to read, and not due to blocking\n"); conn_set_state(c, conn_closing); break; case conn_write: /* * We want to write out a simple response. If we haven't already, * assemble it into a msgbuf list (this will be a single-entry * list for TCP or a two-entry list for UDP). */ if (c->iovused == 0 || (IS_UDP(c->transport) && c->iovused == 1)) { if (add_iov(c, c->wcurr, c->wbytes) != 0) { if (settings.verbose > 0) fprintf(stderr, "Couldn't build response\n"); conn_set_state(c, conn_closing); break; } } /* fall through... */ case conn_mwrite: if (IS_UDP(c->transport) && c->msgcurr == 0 && build_udp_headers(c) != 0) { if (settings.verbose > 0) fprintf(stderr, "Failed to build UDP headers\n"); conn_set_state(c, conn_closing); break; } switch (transmit(c)) { case TRANSMIT_COMPLETE: if (c->state == conn_mwrite) { while (c->ileft > 0) { item *it = *(c->icurr); assert((it->it_flags & ITEM_SLABBED) == 0); item_remove(it); c->icurr++; c->ileft--; } while (c->suffixleft > 0) { char *suffix = *(c->suffixcurr); cache_free(c->thread->suffix_cache, suffix); c->suffixcurr++; c->suffixleft--; } /* XXX: I don't know why this wasn't the general case */ if(c->protocol == binary_prot) { conn_set_state(c, c->write_and_go); } else { conn_set_state(c, conn_new_cmd); } } else if (c->state == conn_write) { if (c->write_and_free) { free(c->write_and_free); c->write_and_free = 0; } conn_set_state(c, c->write_and_go); } else { if (settings.verbose > 0) fprintf(stderr, "Unexpected state %d\n", c->state); conn_set_state(c, conn_closing); } break; case TRANSMIT_INCOMPLETE: case TRANSMIT_HARD_ERROR: break; /* Continue in state machine. */ case TRANSMIT_SOFT_ERROR: stop = true; break; default: assert(false); abort(); } break; case conn_closing: if (IS_UDP(c->transport)) conn_cleanup(c); else conn_close(c); stop = true; break; case conn_max_state: assert(false); break; default: assert(false); abort(); } } return; } void event_handler(const int fd, const short which, void *arg) { conn *c; c = (conn *)arg; assert(c != NULL); c->which = which; /* sanity */ if (fd != c->sfd) { if (settings.verbose > 0) fprintf(stderr, "Catastrophic: event fd doesn't match conn fd!\n"); conn_close(c); return; } drive_machine(c); /* wait for next event */ return; } static int new_socket(struct addrinfo *ai) { int sfd; int flags; if ((sfd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) == -1) { return -1; } if ((flags = fcntl(sfd, F_GETFL, 0)) < 0 || fcntl(sfd, F_SETFL, flags | O_NONBLOCK) < 0) { perror("setting O_NONBLOCK"); close(sfd); return -1; } return sfd; } /* * Sets a socket's send buffer size to the maximum allowed by the system. */ static void maximize_sndbuf(const int sfd) { socklen_t intsize = sizeof(int); int last_good = 0; int min, max, avg; int old_size; /* Start with the default size. */ if (getsockopt(sfd, SOL_SOCKET, SO_SNDBUF, &old_size, &intsize) != 0) { if (settings.verbose > 0) perror("getsockopt(SO_SNDBUF)"); return; } /* Binary-search for the real maximum. */ min = old_size; max = MAX_SENDBUF_SIZE; while (min <= max) { avg = ((unsigned int)(min + max)) / 2; if (setsockopt(sfd, SOL_SOCKET, SO_SNDBUF, (void *)&avg, intsize) == 0) { last_good = avg; min = avg + 1; } else { max = avg - 1; } } if (settings.verbose > 1) fprintf(stderr, "<%d send buffer was %d, now %d\n", sfd, old_size, last_good); } /** * Create a socket and bind it to a specific port number * @param interface the interface to bind to * @param port the port number to bind to * @param transport the transport protocol (TCP / UDP) * @param portnumber_file A filepointer to write the port numbers to * when they are successfully added to the list of ports we * listen on. */ static int server_socket(const char *interface, int port, enum network_transport transport, FILE *portnumber_file) { int sfd; struct linger ling = {0, 0}; struct addrinfo *ai; struct addrinfo *next; struct addrinfo hints = { .ai_flags = AI_PASSIVE, .ai_family = AF_UNSPEC }; char port_buf[NI_MAXSERV]; int error; int success = 0; int flags =1; hints.ai_socktype = IS_UDP(transport) ? SOCK_DGRAM : SOCK_STREAM; if (port == -1) { port = 0; } snprintf(port_buf, sizeof(port_buf), "%d", port); error= getaddrinfo(interface, port_buf, &hints, &ai); if (error != 0) { if (error != EAI_SYSTEM) fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(error)); else perror("getaddrinfo()"); return 1; } for (next= ai; next; next= next->ai_next) { conn *listen_conn_add; if ((sfd = new_socket(next)) == -1) { /* getaddrinfo can return "junk" addresses, * we make sure at least one works before erroring. */ if (errno == EMFILE) { /* ...unless we're out of fds */ perror("server_socket"); exit(EX_OSERR); } continue; } #ifdef IPV6_V6ONLY if (next->ai_family == AF_INET6) { error = setsockopt(sfd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &flags, sizeof(flags)); if (error != 0) { perror("setsockopt"); close(sfd); continue; } } #endif error = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &flags, sizeof(flags)); if (error != 0) { perror("setsockopt(SO_REUSEADDR)"); } if (IS_UDP(transport)) { maximize_sndbuf(sfd); } else { error = setsockopt(sfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&flags, sizeof(flags)); if (error != 0) perror("setsockopt"); error = setsockopt(sfd, SOL_SOCKET, SO_LINGER, (void *)&ling, sizeof(ling)); if (error != 0) perror("setsockopt"); error = setsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, (void *)&flags, sizeof(flags)); if (error != 0) perror("setsockopt"); } if (bind(sfd, next->ai_addr, next->ai_addrlen) == -1) { if (errno != EADDRINUSE) { perror("bind()"); close(sfd); freeaddrinfo(ai); return 1; } close(sfd); continue; } else { success++; if (!IS_UDP(transport) && listen(sfd, settings.backlog) == -1) { perror("listen()"); close(sfd); freeaddrinfo(ai); return 1; } if (portnumber_file != NULL && (next->ai_addr->sa_family == AF_INET || next->ai_addr->sa_family == AF_INET6)) { union { struct sockaddr_in in; struct sockaddr_in6 in6; } my_sockaddr; socklen_t len = sizeof(my_sockaddr); if (getsockname(sfd, (struct sockaddr*)&my_sockaddr, &len)==0) { if (next->ai_addr->sa_family == AF_INET) { fprintf(portnumber_file, "%s INET: %u\n", IS_UDP(transport) ? "UDP" : "TCP", ntohs(my_sockaddr.in.sin_port)); } else { fprintf(portnumber_file, "%s INET6: %u\n", IS_UDP(transport) ? "UDP" : "TCP", ntohs(my_sockaddr.in6.sin6_port)); } } } } if (IS_UDP(transport)) { int c; for (c = 0; c < settings.num_threads_per_udp; c++) { /* this is guaranteed to hit all threads because we round-robin */ dispatch_conn_new(sfd, conn_read, EV_READ | EV_PERSIST, UDP_READ_BUFFER_SIZE, transport); } } else { if (!(listen_conn_add = conn_new(sfd, conn_listening, EV_READ | EV_PERSIST, 1, transport, main_base))) { fprintf(stderr, "failed to create listening connection\n"); exit(EXIT_FAILURE); } listen_conn_add->next = listen_conn; listen_conn = listen_conn_add; } } freeaddrinfo(ai); /* Return zero iff we detected no errors in starting up connections */ return success == 0; } static int server_sockets(int port, enum network_transport transport, FILE *portnumber_file) { if (settings.inter == NULL) { return server_socket(settings.inter, port, transport, portnumber_file); } else { // tokenize them and bind to each one of them.. char *b; int ret = 0; char *list = strdup(settings.inter); if (list == NULL) { fprintf(stderr, "Failed to allocate memory for parsing server interface string\n"); return 1; } for (char *p = strtok_r(list, ";,", &b); p != NULL; p = strtok_r(NULL, ";,", &b)) { int the_port = port; char *s = strchr(p, ':'); if (s != NULL) { *s = '\0'; ++s; if (!safe_strtol(s, &the_port)) { fprintf(stderr, "Invalid port number: \"%s\"", s); return 1; } } if (strcmp(p, "*") == 0) { p = NULL; } ret |= server_socket(p, the_port, transport, portnumber_file); } free(list); return ret; } } static int new_socket_unix(void) { int sfd; int flags; if ((sfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { perror("socket()"); return -1; } if ((flags = fcntl(sfd, F_GETFL, 0)) < 0 || fcntl(sfd, F_SETFL, flags | O_NONBLOCK) < 0) { perror("setting O_NONBLOCK"); close(sfd); return -1; } return sfd; } static int server_socket_unix(const char *path, int access_mask) { int sfd; struct linger ling = {0, 0}; struct sockaddr_un addr; struct stat tstat; int flags =1; int old_umask; if (!path) { return 1; } if ((sfd = new_socket_unix()) == -1) { return 1; } /* * Clean up a previous socket file if we left it around */ if (lstat(path, &tstat) == 0) { if (S_ISSOCK(tstat.st_mode)) unlink(path); } setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, (void *)&flags, sizeof(flags)); setsockopt(sfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&flags, sizeof(flags)); setsockopt(sfd, SOL_SOCKET, SO_LINGER, (void *)&ling, sizeof(ling)); /* * the memset call clears nonstandard fields in some impementations * that otherwise mess things up. */ memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1); assert(strcmp(addr.sun_path, path) == 0); old_umask = umask( ~(access_mask&0777)); if (bind(sfd, (struct sockaddr *)&addr, sizeof(addr)) == -1) { perror("bind()"); close(sfd); umask(old_umask); return 1; } umask(old_umask); if (listen(sfd, settings.backlog) == -1) { perror("listen()"); close(sfd); return 1; } if (!(listen_conn = conn_new(sfd, conn_listening, EV_READ | EV_PERSIST, 1, local_transport, main_base))) { fprintf(stderr, "failed to create listening connection\n"); exit(EXIT_FAILURE); } return 0; } /* * We keep the current time of day in a global variable that's updated by a * timer event. This saves us a bunch of time() system calls (we really only * need to get the time once a second, whereas there can be tens of thousands * of requests a second) and allows us to use server-start-relative timestamps * rather than absolute UNIX timestamps, a space savings on systems where * sizeof(time_t) > sizeof(unsigned int). */ volatile rel_time_t current_time; static struct event clockevent; /* libevent uses a monotonic clock when available for event scheduling. Aside * from jitter, simply ticking our internal timer here is accurate enough. * Note that users who are setting explicit dates for expiration times *must* * ensure their clocks are correct before starting memcached. */ static void clock_handler(const int fd, const short which, void *arg) { struct timeval t = {.tv_sec = 1, .tv_usec = 0}; static bool initialized = false; #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) static bool monotonic = false; static time_t monotonic_start; #endif if (initialized) { /* only delete the event if it's actually there. */ evtimer_del(&clockevent); } else { initialized = true; /* process_started is initialized to time() - 2. We initialize to 1 so * flush_all won't underflow during tests. */ #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { monotonic = true; monotonic_start = ts.tv_sec - 2; } #endif } evtimer_set(&clockevent, clock_handler, 0); event_base_set(main_base, &clockevent); evtimer_add(&clockevent, &t); #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) if (monotonic) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) return; current_time = (rel_time_t) (ts.tv_sec - monotonic_start); return; } #endif { struct timeval tv; gettimeofday(&tv, NULL); current_time = (rel_time_t) (tv.tv_sec - process_started); } } static void usage(void) { printf(RPACKAGE " " RVERSION "\n"); printf("-p TCP port number to listen on (default: 11211)\n" "-U UDP port number to listen on (default: 11211, 0 is off)\n" "-s UNIX socket path to listen on (disables network support)\n" "-a access mask for UNIX socket, in octal (default: 0700)\n" "-l interface to listen on (default: INADDR_ANY, all addresses)\n" " may be specified as host:port. If you don't specify\n" " a port number, the value you specified with -p or -U is\n" " used. You may specify multiple addresses separated by comma\n" " or by using -l multiple times\n" "-d run as a daemon\n" "-r maximize core file limit\n" "-u assume identity of (only when run as root)\n" "-m max memory to use for items in megabytes (default: 64 MB)\n" "-M return error on memory exhausted (rather than removing items)\n" "-c max simultaneous connections (default: 1024)\n" "-k lock down all paged memory. Note that there is a\n" " limit on how much memory you may lock. Trying to\n" " allocate more than that would fail, so be sure you\n" " set the limit correctly for the user you started\n" " the daemon with (not for -u user;\n" " under sh this is done with 'ulimit -S -l NUM_KB').\n" "-v verbose (print errors/warnings while in event loop)\n" "-vv very verbose (also print client commands/reponses)\n" "-vvv extremely verbose (also print internal state transitions)\n" "-h print this help and exit\n" "-i print memcached and libevent license\n" "-P save PID in , only used with -d option\n" "-f chunk size growth factor (default: 1.25)\n" "-n minimum space allocated for key+value+flags (default: 48)\n"); printf("-L Try to use large memory pages (if available). Increasing\n" " the memory page size could reduce the number of TLB misses\n" " and improve the performance. In order to get large pages\n" " from the OS, memcached will allocate the total item-cache\n" " in one large chunk.\n"); printf("-D Use as the delimiter between key prefixes and IDs.\n" " This is used for per-prefix stats reporting. The default is\n" " \":\" (colon). If this option is specified, stats collection\n" " is turned on automatically; if not, then it may be turned on\n" " by sending the \"stats detail on\" command to the server.\n"); printf("-t number of threads to use (default: 4)\n"); printf("-R Maximum number of requests per event, limits the number of\n" " requests process for a given connection to prevent \n" " starvation (default: 20)\n"); printf("-C Disable use of CAS\n"); printf("-b Set the backlog queue limit (default: 1024)\n"); printf("-B Binding protocol - one of ascii, binary, or auto (default)\n"); printf("-I Override the size of each slab page. Adjusts max item size\n" " (default: 1mb, min: 1k, max: 128m)\n"); #ifdef ENABLE_SASL printf("-S Turn on Sasl authentication\n"); #endif printf("-o Comma separated list of extended or experimental options\n" " - (EXPERIMENTAL) maxconns_fast: immediately close new\n" " connections if over maxconns limit\n" " - hashpower: An integer multiplier for how large the hash\n" " table should be. Can be grown at runtime if not big enough.\n" " Set this based on \"STAT hash_power_level\" before a \n" " restart.\n" ); return; } static void usage_license(void) { printf(RPACKAGE " " RVERSION "\n\n"); printf( "Copyright (c) 2003, Danga Interactive, Inc. \n" "All rights reserved.\n" "\n" "Redistribution and use in source and binary forms, with or without\n" "modification, are permitted provided that the following conditions are\n" "met:\n" "\n" " * Redistributions of source code must retain the above copyright\n" "notice, this list of conditions and the following disclaimer.\n" "\n" " * Redistributions in binary form must reproduce the above\n" "copyright notice, this list of conditions and the following disclaimer\n" "in the documentation and/or other materials provided with the\n" "distribution.\n" "\n" " * Neither the name of the Danga Interactive nor the names of its\n" "contributors may be used to endorse or promote products derived from\n" "this software without specific prior written permission.\n" "\n" "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n" "\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n" "LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n" "A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n" "OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n" "SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n" "LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n" "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n" "THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n" "OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" "\n" "\n" "This product includes software developed by Niels Provos.\n" "\n" "[ libevent ]\n" "\n" "Copyright 2000-2003 Niels Provos \n" "All rights reserved.\n" "\n" "Redistribution and use in source and binary forms, with or without\n" "modification, are permitted provided that the following conditions\n" "are met:\n" "1. Redistributions of source code must retain the above copyright\n" " notice, this list of conditions and the following disclaimer.\n" "2. Redistributions in binary form must reproduce the above copyright\n" " notice, this list of conditions and the following disclaimer in the\n" " documentation and/or other materials provided with the distribution.\n" "3. All advertising materials mentioning features or use of this software\n" " must display the following acknowledgement:\n" " This product includes software developed by Niels Provos.\n" "4. The name of the author may not be used to endorse or promote products\n" " derived from this software without specific prior written permission.\n" "\n" "THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n" "IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n" "OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n" "IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\n" "INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n" "NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n" "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n" "THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n" "THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" ); return; } static void save_pid(const char *pid_file) { FILE *fp; if (access(pid_file, F_OK) == 0) { if ((fp = fopen(pid_file, "r")) != NULL) { char buffer[1024]; if (fgets(buffer, sizeof(buffer), fp) != NULL) { unsigned int pid; if (safe_strtoul(buffer, &pid) && kill((pid_t)pid, 0) == 0) { fprintf(stderr, "WARNING: The pid file contained the following (running) pid: %u\n", pid); } } fclose(fp); } } if ((fp = fopen(pid_file, "w")) == NULL) { vperror("Could not open the pid file %s for writing", pid_file); return; } fprintf(fp,"%ld\n", (long)getpid()); if (fclose(fp) == -1) { vperror("Could not close the pid file %s", pid_file); } } static void remove_pidfile(const char *pid_file) { if (pid_file == NULL) return; if (unlink(pid_file) != 0) { vperror("Could not remove the pid file %s", pid_file); } } static void sig_handler(const int sig) { printf("SIGINT handled.\n"); exit(EXIT_SUCCESS); } #ifndef HAVE_SIGIGNORE static int sigignore(int sig) { struct sigaction sa = { .sa_handler = SIG_IGN, .sa_flags = 0 }; if (sigemptyset(&sa.sa_mask) == -1 || sigaction(sig, &sa, 0) == -1) { return -1; } return 0; } #endif /* * On systems that supports multiple page sizes we may reduce the * number of TLB-misses by using the biggest available page size */ static int enable_large_pages(void) { #if defined(HAVE_GETPAGESIZES) && defined(HAVE_MEMCNTL) int ret = -1; size_t sizes[32]; int avail = getpagesizes(sizes, 32); if (avail != -1) { size_t max = sizes[0]; struct memcntl_mha arg = {0}; int ii; for (ii = 1; ii < avail; ++ii) { if (max < sizes[ii]) { max = sizes[ii]; } } arg.mha_flags = 0; arg.mha_pagesize = max; arg.mha_cmd = MHA_MAPSIZE_BSSBRK; if (memcntl(0, 0, MC_HAT_ADVISE, (caddr_t)&arg, 0, 0) == -1) { fprintf(stderr, "Failed to set large pages: %s\n", strerror(errno)); fprintf(stderr, "Will use default page size\n"); } else { ret = 0; } } else { fprintf(stderr, "Failed to get supported pagesizes: %s\n", strerror(errno)); fprintf(stderr, "Will use default page size\n"); } return ret; #else return 0; #endif } /** * Do basic sanity check of the runtime environment * @return true if no errors found, false if we can't use this env */ static bool sanitycheck(void) { /* One of our biggest problems is old and bogus libevents */ const char *ever = event_get_version(); if (ever != NULL) { if (strncmp(ever, "1.", 2) == 0) { /* Require at least 1.3 (that's still a couple of years old) */ if ((ever[2] == '1' || ever[2] == '2') && !isdigit(ever[3])) { fprintf(stderr, "You are using libevent %s.\nPlease upgrade to" " a more recent version (1.3 or newer)\n", event_get_version()); return false; } } } return true; } int main (int argc, char **argv) { int c; bool lock_memory = false; bool do_daemonize = false; bool preallocate = false; int maxcore = 0; char *username = NULL; char *pid_file = NULL; struct passwd *pw; struct rlimit rlim; char unit = '\0'; int size_max = 0; int retval = EXIT_SUCCESS; /* listening sockets */ static int *l_socket = NULL; /* udp socket */ static int *u_socket = NULL; bool protocol_specified = false; bool tcp_specified = false; bool udp_specified = false; char *subopts; char *subopts_value; enum { MAXCONNS_FAST = 0, HASHPOWER_INIT, SLAB_REASSIGN, SLAB_AUTOMOVE }; char *const subopts_tokens[] = { [MAXCONNS_FAST] = (char*)"maxconns_fast", [HASHPOWER_INIT] = (char*)"hashpower", [SLAB_REASSIGN] = (char*)"slab_reassign", [SLAB_AUTOMOVE] = (char*)"slab_automove", NULL }; if (!sanitycheck()) { return EX_OSERR; } /* handle SIGINT */ signal(SIGINT, sig_handler); /* init settings */ settings_init(); /* set stderr non-buffering (for running under, say, daemontools) */ setbuf(stderr, NULL); /* process arguments */ while (-1 != (c = getopt(argc, argv, "a:" /* access mask for unix socket */ "p:" /* TCP port number to listen on */ "s:" /* unix socket path to listen on */ "U:" /* UDP port number to listen on */ "m:" /* max memory to use for items in megabytes */ "M" /* return error on memory exhausted */ "c:" /* max simultaneous connections */ "k" /* lock down all paged memory */ "hi" /* help, licence info */ "r" /* maximize core file limit */ "v" /* verbose */ "d" /* daemon mode */ "l:" /* interface to listen on */ "u:" /* user identity to run as */ "P:" /* save PID in file */ "f:" /* factor? */ "n:" /* minimum space allocated for key+value+flags */ "t:" /* threads */ "D:" /* prefix delimiter? */ "L" /* Large memory pages */ "R:" /* max requests per event */ "C" /* Disable use of CAS */ "b:" /* backlog queue limit */ "B:" /* Binding protocol */ "I:" /* Max item size */ "S" /* Sasl ON */ "o:" /* Extended generic options */ ))) { switch (c) { case 'a': /* access for unix domain socket, as octal mask (like chmod)*/ settings.access= strtol(optarg,NULL,8); break; case 'U': settings.udpport = atoi(optarg); udp_specified = true; break; case 'p': settings.port = atoi(optarg); tcp_specified = true; break; case 's': settings.socketpath = optarg; break; case 'm': settings.maxbytes = ((size_t)atoi(optarg)) * 1024 * 1024; break; case 'M': settings.evict_to_free = 0; break; case 'c': settings.maxconns = atoi(optarg); break; case 'h': usage(); exit(EXIT_SUCCESS); case 'i': usage_license(); exit(EXIT_SUCCESS); case 'k': lock_memory = true; break; case 'v': settings.verbose++; break; case 'l': if (settings.inter != NULL) { size_t len = strlen(settings.inter) + strlen(optarg) + 2; char *p = malloc(len); if (p == NULL) { fprintf(stderr, "Failed to allocate memory\n"); return 1; } snprintf(p, len, "%s,%s", settings.inter, optarg); free(settings.inter); settings.inter = p; } else { settings.inter= strdup(optarg); } break; case 'd': do_daemonize = true; break; case 'r': maxcore = 1; break; case 'R': settings.reqs_per_event = atoi(optarg); if (settings.reqs_per_event == 0) { fprintf(stderr, "Number of requests per event must be greater than 0\n"); return 1; } break; case 'u': username = optarg; break; case 'P': pid_file = optarg; break; case 'f': settings.factor = atof(optarg); if (settings.factor <= 1.0) { fprintf(stderr, "Factor must be greater than 1\n"); return 1; } break; case 'n': settings.chunk_size = atoi(optarg); if (settings.chunk_size == 0) { fprintf(stderr, "Chunk size must be greater than 0\n"); return 1; } break; case 't': settings.num_threads = atoi(optarg); if (settings.num_threads <= 0) { fprintf(stderr, "Number of threads must be greater than 0\n"); return 1; } /* There're other problems when you get above 64 threads. * In the future we should portably detect # of cores for the * default. */ if (settings.num_threads > 64) { fprintf(stderr, "WARNING: Setting a high number of worker" "threads is not recommended.\n" " Set this value to the number of cores in" " your machine or less.\n"); } break; case 'D': if (! optarg || ! optarg[0]) { fprintf(stderr, "No delimiter specified\n"); return 1; } settings.prefix_delimiter = optarg[0]; settings.detail_enabled = 1; break; case 'L' : if (enable_large_pages() == 0) { preallocate = true; } break; case 'C' : settings.use_cas = false; break; case 'b' : settings.backlog = atoi(optarg); break; case 'B': protocol_specified = true; if (strcmp(optarg, "auto") == 0) { settings.binding_protocol = negotiating_prot; } else if (strcmp(optarg, "binary") == 0) { settings.binding_protocol = binary_prot; } else if (strcmp(optarg, "ascii") == 0) { settings.binding_protocol = ascii_prot; } else { fprintf(stderr, "Invalid value for binding protocol: %s\n" " -- should be one of auto, binary, or ascii\n", optarg); exit(EX_USAGE); } break; case 'I': unit = optarg[strlen(optarg)-1]; if (unit == 'k' || unit == 'm' || unit == 'K' || unit == 'M') { optarg[strlen(optarg)-1] = '\0'; size_max = atoi(optarg); if (unit == 'k' || unit == 'K') size_max *= 1024; if (unit == 'm' || unit == 'M') size_max *= 1024 * 1024; settings.item_size_max = size_max; } else { settings.item_size_max = atoi(optarg); } if (settings.item_size_max < 1024) { fprintf(stderr, "Item max size cannot be less than 1024 bytes.\n"); return 1; } if (settings.item_size_max > 1024 * 1024 * 128) { fprintf(stderr, "Cannot set item size limit higher than 128 mb.\n"); return 1; } if (settings.item_size_max > 1024 * 1024) { fprintf(stderr, "WARNING: Setting item max size above 1MB is not" " recommended!\n" " Raising this limit increases the minimum memory requirements\n" " and will decrease your memory efficiency.\n" ); } break; case 'S': /* set Sasl authentication to true. Default is false */ #ifndef ENABLE_SASL fprintf(stderr, "This server is not built with SASL support.\n"); exit(EX_USAGE); #endif settings.sasl = true; break; case 'o': /* It's sub-opts time! */ subopts = optarg; while (*subopts != '\0') { switch (getsubopt(&subopts, subopts_tokens, &subopts_value)) { case MAXCONNS_FAST: settings.maxconns_fast = true; break; case HASHPOWER_INIT: if (subopts_value == NULL) { fprintf(stderr, "Missing numeric argument for hashpower\n"); return 1; } settings.hashpower_init = atoi(subopts_value); if (settings.hashpower_init < 12) { fprintf(stderr, "Initial hashtable multiplier of %d is too low\n", settings.hashpower_init); return 1; } else if (settings.hashpower_init > 64) { fprintf(stderr, "Initial hashtable multiplier of %d is too high\n" "Choose a value based on \"STAT hash_power_level\" from a running instance\n", settings.hashpower_init); return 1; } break; case SLAB_REASSIGN: settings.slab_reassign = true; break; case SLAB_AUTOMOVE: settings.slab_automove = true; break; default: printf("Illegal suboption \"%s\"\n", subopts_value); return 1; } } break; default: fprintf(stderr, "Illegal argument \"%c\"\n", c); return 1; } } /* * Use one workerthread to serve each UDP port if the user specified * multiple ports */ if (settings.inter != NULL && strchr(settings.inter, ',')) { settings.num_threads_per_udp = 1; } else { settings.num_threads_per_udp = settings.num_threads; } if (settings.sasl) { if (!protocol_specified) { settings.binding_protocol = binary_prot; } else { if (settings.binding_protocol != binary_prot) { fprintf(stderr, "ERROR: You cannot allow the ASCII protocol while using SASL.\n"); exit(EX_USAGE); } } } if (tcp_specified && !udp_specified) { settings.udpport = settings.port; } else if (udp_specified && !tcp_specified) { settings.port = settings.udpport; } if (maxcore != 0) { struct rlimit rlim_new; /* * First try raising to infinity; if that fails, try bringing * the soft limit to the hard. */ if (getrlimit(RLIMIT_CORE, &rlim) == 0) { rlim_new.rlim_cur = rlim_new.rlim_max = RLIM_INFINITY; if (setrlimit(RLIMIT_CORE, &rlim_new)!= 0) { /* failed. try raising just to the old max */ rlim_new.rlim_cur = rlim_new.rlim_max = rlim.rlim_max; (void)setrlimit(RLIMIT_CORE, &rlim_new); } } /* * getrlimit again to see what we ended up with. Only fail if * the soft limit ends up 0, because then no core files will be * created at all. */ if ((getrlimit(RLIMIT_CORE, &rlim) != 0) || rlim.rlim_cur == 0) { fprintf(stderr, "failed to ensure corefile creation\n"); exit(EX_OSERR); } } /* * If needed, increase rlimits to allow as many connections * as needed. */ if (getrlimit(RLIMIT_NOFILE, &rlim) != 0) { fprintf(stderr, "failed to getrlimit number of files\n"); exit(EX_OSERR); } else { rlim.rlim_cur = settings.maxconns; rlim.rlim_max = settings.maxconns; if (setrlimit(RLIMIT_NOFILE, &rlim) != 0) { fprintf(stderr, "failed to set rlimit for open files. Try starting as root or requesting smaller maxconns value.\n"); exit(EX_OSERR); } } /* lose root privileges if we have them */ if (getuid() == 0 || geteuid() == 0) { if (username == 0 || *username == '\0') { fprintf(stderr, "can't run as root without the -u switch\n"); exit(EX_USAGE); } if ((pw = getpwnam(username)) == 0) { fprintf(stderr, "can't find the user %s to switch to\n", username); exit(EX_NOUSER); } if (setgid(pw->pw_gid) < 0 || setuid(pw->pw_uid) < 0) { fprintf(stderr, "failed to assume identity of user %s\n", username); exit(EX_OSERR); } } /* Initialize Sasl if -S was specified */ if (settings.sasl) { init_sasl(); } /* daemonize if requested */ /* if we want to ensure our ability to dump core, don't chdir to / */ if (do_daemonize) { if (sigignore(SIGHUP) == -1) { perror("Failed to ignore SIGHUP"); } if (daemonize(maxcore, settings.verbose) == -1) { fprintf(stderr, "failed to daemon() in order to daemonize\n"); exit(EXIT_FAILURE); } } /* lock paged memory if needed */ if (lock_memory) { #ifdef HAVE_MLOCKALL int res = mlockall(MCL_CURRENT | MCL_FUTURE); if (res != 0) { fprintf(stderr, "warning: -k invalid, mlockall() failed: %s\n", strerror(errno)); } #else fprintf(stderr, "warning: -k invalid, mlockall() not supported on this platform. proceeding without.\n"); #endif } /* initialize main thread libevent instance */ main_base = event_init(); /* initialize other stuff */ stats_init(); assoc_init(settings.hashpower_init); conn_init(); slabs_init(settings.maxbytes, settings.factor, preallocate); /* * ignore SIGPIPE signals; we can use errno == EPIPE if we * need that information */ if (sigignore(SIGPIPE) == -1) { perror("failed to ignore SIGPIPE; sigaction"); exit(EX_OSERR); } /* start up worker threads if MT mode */ thread_init(settings.num_threads, main_base); if (start_assoc_maintenance_thread() == -1) { exit(EXIT_FAILURE); } if (settings.slab_reassign && start_slab_maintenance_thread() == -1) { exit(EXIT_FAILURE); } /* initialise clock event */ clock_handler(0, 0, 0); /* create unix mode sockets after dropping privileges */ if (settings.socketpath != NULL) { errno = 0; if (server_socket_unix(settings.socketpath,settings.access)) { vperror("failed to listen on UNIX socket: %s", settings.socketpath); exit(EX_OSERR); } } /* create the listening socket, bind it, and init */ if (settings.socketpath == NULL) { const char *portnumber_filename = getenv("MEMCACHED_PORT_FILENAME"); char temp_portnumber_filename[PATH_MAX]; FILE *portnumber_file = NULL; if (portnumber_filename != NULL) { snprintf(temp_portnumber_filename, sizeof(temp_portnumber_filename), "%s.lck", portnumber_filename); portnumber_file = fopen(temp_portnumber_filename, "a"); if (portnumber_file == NULL) { fprintf(stderr, "Failed to open \"%s\": %s\n", temp_portnumber_filename, strerror(errno)); } } errno = 0; if (settings.port && server_sockets(settings.port, tcp_transport, portnumber_file)) { vperror("failed to listen on TCP port %d", settings.port); exit(EX_OSERR); } /* * initialization order: first create the listening sockets * (may need root on low ports), then drop root if needed, * then daemonise if needed, then init libevent (in some cases * descriptors created by libevent wouldn't survive forking). */ /* create the UDP listening socket and bind it */ errno = 0; if (settings.udpport && server_sockets(settings.udpport, udp_transport, portnumber_file)) { vperror("failed to listen on UDP port %d", settings.udpport); exit(EX_OSERR); } if (portnumber_file) { fclose(portnumber_file); rename(temp_portnumber_filename, portnumber_filename); } } /* Give the sockets a moment to open. I know this is dumb, but the error * is only an advisory. */ usleep(1000); if (stats.curr_conns + stats.reserved_fds >= settings.maxconns - 1) { fprintf(stderr, "Maxconns setting is too low, use -c to increase.\n"); exit(EXIT_FAILURE); } if (pid_file != NULL) { save_pid(pid_file); } /* Drop privileges no longer needed */ drop_privileges(); /* enter the event loop */ if (event_base_loop(main_base, 0) != 0) { retval = EXIT_FAILURE; } stop_assoc_maintenance_thread(); /* remove the PID file if we're a daemon */ #if 0 if (do_daemonize) remove_pidfile(pid_file); #endif /* Clean up strdup() call for bind() address */ if (settings.inter) free(settings.inter); if (l_socket) free(l_socket); if (u_socket) free(u_socket); return retval; } libmemcached-1.0.8/memcached/util.c0000664000076400007640000000634211753573717017453 0ustar00brianbrian00000000000000#include "memcached.h" #include #include #include #include #include #include #include /* Avoid warnings on solaris, where isspace() is an index into an array, and gcc uses signed chars */ #define xisspace(c) isspace((unsigned char)c) bool safe_strtoull(const char *str, uint64_t *out) { assert(out != NULL); errno = 0; *out = 0; char *endptr; unsigned long long ull = strtoull(str, &endptr, 10); if ((errno == ERANGE) || (str == endptr)) { return false; } if (xisspace(*endptr) || (*endptr == '\0' && endptr != str)) { if ((long long) ull < 0) { /* only check for negative signs in the uncommon case when * the unsigned number is so big that it's negative as a * signed number. */ if (strchr(str, '-') != NULL) { return false; } } *out = ull; return true; } return false; } bool safe_strtoll(const char *str, int64_t *out) { assert(out != NULL); errno = 0; *out = 0; char *endptr; long long ll = strtoll(str, &endptr, 10); if ((errno == ERANGE) || (str == endptr)) { return false; } if (xisspace(*endptr) || (*endptr == '\0' && endptr != str)) { *out = ll; return true; } return false; } bool safe_strtoul(const char *str, uint32_t *out) { char *endptr = NULL; unsigned long l = 0; assert(out); assert(str); *out = 0; errno = 0; l = strtoul(str, &endptr, 10); if ((errno == ERANGE) || (str == endptr)) { return false; } if (xisspace(*endptr) || (*endptr == '\0' && endptr != str)) { if ((long) l < 0) { /* only check for negative signs in the uncommon case when * the unsigned number is so big that it's negative as a * signed number. */ if (strchr(str, '-') != NULL) { return false; } } *out = l; return true; } return false; } bool safe_strtol(const char *str, int32_t *out) { assert(out != NULL); errno = 0; *out = 0; char *endptr; long l = strtol(str, &endptr, 10); if ((errno == ERANGE) || (str == endptr)) { return false; } if (xisspace(*endptr) || (*endptr == '\0' && endptr != str)) { *out = l; return true; } return false; } void vperror(const char *fmt, ...) { int old_errno = errno; char buf[1024]; va_list ap; va_start(ap, fmt); if (vsnprintf(buf, sizeof(buf), fmt, ap) == -1) { buf[sizeof(buf) - 1] = '\0'; } va_end(ap); errno = old_errno; perror(buf); } #ifndef HAVE_HTONLL static uint64_t mc_swap64(uint64_t in) { #ifdef ENDIAN_LITTLE /* Little endian, flip the bytes around until someone makes a faster/better * way to do this. */ int64_t rv = 0; int i = 0; for(i = 0; i<8; i++) { rv = (rv << 8) | (in & 0xff); in >>= 8; } return rv; #else /* big-endian machines don't need byte swapping */ return in; #endif } uint64_t ntohll(uint64_t val) { return mc_swap64(val); } uint64_t htonll(uint64_t val) { return mc_swap64(val); } #endif libmemcached-1.0.8/memcached/stats.c0000664000076400007640000003031211753573717017626 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Detailed statistics management. For simple stats like total number of * "get" requests, we use inline code in memcached.c and friends, but when * stats detail mode is activated, the code here records more information. * * Author: * Steven Grimm */ #include "memcached.h" #include #include #include #include /* * Stats are tracked on the basis of key prefixes. This is a simple * fixed-size hash of prefixes; we run the prefixes through the same * CRC function used by the cache hashtable. */ typedef struct _prefix_stats PREFIX_STATS; struct _prefix_stats { char *prefix; size_t prefix_len; uint64_t num_gets; uint64_t num_sets; uint64_t num_deletes; uint64_t num_hits; PREFIX_STATS *next; }; #define PREFIX_HASH_SIZE 256 static PREFIX_STATS *prefix_stats[PREFIX_HASH_SIZE]; static int num_prefixes = 0; static int total_prefix_size = 0; void stats_prefix_init() { memset(prefix_stats, 0, sizeof(prefix_stats)); } /* * Cleans up all our previously collected stats. NOTE: the stats lock is * assumed to be held when this is called. */ void stats_prefix_clear() { int i; for (i = 0; i < PREFIX_HASH_SIZE; i++) { PREFIX_STATS *cur, *next; for (cur = prefix_stats[i]; cur != NULL; cur = next) { next = cur->next; free(cur->prefix); free(cur); } prefix_stats[i] = NULL; } num_prefixes = 0; total_prefix_size = 0; } /* * Returns the stats structure for a prefix, creating it if it's not already * in the list. */ /*@null@*/ static PREFIX_STATS *stats_prefix_find(const char *key, const size_t nkey) { PREFIX_STATS *pfs; uint32_t hashval; size_t length; bool bailout = true; assert(key != NULL); for (length = 0; length < nkey && key[length] != '\0'; length++) { if (key[length] == settings.prefix_delimiter) { bailout = false; break; } } if (bailout) { return NULL; } hashval = hash(key, length, 0) % PREFIX_HASH_SIZE; for (pfs = prefix_stats[hashval]; NULL != pfs; pfs = pfs->next) { if (strncmp(pfs->prefix, key, length) == 0) return pfs; } pfs = calloc(sizeof(PREFIX_STATS), 1); if (NULL == pfs) { perror("Can't allocate space for stats structure: calloc"); return NULL; } pfs->prefix = malloc(length + 1); if (NULL == pfs->prefix) { perror("Can't allocate space for copy of prefix: malloc"); free(pfs); return NULL; } strncpy(pfs->prefix, key, length); pfs->prefix[length] = '\0'; /* because strncpy() sucks */ pfs->prefix_len = length; pfs->next = prefix_stats[hashval]; prefix_stats[hashval] = pfs; num_prefixes++; total_prefix_size += length; return pfs; } /* * Records a "get" of a key. */ void stats_prefix_record_get(const char *key, const size_t nkey, const bool is_hit) { PREFIX_STATS *pfs; STATS_LOCK(); pfs = stats_prefix_find(key, nkey); if (NULL != pfs) { pfs->num_gets++; if (is_hit) { pfs->num_hits++; } } STATS_UNLOCK(); } /* * Records a "delete" of a key. */ void stats_prefix_record_delete(const char *key, const size_t nkey) { PREFIX_STATS *pfs; STATS_LOCK(); pfs = stats_prefix_find(key, nkey); if (NULL != pfs) { pfs->num_deletes++; } STATS_UNLOCK(); } /* * Records a "set" of a key. */ void stats_prefix_record_set(const char *key, const size_t nkey) { PREFIX_STATS *pfs; STATS_LOCK(); pfs = stats_prefix_find(key, nkey); if (NULL != pfs) { pfs->num_sets++; } STATS_UNLOCK(); } /* * Returns stats in textual form suitable for writing to a client. */ /*@null@*/ char *stats_prefix_dump(int *length) { const char *format = "PREFIX %s get %llu hit %llu set %llu del %llu\r\n"; PREFIX_STATS *pfs; char *buf; int i, pos; size_t size = 0, written = 0, total_written = 0; /* * Figure out how big the buffer needs to be. This is the sum of the * lengths of the prefixes themselves, plus the size of one copy of * the per-prefix output with 20-digit values for all the counts, * plus space for the "END" at the end. */ STATS_LOCK(); size = strlen(format) + total_prefix_size + num_prefixes * (strlen(format) - 2 /* %s */ + 4 * (20 - 4)) /* %llu replaced by 20-digit num */ + sizeof("END\r\n"); buf = malloc(size); if (NULL == buf) { perror("Can't allocate stats response: malloc"); STATS_UNLOCK(); return NULL; } pos = 0; for (i = 0; i < PREFIX_HASH_SIZE; i++) { for (pfs = prefix_stats[i]; NULL != pfs; pfs = pfs->next) { written = snprintf(buf + pos, size-pos, format, pfs->prefix, pfs->num_gets, pfs->num_hits, pfs->num_sets, pfs->num_deletes); pos += written; total_written += written; assert(total_written < size); } } STATS_UNLOCK(); memcpy(buf + pos, "END\r\n", 6); *length = pos + 5; return buf; } #ifdef UNIT_TEST /**************************************************************************** To run unit tests, compile with $(CC) -DUNIT_TEST stats.c assoc.o (need assoc.o to get the hash() function). ****************************************************************************/ struct settings settings; static char *current_test = ""; static int test_count = 0; static int fail_count = 0; static void fail(char *what) { printf("\tFAIL: %s\n", what); fflush(stdout); fail_count++; } static void test_equals_int(char *what, int a, int b) { test_count++; if (a != b) fail(what); } static void test_equals_ptr(char *what, void *a, void *b) { test_count++; if (a != b) fail(what); } static void test_equals_str(char *what, const char *a, const char *b) { test_count++; if (strcmp(a, b)) fail(what); } static void test_equals_ull(char *what, uint64_t a, uint64_t b) { test_count++; if (a != b) fail(what); } static void test_notequals_ptr(char *what, void *a, void *b) { test_count++; if (a == b) fail(what); } static void test_notnull_ptr(char *what, void *a) { test_count++; if (NULL == a) fail(what); } static void test_prefix_find() { PREFIX_STATS *pfs1, *pfs2; pfs1 = stats_prefix_find("abc"); test_notnull_ptr("initial prefix find", pfs1); test_equals_ull("request counts", 0ULL, pfs1->num_gets + pfs1->num_sets + pfs1->num_deletes + pfs1->num_hits); pfs2 = stats_prefix_find("abc"); test_equals_ptr("find of same prefix", pfs1, pfs2); pfs2 = stats_prefix_find("abc:"); test_equals_ptr("find of same prefix, ignoring delimiter", pfs1, pfs2); pfs2 = stats_prefix_find("abc:d"); test_equals_ptr("find of same prefix, ignoring extra chars", pfs1, pfs2); pfs2 = stats_prefix_find("xyz123"); test_notequals_ptr("find of different prefix", pfs1, pfs2); pfs2 = stats_prefix_find("ab:"); test_notequals_ptr("find of shorter prefix", pfs1, pfs2); } static void test_prefix_record_get() { PREFIX_STATS *pfs; stats_prefix_record_get("abc:123", 0); pfs = stats_prefix_find("abc:123"); test_equals_ull("get count after get #1", 1, pfs->num_gets); test_equals_ull("hit count after get #1", 0, pfs->num_hits); stats_prefix_record_get("abc:456", 0); test_equals_ull("get count after get #2", 2, pfs->num_gets); test_equals_ull("hit count after get #2", 0, pfs->num_hits); stats_prefix_record_get("abc:456", 1); test_equals_ull("get count after get #3", 3, pfs->num_gets); test_equals_ull("hit count after get #3", 1, pfs->num_hits); stats_prefix_record_get("def:", 1); test_equals_ull("get count after get #4", 3, pfs->num_gets); test_equals_ull("hit count after get #4", 1, pfs->num_hits); } static void test_prefix_record_delete() { PREFIX_STATS *pfs; stats_prefix_record_delete("abc:123"); pfs = stats_prefix_find("abc:123"); test_equals_ull("get count after delete #1", 0, pfs->num_gets); test_equals_ull("hit count after delete #1", 0, pfs->num_hits); test_equals_ull("delete count after delete #1", 1, pfs->num_deletes); test_equals_ull("set count after delete #1", 0, pfs->num_sets); stats_prefix_record_delete("def:"); test_equals_ull("delete count after delete #2", 1, pfs->num_deletes); } static void test_prefix_record_set() { PREFIX_STATS *pfs; stats_prefix_record_set("abc:123"); pfs = stats_prefix_find("abc:123"); test_equals_ull("get count after set #1", 0, pfs->num_gets); test_equals_ull("hit count after set #1", 0, pfs->num_hits); test_equals_ull("delete count after set #1", 0, pfs->num_deletes); test_equals_ull("set count after set #1", 1, pfs->num_sets); stats_prefix_record_delete("def:"); test_equals_ull("set count after set #2", 1, pfs->num_sets); } static void test_prefix_dump() { int hashval = hash("abc", 3, 0) % PREFIX_HASH_SIZE; char tmp[500]; char *expected; int keynum; int length; test_equals_str("empty stats", "END\r\n", stats_prefix_dump(&length)); test_equals_int("empty stats length", 5, length); stats_prefix_record_set("abc:123"); expected = "PREFIX abc get 0 hit 0 set 1 del 0\r\nEND\r\n"; test_equals_str("stats after set", expected, stats_prefix_dump(&length)); test_equals_int("stats length after set", strlen(expected), length); stats_prefix_record_get("abc:123", 0); expected = "PREFIX abc get 1 hit 0 set 1 del 0\r\nEND\r\n"; test_equals_str("stats after get #1", expected, stats_prefix_dump(&length)); test_equals_int("stats length after get #1", strlen(expected), length); stats_prefix_record_get("abc:123", 1); expected = "PREFIX abc get 2 hit 1 set 1 del 0\r\nEND\r\n"; test_equals_str("stats after get #2", expected, stats_prefix_dump(&length)); test_equals_int("stats length after get #2", strlen(expected), length); stats_prefix_record_delete("abc:123"); expected = "PREFIX abc get 2 hit 1 set 1 del 1\r\nEND\r\n"; test_equals_str("stats after del #1", expected, stats_prefix_dump(&length)); test_equals_int("stats length after del #1", strlen(expected), length); /* The order of results might change if we switch hash functions. */ stats_prefix_record_delete("def:123"); expected = "PREFIX abc get 2 hit 1 set 1 del 1\r\n" "PREFIX def get 0 hit 0 set 0 del 1\r\n" "END\r\n"; test_equals_str("stats after del #2", expected, stats_prefix_dump(&length)); test_equals_int("stats length after del #2", strlen(expected), length); /* Find a key that hashes to the same bucket as "abc" */ for (keynum = 0; keynum < PREFIX_HASH_SIZE * 100; keynum++) { snprintf(tmp, sizeof(tmp), "%d", keynum); if (hashval == hash(tmp, strlen(tmp), 0) % PREFIX_HASH_SIZE) { break; } } stats_prefix_record_set(tmp); snprintf(tmp, sizeof(tmp), "PREFIX %d get 0 hit 0 set 1 del 0\r\n" "PREFIX abc get 2 hit 1 set 1 del 1\r\n" "PREFIX def get 0 hit 0 set 0 del 1\r\n" "END\r\n", keynum); test_equals_str("stats with two stats in one bucket", tmp, stats_prefix_dump(&length)); test_equals_int("stats length with two stats in one bucket", strlen(tmp), length); } static void run_test(char *what, void (*func)(void)) { current_test = what; test_count = fail_count = 0; puts(what); fflush(stdout); stats_prefix_clear(); (func)(); printf("\t%d / %d pass\n", (test_count - fail_count), test_count); } /* In case we're compiled in thread mode */ void mt_stats_lock() { } void mt_stats_unlock() { } main(int argc, char **argv) { stats_prefix_init(); settings.prefix_delimiter = ':'; run_test("stats_prefix_find", test_prefix_find); run_test("stats_prefix_record_get", test_prefix_record_get); run_test("stats_prefix_record_delete", test_prefix_record_delete); run_test("stats_prefix_record_set", test_prefix_record_set); run_test("stats_prefix_dump", test_prefix_dump); } #endif libmemcached-1.0.8/memcached/protocol_binary.h0000664000076400007640000004021411753573717021704 0ustar00brianbrian00000000000000/* * Copyright (c) <2008>, Sun Microsystems, Inc. * 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. * * Neither the name of the nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY SUN MICROSYSTEMS, INC. ``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 SUN MICROSYSTEMS, INC. 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. */ /* * Summary: Constants used by to implement the binary protocol. * * Copy: See Copyright for the status of this software. * * Author: Trond Norbye */ #ifndef PROTOCOL_BINARY_H #define PROTOCOL_BINARY_H /** * This file contains definitions of the constants and packet formats * defined in the binary specification. Please note that you _MUST_ remember * to convert each multibyte field to / from network byte order to / from * host order. */ #ifdef __cplusplus extern "C" { #endif /** * Definition of the legal "magic" values used in a packet. * See section 3.1 Magic byte */ typedef enum { PROTOCOL_BINARY_REQ = 0x80, PROTOCOL_BINARY_RES = 0x81 } protocol_binary_magic; /** * Definition of the valid response status numbers. * See section 3.2 Response Status */ typedef enum { PROTOCOL_BINARY_RESPONSE_SUCCESS = 0x00, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT = 0x01, PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS = 0x02, PROTOCOL_BINARY_RESPONSE_E2BIG = 0x03, PROTOCOL_BINARY_RESPONSE_EINVAL = 0x04, PROTOCOL_BINARY_RESPONSE_NOT_STORED = 0x05, PROTOCOL_BINARY_RESPONSE_DELTA_BADVAL = 0x06, PROTOCOL_BINARY_RESPONSE_AUTH_ERROR = 0x20, PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE = 0x21, PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND = 0x81, PROTOCOL_BINARY_RESPONSE_ENOMEM = 0x82 } protocol_binary_response_status; /** * Defintion of the different command opcodes. * See section 3.3 Command Opcodes */ typedef enum { PROTOCOL_BINARY_CMD_GET = 0x00, PROTOCOL_BINARY_CMD_SET = 0x01, PROTOCOL_BINARY_CMD_ADD = 0x02, PROTOCOL_BINARY_CMD_REPLACE = 0x03, PROTOCOL_BINARY_CMD_DELETE = 0x04, PROTOCOL_BINARY_CMD_INCREMENT = 0x05, PROTOCOL_BINARY_CMD_DECREMENT = 0x06, PROTOCOL_BINARY_CMD_QUIT = 0x07, PROTOCOL_BINARY_CMD_FLUSH = 0x08, PROTOCOL_BINARY_CMD_GETQ = 0x09, PROTOCOL_BINARY_CMD_NOOP = 0x0a, PROTOCOL_BINARY_CMD_VERSION = 0x0b, PROTOCOL_BINARY_CMD_GETK = 0x0c, PROTOCOL_BINARY_CMD_GETKQ = 0x0d, PROTOCOL_BINARY_CMD_APPEND = 0x0e, PROTOCOL_BINARY_CMD_PREPEND = 0x0f, PROTOCOL_BINARY_CMD_STAT = 0x10, PROTOCOL_BINARY_CMD_SETQ = 0x11, PROTOCOL_BINARY_CMD_ADDQ = 0x12, PROTOCOL_BINARY_CMD_REPLACEQ = 0x13, PROTOCOL_BINARY_CMD_DELETEQ = 0x14, PROTOCOL_BINARY_CMD_INCREMENTQ = 0x15, PROTOCOL_BINARY_CMD_DECREMENTQ = 0x16, PROTOCOL_BINARY_CMD_QUITQ = 0x17, PROTOCOL_BINARY_CMD_FLUSHQ = 0x18, PROTOCOL_BINARY_CMD_APPENDQ = 0x19, PROTOCOL_BINARY_CMD_PREPENDQ = 0x1a, PROTOCOL_BINARY_CMD_TOUCH = 0x1c, PROTOCOL_BINARY_CMD_GAT = 0x1d, PROTOCOL_BINARY_CMD_GATQ = 0x1e, PROTOCOL_BINARY_CMD_GATK = 0x23, PROTOCOL_BINARY_CMD_GATKQ = 0x24, PROTOCOL_BINARY_CMD_SASL_LIST_MECHS = 0x20, PROTOCOL_BINARY_CMD_SASL_AUTH = 0x21, PROTOCOL_BINARY_CMD_SASL_STEP = 0x22, /* These commands are used for range operations and exist within * this header for use in other projects. Range operations are * not expected to be implemented in the memcached server itself. */ PROTOCOL_BINARY_CMD_RGET = 0x30, PROTOCOL_BINARY_CMD_RSET = 0x31, PROTOCOL_BINARY_CMD_RSETQ = 0x32, PROTOCOL_BINARY_CMD_RAPPEND = 0x33, PROTOCOL_BINARY_CMD_RAPPENDQ = 0x34, PROTOCOL_BINARY_CMD_RPREPEND = 0x35, PROTOCOL_BINARY_CMD_RPREPENDQ = 0x36, PROTOCOL_BINARY_CMD_RDELETE = 0x37, PROTOCOL_BINARY_CMD_RDELETEQ = 0x38, PROTOCOL_BINARY_CMD_RINCR = 0x39, PROTOCOL_BINARY_CMD_RINCRQ = 0x3a, PROTOCOL_BINARY_CMD_RDECR = 0x3b, PROTOCOL_BINARY_CMD_RDECRQ = 0x3c /* End Range operations */ } protocol_binary_command; /** * Definition of the data types in the packet * See section 3.4 Data Types */ typedef enum { PROTOCOL_BINARY_RAW_BYTES = 0x00 } protocol_binary_datatypes; /** * Definition of the header structure for a request packet. * See section 2 */ typedef union { struct { uint8_t magic; uint8_t opcode; uint16_t keylen; uint8_t extlen; uint8_t datatype; uint16_t reserved; uint32_t bodylen; uint32_t opaque; uint64_t cas; } request; uint8_t bytes[24]; } protocol_binary_request_header; /** * Definition of the header structure for a response packet. * See section 2 */ typedef union { struct { uint8_t magic; uint8_t opcode; uint16_t keylen; uint8_t extlen; uint8_t datatype; uint16_t status; uint32_t bodylen; uint32_t opaque; uint64_t cas; } response; uint8_t bytes[24]; } protocol_binary_response_header; /** * Definition of a request-packet containing no extras */ typedef union { struct { protocol_binary_request_header header; } message; uint8_t bytes[sizeof(protocol_binary_request_header)]; } protocol_binary_request_no_extras; /** * Definition of a response-packet containing no extras */ typedef union { struct { protocol_binary_response_header header; } message; uint8_t bytes[sizeof(protocol_binary_response_header)]; } protocol_binary_response_no_extras; /** * Definition of the packet used by the get, getq, getk and getkq command. * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_get; typedef protocol_binary_request_no_extras protocol_binary_request_getq; typedef protocol_binary_request_no_extras protocol_binary_request_getk; typedef protocol_binary_request_no_extras protocol_binary_request_getkq; /** * Definition of the packet returned from a successful get, getq, getk and * getkq. * See section 4 */ typedef union { struct { protocol_binary_response_header header; struct { uint32_t flags; } body; } message; uint8_t bytes[sizeof(protocol_binary_response_header) + 4]; } protocol_binary_response_get; typedef protocol_binary_response_get protocol_binary_response_getq; typedef protocol_binary_response_get protocol_binary_response_getk; typedef protocol_binary_response_get protocol_binary_response_getkq; /** * Definition of the packet used by the delete command * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_delete; /** * Definition of the packet returned by the delete command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_delete; /** * Definition of the packet used by the flush command * See section 4 * Please note that the expiration field is optional, so remember to see * check the header.bodysize to see if it is present. */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_flush; /** * Definition of the packet returned by the flush command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_flush; /** * Definition of the packet used by set, add and replace * See section 4 */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t flags; uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 8]; } protocol_binary_request_set; typedef protocol_binary_request_set protocol_binary_request_add; typedef protocol_binary_request_set protocol_binary_request_replace; /** * Definition of the packet returned by set, add and replace * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_set; typedef protocol_binary_response_no_extras protocol_binary_response_add; typedef protocol_binary_response_no_extras protocol_binary_response_replace; /** * Definition of the noop packet * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_noop; /** * Definition of the packet returned by the noop command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_noop; /** * Definition of the structure used by the increment and decrement * command. * See section 4 */ typedef union { struct { protocol_binary_request_header header; struct { uint64_t delta; uint64_t initial; uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 20]; } protocol_binary_request_incr; typedef protocol_binary_request_incr protocol_binary_request_decr; /** * Definition of the response from an incr or decr command * command. * See section 4 */ typedef union { struct { protocol_binary_response_header header; struct { uint64_t value; } body; } message; uint8_t bytes[sizeof(protocol_binary_response_header) + 8]; } protocol_binary_response_incr; typedef protocol_binary_response_incr protocol_binary_response_decr; /** * Definition of the quit * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_quit; /** * Definition of the packet returned by the quit command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_quit; /** * Definition of the packet used by append and prepend command * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_append; typedef protocol_binary_request_no_extras protocol_binary_request_prepend; /** * Definition of the packet returned from a successful append or prepend * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_append; typedef protocol_binary_response_no_extras protocol_binary_response_prepend; /** * Definition of the packet used by the version command * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_version; /** * Definition of the packet returned from a successful version command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_version; /** * Definition of the packet used by the stats command. * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_stats; /** * Definition of the packet returned from a successful stats command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_stats; /** * Definition of the packet used by the touch command. */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_touch; /** * Definition of the packet returned from the touch command */ typedef protocol_binary_response_no_extras protocol_binary_response_touch; /** * Definition of the packet used by the GAT(Q) command. */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_gat; typedef protocol_binary_request_gat protocol_binary_request_gatq; typedef protocol_binary_request_gat protocol_binary_request_gatk; typedef protocol_binary_request_gat protocol_binary_request_gatkq; /** * Definition of the packet returned from the GAT(Q) */ typedef protocol_binary_response_get protocol_binary_response_gat; typedef protocol_binary_response_get protocol_binary_response_gatq; typedef protocol_binary_response_get protocol_binary_response_gatk; typedef protocol_binary_response_get protocol_binary_response_gatkq; /** * Definition of a request for a range operation. * See http://code.google.com/p/memcached/wiki/RangeOps * * These types are used for range operations and exist within * this header for use in other projects. Range operations are * not expected to be implemented in the memcached server itself. */ typedef union { struct { protocol_binary_response_header header; struct { uint16_t size; uint8_t reserved; uint8_t flags; uint32_t max_results; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_rangeop; typedef protocol_binary_request_rangeop protocol_binary_request_rget; typedef protocol_binary_request_rangeop protocol_binary_request_rset; typedef protocol_binary_request_rangeop protocol_binary_request_rsetq; typedef protocol_binary_request_rangeop protocol_binary_request_rappend; typedef protocol_binary_request_rangeop protocol_binary_request_rappendq; typedef protocol_binary_request_rangeop protocol_binary_request_rprepend; typedef protocol_binary_request_rangeop protocol_binary_request_rprependq; typedef protocol_binary_request_rangeop protocol_binary_request_rdelete; typedef protocol_binary_request_rangeop protocol_binary_request_rdeleteq; typedef protocol_binary_request_rangeop protocol_binary_request_rincr; typedef protocol_binary_request_rangeop protocol_binary_request_rincrq; typedef protocol_binary_request_rangeop protocol_binary_request_rdecr; typedef protocol_binary_request_rangeop protocol_binary_request_rdecrq; #ifdef __cplusplus } #endif #endif /* PROTOCOL_BINARY_H */ libmemcached-1.0.8/memcached/assoc.h0000664000076400007640000000060211753573717017604 0ustar00brianbrian00000000000000/* associative array */ void assoc_init(const int hashpower_init); item *assoc_find(const char *key, const size_t nkey, const uint32_t hv); int assoc_insert(item *item, const uint32_t hv); void assoc_delete(const char *key, const size_t nkey, const uint32_t hv); void do_assoc_move_next_bucket(void); int start_assoc_maintenance_thread(void); void stop_assoc_maintenance_thread(void); libmemcached-1.0.8/memcached/hash.h0000664000076400007640000000031511753573717017420 0ustar00brianbrian00000000000000#ifndef HASH_H #define HASH_H #ifdef __cplusplus extern "C" { #endif uint32_t hash(const void *key, size_t length, const uint32_t initval); #ifdef __cplusplus } #endif #endif /* HASH_H */ libmemcached-1.0.8/memcached/hash.c0000664000076400007640000003506411753573717017424 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Hash table * * The hash function used here is by Bob Jenkins, 1996: * * "By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. * You may use this code any way you wish, private, educational, * or commercial. It's free." * */ #include "memcached.h" /* * Since the hash function does bit manipulation, it needs to know * whether it's big or little-endian. ENDIAN_LITTLE and ENDIAN_BIG * are set in the configure script. */ #if defined(ENDIAN_BIG) && ENDIAN_BIG == 1 # define HASH_LITTLE_ENDIAN 0 # define HASH_BIG_ENDIAN 1 #else # if defined(ENDIAN_LITTLE) && ENDIAN_LITTLE == 1 # define HASH_LITTLE_ENDIAN 1 # define HASH_BIG_ENDIAN 0 # else # define HASH_LITTLE_ENDIAN 0 # define HASH_BIG_ENDIAN 0 # endif #endif #define rot(x,k) (((x)<<(k)) ^ ((x)>>(32-(k)))) /* ------------------------------------------------------------------------------- mix -- mix 3 32-bit values reversibly. This is reversible, so any information in (a,b,c) before mix() is still in (a,b,c) after mix(). If four pairs of (a,b,c) inputs are run through mix(), or through mix() in reverse, there are at least 32 bits of the output that are sometimes the same for one pair and different for another pair. This was tested for: * pairs that differed by one bit, by two bits, in any combination of top bits of (a,b,c), or in any combination of bottom bits of (a,b,c). * "differ" is defined as +, -, ^, or ~^. For + and -, I transformed the output delta to a Gray code (a^(a>>1)) so a string of 1's (as is commonly produced by subtraction) look like a single 1-bit difference. * the base values were pseudorandom, all zero but one bit set, or all zero plus a counter that starts at zero. Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that satisfy this are 4 6 8 16 19 4 9 15 3 18 27 15 14 9 3 7 17 3 Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing for "differ" defined as + with a one-bit base and a two-bit delta. I used http://burtleburtle.net/bob/hash/avalanche.html to choose the operations, constants, and arrangements of the variables. This does not achieve avalanche. There are input bits of (a,b,c) that fail to affect some output bits of (a,b,c), especially of a. The most thoroughly mixed value is c, but it doesn't really even achieve avalanche in c. This allows some parallelism. Read-after-writes are good at doubling the number of bits affected, so the goal of mixing pulls in the opposite direction as the goal of parallelism. I did what I could. Rotates seem to cost as much as shifts on every machine I could lay my hands on, and rotates are much kinder to the top and bottom bits, so I used rotates. ------------------------------------------------------------------------------- */ #define mix(a,b,c) \ { \ a -= c; a ^= rot(c, 4); c += b; \ b -= a; b ^= rot(a, 6); a += c; \ c -= b; c ^= rot(b, 8); b += a; \ a -= c; a ^= rot(c,16); c += b; \ b -= a; b ^= rot(a,19); a += c; \ c -= b; c ^= rot(b, 4); b += a; \ } /* ------------------------------------------------------------------------------- final -- final mixing of 3 32-bit values (a,b,c) into c Pairs of (a,b,c) values differing in only a few bits will usually produce values of c that look totally different. This was tested for * pairs that differed by one bit, by two bits, in any combination of top bits of (a,b,c), or in any combination of bottom bits of (a,b,c). * "differ" is defined as +, -, ^, or ~^. For + and -, I transformed the output delta to a Gray code (a^(a>>1)) so a string of 1's (as is commonly produced by subtraction) look like a single 1-bit difference. * the base values were pseudorandom, all zero but one bit set, or all zero plus a counter that starts at zero. These constants passed: 14 11 25 16 4 14 24 12 14 25 16 4 14 24 and these came close: 4 8 15 26 3 22 24 10 8 15 26 3 22 24 11 8 15 26 3 22 24 ------------------------------------------------------------------------------- */ #define final(a,b,c) \ { \ c ^= b; c -= rot(b,14); \ a ^= c; a -= rot(c,11); \ b ^= a; b -= rot(a,25); \ c ^= b; c -= rot(b,16); \ a ^= c; a -= rot(c,4); \ b ^= a; b -= rot(a,14); \ c ^= b; c -= rot(b,24); \ } #if HASH_LITTLE_ENDIAN == 1 uint32_t hash( const void *key, /* the key to hash */ size_t length, /* length of the key */ const uint32_t initval) /* initval */ { uint32_t a,b,c; /* internal state */ union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */ /* Set up the internal state */ a = b = c = 0xdeadbeef + ((uint32_t)length) + initval; u.ptr = key; if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) { const uint32_t *k = key; /* read 32-bit chunks */ #ifdef VALGRIND const uint8_t *k8; #endif /* ifdef VALGRIND */ /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */ while (length > 12) { a += k[0]; b += k[1]; c += k[2]; mix(a,b,c); length -= 12; k += 3; } /*----------------------------- handle the last (probably partial) block */ /* * "k[2]&0xffffff" actually reads beyond the end of the string, but * then masks off the part it's not allowed to read. Because the * string is aligned, the masked-off tail is in the same word as the * rest of the string. Every machine with memory protection I've seen * does it on word boundaries, so is OK with this. But VALGRIND will * still catch it and complain. The masking trick does make the hash * noticably faster for short strings (like English words). */ #ifndef VALGRIND switch(length) { case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break; case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break; case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break; case 8 : b+=k[1]; a+=k[0]; break; case 7 : b+=k[1]&0xffffff; a+=k[0]; break; case 6 : b+=k[1]&0xffff; a+=k[0]; break; case 5 : b+=k[1]&0xff; a+=k[0]; break; case 4 : a+=k[0]; break; case 3 : a+=k[0]&0xffffff; break; case 2 : a+=k[0]&0xffff; break; case 1 : a+=k[0]&0xff; break; case 0 : return c; /* zero length strings require no mixing */ default: abort(); } #else /* make valgrind happy */ k8 = (const uint8_t *)k; switch(length) { case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; case 11: c+=((uint32_t)k8[10])<<16; /* fall through */ case 10: c+=((uint32_t)k8[9])<<8; /* fall through */ case 9 : c+=k8[8]; /* fall through */ case 8 : b+=k[1]; a+=k[0]; break; case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */ case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */ case 5 : b+=k8[4]; /* fall through */ case 4 : a+=k[0]; break; case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */ case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */ case 1 : a+=k8[0]; break; case 0 : return c; /* zero length strings require no mixing */ } #endif /* !valgrind */ } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) { const uint16_t *k = key; /* read 16-bit chunks */ const uint8_t *k8; /*--------------- all but last block: aligned reads and different mixing */ while (length > 12) { a += k[0] + (((uint32_t)k[1])<<16); b += k[2] + (((uint32_t)k[3])<<16); c += k[4] + (((uint32_t)k[5])<<16); mix(a,b,c); length -= 12; k += 6; } /*----------------------------- handle the last (probably partial) block */ k8 = (const uint8_t *)k; switch(length) { case 12: c+=k[4]+(((uint32_t)k[5])<<16); b+=k[2]+(((uint32_t)k[3])<<16); a+=k[0]+(((uint32_t)k[1])<<16); break; case 11: c+=((uint32_t)k8[10])<<16; /* @fallthrough */ case 10: c+=k[4]; /* @fallthrough@ */ b+=k[2]+(((uint32_t)k[3])<<16); a+=k[0]+(((uint32_t)k[1])<<16); break; case 9 : c+=k8[8]; /* @fallthrough */ case 8 : b+=k[2]+(((uint32_t)k[3])<<16); a+=k[0]+(((uint32_t)k[1])<<16); break; case 7 : b+=((uint32_t)k8[6])<<16; /* @fallthrough */ case 6 : b+=k[2]; a+=k[0]+(((uint32_t)k[1])<<16); break; case 5 : b+=k8[4]; /* @fallthrough */ case 4 : a+=k[0]+(((uint32_t)k[1])<<16); break; case 3 : a+=((uint32_t)k8[2])<<16; /* @fallthrough */ case 2 : a+=k[0]; break; case 1 : a+=k8[0]; break; case 0 : return c; /* zero length strings require no mixing */ default: abort(); } } else { /* need to read the key one byte at a time */ const uint8_t *k = key; /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ while (length > 12) { a += k[0]; a += ((uint32_t)k[1])<<8; a += ((uint32_t)k[2])<<16; a += ((uint32_t)k[3])<<24; b += k[4]; b += ((uint32_t)k[5])<<8; b += ((uint32_t)k[6])<<16; b += ((uint32_t)k[7])<<24; c += k[8]; c += ((uint32_t)k[9])<<8; c += ((uint32_t)k[10])<<16; c += ((uint32_t)k[11])<<24; mix(a,b,c); length -= 12; k += 12; } /*-------------------------------- last block: affect all 32 bits of (c) */ switch(length) /* all the case statements fall through */ { case 12: c+=((uint32_t)k[11])<<24; case 11: c+=((uint32_t)k[10])<<16; case 10: c+=((uint32_t)k[9])<<8; case 9 : c+=k[8]; case 8 : b+=((uint32_t)k[7])<<24; case 7 : b+=((uint32_t)k[6])<<16; case 6 : b+=((uint32_t)k[5])<<8; case 5 : b+=k[4]; case 4 : a+=((uint32_t)k[3])<<24; case 3 : a+=((uint32_t)k[2])<<16; case 2 : a+=((uint32_t)k[1])<<8; case 1 : a+=k[0]; break; case 0 : return c; /* zero length strings require no mixing */ default: abort(); } } final(a,b,c); return c; /* zero length strings require no mixing */ } #elif HASH_BIG_ENDIAN == 1 /* * hashbig(): * This is the same as hashword() on big-endian machines. It is different * from hashlittle() on all machines. hashbig() takes advantage of * big-endian byte ordering. */ uint32_t hash( const void *key, size_t length, const uint32_t initval) { uint32_t a,b,c; union { const void *ptr; size_t i; } u; /* to cast key to (size_t) happily */ /* Set up the internal state */ a = b = c = 0xdeadbeef + ((uint32_t)length) + initval; u.ptr = key; if (HASH_BIG_ENDIAN && ((u.i & 0x3) == 0)) { const uint32_t *k = key; /* read 32-bit chunks */ #ifdef VALGRIND const uint8_t *k8; #endif /* ifdef VALGRIND */ /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */ while (length > 12) { a += k[0]; b += k[1]; c += k[2]; mix(a,b,c); length -= 12; k += 3; } /*----------------------------- handle the last (probably partial) block */ /* * "k[2]<<8" actually reads beyond the end of the string, but * then shifts out the part it's not allowed to read. Because the * string is aligned, the illegal read is in the same word as the * rest of the string. Every machine with memory protection I've seen * does it on word boundaries, so is OK with this. But VALGRIND will * still catch it and complain. The masking trick does make the hash * noticably faster for short strings (like English words). */ #ifndef VALGRIND switch(length) { case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; case 11: c+=k[2]&0xffffff00; b+=k[1]; a+=k[0]; break; case 10: c+=k[2]&0xffff0000; b+=k[1]; a+=k[0]; break; case 9 : c+=k[2]&0xff000000; b+=k[1]; a+=k[0]; break; case 8 : b+=k[1]; a+=k[0]; break; case 7 : b+=k[1]&0xffffff00; a+=k[0]; break; case 6 : b+=k[1]&0xffff0000; a+=k[0]; break; case 5 : b+=k[1]&0xff000000; a+=k[0]; break; case 4 : a+=k[0]; break; case 3 : a+=k[0]&0xffffff00; break; case 2 : a+=k[0]&0xffff0000; break; case 1 : a+=k[0]&0xff000000; break; case 0 : return c; /* zero length strings require no mixing */ } #else /* make valgrind happy */ k8 = (const uint8_t *)k; switch(length) /* all the case statements fall through */ { case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; case 11: c+=((uint32_t)k8[10])<<8; /* fall through */ case 10: c+=((uint32_t)k8[9])<<16; /* fall through */ case 9 : c+=((uint32_t)k8[8])<<24; /* fall through */ case 8 : b+=k[1]; a+=k[0]; break; case 7 : b+=((uint32_t)k8[6])<<8; /* fall through */ case 6 : b+=((uint32_t)k8[5])<<16; /* fall through */ case 5 : b+=((uint32_t)k8[4])<<24; /* fall through */ case 4 : a+=k[0]; break; case 3 : a+=((uint32_t)k8[2])<<8; /* fall through */ case 2 : a+=((uint32_t)k8[1])<<16; /* fall through */ case 1 : a+=((uint32_t)k8[0])<<24; break; case 0 : return c; } #endif /* !VALGRIND */ } else { /* need to read the key one byte at a time */ const uint8_t *k = key; /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ while (length > 12) { a += ((uint32_t)k[0])<<24; a += ((uint32_t)k[1])<<16; a += ((uint32_t)k[2])<<8; a += ((uint32_t)k[3]); b += ((uint32_t)k[4])<<24; b += ((uint32_t)k[5])<<16; b += ((uint32_t)k[6])<<8; b += ((uint32_t)k[7]); c += ((uint32_t)k[8])<<24; c += ((uint32_t)k[9])<<16; c += ((uint32_t)k[10])<<8; c += ((uint32_t)k[11]); mix(a,b,c); length -= 12; k += 12; } /*-------------------------------- last block: affect all 32 bits of (c) */ switch(length) /* all the case statements fall through */ { case 12: c+=k[11]; case 11: c+=((uint32_t)k[10])<<8; case 10: c+=((uint32_t)k[9])<<16; case 9 : c+=((uint32_t)k[8])<<24; case 8 : b+=k[7]; case 7 : b+=((uint32_t)k[6])<<8; case 6 : b+=((uint32_t)k[5])<<16; case 5 : b+=((uint32_t)k[4])<<24; case 4 : a+=k[3]; case 3 : a+=((uint32_t)k[2])<<8; case 2 : a+=((uint32_t)k[1])<<16; case 1 : a+=((uint32_t)k[0])<<24; break; case 0 : return c; } } final(a,b,c); return c; } #else /* HASH_XXX_ENDIAN == 1 */ #error Must define HASH_BIG_ENDIAN or HASH_LITTLE_ENDIAN #endif /* HASH_XXX_ENDIAN == 1 */ libmemcached-1.0.8/memcached/daemon.c0000664000076400007640000000601211753573717017733 0ustar00brianbrian00000000000000/* $Header: /cvsroot/wikipedia/willow/src/bin/willow/daemon.c,v 1.1 2005/05/02 19:15:21 kateturner Exp $ */ /* $NetBSD: daemon.c,v 1.9 2003/08/07 16:42:46 agc Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. */ #if defined __SUNPRO_C || defined __DECC || defined __HP_cc # pragma ident "@(#)$Header: /cvsroot/wikipedia/willow/src/bin/willow/daemon.c,v 1.1 2005/05/02 19:15:21 kateturner Exp $" # pragma ident "$NetBSD: daemon.c,v 1.9 2003/08/07 16:42:46 agc Exp $" #endif #include "memcached.h" #include #include #include #include int daemonize(int nochdir, int noclose) { int fd; switch (fork()) { case -1: return (-1); case 0: break; default: _exit(EXIT_SUCCESS); } if (setsid() == -1) return (-1); if (nochdir == 0) { if(chdir("/") != 0) { perror("chdir"); return (-1); } } if (noclose == 0 && (fd = open("/dev/null", O_RDWR, 0)) != -1) { if(dup2(fd, STDIN_FILENO) < 0) { perror("dup2 stdin"); return (-1); } if(dup2(fd, STDOUT_FILENO) < 0) { perror("dup2 stdout"); return (-1); } if(dup2(fd, STDERR_FILENO) < 0) { perror("dup2 stderr"); return (-1); } if (fd > STDERR_FILENO) { if(close(fd) < 0) { perror("close"); return (-1); } } } return (0); } libmemcached-1.0.8/memcached/thread.c0000664000076400007640000005012211753573717017740 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Thread management for memcached. */ #include "memcached.h" #include #include #include #include #include #include #include #ifdef __sun #include #endif #define ITEMS_PER_ALLOC 64 /* An item in the connection queue. */ typedef struct conn_queue_item CQ_ITEM; struct conn_queue_item { int sfd; enum conn_states init_state; int event_flags; int read_buffer_size; enum network_transport transport; CQ_ITEM *next; }; /* A connection queue. */ typedef struct conn_queue CQ; struct conn_queue { CQ_ITEM *head; CQ_ITEM *tail; pthread_mutex_t lock; pthread_cond_t cond; }; /* Lock for cache operations (item_*, assoc_*) */ pthread_mutex_t cache_lock; /* Connection lock around accepting new connections */ pthread_mutex_t conn_lock = PTHREAD_MUTEX_INITIALIZER; #if !defined(HAVE_GCC_ATOMICS) && !defined(__sun) pthread_mutex_t atomics_mutex = PTHREAD_MUTEX_INITIALIZER; #endif /* Lock for global stats */ static pthread_mutex_t stats_lock; /* Free list of CQ_ITEM structs */ static CQ_ITEM *cqi_freelist; static pthread_mutex_t cqi_freelist_lock; static pthread_mutex_t *item_locks; /* size of the item lock hash table */ static uint32_t item_lock_count; /* size - 1 for lookup masking */ static uint32_t item_lock_mask; static LIBEVENT_DISPATCHER_THREAD dispatcher_thread; /* * Each libevent instance has a wakeup pipe, which other threads * can use to signal that they've put a new connection on its queue. */ static LIBEVENT_THREAD *threads; /* * Number of worker threads that have finished setting themselves up. */ static int init_count = 0; static pthread_mutex_t init_lock; static pthread_cond_t init_cond; static void thread_libevent_process(int fd, short which, void *arg); unsigned short refcount_incr(unsigned short *refcount) { #ifdef HAVE_GCC_ATOMICS return __sync_add_and_fetch(refcount, 1); #elif defined(__sun) return atomic_inc_ushort_nv(refcount); #else unsigned short res; mutex_lock(&atomics_mutex); (*refcount)++; res = *refcount; pthread_mutex_unlock(&atomics_mutex); return res; #endif } unsigned short refcount_decr(unsigned short *refcount) { #ifdef HAVE_GCC_ATOMICS return __sync_sub_and_fetch(refcount, 1); #elif defined(__sun) return atomic_dec_ushort_nv(refcount); #else unsigned short res; mutex_lock(&atomics_mutex); (*refcount)--; res = *refcount; pthread_mutex_unlock(&atomics_mutex); return res; #endif } void item_lock(uint32_t hv) { mutex_lock(&item_locks[hv & item_lock_mask]); } void item_unlock(uint32_t hv) { pthread_mutex_unlock(&item_locks[hv & item_lock_mask]); } /* * Initializes a connection queue. */ static void cq_init(CQ *cq) { pthread_mutex_init(&cq->lock, NULL); pthread_cond_init(&cq->cond, NULL); cq->head = NULL; cq->tail = NULL; } /* * Looks for an item on a connection queue, but doesn't block if there isn't * one. * Returns the item, or NULL if no item is available */ static CQ_ITEM *cq_pop(CQ *cq) { CQ_ITEM *item; pthread_mutex_lock(&cq->lock); item = cq->head; if (NULL != item) { cq->head = item->next; if (NULL == cq->head) cq->tail = NULL; } pthread_mutex_unlock(&cq->lock); return item; } /* * Adds an item to a connection queue. */ static void cq_push(CQ *cq, CQ_ITEM *item) { item->next = NULL; pthread_mutex_lock(&cq->lock); if (NULL == cq->tail) cq->head = item; else cq->tail->next = item; cq->tail = item; pthread_cond_signal(&cq->cond); pthread_mutex_unlock(&cq->lock); } /* * Returns a fresh connection queue item. */ static CQ_ITEM *cqi_new(void) { CQ_ITEM *item = NULL; pthread_mutex_lock(&cqi_freelist_lock); if (cqi_freelist) { item = cqi_freelist; cqi_freelist = item->next; } pthread_mutex_unlock(&cqi_freelist_lock); if (NULL == item) { int i; /* Allocate a bunch of items at once to reduce fragmentation */ item = malloc(sizeof(CQ_ITEM) * ITEMS_PER_ALLOC); if (NULL == item) return NULL; /* * Link together all the new items except the first one * (which we'll return to the caller) for placement on * the freelist. */ for (i = 2; i < ITEMS_PER_ALLOC; i++) item[i - 1].next = &item[i]; pthread_mutex_lock(&cqi_freelist_lock); item[ITEMS_PER_ALLOC - 1].next = cqi_freelist; cqi_freelist = &item[1]; pthread_mutex_unlock(&cqi_freelist_lock); } return item; } /* * Frees a connection queue item (adds it to the freelist.) */ static void cqi_free(CQ_ITEM *item) { pthread_mutex_lock(&cqi_freelist_lock); item->next = cqi_freelist; cqi_freelist = item; pthread_mutex_unlock(&cqi_freelist_lock); } /* * Creates a worker thread. */ static void create_worker(void *(*func)(void *), void *arg) { pthread_t thread; pthread_attr_t attr; int ret; pthread_attr_init(&attr); if ((ret = pthread_create(&thread, &attr, func, arg)) != 0) { fprintf(stderr, "Can't create thread: %s\n", strerror(ret)); exit(1); } } /* * Sets whether or not we accept new connections. */ void accept_new_conns(const bool do_accept) { pthread_mutex_lock(&conn_lock); do_accept_new_conns(do_accept); pthread_mutex_unlock(&conn_lock); } /****************************** LIBEVENT THREADS *****************************/ /* * Set up a thread's information. */ static void setup_thread(LIBEVENT_THREAD *me) { me->base = event_init(); if (! me->base) { fprintf(stderr, "Can't allocate event base\n"); exit(1); } /* Listen for notifications from other threads */ event_set(&me->notify_event, me->notify_receive_fd, EV_READ | EV_PERSIST, thread_libevent_process, me); event_base_set(me->base, &me->notify_event); if (event_add(&me->notify_event, 0) == -1) { fprintf(stderr, "Can't monitor libevent notify pipe\n"); exit(1); } me->new_conn_queue = malloc(sizeof(struct conn_queue)); if (me->new_conn_queue == NULL) { perror("Failed to allocate memory for connection queue"); exit(EXIT_FAILURE); } cq_init(me->new_conn_queue); if (pthread_mutex_init(&me->stats.mutex, NULL) != 0) { perror("Failed to initialize mutex"); exit(EXIT_FAILURE); } me->suffix_cache = cache_create("suffix", SUFFIX_SIZE, sizeof(char*), NULL, NULL); if (me->suffix_cache == NULL) { fprintf(stderr, "Failed to create suffix cache\n"); exit(EXIT_FAILURE); } } /* * Worker thread: main event loop */ static void *worker_libevent(void *arg) { LIBEVENT_THREAD *me = arg; /* Any per-thread setup can happen here; thread_init() will block until * all threads have finished initializing. */ pthread_mutex_lock(&init_lock); init_count++; pthread_cond_signal(&init_cond); pthread_mutex_unlock(&init_lock); event_base_loop(me->base, 0); return NULL; } #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wunused-parameter" #endif /* * Processes an incoming "handle a new connection" item. This is called when * input arrives on the libevent wakeup pipe. */ static void thread_libevent_process(int fd, short which, void *arg) { LIBEVENT_THREAD *me = arg; CQ_ITEM *item; char buf[1]; if (read(fd, buf, 1) != 1) if (settings.verbose > 0) fprintf(stderr, "Can't read from libevent pipe\n"); item = cq_pop(me->new_conn_queue); if (NULL != item) { conn *c = conn_new(item->sfd, item->init_state, item->event_flags, item->read_buffer_size, item->transport, me->base); if (c == NULL) { if (IS_UDP(item->transport)) { fprintf(stderr, "Can't listen for events on UDP socket\n"); exit(1); } else { if (settings.verbose > 0) { fprintf(stderr, "Can't listen for events on fd %d\n", item->sfd); } close(item->sfd); } } else { c->thread = me; } cqi_free(item); } } /* Which thread we assigned a connection to most recently. */ static int last_thread = -1; /* * Dispatches a new connection to another thread. This is only ever called * from the main thread, either during initialization (for UDP) or because * of an incoming connection. */ void dispatch_conn_new(int sfd, enum conn_states init_state, int event_flags, int read_buffer_size, enum network_transport transport) { CQ_ITEM *item = cqi_new(); int tid = (last_thread + 1) % settings.num_threads; LIBEVENT_THREAD *thread = threads + tid; last_thread = tid; item->sfd = sfd; item->init_state = init_state; item->event_flags = event_flags; item->read_buffer_size = read_buffer_size; item->transport = transport; cq_push(thread->new_conn_queue, item); MEMCACHED_CONN_DISPATCH(sfd, thread->thread_id); if (write(thread->notify_send_fd, "", 1) != 1) { perror("Writing to thread notify pipe"); } } /* * Returns true if this is the thread that listens for new TCP connections. */ int is_listen_thread() { return pthread_self() == dispatcher_thread.thread_id; } /********************************* ITEM ACCESS *******************************/ /* * Allocates a new item. */ item *item_alloc(char *key, size_t nkey, int flags, rel_time_t exptime, int nbytes) { item *it; /* do_item_alloc handles its own locks */ it = do_item_alloc(key, nkey, flags, exptime, nbytes); return it; } /* * Returns an item if it hasn't been marked as expired, * lazy-expiring as needed. */ item *item_get(const char *key, const size_t nkey) { item *it; uint32_t hv; hv = hash(key, nkey, 0); item_lock(hv); it = do_item_get(key, nkey, hv); item_unlock(hv); return it; } item *item_touch(const char *key, size_t nkey, uint32_t exptime) { item *it; uint32_t hv; hv = hash(key, nkey, 0); item_lock(hv); it = do_item_touch(key, nkey, exptime, hv); item_unlock(hv); return it; } /* * Links an item into the LRU and hashtable. */ int item_link(item *item) { int ret; uint32_t hv; hv = hash(ITEM_key(item), item->nkey, 0); item_lock(hv); ret = do_item_link(item, hv); item_unlock(hv); return ret; } /* * Decrements the reference count on an item and adds it to the freelist if * needed. */ void item_remove(item *item) { uint32_t hv; hv = hash(ITEM_key(item), item->nkey, 0); item_lock(hv); do_item_remove(item); item_unlock(hv); } /* * Replaces one item with another in the hashtable. * Unprotected by a mutex lock since the core server does not require * it to be thread-safe. */ int item_replace(item *old_it, item *new_it, const uint32_t hv) { return do_item_replace(old_it, new_it, hv); } /* * Unlinks an item from the LRU and hashtable. */ void item_unlink(item *item) { uint32_t hv; hv = hash(ITEM_key(item), item->nkey, 0); item_lock(hv); do_item_unlink(item, hv); item_unlock(hv); } /* * Moves an item to the back of the LRU queue. */ void item_update(item *item) { uint32_t hv; hv = hash(ITEM_key(item), item->nkey, 0); item_lock(hv); do_item_update(item); item_unlock(hv); } /* * Does arithmetic on a numeric item value. */ enum delta_result_type add_delta(conn *c, const char *key, const size_t nkey, int incr, const int64_t delta, char *buf, uint64_t *cas) { enum delta_result_type ret; uint32_t hv; hv = hash(key, nkey, 0); item_lock(hv); ret = do_add_delta(c, key, nkey, incr, delta, buf, cas, hv); item_unlock(hv); return ret; } /* * Stores an item in the cache (high level, obeys set/add/replace semantics) */ enum store_item_type store_item(item *item, int comm, conn* c) { enum store_item_type ret; uint32_t hv; hv = hash(ITEM_key(item), item->nkey, 0); item_lock(hv); ret = do_store_item(item, comm, c, hv); item_unlock(hv); return ret; } /* * Flushes expired items after a flush_all call */ void item_flush_expired() { mutex_lock(&cache_lock); do_item_flush_expired(); pthread_mutex_unlock(&cache_lock); } /* * Dumps part of the cache */ char *item_cachedump(unsigned int slabs_clsid, unsigned int limit, unsigned int *bytes) { char *ret; mutex_lock(&cache_lock); ret = do_item_cachedump(slabs_clsid, limit, bytes); pthread_mutex_unlock(&cache_lock); return ret; } /* * Dumps statistics about slab classes */ void item_stats(ADD_STAT add_stats, void *c) { mutex_lock(&cache_lock); do_item_stats(add_stats, c); pthread_mutex_unlock(&cache_lock); } /* * Dumps a list of objects of each size in 32-byte increments */ void item_stats_sizes(ADD_STAT add_stats, void *c) { mutex_lock(&cache_lock); do_item_stats_sizes(add_stats, c); pthread_mutex_unlock(&cache_lock); } /******************************* GLOBAL STATS ******************************/ void STATS_LOCK() { pthread_mutex_lock(&stats_lock); } void STATS_UNLOCK() { pthread_mutex_unlock(&stats_lock); } void threadlocal_stats_reset(void) { int ii, sid; for (ii = 0; ii < settings.num_threads; ++ii) { pthread_mutex_lock(&threads[ii].stats.mutex); threads[ii].stats.get_cmds = 0; threads[ii].stats.get_misses = 0; threads[ii].stats.touch_cmds = 0; threads[ii].stats.touch_misses = 0; threads[ii].stats.delete_misses = 0; threads[ii].stats.incr_misses = 0; threads[ii].stats.decr_misses = 0; threads[ii].stats.cas_misses = 0; threads[ii].stats.bytes_read = 0; threads[ii].stats.bytes_written = 0; threads[ii].stats.flush_cmds = 0; threads[ii].stats.conn_yields = 0; threads[ii].stats.auth_cmds = 0; threads[ii].stats.auth_errors = 0; for(sid = 0; sid < MAX_NUMBER_OF_SLAB_CLASSES; sid++) { threads[ii].stats.slab_stats[sid].set_cmds = 0; threads[ii].stats.slab_stats[sid].get_hits = 0; threads[ii].stats.slab_stats[sid].touch_hits = 0; threads[ii].stats.slab_stats[sid].delete_hits = 0; threads[ii].stats.slab_stats[sid].incr_hits = 0; threads[ii].stats.slab_stats[sid].decr_hits = 0; threads[ii].stats.slab_stats[sid].cas_hits = 0; threads[ii].stats.slab_stats[sid].cas_badval = 0; } pthread_mutex_unlock(&threads[ii].stats.mutex); } } void threadlocal_stats_aggregate(struct thread_stats *stats) { int ii, sid; /* The struct has a mutex, but we can safely set the whole thing * to zero since it is unused when aggregating. */ memset(stats, 0, sizeof(*stats)); for (ii = 0; ii < settings.num_threads; ++ii) { pthread_mutex_lock(&threads[ii].stats.mutex); stats->get_cmds += threads[ii].stats.get_cmds; stats->get_misses += threads[ii].stats.get_misses; stats->touch_cmds += threads[ii].stats.touch_cmds; stats->touch_misses += threads[ii].stats.touch_misses; stats->delete_misses += threads[ii].stats.delete_misses; stats->decr_misses += threads[ii].stats.decr_misses; stats->incr_misses += threads[ii].stats.incr_misses; stats->cas_misses += threads[ii].stats.cas_misses; stats->bytes_read += threads[ii].stats.bytes_read; stats->bytes_written += threads[ii].stats.bytes_written; stats->flush_cmds += threads[ii].stats.flush_cmds; stats->conn_yields += threads[ii].stats.conn_yields; stats->auth_cmds += threads[ii].stats.auth_cmds; stats->auth_errors += threads[ii].stats.auth_errors; for (sid = 0; sid < MAX_NUMBER_OF_SLAB_CLASSES; sid++) { stats->slab_stats[sid].set_cmds += threads[ii].stats.slab_stats[sid].set_cmds; stats->slab_stats[sid].get_hits += threads[ii].stats.slab_stats[sid].get_hits; stats->slab_stats[sid].touch_hits += threads[ii].stats.slab_stats[sid].touch_hits; stats->slab_stats[sid].delete_hits += threads[ii].stats.slab_stats[sid].delete_hits; stats->slab_stats[sid].decr_hits += threads[ii].stats.slab_stats[sid].decr_hits; stats->slab_stats[sid].incr_hits += threads[ii].stats.slab_stats[sid].incr_hits; stats->slab_stats[sid].cas_hits += threads[ii].stats.slab_stats[sid].cas_hits; stats->slab_stats[sid].cas_badval += threads[ii].stats.slab_stats[sid].cas_badval; } pthread_mutex_unlock(&threads[ii].stats.mutex); } } void slab_stats_aggregate(struct thread_stats *stats, struct slab_stats *out) { int sid; out->set_cmds = 0; out->get_hits = 0; out->touch_hits = 0; out->delete_hits = 0; out->incr_hits = 0; out->decr_hits = 0; out->cas_hits = 0; out->cas_badval = 0; for (sid = 0; sid < MAX_NUMBER_OF_SLAB_CLASSES; sid++) { out->set_cmds += stats->slab_stats[sid].set_cmds; out->get_hits += stats->slab_stats[sid].get_hits; out->touch_hits += stats->slab_stats[sid].touch_hits; out->delete_hits += stats->slab_stats[sid].delete_hits; out->decr_hits += stats->slab_stats[sid].decr_hits; out->incr_hits += stats->slab_stats[sid].incr_hits; out->cas_hits += stats->slab_stats[sid].cas_hits; out->cas_badval += stats->slab_stats[sid].cas_badval; } } #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wsign-compare" #endif /* * Initializes the thread subsystem, creating various worker threads. * * nthreads Number of worker event handler threads to spawn * main_base Event base for main thread */ void thread_init(int nthreads, struct event_base *main_base) { int i; int power; pthread_mutex_init(&cache_lock, NULL); pthread_mutex_init(&stats_lock, NULL); pthread_mutex_init(&init_lock, NULL); pthread_cond_init(&init_cond, NULL); pthread_mutex_init(&cqi_freelist_lock, NULL); cqi_freelist = NULL; /* Want a wide lock table, but don't waste memory */ if (nthreads < 3) { power = 10; } else if (nthreads < 4) { power = 11; } else if (nthreads < 5) { power = 12; } else { /* 8192 buckets, and central locks don't scale much past 5 threads */ power = 13; } item_lock_count = ((unsigned long int)1 << (power)); item_lock_mask = item_lock_count - 1; item_locks = calloc(item_lock_count, sizeof(pthread_mutex_t)); if (! item_locks) { perror("Can't allocate item locks"); exit(1); } for (i = 0; i < item_lock_count; i++) { pthread_mutex_init(&item_locks[i], NULL); } threads = calloc(nthreads, sizeof(LIBEVENT_THREAD)); if (! threads) { perror("Can't allocate thread descriptors"); exit(1); } dispatcher_thread.base = main_base; dispatcher_thread.thread_id = pthread_self(); for (i = 0; i < nthreads; i++) { int fds[2]; if (pipe(fds)) { perror("Can't create notify pipe"); exit(1); } threads[i].notify_receive_fd = fds[0]; threads[i].notify_send_fd = fds[1]; setup_thread(&threads[i]); /* Reserve three fds for the libevent base, and two for the pipe */ stats.reserved_fds += 5; } /* Create threads after we've done all the libevent setup. */ for (i = 0; i < nthreads; i++) { create_worker(worker_libevent, &threads[i]); } /* Wait for all the threads to set themselves up before returning. */ pthread_mutex_lock(&init_lock); while (init_count < nthreads) { pthread_cond_wait(&init_cond, &init_lock); } pthread_mutex_unlock(&init_lock); } libmemcached-1.0.8/memcached/trace.h0000664000076400007640000000615311753573717017601 0ustar00brianbrian00000000000000#ifndef TRACE_H #define TRACE_H #ifdef ENABLE_DTRACE #include "memcached_dtrace.h" #else #define MEMCACHED_ASSOC_DELETE(arg0, arg1, arg2) #define MEMCACHED_ASSOC_DELETE_ENABLED() (0) #define MEMCACHED_ASSOC_FIND(arg0, arg1, arg2) #define MEMCACHED_ASSOC_FIND_ENABLED() (0) #define MEMCACHED_ASSOC_INSERT(arg0, arg1, arg2) #define MEMCACHED_ASSOC_INSERT_ENABLED() (0) #define MEMCACHED_COMMAND_ADD(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_ADD_ENABLED() (0) #define MEMCACHED_COMMAND_APPEND(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_APPEND_ENABLED() (0) #define MEMCACHED_COMMAND_CAS(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_CAS_ENABLED() (0) #define MEMCACHED_COMMAND_DECR(arg0, arg1, arg2, arg3) #define MEMCACHED_COMMAND_DECR_ENABLED() (0) #define MEMCACHED_COMMAND_DELETE(arg0, arg1, arg2) #define MEMCACHED_COMMAND_DELETE_ENABLED() (0) #define MEMCACHED_COMMAND_GET(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_GET_ENABLED() (0) #define MEMCACHED_COMMAND_TOUCH(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_TOUCH_ENABLED() (0) #define MEMCACHED_COMMAND_INCR(arg0, arg1, arg2, arg3) #define MEMCACHED_COMMAND_INCR_ENABLED() (0) #define MEMCACHED_COMMAND_PREPEND(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_PREPEND_ENABLED() (0) #define MEMCACHED_COMMAND_REPLACE(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_REPLACE_ENABLED() (0) #define MEMCACHED_COMMAND_SET(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_SET_ENABLED() (0) #define MEMCACHED_CONN_ALLOCATE(arg0) #define MEMCACHED_CONN_ALLOCATE_ENABLED() (0) #define MEMCACHED_CONN_CREATE(arg0) #define MEMCACHED_CONN_CREATE_ENABLED() (0) #define MEMCACHED_CONN_DESTROY(arg0) #define MEMCACHED_CONN_DESTROY_ENABLED() (0) #define MEMCACHED_CONN_DISPATCH(arg0, arg1) #define MEMCACHED_CONN_DISPATCH_ENABLED() (0) #define MEMCACHED_CONN_RELEASE(arg0) #define MEMCACHED_CONN_RELEASE_ENABLED() (0) #define MEMCACHED_ITEM_LINK(arg0, arg1, arg2) #define MEMCACHED_ITEM_LINK_ENABLED() (0) #define MEMCACHED_ITEM_REMOVE(arg0, arg1, arg2) #define MEMCACHED_ITEM_REMOVE_ENABLED() (0) #define MEMCACHED_ITEM_REPLACE(arg0, arg1, arg2, arg3, arg4, arg5) #define MEMCACHED_ITEM_REPLACE_ENABLED() (0) #define MEMCACHED_ITEM_UNLINK(arg0, arg1, arg2) #define MEMCACHED_ITEM_UNLINK_ENABLED() (0) #define MEMCACHED_ITEM_UPDATE(arg0, arg1, arg2) #define MEMCACHED_ITEM_UPDATE_ENABLED() (0) #define MEMCACHED_PROCESS_COMMAND_END(arg0, arg1, arg2) #define MEMCACHED_PROCESS_COMMAND_END_ENABLED() (0) #define MEMCACHED_PROCESS_COMMAND_START(arg0, arg1, arg2) #define MEMCACHED_PROCESS_COMMAND_START_ENABLED() (0) #define MEMCACHED_SLABS_ALLOCATE(arg0, arg1, arg2, arg3) #define MEMCACHED_SLABS_ALLOCATE_ENABLED() (0) #define MEMCACHED_SLABS_ALLOCATE_FAILED(arg0, arg1) #define MEMCACHED_SLABS_ALLOCATE_FAILED_ENABLED() (0) #define MEMCACHED_SLABS_FREE(arg0, arg1, arg2) #define MEMCACHED_SLABS_FREE_ENABLED() (0) #define MEMCACHED_SLABS_SLABCLASS_ALLOCATE(arg0) #define MEMCACHED_SLABS_SLABCLASS_ALLOCATE_ENABLED() (0) #define MEMCACHED_SLABS_SLABCLASS_ALLOCATE_FAILED(arg0) #define MEMCACHED_SLABS_SLABCLASS_ALLOCATE_FAILED_ENABLED() (0) #endif #endif libmemcached-1.0.8/memcached/memcached.h0000664000076400007640000004534011753573717020412 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /** \file * The main memcached header holding commonly used data * structures and function prototypes. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include "protocol_binary.h" #include "cache.h" #include "sasl_defs.h" /** Maximum length of a key. */ #define KEY_MAX_LENGTH 250 /** Size of an incr buf. */ #define INCR_MAX_STORAGE_LEN 24 #define DATA_BUFFER_SIZE 2048 #define UDP_READ_BUFFER_SIZE 65536 #define UDP_MAX_PAYLOAD_SIZE 1400 #define UDP_HEADER_SIZE 8 #define MAX_SENDBUF_SIZE (256 * 1024 * 1024) /* I'm told the max length of a 64-bit num converted to string is 20 bytes. * Plus a few for spaces, \r\n, \0 */ #define SUFFIX_SIZE 24 /** Initial size of list of items being returned by "get". */ #define ITEM_LIST_INITIAL 200 /** Initial size of list of CAS suffixes appended to "gets" lines. */ #define SUFFIX_LIST_INITIAL 20 /** Initial size of the sendmsg() scatter/gather array. */ #define IOV_LIST_INITIAL 400 /** Initial number of sendmsg() argument structures to allocate. */ #define MSG_LIST_INITIAL 10 /** High water marks for buffer shrinking */ #define READ_BUFFER_HIGHWAT 8192 #define ITEM_LIST_HIGHWAT 400 #define IOV_LIST_HIGHWAT 600 #define MSG_LIST_HIGHWAT 100 /* Binary protocol stuff */ #define MIN_BIN_PKT_LENGTH 16 #define BIN_PKT_HDR_WORDS (MIN_BIN_PKT_LENGTH/sizeof(uint32_t)) /* Initial power multiplier for the hash table */ #define HASHPOWER_DEFAULT 16 /* unistd.h is here */ #if HAVE_UNISTD_H # include #endif /* Slab sizing definitions. */ #define POWER_SMALLEST 1 #define POWER_LARGEST 200 #define CHUNK_ALIGN_BYTES 8 #define DONT_PREALLOC_SLABS #define MAX_NUMBER_OF_SLAB_CLASSES (POWER_LARGEST + 1) /** How long an object can reasonably be assumed to be locked before harvesting it on a low memory condition. */ #define TAIL_REPAIR_TIME (3 * 3600) /* warning: don't use these macros with a function, as it evals its arg twice */ #define ITEM_get_cas(i) (((i)->it_flags & ITEM_CAS) ? \ (i)->data->cas : (uint64_t)0) #define ITEM_set_cas(i,v) { \ if ((i)->it_flags & ITEM_CAS) { \ (i)->data->cas = v; \ } \ } #define ITEM_key(item) (((char*)&((item)->data)) \ + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0)) #define ITEM_suffix(item) ((char*) &((item)->data) + (item)->nkey + 1 \ + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0)) #define ITEM_data(item) ((char*) &((item)->data) + (item)->nkey + 1 \ + (item)->nsuffix \ + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0)) #define ITEM_ntotal(item) (sizeof(struct _stritem) + (item)->nkey + 1 \ + (item)->nsuffix + (item)->nbytes \ + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0)) #define STAT_KEY_LEN 128 #define STAT_VAL_LEN 128 /** Append a simple stat with a stat name, value format and value */ #define APPEND_STAT(name, fmt, val) \ append_stat(name, add_stats, c, fmt, val); /** Append an indexed stat with a stat name (with format), value format and value */ #define APPEND_NUM_FMT_STAT(name_fmt, num, name, fmt, val) \ klen = snprintf(key_str, STAT_KEY_LEN, name_fmt, num, name); \ vlen = snprintf(val_str, STAT_VAL_LEN, fmt, val); \ add_stats(key_str, klen, val_str, vlen, c); /** Common APPEND_NUM_FMT_STAT format. */ #define APPEND_NUM_STAT(num, name, fmt, val) \ APPEND_NUM_FMT_STAT("%d:%s", num, name, fmt, val) /** * Callback for any function producing stats. * * @param key the stat's key * @param klen length of the key * @param val the stat's value in an ascii form (e.g. text form of a number) * @param vlen length of the value * @parm cookie magic callback cookie */ typedef void (*ADD_STAT)(const char *key, const uint16_t klen, const char *val, const uint32_t vlen, const void *cookie); /* * NOTE: If you modify this table you _MUST_ update the function state_text */ /** * Possible states of a connection. */ enum conn_states { conn_listening, /**< the socket which listens for connections */ conn_new_cmd, /**< Prepare connection for next command */ conn_waiting, /**< waiting for a readable socket */ conn_read, /**< reading in a command line */ conn_parse_cmd, /**< try to parse a command from the input buffer */ conn_write, /**< writing out a simple response */ conn_nread, /**< reading in a fixed number of bytes */ conn_swallow, /**< swallowing unnecessary bytes w/o storing */ conn_closing, /**< closing this connection */ conn_mwrite, /**< writing out many items sequentially */ conn_max_state /**< Max state value (used for assertion) */ }; enum bin_substates { bin_no_state, bin_reading_set_header, bin_reading_cas_header, bin_read_set_value, bin_reading_get_key, bin_reading_stat, bin_reading_del_header, bin_reading_incr_header, bin_read_flush_exptime, bin_reading_sasl_auth, bin_reading_sasl_auth_data, bin_reading_touch_key, }; enum protocol { ascii_prot = 3, /* arbitrary value. */ binary_prot, negotiating_prot /* Discovering the protocol */ }; enum network_transport { local_transport, /* Unix sockets*/ tcp_transport, udp_transport }; #define IS_UDP(x) (x == udp_transport) #define NREAD_ADD 1 #define NREAD_SET 2 #define NREAD_REPLACE 3 #define NREAD_APPEND 4 #define NREAD_PREPEND 5 #define NREAD_CAS 6 enum store_item_type { NOT_STORED=0, STORED, EXISTS, NOT_FOUND }; enum delta_result_type { OK, NON_NUMERIC, EOM, DELTA_ITEM_NOT_FOUND, DELTA_ITEM_CAS_MISMATCH }; /** Time relative to server start. Smaller than time_t on 64-bit systems. */ typedef unsigned int rel_time_t; /** Stats stored per slab (and per thread). */ struct slab_stats { uint64_t set_cmds; uint64_t get_hits; uint64_t touch_hits; uint64_t delete_hits; uint64_t cas_hits; uint64_t cas_badval; uint64_t incr_hits; uint64_t decr_hits; }; /** * Stats stored per-thread. */ struct thread_stats { pthread_mutex_t mutex; uint64_t get_cmds; uint64_t get_misses; uint64_t touch_cmds; uint64_t touch_misses; uint64_t delete_misses; uint64_t incr_misses; uint64_t decr_misses; uint64_t cas_misses; uint64_t bytes_read; uint64_t bytes_written; uint64_t flush_cmds; uint64_t conn_yields; /* # of yields for connections (-R option)*/ uint64_t auth_cmds; uint64_t auth_errors; struct slab_stats slab_stats[MAX_NUMBER_OF_SLAB_CLASSES]; }; /** * Global stats. */ struct stats { pthread_mutex_t mutex; unsigned int curr_items; unsigned int total_items; uint64_t curr_bytes; unsigned int curr_conns; unsigned int total_conns; uint64_t rejected_conns; unsigned int reserved_fds; unsigned int conn_structs; uint64_t get_cmds; uint64_t set_cmds; uint64_t touch_cmds; uint64_t get_hits; uint64_t get_misses; uint64_t touch_hits; uint64_t touch_misses; uint64_t evictions; uint64_t reclaimed; time_t started; /* when the process was started */ bool accepting_conns; /* whether we are currently accepting */ uint64_t listen_disabled_num; unsigned int hash_power_level; /* Better hope it's not over 9000 */ uint64_t hash_bytes; /* size used for hash tables */ bool hash_is_expanding; /* If the hash table is being expanded */ uint64_t expired_unfetched; /* items reclaimed but never touched */ uint64_t evicted_unfetched; /* items evicted but never touched */ bool slab_reassign_running; /* slab reassign in progress */ uint64_t slabs_moved; /* times slabs were moved around */ }; #define MAX_VERBOSITY_LEVEL 2 /* When adding a setting, be sure to update process_stat_settings */ /** * Globally accessible settings as derived from the commandline. */ struct settings { size_t maxbytes; int maxconns; int port; int udpport; char *inter; int verbose; rel_time_t oldest_live; /* ignore existing items older than this */ int evict_to_free; char *socketpath; /* path to unix socket if using local socket */ int access; /* access mask (a la chmod) for unix domain socket */ double factor; /* chunk size growth factor */ int chunk_size; int num_threads; /* number of worker (without dispatcher) libevent threads to run */ int num_threads_per_udp; /* number of worker threads serving each udp socket */ char prefix_delimiter; /* character that marks a key prefix (for stats) */ int detail_enabled; /* nonzero if we're collecting detailed stats */ int reqs_per_event; /* Maximum number of io to process on each io-event. */ bool use_cas; enum protocol binding_protocol; int backlog; int item_size_max; /* Maximum item size, and upper end for slabs */ bool sasl; /* SASL on/off */ bool maxconns_fast; /* Whether or not to early close connections */ bool slab_reassign; /* Whether or not slab reassignment is allowed */ bool slab_automove; /* Whether or not to automatically move slabs */ int hashpower_init; /* Starting hash power level */ }; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wshadow" #endif extern struct stats stats; extern time_t process_started; extern struct settings settings; #define ITEM_LINKED 1 #define ITEM_CAS 2 /* temp */ #define ITEM_SLABBED 4 #define ITEM_FETCHED 8 #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wshadow" #endif /** * Structure for storing items within memcached. */ typedef struct _stritem { struct _stritem *next; struct _stritem *prev; struct _stritem *h_next; /* hash chain next */ rel_time_t time; /* least recent access */ rel_time_t exptime; /* expire time */ int nbytes; /* size of data */ unsigned short refcount; uint8_t nsuffix; /* length of flags-and-length string */ uint8_t it_flags; /* ITEM_* above */ uint8_t slabs_clsid;/* which slab class we're in */ uint8_t nkey; /* key length, w/terminating null and padding */ /* this odd type prevents type-punning issues when we do * the little shuffle to save space when not using CAS. */ union { uint64_t cas; char end; } data[]; /* if it_flags & ITEM_CAS we have 8 bytes CAS */ /* then null-terminated key */ /* then " flags length\r\n" (no terminating null) */ /* then data with terminating \r\n (no terminating null; it's binary!) */ } item; typedef struct { pthread_t thread_id; /* unique ID of this thread */ struct event_base *base; /* libevent handle this thread uses */ struct event notify_event; /* listen event for notify pipe */ int notify_receive_fd; /* receiving end of notify pipe */ int notify_send_fd; /* sending end of notify pipe */ struct thread_stats stats; /* Stats generated by this thread */ struct conn_queue *new_conn_queue; /* queue of new connections to handle */ cache_t *suffix_cache; /* suffix cache */ } LIBEVENT_THREAD; typedef struct { pthread_t thread_id; /* unique ID of this thread */ struct event_base *base; /* libevent handle this thread uses */ } LIBEVENT_DISPATCHER_THREAD; /** * The structure representing a connection into memcached. */ typedef struct conn conn; struct conn { int sfd; sasl_conn_t *sasl_conn; enum conn_states state; enum bin_substates substate; struct event event; short ev_flags; short which; /** which events were just triggered */ char *rbuf; /** buffer to read commands into */ char *rcurr; /** but if we parsed some already, this is where we stopped */ int rsize; /** total allocated size of rbuf */ int rbytes; /** how much data, starting from rcur, do we have unparsed */ char *wbuf; char *wcurr; int wsize; int wbytes; /** which state to go into after finishing current write */ enum conn_states write_and_go; void *write_and_free; /** free this memory after finishing writing */ char *ritem; /** when we read in an item's value, it goes here */ int rlbytes; /* data for the nread state */ /** * item is used to hold an item structure created after reading the command * line of set/add/replace commands, but before we finished reading the actual * data. The data is read into ITEM_data(item) to avoid extra copying. */ void *item; /* for commands set/add/replace */ /* data for the swallow state */ int sbytes; /* how many bytes to swallow */ /* data for the mwrite state */ struct iovec *iov; int iovsize; /* number of elements allocated in iov[] */ int iovused; /* number of elements used in iov[] */ struct msghdr *msglist; int msgsize; /* number of elements allocated in msglist[] */ int msgused; /* number of elements used in msglist[] */ int msgcurr; /* element in msglist[] being transmitted now */ int msgbytes; /* number of bytes in current msg */ item **ilist; /* list of items to write out */ int isize; item **icurr; int ileft; char **suffixlist; int suffixsize; char **suffixcurr; int suffixleft; enum protocol protocol; /* which protocol this connection speaks */ enum network_transport transport; /* what transport is used by this connection */ /* data for UDP clients */ int request_id; /* Incoming UDP request ID, if this is a UDP "connection" */ struct sockaddr request_addr; /* Who sent the most recent request */ socklen_t request_addr_size; unsigned char *hdrbuf; /* udp packet headers */ int hdrsize; /* number of headers' worth of space is allocated */ bool noreply; /* True if the reply should not be sent. */ /* current stats command */ struct { char *buffer; size_t size; size_t offset; } stats; /* Binary protocol stuff */ /* This is where the binary header goes */ protocol_binary_request_header binary_header; uint64_t cas; /* the cas to return */ short cmd; /* current command being processed */ int opaque; int keylen; conn *next; /* Used for generating a list of conn structures */ LIBEVENT_THREAD *thread; /* Pointer to the thread object serving this connection */ }; /* current time of day (updated periodically) */ extern volatile rel_time_t current_time; /* TODO: Move to slabs.h? */ extern volatile int slab_rebalance_signal; struct slab_rebalance { void *slab_start; void *slab_end; void *slab_pos; int s_clsid; int d_clsid; int busy_items; uint8_t done; }; extern struct slab_rebalance slab_rebal; /* * Functions */ void do_accept_new_conns(const bool do_accept); enum delta_result_type do_add_delta(conn *c, const char *key, const size_t nkey, const bool incr, const int64_t delta, char *buf, uint64_t *cas, const uint32_t hv); enum store_item_type do_store_item(item *item, int comm, conn* c, const uint32_t hv); conn *conn_new(const int sfd, const enum conn_states init_state, const int event_flags, const int read_buffer_size, enum network_transport transport, struct event_base *base); extern int daemonize(int nochdir, int noclose); static inline int mutex_lock(pthread_mutex_t *mutex) { while (pthread_mutex_trylock(mutex)); return 0; } #define mutex_unlock(x) pthread_mutex_unlock(x) #include "stats.h" #include "slabs.h" #include "assoc.h" #include "items.h" #include "trace.h" #include "hash.h" #include "util.h" /* * Functions such as the libevent-related calls that need to do cross-thread * communication in multithreaded mode (rather than actually doing the work * in the current thread) are called via "dispatch_" frontends, which are * also #define-d to directly call the underlying code in singlethreaded mode. */ void thread_init(int nthreads, struct event_base *main_base); int dispatch_event_add(int thread, conn *c); void dispatch_conn_new(int sfd, enum conn_states init_state, int event_flags, int read_buffer_size, enum network_transport transport); /* Lock wrappers for cache functions that are called from main loop. */ enum delta_result_type add_delta(conn *c, const char *key, const size_t nkey, const int incr, const int64_t delta, char *buf, uint64_t *cas); void accept_new_conns(const bool do_accept); conn *conn_from_freelist(void); bool conn_add_to_freelist(conn *c); int is_listen_thread(void); item *item_alloc(char *key, size_t nkey, int flags, rel_time_t exptime, int nbytes); char *item_cachedump(const unsigned int slabs_clsid, const unsigned int limit, unsigned int *bytes); void item_flush_expired(void); item *item_get(const char *key, const size_t nkey); item *item_touch(const char *key, const size_t nkey, uint32_t exptime); int item_link(item *it); void item_remove(item *it); int item_replace(item *it, item *new_it, const uint32_t hv); void item_stats(ADD_STAT add_stats, void *c); void item_stats_sizes(ADD_STAT add_stats, void *c); void item_unlink(item *it); void item_update(item *it); void item_lock(uint32_t hv); void item_unlock(uint32_t hv); unsigned short refcount_incr(unsigned short *refcount); unsigned short refcount_decr(unsigned short *refcount); void STATS_LOCK(void); void STATS_UNLOCK(void); void threadlocal_stats_reset(void); void threadlocal_stats_aggregate(struct thread_stats *stats); void slab_stats_aggregate(struct thread_stats *stats, struct slab_stats *out); /* Stat processing functions */ void append_stat(const char *name, ADD_STAT add_stats, conn *c, const char *fmt, ...); enum store_item_type store_item(item *item, int comm, conn *c); #if defined(HAVE_DROP_PRIVILEGES) && HAVE_DROP_PRIVILEGES extern void drop_privileges(void); #else #define drop_privileges() #endif /* If supported, give compiler hints for branch prediction. */ #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) #define __builtin_expect(x, expected_value) (x) #endif #define likely(x) __builtin_expect((x),1) #define unlikely(x) __builtin_expect((x),0) libmemcached-1.0.8/memcached/stats.h0000664000076400007640000000052611753573717017637 0ustar00brianbrian00000000000000/* stats */ void stats_prefix_init(void); void stats_prefix_clear(void); void stats_prefix_record_get(const char *key, const size_t nkey, const bool is_hit); void stats_prefix_record_delete(const char *key, const size_t nkey); void stats_prefix_record_set(const char *key, const size_t nkey); /*@null@*/ char *stats_prefix_dump(int *length); libmemcached-1.0.8/memcached/items.h0000664000076400007640000000224511753573717017622 0ustar00brianbrian00000000000000/* See items.c */ uint64_t get_cas_id(void); /*@null@*/ item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_time_t exptime, const int nbytes); void item_free(item *it); bool item_size_ok(const size_t nkey, const int flags, const int nbytes); int do_item_link(item *it, const uint32_t hv); /** may fail if transgresses limits */ void do_item_unlink(item *it, const uint32_t hv); void do_item_unlink_nolock(item *it, const uint32_t hv); void do_item_remove(item *it); void do_item_update(item *it); /** update LRU time to current and reposition */ int do_item_replace(item *it, item *new_it, const uint32_t hv); /*@null@*/ char *do_item_cachedump(const unsigned int slabs_clsid, const unsigned int limit, unsigned int *bytes); void do_item_stats(ADD_STAT add_stats, void *c); /*@null@*/ void do_item_stats_sizes(ADD_STAT add_stats, void *c); void do_item_flush_expired(void); item *do_item_get(const char *key, const size_t nkey, const uint32_t hv); item *do_item_touch(const char *key, const size_t nkey, uint32_t exptime, const uint32_t hv); void item_stats_reset(void); extern pthread_mutex_t cache_lock; void item_stats_evictions(uint64_t *evicted); libmemcached-1.0.8/memcached/cache.c0000664000076400007640000000732011753573717017536 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ #include "memcached.h" #include #include #include #include #ifndef NDEBUG #include #endif #include "cache.h" #ifndef NDEBUG const uint64_t redzone_pattern = 0xdeadbeefcafebabe; int cache_error = 0; #endif const int initial_pool_size = 64; cache_t* cache_create(const char *name, size_t bufsize, size_t align, cache_constructor_t* constructor, cache_destructor_t* destructor) { cache_t* ret = calloc(1, sizeof(cache_t)); char* nm = strdup(name); void** ptr = calloc(initial_pool_size, sizeof(void*)); if (ret == NULL || nm == NULL || ptr == NULL || pthread_mutex_init(&ret->mutex, NULL) == -1) { free(ret); free(nm); free(ptr); return NULL; } ret->name = nm; ret->ptr = ptr; ret->freetotal = initial_pool_size; ret->constructor = constructor; ret->destructor = destructor; #ifndef NDEBUG ret->bufsize = bufsize + 2 * sizeof(redzone_pattern); #else ret->bufsize = bufsize; #endif return ret; } static inline void* get_object(void *ptr) { #ifndef NDEBUG uint64_t *pre = ptr; return pre + 1; #else return ptr; #endif } void cache_destroy(cache_t *cache) { while (cache->freecurr > 0) { void *ptr = cache->ptr[--cache->freecurr]; if (cache->destructor) { cache->destructor(get_object(ptr), NULL); } free(ptr); } free(cache->name); free(cache->ptr); pthread_mutex_destroy(&cache->mutex); } void* cache_alloc(cache_t *cache) { void *ret; void *object; pthread_mutex_lock(&cache->mutex); if (cache->freecurr > 0) { ret = cache->ptr[--cache->freecurr]; object = get_object(ret); } else { object = ret = malloc(cache->bufsize); if (ret != NULL) { object = get_object(ret); if (cache->constructor != NULL && cache->constructor(object, NULL, 0) != 0) { free(ret); object = NULL; } } } pthread_mutex_unlock(&cache->mutex); #ifndef NDEBUG if (object != NULL) { /* add a simple form of buffer-check */ uint64_t *pre = ret; *pre = redzone_pattern; ret = pre+1; memcpy(((char*)ret) + cache->bufsize - (2 * sizeof(redzone_pattern)), &redzone_pattern, sizeof(redzone_pattern)); } #endif return object; } void cache_free(cache_t *cache, void *ptr) { pthread_mutex_lock(&cache->mutex); #ifndef NDEBUG /* validate redzone... */ if (memcmp(((char*)ptr) + cache->bufsize - (2 * sizeof(redzone_pattern)), &redzone_pattern, sizeof(redzone_pattern)) != 0) { raise(SIGABRT); cache_error = 1; pthread_mutex_unlock(&cache->mutex); return; } uint64_t *pre = ptr; --pre; if (*pre != redzone_pattern) { raise(SIGABRT); cache_error = -1; pthread_mutex_unlock(&cache->mutex); return; } ptr = pre; #endif if (cache->freecurr < cache->freetotal) { cache->ptr[cache->freecurr++] = ptr; } else { /* try to enlarge free connections array */ size_t newtotal = cache->freetotal * 2; void **new_free = realloc(cache->ptr, sizeof(char *) * newtotal); if (new_free) { cache->freetotal = newtotal; cache->ptr = new_free; cache->ptr[cache->freecurr++] = ptr; } else { if (cache->destructor) { cache->destructor(ptr, NULL); } free(ptr); } } pthread_mutex_unlock(&cache->mutex); } libmemcached-1.0.8/memcached/sasl_defs.h0000664000076400007640000000126511753573717020445 0ustar00brianbrian00000000000000#ifndef SASL_DEFS_H #define SASL_DEFS_H 1 // Longest one I could find was ``9798-U-RSA-SHA1-ENC'' #define MAX_SASL_MECH_LEN 32 #if defined(HAVE_SASL_SASL_H) && defined(ENABLE_SASL) #include void init_sasl(void); extern char my_sasl_hostname[1025]; #else /* End of SASL support */ typedef void* sasl_conn_t; #define init_sasl() {} #define sasl_dispose(x) {} #define sasl_server_new(a, b, c, d, e, f, g, h) 1 #define sasl_listmech(a, b, c, d, e, f, g, h) 1 #define sasl_server_start(a, b, c, d, e, f) 1 #define sasl_server_step(a, b, c, d, e) 1 #define sasl_getprop(a, b, c) {} #define SASL_OK 0 #define SASL_CONTINUE -1 #endif /* sasl compat */ #endif /* SASL_DEFS_H */ libmemcached-1.0.8/memcached/slabs.h0000664000076400007640000000322011753573717017577 0ustar00brianbrian00000000000000/* slabs memory allocation */ #ifndef SLABS_H #define SLABS_H /** Init the subsystem. 1st argument is the limit on no. of bytes to allocate, 0 if no limit. 2nd argument is the growth factor; each slab will use a chunk size equal to the previous slab's chunk size times this factor. 3rd argument specifies if the slab allocator should allocate all memory up front (if true), or allocate memory in chunks as it is needed (if false) */ void slabs_init(const size_t limit, const double factor, const bool prealloc); /** * Given object size, return id to use when allocating/freeing memory for object * 0 means error: can't store such a large object */ #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wshadow" #endif unsigned int slabs_clsid(const size_t size); /** Allocate object of given length. 0 on error */ /*@null@*/ void *slabs_alloc(const size_t size, unsigned int id); /** Free previously allocated object */ void slabs_free(void *ptr, size_t size, unsigned int id); /** Adjust the stats for memory requested */ void slabs_adjust_mem_requested(unsigned int id, size_t old, size_t ntotal); /** Return a datum for stats in binary protocol */ bool get_stats(const char *stat_type, int nkey, ADD_STAT add_stats, void *c); /** Fill buffer with stats */ /*@null@*/ void slabs_stats(ADD_STAT add_stats, void *c); int start_slab_maintenance_thread(void); void stop_slab_maintenance_thread(void); enum reassign_result_type { REASSIGN_OK=0, REASSIGN_RUNNING, REASSIGN_BADCLASS, REASSIGN_NOSPARE, REASSIGN_DEST_NOT_FULL, REASSIGN_SRC_NOT_SAFE, REASSIGN_SRC_DST_SAME }; enum reassign_result_type slabs_reassign(int src, int dst); #endif libmemcached-1.0.8/memcached/items.c0000664000076400007640000004450411753573717017621 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ #include "memcached.h" #include #include #include #include #include #include #include #include #include #include #include #include /* Forward Declarations */ static void item_link_q(item *it); static void item_unlink_q(item *it); /* * We only reposition items in the LRU queue if they haven't been repositioned * in this many seconds. That saves us from churning on frequently-accessed * items. */ #define ITEM_UPDATE_INTERVAL 60 #define LARGEST_ID POWER_LARGEST typedef struct { uint64_t evicted; uint64_t evicted_nonzero; rel_time_t evicted_time; uint64_t reclaimed; uint64_t outofmemory; uint64_t tailrepairs; uint64_t expired_unfetched; uint64_t evicted_unfetched; } itemstats_t; static item *heads[LARGEST_ID]; static item *tails[LARGEST_ID]; static itemstats_t itemstats[LARGEST_ID]; static unsigned int sizes[LARGEST_ID]; void item_stats_reset(void) { mutex_lock(&cache_lock); memset(itemstats, 0, sizeof(itemstats)); pthread_mutex_unlock(&cache_lock); } /* Get the next CAS id for a new item. */ uint64_t get_cas_id(void) { static uint64_t cas_id = 0; return ++cas_id; } /* Enable this for reference-count debugging. */ #if 0 # define DEBUG_REFCNT(it,op) \ fprintf(stderr, "item %x refcnt(%c) %d %c%c%c\n", \ it, op, it->refcount, \ (it->it_flags & ITEM_LINKED) ? 'L' : ' ', \ (it->it_flags & ITEM_SLABBED) ? 'S' : ' ') #else # define DEBUG_REFCNT(it,op) while(0) #endif /** * Generates the variable-sized part of the header for an object. * * key - The key * nkey - The length of the key * flags - key flags * nbytes - Number of bytes to hold value and addition CRLF terminator * suffix - Buffer for the "VALUE" line suffix (flags, size). * nsuffix - The length of the suffix is stored here. * * Returns the total size of the header. */ static size_t item_make_header(const uint8_t nkey, const int flags, const int nbytes, char *suffix, uint8_t *nsuffix) { /* suffix is defined at 40 chars elsewhere.. */ *nsuffix = (uint8_t) snprintf(suffix, 40, " %d %d\r\n", flags, nbytes - 2); return sizeof(item) + nkey + *nsuffix + nbytes; } /*@null@*/ item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_time_t exptime, const int nbytes) { uint8_t nsuffix; item *it = NULL; char suffix[40]; size_t ntotal = item_make_header(nkey + 1, flags, nbytes, suffix, &nsuffix); if (settings.use_cas) { ntotal += sizeof(uint64_t); } unsigned int id = slabs_clsid(ntotal); if (id == 0) return 0; mutex_lock(&cache_lock); /* do a quick check if we have any expired items in the tail.. */ item *search; rel_time_t oldest_live = settings.oldest_live; search = tails[id]; if (search != NULL && (refcount_incr(&search->refcount) == 2)) { if ((search->exptime != 0 && search->exptime < current_time) || (search->time <= oldest_live && oldest_live <= current_time)) { // dead by flush STATS_LOCK(); stats.reclaimed++; STATS_UNLOCK(); itemstats[id].reclaimed++; if ((search->it_flags & ITEM_FETCHED) == 0) { STATS_LOCK(); stats.expired_unfetched++; STATS_UNLOCK(); itemstats[id].expired_unfetched++; } it = search; slabs_adjust_mem_requested(it->slabs_clsid, ITEM_ntotal(it), ntotal); do_item_unlink_nolock(it, hash(ITEM_key(it), it->nkey, 0)); /* Initialize the item block: */ it->slabs_clsid = 0; } else if ((it = slabs_alloc(ntotal, id)) == NULL) { if (settings.evict_to_free == 0) { itemstats[id].outofmemory++; pthread_mutex_unlock(&cache_lock); return NULL; } itemstats[id].evicted++; itemstats[id].evicted_time = current_time - search->time; if (search->exptime != 0) itemstats[id].evicted_nonzero++; if ((search->it_flags & ITEM_FETCHED) == 0) { STATS_LOCK(); stats.evicted_unfetched++; STATS_UNLOCK(); itemstats[id].evicted_unfetched++; } STATS_LOCK(); stats.evictions++; STATS_UNLOCK(); it = search; slabs_adjust_mem_requested(it->slabs_clsid, ITEM_ntotal(it), ntotal); do_item_unlink_nolock(it, hash(ITEM_key(it), it->nkey, 0)); /* Initialize the item block: */ it->slabs_clsid = 0; } else { refcount_decr(&search->refcount); } } else { /* If the LRU is empty or locked, attempt to allocate memory */ it = slabs_alloc(ntotal, id); if (search != NULL) refcount_decr(&search->refcount); } if (it == NULL) { itemstats[id].outofmemory++; /* Last ditch effort. There was a very rare bug which caused * refcount leaks. We leave this just in case they ever happen again. * We can reasonably assume no item can stay locked for more than * three hours, so if we find one in the tail which is that old, * free it anyway. */ if (search != NULL && search->refcount != 2 && search->time + TAIL_REPAIR_TIME < current_time) { itemstats[id].tailrepairs++; search->refcount = 1; do_item_unlink_nolock(search, hash(ITEM_key(search), search->nkey, 0)); } pthread_mutex_unlock(&cache_lock); return NULL; } assert(it->slabs_clsid == 0); assert(it != heads[id]); /* Item initialization can happen outside of the lock; the item's already * been removed from the slab LRU. */ it->refcount = 1; /* the caller will have a reference */ pthread_mutex_unlock(&cache_lock); it->next = it->prev = it->h_next = 0; it->slabs_clsid = id; DEBUG_REFCNT(it, '*'); it->it_flags = settings.use_cas ? ITEM_CAS : 0; it->nkey = nkey; it->nbytes = nbytes; memcpy(ITEM_key(it), key, nkey); it->exptime = exptime; memcpy(ITEM_suffix(it), suffix, (size_t)nsuffix); it->nsuffix = nsuffix; return it; } void item_free(item *it) { size_t ntotal = ITEM_ntotal(it); unsigned int clsid; assert((it->it_flags & ITEM_LINKED) == 0); assert(it != heads[it->slabs_clsid]); assert(it != tails[it->slabs_clsid]); assert(it->refcount == 0); /* so slab size changer can tell later if item is already free or not */ clsid = it->slabs_clsid; it->slabs_clsid = 0; DEBUG_REFCNT(it, 'F'); slabs_free(it, ntotal, clsid); } /** * Returns true if an item will fit in the cache (its size does not exceed * the maximum for a cache entry.) */ bool item_size_ok(const size_t nkey, const int flags, const int nbytes) { char prefix[40]; uint8_t nsuffix; size_t ntotal = item_make_header(nkey + 1, flags, nbytes, prefix, &nsuffix); if (settings.use_cas) { ntotal += sizeof(uint64_t); } return slabs_clsid(ntotal) != 0; } static void item_link_q(item *it) { /* item is the new head */ item **head, **tail; assert(it->slabs_clsid < LARGEST_ID); assert((it->it_flags & ITEM_SLABBED) == 0); head = &heads[it->slabs_clsid]; tail = &tails[it->slabs_clsid]; assert(it != *head); assert((*head && *tail) || (*head == 0 && *tail == 0)); it->prev = 0; it->next = *head; if (it->next) it->next->prev = it; *head = it; if (*tail == 0) *tail = it; sizes[it->slabs_clsid]++; return; } static void item_unlink_q(item *it) { item **head, **tail; assert(it->slabs_clsid < LARGEST_ID); head = &heads[it->slabs_clsid]; tail = &tails[it->slabs_clsid]; if (*head == it) { assert(it->prev == 0); *head = it->next; } if (*tail == it) { assert(it->next == 0); *tail = it->prev; } assert(it->next != it); assert(it->prev != it); if (it->next) it->next->prev = it->prev; if (it->prev) it->prev->next = it->next; sizes[it->slabs_clsid]--; return; } int do_item_link(item *it, const uint32_t hv) { MEMCACHED_ITEM_LINK(ITEM_key(it), it->nkey, it->nbytes); assert((it->it_flags & (ITEM_LINKED|ITEM_SLABBED)) == 0); mutex_lock(&cache_lock); it->it_flags |= ITEM_LINKED; it->time = current_time; STATS_LOCK(); stats.curr_bytes += ITEM_ntotal(it); stats.curr_items += 1; stats.total_items += 1; STATS_UNLOCK(); /* Allocate a new CAS ID on link. */ ITEM_set_cas(it, (settings.use_cas) ? get_cas_id() : 0); assoc_insert(it, hv); item_link_q(it); refcount_incr(&it->refcount); pthread_mutex_unlock(&cache_lock); return 1; } void do_item_unlink(item *it, const uint32_t hv) { MEMCACHED_ITEM_UNLINK(ITEM_key(it), it->nkey, it->nbytes); mutex_lock(&cache_lock); if ((it->it_flags & ITEM_LINKED) != 0) { it->it_flags &= ~ITEM_LINKED; STATS_LOCK(); stats.curr_bytes -= ITEM_ntotal(it); stats.curr_items -= 1; STATS_UNLOCK(); assoc_delete(ITEM_key(it), it->nkey, hv); item_unlink_q(it); do_item_remove(it); } pthread_mutex_unlock(&cache_lock); } /* FIXME: Is it necessary to keep this copy/pasted code? */ void do_item_unlink_nolock(item *it, const uint32_t hv) { MEMCACHED_ITEM_UNLINK(ITEM_key(it), it->nkey, it->nbytes); if ((it->it_flags & ITEM_LINKED) != 0) { it->it_flags &= ~ITEM_LINKED; STATS_LOCK(); stats.curr_bytes -= ITEM_ntotal(it); stats.curr_items -= 1; STATS_UNLOCK(); assoc_delete(ITEM_key(it), it->nkey, hv); item_unlink_q(it); do_item_remove(it); } } void do_item_remove(item *it) { MEMCACHED_ITEM_REMOVE(ITEM_key(it), it->nkey, it->nbytes); assert((it->it_flags & ITEM_SLABBED) == 0); if (refcount_decr(&it->refcount) == 0) { item_free(it); } } void do_item_update(item *it) { MEMCACHED_ITEM_UPDATE(ITEM_key(it), it->nkey, it->nbytes); if (it->time < current_time - ITEM_UPDATE_INTERVAL) { assert((it->it_flags & ITEM_SLABBED) == 0); mutex_lock(&cache_lock); if ((it->it_flags & ITEM_LINKED) != 0) { item_unlink_q(it); it->time = current_time; item_link_q(it); } pthread_mutex_unlock(&cache_lock); } } int do_item_replace(item *it, item *new_it, const uint32_t hv) { MEMCACHED_ITEM_REPLACE(ITEM_key(it), it->nkey, it->nbytes, ITEM_key(new_it), new_it->nkey, new_it->nbytes); assert((it->it_flags & ITEM_SLABBED) == 0); do_item_unlink(it, hv); return do_item_link(new_it, hv); } #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wshadow" #endif /*@null@*/ char *do_item_cachedump(const unsigned int slabs_clsid, const unsigned int limit, unsigned int *bytes) { unsigned int memlimit = 2 * 1024 * 1024; /* 2MB max response size */ char *buffer; unsigned int bufcurr; item *it; unsigned int len; unsigned int shown = 0; char key_temp[KEY_MAX_LENGTH + 1]; char temp[512]; it = heads[slabs_clsid]; buffer = malloc((size_t)memlimit); if (buffer == 0) return NULL; bufcurr = 0; while (it != NULL && (limit == 0 || shown < limit)) { assert(it->nkey <= KEY_MAX_LENGTH); /* Copy the key since it may not be null-terminated in the struct */ strncpy(key_temp, ITEM_key(it), it->nkey); key_temp[it->nkey] = 0x00; /* terminate */ len = snprintf(temp, sizeof(temp), "ITEM %s [%d b; %lu s]\r\n", key_temp, it->nbytes - 2, (unsigned long)it->exptime + process_started); if (bufcurr + len + 6 > memlimit) /* 6 is END\r\n\0 */ break; memcpy(buffer + bufcurr, temp, len); bufcurr += len; shown++; it = it->next; } memcpy(buffer + bufcurr, "END\r\n", 6); bufcurr += 5; *bytes = bufcurr; return buffer; } void item_stats_evictions(uint64_t *evicted) { int i; mutex_lock(&cache_lock); for (i = 0; i < LARGEST_ID; i++) { evicted[i] = itemstats[i].evicted; } pthread_mutex_unlock(&cache_lock); } void do_item_stats(ADD_STAT add_stats, void *c) { int i; for (i = 0; i < LARGEST_ID; i++) { if (tails[i] != NULL) { const char *fmt = "items:%d:%s"; char key_str[STAT_KEY_LEN]; char val_str[STAT_VAL_LEN]; int klen = 0, vlen = 0; if (tails[i] == NULL) { /* We removed all of the items in this slab class */ continue; } APPEND_NUM_FMT_STAT(fmt, i, "number", "%u", sizes[i]); APPEND_NUM_FMT_STAT(fmt, i, "age", "%u", current_time - tails[i]->time); APPEND_NUM_FMT_STAT(fmt, i, "evicted", "%llu", (unsigned long long)itemstats[i].evicted); APPEND_NUM_FMT_STAT(fmt, i, "evicted_nonzero", "%llu", (unsigned long long)itemstats[i].evicted_nonzero); APPEND_NUM_FMT_STAT(fmt, i, "evicted_time", "%u", itemstats[i].evicted_time); APPEND_NUM_FMT_STAT(fmt, i, "outofmemory", "%llu", (unsigned long long)itemstats[i].outofmemory); APPEND_NUM_FMT_STAT(fmt, i, "tailrepairs", "%llu", (unsigned long long)itemstats[i].tailrepairs); APPEND_NUM_FMT_STAT(fmt, i, "reclaimed", "%llu", (unsigned long long)itemstats[i].reclaimed); APPEND_NUM_FMT_STAT(fmt, i, "expired_unfetched", "%llu", (unsigned long long)itemstats[i].expired_unfetched); APPEND_NUM_FMT_STAT(fmt, i, "evicted_unfetched", "%llu", (unsigned long long)itemstats[i].evicted_unfetched); } } /* getting here means both ascii and binary terminators fit */ add_stats(NULL, 0, NULL, 0, c); } /** dumps out a list of objects of each size, with granularity of 32 bytes */ /*@null@*/ void do_item_stats_sizes(ADD_STAT add_stats, void *c) { /* max 1MB object, divided into 32 bytes size buckets */ const int num_buckets = 32768; unsigned int *histogram = calloc(num_buckets, sizeof(int)); if (histogram != NULL) { int i; /* build the histogram */ for (i = 0; i < LARGEST_ID; i++) { item *iter = heads[i]; while (iter) { int ntotal = ITEM_ntotal(iter); int bucket = ntotal / 32; if ((ntotal % 32) != 0) bucket++; if (bucket < num_buckets) histogram[bucket]++; iter = iter->next; } } /* write the buffer */ for (i = 0; i < num_buckets; i++) { if (histogram[i] != 0) { char key[8]; snprintf(key, sizeof(key), "%d", i * 32); APPEND_STAT(key, "%u", histogram[i]); } } free(histogram); } add_stats(NULL, 0, NULL, 0, c); } /** wrapper around assoc_find which does the lazy expiration logic */ item *do_item_get(const char *key, const size_t nkey, const uint32_t hv) { mutex_lock(&cache_lock); item *it = assoc_find(key, nkey, hv); if (it != NULL) { refcount_incr(&it->refcount); /* Optimization for slab reassignment. prevents popular items from * jamming in busy wait. Can only do this here to satisfy lock order * of item_lock, cache_lock, slabs_lock. */ if (slab_rebalance_signal && ((void *)it >= slab_rebal.slab_start && (void *)it < slab_rebal.slab_end)) { do_item_unlink_nolock(it, hv); do_item_remove(it); it = NULL; } } pthread_mutex_unlock(&cache_lock); int was_found = 0; if (settings.verbose > 2) { if (it == NULL) { fprintf(stderr, "> NOT FOUND %s", key); } else { fprintf(stderr, "> FOUND KEY %s", ITEM_key(it)); was_found++; } } if (it != NULL) { if (settings.oldest_live != 0 && settings.oldest_live <= current_time && it->time <= settings.oldest_live) { do_item_unlink(it, hv); do_item_remove(it); it = NULL; if (was_found) { fprintf(stderr, " -nuked by flush"); } } else if (it->exptime != 0 && it->exptime <= current_time) { do_item_unlink(it, hv); do_item_remove(it); it = NULL; if (was_found) { fprintf(stderr, " -nuked by expire"); } } else { it->it_flags |= ITEM_FETCHED; DEBUG_REFCNT(it, '+'); } } if (settings.verbose > 2) fprintf(stderr, "\n"); return it; } item *do_item_touch(const char *key, size_t nkey, uint32_t exptime, const uint32_t hv) { item *it = do_item_get(key, nkey, hv); if (it != NULL) { it->exptime = exptime; } return it; } /* expires items that are more recent than the oldest_live setting. */ void do_item_flush_expired(void) { int i; item *iter, *next; if (settings.oldest_live == 0) return; for (i = 0; i < LARGEST_ID; i++) { /* The LRU is sorted in decreasing time order, and an item's timestamp * is never newer than its last access time, so we only need to walk * back until we hit an item older than the oldest_live time. * The oldest_live checking will auto-expire the remaining items. */ for (iter = heads[i]; iter != NULL; iter = next) { if (iter->time >= settings.oldest_live) { next = iter->next; if ((iter->it_flags & ITEM_SLABBED) == 0) { do_item_unlink_nolock(iter, hash(ITEM_key(iter), iter->nkey, 0)); } } else { /* We've hit the first old item. Continue to the next queue. */ break; } } } } libmemcached-1.0.8/memcached/cache.h0000664000076400007640000001032011753573717017535 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ #ifndef CACHE_H #define CACHE_H #include #ifdef HAVE_UMEM_H #include #define cache_t umem_cache_t #define cache_alloc(a) umem_cache_alloc(a, UMEM_DEFAULT) #define cache_free(a, b) umem_cache_free(a, b) #define cache_create(a,b,c,d,e) umem_cache_create((char*)a, b, c, d, e, NULL, NULL, NULL, 0) #define cache_destroy(a) umem_cache_destroy(a); #else #ifndef NDEBUG /* may be used for debug purposes */ extern int cache_error; #endif /** * Constructor used to initialize allocated objects * * @param obj pointer to the object to initialized. * @param notused1 This parameter is currently not used. * @param notused2 This parameter is currently not used. * @return you should return 0, but currently this is not checked */ typedef int cache_constructor_t(void* obj, void* notused1, int notused2); /** * Destructor used to clean up allocated objects before they are * returned to the operating system. * * @param obj pointer to the object to initialized. * @param notused1 This parameter is currently not used. * @param notused2 This parameter is currently not used. * @return you should return 0, but currently this is not checked */ typedef void cache_destructor_t(void* obj, void* notused); /** * Definition of the structure to keep track of the internal details of * the cache allocator. Touching any of these variables results in * undefined behavior. */ typedef struct { /** Mutex to protect access to the structure */ pthread_mutex_t mutex; /** Name of the cache objects in this cache (provided by the caller) */ char *name; /** List of pointers to available buffers in this cache */ void **ptr; /** The size of each element in this cache */ size_t bufsize; /** The capacity of the list of elements */ int freetotal; /** The current number of free elements */ int freecurr; /** The constructor to be called each time we allocate more memory */ cache_constructor_t* constructor; /** The destructor to be called each time before we release memory */ cache_destructor_t* destructor; } cache_t; /** * Create an object cache. * * The object cache will let you allocate objects of the same size. It is fully * MT safe, so you may allocate objects from multiple threads without having to * do any syncrhonization in the application code. * * @param name the name of the object cache. This name may be used for debug purposes * and may help you track down what kind of object you have problems with * (buffer overruns, leakage etc) * @param bufsize the size of each object in the cache * @param align the alignment requirements of the objects in the cache. * @param constructor the function to be called to initialize memory when we need * to allocate more memory from the os. * @param destructor the function to be called before we release the memory back * to the os. * @return a handle to an object cache if successful, NULL otherwise. */ cache_t* cache_create(const char* name, size_t bufsize, size_t align, cache_constructor_t* constructor, cache_destructor_t* destructor); /** * Destroy an object cache. * * Destroy and invalidate an object cache. You should return all buffers allocated * with cache_alloc by using cache_free before calling this function. Not doing * so results in undefined behavior (the buffers may or may not be invalidated) * * @param handle the handle to the object cache to destroy. */ void cache_destroy(cache_t* handle); /** * Allocate an object from the cache. * * @param handle the handle to the object cache to allocate from * @return a pointer to an initialized object from the cache, or NULL if * the allocation cannot be satisfied. */ void* cache_alloc(cache_t* handle); /** * Return an object back to the cache. * * The caller should return the object in an initialized state so that * the object may be returned in an expected state from cache_alloc. * * @param handle handle to the object cache to return the object to * @param ptr pointer to the object to return. */ void cache_free(cache_t* handle, void* ptr); #endif #endif libmemcached-1.0.8/memcached/version.m40000664000076400007640000000004611753573717020254 0ustar00brianbrian00000000000000m4_define([VERSION_NUMBER], [1.4.13]) libmemcached-1.0.8/memcached/assoc.c0000664000076400007640000002001211753573717017574 0ustar00brianbrian00000000000000/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Hash table * * The hash function used here is by Bob Jenkins, 1996: * * "By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. * You may use this code any way you wish, private, educational, * or commercial. It's free." * * The rest of the file is licensed under the BSD license. See LICENSE. */ #include "memcached.h" #include #include #include #include #include #include #include #include #include #include #include #include static pthread_cond_t maintenance_cond = PTHREAD_COND_INITIALIZER; #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wunused-parameter" #endif typedef unsigned long int ub4; /* unsigned 4-byte quantities */ typedef unsigned char ub1; /* unsigned 1-byte quantities */ /* how many powers of 2's worth of buckets we use */ static unsigned int hashpower = HASHPOWER_DEFAULT; #define hashsize(n) ((ub4)1<<(n)) #define hashmask(n) (hashsize(n)-1) /* Main hash table. This is where we look except during expansion. */ static item** primary_hashtable = 0; /* * Previous hash table. During expansion, we look here for keys that haven't * been moved over to the primary yet. */ static item** old_hashtable = 0; /* Number of items in the hash table. */ static unsigned int hash_items = 0; /* Flag: Are we in the middle of expanding now? */ static bool expanding = false; /* * During expansion we migrate values with bucket granularity; this is how * far we've gotten so far. Ranges from 0 .. hashsize(hashpower - 1) - 1. */ static unsigned int expand_bucket = 0; void assoc_init(const int hashtable_init) { if (hashtable_init) { hashpower = hashtable_init; } primary_hashtable = calloc(hashsize(hashpower), sizeof(void *)); if (! primary_hashtable) { fprintf(stderr, "Failed to init hashtable.\n"); exit(EXIT_FAILURE); } STATS_LOCK(); stats.hash_power_level = hashpower; stats.hash_bytes = hashsize(hashpower) * sizeof(void *); STATS_UNLOCK(); } item *assoc_find(const char *key, const size_t nkey, const uint32_t hv) { item *it; unsigned int oldbucket; if (expanding && (oldbucket = (hv & hashmask(hashpower - 1))) >= expand_bucket) { it = old_hashtable[oldbucket]; } else { it = primary_hashtable[hv & hashmask(hashpower)]; } item *ret = NULL; int depth = 0; while (it) { if ((nkey == it->nkey) && (memcmp(key, ITEM_key(it), nkey) == 0)) { ret = it; break; } it = it->h_next; ++depth; } MEMCACHED_ASSOC_FIND(key, nkey, depth); return ret; } /* returns the address of the item pointer before the key. if *item == 0, the item wasn't found */ static item** _hashitem_before (const char *key, const size_t nkey, const uint32_t hv) { item **pos; unsigned int oldbucket; if (expanding && (oldbucket = (hv & hashmask(hashpower - 1))) >= expand_bucket) { pos = &old_hashtable[oldbucket]; } else { pos = &primary_hashtable[hv & hashmask(hashpower)]; } while (*pos && ((nkey != (*pos)->nkey) || memcmp(key, ITEM_key(*pos), nkey))) { pos = &(*pos)->h_next; } return pos; } /* grows the hashtable to the next power of 2. */ static void assoc_expand(void) { old_hashtable = primary_hashtable; primary_hashtable = calloc(hashsize(hashpower + 1), sizeof(void *)); if (primary_hashtable) { if (settings.verbose > 1) fprintf(stderr, "Hash table expansion starting\n"); hashpower++; expanding = true; expand_bucket = 0; STATS_LOCK(); stats.hash_power_level = hashpower; stats.hash_bytes += hashsize(hashpower) * sizeof(void *); stats.hash_is_expanding = 1; STATS_UNLOCK(); pthread_cond_signal(&maintenance_cond); } else { primary_hashtable = old_hashtable; /* Bad news, but we can keep running. */ } } /* Note: this isn't an assoc_update. The key must not already exist to call this */ int assoc_insert(item *it, const uint32_t hv) { unsigned int oldbucket; // assert(assoc_find(ITEM_key(it), it->nkey) == 0); /* shouldn't have duplicately named things defined */ if (expanding && (oldbucket = (hv & hashmask(hashpower - 1))) >= expand_bucket) { it->h_next = old_hashtable[oldbucket]; old_hashtable[oldbucket] = it; } else { it->h_next = primary_hashtable[hv & hashmask(hashpower)]; primary_hashtable[hv & hashmask(hashpower)] = it; } hash_items++; if (! expanding && hash_items > (hashsize(hashpower) * 3) / 2) { assoc_expand(); } MEMCACHED_ASSOC_INSERT(ITEM_key(it), it->nkey, hash_items); return 1; } void assoc_delete(const char *key, const size_t nkey, const uint32_t hv) { item **before = _hashitem_before(key, nkey, hv); if (*before) { item *nxt; hash_items--; /* The DTrace probe cannot be triggered as the last instruction * due to possible tail-optimization by the compiler */ MEMCACHED_ASSOC_DELETE(key, nkey, hash_items); nxt = (*before)->h_next; (*before)->h_next = 0; /* probably pointless, but whatever. */ *before = nxt; return; } /* Note: we never actually get here. the callers don't delete things they can't find. */ assert(*before != 0); } static volatile int do_run_maintenance_thread = 1; #define DEFAULT_HASH_BULK_MOVE 1 int hash_bulk_move = DEFAULT_HASH_BULK_MOVE; static void *assoc_maintenance_thread(void *arg) { while (do_run_maintenance_thread) { int ii = 0; /* Lock the cache, and bulk move multiple buckets to the new * hash table. */ mutex_lock(&cache_lock); for (ii = 0; ii < hash_bulk_move && expanding; ++ii) { item *it, *next; int bucket; for (it = old_hashtable[expand_bucket]; NULL != it; it = next) { next = it->h_next; bucket = hash(ITEM_key(it), it->nkey, 0) & hashmask(hashpower); it->h_next = primary_hashtable[bucket]; primary_hashtable[bucket] = it; } old_hashtable[expand_bucket] = NULL; expand_bucket++; if (expand_bucket == hashsize(hashpower - 1)) { expanding = false; free(old_hashtable); STATS_LOCK(); stats.hash_bytes -= hashsize(hashpower - 1) * sizeof(void *); stats.hash_is_expanding = 0; STATS_UNLOCK(); if (settings.verbose > 1) fprintf(stderr, "Hash table expansion done\n"); } } if (!expanding) { /* We are done expanding.. just wait for next invocation */ pthread_cond_wait(&maintenance_cond, &cache_lock); } pthread_mutex_unlock(&cache_lock); } return NULL; } static pthread_t maintenance_tid; int start_assoc_maintenance_thread() { int ret; char *env = getenv("MEMCACHED_HASH_BULK_MOVE"); if (env != NULL) { hash_bulk_move = atoi(env); if (hash_bulk_move == 0) { hash_bulk_move = DEFAULT_HASH_BULK_MOVE; } } if ((ret = pthread_create(&maintenance_tid, NULL, assoc_maintenance_thread, NULL)) != 0) { fprintf(stderr, "Can't create thread: %s\n", strerror(ret)); return -1; } return 0; } void stop_assoc_maintenance_thread() { mutex_lock(&cache_lock); do_run_maintenance_thread = 0; pthread_cond_signal(&maintenance_cond); pthread_mutex_unlock(&cache_lock); /* Wait for the maintenance thread to stop */ pthread_join(maintenance_tid, NULL); } libmemcached-1.0.8/libhashkit-1.0/0000775000076400007640000000000011757025117017023 5ustar00brianbrian00000000000000libmemcached-1.0.8/libhashkit-1.0/has.h0000664000076400007640000000343211753573717017763 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif HASHKIT_API bool libhashkit_has_algorithm(const hashkit_hash_algorithm_t); #ifdef __cplusplus } #endif libmemcached-1.0.8/libhashkit-1.0/include.am0000664000076400007640000000112711753573717021000 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root # EXTRA_DIST+= \ libhashkit-1.0/configure.h.in nobase_include_HEADERS+= \ libhashkit-1.0/algorithm.h \ libhashkit-1.0/behavior.h \ libhashkit-1.0/configure.h \ libhashkit-1.0/digest.h \ libhashkit-1.0/function.h \ libhashkit-1.0/has.h \ libhashkit-1.0/hashkit.h \ libhashkit-1.0/hashkit.hpp \ libhashkit-1.0/strerror.h \ libhashkit-1.0/string.h \ libhashkit-1.0/str_algorithm.h \ libhashkit-1.0/types.h \ libhashkit-1.0/visibility.h libmemcached-1.0.8/libhashkit-1.0/algorithm.h0000664000076400007640000000411711753573717021177 0ustar00brianbrian00000000000000/* HashKit * Copyright (C) 2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ /** * @file * @brief HashKit Header */ #pragma once #ifdef __cplusplus extern "C" { #endif HASHKIT_API uint32_t libhashkit_one_at_a_time(const char *key, size_t key_length); HASHKIT_API uint32_t libhashkit_fnv1_64(const char *key, size_t key_length); HASHKIT_API uint32_t libhashkit_fnv1a_64(const char *key, size_t key_length); HASHKIT_API uint32_t libhashkit_fnv1_32(const char *key, size_t key_length); HASHKIT_API uint32_t libhashkit_fnv1a_32(const char *key, size_t key_length); HASHKIT_API uint32_t libhashkit_crc32(const char *key, size_t key_length); HASHKIT_API 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_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); #ifdef __cplusplus } #endif libmemcached-1.0.8/libhashkit-1.0/hashkit.h0000664000076400007640000000626211753573717020647 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * HashKit library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2009-2010 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. * */ #pragma once #if !defined(__cplusplus) # include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include struct hashkit_st { struct hashkit_function_st { hashkit_hash_fn function; void *context; } base_hash, distribution_hash; struct { bool is_base_same_distributed:1; } flags; struct { bool is_allocated:1; } options; void *_key; }; #ifdef __cplusplus extern "C" { #endif HASHKIT_API hashkit_st *hashkit_create(hashkit_st *hash); HASHKIT_API hashkit_st *hashkit_clone(hashkit_st *destination, const hashkit_st *ptr); HASHKIT_API bool hashkit_compare(const hashkit_st *first, const hashkit_st *second); HASHKIT_API void hashkit_free(hashkit_st *hash); HASHKIT_API hashkit_string_st *hashkit_encrypt(hashkit_st *, const char* source, size_t source_length); HASHKIT_API hashkit_string_st *hashkit_decrypt(hashkit_st *, const char* source, size_t source_length); HASHKIT_API bool hashkit_key(hashkit_st *, const char *key, const size_t key_length); #ifdef __cplusplus } // extern "C" #endif libmemcached-1.0.8/libhashkit-1.0/hashkit.hpp0000664000076400007640000000535711753573717021213 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #include #include class Hashkit { public: Hashkit() { hashkit_create(&self); } Hashkit(const Hashkit& source) { hashkit_clone(&self, &source.self); } Hashkit& operator=(const Hashkit& source) { hashkit_free(&self); hashkit_clone(&self, &source.self); return *this; } friend bool operator==(const Hashkit &left, const Hashkit &right) { return hashkit_compare(&left.self, &right.self); } uint32_t digest(std::string& str) { return hashkit_digest(&self, str.c_str(), str.length()); } uint32_t digest(const char *key, size_t key_length) { return hashkit_digest(&self, key, key_length); } hashkit_return_t set_function(hashkit_hash_algorithm_t hash_algorithm) { return hashkit_set_function(&self, hash_algorithm); } hashkit_return_t set_distribution_function(hashkit_hash_algorithm_t hash_algorithm) { return hashkit_set_function(&self, hash_algorithm); } ~Hashkit() { hashkit_free(&self); } private: hashkit_st self; }; libmemcached-1.0.8/libhashkit-1.0/configure.h.in0000664000076400007640000000043311753573717021574 0ustar00brianbrian00000000000000/* HashKit * Copyright (C) 2009-2010 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ #pragma once #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif libmemcached-1.0.8/libhashkit-1.0/str_algorithm.h0000664000076400007640000000342111753573717022064 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * HashKit * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif HASHKIT_API const char *libhashkit_string_hash(hashkit_hash_algorithm_t type); #ifdef __cplusplus } #endif libmemcached-1.0.8/libhashkit-1.0/behavior.h0000664000076400007640000000050211753573717021002 0ustar00brianbrian00000000000000/* HashKit * Copyright (C) 2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ /** * @file * @brief HashKit Header */ #pragma once #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif libmemcached-1.0.8/libhashkit-1.0/digest.h0000664000076400007640000000112711753573717020466 0ustar00brianbrian00000000000000/* HashKit * Copyright (C) 2010 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ #pragma once #ifdef __cplusplus extern "C" { #endif HASHKIT_API uint32_t hashkit_digest(const hashkit_st *self, const char *key, size_t key_length); /** This is a utilitly function provided so that you can directly access hashes with a hashkit_st. */ HASHKIT_API uint32_t libhashkit_digest(const char *key, size_t key_length, hashkit_hash_algorithm_t hash_algorithm); #ifdef __cplusplus } #endif libmemcached-1.0.8/libhashkit-1.0/types.h0000664000076400007640000000567011753573717020362 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * HashKit * * Copyright (C) 2011 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. * */ #pragma once typedef enum { HASHKIT_SUCCESS, HASHKIT_FAILURE, HASHKIT_MEMORY_ALLOCATION_FAILURE, HASHKIT_INVALID_HASH, HASHKIT_INVALID_ARGUMENT, HASHKIT_MAXIMUM_RETURN /* Always add new error code before */ } hashkit_return_t; static inline bool hashkit_success(const hashkit_return_t rc) { return (rc == HASHKIT_SUCCESS); } static inline bool hashkit_failed(const hashkit_return_t rc) { return (rc != HASHKIT_SUCCESS); } typedef enum { HASHKIT_HASH_DEFAULT= 0, // hashkit_one_at_a_time() HASHKIT_HASH_MD5, HASHKIT_HASH_CRC, HASHKIT_HASH_FNV1_64, HASHKIT_HASH_FNV1A_64, HASHKIT_HASH_FNV1_32, HASHKIT_HASH_FNV1A_32, HASHKIT_HASH_HSIEH, HASHKIT_HASH_MURMUR, HASHKIT_HASH_JENKINS, HASHKIT_HASH_CUSTOM, HASHKIT_HASH_MAX } hashkit_hash_algorithm_t; /** * Hash distributions that are available to use. */ typedef enum { HASHKIT_DISTRIBUTION_MODULA, HASHKIT_DISTRIBUTION_RANDOM, HASHKIT_DISTRIBUTION_KETAMA, HASHKIT_DISTRIBUTION_MAX /* Always add new values before this. */ } hashkit_distribution_t; #ifdef __cplusplus extern "C" { #endif typedef struct hashkit_st hashkit_st; typedef struct hashkit_string_st hashkit_string_st; typedef uint32_t (*hashkit_hash_fn)(const char *key, size_t key_length, void *context); #ifdef __cplusplus } #endif libmemcached-1.0.8/libhashkit-1.0/configure.h0000664000076400007640000000043311756761746021173 0ustar00brianbrian00000000000000/* HashKit * Copyright (C) 2009-2010 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ #pragma once #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif libmemcached-1.0.8/libhashkit-1.0/function.h0000664000076400007640000000205411753573717021034 0ustar00brianbrian00000000000000/* HashKit * Copyright (C) 2010 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ #pragma once #ifdef __cplusplus extern "C" { #endif /** This sets/gets the default function we will be using. */ HASHKIT_API hashkit_return_t hashkit_set_function(hashkit_st *hash, hashkit_hash_algorithm_t hash_algorithm); HASHKIT_API hashkit_return_t hashkit_set_custom_function(hashkit_st *hash, hashkit_hash_fn function, void *context); HASHKIT_API hashkit_hash_algorithm_t hashkit_get_function(const hashkit_st *hash); /** This sets/gets the function we use for distribution. */ HASHKIT_API hashkit_return_t hashkit_set_distribution_function(hashkit_st *hash, hashkit_hash_algorithm_t hash_algorithm); HASHKIT_API hashkit_return_t hashkit_set_custom_distribution_function(hashkit_st *self, hashkit_hash_fn function, void *context); HASHKIT_API hashkit_hash_algorithm_t hashkit_get_distribution_function(const hashkit_st *self); #ifdef __cplusplus } #endif libmemcached-1.0.8/libhashkit-1.0/visibility.h0000664000076400007640000000240411753573717021375 0ustar00brianbrian00000000000000/* * Summary: interface for HashKit functions * Description: visibitliy macros for HashKit library * * Use and distribution licensed under the BSD license. See * the COPYING file in this directory for full text. * * Author: Monty Taylor */ /** * @file * @brief Visibility control macros */ #pragma once /** * * HASHKIT_API is used for the public API symbols. It either DLL imports or * DLL exports (or does nothing for static build). * * HASHKIT_LOCAL is used for non-api symbols. */ #if defined(BUILDING_HASHKIT) # if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY # define HASHKIT_API __attribute__ ((visibility("default"))) # define HASHKIT_LOCAL __attribute__ ((visibility("hidden"))) # elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550) # define HASHKIT_API __global # define HASHKIT_LOCAL __hidden # elif defined(_MSC_VER) # define HASHKIT_API extern __declspec(dllexport) # define HASHKIT_LOCAL # else # define HASHKIT_API # define HASHKIT_LOCAL # endif /* defined(HAVE_VISIBILITY) */ #else /* defined(BUILDING_HASHKIT) */ # if defined(_MSC_VER) # define HASHKIT_API extern __declspec(dllimport) # define HASHKIT_LOCAL # else # define HASHKIT_API # define HASHKIT_LOCAL # endif /* defined(_MSC_VER) */ #endif /* defined(BUILDING_HASHKIT) */ libmemcached-1.0.8/libhashkit-1.0/strerror.h0000664000076400007640000000055111753573717021071 0ustar00brianbrian00000000000000/* HashKit * Copyright (C) 2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ #pragma once #ifdef __cplusplus extern "C" { #endif HASHKIT_API const char *hashkit_strerror(hashkit_st *ptr, hashkit_return_t rc); #ifdef __cplusplus } #endif libmemcached-1.0.8/libhashkit-1.0/string.h0000664000076400007640000000375611753573717020527 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libhashkit library * * Copyright (C) 2011-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. * */ #pragma once #ifdef __cplusplus struct hashkit_string_st; #endif #ifdef __cplusplus extern "C" { #endif HASHKIT_API void hashkit_string_free(hashkit_string_st *ptr); HASHKIT_API size_t hashkit_string_length(const hashkit_string_st *self); HASHKIT_API const char *hashkit_string_c_str(const hashkit_string_st* self); #ifdef __cplusplus } // extern "C" #endif libmemcached-1.0.8/COPYING0000664000076400007640000000302711753573717015454 0ustar00brianbrian00000000000000Software License Agreement (BSD License) 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. * Neither the name of TangentOrg nor the names of its contributors may 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. libmemcached-1.0.8/m4/0000775000076400007640000000000011757025120014717 5ustar00brianbrian00000000000000libmemcached-1.0.8/m4/pandora_canonical.m40000664000076400007640000001457411753573717020647 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl Which version of the canonical setup we're using AC_DEFUN([PANDORA_CANONICAL_VERSION],[0.175]) AC_DEFUN([PANDORA_BLOCK_BAD_OPTIONS],[ AS_IF([test "x${prefix}" = "x"],[ AC_MSG_ERROR([--prefix requires an argument]) ]) ]) dnl The standard setup for how we build Pandora projects AC_DEFUN([PANDORA_CANONICAL_TARGET],[ ifdef([m4_define],,[define([m4_define], defn([define]))]) ifdef([m4_undefine],,[define([m4_undefine], defn([undefine]))]) m4_define([PCT_ALL_ARGS],[$*]) m4_define([PCT_REQUIRE_CXX],[no]) m4_define([PCT_FORCE_GCC42],[no]) m4_define([PCT_DONT_SUPPRESS_INCLUDE],[no]) m4_define([PCT_NO_VC_CHANGELOG],[no]) m4_define([PCT_VERSION_FROM_VC],[no]) m4_define([PCT_USE_VISIBILITY],[yes]) m4_foreach([pct_arg],[$*],[ m4_case(pct_arg, [require-cxx], [ m4_undefine([PCT_REQUIRE_CXX]) m4_define([PCT_REQUIRE_CXX],[yes]) ], [force-gcc42], [ m4_undefine([PCT_FORCE_GCC42]) m4_define([PCT_FORCE_GCC42],[yes]) ], [skip-visibility], [ m4_undefine([PCT_USE_VISIBILITY]) m4_define([PCT_USE_VISIBILITY],[no]) ], [dont-suppress-include], [ m4_undefine([PCT_DONT_SUPPRESS_INCLUDE]) m4_define([PCT_DONT_SUPPRESS_INCLUDE],[yes]) ], [no-vc-changelog], [ m4_undefine([PCT_NO_VC_CHANGELOG]) m4_define([PCT_NO_VC_CHANGELOG],[yes]) ], [version-from-vc], [ m4_undefine([PCT_VERSION_FROM_VC]) m4_define([PCT_VERSION_FROM_VC],[yes]) ]) ]) PANDORA_BLOCK_BAD_OPTIONS # We need to prevent canonical target # from injecting -O2 into CFLAGS - but we won't modify anything if we have # set CFLAGS on the command line, since that should take ultimate precedence AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"], [CFLAGS=""]) AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"], [CXXFLAGS=""]) AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability subdir-objects foreign tar-ustar]) m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[ gl_EARLY ],[ PANDORA_EXTENSIONS ]) AC_REQUIRE([AC_PROG_CC]) m4_if(PCT_FORCE_GCC42, [yes], [ AC_REQUIRE([PANDORA_ENSURE_GCC_VERSION]) ]) AC_REQUIRE([PANDORA_64BIT]) m4_if(PCT_NO_VC_CHANGELOG,yes,[ vc_changelog=no ],[ vc_changelog=yes ]) m4_if(PCT_VERSION_FROM_VC,yes,[ PANDORA_VC_INFO_HEADER ],[ PANDORA_TEST_VC_DIR changequote(<<, >>)dnl PANDORA_RELEASE_ID=`echo $VERSION | sed 's/[^0-9]//g'` changequote([, ])dnl PANDORA_RELEASE_COMMENT="" AC_DEFINE_UNQUOTED([PANDORA_RELEASE_VERSION],["$VERSION"], [Version of the software]) AC_SUBST(PANDORA_RELEASE_COMMENT) AC_SUBST(PANDORA_RELEASE_VERSION) AC_SUBST(PANDORA_RELEASE_ID) ]) PANDORA_VERSION dnl Once we can use a modern autoconf, we can use this dnl AC_PROG_CC_C99 AC_REQUIRE([AC_PROG_CXX]) PANDORA_EXTENSIONS AM_PROG_CC_C_O PANDORA_PLATFORM dnl autoconf doesn't automatically provide a fail-if-no-C++ macro dnl so we check c++98 features and fail if we don't have them, mainly dnl for that reason m4_if(PCT_REQUIRE_CXX, [yes], [ AS_IF([test "$ac_cv_cxx_stdcxx_98" = "no"],[ AC_MSG_ERROR([No working C++ Compiler has been found. ${PACKAGE} requires a C++ compiler that can handle C++98]) ]) ]) m4_if(m4_substr(m4_esyscmd(test -d gnulib && echo 0),0,1),0,[ gl_INIT AC_CONFIG_LIBOBJ_DIR([gnulib]) ]) PANDORA_CHECK_C_VERSION PANDORA_CHECK_CXX_VERSION AC_HEADER_TIME AC_STRUCT_TM AC_TYPE_SIZE_T AC_SYS_LARGEFILE PANDORA_CLOCK_GETTIME AC_CHECK_HEADERS(sys/socket.h) # off_t is not a builtin type AC_CHECK_SIZEOF(off_t, 4) AS_IF([test "$ac_cv_sizeof_off_t" -eq 0],[ AC_MSG_ERROR("${PACKAGE} needs an off_t type.") ]) AC_CHECK_SIZEOF(size_t) AS_IF([test "$ac_cv_sizeof_size_t" -eq 0],[ AC_MSG_ERROR("${PACKAGE} needs an size_t type.") ]) AC_DEFINE_UNQUOTED([SIZEOF_SIZE_T],[$ac_cv_sizeof_size_t],[Size of size_t as computed by sizeof()]) AC_CHECK_SIZEOF(long long) AC_DEFINE_UNQUOTED([SIZEOF_LONG_LONG],[$ac_cv_sizeof_long_long],[Size of long long as computed by sizeof()]) AC_CACHE_CHECK([if time_t is unsigned], [ac_cv_time_t_unsigned],[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[ #include ]], [[ int array[(((time_t)-1) > 0) ? 1 : -1]; ]]) ],[ ac_cv_time_t_unsigned=yes ],[ ac_cv_time_t_unsigned=no ]) ]) AS_IF([test "$ac_cv_time_t_unsigned" = "yes"],[ AC_DEFINE([TIME_T_UNSIGNED], 1, [Define to 1 if time_t is unsigned]) ]) AC_CHECK_FUNC(setsockopt, [], [AC_CHECK_LIB(socket, setsockopt)]) AC_CHECK_FUNC(bind, [], [AC_CHECK_LIB(bind, bind)]) PANDORA_OPTIMIZE PANDORA_HAVE_GCC_ATOMICS PANDORA_HEADER_ASSERT PANDORA_WARNINGS(PCT_ALL_ARGS) PANDORA_ENABLE_DTRACE AC_LIB_PREFIX PANDORA_HAVE_BETTER_MALLOC AC_CHECK_PROGS([PERL], [perl]) AC_CHECK_PROGS([DPKG_GENSYMBOLS], [dpkg-gensymbols], [:]) AC_CHECK_PROGS([LCOV], [lcov], [echo lcov not found]) AC_CHECK_PROGS([LCOV_GENHTML], [genhtml], [echo genhtml not found]) AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build], [:]) AS_IF([test "x${SPHINXBUILD}" != "x:"],[ AC_CACHE_CHECK([if sphinx is new enough],[ac_cv_recent_sphinx],[ ${SPHINXBUILD} -Q -C -b man -d conftest.d . . >/dev/null 2>&1 AS_IF([test $? -eq 0],[ac_cv_recent_sphinx=yes], [ac_cv_recent_sphinx=no]) rm -rf conftest.d ]) ]) AM_CONDITIONAL(HAVE_DPKG_GENSYMBOLS,[test "x${DPKG_GENSYMBOLS}" != "x:"]) AM_CONDITIONAL(HAVE_SPHINX,[test "x${SPHINXBUILD}" != "x:"]) AM_CONDITIONAL(HAVE_RECENT_SPHINX,[test "x${ac_cv_recent_sphinx}" = "xyes"]) m4_if(m4_substr(m4_esyscmd(test -d src && echo 0),0,1),0,[ AM_CPPFLAGS="-I\$(top_srcdir)/src -I\$(top_builddir)/src ${AM_CPPFLAGS}" ],[ AM_CPPFLAGS="-I\$(top_srcdir) -I\$(top_builddir) ${AM_CPPFLAGS}" ]) PANDORA_USE_PIPE AM_CFLAGS="-std=c99 ${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}" AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}" AC_SUBST([AM_CFLAGS]) AC_SUBST([AM_CXXFLAGS]) AC_SUBST([AM_CPPFLAGS]) AC_SUBST([AM_LDFLAGS]) ]) libmemcached-1.0.8/m4/ltsugar.m40000644000076400007640000001042411753633364016654 0ustar00brianbrian00000000000000# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59 which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) libmemcached-1.0.8/m4/pandora_warnings.m40000664000076400007640000004011111753573717020532 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl AC_PANDORA_WARNINGS([less-warnings|warnings-always-on]) dnl less-warnings turn on a limited set of warnings dnl warnings-always-on always set warnings=error regardless of tarball/vc dnl @TODO: remove less-warnings option as soon as Drizzle is clean enough to dnl allow it AC_DEFUN([PANDORA_WARNINGS],[ m4_define([PW_LESS_WARNINGS],[no]) m4_define([PW_WARN_ALWAYS_ON],[no]) ifdef([m4_define],,[define([m4_define], defn([define]))]) ifdef([m4_undefine],,[define([m4_undefine], defn([undefine]))]) m4_foreach([pw_arg],[$*],[ m4_case(pw_arg, [less-warnings],[ m4_undefine([PW_LESS_WARNINGS]) m4_define([PW_LESS_WARNINGS],[yes]) ], [warnings-always-on],[ m4_undefine([PW_WARN_ALWAYS_ON]) m4_define([PW_WARN_ALWAYS_ON],[yes]) ]) ]) m4_if(PW_WARN_ALWAYS_ON, [yes], [ac_cv_warnings_as_errors=yes], AS_IF([test "$pandora_building_from_vc" = "yes"], [ac_cv_warnings_as_errors=yes], [ac_cv_warnings_as_errors=no])) AC_ARG_ENABLE([gcc-profile-mode], [AS_HELP_STRING([--enable-gcc-profile-mode], [Toggle gcc profile mode @<:@default=off@:>@])], [ac_gcc_profile_mode="$enableval"], [ac_gcc_profile_mode="no"]) AC_ARG_ENABLE([profiling], [AS_HELP_STRING([--enable-profiling], [Toggle profiling @<:@default=off@:>@])], [ac_profiling="$enableval"], [ac_profiling="no"]) AC_ARG_ENABLE([coverage], [AS_HELP_STRING([--enable-coverage], [Toggle coverage @<:@default=off@:>@])], [ac_coverage="$enableval"], [ac_coverage="no"]) AS_IF([test "$GCC" = "yes"],[ AS_IF([test "$ac_profiling" = "yes"],[ CC_PROFILING="-pg" GCOV_LIBS="-pg -lgcov" save_LIBS="${LIBS}" LIBS="" AC_CHECK_LIB(c_p, read) LIBC_P="${LIBS}" LIBS="${save_LIBS}" AC_SUBST(LIBC_P) ],[ CC_PROFILING=" " ]) AS_IF([test "$ac_coverage" = "yes"], [ CC_COVERAGE="--coverage" GCOV_LIBS="-lgcov" ]) AS_IF([test "$ac_cv_warnings_as_errors" = "yes"],[ W_FAIL="-Werror" SPHINX_WARNINGS="-W -n" INTLTOOL_WARNINGS="yes" ]) AC_CACHE_CHECK([whether it is safe to use -fdiagnostics-show-option], [ac_cv_safe_to_use_fdiagnostics_show_option_], [save_CFLAGS="$CFLAGS" CFLAGS="-fdiagnostics-show-option ${AM_CFLAGS} ${CFLAGS}" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([],[])], [ac_cv_safe_to_use_fdiagnostics_show_option_=yes], [ac_cv_safe_to_use_fdiagnostics_show_option_=no]) CFLAGS="$save_CFLAGS"]) AS_IF([test "$ac_cv_safe_to_use_fdiagnostics_show_option_" = "yes"], [ F_DIAGNOSTICS_SHOW_OPTION="-fdiagnostics-show-option" ]) AC_CACHE_CHECK([whether it is safe to use -floop-parallelize-all], [ac_cv_safe_to_use_floop_parallelize_all_], [save_CFLAGS="$CFLAGS" CFLAGS="-floop-parallelize-all ${AM_CFLAGS} ${CFLAGS}" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([],[])], [ac_cv_safe_to_use_floop_parallelize_all_=yes], [ac_cv_safe_to_use_floop_parallelize_all_=no]) CFLAGS="$save_CFLAGS"]) AS_IF([test "$ac_cv_safe_to_use_floop_parallelize_all_" = "yes"], [ F_LOOP_PARALLELIZE_ALL="-floop-parallelize-all" ]) NO_STRICT_ALIASING="-fno-strict-aliasing -Wno-strict-aliasing" NO_SHADOW="-Wno-shadow" AS_IF([test "$INTELCC" = "yes"],[ m4_if(PW_LESS_WARNINGS,[no],[ BASE_WARNINGS="-w1 -Werror -Wcheck -Wp64 -Woverloaded-virtual -Wcast-qual -diag-disable 188" ],[ dnl 2203 is like old-style-cast dnl 1684 is like strict-aliasing dnl 188 is about using enums as bitfields dnl 1683 is a warning about _EXPLICIT_ casting, which we want BASE_WARNINGS="-w1 -Werror -Wcheck -Wp64 -Woverloaded-virtual -Wcast-qual -diag-disable 188,981,2259,2203,1683,1684" ]) CC_WARNINGS="${BASE_WARNINGS}" CXX_WARNINGS="${BASE_WARNINGS}" PROTOSKIP_WARNINGS="-diag-disable 188,981,967,2259,1683,1684,2203" ],[ m4_if(PW_LESS_WARNINGS,[no],[ BASE_WARNINGS_FULL="${W_CONVERSION} -Wstrict-aliasing -Wswitch-enum " CC_WARNINGS_FULL="-Wswitch-default -Wswitch-enum -Wwrite-strings" CXX_WARNINGS_FULL="" NO_OLD_STYLE_CAST="-Wno-old-style-cast" NO_EFF_CXX="-Wno-effc++" ],[ BASE_WARNINGS_FULL="${NO_STRICT_ALIASING}" ]) AS_IF([test "${ac_cv_assert}" = "no"], [NO_UNUSED="-Wno-unused-variable -Wno-unused-parameter"]) AC_CACHE_CHECK([whether it is safe to use -Wextra], [ac_cv_safe_to_use_Wextra_], [save_CFLAGS="$CFLAGS" CFLAGS="${W_FAIL} -pedantic -Wextra ${AM_CFLAGS} ${CFLAGS}" AC_COMPILE_IFELSE([ AC_LANG_PROGRAM( [[ #include ]], [[]]) ], [ac_cv_safe_to_use_Wextra_=yes], [ac_cv_safe_to_use_Wextra_=no]) CFLAGS="$save_CFLAGS"]) BASE_WARNINGS="${W_FAIL} -pedantic -Wall -Wundef -Wshadow -Wparentheses ${NO_UNUSED} ${F_DIAGNOSTICS_SHOW_OPTION} ${F_LOOP_PARALLELIZE_ALL} ${BASE_WARNINGS_FULL}" AS_IF([test "$ac_cv_safe_to_use_Wextra_" = "yes"], [BASE_WARNINGS="${BASE_WARNINGS} -Wextra"], [BASE_WARNINGS="${BASE_WARNINGS} -W"]) AC_CACHE_CHECK([whether it is safe to use -Wformat], [ac_cv_safe_to_use_wformat_], [save_CFLAGS="$CFLAGS" dnl Use -Werror here instead of ${W_FAIL} so that we don't spew dnl conversion warnings to all the tarball folks CFLAGS="-Wformat -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[ #include #include #include void foo(); void foo() { uint64_t test_u= 0; printf("This is a %" PRIu64 "test\n", test_u); } ]],[[ foo(); ]])], [ac_cv_safe_to_use_wformat_=yes], [ac_cv_safe_to_use_wformat_=no]) CFLAGS="$save_CFLAGS"]) AS_IF([test "$ac_cv_safe_to_use_wformat_" = "yes"],[ BASE_WARNINGS="${BASE_WARNINGS} -Wformat -Wno-format-nonliteral -Wformat-security" BASE_WARNINGS_FULL="${BASE_WARNINGS_FULL} -Wformat=2 -Wno-format-nonliteral -Wformat-security" ],[ BASE_WARNINGS="${BASE_WARNINGS} -Wno-format" BASE_WARNINGS_FULL="${BASE_WARNINGS_FULL} -Wno-format" ]) AC_CACHE_CHECK([whether it is safe to use -Wconversion], [ac_cv_safe_to_use_wconversion_], [save_CFLAGS="$CFLAGS" dnl Use -Werror here instead of ${W_FAIL} so that we don't spew dnl conversion warnings to all the tarball folks CFLAGS="-Wconversion -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[ #include void foo(bool a) { (void)a; } ]],[[ foo(0); ]])], [ac_cv_safe_to_use_wconversion_=yes], [ac_cv_safe_to_use_wconversion_=no]) CFLAGS="$save_CFLAGS"]) AS_IF([test "$ac_cv_safe_to_use_wconversion_" = "yes"], [W_CONVERSION="-Wconversion" AC_CACHE_CHECK([whether it is safe to use -Wconversion with htons], [ac_cv_safe_to_use_Wconversion_], [save_CFLAGS="$CFLAGS" dnl Use -Werror here instead of ${W_FAIL} so that we don't spew dnl conversion warnings to all the tarball folks CFLAGS="-Wconversion -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[ #include ]],[[ uint16_t x= htons(80); ]])], [ac_cv_safe_to_use_Wconversion_=yes], [ac_cv_safe_to_use_Wconversion_=no]) CFLAGS="$save_CFLAGS"]) AS_IF([test "$ac_cv_safe_to_use_Wconversion_" = "no"], [NO_CONVERSION="-Wno-conversion"]) ]) CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wmissing-declarations -Wcast-align -Wsign-compare ${CC_WARNINGS_FULL}" CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long -Wsign-compare ${CXX_WARNINGS_FULL}" AC_CACHE_CHECK([whether it is safe to use -Wmissing-declarations from C++], [ac_cv_safe_to_use_Wmissing_declarations_], [AC_LANG_PUSH(C++) save_CXXFLAGS="$CXXFLAGS" CXXFLAGS="-Werror -pedantic -Wmissing-declarations ${AM_CXXFLAGS}" AC_COMPILE_IFELSE([ AC_LANG_PROGRAM( [[ #include ]], [[]]) ], [ac_cv_safe_to_use_Wmissing_declarations_=yes], [ac_cv_safe_to_use_Wmissing_declarations_=no]) CXXFLAGS="$save_CXXFLAGS" AC_LANG_POP() ]) AS_IF([test "$ac_cv_safe_to_use_Wmissing_declarations_" = "yes"], [CXX_WARNINGS="${CXX_WARNINGS} -Wmissing-declarations"]) AC_CACHE_CHECK([whether it is safe to use -Wframe-larger-than], [ac_cv_safe_to_use_Wframe_larger_than_], [AC_LANG_PUSH(C++) save_CXXFLAGS="$CXXFLAGS" CXXFLAGS="-Werror -pedantic -Wframe-larger-than=32768 ${AM_CXXFLAGS}" AC_COMPILE_IFELSE([ AC_LANG_PROGRAM( [[ #include ]], [[]]) ], [ac_cv_safe_to_use_Wframe_larger_than_=yes], [ac_cv_safe_to_use_Wframe_larger_than_=no]) CXXFLAGS="$save_CXXFLAGS" AC_LANG_POP() ]) AS_IF([test "$ac_cv_safe_to_use_Wframe_larger_than_" = "yes"], [CXX_WARNINGS="${CXX_WARNINGS} -Wframe-larger-than=32768"]) AC_CACHE_CHECK([whether it is safe to use -Wlogical-op], [ac_cv_safe_to_use_Wlogical_op_], [save_CFLAGS="$CFLAGS" CFLAGS="${W_FAIL} -pedantic -Wlogical-op ${AM_CFLAGS} ${CFLAGS}" AC_COMPILE_IFELSE([ AC_LANG_PROGRAM( [[ #include ]], [[]]) ], [ac_cv_safe_to_use_Wlogical_op_=yes], [ac_cv_safe_to_use_Wlogical_op_=no]) CFLAGS="$save_CFLAGS"]) AS_IF([test "$ac_cv_safe_to_use_Wlogical_op_" = "yes"], [CC_WARNINGS="${CC_WARNINGS} -Wlogical-op"]) AC_CACHE_CHECK([whether it is safe to use -Wredundant-decls from C++], [ac_cv_safe_to_use_Wredundant_decls_], [AC_LANG_PUSH(C++) save_CXXFLAGS="${CXXFLAGS}" CXXFLAGS="${W_FAIL} -pedantic -Wredundant-decls ${AM_CXXFLAGS}" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([ template struct C { void foo(); }; template void C::foo() { } template <> void C::foo(); AC_INCLUDES_DEFAULT])], [ac_cv_safe_to_use_Wredundant_decls_=yes], [ac_cv_safe_to_use_Wredundant_decls_=no]) CXXFLAGS="${save_CXXFLAGS}" AC_LANG_POP()]) AS_IF([test "$ac_cv_safe_to_use_Wredundant_decls_" = "yes"], [CXX_WARNINGS="${CXX_WARNINGS} -Wredundant-decls"], [CXX_WARNINGS="${CXX_WARNINGS} -Wno-redundant-decls"]) AC_CACHE_CHECK([whether it is safe to use -Wattributes from C++], [ac_cv_safe_to_use_Wattributes_], [AC_LANG_PUSH(C++) save_CXXFLAGS="${CXXFLAGS}" CXXFLAGS="${W_FAIL} -pedantic -Wattributes -fvisibility=hidden ${AM_CXXFLAGS}" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([ #include #include const ::google::protobuf::EnumDescriptor* Table_TableOptions_RowType_descriptor(); enum Table_TableOptions_RowType { Table_TableOptions_RowType_ROW_TYPE_DEFAULT = 0, Table_TableOptions_RowType_ROW_TYPE_FIXED = 1, Table_TableOptions_RowType_ROW_TYPE_DYNAMIC = 2, Table_TableOptions_RowType_ROW_TYPE_COMPRESSED = 3, Table_TableOptions_RowType_ROW_TYPE_REDUNDANT = 4, Table_TableOptions_RowType_ROW_TYPE_COMPACT = 5, Table_TableOptions_RowType_ROW_TYPE_PAGE = 6 }; namespace google { namespace protobuf { template <> inline const EnumDescriptor* GetEnumDescriptor() { return Table_TableOptions_RowType_descriptor(); } } } ])], [ac_cv_safe_to_use_Wattributes_=yes], [ac_cv_safe_to_use_Wattributes_=no]) CXXFLAGS="${save_CXXFLAGS}" AC_LANG_POP()]) AC_CACHE_CHECK([whether it is safe to use -Wno-attributes], [ac_cv_safe_to_use_Wno_attributes_], [save_CFLAGS="$CFLAGS" CFLAGS="${W_FAIL} -pedantic -Wno_attributes_ ${AM_CFLAGS} ${CFLAGS}" AC_COMPILE_IFELSE([ AC_LANG_PROGRAM( [[ #include ]], [[]]) ], [ac_cv_safe_to_use_Wno_attributes_=yes], [ac_cv_safe_to_use_Wno_attributes_=no]) CFLAGS="$save_CFLAGS"]) dnl GCC 3.4 doesn't have -Wno-attributes, so we can't turn them off dnl by using that. AS_IF([test "$ac_cv_safe_to_use_Wattributes_" != "yes"],[ AS_IF([test "$ac_cv_safe_to_use_Wno_attributes_" = "yes"],[ CC_WARNINGS="${CC_WARNINGS} -Wno-attributes" NO_ATTRIBUTES="-Wno-attributes"])]) NO_REDUNDANT_DECLS="-Wno-redundant-decls" dnl TODO: Figure out a better way to deal with this: PROTOSKIP_WARNINGS="-Wno-effc++ -Wno-shadow -Wno-missing-braces ${NO_ATTRIBUTES}" NO_WERROR="-Wno-error" PERMISSIVE_WARNINGS="-Wno-error -Wno-unused-function -fpermissive" PERMISSIVE_C_WARNINGS="-Wno-error -Wno-redundant-decls" AS_IF([test "$host_vendor" = "apple"],[ BOOSTSKIP_WARNINGS="-Wno-uninitialized" ]) ]) ]) AS_IF([test "$SUNCC" = "yes"],[ AS_IF([test "$ac_profiling" = "yes"], [CC_PROFILING="-xinstrument=datarace"]) AS_IF([test "$ac_cv_warnings_as_errors" = "yes"], [W_FAIL="-errwarn=%all"]) AC_CACHE_CHECK([whether E_PASTE_RESULT_NOT_TOKEN is usable], [ac_cv_paste_result], [ save_CFLAGS="${CFLAGS}" CFLAGS="-errwarn=%all -erroff=E_PASTE_RESULT_NOT_TOKEN ${CFLAGS}" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([ AC_INCLUDES_DEFAULT ],[ int x= 0;])], [ac_cv_paste_result=yes], [ac_cv_paste_result=no]) CFLAGS="${save_CFLAGS}" ]) AS_IF([test $ac_cv_paste_result = yes], [W_PASTE_RESULT=",E_PASTE_RESULT_NOT_TOKEN"]) m4_if(PW_LESS_WARNINGS, [no],[ CC_WARNINGS_FULL="-erroff=E_STATEMENT_NOT_REACHED,E_INTEGER_OVERFLOW_DETECTED${W_PASTE_RESULT}" CXX_WARNINGS_FULL="-erroff=inllargeuse" ],[ CC_WARNINGS_FULL="-erroff=E_ATTRIBUTE_NOT_VAR,E_STATEMENT_NOT_REACHED" CXX_WARNINGS_FULL="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint" ]) CC_WARNINGS="-v -errtags=yes ${W_FAIL} ${CC_WARNINGS_FULL}" CXX_WARNINGS="+w +w2 -xwe -xport64 -errtags=yes ${CXX_WARNINGS_FULL} ${W_FAIL}" PROTOSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn,partinit,notused,badargtype2w,wbadinit" BOOSTSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint,hidef,wvarhidenmem" PERMISSIVE_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint,hidef,wvarhidenmem,notused,badargtype2w,wunreachable" INNOBASE_SKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn,partinit,notused,badargtype2w,wbadinit,wunreachable" NO_UNREACHED="-erroff=E_STATEMENT_NOT_REACHED" NO_WERROR="-errwarn=%none" ]) AC_SUBST(NO_CONVERSION) AC_SUBST(NO_REDUNDANT_DECLS) AC_SUBST(NO_UNREACHED) AC_SUBST(NO_SHADOW) AC_SUBST(NO_STRICT_ALIASING) AC_SUBST(NO_EFF_CXX) AC_SUBST(NO_OLD_STYLE_CAST) AC_SUBST(PROTOSKIP_WARNINGS) AC_SUBST(INNOBASE_SKIP_WARNINGS) AC_SUBST(BOOSTSKIP_WARNINGS) AC_SUBST(PERMISSIVE_WARNINGS) AC_SUBST(PERMISSIVE_C_WARNINGS) AC_SUBST(NO_WERROR) AC_SUBST([GCOV_LIBS]) AC_SUBST([SPHINX_WARNINGS]) AC_SUBST([INTLTOOL_WARNINGS]) ]) libmemcached-1.0.8/m4/fnv.m40000664000076400007640000000136511753573717015777 0ustar00brianbrian00000000000000dnl --------------------------------------------------------------------------- dnl Macro: ENABLE_FNV64_HASH dnl --------------------------------------------------------------------------- AC_DEFUN([ENABLE_FNV64_HASH], [AC_ARG_ENABLE([fnv64_hash], [AS_HELP_STRING([--disable-fnv64_hash], [build with support for fnv64 hashing. @<:@default=on@:>@])], [ac_cv_enable_fnv64_hash=no], [ac_cv_enable_fnv64_hash=yes]) AS_IF([test "$ac_cv_enable_fnv64_hash" = "yes"], [AC_DEFINE([HAVE_FNV64_HASH], [1], [Enables fnv64 hashing support])]) ]) dnl --------------------------------------------------------------------------- dnl End Macro: ENABLE_FNV64_HASH dnl --------------------------------------------------------------------------- libmemcached-1.0.8/m4/ax_sasl.m40000664000076400007640000000265611753573717016644 0ustar00brianbrian00000000000000# =========================================================================== # http://www.tangent.org/ # =========================================================================== # # SYNOPSIS # # AX_SASL # # DESCRIPTION # # Check for sasl version one or two support. # # LICENSE # # Copyright (c) 2012 Brian Aker # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 1 AC_DEFUN([AX_SASL_OPTION],[ AC_REQUIRE([AX_SASL_CHECK]) AC_ARG_ENABLE([sasl], [AS_HELP_STRING([--disable-sasl], [Build with sasl support @<:@default=on@:>@])], [ac_enable_sasl="$enableval"], [ac_enable_sasl="yes"]) AS_IF([test "x$ac_enable_sasl" = "xyes"], [ac_enable_sasl="yes"], [ac_enable_sasl="no"]) AS_IF([test "x$ac_enable_sasl" = "xyes"], [ AC_DEFINE([HAVE_LIBSASL], [ 1 ], [Have libsasl2]) ], [ AC_DEFINE([HAVE_LIBSASL], [ 0 ], [Have libsasl2]) ]) AM_CONDITIONAL(HAVE_SASL, test "x${ac_enable_sasl}" = "xyes") ]) AC_DEFUN([AX_SASL_CHECK],[ AX_CHECK_LIBRARY([LIBSASL], [sasl/sasl.h], [sasl2],[ LIBSASL_LDFLAGS="-lsasl2" ax_cv_sasl=yes ], [ ax_cv_sasl=no ]) AM_CONDITIONAL(HAVE_SASL, test "x${ac_enable_sasl}" = "xyes") ]) libmemcached-1.0.8/m4/pandora_stack_direction.m40000664000076400007640000000176311753573717022061 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems dnl This file is free software; Sun Microsystems dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. #-------------------------------------------------------------------- # Check what direction the stack runs in #-------------------------------------------------------------------- AC_DEFUN([PANDORA_STACK_DIRECTION],[ AC_REQUIRE([AC_FUNC_ALLOCA]) AC_CACHE_CHECK([stack direction], [ac_cv_c_stack_direction],[ AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include int find_stack_direction () { static char *addr = 0; auto char dummy; if (addr == 0) { addr = &dummy; return find_stack_direction (); } else return (&dummy > addr) ? 1 : -1; } ]],[[ exit (find_stack_direction() < 0); ]])],[ ac_cv_c_stack_direction=1 ],[ ac_cv_c_stack_direction=-1 ]) ]) AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction) ]) libmemcached-1.0.8/m4/memaslap.m40000664000076400007640000000045411753573717017003 0ustar00brianbrian00000000000000AC_DEFUN([ENABLE_MEMASLAP], [AC_ARG_ENABLE([memaslap], [AS_HELP_STRING([--enable-memaslap], [build with memaslap tool. @<:@default=off@:>@])], [ac_cv_enable_memaslap=yes], [ac_cv_enable_memaslap=no]) AM_CONDITIONAL([BUILD_MEMASLAP], [test "$ac_cv_enable_memaslap" = "yes"]) ]) libmemcached-1.0.8/m4/pandora_platform.m40000664000076400007640000001002211753573717020524 0ustar00brianbrian00000000000000dnl -*- mode: m4; c-basic-offset: 2; indent-tabs-mode: nil; -*- dnl vim:expandtab:shiftwidth=2:tabstop=2:smarttab: dnl dnl pandora-build: A pedantic build system dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl From Monty Taylor AC_DEFUN([PANDORA_PLATFORM],[ dnl Canonicalize the configuration name. AC_DEFINE_UNQUOTED([HOST_VENDOR], ["$host_vendor"],[Vendor of Build System]) AC_DEFINE_UNQUOTED([HOST_OS], ["$host_os"], [OS of Build System]) AC_DEFINE_UNQUOTED([HOST_CPU], ["$host_cpu"], [CPU of Build System]) AC_DEFINE_UNQUOTED([TARGET_VENDOR], ["$target_vendor"],[Vendor of Target System]) AC_DEFINE_UNQUOTED([TARGET_OS], ["$target_os"], [OS of Target System]) AC_DEFINE_UNQUOTED([TARGET_CPU], ["$target_cpu"], [CPU of Target System]) case "$host_os" in *solaris*) AS_IF([test "x${ac_cv_env_CPPFLAGS_set}" = "x"],[ CPPFLAGS="${CPPFLAGS} -I/usr/local/include" ]) AS_IF([test "x${ac_cv_env_LDFLAGS_set}" = "x"],[ LDFLAGS="${LDFLAGS} -L/usr/local/lib" ]) ;; *freebsd*) AS_IF([test "x${ac_cv_env_CPPFLAGS_set}" = "x"],[ CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include" ]) AS_IF([test "x${ac_cv_env_LDFLAGS_set}" = "x"],[ LDFLAGS="${LDFLAGS} -L/usr/local/lib" ]) ;; esac PANDORA_OPTIMIZE_BITFIELD=1 case "$target_os" in *linux*) TARGET_LINUX="true" AC_SUBST(TARGET_LINUX) AC_DEFINE([TARGET_OS_LINUX], [1], [Whether we build for Linux]) ;; *darwin*) TARGET_OSX="true" AC_SUBST(TARGET_OSX) AC_DEFINE([TARGET_OS_OSX], [1], [Whether we build for OSX]) ;; *solaris*) TARGET_SOLARIS="true" PANDORA_OPTIMIZE_BITFIELD=0 AS_IF([test "x${USE_NLS}" = "xyes"],[LIBS="${LIBS} -lintl"]) AC_SUBST(TARGET_SOLARIS) AC_DEFINE([TARGET_OS_SOLARIS], [1], [Whether we are building for Solaris]) ;; *freebsd*) TARGET_FREEBSD="true" AC_SUBST(TARGET_FREEBSD) AC_DEFINE([TARGET_OS_FREEBSD], [1], [Whether we are building for FreeBSD]) AC_DEFINE([__APPLE_CC__],[1],[Workaround for bug in FreeBSD headers]) ;; *mingw32*) TARGET_WINDOWS="true" AC_SUBST(TARGET_WINDOWS) AC_DEFINE([TARGET_OS_WINDOWS], [1], [Whether we are building for Windows]) AC_DEFINE([WINVER], [WindowsXP], [Version of Windows]) AC_DEFINE([_WIN32_WINNT], [0x0501], [Magical number to make things work]) AC_DEFINE([EAI_SYSTEM], [11], [Another magical number]) AH_BOTTOM([ #ifndef HAVE_SYS_SOCKET_H # define SHUT_RD SD_RECEIVE # define SHUT_WR SD_SEND # define SHUT_RDWR SD_BOTH #endif ]) LIBS="$LIBS -lwsock32 -lws2_32" AM_CFLAGS="${AM_CFLAGS} -I\${top_srcdir}/win32/mingw -I\${top_builddir}/win32/mingw -I\${top_srcdir}/win32 -I\${top_builddir}/win32" ;; esac AM_CONDITIONAL(BUILD_WIN32, [test "x${TARGET_WINDOWS}" = "xtrue"]) AM_CONDITIONAL(TARGET_OSX, [test "x${TARGET_OSX}" = "xtrue"]) AM_CONDITIONAL(TARGET_LINUX, [test "x${TARGET_LINUX}" = "xtrue"]) AC_SUBST(PANDORA_OPTIMIZE_BITFIELD) AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) AC_CHECK_DECL([__ICC], [INTELCC="yes"], [INTELCC="no"]) AS_IF([test "$INTELCC" = "yes"], [enable_rpath=no]) dnl By default, Sun Studio grabs special versions of limits.h and string.h dnl when you use and . By setting this define, we can dnl disable that and cause those to wrap the standard headers instead. dnl http://www.stlport.com/doc/configure.html AS_IF([test "$SUNCC" = "yes"],[ AC_DEFINE([_STLP_NO_NEW_C_HEADERS],[1], [Cause Sun Studio to not be quite so strict with standards conflicts]) ]) AS_IF([test "x$TARGET_OSX" = "xtrue"],[ AS_IF([test "x$ac_enable_fat_binaries" = "xyes"],[ AM_CFLAGS="-arch i386 -arch x86_64 -arch ppc" AM_CXXFLAGS="-arch i386 -arch x86_64 -arch ppc" AM_LDFLAGS="-arch i386 -arch x86_64 -arch ppc" ]) ]) ]) libmemcached-1.0.8/m4/pandora_have_libpcre.m40000664000076400007640000000352711753573717021337 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. #-------------------------------------------------------------------- # Check for libpcre #-------------------------------------------------------------------- AC_DEFUN([_PANDORA_SEARCH_LIBPCRE],[ AC_REQUIRE([AC_LIB_PREFIX]) AC_LIB_HAVE_LINKFLAGS(pcre,, [#include ], [ pcre *re= NULL; pcre_version(); ]) AS_IF([test "x$ac_cv_libpcre" = "xno"], [ unset ac_cv_libpcre unset HAVE_LIBPCRE unset LIBPCRE unset LIBPCRE_PREFIX unset LTLIBPCRE AC_LIB_HAVE_LINKFLAGS(pcre,, [#include ], [ pcre *re= NULL; pcre_version(); ]) AS_IF([test "x$ac_cv_libpcre" = "xyes"], [ ac_cv_pcre_location="" ]) ],[ ac_cv_pcre_location="" ]) AM_CONDITIONAL(HAVE_LIBPCRE, [test "x${ac_cv_libpcre}" = "xyes"]) ]) AC_DEFUN([_PANDORA_HAVE_LIBPCRE],[ AC_ARG_ENABLE([libpcre], [AS_HELP_STRING([--disable-libpcre], [Build with libpcre support @<:@default=on@:>@])], [ac_enable_libpcre="$enableval"], [ac_enable_libpcre="yes"]) _PANDORA_SEARCH_LIBPCRE ]) AC_DEFUN([PANDORA_HAVE_LIBPCRE],[ AC_REQUIRE([_PANDORA_HAVE_LIBPCRE]) ]) AC_DEFUN([_PANDORA_REQUIRE_LIBPCRE],[ ac_enable_libpcre="yes" _PANDORA_SEARCH_LIBPCRE AS_IF([test x$ac_cv_libpcre = xno],[ AC_MSG_ERROR([libpcre is required for ${PACKAGE}. On Debian this can be found in libpcre3-dev. On RedHat this can be found in pcre-devel.]) ],[ AC_DEFINE_UNQUOTED(PCRE_HEADER,[${ac_cv_pcre_location}], [Location of pcre header]) ]) ]) AC_DEFUN([PANDORA_REQUIRE_LIBPCRE],[ AC_REQUIRE([_PANDORA_REQUIRE_LIBPCRE]) ]) libmemcached-1.0.8/m4/pandora_extensions.m40000664000076400007640000000072611753573717021111 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([PANDORA_EXTENSIONS],[ m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], [AC_REQUIRE([AC_GNU_SOURCE])]) ]) AC_DEFUN([gl_USE_SYSTEM_EXTENSIONS],[ AC_REQUIRE([PANDORA_EXTENSIONS]) ]) libmemcached-1.0.8/m4/gearmand.m40000664000076400007640000000077011753573717016763 0ustar00brianbrian00000000000000AX_WITH_PROG(GEARMAND_BINARY,gearmand) AS_IF([test -f "$ac_cv_path_GEARMAND_BINARY"], [ AC_DEFINE([HAVE_GEARMAND_BINARY], [1], [If Gearmand binary is available]) AC_DEFINE_UNQUOTED([GEARMAND_BINARY], "$ac_cv_path_GEARMAND_BINARY", [Name of the gearmand binary used in make test]) ], [ AC_DEFINE([HAVE_GEARMAND_BINARY], [0], [If Gearmand binary is available]) AC_DEFINE([GEARMAND_BINARY], [0], [Name of the gearmand binary used in make test]) ]) libmemcached-1.0.8/m4/have_cstdint.m40000664000076400007640000000575511753573717017670 0ustar00brianbrian00000000000000# =========================================================================== # http://tangent.org/ # =========================================================================== # # SYNOPSIS # # AX_CXX_CSTDINT # # DESCRIPTION # # Example: # # LICENSE # # Copyright (c) 2012 Brian Aker` # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 1 AC_DEFUN([AX_CXX_CSTDINT], [ AC_REQUIRE([AC_PROG_CXX]) AC_REQUIRE([AC_PROG_CXXCPP]) AC_MSG_CHECKING(the location of cstdint) AC_LANG_PUSH([C++]) save_CXXFLAGS="${CXXFLAGS}" CXXFLAGS="${CXX_STANDARD} ${CXXFLAGS}" ac_cv_cxx_cstdint="" AC_LANG_PUSH([C++]) # AC_CACHE_CHECK([for location of cstdint], [ac_cv_cxx_cstdint], # [ # Look for cstdint AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], [ uint32_t t ])], [ac_cv_cxx_cstdint=""], [ # Look for tr1/cstdint AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], [ uint32_t t ])], [ac_cv_cxx_cstdint=""], [ # Look for boost/cstdint.hpp AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], [ uint32_t t ])], [ac_cv_cxx_cstdint=""]) ]) ]) # ]) AC_LANG_POP() CXXFLAGS="${save_CXXFLAGS}" if test -n "$ac_cv_cxx_cstdint"; then AC_MSG_RESULT([$ac_cv_cxx_cstdint]) else ac_cv_cxx_cstdint="" AC_MSG_WARN([Could not find a cstdint header.]) AC_MSG_RESULT([$ac_cv_cxx_cstdint]) fi AC_DEFINE_UNQUOTED(CSTDINT_H,$ac_cv_cxx_cstdint, [the location of ]) ]) libmemcached-1.0.8/m4/memcached.m40000664000076400007640000000103211753573717017103 0ustar00brianbrian00000000000000AX_WITH_PROG(MEMCACHED_BINARY, [memcached]) AS_IF([test -f "$ac_cv_path_MEMCACHED_BINARY"], [ AC_DEFINE([HAVE_MEMCACHED_BINARY], [1], [If Memcached binary is available]) AC_DEFINE_UNQUOTED([MEMCACHED_BINARY], "$ac_cv_path_MEMCACHED_BINARY", [Name of the memcached binary used in make test]) ], [ AC_DEFINE([HAVE_MEMCACHED_BINARY], [1], [If Memcached binary is available]) AC_DEFINE([MEMCACHED_BINARY], ["memcached/memcached"], [Name of the memcached binary used in make test]) ]) libmemcached-1.0.8/m4/pandora_have_gcc_atomics.m40000664000076400007640000000225311753573717022165 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. #-------------------------------------------------------------------- # Check for GCC Atomic Support #-------------------------------------------------------------------- AC_DEFUN([PANDORA_HAVE_GCC_ATOMICS],[ AC_CACHE_CHECK( [whether the compiler provides atomic builtins], [ac_cv_gcc_atomic_builtins], [AC_LINK_IFELSE( [AC_LANG_PROGRAM([],[[ int foo= -10; int bar= 10; if (!__sync_fetch_and_add(&foo, bar) || foo) return -1; bar= __sync_lock_test_and_set(&foo, bar); if (bar || foo != 10) return -1; bar= __sync_val_compare_and_swap(&bar, foo, 15); if (bar) return -1; return 0; ]])], [ac_cv_gcc_atomic_builtins=yes], [ac_cv_gcc_atomic_builtins=no])]) AS_IF([test "x$ac_cv_gcc_atomic_builtins" = "xyes"],[ AC_DEFINE(HAVE_GCC_ATOMIC_BUILTINS, 1, [Define to 1 if compiler provides atomic builtins.]) ]) ]) libmemcached-1.0.8/m4/pandora_fdatasync.m40000664000076400007640000000153211753573717020662 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. #-------------------------------------------------------------------- # Check for a working fdatasync call #-------------------------------------------------------------------- AC_DEFUN([PANDORA_WORKING_FDATASYNC],[ AC_CACHE_CHECK([working fdatasync],[ac_cv_func_fdatasync],[ AC_LANG_PUSH(C++) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ]],[[ fdatasync(4); ]])], [ac_cv_func_fdatasync=yes], [ac_cv_func_fdatasync=no]) AC_LANG_POP() ]) AS_IF([test "x${ac_cv_func_fdatasync}" = "xyes"], [AC_DEFINE([HAVE_FDATASYNC],[1],[If the system has a working fdatasync])]) ]) libmemcached-1.0.8/m4/protocol_binary.m40000664000076400007640000000222011753573717020402 0ustar00brianbrian00000000000000dnl --------------------------------------------------------------------------- dnl Macro: PROTOCOL_BINARY_TEST dnl --------------------------------------------------------------------------- AC_DEFUN([PROTOCOL_BINARY_TEST], [ AC_LANG_PUSH([C++]) AC_CACHE_CHECK([for supported struct padding], [ac_cv_supported_struct_padding], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [ #include #include "libmemcached/memcached/protocol_binary.h" ], [ protocol_binary_request_set request; int a = 1; switch (a) { case sizeof(request): case sizeof(request.bytes): break; default: a = 2; } ])], [ ac_cv_supported_struct_padding=no ], [ ac_cv_supported_struct_padding=yes ]) ]) AC_LANG_POP AS_IF([test "x$ac_cv_supported_struct_padding" = "xno"],[ AC_MSG_ERROR([Unsupported struct padding done by compiler.])]) ]) dnl --------------------------------------------------------------------------- dnl End Macro: PROTOCOL_BINARY_TEST dnl --------------------------------------------------------------------------- libmemcached-1.0.8/m4/pandora_clock_gettime.m40000664000076400007640000000113311753573717021514 0ustar00brianbrian00000000000000dnl Copyright (C) 2010 Monty Taylor dnl This file is free software; Monty Taylor dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. #-------------------------------------------------------------------- # Check for clock_gettime #-------------------------------------------------------------------- AC_DEFUN([PANDORA_CLOCK_GETTIME],[ AC_SEARCH_LIBS([clock_gettime],[rt]) AS_IF([test "x${ac_cv_search_clock_gettime}" != "xno"],[ AC_DEFINE([HAVE_CLOCK_GETTIME],[1],[Have a working clock_gettime function]) ]) ]) libmemcached-1.0.8/m4/ax_compiler_vendor.m40000664000076400007640000000661611753573717021071 0ustar00brianbrian00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html # =========================================================================== # # SYNOPSIS # # AX_COMPILER_VENDOR # # DESCRIPTION # # Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm, sun, # hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi, microsoft, # watcom, etc. The vendor is returned in the cache variable # $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++. # # LICENSE # # Copyright (c) 2008 Steven G. Johnson # Copyright (c) 2008 Matteo Frigo # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 11 AC_DEFUN([AX_COMPILER_VENDOR], [AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, [# note: don't check for gcc first since some other compilers define __GNUC__ vendors="intel: __ICC,__ECC,__INTEL_COMPILER ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__ pathscale: __PATHCC__,__PATHSCALE__ clang: __clang__ gnu: __GNUC__ sun: __SUNPRO_C,__SUNPRO_CC hp: __HP_cc,__HP_aCC dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland: __BORLANDC__,__TURBOC__ comeau: __COMO__ cray: _CRAYC kai: __KCC lcc: __LCC__ sgi: __sgi,sgi microsoft: _MSC_VER metrowerks: __MWERKS__ watcom: __WATCOMC__ portland: __PGI unknown: UNKNOWN" for ventest in $vendors; do case $ventest in *:) vendor=$ventest; continue ;; *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;; esac AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ #if !($vencpp) thisisanerror; #endif ])], [break]) done ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1` ]) ]) libmemcached-1.0.8/m4/pandora_have_better_malloc.m40000664000076400007640000000344011753573717022525 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([PANDORA_HAVE_BETTER_MALLOC],[ AC_REQUIRE([AC_LIB_PREFIX]) AC_ARG_ENABLE([umem], [AS_HELP_STRING([--enable-umem], [Enable linking with libumem @<:@default=off@:>@])], [ac_enable_umem="$enableval"],[ case "$target_os" in *solaris*) ac_enable_umem="yes" ;; *) ac_enable_umem="no" ;; esac ]) AC_ARG_ENABLE([tcmalloc], [AS_HELP_STRING([--enable-tcmalloc], [Enable linking with tcmalloc @<:@default=off@:>@])], [ac_enable_tcmalloc="$enableval"], [ac_enable_tcmalloc="no"]) AC_ARG_ENABLE([mtmalloc], [AS_HELP_STRING([--disable-mtmalloc], [Enable linking with mtmalloc @<:@default=on@:>@])], [ac_enable_mtmalloc="$enableval"], [ac_enable_mtmalloc="yes"]) save_LIBS="${LIBS}" LIBS= AS_IF([test "x$ac_enable_umem" = "xyes"],[ AC_CHECK_LIB(umem,malloc,[],[]) ],[ case "$target_os" in *linux*) AS_IF([test "x$ac_enable_tcmalloc" != "xno"],[ AC_CHECK_LIB(tcmalloc-minimal,malloc,[],[]) AS_IF([test "x$ac_cv_lib_tcmalloc_minimal_malloc" != "xyes"],[ AC_CHECK_LIB(tcmalloc,malloc,[],[]) ]) ]) ;; *solaris*) AS_IF([test "x$ac_enable_mtmalloc" != "xno"],[ AC_CHECK_LIB(mtmalloc,malloc,[],[]) ]) ;; esac ]) BETTER_MALLOC_LIBS="${LIBS}" LIBS="${save_LIBS}" AC_SUBST([BETTER_MALLOC_LIBS]) ]) AC_DEFUN([PANDORA_USE_BETTER_MALLOC],[ AC_REQUIRE([PANDORA_HAVE_BETTER_MALLOC]) LIBS="${LIBS} ${BETTER_MALLOC_LIBS}" ]) libmemcached-1.0.8/m4/ax_with_prog.m40000664000076400007640000000471111753573717017676 0ustar00brianbrian00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_with_prog.html # =========================================================================== # # SYNOPSIS # # AX_WITH_PROG([VARIABLE],[program],[VALUE-IF-NOT-FOUND],[PATH]) # # DESCRIPTION # # Locates an installed program binary, placing the result in the precious # variable VARIABLE. Accepts a present VARIABLE, then --with-program, and # failing that searches for program in the given path (which defaults to # the system path). If program is found, VARIABLE is set to the full path # of the binary; if it is not found VARIABLE is set to VALUE-IF-NOT-FOUND # if provided, unchanged otherwise. # # A typical example could be the following one: # # AX_WITH_PROG(PERL,perl) # # NOTE: This macro is based upon the original AX_WITH_PYTHON macro from # Dustin J. Mitchell . # # LICENSE # # Copyright (c) 2008 Francesco Salvestrini # Copyright (c) 2008 Dustin J. Mitchell # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 16 AC_DEFUN([AX_WITH_PROG],[ AC_PREREQ([2.61]) pushdef([VARIABLE],$1) pushdef([EXECUTABLE],$2) pushdef([VALUE_IF_NOT_FOUND],$3) pushdef([PATH_PROG],$4) AC_ARG_VAR(VARIABLE,Absolute path to EXECUTABLE executable) AS_IF(test -z "$VARIABLE",[ AC_MSG_CHECKING(whether EXECUTABLE executable path has been provided) AC_ARG_WITH(EXECUTABLE,AS_HELP_STRING([--with-EXECUTABLE=[[[PATH]]]],absolute path to EXECUTABLE executable), [ AS_IF([test "$withval" != yes && test "$withval" != no],[ VARIABLE="$withval" AC_MSG_RESULT($VARIABLE) ],[ VARIABLE="" AC_MSG_RESULT([no]) AS_IF([test "$withval" != no], [ AC_PATH_PROG([]VARIABLE[],[]EXECUTABLE[],[]VALUE_IF_NOT_FOUND[],[]PATH_PROG[]) ]) ]) ],[ AC_MSG_RESULT([no]) AC_PATH_PROG([]VARIABLE[],[]EXECUTABLE[],[]VALUE_IF_NOT_FOUND[],[]PATH_PROG[]) ]) ]) popdef([PATH_PROG]) popdef([VALUE_IF_NOT_FOUND]) popdef([EXECUTABLE]) popdef([VARIABLE]) ]) libmemcached-1.0.8/m4/libgearman.m40000664000076400007640000000066411753573717017310 0ustar00brianbrian00000000000000AX_CHECK_LIBRARY([LIBGEARMAN], [libgearman/gearmand.h], [gearman], [ AM_CONDITIONAL(HAVE_LIBGEARMAN, true) AC_DEFINE([HAVE_LIBGEARMAN], [1], [Enables libgearman Support]) ], [ AM_CONDITIONAL(HAVE_LIBGEARMAN, false) AC_DEFINE([HAVE_LIBGEARMAN], [0], [Enables libgearman Support]) ]) libmemcached-1.0.8/m4/hsieh.m40000664000076400007640000000150711753573717016304 0ustar00brianbrian00000000000000dnl --------------------------------------------------------------------------- dnl Macro: ENABLE_HSIEH_HASH dnl --------------------------------------------------------------------------- AC_DEFUN([ENABLE_HSIEH_HASH], [AC_ARG_ENABLE([hsieh_hash], [AS_HELP_STRING([--enable-hsieh_hash], [build with support for hsieh hashing. @<:@default=off@:>@])], [ac_cv_enable_hsieh_hash=yes], [ac_cv_enable_hsieh_hash=no]) AS_IF([test "$ac_cv_enable_hsieh_hash" = "yes"], [AC_DEFINE([HAVE_HSIEH_HASH], [1], [Enables hsieh hashing support])]) AM_CONDITIONAL([INCLUDE_HSIEH_SRC], [test "$ac_cv_enable_hsieh_hash" = "yes"]) ]) dnl --------------------------------------------------------------------------- dnl End Macro: ENABLE_HSIEH_HASH dnl --------------------------------------------------------------------------- libmemcached-1.0.8/m4/pandora_have_libhaildb.m40000664000076400007640000000253311753573717021625 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([_PANDORA_SEARCH_LIBHAILDB],[ AC_REQUIRE([AC_LIB_PREFIX]) dnl -------------------------------------------------------------------- dnl Check for libhaildb dnl -------------------------------------------------------------------- AC_ARG_ENABLE([libhaildb], [AS_HELP_STRING([--disable-libhaildb], [Build with libhaildb support @<:@default=on@:>@])], [ac_enable_libhaildb="$enableval"], [ac_enable_libhaildb="yes"]) AS_IF([test "x$ac_enable_libhaildb" = "xyes"],[ AC_LIB_HAVE_LINKFLAGS(haildb,,[ #include ],[ ib_update_table_statistics(NULL); ]) AS_IF([test "x${ac_cv_libhaildb}" = "xyes"],[ AC_DEFINE([HAVE_HAILDB_H],[1],[Do we have haildb.h]) ]) ],[ ac_cv_libhaildb="no" ]) AM_CONDITIONAL(HAVE_LIBHAILDB, [test "x${ac_cv_libhaildb}" = "xyes"]) ]) AC_DEFUN([PANDORA_HAVE_LIBHAILDB],[ AC_REQUIRE([_PANDORA_SEARCH_LIBHAILDB]) ]) AC_DEFUN([PANDORA_REQUIRE_LIBHAILDB],[ AC_REQUIRE([PANDORA_HAVE_LIBHAILDB]) AS_IF([test "x${ac_cv_libhaildb}" = "xno"], AC_MSG_ERROR([libhaildb 2.3.2 or later is required for ${PACKAGE}])) ]) libmemcached-1.0.8/m4/have_cinttypes.m40000664000076400007640000000624711753573717020237 0ustar00brianbrian00000000000000# vim:ft=m4 # =========================================================================== # http://tangent.org/ # =========================================================================== # # SYNOPSIS # # AX_CXX_CINTTYPES # # DESCRIPTION # # Example: # # LICENSE # # Copyright (c) 2012 Brian Aker` # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 1 AC_DEFUN([AX_CXX_CINTTYPES], [ AC_REQUIRE([AC_PROG_CXX]) AC_REQUIRE([AC_PROG_CXXCPP]) AC_REQUIRE([AX_CXX_CSTDINT]) AC_MSG_CHECKING(the location of cinttypes) save_CXXFLAGS="${CXXFLAGS}" CXXFLAGS="${CXX_STANDARD} ${CXXFLAGS}" ac_cv_cxx_cinttypes="" AC_LANG_PUSH([C++]) # AC_CACHE_CHECK([for location of cinttypes], [ac_cv_cxx_cinttypes], # [ # Look for cinttypes AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], [ uint32_t foo= UINT32_C(1) ])], [ac_cv_cxx_cinttypes=""], [ # Look for tr1/cinttypes AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], [ uint32_t foo= UINT32_C(1) ])], [ac_cv_cxx_cinttypes=""], [ # Look for boost/cinttypes.hpp AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], [ uint32_t foo= UINT32_C(1) ])], [ac_cv_cxx_cinttypes=""]) ]) ]) # ]) AC_LANG_POP() CXXFLAGS="${save_CXXFLAGS}" if test -n "$ac_cv_cxx_cinttypes"; then AC_MSG_RESULT([$ac_cv_cxx_cinttypes]) else ac_cv_cxx_cinttypes="" AC_MSG_WARN([Could not find a cinttypes header.]) AC_MSG_RESULT([$ac_cv_cxx_cinttypes]) fi AC_DEFINE([__STDC_LIMIT_MACROS],[1],[Use STDC Limit Macros in C++]) AC_DEFINE_UNQUOTED(CINTTYPES_H,$ac_cv_cxx_cinttypes, [the location of ]) ]) libmemcached-1.0.8/m4/pandora_use_pipe.m40000664000076400007640000000201511753573717020514 0ustar00brianbrian00000000000000dnl -*- mode: m4; c-basic-offset: 2; indent-tabs-mode: nil; -*- dnl vim:expandtab:shiftwidth=2:tabstop=2:smarttab: dnl dnl pandora-build: A pedantic build system dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystem dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl From Monty Taylor dnl dnl Test if we can Use -pipe to avoid making temp files during the compile. dnl Should speed up compile on slower disks AC_DEFUN([PANDORA_USE_PIPE],[ AS_IF([test "$GCC" = "yes"],[ AC_CACHE_CHECK([for working -pipe], [pandora_cv_use_pipe], [ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #include int main(int argc, char** argv) { (void) argc; (void) argv; return 0; } ]])], [pandora_cv_use_pipe=yes], [pandora_cv_use_pipe=no]) ]) AS_IF([test "$pandora_cv_use_pipe" = "yes"],[ AM_CFLAGS="-pipe ${AM_CFLAGS}" AM_CXXFLAGS="-pipe ${AM_CXXFLAGS}" ]) ]) ]) libmemcached-1.0.8/m4/ax_cxx_header_stdcxx_98.m40000664000076400007640000000405611753573717021725 0ustar00brianbrian00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_cxx_header_stdcxx_98.html # =========================================================================== # # SYNOPSIS # # AX_CXX_HEADER_STDCXX_98 # # DESCRIPTION # # Check for complete library coverage of the C++1998/2003 standard. # # LICENSE # # Copyright (c) 2008 Benjamin Kosnik # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 7 AU_ALIAS([AC_CXX_HEADER_STDCXX_98], [AX_CXX_HEADER_STDCXX_98]) AC_DEFUN([AX_CXX_HEADER_STDCXX_98], [ AC_CACHE_CHECK([for ISO C++ 98 include files], [ax_cv_cxx_stdcxx_98], [ AC_LANG_PUSH([C++]) AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include ], [ int x ]), [ax_cv_cxx_stdcxx_98=yes ], [ax_cv_cxx_stdcxx_98=no ] ]) AC_LANG_POP ]) if test "$ax_cv_cxx_stdcxx_98" = yes; then AC_DEFINE(STDCXX_98_HEADERS,,[Define if ISO C++ 1998 header files are present. ]) fi ]) libmemcached-1.0.8/m4/socket_send_flags.m40000664000076400007640000000353211753573717020661 0ustar00brianbrian00000000000000dnl Copyright (C) 2012 Data Differential LLC dnl Copyright (C) 2011 Trond Norbye dnl This file is free software; Trond Norbye dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl --------------------------------------------------------------------------- dnl Macro: SOCKET_SEND_FLAGS dnl --------------------------------------------------------------------------- AC_DEFUN([SOCKET_SEND_FLAGS], [ AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [ AC_LANG_PUSH([C]) save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -I${srcdir}" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], [ int flags= MSG_NOSIGNAL ])], [ac_cv_msg_nosignal="yes"]) AC_LANG_POP ]) AC_CACHE_CHECK([for MSG_DONTWAIT], [ac_cv_msg_dontwait], [ AC_LANG_PUSH([C]) save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -I${srcdir}" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], [ int flags= MSG_DONTWAIT ])], [ac_cv_msg_dontwait="yes"]) AC_LANG_POP ]) AC_CACHE_CHECK([for MSG_MORE], [ac_cv_msg_more], [ AC_LANG_PUSH([C]) save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -I${srcdir}" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], [ int flags= MSG_MORE ])], [ac_cv_msg_more="yes"]) AC_LANG_POP ]) AS_IF([test "x$ac_cv_msg_nosignal" = "xyes"],[ AC_DEFINE(HAVE_MSG_NOSIGNAL, 1, [Define to 1 if you have a MSG_NOSIGNAL])]) AS_IF([test "x$ac_cv_msg_dontwait" = "xyes"],[ AC_DEFINE(HAVE_MSG_DONTWAIT, 1, [Define to 1 if you have a MSG_DONTWAIT])]) AS_IF([test "x$ac_cv_msg_more" = "xyes"],[ AC_DEFINE(HAVE_MSG_MORE, 1, [Define to 1 if you have a MSG_MORE])]) ]) dnl --------------------------------------------------------------------------- dnl End Macro: SOCKET_SEND_FLAGS dnl --------------------------------------------------------------------------- libmemcached-1.0.8/m4/bottom.m40000664000076400007640000000114411753573717016505 0ustar00brianbrian00000000000000AC_DEFUN([CONFIG_EXTRA], [ AH_TOP([ #pragma once /* _SYS_FEATURE_TESTS_H is Solaris, _FEATURES_H is GCC */ #if defined( _SYS_FEATURE_TESTS_H) || defined(_FEATURES_H) #error "You should include config.h as your first include file" #endif ]) AH_BOTTOM([ #ifndef __STDC_FORMAT_MACROS # define __STDC_FORMAT_MACROS #endif #if defined(__cplusplus) # include CINTTYPES_H #else # include #endif #if !defined(HAVE_ULONG) && !defined(__USE_MISC) # define HAVE_ULONG 1 typedef unsigned long int ulong; #endif #define RPACKAGE "memcached" #define RVERSION "1.4.13" ]) ])dnl CONFIG_EXTRA libmemcached-1.0.8/m4/pandora_vc_build.m40000664000076400007640000000153311753573717020476 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([PANDORA_TEST_VC_DIR],[ pandora_building_from_vc=no if test -d ".bzr" ; then pandora_building_from_bzr=yes pandora_building_from_vc=yes else pandora_building_from_bzr=no fi if test -d ".svn" ; then pandora_building_from_svn=yes pandora_building_from_vc=yes else pandora_building_from_svn=no fi if test -d ".hg" ; then pandora_building_from_hg=yes pandora_building_from_vc=yes else pandora_building_from_hg=no fi if test -d ".git" ; then pandora_building_from_git=yes pandora_building_from_vc=yes else pandora_building_from_git=no fi ]) libmemcached-1.0.8/m4/pandora_64bit.m40000664000076400007640000000403211753573717017634 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl --------------------------------------------------------------------------- dnl Macro: PANDORA_64BIT dnl --------------------------------------------------------------------------- AC_DEFUN([PANDORA_64BIT],[ AC_BEFORE([$0], [AC_LIB_PREFIX]) AC_ARG_ENABLE([64bit], [AS_HELP_STRING([--disable-64bit], [Build 64 bit binary @<:@default=on@:>@])], [ac_enable_64bit="$enableval"], [ac_enable_64bit="yes"]) AC_CHECK_PROGS(ISAINFO, [isainfo], [no]) AS_IF([test "x$ISAINFO" != "xno"], [isainfo_b=`${ISAINFO} -b`], [isainfo_b="x"]) AS_IF([test "$isainfo_b" != "x" -a "$isainfo_b" != "32"],[ isainfo_k=`${ISAINFO} -k` DTRACEFLAGS="${DTRACEFLAGS} -${isainfo_b}" AS_IF([test "x$ac_enable_64bit" = "xyes"],[ AS_IF([test "x${ac_cv_env_LDFLAGS_set}" = "x"],[ LDFLAGS="-L/usr/local/lib/${isainfo_k} ${LDFLAGS}" ]) AS_IF([test "x$libdir" = "x\${exec_prefix}/lib"],[ dnl The user hasn't overridden the default libdir, so we'll dnl the dir suffix to match solaris 32/64-bit policy libdir="${libdir}/${isainfo_k}" ]) AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],[ CFLAGS="${CFLAGS} -m64" ac_cv_env_CFLAGS_set=set ac_cv_env_CFLAGS_value='-m64' ]) AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],[ CXXFLAGS="${CXXFLAGS} -m64" ac_cv_env_CXXFLAGS_set=set ac_cv_env_CXXFLAGS_value='-m64' ]) AS_IF([test "$target_cpu" = "sparc" -a "x$SUNCC" = "xyes"],[ AM_CFLAGS="-xmemalign=8s ${AM_CFLAGS}" AM_CXXFLAGS="-xmemalign=8s ${AM_CXXFLAGS}" ]) ]) ]) ]) dnl --------------------------------------------------------------------------- dnl End Macro: PANDORA_64BIT dnl --------------------------------------------------------------------------- libmemcached-1.0.8/m4/pandora_have_libvbucket.m40000664000076400007640000000236411753573717022047 0ustar00brianbrian00000000000000dnl Copyright (C) 2010 NorthScale dnl This file is free software; NorthScale dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([_PANDORA_SEARCH_LIBVBUCKET],[ AC_REQUIRE([AC_LIB_PREFIX]) dnl -------------------------------------------------------------------- dnl Check for libvbucket dnl -------------------------------------------------------------------- AC_ARG_ENABLE([libvbucket], [AS_HELP_STRING([--disable-libvbucket], [Build with libvbucket support @<:@default=on@:>@])], [ac_enable_libvbucket="$enableval"], [ac_enable_libvbucket="yes"]) AS_IF([test "x$ac_enable_libvbucket" = "xyes"],[ AC_LIB_HAVE_LINKFLAGS(vbucket,,[ #include ],[ VBUCKET_CONFIG_HANDLE config = vbucket_config_parse_file(NULL); ]) ],[ ac_cv_libvbucket="no" ]) AM_CONDITIONAL(HAVE_LIBVBUCKET, [test "x${ac_cv_libvbucket}" = "xyes"]) ]) AC_DEFUN([PANDORA_HAVE_LIBVBUCKET],[ AC_REQUIRE([_PANDORA_SEARCH_LIBVBUCKET]) ]) AC_DEFUN([PANDORA_REQUIRE_LIBVBUCKET],[ AC_REQUIRE([PANDORA_HAVE_LIBVBUCKET]) AS_IF([test x$ac_cv_libvbucket = xno], AC_MSG_ERROR([libvbucket is required for ${PACKAGE}])) ]) libmemcached-1.0.8/m4/ax_cxx_gcc_abi_demangle.m40000664000076400007640000000327211753573717021762 0ustar00brianbrian00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_cxx_gcc_abi_demangle.html # =========================================================================== # # SYNOPSIS # # AX_CXX_GCC_ABI_DEMANGLE # # DESCRIPTION # # If the compiler supports GCC C++ ABI name demangling (has header # cxxabi.h and abi::__cxa_demangle() function), define # HAVE_GCC_ABI_DEMANGLE # # Adapted from AX_CXX_RTTI by Luc Maisonobe # # LICENSE # # Copyright (c) 2008 Neil Ferguson # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 9 AC_DEFUN([AX_CXX_GCC_ABI_DEMANGLE], [AC_CACHE_CHECK([whether the compiler supports GCC C++ ABI name demangling], [ax_cv_cxx_gcc_abi_demangle], [AC_LANG_PUSH([C++]) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [ #include #include #include #include template class A {}; ],[ A instance; int status = 0; char* c_name = 0; c_name = abi::__cxa_demangle(typeid(instance).name(), 0, 0, &status); std::string name(c_name); ::free(c_name); return name == "A"; ])], [ax_cv_cxx_gcc_abi_demangle=yes], [ax_cv_cxx_gcc_abi_demangle=no]) AC_LANG_POP() ]) if test "$ax_cv_cxx_gcc_abi_demangle" = yes; then AC_DEFINE(HAVE_GCC_ABI_DEMANGLE, [1], [define if the compiler supports GCC C++ ABI name demangling]) fi ]) libmemcached-1.0.8/m4/pandora_have_libz.m40000664000076400007640000000236511753573717020656 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. #-------------------------------------------------------------------- # Check for libz #-------------------------------------------------------------------- AC_DEFUN([_PANDORA_SEARCH_LIBZ],[ AC_REQUIRE([AC_LIB_PREFIX]) AC_LIB_HAVE_LINKFLAGS(z,, [ #include ],[ crc32(0, Z_NULL, 0); ]) AM_CONDITIONAL(HAVE_LIBZ, [test "x${ac_cv_libz}" = "xyes"]) ]) AC_DEFUN([_PANDORA_HAVE_LIBZ],[ AC_ARG_ENABLE([libz], [AS_HELP_STRING([--disable-libz], [Build with libz support @<:@default=on@:>@])], [ac_enable_libz="$enableval"], [ac_enable_libz="yes"]) _PANDORA_SEARCH_LIBZ ]) AC_DEFUN([PANDORA_HAVE_LIBZ],[ AC_REQUIRE([_PANDORA_HAVE_LIBZ]) ]) AC_DEFUN([_PANDORA_REQUIRE_LIBZ],[ ac_enable_libz="yes" _PANDORA_SEARCH_LIBZ AS_IF([test x$ac_cv_libz = xno],[ AC_MSG_ERROR([libz is required for ${PACKAGE}. On Debian this can be found in zlib1g-dev. On RedHat this can be found in zlib-devel.]) ]) ]) AC_DEFUN([PANDORA_REQUIRE_LIBZ],[ AC_REQUIRE([_PANDORA_REQUIRE_LIBZ]) ]) libmemcached-1.0.8/m4/pandora_ensure_gcc_version.m40000664000076400007640000000457111753573717022576 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([_PANDORA_TRY_GCC],[ pushdef([Name],[translit([$1],[./-], [___])]) pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) AC_CHECK_PROGS([CC]NAME,[gcc$1]) AC_CHECK_PROGS([CXX]NAME,[g++$1]) AS_IF([test "x${CC]NAME[}" != "x" -a "x${ac_cv_env_CC_set}" = "x"], [CC="${CC]NAME[}"]) AS_IF([test "x${CXX]NAME[}" != "x" -a "x${ac_cv_env_CCX_set}" = "x"], [CXX="${CXX]NAME[}"]) AS_IF([test "x${CC]NAME[}" != "x" -a "x${ac_cv_env_CPP_set}" = "x"], [CPP="${CC]NAME[} -E"]) ]) dnl If the user is on a Mac and didn't ask for a specific compiler dnl You're gonna get 4.2. AC_DEFUN([PANDORA_MAC_GCC42], [AS_IF([test "$GCC" = "yes"],[ AS_IF([test "$host_vendor" = "apple" -a "x${ac_cv_env_CC_set}" = "x"],[ host_os_version=`echo ${host_os} | perl -ple 's/^\D+//g;s,\..*,,'` AS_IF([test "$host_os_version" -lt 10],[ _PANDORA_TRY_GCC([-4.2]) ]) ]) ]) ]) dnl If the user is on CentOS or RHEL and didn't ask for a specific compiler dnl You're gonna get 4.4 (forward compatible with 4.5) AC_DEFUN([PANDORA_RH_GCC44], [AS_IF([test "$GCC" = "yes"],[ AS_IF([test "x${ac_cv_env_CC_set}" = "x"],[ _PANDORA_TRY_GCC([44]) _PANDORA_TRY_GCC([45]) ]) ]) ]) dnl AC_DEFUN([PANDORA_ENSURE_GCC_VERSION],[ AC_REQUIRE([PANDORA_MAC_GCC42]) AC_REQUIRE([PANDORA_RH_GCC44]) AS_IF([test "$GCC" = "yes"],[ AC_CACHE_CHECK([if GCC is recent enough], [ac_cv_gcc_recent], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if !defined(__GNUC__) || (__GNUC__ < 4) || ((__GNUC__ >= 4) && (__GNUC_MINOR__ < 2)) # error GCC is Too Old! #endif ]])], [ac_cv_gcc_recent=yes], [ac_cv_gcc_recent=no])]) AS_IF([test "$ac_cv_gcc_recent" = "no" -a "$host_vendor" = "apple"], AC_MSG_ERROR([Your version of GCC is too old. At least version 4.2 is required on OSX. You may need to install a version of XCode >= 3.1.2])) AS_IF([test "$ac_cv_gcc_recent" = "no"], AC_MSG_ERROR([Your version of GCC is too old. At least version 4.2 is required. On RHEL/CentOS systems this is found in the gcc44 and gcc44-c++ packages.])) ]) ]) libmemcached-1.0.8/m4/pandora_have_libavahi.m40000664000076400007640000000244711753573717021476 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([_PANDORA_SEARCH_LIBAVAHI],[ AC_REQUIRE([AC_LIB_PREFIX]) dnl -------------------------------------------------------------------- dnl Check for libavahi dnl -------------------------------------------------------------------- AC_ARG_ENABLE([libavahi], [AS_HELP_STRING([--disable-libavahi], [Build with libavahi support @<:@default=on@:>@])], [ac_enable_libavahi="$enableval"], [ac_enable_libavahi="yes"]) AS_IF([test "x$ac_enable_libavahi" = "xyes"],[ AC_LIB_HAVE_LINKFLAGS(avahi-client,avahi-common,[ #include #include ],[ AvahiSimplePoll *simple_poll= avahi_simple_poll_new(); ]) ],[ ac_cv_libavahi="no" ]) AM_CONDITIONAL(HAVE_LIBAVAHI, [test "x${ac_cv_libavahi}" = "xyes"]) ]) AC_DEFUN([PANDORA_HAVE_LIBAVAHI],[ AC_REQUIRE([_PANDORA_SEARCH_LIBAVAHI]) ]) AC_DEFUN([PANDORA_REQUIRE_LIBAVAHI],[ AC_REQUIRE([_PANDORA_SEARCH_LIBAVAHI]) AS_IF([test "x${ac_cv_libavahi}" = "xno"], AC_MSG_ERROR([libavahi is required for ${PACKAGE}])) ]) libmemcached-1.0.8/m4/pandora_check_compiler_version.m40000664000076400007640000000171411753573717023424 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([PANDORA_CHECK_C_VERSION],[ dnl Print version of C compiler AC_MSG_CHECKING("C Compiler version--$GCC") AS_IF([test "$GCC" = "yes"],[ CC_VERSION=`$CC --version | sed 1q` ],[AS_IF([test "$SUNCC" = "yes"],[ CC_VERSION=`$CC -V 2>&1 | sed 1q` ],[ CC_VERSION="" ]) ]) AC_MSG_RESULT("$CC_VERSION") AC_SUBST(CC_VERSION) ]) AC_DEFUN([PANDORA_CHECK_CXX_VERSION], [ dnl Print version of CXX compiler AC_MSG_CHECKING("C++ Compiler version") AS_IF([test "$GCC" = "yes"],[ CXX_VERSION=`$CXX --version | sed 1q` ],[AS_IF([test "$SUNCC" = "yes"],[ CXX_VERSION=`$CXX -V 2>&1 | sed 1q` ],[ CXX_VERSION="" ]) ]) AC_MSG_RESULT("$CXX_VERSION") AC_SUBST(CXX_VERSION) ]) libmemcached-1.0.8/m4/ltoptions.m40000644000076400007640000002725611753633364017241 0ustar00brianbrian00000000000000# Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, # Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 7 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option `$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl `shared' nor `disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) ]) ])# _LT_SET_OPTIONS ## --------------------------------- ## ## Macros to handle LT_INIT options. ## ## --------------------------------- ## # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the `shared' and # `disable-shared' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the `static' and # `disable-static' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the `fast-install' # and `disable-fast-install' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the `pic-only' and `no-pic' # LT_INIT options. # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [pic_mode="$withval"], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) ## ----------------- ## ## LTDL_INIT Options ## ## ----------------- ## m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) libmemcached-1.0.8/m4/ax_pthread.m40000664000076400007640000003044011753573717017321 0ustar00brianbrian00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_pthread.html # =========================================================================== # # SYNOPSIS # # AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) # # DESCRIPTION # # This macro figures out how to build C programs using POSIX threads. It # sets the PTHREAD_LIBS output variable to the threads library and linker # flags, and the PTHREAD_CFLAGS output variable to any special C compiler # flags that are needed. (The user can also force certain compiler # flags/libs to be tested by setting these environment variables.) # # Also sets PTHREAD_CC to any special C compiler that is needed for # multi-threaded programs (defaults to the value of CC otherwise). (This # is necessary on AIX to use the special cc_r compiler alias.) # # NOTE: You are assumed to not only compile your program with these flags, # but also link it with them as well. e.g. you should link with # $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS # # If you are only building threads programs, you may wish to use these # variables in your default LIBS, CFLAGS, and CC: # # LIBS="$PTHREAD_LIBS $LIBS" # CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # CC="$PTHREAD_CC" # # In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant # has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name # (e.g. PTHREAD_CREATE_UNDETACHED on AIX). # # Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the # PTHREAD_PRIO_INHERIT symbol is defined when compiling with # PTHREAD_CFLAGS. # # ACTION-IF-FOUND is a list of shell commands to run if a threads library # is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it # is not found. If ACTION-IF-FOUND is not specified, the default action # will define HAVE_PTHREAD. # # Please let the authors know if this macro fails on any platform, or if # you have any other suggestions or comments. This macro was based on work # by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help # from M. Frigo), as well as ac_pthread and hb_pthread macros posted by # Alejandro Forero Cuervo to the autoconf macro repository. We are also # grateful for the helpful feedback of numerous users. # # Updated for Autoconf 2.68 by Daniel Richard G. # # LICENSE # # Copyright (c) 2008 Steven G. Johnson # Copyright (c) 2011 Daniel Richard G. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 17 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AC_DEFUN([AX_PTHREAD], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_LANG_PUSH([C]) ax_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes) AC_MSG_RESULT($ax_pthread_ok) if test x"$ax_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthreads: Solaris/gcc # -mthreads: Mingw32/gcc, Lynx/gcc # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # ... -mt is also the pthreads flag for HP/aCC # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case "${host_cpu}-${host_os}" in *solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthreads/-mt/ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" ;; *-darwin*) ax_pthread_flags="-pthread $ax_pthread_flags" ;; esac if test x"$ax_pthread_ok" = xno; then for flag in $ax_pthread_flags; do case $flag in none) AC_MSG_CHECKING([whether pthreads work without any flags]) ;; -*) AC_MSG_CHECKING([whether pthreads work with $flag]) PTHREAD_CFLAGS="$flag" ;; pthread-config) AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no) if test x"$ax_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) AC_MSG_CHECKING([for the pthreads library -l$flag]) PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include static void routine(void *a) { a = 0; } static void *start_routine(void *a) { return a; }], [pthread_t th; pthread_attr_t attr; pthread_create(&th, 0, start_routine, 0); pthread_join(th, 0); pthread_attr_init(&attr); pthread_cleanup_push(routine, 0); pthread_cleanup_pop(0) /* ; */])], [ax_pthread_ok=yes], []) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" AC_MSG_RESULT($ax_pthread_ok) if test "x$ax_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$ax_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. AC_MSG_CHECKING([for joinable pthread attribute]) attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], [int attr = $attr; return attr /* ; */])], [attr_name=$attr; break], []) done AC_MSG_RESULT($attr_name) if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, [Define to necessary symbol if this constant uses a non-standard name on your system.]) fi AC_MSG_CHECKING([if more special flags are required for pthreads]) flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; *-osf* | *-hpux*) flag="-D_REENTRANT";; *solaris*) if test "$GCC" = "yes"; then flag="-D_REENTRANT" else flag="-mt -D_REENTRANT" fi ;; esac AC_MSG_RESULT(${flag}) if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], ax_cv_PTHREAD_PRIO_INHERIT, [ AC_LINK_IFELSE([ AC_LANG_PROGRAM([[#include ]], [[int i = PTHREAD_PRIO_INHERIT;]])], [ax_cv_PTHREAD_PRIO_INHERIT=yes], [ax_cv_PTHREAD_PRIO_INHERIT=no]) ]) AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"], AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.])) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: must compile with xlc_r or cc_r if test x"$GCC" != xyes; then AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) else PTHREAD_CC=$CC fi else PTHREAD_CC="$CC" fi AC_SUBST(PTHREAD_LIBS) AC_SUBST(PTHREAD_CFLAGS) AC_SUBST(PTHREAD_CC) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$ax_pthread_ok" = xyes; then ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) : else ax_pthread_ok=no $2 fi AC_LANG_POP ])dnl AX_PTHREAD libmemcached-1.0.8/m4/ltversion.m40000644000076400007640000000125611753633364017223 0ustar00brianbrian00000000000000# ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # @configure_input@ # serial 3293 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4]) m4_define([LT_PACKAGE_REVISION], [1.3293]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4' macro_revision='1.3293' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) libmemcached-1.0.8/m4/libtool.m40000644000076400007640000104515511753633364016651 0ustar00brianbrian00000000000000# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, # Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, # Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) # serial 57 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. m4_defun([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ]) # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from `configure', and `config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # `config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain="$ac_aux_dir/ltmain.sh" ])# _LT_PROG_LTMAIN ## ------------------------------------- ## ## Accumulate code for creating libtool. ## ## ------------------------------------- ## # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the `libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) ## ------------------------ ## ## FIXME: Eliminate VARNAME ## ## ------------------------ ## # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to `config.status' so that its # declaration there will have the same value as in `configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags="_LT_TAGS"dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the `libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into `config.status', and then the shell code to quote escape them in # for loops in `config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # `#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test $lt_write_fail = 0 && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ \`$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2010 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test $[#] != 0 do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try \`$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try \`$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: test "$silent" = yes && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # _LT_COPYING _LT_LIBTOOL_TAGS # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_REPLACE_SHELLFNS mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[[012]]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES # -------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" m4_if([$1], [CXX], [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX([TAGNAME]) # ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script which will find a shell with a builtin # printf (which we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case "$ECHO" in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [ --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified).], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([${with_sysroot}]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and in which our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; sparc*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) LD="${LD-ld} -m elf64_sparc" ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) _LT_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test x"[$]$2" = xyes; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" ]) if test x"[$]$2" = xyes; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n $lt_cv_sys_max_cmd_len ; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "$cross_compiling" = yes; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links="nottested" if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", [Define to the sub-directory in which libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existent directories. if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[[4-9]]*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[123]]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; haiku*) version_type=linux need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Add ABI-specific directories to the system library path. sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib" # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([], [sys_lib_dlsearch_path_spec], [2], [Run-time system search path for libraries]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program which can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program which can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method = "file_magic"]) _LT_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi]) if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi AC_SUBST([DUMPBIN]) if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # _LT_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM="-lm") ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT@&t@_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Xcompiler -fPIC' ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ F* | *Sun*Fortran*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; freebsd1*) _LT_TAGVAR(ld_shlibs, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS="$save_LDFLAGS"]) if test "$lt_cv_irix_exported_symbol" = yes; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' else case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' ;; esac fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], [[If ld is used when linking, flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting ${shlibpath_var} if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC="$CC" AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report which library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC="$lt_save_CC" ])# _LT_LANG_C_CONFIG # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ func_to_tool_file "$lt_outputfile"~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd[[12]]*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; gnu*) ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd2*) # C++ shared libraries are fairly broken _LT_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(GCC, $1)="$GXX" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; esac dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case ${prev}${p} in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test "$pre_test_object_deps_done" = no; then case ${prev} in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)="${prev}${p}" else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)="$p" else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)="$p" else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_F77" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$G77" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" CFLAGS="$lt_save_CFLAGS" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_FC" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test "$_lt_disable_FC" != yes AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code="$lt_simple_compile_test_code" # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [AC_MSG_CHECKING([whether the shell understands some XSI constructs]) # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes AC_MSG_RESULT([$xsi_shell]) _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) AC_MSG_CHECKING([whether the shell understands "+="]) lt_shell_append=no ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes AC_MSG_RESULT([$lt_shell_append]) _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) # ------------------------------------------------------ # In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and # '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. m4_defun([_LT_PROG_FUNCTION_REPLACE], [dnl { sed -e '/^$1 ()$/,/^} # $1 /c\ $1 ()\ {\ m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) } # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: ]) # _LT_PROG_REPLACE_SHELLFNS # ------------------------- # Replace existing portable implementations of several shell functions with # equivalent extended shell implementations where those features are available.. m4_defun([_LT_PROG_REPLACE_SHELLFNS], [if test x"$xsi_shell" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"}]) _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl func_split_long_opt_name=${1%%=*} func_split_long_opt_arg=${1#*=}]) _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) fi if test x"$lt_shell_append" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl func_quote_for_eval "${2}" dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) fi ]) # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine which file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS libmemcached-1.0.8/m4/pandora_swig.m40000664000076400007640000000220711753573717017657 0ustar00brianbrian00000000000000dnl -*- mode: m4; c-basic-offset: 2; indent-tabs-mode: nil; -*- dnl vim:expandtab:shiftwidth=2:tabstop=2:smarttab: dnl dnl pandora-build: A pedantic build system dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystem dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl dnl From Monty Taylor AC_DEFUN([PANDORA_SWIG],[ AC_PROG_SWIG(1.3.31) AC_DEFINE_UNQUOTED([SWIG_TYPE_TABLE], [$PACKAGE], [Type Table name for SWIG symbol table]) dnl Have to hard-code /usr/local/include and /usr/include into the path. dnl I hate this. Why is swig sucking me SWIG="$SWIG \${DEFS} -I\${top_srcdir} -I\${top_builddir} -I/usr/local/include -I/usr/include" AC_SUBST([SWIG]) ]) AC_DEFUN([PANDORA_SWIG_PYTHON3],[ AC_REQUIRE([PANDORA_SWIG]) AS_IF([test "x$SWIG" != "x"],[ AC_CACHE_CHECK([if swig supports Python3], [ac_cv_swig_has_python3_], [ AS_IF([$SWIG -python -help 2>&1 | grep py3 > /dev/null], [ac_cv_swig_has_python3_=yes], [ac_cv_swig_has_python3_=no]) ]) ]) ]) libmemcached-1.0.8/m4/memcached_sasl.m40000664000076400007640000000113311753573717020127 0ustar00brianbrian00000000000000AX_WITH_PROG(MEMCACHED_SASL_BINARY,memcached_sasl) AS_IF([test -f "$ac_cv_path_MEMCACHED_SASL_BINARY"], [ AC_DEFINE([HAVE_MEMCACHED_SASL_BINARY], [1], [Name of the memcached_sasl binary used in make test]) AC_DEFINE_UNQUOTED([MEMCACHED_SASL_BINARY], "$ac_cv_path_MEMCACHED_SASL_BINARY", [Name of the memcached_sasl binary used in make test]) ], [ AC_DEFINE([HAVE_MEMCACHED_SASL_BINARY], [0], [Name of the memcached_sasl binary used in make test]) AC_DEFINE([MEMCACHED_SASL_BINARY], [0], [Name of the memcached_sasl binary used in make test]) ]) libmemcached-1.0.8/m4/pandora_enable_dtrace.m40000664000076400007640000000436611753573717021466 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl --------------------------------------------------------------------------- dnl Macro: PANDORA_ENABLE_DTRACE dnl --------------------------------------------------------------------------- AC_DEFUN([PANDORA_ENABLE_DTRACE],[ AC_ARG_ENABLE([dtrace], [AS_HELP_STRING([--enable-dtrace], [Build with support for the DTRACE. @<:@default=no@:>@])], [ac_cv_enable_dtrace="$enableval"], [ac_cv_enable_dtrace="no"]) AS_IF([test "$ac_cv_enable_dtrace" = "yes"],[ AC_CHECK_PROGS([DTRACE], [dtrace]) AC_CHECK_HEADERS(sys/sdt.h) AS_IF([test "x$ac_cv_prog_DTRACE" = "xdtrace" -a "x${ac_cv_header_sys_sdt_h}" = "xyes"],[ AC_CACHE_CHECK([if dtrace works],[ac_cv_dtrace_works],[ cat >conftest.d <<_ACEOF provider Example { probe increment(int); }; _ACEOF $DTRACE -h -o conftest.h -s conftest.d 2>/dev/zero AS_IF([test $? -eq 0],[ac_cv_dtrace_works=yes], [ac_cv_dtrace_works=no]) rm -f conftest.h conftest.d ]) AS_IF([test "x$ac_cv_dtrace_works" = "xyes"],[ AC_DEFINE([HAVE_DTRACE], [1], [Enables DTRACE Support]) ]) AC_CACHE_CHECK([if dtrace should instrument object files], [ac_cv_dtrace_needs_objects],[ dnl DTrace on MacOSX does not use -G option cat >conftest.d <<_ACEOF provider Example { probe increment(int); }; _ACEOF $DTRACE -G -o conftest.d.o -s conftest.d 2>/dev/zero AS_IF([test $? -eq 0],[ac_cv_dtrace_needs_objects=yes], [ac_cv_dtrace_needs_objects=no]) rm -f conftest.d.o conftest.d ]) AC_SUBST(DTRACEFLAGS) dnl TODO: test for -G on OSX ac_cv_have_dtrace=yes ])]) AM_CONDITIONAL([HAVE_DTRACE], [test "x$ac_cv_dtrace_works" = "xyes"]) AM_CONDITIONAL([DTRACE_NEEDS_OBJECTS], [test "x$ac_cv_dtrace_needs_objects" = "xyes"]) ]) dnl --------------------------------------------------------------------------- dnl End Macro: PANDORA_ENABLE_DTRACE dnl --------------------------------------------------------------------------- libmemcached-1.0.8/m4/murmur.m40000664000076400007640000000152411753573717016532 0ustar00brianbrian00000000000000dnl --------------------------------------------------------------------------- dnl Macro: ENABLE_MURMUR_HASH dnl --------------------------------------------------------------------------- AC_DEFUN([ENABLE_MURMUR_HASH], [AC_ARG_ENABLE([murmur_hash], [AS_HELP_STRING([--disable-murmur_hash], [build with support for murmur hashing. @<:@default=on@:>@])], [ac_cv_enable_murmur_hash=no], [ac_cv_enable_murmur_hash=yes]) AS_IF([test "$ac_cv_enable_murmur_hash" = "yes"], [AC_DEFINE([HAVE_MURMUR_HASH], [1], [Enables murmur hashing support])]) AM_CONDITIONAL([INCLUDE_MURMUR_SRC], [test "$ac_cv_enable_murmur_hash" = "yes"]) ]) dnl --------------------------------------------------------------------------- dnl End Macro: ENABLE_MURMUR_HASH dnl --------------------------------------------------------------------------- libmemcached-1.0.8/m4/lt~obsolete.m40000644000076400007640000001375611753633365017561 0ustar00brianbrian00000000000000# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 5 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) libmemcached-1.0.8/m4/pandora_optimize.m40000664000076400007640000000452011753573717020546 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([PANDORA_OPTIMIZE],[ dnl Build optimized or debug version ? dnl First check for gcc and g++ AS_IF([test "$GCC" = "yes" -a "$INTELCC" = "no"],[ dnl The following is required for portable results of floating point dnl calculations on PowerPC. The same must also be done for IA-64, but dnl this options is missing in the IA-64 gcc backend. case "$target_cpu" in *ppc* | *powerpc*) AM_CFLAGS="-mno-fused-madd ${AM_CFLAGS}" AM_CXXFLAGS="-mno-fused-madd ${AM_CXXFLAGS}" ;; esac AM_CPPFLAGS="-ggdb ${AM_CPPFLAGS}" DEBUG_CFLAGS="-O0" DEBUG_CXXFLAGS="-O0" OPTIMIZE_CFLAGS="-O2" OPTIMIZE_CXXFLAGS="-O2" ]) AS_IF([test "$INTELCC" = "yes"],[ AM_CPPFLAGS="-g ${AM_CPPFLAGS}" DEBUG_CFLAGS="-O0" DEBUG_CXXFLAGS="-O0" OPTIMIZE_CFLAGS="-xHOST -O2 -no-prec-div -static" OPTIMIZE_CXXFLAGS="${OPTIMIZE_CFLAGS}" ]) AS_IF([test "$SUNCC" = "yes"],[ dnl Once we can use a modern autoconf, we can replace the -xc99=all here dnl with using AC_CC_STD_C99 above CC="${CC} -xc99=all" CXX="${CXX} -xlang=c99" AM_CFLAGS="-g -mt -xstrconst -Xa ${AM_CFLAGS}" AM_CXXFLAGS="-mt -compat=5 -library=stlport4 -library=Crun -template=no%extdef ${AM_CXXFLAGS}" DEBUG_CXXFLAGS="-g" dnl TODO: Make a test for -xO4 usability here OPTIMIZE_FLAGS="-xO3 -xlibmil -xdepend -xbuiltin" OPTIMIZE_CFLAGS="${OPTIMIZE_FLAGS}" OPTIMIZE_CXXFLAGS="-g0 ${OPTIMIZE_FLAGS}" ]) AC_ARG_WITH([debug], [AS_HELP_STRING([--with-debug], [Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])], [with_debug=$withval], [with_debug=no]) AS_IF([test "$with_debug" = "yes"],[ # Debugging. No optimization. AM_CFLAGS="${AM_CFLAGS} ${DEBUG_CFLAGS} -DDEBUG" AM_CXXFLAGS="${AM_CXXFLAGS} ${DEBUG_CXXFLAGS} -DDEBUG" AC_DEFINE(DEBUG, [ 1 ], [Define to 1 to enable debugging code.]) ],[ # Optimized version. No debug AM_CFLAGS="${AM_CFLAGS} ${OPTIMIZE_CFLAGS}" AM_CXXFLAGS="${AM_CXXFLAGS} ${OPTIMIZE_CXXFLAGS}" AC_DEFINE(DEBUG, [ 0 ], [Define to 1 to enable debugging code.]) ]) ]) libmemcached-1.0.8/m4/lib-prefix.m40000664000076400007640000002042211753573717017242 0ustar00brianbrian00000000000000# lib-prefix.m4 serial 7 (gettext-0.18) dnl Copyright (C) 2001-2005, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't dnl require excessive bracketing. ifdef([AC_HELP_STRING], [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], [AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed dnl to access previously installed libraries. The basic assumption is that dnl a user will want packages to use other packages he previously installed dnl with the same --prefix option. dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate dnl libraries, but is otherwise very convenient. AC_DEFUN([AC_LIB_PREFIX], [ AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) AC_LIB_ARG_WITH([lib-prefix], [ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib --without-lib-prefix don't search for libraries in includedir and libdir], [ if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" fi fi ]) if test $use_additional = yes; then dnl Potentially add $additional_includedir to $CPPFLAGS. dnl But don't add it dnl 1. if it's the standard /usr/include, dnl 2. if it's already present in $CPPFLAGS, dnl 3. if it's /usr/local/include and we are using GCC on Linux, dnl 4. if it doesn't exist as a directory. if test "X$additional_includedir" != "X/usr/include"; then haveit= for x in $CPPFLAGS; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_includedir"; then dnl Really add $additional_includedir to $CPPFLAGS. CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" fi fi fi fi dnl Potentially add $additional_libdir to $LDFLAGS. dnl But don't add it dnl 1. if it's the standard /usr/lib, dnl 2. if it's already present in $LDFLAGS, dnl 3. if it's /usr/local/lib and we are using GCC on Linux, dnl 4. if it doesn't exist as a directory. if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then haveit= for x in $LDFLAGS; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then if test -n "$GCC"; then case $host_os in linux*) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LDFLAGS. LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" fi fi fi fi fi ]) dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, dnl acl_final_exec_prefix, containing the values to which $prefix and dnl $exec_prefix will expand at the end of the configure script. AC_DEFUN([AC_LIB_PREPARE_PREFIX], [ dnl Unfortunately, prefix and exec_prefix get only finally determined dnl at the end of configure. if test "X$prefix" = "XNONE"; then acl_final_prefix="$ac_default_prefix" else acl_final_prefix="$prefix" fi if test "X$exec_prefix" = "XNONE"; then acl_final_exec_prefix='${prefix}' else acl_final_exec_prefix="$exec_prefix" fi acl_save_prefix="$prefix" prefix="$acl_final_prefix" eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" prefix="$acl_save_prefix" ]) dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the dnl variables prefix and exec_prefix bound to the values they will have dnl at the end of the configure script. AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], [ acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" $1 exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" ]) dnl AC_LIB_PREPARE_MULTILIB creates dnl - a variable acl_libdirstem, containing the basename of the libdir, either dnl "lib" or "lib64" or "lib/64", dnl - a variable acl_libdirstem2, as a secondary possible value for dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or dnl "lib/amd64". AC_DEFUN([AC_LIB_PREPARE_MULTILIB], [ dnl There is no formal standard regarding lib and lib64. dnl On glibc systems, the current practice is that on a system supporting dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine dnl the compiler's default mode by looking at the compiler's library search dnl path. If at least one of its elements ends in /lib64 or points to a dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. dnl Otherwise we use the default, namely "lib". dnl On Solaris systems, the current practice is that on a system supporting dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. AC_REQUIRE([AC_CANONICAL_HOST]) acl_libdirstem=lib acl_libdirstem2= case "$host_os" in solaris*) dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment dnl . dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the dnl symlink is missing, so we set acl_libdirstem2 too. AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], [AC_EGREP_CPP([sixtyfour bits], [ #ifdef _LP64 sixtyfour bits #endif ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) ]) if test $gl_cv_solaris_64bit = yes; then acl_libdirstem=lib/64 case "$host_cpu" in sparc*) acl_libdirstem2=lib/sparcv9 ;; i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; esac fi ;; *) searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` if test -n "$searchpath"; then acl_save_IFS="${IFS= }"; IFS=":" for searchdir in $searchpath; do if test -d "$searchdir"; then case "$searchdir" in */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; */../ | */.. ) # Better ignore directories of this form. They are misleading. ;; *) searchdir=`cd "$searchdir" && pwd` case "$searchdir" in */lib64 ) acl_libdirstem=lib64 ;; esac ;; esac fi done IFS="$acl_save_IFS" fi ;; esac test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" ]) libmemcached-1.0.8/m4/setsockopt.m40000664000076400007640000000415711753573717017406 0ustar00brianbrian00000000000000dnl --------------------------------------------------------------------------- dnl Macro: SETSOCKOPT_SANITY dnl --------------------------------------------------------------------------- AC_DEFUN([SETSOCKOPT_SANITY],[ AC_CACHE_CHECK([for working SO_SNDTIMEO], [ac_cv_have_so_sndtimeo], AC_LANG_PUSH([C]) AC_RUN_IFELSE([ AC_LANG_PROGRAM([[ #include #include #include #include #include ]],[[ int sock = socket(AF_INET, SOCK_STREAM, 0); struct timeval waittime; waittime.tv_sec= 0; waittime.tv_usec= 500; if (setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &waittime, (socklen_t)sizeof(struct timeval)) == -1) { if (errno == ENOPROTOOPT) { return 1; } } return 0; ]])], [ac_cv_have_so_sndtimeo=yes], [ac_cv_have_so_sndtimeo=no], [ac_cv_have_so_sndtimeo=yes]) AS_IF([test "x$ac_cv_have_so_sndtimeo" = "xyes"], [ AC_DEFINE(HAVE_SNDTIMEO, 1, [Define to 1 if you have a working SO_SNDTIMEO])]) AC_LANG_POP ) AC_CACHE_CHECK([for working SO_RCVTIMEO], [ac_cv_have_so_rcvtimeo], AC_LANG_PUSH([C]) AC_RUN_IFELSE([ AC_LANG_PROGRAM([[ #include #include #include #include #include ]],[[ int sock = socket(AF_INET, SOCK_STREAM, 0); struct timeval waittime; waittime.tv_sec= 0; waittime.tv_usec= 500; if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &waittime, (socklen_t)sizeof(struct timeval)) == -1) { if (errno == ENOPROTOOPT) { return 1; } } return 0; ]])], [ac_cv_have_so_rcvtimeo=yes], [ac_cv_have_so_rcvtimeo=no], [ac_cv_have_so_rcvtimeo=yes]) AS_IF([test "x$ac_cv_have_so_rcvtimeo" = "xyes"], [ AC_DEFINE(HAVE_RCVTIMEO, 1, [Define to 1 if you have a working SO_RCVTIMEO])]) AC_LANG_POP ) ]) dnl --------------------------------------------------------------------------- dnl End Macro: SETSOCKOPT_SANITY dnl --------------------------------------------------------------------------- libmemcached-1.0.8/m4/visibility.m40000664000076400007640000000642611753573717017400 0ustar00brianbrian00000000000000# visibility.m4 serial 4 (gettext-0.18.2) dnl Copyright (C) 2005, 2008, 2010-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl Tests whether the compiler supports the command-line option dnl -fvisibility=hidden and the function and variable attributes dnl __attribute__((__visibility__("hidden"))) and dnl __attribute__((__visibility__("default"))). dnl Does *not* test for __visibility__("protected") - which has tricky dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on dnl MacOS X. dnl Does *not* test for __visibility__("internal") - which has processor dnl dependent semantics. dnl Does *not* test for #pragma GCC visibility push(hidden) - which is dnl "really only recommended for legacy code". dnl Set the variable CFLAG_VISIBILITY. dnl Defines and sets the variable HAVE_VISIBILITY. AC_DEFUN([gl_VISIBILITY], [ AC_REQUIRE([AC_PROG_CC]) CFLAG_VISIBILITY= HAVE_VISIBILITY=0 if test -n "$GCC"; then dnl First, check whether -Werror can be added to the command line, or dnl whether it leads to an error because of some other option that the dnl user has put into $CC $CFLAGS $CPPFLAGS. AC_MSG_CHECKING([whether the -Werror option is usable]) AC_CACHE_VAL([gl_cv_cc_vis_werror], [ gl_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Werror" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[]], [[]])], [gl_cv_cc_vis_werror=yes], [gl_cv_cc_vis_werror=no]) CFLAGS="$gl_save_CFLAGS"]) AC_MSG_RESULT([$gl_cv_cc_vis_werror]) dnl Now check whether visibility declarations are supported. AC_MSG_CHECKING([for simple visibility declarations]) AC_CACHE_VAL([gl_cv_cc_visibility], [ gl_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fvisibility=hidden" dnl We use the option -Werror and a function dummyfunc, because on some dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning dnl "visibility attribute not supported in this configuration; ignored" dnl at the first function definition in every compilation unit, and we dnl don't want to use the option in this case. if test $gl_cv_cc_vis_werror = yes; then CFLAGS="$CFLAGS -Werror" fi AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[extern __attribute__((__visibility__("hidden"))) int hiddenvar; extern __attribute__((__visibility__("default"))) int exportedvar; extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); extern __attribute__((__visibility__("default"))) int exportedfunc (void); void dummyfunc (void) {} ]], [[]])], [gl_cv_cc_visibility=yes], [gl_cv_cc_visibility=no]) CFLAGS="$gl_save_CFLAGS"]) AC_MSG_RESULT([$gl_cv_cc_visibility]) if test $gl_cv_cc_visibility = yes; then CFLAG_VISIBILITY="-fvisibility=hidden" HAVE_VISIBILITY=1 fi fi AC_SUBST([CFLAG_VISIBILITY]) AC_SUBST([HAVE_VISIBILITY]) AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY], [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.]) ]) libmemcached-1.0.8/m4/pandora_version.m40000664000076400007640000000065711753573717020402 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([PANDORA_VERSION],[ PANDORA_HEX_VERSION=`echo $VERSION | sed 's|[\-a-z0-9]*$||' | \ awk -F. '{printf "0x%0.2d%0.3d%0.3d", $[]1, $[]2, $[]3}'` AC_SUBST([PANDORA_HEX_VERSION]) ]) libmemcached-1.0.8/m4/byteorder.m40000664000076400007640000000111011753573717017171 0ustar00brianbrian00000000000000AC_DEFUN([DETECT_BYTEORDER], [ AC_REQUIRE([AC_C_BIGENDIAN]) AC_LANG_PUSH([C++]) AC_CACHE_CHECK([for htonll], [ac_cv_have_htonll], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [#include #include #include ], [ return htonll(0) ])], [ ac_cv_have_htonll=yes ], [ ac_cv_have_htonll=no ]) ]) AC_LANG_POP() AS_IF([test "x$ac_cv_have_htonll" = "xyes"],[ AC_DEFINE([HAVE_HTONLL], [1], [Have ntohll])]) AM_CONDITIONAL([BUILD_BYTEORDER],[test "x$ac_cv_have_htonll" = "xno"]) ]) libmemcached-1.0.8/m4/ax_check_library.m40000664000076400007640000000742111753573717020476 0ustar00brianbrian00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_check_library.html # =========================================================================== # # SYNOPSIS # # AX_CHECK_LIBRARY(VARIABLE-PREFIX, HEADER-FILE, LIBRARY-FILE, # [ACTION-IF-FOUND], [ACTION-IF-NOT_FOUND]) # # DESCRIPTION # # Provides a generic test for a given library, similar in concept to the # PKG_CHECK_MODULES macro used by pkg-config. # # Most simplest libraries can be checked against simply through the # presence of a header file and a library to link to. This macro allows to # wrap around the test so that it doesn't have to be recreated each time. # # Rather than define --with-$LIBRARY arguments, it uses variables in the # same way that PKG_CHECK_MODULES does. It doesn't, though, use the same # names, since you shouldn't provide a value for LIBS or CFLAGS but rather # for LDFLAGS and CPPFLAGS, to tell the linker and compiler where to find # libraries and headers respectively. # # If the library is find, HAVE_PREFIX is defined, and in all cases # PREFIX_LDFLAGS and PREFIX_CPPFLAGS are substituted. # # Example: # # AX_CHECK_LIBRARY([LIBEVENT], [event.h], [event], [], # [AC_MSG_ERROR([Unable to find libevent])]) # # LICENSE # # Copyright (c) 2010 Diego Elio Petteno` # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # 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 AC_DEFUN([AX_CHECK_LIBRARY], [ AC_ARG_VAR($1[_CPPFLAGS], [C preprocessor flags for ]$1[ headers]) AC_ARG_VAR($1[_LDFLAGS], [linker flags for ]$1[ libraries]) AC_CACHE_VAL(AS_TR_SH([ax_cv_have_]$1), [save_CPPFLAGS="$CPPFLAGS" save_LDFLAGS="$LDFLAGS" save_LIBS="$LIBS" AS_IF([test "x$]$1[_CPPFLAGS" != "x"], [CPPFLAGS="$CPPFLAGS $]$1[_CPPFLAGS"]) AS_IF([test "x$]$1[_LDFLAGS" != "x"], [LDFLAGS="$LDFLAGS $]$1[_LDFLAGS"]) AC_CHECK_HEADER($2, [ AC_CHECK_LIB($3, [main], [AS_TR_SH([ax_cv_have_]$1)=yes], [AS_TR_SH([ax_cv_have_]$1)=no]) ], [AS_TR_SH([ax_cv_have_]$1)=no]) CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ]) 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])) ]) libmemcached-1.0.8/m4/deprecated.m40000664000076400007640000000135111753573717017301 0ustar00brianbrian00000000000000dnl --------------------------------------------------------------------------- dnl Macro: deprecated dnl --------------------------------------------------------------------------- AC_DEFUN([ENABLE_DEPRECATED],[ AC_ARG_ENABLE([deprecated], [AS_HELP_STRING([--enable-deprecated], [Enable deprecated interface @<:@default=off@:>@])], [ac_enable_deprecated="$enableval"], [ac_enable_deprecated="no"]) AS_IF([test "$ac_enable_deprecated" = "yes"], [DEPRECATED="#define MEMCACHED_ENABLE_DEPRECATED 1"]) AC_SUBST([DEPRECATED]) ]) dnl --------------------------------------------------------------------------- dnl End Macro: deprecated dnl --------------------------------------------------------------------------- libmemcached-1.0.8/m4/pandora_have_libaio.m40000664000076400007640000000270111753573717021147 0ustar00brianbrian00000000000000dnl Copyright (C) 2011 Andrew Hutchings dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. #-------------------------------------------------------------------- # Check for libaio #-------------------------------------------------------------------- AC_DEFUN([_PANDORA_SEARCH_LIBAIO],[ AC_REQUIRE([AC_LIB_PREFIX]) AC_CHECK_HEADERS(libaio.h) AC_LIB_HAVE_LINKFLAGS(aio,, [ #include ], [ int aio_cmd= IO_CMD_PREAD; ]) AM_CONDITIONAL(HAVE_LIBAIO, [test "x${ac_cv_libaio}" = "xyes"]) AS_IF([test "x${ac_cv_libaio}" = "xyes"],[ AC_DEFINE([LINUX_NATIVE_AIO], [1], [Enabel libaio support in InnoDB]) ]) ]) AC_DEFUN([_PANDORA_HAVE_LIBAIO],[ AC_ARG_ENABLE([libaio], [AS_HELP_STRING([--disable-libaio], [Build with libaio support @<:@default=on@:>@])], [ac_enable_libaio="$enableval"], [ac_enable_libaio="yes"]) _PANDORA_SEARCH_LIBAIO ]) AC_DEFUN([PANDORA_HAVE_LIBAIO],[ AC_REQUIRE([_PANDORA_HAVE_LIBAIO]) ]) AC_DEFUN([_PANDORA_REQUIRE_LIBAIO],[ ac_enable_libaio="yes" _PANDORA_SEARCH_LIBAIO AS_IF([test "x$ac_cv_header_libaio_h" = "xno"],[ AC_MSG_ERROR([Couldn't find libaio.h. On Debian this can be found in libaio-dev. On Redhat this can be found in libaio-devel.]) ]) ]) AC_DEFUN([PANDORA_REQUIRE_LIBAIO],[ AC_REQUIRE([_PANDORA_REQUIRE_LIBAIO]) ]) libmemcached-1.0.8/m4/pandora_header_assert.m40000664000076400007640000000134611753573717021522 0ustar00brianbrian00000000000000dnl Copyright (C) 2009 Sun Microsystems, Inc. dnl This file is free software; Sun Microsystems, Inc. dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl PANDORA_HEADER_ASSERT dnl ---------------- dnl Check whether to enable assertions. AC_DEFUN([PANDORA_HEADER_ASSERT], [ AC_CHECK_HEADERS(assert.h) AC_MSG_CHECKING([whether to enable assertions]) AC_ARG_ENABLE([assert], [AS_HELP_STRING([--disable-assert], [Turn off assertions])], [ac_cv_assert="no"], [ac_cv_assert="yes"]) AC_MSG_RESULT([$ac_cv_assert]) AS_IF([test "$ac_cv_assert" = "no"], [AC_DEFINE(NDEBUG, 1, [Define to 1 if assertions should be disabled.])]) ]) libmemcached-1.0.8/libmemcachedutil-1.0/0000775000076400007640000000000011757025117020174 5ustar00brianbrian00000000000000libmemcached-1.0.8/libmemcachedutil-1.0/util.h0000664000076400007640000000366511753573717021346 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #include #include #include #include #include #include libmemcached-1.0.8/libmemcachedutil-1.0/pid.h0000664000076400007640000000404011753573717021131 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #ifndef WIN32 #include #endif #include #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API pid_t libmemcached_util_getpid(const char *hostname, in_port_t port, memcached_return_t *ret); LIBMEMCACHED_API pid_t libmemcached_util_getpid2(const char *hostname, in_port_t port, const char *username, const char *password, memcached_return_t *ret); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcachedutil-1.0/include.am0000664000076400007640000000057211753573717022154 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root nobase_include_HEADERS+= \ libmemcachedutil-1.0/flush.h \ libmemcachedutil-1.0/ostream.hpp \ libmemcachedutil-1.0/pid.h \ libmemcachedutil-1.0/ping.h \ libmemcachedutil-1.0/pool.h \ libmemcachedutil-1.0/util.h \ libmemcachedutil-1.0/version.h libmemcached-1.0.8/libmemcachedutil-1.0/pool.h0000664000076400007640000000626211753573717021336 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #pragma once #include #ifdef __cplusplus extern "C" { #endif struct memcached_pool_st; typedef struct memcached_pool_st memcached_pool_st; LIBMEMCACHED_API memcached_pool_st *memcached_pool_create(memcached_st* mmc, uint32_t initial, uint32_t max); LIBMEMCACHED_API memcached_pool_st *memcached_pool(const char *option_string, size_t option_string_length); LIBMEMCACHED_API memcached_st* memcached_pool_destroy(memcached_pool_st* pool); LIBMEMCACHED_API memcached_st* memcached_pool_pop(memcached_pool_st* pool, bool block, memcached_return_t* rc); LIBMEMCACHED_API memcached_return_t memcached_pool_push(memcached_pool_st* pool, memcached_st* mmc); LIBMEMCACHED_API memcached_return_t memcached_pool_release(memcached_pool_st* pool, memcached_st* mmc); LIBMEMCACHED_API memcached_st* memcached_pool_fetch(memcached_pool_st*, struct timespec* relative_time, memcached_return_t* rc); LIBMEMCACHED_API memcached_return_t memcached_pool_behavior_set(memcached_pool_st *ptr, memcached_behavior_t flag, uint64_t data); LIBMEMCACHED_API memcached_return_t memcached_pool_behavior_get(memcached_pool_st *ptr, memcached_behavior_t flag, uint64_t *value); #ifdef __cplusplus } // extern "C" #endif libmemcached-1.0.8/libmemcachedutil-1.0/ping.h0000664000076400007640000000401711753573717021316 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API bool libmemcached_util_ping(const char *hostname, in_port_t port, memcached_return_t *ret); LIBMEMCACHED_API bool libmemcached_util_ping2(const char *hostname, in_port_t port, const char *username, const char *password, memcached_return_t *ret); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcachedutil-1.0/ostream.hpp0000664000076400007640000000345211753573717022375 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once static inline std::ostream& operator<<(std::ostream& output, const enum memcached_return_t &arg) { output << memcached_strerror(NULL, arg); return output; } libmemcached-1.0.8/libmemcachedutil-1.0/version.h0000664000076400007640000000401711753573717022046 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API bool libmemcached_util_version_check(memcached_st *memc, uint8_t major_version, uint8_t minor_version, uint8_t micro_version); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcachedutil-1.0/flush.h0000664000076400007640000000356511753573717021511 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif LIBMEMCACHED_API bool libmemcached_util_flush(const char *hostname, in_port_t port, memcached_return_t *ret); #ifdef __cplusplus } #endif libmemcached-1.0.8/libmemcachedutil/0000775000076400007640000000000011757025120017672 5ustar00brianbrian00000000000000libmemcached-1.0.8/libmemcachedutil/common.h0000664000076400007640000000354411753573717021361 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached Utility library * * Copyright (C) 2011 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. * * Summary: connects to a host, and then flushes it (memcached_flush(3)). * */ #pragma once #include #include #include #include libmemcached-1.0.8/libmemcachedutil/include.am0000664000076400007640000000167511753573717021665 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root lib_LTLIBRARIES+= libmemcached/libmemcachedutil.la noinst_HEADERS+= \ libmemcachedutil/common.h libmemcached_libmemcachedutil_la_SOURCES= \ libmemcached/backtrace.cc \ libmemcachedutil/flush.cc \ libmemcachedutil/pid.cc \ libmemcachedutil/ping.cc \ libmemcachedutil/pool.cc \ libmemcachedutil/version.cc 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_LIBADD+= ${PTHREAD_LIBS} libmemcached_libmemcachedutil_la_LDFLAGS= ${AM_LDFLAGS} -version-info ${MEMCACHED_UTIL_LIBRARY_VERSION} libmemcached_libmemcachedutil_la_DEPENDENCIES= libmemcached/libmemcached.la libmemcached-1.0.8/libmemcachedutil/version.cc0000664000076400007640000000577311753573717021722 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #include #include struct local_context { uint8_t major_version; uint8_t minor_version; uint8_t micro_version; bool truth; }; static memcached_return_t check_server_version(const memcached_st *, const memcached_server_st *instance, void *context) { /* Do Nothing */ struct local_context *check= (struct local_context *)context; if (instance->major_version != UINT8_MAX && instance->major_version >= check->major_version and instance->minor_version >= check->minor_version and instance->micro_version >= check->micro_version ) { return MEMCACHED_SUCCESS; } check->truth= false; return MEMCACHED_FAILURE; } bool libmemcached_util_version_check(memcached_st *memc, uint8_t major_version, uint8_t minor_version, uint8_t micro_version) { if (memcached_failed(memcached_version(memc))) { return false; } struct local_context check= { major_version, minor_version, micro_version, true }; memcached_server_fn callbacks[1]; callbacks[0]= check_server_version; memcached_server_cursor(memc, callbacks, (void *)&check, 1); return check.truth; } libmemcached-1.0.8/libmemcachedutil/pool.cc0000664000076400007640000002576511753573717021211 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * */ #include #include #include #include #include struct memcached_pool_st { pthread_mutex_t mutex; pthread_cond_t cond; memcached_st *master; memcached_st **server_pool; int firstfree; const uint32_t size; uint32_t current_size; bool _owns_master; struct timespec _timeout; memcached_pool_st(memcached_st *master_arg, size_t max_arg) : master(master_arg), server_pool(NULL), firstfree(-1), size(max_arg), current_size(0), _owns_master(false) { pthread_mutex_init(&mutex, NULL); pthread_cond_init(&cond, NULL); _timeout.tv_sec= 5; _timeout.tv_nsec= 0; } const struct timespec& timeout() const { return _timeout; } bool release(memcached_st*, memcached_return_t& rc); memcached_st *fetch(memcached_return_t& rc); memcached_st *fetch(const struct timespec&, memcached_return_t& rc); bool init(uint32_t initial); ~memcached_pool_st() { for (int x= 0; x <= firstfree; ++x) { memcached_free(server_pool[x]); server_pool[x] = NULL; } pthread_mutex_destroy(&mutex); pthread_cond_destroy(&cond); delete [] server_pool; if (_owns_master) { memcached_free(master); } } void increment_version() { ++master->configure.version; } bool compare_version(const memcached_st *arg) const { return (arg->configure.version == version()); } int32_t version() const { return master->configure.version; } }; /** * Grow the connection pool by creating a connection structure and clone the * original memcached handle. */ static bool grow_pool(memcached_pool_st* pool) { assert(pool); memcached_st *obj; if (not (obj= memcached_clone(NULL, pool->master))) { return false; } pool->server_pool[++pool->firstfree]= obj; pool->current_size++; obj->configure.version= pool->version(); return true; } bool memcached_pool_st::init(uint32_t initial) { server_pool= new (std::nothrow) memcached_st *[size]; if (not server_pool) return false; /* Try to create the initial size of the pool. An allocation failure at this time is not fatal.. */ for (unsigned int x= 0; x < initial; ++x) { if (grow_pool(this) == false) { break; } } return true; } static inline memcached_pool_st *_pool_create(memcached_st* master, uint32_t initial, uint32_t max) { if (initial == 0 or max == 0 or (initial > max)) { return NULL; } memcached_pool_st *object= new (std::nothrow) memcached_pool_st(master, max); if (object == NULL) { return NULL; } /* Try to create the initial size of the pool. An allocation failure at this time is not fatal.. */ if (not object->init(initial)) { delete object; return NULL; } return object; } memcached_pool_st *memcached_pool_create(memcached_st* master, uint32_t initial, uint32_t max) { return _pool_create(master, initial, max); } memcached_pool_st * memcached_pool(const char *option_string, size_t option_string_length) { memcached_st *memc= memcached(option_string, option_string_length); if (memc == NULL) { return NULL; } memcached_pool_st *self= memcached_pool_create(memc, memc->configure.initial_pool_size, memc->configure.max_pool_size); if (self == NULL) { memcached_free(memc); return NULL; } self->_owns_master= true; return self; } memcached_st* memcached_pool_destroy(memcached_pool_st* pool) { if (pool == NULL) { return NULL; } // Legacy that we return the original structure memcached_st *ret= NULL; if (pool->_owns_master) { } else { ret= pool->master; } delete pool; return ret; } memcached_st* memcached_pool_st::fetch(memcached_return_t& rc) { static struct timespec relative_time= { 0, 0 }; return fetch(relative_time, rc); } memcached_st* memcached_pool_st::fetch(const struct timespec& relative_time, memcached_return_t& rc) { rc= MEMCACHED_SUCCESS; int error; if ((error= pthread_mutex_lock(&mutex)) != 0) { rc= MEMCACHED_IN_PROGRESS; return NULL; } memcached_st *ret= NULL; do { if (firstfree > -1) { ret= server_pool[firstfree--]; } else if (current_size == size) { if (relative_time.tv_sec == 0 and relative_time.tv_nsec == 0) { error= pthread_mutex_unlock(&mutex); rc= MEMCACHED_NOTFOUND; return NULL; } struct timespec time_to_wait= {0, 0}; time_to_wait.tv_sec= time(NULL) +relative_time.tv_sec; time_to_wait.tv_nsec= relative_time.tv_nsec; int thread_ret; if ((thread_ret= pthread_cond_timedwait(&cond, &mutex, &time_to_wait)) != 0) { int unlock_error; if ((unlock_error= pthread_mutex_unlock(&mutex)) != 0) { } if (thread_ret == ETIMEDOUT) { rc= MEMCACHED_TIMEOUT; } else { errno= thread_ret; rc= MEMCACHED_ERRNO; } return NULL; } } else if (grow_pool(this) == false) { int unlock_error; if ((unlock_error= pthread_mutex_unlock(&mutex)) != 0) { } return NULL; } } while (ret == NULL); if ((error= pthread_mutex_unlock(&mutex)) != 0) { } return ret; } bool memcached_pool_st::release(memcached_st *released, memcached_return_t& rc) { rc= MEMCACHED_SUCCESS; if (released == NULL) { rc= MEMCACHED_INVALID_ARGUMENTS; return false; } int error; if ((error= pthread_mutex_lock(&mutex))) { rc= MEMCACHED_IN_PROGRESS; return false; } /* Someone updated the behavior on the object, so we clone a new memcached_st with the new settings. If we fail to clone, we keep the old one around. */ if (compare_version(released) == false) { memcached_st *memc; if ((memc= memcached_clone(NULL, master))) { memcached_free(released); released= memc; } } server_pool[++firstfree]= released; if (firstfree == 0 and current_size == size) { /* we might have people waiting for a connection.. wake them up :-) */ if ((error= pthread_cond_broadcast(&cond)) != 0) { } } if ((error= pthread_mutex_unlock(&mutex)) != 0) { } return true; } memcached_st* memcached_pool_fetch(memcached_pool_st* pool, struct timespec* relative_time, memcached_return_t* rc) { if (pool == NULL) { return NULL; } memcached_return_t unused; if (rc == NULL) { rc= &unused; } if (relative_time == NULL) { return pool->fetch(*rc); } return pool->fetch(*relative_time, *rc); } memcached_st* memcached_pool_pop(memcached_pool_st* pool, bool block, memcached_return_t *rc) { if (pool == NULL) { return NULL; } memcached_return_t unused; if (rc == NULL) { rc= &unused; } memcached_st *memc; if (block) { memc= pool->fetch(pool->timeout(), *rc); } else { memc= pool->fetch(*rc); } return memc; } memcached_return_t memcached_pool_release(memcached_pool_st* pool, memcached_st *released) { if (pool == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } memcached_return_t rc; (void) pool->release(released, rc); return rc; } memcached_return_t memcached_pool_push(memcached_pool_st* pool, memcached_st *released) { return memcached_pool_release(pool, released); } memcached_return_t memcached_pool_behavior_set(memcached_pool_st *pool, memcached_behavior_t flag, uint64_t data) { if (pool == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } int error; if ((error= pthread_mutex_lock(&pool->mutex))) { return MEMCACHED_IN_PROGRESS; } /* update the master */ memcached_return_t rc= memcached_behavior_set(pool->master, flag, data); if (memcached_failed(rc)) { if ((error= pthread_mutex_unlock(&pool->mutex)) != 0) { } return rc; } pool->increment_version(); /* update the clones */ for (int xx= 0; xx <= pool->firstfree; ++xx) { if (memcached_success(memcached_behavior_set(pool->server_pool[xx], flag, data))) { pool->server_pool[xx]->configure.version= pool->version(); } else { memcached_st *memc; if ((memc= memcached_clone(NULL, pool->master))) { memcached_free(pool->server_pool[xx]); pool->server_pool[xx]= memc; /* I'm not sure what to do in this case.. this would happen if we fail to push the server list inside the client.. I should add a testcase for this, but I believe the following would work, except that you would add a hole in the pool list.. in theory you could end up with an empty pool.... */ } } } if ((error= pthread_mutex_unlock(&pool->mutex)) != 0) { } return rc; } memcached_return_t memcached_pool_behavior_get(memcached_pool_st *pool, memcached_behavior_t flag, uint64_t *value) { if (pool == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } int error; if ((error= pthread_mutex_lock(&pool->mutex))) { return MEMCACHED_IN_PROGRESS; } *value= memcached_behavior_get(pool->master, flag); if ((error= pthread_mutex_unlock(&pool->mutex)) != 0) { } return MEMCACHED_SUCCESS; } libmemcached-1.0.8/libmemcachedutil/flush.cc0000664000076400007640000000416711753573717021352 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * * Summary: connects to a host, and then flushes it (memcached_flush(3)). * */ #include bool libmemcached_util_flush(const char *hostname, in_port_t port, memcached_return_t *ret) { memcached_st *memc_ptr= memcached_create(NULL); memcached_return_t rc= memcached_server_add(memc_ptr, hostname, port); if (memcached_success(rc)) { rc= memcached_flush(memc_ptr, 0); } memcached_free(memc_ptr); if (ret) { *ret= rc; } return memcached_success(rc); } libmemcached-1.0.8/libmemcachedutil/pid.cc0000664000076400007640000001116711753573717021003 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * * Summary: connects to a host, and determines what its pid is * */ #include // Never look at the stat object directly. pid_t libmemcached_util_getpid(const char *hostname, in_port_t port, memcached_return_t *ret) { pid_t pid= -1; memcached_return_t unused; if (ret == NULL) { ret= &unused; } memcached_st *memc_ptr= memcached_create(NULL); if (memc_ptr == NULL) { *ret= MEMCACHED_MEMORY_ALLOCATION_FAILURE; return -1; } memcached_return_t rc= memcached_server_add(memc_ptr, hostname, port); if (memcached_success(rc)) { memcached_stat_st *stat= memcached_stat(memc_ptr, NULL, &rc); if (memcached_success(rc) and stat and stat->pid != -1) { pid= stat->pid; } else if (memcached_success(rc)) { rc= MEMCACHED_UNKNOWN_STAT_KEY; // Something went wrong if this happens } else if (rc == MEMCACHED_SOME_ERRORS) // Generic answer, we will now find the specific reason (if one exists) { memcached_server_instance_st instance= memcached_server_instance_by_position(memc_ptr, 0); assert_msg(instance and instance->error_messages, " "); if (instance and instance->error_messages) { rc= memcached_server_error_return(instance); } } memcached_stat_free(memc_ptr, stat); } memcached_free(memc_ptr); *ret= rc; return pid; } pid_t libmemcached_util_getpid2(const char *hostname, in_port_t port, const char *username, const char *password, memcached_return_t *ret) { if (username == NULL) { return libmemcached_util_getpid(hostname, port, ret); } pid_t pid= -1; memcached_return_t unused; if (not ret) ret= &unused; if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0) { *ret= MEMCACHED_NOT_SUPPORTED; return pid; } memcached_st *memc_ptr= memcached_create(NULL); if (not memc_ptr) { *ret= MEMCACHED_MEMORY_ALLOCATION_FAILURE; return -1; } if (memcached_failed(*ret= memcached_set_sasl_auth_data(memc_ptr, username, password))) { memcached_free(memc_ptr); return false; } memcached_return_t rc= memcached_server_add(memc_ptr, hostname, port); if (memcached_success(rc)) { memcached_stat_st *stat= memcached_stat(memc_ptr, NULL, &rc); if (memcached_success(rc) and stat and stat->pid != -1) { pid= stat->pid; } else if (memcached_success(rc)) { rc= MEMCACHED_UNKNOWN_STAT_KEY; // Something went wrong if this happens } else if (rc == MEMCACHED_SOME_ERRORS) // Generic answer, we will now find the specific reason (if one exists) { memcached_server_instance_st instance= memcached_server_instance_by_position(memc_ptr, 0); #if 0 assert_msg(instance and instance->error_messages, " "); #endif if (instance and instance->error_messages) { rc= memcached_server_error_return(instance); } } memcached_stat_free(memc_ptr, stat); } memcached_free(memc_ptr); *ret= rc; return pid; } libmemcached-1.0.8/libmemcachedutil/ping.cc0000664000076400007640000000755411753573717021171 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 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. * * Summary: connects to a host, and makes sure it is alive. * */ #include bool libmemcached_util_ping(const char *hostname, in_port_t port, memcached_return_t *ret) { memcached_return_t unused; if (ret == NULL) { ret= &unused; } memcached_st *memc_ptr= memcached_create(NULL); if (memc_ptr == NULL) { *ret= MEMCACHED_MEMORY_ALLOCATION_FAILURE; return false; } memcached_return_t rc= memcached_server_add(memc_ptr, hostname, port); if (memcached_success(rc)) { rc= memcached_version(memc_ptr); } if (memcached_failed(rc) and rc == MEMCACHED_SOME_ERRORS) { memcached_server_instance_st instance= memcached_server_instance_by_position(memc_ptr, 0); assert_msg(instance and instance->error_messages, " "); if (instance and instance->error_messages) { rc= memcached_server_error_return(instance); } } memcached_free(memc_ptr); *ret= rc; return memcached_success(rc); } bool libmemcached_util_ping2(const char *hostname, in_port_t port, const char *username, const char *password, memcached_return_t *ret) { if (username == NULL) { return libmemcached_util_ping(hostname, port, ret); } memcached_return_t unused; if (not ret) ret= &unused; if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0) { *ret= MEMCACHED_NOT_SUPPORTED; return false; } memcached_st *memc_ptr= memcached_create(NULL); if (not memc_ptr) { *ret= MEMCACHED_MEMORY_ALLOCATION_FAILURE; return false; } if (memcached_failed(*ret= memcached_set_sasl_auth_data(memc_ptr, username, password))) { memcached_free(memc_ptr); return false; } memcached_return_t rc= memcached_server_add(memc_ptr, hostname, port); if (memcached_success(rc)) { rc= memcached_version(memc_ptr); } if (memcached_failed(rc) and rc == MEMCACHED_SOME_ERRORS) { memcached_server_instance_st instance= memcached_server_instance_by_position(memc_ptr, 0); assert_msg(instance and instance->error_messages, " "); if (instance and instance->error_messages) { rc= memcached_server_error_return(instance); } } memcached_free(memc_ptr); *ret= rc; return memcached_success(rc); } libmemcached-1.0.8/README0000664000076400007640000000266511753573717015310 0ustar00brianbrian00000000000000Hi! So what is this? It is a library in C for connecting to memcached servers (http://danga.com/memcached/). It is also a collection of utilities designed to work with memcached. memcat - Copy the value of a key to standard output memflush - Flush the contents of your servers. memrm - Remove a key(s) from the server. memstat - Dump the stats of your servers to standard output memslap - Load generation utility (benchmark!) The library is in production in many locations (upwards to 1000+ nodes). The project has information here: http://libmemcached.org/ Documentation can be found here: http://docs.libmemcached.org/ Want to contribute? If you write more then three good patches, then I will just ask you to commit directly to the tree. I am happy to have additional people work on this project. Please checkout README.FIRST. You will need a C99 compiler in order to compile this library. Currently we actively support Linux, MacOSX, FreeBSD, and Solaris. A Windows port is currently not supported, but one is listed on the homepage that is supported by someone in the community. If you are looking for answers to your questions please check out the mailing list at: http://lists.libmemcached.org/ Subscription information for the libmemcached mailing list can be found there. Please report bugs here: https://bugs.launchpad.net/libmemcached/ You can purchase support from: http://datadifferential.com/ Cheers, -Brian Aker Seattle, WA. libmemcached-1.0.8/libmemcachedprotocol/0000775000076400007640000000000011757025120020556 5ustar00brianbrian00000000000000libmemcached-1.0.8/libmemcachedprotocol/common.h0000664000076400007640000001170411753573717022242 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #include "config.h" #include #include #include #include #include /* * I don't really need the following two functions as function pointers * in the instance handle, but I don't want to put them in the global * namespace for those linking statically (personally I don't like that, * but some people still do). If it ever shows up as a performance thing * I'll look into optimizing this ;-) */ typedef bool (*drain_func)(memcached_protocol_client_st *client); typedef protocol_binary_response_status (*spool_func)(memcached_protocol_client_st *client, const void *data, size_t length); /** * Definition of the per instance structure. */ struct memcached_protocol_st { memcached_binary_protocol_callback_st *callback; memcached_protocol_recv_func recv; memcached_protocol_send_func send; /* * I really don't need these as funciton pointers, but I don't want * to clutter the namespace if someone links statically. */ drain_func drain; spool_func spool; /* * To avoid keeping a buffer in each client all the time I have a * bigger buffer in the instance that I read to initially, and then * I try to parse and execute as much from the buffer. If I wasn't able * to process all data I'll keep that in a per-connection buffer until * the next time I can read from the socket. */ uint8_t *input_buffer; size_t input_buffer_size; bool pedantic; /* @todo use multiple sized buffers */ cache_t *buffer_cache; }; struct chunk_st { /* Pointer to the data */ char *data; /* The offset to the first byte into the buffer that is used */ size_t offset; /* The offset into the buffer for the first free byte */ size_t nbytes; /* The number of bytes in the buffer */ size_t size; /* Pointer to the next buffer in the chain */ struct chunk_st *next; }; #define CHUNK_BUFFERSIZE 2048 typedef memcached_protocol_event_t (*process_data)(struct memcached_protocol_client_st *client, ssize_t *length, void **endptr); enum ascii_cmd { GET_CMD, GETS_CMD, SET_CMD, ADD_CMD, REPLACE_CMD, CAS_CMD, APPEND_CMD, PREPEND_CMD, DELETE_CMD, INCR_CMD, DECR_CMD, STATS_CMD, FLUSH_ALL_CMD, VERSION_CMD, QUIT_CMD, VERBOSITY_CMD, UNKNOWN_CMD }; struct memcached_protocol_client_st { bool is_verbose; memcached_protocol_st *root; memcached_socket_t sock; int error; /* Linked list of data to send */ struct chunk_st *output; struct chunk_st *output_tail; /* * While we process input data, this is where we spool incomplete commands * if we need to receive more data.... * @todo use the buffercace */ uint8_t *input_buffer; size_t input_buffer_size; size_t input_buffer_offset; /* The callback to the protocol handler to use (ascii or binary) */ process_data work; /* * Should the spool data discard the data to send or not? (aka noreply in * the ascii protocol.. */ bool mute; /* Members used by the binary protocol */ protocol_binary_request_header *current_command; /* Members used by the ascii protocol */ enum ascii_cmd ascii_command; }; #include "ascii_handler.h" #include "binary_handler.h" libmemcached-1.0.8/libmemcachedprotocol/include.am0000664000076400007640000000235511753573717022545 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root lib_LTLIBRARIES+= libmemcached/libmemcachedprotocol.la noinst_HEADERS+= \ libmemcachedprotocol/ascii_handler.h \ libmemcachedprotocol/binary_handler.h \ libmemcachedprotocol/cache.h \ libmemcachedprotocol/common.h libmemcached_libmemcachedprotocol_la_SOURCES= \ libmemcached/byteorder.cc \ libmemcachedprotocol/ascii_handler.c \ libmemcachedprotocol/binary_handler.c \ libmemcachedprotocol/cache.c \ libmemcachedprotocol/handler.c \ libmemcachedprotocol/pedantic.c libmemcached_libmemcachedprotocol_la_CFLAGS= \ ${AM_CFLAGS} \ ${NO_CONVERSION} \ -DBUILDING_LIBMEMCACHED libmemcached_libmemcachedprotocol_la_CFLAGS+= ${PTHREAD_CFLAGS} libmemcached_libmemcachedprotocol_la_CXXFLAGS= \ ${AM_CXXFLAGS} \ -DBUILDING_LIBMEMCACHED libmemcached_libmemcachedprotocol_la_CXXFLAGS+= ${PTHREAD_CFLAGS} libmemcached_libmemcachedprotocol_la_LIBADD= ${PTHREAD_LIBS} libmemcached_libmemcachedprotocol_la_LDFLAGS= ${AM_LDFLAGS} libmemcached_libmemcachedprotocol_la_LDFLAGS+= -version-info ${MEMCACHED_PROTOCAL_LIBRARY_VERSION} libmemcached-1.0.8/libmemcachedprotocol/ascii_handler.c0000664000076400007640000007673511753573717023551 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 #include #include #include #include #include static void print_ascii_command(memcached_protocol_client_st *client) { if (client->is_verbose) { switch (client->ascii_command) { case SET_CMD: fprintf(stderr, "%s:%d SET_CMD\n", __FILE__, __LINE__); break; case ADD_CMD: fprintf(stderr, "%s:%d ADD_CMD\n", __FILE__, __LINE__); break; case REPLACE_CMD: fprintf(stderr, "%s:%d REPLACE_CMD\n", __FILE__, __LINE__); break; case CAS_CMD: fprintf(stderr, "%s:%d CAS_CMD\n", __FILE__, __LINE__); break; case APPEND_CMD: fprintf(stderr, "%s:%d APPEND_CMD\n", __FILE__, __LINE__); break; case PREPEND_CMD: fprintf(stderr, "%s:%d PREPEND_CMD\n", __FILE__, __LINE__); break; case DELETE_CMD: fprintf(stderr, "%s:%d DELETE_CMD\n", __FILE__, __LINE__); break; case INCR_CMD: /* FALLTHROUGH */ fprintf(stderr, "%s:%d INCR_CMD\n", __FILE__, __LINE__); break; case DECR_CMD: fprintf(stderr, "%s:%d DECR_CMD\n", __FILE__, __LINE__); break; case STATS_CMD: fprintf(stderr, "%s:%d STATS_CMD\n", __FILE__, __LINE__); break; case FLUSH_ALL_CMD: fprintf(stderr, "%s:%d FLUSH_ALL_CMD\n", __FILE__, __LINE__); break; case VERSION_CMD: fprintf(stderr, "%s:%d VERSION_CMD\n", __FILE__, __LINE__); break; case QUIT_CMD: fprintf(stderr, "%s:%d QUIT_CMD\n", __FILE__, __LINE__); break; case VERBOSITY_CMD: fprintf(stderr, "%s:%d VERBOSITY_CMD\n", __FILE__, __LINE__); break; case GET_CMD: fprintf(stderr, "%s:%d GET_CMD\n", __FILE__, __LINE__); break; case GETS_CMD: fprintf(stderr, "%s:%d GETS_CMD\n", __FILE__, __LINE__); break; default: case UNKNOWN_CMD: fprintf(stderr, "%s:%d UNKNOWN_CMD\n", __FILE__, __LINE__); break; } } } /** * Try to parse a key from the string. * @pointer start pointer to a pointer to the string (IN and OUT) * @return length of the string of -1 if this was an illegal key (invalid * characters or invalid length) * @todo add length! */ static uint16_t parse_ascii_key(char **start) { uint16_t len= 0; char *c= *start; /* Strip leading whitespaces */ while (isspace(*c)) { ++c; } *start= c; while (*c != '\0' && !isspace(*c) && !iscntrl(*c)) { ++c; ++len; } if (len == 0 || len > 240 || (*c != '\0' && *c != '\r' && iscntrl(*c))) { return 0; } return len; } /** * Spool a zero-terminated string * @param client destination * @param text the text to spool * @return status of the spool operation */ static protocol_binary_response_status raw_response_handler(memcached_protocol_client_st *client, const char *text) { if (client->is_verbose) { fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, text); } if (client->root->drain(client) == false) { return PROTOCOL_BINARY_RESPONSE_EINTERNAL; } assert(client->output != NULL); #if 0 if (client->output == NULL) { /* I can write directly to the socket.... */ do { size_t num_bytes= len -offset; ssize_t nw= client->root->send(client, client->sock, ptr + offset, num_bytes); if (nw == -1) { if (get_socket_errno() == EWOULDBLOCK) { break; } else if (get_socket_errno() != EINTR) { client->error= errno; return PROTOCOL_BINARY_RESPONSE_EINTERNAL; } } else { offset += (size_t)nw; } } while (offset < len); } #endif return client->root->spool(client, text, strlen(text)); } /** * Send a "CLIENT_ERROR" message back to the client with the correct * format of the command being sent * @param client the client to send the message to */ static void send_command_usage(memcached_protocol_client_st *client) { const char *errmsg[]= { [GET_CMD]= "CLIENT_ERROR: Syntax error: get *\r\n", [GETS_CMD]= "CLIENT_ERROR: Syntax error: gets *\r\n", [SET_CMD]= "CLIENT_ERROR: Syntax error: set [noreply]\r\n", [ADD_CMD]= "CLIENT_ERROR: Syntax error: add [noreply]\r\n", [REPLACE_CMD]= "CLIENT_ERROR: Syntax error: replace [noreply]\r\n", [CAS_CMD]= "CLIENT_ERROR: Syntax error: cas [noreply]\r\n", [APPEND_CMD]= "CLIENT_ERROR: Syntax error: append [noreply]\r\n", [PREPEND_CMD]= "CLIENT_ERROR: Syntax error: prepend [noreply]\r\n", [DELETE_CMD]= "CLIENT_ERROR: Syntax error: delete_object [noreply]\r\n", [INCR_CMD]= "CLIENT_ERROR: Syntax error: incr [noreply]\r\n", [DECR_CMD]= "CLIENT_ERROR: Syntax error: decr [noreply]\r\n", [STATS_CMD]= "CLIENT_ERROR: Syntax error: stats [key]\r\n", [FLUSH_ALL_CMD]= "CLIENT_ERROR: Syntax error: flush_all [timeout] [noreply]\r\n", [VERSION_CMD]= "CLIENT_ERROR: Syntax error: version\r\n", [QUIT_CMD]="CLIENT_ERROR: Syntax error: quit\r\n", [VERBOSITY_CMD]= "CLIENT_ERROR: Syntax error: verbosity \r\n", [UNKNOWN_CMD]= "CLIENT_ERROR: Unknown command\r\n", }; client->mute = false; raw_response_handler(client, errmsg[client->ascii_command]); } /** * Callback for the VERSION responses * @param cookie client identifier * @param text the length of the body * @param textlen the length of the body */ static protocol_binary_response_status ascii_version_response_handler(const void *cookie, const void *text, uint32_t textlen) { memcached_protocol_client_st *client= (memcached_protocol_client_st*)cookie; raw_response_handler(client, "VERSION "); client->root->spool(client, text, textlen); raw_response_handler(client, "\r\n"); return PROTOCOL_BINARY_RESPONSE_SUCCESS; } /** * Callback for the GET/GETQ/GETK and GETKQ responses * @param cookie client identifier * @param key the key for the item * @param keylen the length of the key * @param body the length of the body * @param bodylen the length of the body * @param flags the flags for the item * @param cas the CAS id for the item */ static protocol_binary_response_status ascii_get_response_handler(const void *cookie, const void *key, uint16_t keylen, const void *body, uint32_t bodylen, uint32_t flags, uint64_t cas) { memcached_protocol_client_st *client= (void*)cookie; char buffer[300]; strcpy(buffer, "VALUE "); const char *source= key; char *dest= buffer + 6; for (int x= 0; x < keylen; ++x) { if (*source != '\0' && !isspace(*source) && !iscntrl(*source)) { *dest= *source; } else { return PROTOCOL_BINARY_RESPONSE_EINVAL; /* key constraints in ascii */ } ++dest; ++source; } size_t used= (size_t)(dest - buffer); if (client->ascii_command == GETS_CMD) { snprintf(dest, sizeof(buffer) - used, " %u %u %" PRIu64 "\r\n", flags, bodylen, cas); } else { snprintf(dest, sizeof(buffer) - used, " %u %u\r\n", flags, bodylen); } client->root->spool(client, buffer, strlen(buffer)); client->root->spool(client, body, bodylen); client->root->spool(client, "\r\n", 2); return PROTOCOL_BINARY_RESPONSE_SUCCESS; } /** * Callback for the STAT responses * @param cookie client identifier * @param key the key for the item * @param keylen the length of the key * @param body the length of the body * @param bodylen the length of the body */ static protocol_binary_response_status ascii_stat_response_handler(const void *cookie, const void *key, uint16_t keylen, const void *body, uint32_t bodylen) { memcached_protocol_client_st *client= (void*)cookie; if (key != NULL) { raw_response_handler(client, "STAT "); client->root->spool(client, key, keylen); raw_response_handler(client, " "); client->root->spool(client, body, bodylen); raw_response_handler(client, "\r\n"); } else { raw_response_handler(client, "END\r\n"); } return PROTOCOL_BINARY_RESPONSE_SUCCESS; } /** * Process a get or a gets request. * @param client the client handle * @param buffer the complete get(s) command * @param end the last character in the command */ static void ascii_process_gets(memcached_protocol_client_st *client, char *buffer, char *end) { char *key= buffer; /* Skip command */ key += (client->ascii_command == GETS_CMD) ? 5 : 4; int num_keys= 0; while (key < end) { uint16_t nkey= parse_ascii_key(&key); if (nkey == 0) /* Invalid key... stop processing this line */ { break; } (void)client->root->callback->interface.v1.get(client, key, nkey, ascii_get_response_handler); key += nkey; ++num_keys; } if (num_keys == 0) { send_command_usage(client); } else { client->root->spool(client, "END\r\n", 5); } } /** * Try to split up the command line "asdf asdf asdf asdf\n" into an * argument vector for easier parsing. * @param start the first character in the command line * @param end the last character in the command line ("\n") * @param vec the vector to insert the pointers into * @size the number of elements in the vector * @return the number of tokens in the vector */ static int ascii_tokenize_command(char *str, char *end, char **vec, int size) { int elem= 0; while (str < end) { /* Skip leading blanks */ while (str < end && isspace(*str)) { ++str; } if (str == end) { return elem; } vec[elem++]= str; /* find the next non-blank field */ while (str < end && !isspace(*str)) { ++str; } /* zero-terminate it for easier parsing later on */ *str= '\0'; ++str; /* Is the vector full? */ if (elem == size) { break; } } return elem; } /** * If we for some reasons needs to push the line back to read more * data we have to reverse the tokenization. Just do the brain-dead replace * of all '\0' to ' ' and set the last character to '\n'. We could have used * the vector we created, but then we would have to search for all of the * spaces we ignored... * @param start pointer to the first character in the buffer to recover * @param end pointer to the last character in the buffer to recover */ static void recover_tokenize_command(char *start, char *end) { while (start < end) { if (*start == '\0') *start= ' '; ++start; } *end= '\n'; } /** * Convert the textual command into a comcode */ static enum ascii_cmd ascii_to_cmd(char *start, size_t length) { struct { const char *cmd; size_t len; enum ascii_cmd cc; } commands[]= { { .cmd= "get", .len= 3, .cc= GET_CMD }, { .cmd= "gets", .len= 4, .cc= GETS_CMD }, { .cmd= "set", .len= 3, .cc= SET_CMD }, { .cmd= "add", .len= 3, .cc= ADD_CMD }, { .cmd= "replace", .len= 7, .cc= REPLACE_CMD }, { .cmd= "cas", .len= 3, .cc= CAS_CMD }, { .cmd= "append", .len= 6, .cc= APPEND_CMD }, { .cmd= "prepend", .len= 7, .cc= PREPEND_CMD }, { .cmd= "delete_object", .len= 6, .cc= DELETE_CMD }, { .cmd= "incr", .len= 4, .cc= INCR_CMD }, { .cmd= "decr", .len= 4, .cc= DECR_CMD }, { .cmd= "stats", .len= 5, .cc= STATS_CMD }, { .cmd= "flush_all", .len= 9, .cc= FLUSH_ALL_CMD }, { .cmd= "version", .len= 7, .cc= VERSION_CMD }, { .cmd= "quit", .len= 4, .cc= QUIT_CMD }, { .cmd= "verbosity", .len= 9, .cc= VERBOSITY_CMD }, { .cmd= NULL, .len= 0, .cc= UNKNOWN_CMD }}; int x= 0; while (commands[x].len > 0) { if (length >= commands[x].len) { if (strncmp(start, commands[x].cmd, commands[x].len) == 0) { /* Potential hit */ if (length == commands[x].len || isspace(*(start + commands[x].len))) { return commands[x].cc; } } } ++x; } return UNKNOWN_CMD; } /** * Perform a delete_object operation. * * @param client client requesting the deletion * @param tokens the command as a vector * @param ntokens the number of items in the vector */ static void process_delete(memcached_protocol_client_st *client, char **tokens, int ntokens) { char *key= tokens[1]; uint16_t nkey; if (ntokens != 2 || (nkey= parse_ascii_key(&key)) == 0) { send_command_usage(client); return; } if (client->root->callback->interface.v1.delete_object == NULL) { raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); return; } protocol_binary_response_status rval= client->root->callback->interface.v1.delete_object(client, key, nkey, 0); if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS) { raw_response_handler(client, "DELETED\r\n"); } else if (rval == PROTOCOL_BINARY_RESPONSE_KEY_ENOENT) { raw_response_handler(client, "NOT_FOUND\r\n"); } else { char msg[80]; snprintf(msg, sizeof(msg), "SERVER_ERROR: delete_object failed %u\r\n",(uint32_t)rval); raw_response_handler(client, msg); } } static void process_arithmetic(memcached_protocol_client_st *client, char **tokens, int ntokens) { char *key= tokens[1]; uint16_t nkey; if (ntokens != 3 || (nkey= parse_ascii_key(&key)) == 0) { send_command_usage(client); return; } uint64_t cas; uint64_t result; uint64_t delta= strtoull(tokens[2], NULL, 10); protocol_binary_response_status rval; if (client->ascii_command == INCR_CMD) { if (client->root->callback->interface.v1.increment == NULL) { raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); return; } rval= client->root->callback->interface.v1.increment(client, key, nkey, delta, 0, 0, &result, &cas); } else { if (client->root->callback->interface.v1.decrement == NULL) { raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); return; } rval= client->root->callback->interface.v1.decrement(client, key, nkey, delta, 0, 0, &result, &cas); } if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS) { char buffer[80]; snprintf(buffer, sizeof(buffer), "%"PRIu64"\r\n", result); raw_response_handler(client, buffer); } else { raw_response_handler(client, "NOT_FOUND\r\n"); } } /** * Process the stats command (with or without a key specified) * @param key pointer to the first character after "stats" * @param end pointer to the "\n" */ static void process_stats(memcached_protocol_client_st *client, char *key, char *end) { if (client->root->callback->interface.v1.stat == NULL) { raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); return; } while (isspace(*key)) { key++; } uint16_t nkey= (uint16_t)(end - key); (void)client->root->callback->interface.v1.stat(client, key, nkey, ascii_stat_response_handler); } static void process_version(memcached_protocol_client_st *client, char **tokens, int ntokens) { (void)tokens; if (ntokens != 1) { send_command_usage(client); return; } if (client->root->callback->interface.v1.version == NULL) { raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); return; } client->root->callback->interface.v1.version(client, ascii_version_response_handler); } static void process_flush(memcached_protocol_client_st *client, char **tokens, int ntokens) { if (ntokens > 2) { send_command_usage(client); return; } if (client->root->callback->interface.v1.flush_object == NULL) { raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); return; } uint32_t timeout= 0; if (ntokens == 2) { timeout= (uint32_t)strtoul(tokens[1], NULL, 10); } protocol_binary_response_status rval; rval= client->root->callback->interface.v1.flush_object(client, timeout); if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS) raw_response_handler(client, "OK\r\n"); else raw_response_handler(client, "SERVER_ERROR: internal error\r\n"); } /** * Process one of the storage commands * @param client the client performing the operation * @param tokens the command tokens * @param ntokens the number of tokens * @param start pointer to the first character in the line * @param end pointer to the pointer where the last character of this * command is (IN and OUT) * @param length the number of bytes available * @return -1 if an error occurs (and we should just terminate the connection * because we are out of sync) * 0 storage command completed, continue processing * 1 We need more data, so just go ahead and wait for more! */ static inline int process_storage_command(memcached_protocol_client_st *client, char **tokens, int ntokens, char *start, char **end, ssize_t length) { (void)ntokens; /* already checked */ char *key= tokens[1]; uint16_t nkey= parse_ascii_key(&key); if (nkey == 0) { /* return error */ raw_response_handler(client, "CLIENT_ERROR: bad key\r\n"); return -1; } uint32_t flags= (uint32_t)strtoul(tokens[2], NULL, 10); uint32_t timeout= (uint32_t)strtoul(tokens[3], NULL, 10); unsigned long nbytes= strtoul(tokens[4], NULL, 10); /* Do we have all data? */ unsigned long need= nbytes + (unsigned long)((*end - start) + 1) + 2; /* \n\r\n */ if ((ssize_t)need > length) { /* Keep on reading */ recover_tokenize_command(start, *end); return 1; } void *data= (*end) + 1; uint64_t cas= 0; uint64_t result_cas; protocol_binary_response_status rval; switch (client->ascii_command) { case SET_CMD: rval= client->root->callback->interface.v1.set(client, key, (uint16_t)nkey, data, (uint32_t)nbytes, flags, timeout, cas, &result_cas); break; case ADD_CMD: rval= client->root->callback->interface.v1.add(client, key, (uint16_t)nkey, data, (uint32_t)nbytes, flags, timeout, &result_cas); break; case CAS_CMD: cas= strtoull(tokens[5], NULL, 10); /* FALLTHROUGH */ case REPLACE_CMD: rval= client->root->callback->interface.v1.replace(client, key, (uint16_t)nkey, data, (uint32_t)nbytes, flags, timeout, cas, &result_cas); break; case APPEND_CMD: rval= client->root->callback->interface.v1.append(client, key, (uint16_t)nkey, data, (uint32_t)nbytes, cas, &result_cas); break; case PREPEND_CMD: rval= client->root->callback->interface.v1.prepend(client, key, (uint16_t)nkey, data, (uint32_t)nbytes, cas, &result_cas); break; /* gcc complains if I don't put all of the enums in here.. */ case GET_CMD: case GETS_CMD: case DELETE_CMD: case DECR_CMD: case INCR_CMD: case STATS_CMD: case FLUSH_ALL_CMD: case VERSION_CMD: case QUIT_CMD: case VERBOSITY_CMD: case UNKNOWN_CMD: default: abort(); /* impossible */ } if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS) { raw_response_handler(client, "STORED\r\n"); } else { if (client->ascii_command == CAS_CMD) { if (rval == PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS) { raw_response_handler(client, "EXISTS\r\n"); } else if (rval == PROTOCOL_BINARY_RESPONSE_KEY_ENOENT) { raw_response_handler(client, "NOT_FOUND\r\n"); } else { raw_response_handler(client, "NOT_STORED\r\n"); } } else { raw_response_handler(client, "NOT_STORED\r\n"); } } *end += nbytes + 2; return 0; } static int process_cas_command(memcached_protocol_client_st *client, char **tokens, int ntokens, char *start, char **end, ssize_t length) { if (ntokens != 6) { send_command_usage(client); return false; } if (client->root->callback->interface.v1.replace == NULL) { raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); return false; } return process_storage_command(client, tokens, ntokens, start, end, length); } static int process_set_command(memcached_protocol_client_st *client, char **tokens, int ntokens, char *start, char **end, ssize_t length) { if (ntokens != 5) { send_command_usage(client); return false; } if (client->root->callback->interface.v1.set == NULL) { raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); return false; } return process_storage_command(client, tokens, ntokens, start, end, length); } static int process_add_command(memcached_protocol_client_st *client, char **tokens, int ntokens, char *start, char **end, ssize_t length) { if (ntokens != 5) { send_command_usage(client); return false; } if (client->root->callback->interface.v1.add == NULL) { raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); return false; } return process_storage_command(client, tokens, ntokens, start, end, length); } static int process_replace_command(memcached_protocol_client_st *client, char **tokens, int ntokens, char *start, char **end, ssize_t length) { if (ntokens != 5) { send_command_usage(client); return false; } if (client->root->callback->interface.v1.replace == NULL) { raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); return false; } return process_storage_command(client, tokens, ntokens, start, end, length); } static int process_append_command(memcached_protocol_client_st *client, char **tokens, int ntokens, char *start, char **end, ssize_t length) { if (ntokens != 5) { send_command_usage(client); return false; } if (client->root->callback->interface.v1.append == NULL) { raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); return false; } return process_storage_command(client, tokens, ntokens, start, end, length); } static int process_prepend_command(memcached_protocol_client_st *client, char **tokens, int ntokens, char *start, char **end, ssize_t length) { if (ntokens != 5) { send_command_usage(client); return false; } if (client->root->callback->interface.v1.prepend == NULL) { raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n"); return false; } return process_storage_command(client, tokens, ntokens, start, end, length); } /** * The ASCII protocol support is just one giant big hack. Instead of adding * a optimal ascii support, I just convert the ASCII commands to the binary * protocol and calls back into the command handlers for the binary protocol ;) */ memcached_protocol_event_t memcached_ascii_protocol_process_data(memcached_protocol_client_st *client, ssize_t *length, void **endptr) { char *ptr= (char*)client->root->input_buffer; *endptr= ptr; do { /* Do we have \n (indicating the command preamble)*/ char *end= memchr(ptr, '\n', (size_t)*length); if (end == NULL) { *endptr= ptr; return MEMCACHED_PROTOCOL_READ_EVENT; } client->ascii_command= ascii_to_cmd(ptr, (size_t)(*length)); /* we got all data available, execute the callback! */ if (client->root->callback->pre_execute != NULL) { client->root->callback->pre_execute(client, NULL); } /* A multiget lists all of the keys, and I don't want to have an * avector of let's say 512 pointers to tokenize all of them, so let's * just handle them immediately */ if (client->ascii_command == GET_CMD || client->ascii_command == GETS_CMD) { if (client->root->callback->interface.v1.get != NULL) { ascii_process_gets(client, ptr, end); } else { raw_response_handler(client, "SERVER_ERROR: Command not implemented\n"); } } else { /* None of the defined commands takes 10 parameters, so lets just use * that as a maximum limit. */ char *tokens[10]; int ntokens= ascii_tokenize_command(ptr, end, tokens, 10); if (ntokens < 10) { client->mute= strcmp(tokens[ntokens - 1], "noreply") == 0; if (client->mute) { --ntokens; /* processed noreply token*/ } } int error= 0; print_ascii_command(client); switch (client->ascii_command) { case SET_CMD: error= process_set_command(client, tokens, ntokens, ptr, &end, *length); break; case ADD_CMD: error= process_add_command(client, tokens, ntokens, ptr, &end, *length); break; case REPLACE_CMD: error= process_replace_command(client, tokens, ntokens, ptr, &end, *length); break; case CAS_CMD: error= process_cas_command(client, tokens, ntokens, ptr, &end, *length); break; case APPEND_CMD: error= process_append_command(client, tokens, ntokens, ptr, &end, *length); break; case PREPEND_CMD: error= process_prepend_command(client, tokens, ntokens, ptr, &end, *length); break; case DELETE_CMD: process_delete(client, tokens, ntokens); break; case INCR_CMD: /* FALLTHROUGH */ case DECR_CMD: process_arithmetic(client, tokens, ntokens); break; case STATS_CMD: if (client->mute) { send_command_usage(client); } else { recover_tokenize_command(ptr, end); process_stats(client, ptr + 6, end); } break; case FLUSH_ALL_CMD: process_flush(client, tokens, ntokens); break; case VERSION_CMD: if (client->mute) { send_command_usage(client); } else { process_version(client, tokens, ntokens); } break; case QUIT_CMD: if (ntokens != 1 || client->mute) { send_command_usage(client); } else { if (client->root->callback->interface.v1.quit != NULL) { client->root->callback->interface.v1.quit(client); } return MEMCACHED_PROTOCOL_ERROR_EVENT; } break; case VERBOSITY_CMD: if (ntokens != 2) { send_command_usage(client); } else { raw_response_handler(client, "OK\r\n"); } break; case UNKNOWN_CMD: send_command_usage(client); break; case GET_CMD: case GETS_CMD: default: /* Should already be handled */ abort(); } if (error == -1) { return MEMCACHED_PROTOCOL_ERROR_EVENT; } else if (error == 1) { return MEMCACHED_PROTOCOL_READ_EVENT; } } if (client->root->callback->post_execute != NULL) { client->root->callback->post_execute(client, NULL); } /* Move past \n */ ++end; *length -= end - ptr; ptr= end; } while (*length > 0); *endptr= ptr; return MEMCACHED_PROTOCOL_READ_EVENT; } libmemcached-1.0.8/libmemcachedprotocol/binary_handler.h0000664000076400007640000000420311753573717023727 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once LIBMEMCACHED_LOCAL bool memcached_binary_protocol_pedantic_check_request(const protocol_binary_request_header *request); LIBMEMCACHED_LOCAL bool memcached_binary_protocol_pedantic_check_response(const protocol_binary_request_header *request, const protocol_binary_response_header *response); LIBMEMCACHED_LOCAL memcached_protocol_event_t memcached_binary_protocol_process_data(memcached_protocol_client_st *client, ssize_t *length, void **endptr); libmemcached-1.0.8/libmemcachedprotocol/pedantic.c0000664000076400007640000001655011753573717022540 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ /* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ #include #include #define ensure(a) if (!(a)) { return false; } bool memcached_binary_protocol_pedantic_check_request(const protocol_binary_request_header *request) { ensure(request->request.magic == PROTOCOL_BINARY_REQ); ensure(request->request.datatype == PROTOCOL_BINARY_RAW_BYTES); ensure(request->bytes[6] == 0); ensure(request->bytes[7] == 0); uint8_t opcode= request->request.opcode; uint16_t keylen= ntohs(request->request.keylen); uint8_t extlen= request->request.extlen; uint32_t bodylen= ntohl(request->request.bodylen); ensure(bodylen >= (keylen + extlen)); switch (opcode) { case PROTOCOL_BINARY_CMD_GET: case PROTOCOL_BINARY_CMD_GETK: case PROTOCOL_BINARY_CMD_GETKQ: case PROTOCOL_BINARY_CMD_GETQ: ensure(extlen == 0); ensure(keylen > 0); ensure(keylen == bodylen); ensure(request->request.cas == 0); break; case PROTOCOL_BINARY_CMD_ADD: case PROTOCOL_BINARY_CMD_ADDQ: /* it makes no sense to run add with a cas value */ ensure(request->request.cas == 0); /* FALLTHROUGH */ case PROTOCOL_BINARY_CMD_SET: case PROTOCOL_BINARY_CMD_SETQ: case PROTOCOL_BINARY_CMD_REPLACE: case PROTOCOL_BINARY_CMD_REPLACEQ: ensure(keylen > 0); ensure(extlen == 8); break; case PROTOCOL_BINARY_CMD_DELETE: case PROTOCOL_BINARY_CMD_DELETEQ: ensure(extlen == 0); ensure(keylen > 0); ensure(keylen == bodylen); break; case PROTOCOL_BINARY_CMD_INCREMENT: case PROTOCOL_BINARY_CMD_INCREMENTQ: case PROTOCOL_BINARY_CMD_DECREMENT: case PROTOCOL_BINARY_CMD_DECREMENTQ: ensure(extlen == 20); ensure(keylen > 0); ensure(keylen + extlen == bodylen); break; case PROTOCOL_BINARY_CMD_QUIT: case PROTOCOL_BINARY_CMD_QUITQ: case PROTOCOL_BINARY_CMD_NOOP: case PROTOCOL_BINARY_CMD_VERSION: ensure(extlen == 0); ensure(keylen == 0); ensure(bodylen == 0); break; case PROTOCOL_BINARY_CMD_FLUSH: case PROTOCOL_BINARY_CMD_FLUSHQ: ensure(extlen == 0 || extlen == 4); ensure(keylen == 0); ensure(bodylen == extlen); break; case PROTOCOL_BINARY_CMD_STAT: ensure(extlen == 0); /* May have key, but not value */ ensure(keylen == bodylen); break; case PROTOCOL_BINARY_CMD_APPEND: case PROTOCOL_BINARY_CMD_APPENDQ: case PROTOCOL_BINARY_CMD_PREPEND: case PROTOCOL_BINARY_CMD_PREPENDQ: ensure(extlen == 0); ensure(keylen > 0); break; default: /* Unknown command */ ; } return true; } bool memcached_binary_protocol_pedantic_check_response(const protocol_binary_request_header *request, const protocol_binary_response_header *response) { ensure(response->response.magic == PROTOCOL_BINARY_RES); ensure(response->response.datatype == PROTOCOL_BINARY_RAW_BYTES); ensure(response->response.opaque == request->request.opaque); uint16_t status= ntohs(response->response.status); uint8_t opcode= response->response.opcode; if (status == PROTOCOL_BINARY_RESPONSE_SUCCESS) { switch (opcode) { case PROTOCOL_BINARY_CMD_ADDQ: case PROTOCOL_BINARY_CMD_APPENDQ: case PROTOCOL_BINARY_CMD_DECREMENTQ: case PROTOCOL_BINARY_CMD_DELETEQ: case PROTOCOL_BINARY_CMD_FLUSHQ: case PROTOCOL_BINARY_CMD_INCREMENTQ: case PROTOCOL_BINARY_CMD_PREPENDQ: case PROTOCOL_BINARY_CMD_QUITQ: case PROTOCOL_BINARY_CMD_REPLACEQ: case PROTOCOL_BINARY_CMD_SETQ: /* Quiet command shouldn't return on success */ return false; default: break; } switch (opcode) { case PROTOCOL_BINARY_CMD_ADD: case PROTOCOL_BINARY_CMD_REPLACE: case PROTOCOL_BINARY_CMD_SET: case PROTOCOL_BINARY_CMD_APPEND: case PROTOCOL_BINARY_CMD_PREPEND: ensure(response->response.keylen == 0); ensure(response->response.extlen == 0); ensure(response->response.bodylen == 0); ensure(response->response.cas != 0); break; case PROTOCOL_BINARY_CMD_FLUSH: case PROTOCOL_BINARY_CMD_NOOP: case PROTOCOL_BINARY_CMD_QUIT: case PROTOCOL_BINARY_CMD_DELETE: ensure(response->response.keylen == 0); ensure(response->response.extlen == 0); ensure(response->response.bodylen == 0); ensure(response->response.cas == 0); break; case PROTOCOL_BINARY_CMD_DECREMENT: case PROTOCOL_BINARY_CMD_INCREMENT: ensure(response->response.keylen == 0); ensure(response->response.extlen == 0); ensure(ntohl(response->response.bodylen) == 8); ensure(response->response.cas != 0); break; case PROTOCOL_BINARY_CMD_STAT: ensure(response->response.extlen == 0); /* key and value exists in all packets except in the terminating */ ensure(response->response.cas == 0); break; case PROTOCOL_BINARY_CMD_VERSION: ensure(response->response.keylen == 0); ensure(response->response.extlen == 0); ensure(response->response.bodylen != 0); ensure(response->response.cas == 0); break; case PROTOCOL_BINARY_CMD_GET: case PROTOCOL_BINARY_CMD_GETQ: ensure(response->response.keylen == 0); ensure(response->response.extlen == 4); ensure(response->response.cas != 0); break; case PROTOCOL_BINARY_CMD_GETK: case PROTOCOL_BINARY_CMD_GETKQ: ensure(response->response.keylen != 0); ensure(response->response.extlen == 4); ensure(response->response.cas != 0); break; default: /* Undefined command code */ break; } } else { ensure(response->response.cas == 0); ensure(response->response.extlen == 0); if (opcode != PROTOCOL_BINARY_CMD_GETK) { ensure(response->response.keylen == 0); } } return true; } libmemcached-1.0.8/libmemcachedprotocol/ascii_handler.h0000664000076400007640000000344511753573717023542 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once LIBMEMCACHED_LOCAL memcached_protocol_event_t memcached_ascii_protocol_process_data(memcached_protocol_client_st *client, ssize_t *length, void **endptr); libmemcached-1.0.8/libmemcachedprotocol/cache.c0000664000076400007640000001270011753573717022005 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ #include "config.h" #include #include #include #ifndef NDEBUG #include #endif #include #ifndef NDEBUG const uint64_t redzone_pattern = 0xdeadbeefcafebabe; int cache_error = 0; #endif const size_t initial_pool_size = 64; cache_t* cache_create(const char *name, size_t bufsize, size_t align, cache_constructor_t* constructor, cache_destructor_t* destructor) { cache_t* ret = calloc(1, sizeof(cache_t)); size_t name_length= strlen(name); char* nm= calloc(1, (sizeof(char) * name_length) +1); memcpy(nm, name, name_length); void** ptr = calloc(initial_pool_size, bufsize); if (ret == NULL || nm == NULL || ptr == NULL || pthread_mutex_init(&ret->mutex, NULL) == -1) { free(ret); free(nm); free(ptr); return NULL; } ret->name = nm; ret->ptr = ptr; ret->freetotal = initial_pool_size; ret->constructor = constructor; ret->destructor = destructor; #ifndef NDEBUG ret->bufsize = bufsize + 2 * sizeof(redzone_pattern); #else ret->bufsize = bufsize; #endif (void)align; return ret; } static inline void* get_object(void *ptr) { #ifndef NDEBUG uint64_t *pre = ptr; return pre + 1; #else return ptr; #endif } void cache_destroy(cache_t *cache) { while (cache->freecurr > 0) { void *ptr = cache->ptr[--cache->freecurr]; if (cache->destructor) { cache->destructor(get_object(ptr), NULL); } free(ptr); } free(cache->name); free(cache->ptr); pthread_mutex_destroy(&cache->mutex); } void* cache_alloc(cache_t *cache) { void *ret; void *object; pthread_mutex_lock(&cache->mutex); if (cache->freecurr > 0) { ret = cache->ptr[--cache->freecurr]; object = get_object(ret); } else { object = ret = malloc(cache->bufsize); if (ret != NULL) { object = get_object(ret); if (cache->constructor != NULL && cache->constructor(object, NULL, 0) != 0) { free(ret); object = NULL; } } } pthread_mutex_unlock(&cache->mutex); #ifndef NDEBUG if (object != NULL) { /* add a simple form of buffer-check */ uint64_t *pre = ret; *pre = redzone_pattern; ret = pre+1; memcpy(((char*)ret) + cache->bufsize - (2 * sizeof(redzone_pattern)), &redzone_pattern, sizeof(redzone_pattern)); } #endif return object; } void cache_free(cache_t *cache, void *ptr) { pthread_mutex_lock(&cache->mutex); #ifndef NDEBUG /* validate redzone... */ if (memcmp(((char*)ptr) + cache->bufsize - (2 * sizeof(redzone_pattern)), &redzone_pattern, sizeof(redzone_pattern)) != 0) { raise(SIGABRT); cache_error = 1; pthread_mutex_unlock(&cache->mutex); return; } uint64_t *pre = ptr; --pre; if (*pre != redzone_pattern) { raise(SIGABRT); cache_error = -1; pthread_mutex_unlock(&cache->mutex); return; } ptr = pre; #endif if (cache->freecurr < cache->freetotal) { cache->ptr[cache->freecurr++] = ptr; } else { /* try to enlarge free connections array */ size_t newtotal = cache->freetotal * 2; void **new_free = realloc(cache->ptr, sizeof(char *) * newtotal); if (new_free) { cache->freetotal = newtotal; cache->ptr = new_free; cache->ptr[cache->freecurr++] = ptr; } else { if (cache->destructor) { cache->destructor(ptr, NULL); } free(ptr); } } pthread_mutex_unlock(&cache->mutex); } libmemcached-1.0.8/libmemcachedprotocol/binary_handler.c0000664000076400007640000012775211753573717023741 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 #include #include #include #include #include #include /* ** ********************************************************************** ** INTERNAL INTERFACE ** ********************************************************************** */ /** * Send a preformatted packet back to the client. If the connection is in * pedantic mode, it will validate the packet and refuse to send it if it * breaks the specification. * * @param cookie client identification * @param request the original request packet * @param response the packet to send * @return The status of the operation */ static protocol_binary_response_status raw_response_handler(const void *cookie, protocol_binary_request_header *request, protocol_binary_response_header *response) { memcached_protocol_client_st *client= (void*)cookie; if (client->root->pedantic && !memcached_binary_protocol_pedantic_check_response(request, response)) { return PROTOCOL_BINARY_RESPONSE_EINVAL; } if (client->root->drain(client) == false) { return PROTOCOL_BINARY_RESPONSE_EINTERNAL; } size_t len= sizeof(protocol_binary_response_header) + htonl(response->response.bodylen); size_t offset= 0; char *ptr= (void*)response; if (client->output == NULL) { /* I can write directly to the socket.... */ do { size_t num_bytes= len - offset; ssize_t nw= client->root->send(client, client->sock, ptr + offset, num_bytes); if (nw == -1) { if (get_socket_errno() == EWOULDBLOCK) { break; } else if (get_socket_errno() != EINTR) { client->error= errno; return PROTOCOL_BINARY_RESPONSE_EINTERNAL; } } else { offset += (size_t)nw; } } while (offset < len); } return client->root->spool(client, ptr, len - offset); } static void print_cmd(protocol_binary_command cmd) { switch (cmd) { case PROTOCOL_BINARY_CMD_GET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GET\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_SET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_SET\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_ADD: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_ADD\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_REPLACE: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_REPLACE\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_DELETE: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_DELETE\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_INCREMENT: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_INCREMENT\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_DECREMENT: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_DECREMENT\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_QUIT: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_QUIT\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_FLUSH: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_FLUSH\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_GETQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GETQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_NOOP: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_NOOP\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_VERSION: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_VERSION\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_GETK: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GETK\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_GETKQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GETKQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_APPEND: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_APPEND\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_PREPEND: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_PREPEND\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_STAT: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_STAT\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_SETQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_SETQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_ADDQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_ADDQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_REPLACEQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_REPLACEQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_DELETEQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_DELETEQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_INCREMENTQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_INCREMENTQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_DECREMENTQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_DECREMENTQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_QUITQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_QUITQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_FLUSHQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_FLUSHQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_APPENDQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_APPENDQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_PREPENDQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_PREPENDQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_VERBOSITY: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_VERBOSITY\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_TOUCH: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TOUCH\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_GAT: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GAT\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_GATQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GATQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_SASL_LIST_MECHS: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_SASL_LIST_MECHS\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_SASL_AUTH: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_SASL_AUTH\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_SASL_STEP: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_SASL_STEP\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_RGET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RGET\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_RSET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RSET\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_RSETQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RSETQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_RAPPEND: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RAPPEND\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_RAPPENDQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RAPPENDQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_RPREPEND: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RPREPEND\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_RPREPENDQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RPREPENDQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_RDELETE: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RDELETE\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_RDELETEQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RDELETEQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_RINCR: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RINCR\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_RINCRQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RINCRQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_RDECR: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RDECR\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_RDECRQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_RDECRQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_SET_VBUCKET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_SET_VBUCKET\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_GET_VBUCKET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GET_VBUCKET\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_DEL_VBUCKET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_DEL_VBUCKET\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_TAP_CONNECT: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_CONNECT\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_TAP_MUTATION: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_MUTATION\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_TAP_DELETE: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_DELETE\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_TAP_FLUSH: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_FLUSH\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_TAP_OPAQUE: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_OPAQUE\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_TAP_VBUCKET_SET: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_VBUCKET_SET\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_TAP_CHECKPOINT_START: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_CHECKPOINT_START\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_TAP_CHECKPOINT_END: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_TAP_CHECKPOINT_END\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_LAST_RESERVED: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_LAST_RESERVED\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_GATK: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GATK\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_GATKQ: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_GATKQ\n", __FILE__, __LINE__); return; case PROTOCOL_BINARY_CMD_SCRUB: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_SCRUB\n", __FILE__, __LINE__); return; default: abort(); } } /* * Version 0 of the interface is really low level and protocol specific, * while the version 1 of the interface is more API focused. We need a * way to translate between the command codes on the wire and the * application level interface in V1, so let's just use the V0 of the * interface as a map instead of creating a huuuge switch :-) */ /** * Callback for the GET/GETQ/GETK and GETKQ responses * @param cookie client identifier * @param key the key for the item * @param keylen the length of the key * @param body the length of the body * @param bodylen the length of the body * @param flags the flags for the item * @param cas the CAS id for the item */ static protocol_binary_response_status get_response_handler(const void *cookie, const void *key, uint16_t keylen, const void *body, uint32_t bodylen, uint32_t flags, uint64_t cas) { memcached_protocol_client_st *client= (void*)cookie; uint8_t opcode= client->current_command->request.opcode; if (opcode == PROTOCOL_BINARY_CMD_GET || opcode == PROTOCOL_BINARY_CMD_GETQ) { keylen= 0; } protocol_binary_response_get response= { .message.header.response= { .magic= PROTOCOL_BINARY_RES, .opcode= opcode, .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), .opaque= client->current_command->request.opaque, .cas= memcached_htonll(cas), .keylen= htons(keylen), .extlen= 4, .bodylen= htonl(bodylen + keylen + 4), }, }; response.message.body.flags= htonl(flags); protocol_binary_response_status rval; const protocol_binary_response_status success= PROTOCOL_BINARY_RESPONSE_SUCCESS; if ((rval= client->root->spool(client, response.bytes, sizeof(response.bytes))) != success || (rval= client->root->spool(client, key, keylen)) != success || (rval= client->root->spool(client, body, bodylen)) != success) { return rval; } return PROTOCOL_BINARY_RESPONSE_SUCCESS; } /** * Callback for the STAT responses * @param cookie client identifier * @param key the key for the item * @param keylen the length of the key * @param body the length of the body * @param bodylen the length of the body */ static protocol_binary_response_status stat_response_handler(const void *cookie, const void *key, uint16_t keylen, const void *body, uint32_t bodylen) { memcached_protocol_client_st *client= (void*)cookie; protocol_binary_response_no_extras response= { .message.header.response= { .magic= PROTOCOL_BINARY_RES, .opcode= client->current_command->request.opcode, .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), .opaque= client->current_command->request.opaque, .keylen= htons(keylen), .bodylen= htonl(bodylen + keylen), .cas= 0 }, }; protocol_binary_response_status rval; const protocol_binary_response_status success= PROTOCOL_BINARY_RESPONSE_SUCCESS; if ((rval= client->root->spool(client, response.bytes, sizeof(response.bytes))) != success || (rval= client->root->spool(client, key, keylen)) != success || (rval= client->root->spool(client, body, bodylen)) != success) { return rval; } return PROTOCOL_BINARY_RESPONSE_SUCCESS; } /** * Callback for the VERSION responses * @param cookie client identifier * @param text the length of the body * @param textlen the length of the body */ static protocol_binary_response_status version_response_handler(const void *cookie, const void *text, uint32_t textlen) { memcached_protocol_client_st *client= (void*)cookie; protocol_binary_response_no_extras response= { .message.header.response= { .magic= PROTOCOL_BINARY_RES, .opcode= client->current_command->request.opcode, .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), .opaque= client->current_command->request.opaque, .bodylen= htonl(textlen), .cas= 0 }, }; protocol_binary_response_status rval; const protocol_binary_response_status success= PROTOCOL_BINARY_RESPONSE_SUCCESS; if ((rval= client->root->spool(client, response.bytes, sizeof(response.bytes))) != success || (rval= client->root->spool(client, text, textlen)) != success) { return rval; } return PROTOCOL_BINARY_RESPONSE_SUCCESS; } /** * Callback for ADD and ADDQ * @param cookie the calling client * @param header the add/addq command * @param response_handler not used * @return the result of the operation */ static protocol_binary_response_status add_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { protocol_binary_response_status rval; memcached_protocol_client_st *client= (void*)cookie; if (client->root->callback->interface.v1.add != NULL) { uint16_t keylen= ntohs(header->request.keylen); uint32_t datalen= ntohl(header->request.bodylen) - keylen - 8; protocol_binary_request_add *request= (void*)header; uint32_t flags= ntohl(request->message.body.flags); uint32_t timeout= ntohl(request->message.body.expiration); char *key= ((char*)header) + sizeof(*header) + 8; char *data= key + keylen; uint64_t cas; rval= client->root->callback->interface.v1.add(cookie, key, keylen, data, datalen, flags, timeout, &cas); if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && header->request.opcode == PROTOCOL_BINARY_CMD_ADD) { /* Send a positive request */ protocol_binary_response_no_extras response= { .message= { .header.response= { .magic= PROTOCOL_BINARY_RES, .opcode= PROTOCOL_BINARY_CMD_ADD, .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), .opaque= header->request.opaque, .cas= memcached_ntohll(cas) } } }; rval= response_handler(cookie, header, (void*)&response); } } else { rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; } return rval; } /** * Callback for DECREMENT and DECREMENTQ * @param cookie the calling client * @param header the command * @param response_handler not used * @return the result of the operation */ static protocol_binary_response_status decrement_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { (void)response_handler; protocol_binary_response_status rval; memcached_protocol_client_st *client= (void*)cookie; if (client->root->callback->interface.v1.decrement != NULL) { uint16_t keylen= ntohs(header->request.keylen); protocol_binary_request_decr *request= (void*)header; uint64_t init= memcached_ntohll(request->message.body.initial); uint64_t delta= memcached_ntohll(request->message.body.delta); uint32_t timeout= ntohl(request->message.body.expiration); void *key= request->bytes + sizeof(request->bytes); uint64_t result; uint64_t cas; rval= client->root->callback->interface.v1.decrement(cookie, key, keylen, delta, init, timeout, &result, &cas); if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && header->request.opcode == PROTOCOL_BINARY_CMD_DECREMENT) { /* Send a positive request */ protocol_binary_response_decr response= { .message= { .header.response= { .magic= PROTOCOL_BINARY_RES, .opcode= PROTOCOL_BINARY_CMD_DECREMENT, .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), .opaque= header->request.opaque, .cas= memcached_ntohll(cas), .bodylen= htonl(8) }, .body.value= memcached_htonll(result) } }; rval= response_handler(cookie, header, (void*)&response); } } else { rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; } return rval; } /** * Callback for DELETE and DELETEQ * @param cookie the calling client * @param header the command * @param response_handler not used * @return the result of the operation */ static protocol_binary_response_status delete_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { (void)response_handler; protocol_binary_response_status rval; memcached_protocol_client_st *client= (void*)cookie; if (client->root->callback->interface.v1.delete_object != NULL) { uint16_t keylen= ntohs(header->request.keylen); void *key= (header +1); uint64_t cas= memcached_ntohll(header->request.cas); rval= client->root->callback->interface.v1.delete_object(cookie, key, keylen, cas); if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && header->request.opcode == PROTOCOL_BINARY_CMD_DELETE) { /* Send a positive request */ protocol_binary_response_no_extras response= { .message= { .header.response= { .magic= PROTOCOL_BINARY_RES, .opcode= PROTOCOL_BINARY_CMD_DELETE, .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), .opaque= header->request.opaque, } } }; rval= response_handler(cookie, header, (void*)&response); } } else { rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; } return rval; } /** * Callback for FLUSH and FLUSHQ * @param cookie the calling client * @param header the command * @param response_handler not used * @return the result of the operation */ static protocol_binary_response_status flush_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { (void)response_handler; protocol_binary_response_status rval; memcached_protocol_client_st *client= (void*)cookie; if (client->root->callback->interface.v1.flush_object != NULL) { protocol_binary_request_flush *flush_object= (void*)header; uint32_t timeout= 0; if (htonl(header->request.bodylen) == 4) { timeout= ntohl(flush_object->message.body.expiration); } rval= client->root->callback->interface.v1.flush_object(cookie, timeout); if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && header->request.opcode == PROTOCOL_BINARY_CMD_FLUSH) { /* Send a positive request */ protocol_binary_response_no_extras response= { .message= { .header.response= { .magic= PROTOCOL_BINARY_RES, .opcode= PROTOCOL_BINARY_CMD_FLUSH, .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), .opaque= header->request.opaque, } } }; rval= response_handler(cookie, header, (void*)&response); } } else { rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; } return rval; } /** * Callback for GET, GETK, GETQ, GETKQ * @param cookie the calling client * @param header the command * @param response_handler not used * @return the result of the operation */ static protocol_binary_response_status get_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { (void)response_handler; protocol_binary_response_status rval; memcached_protocol_client_st *client= (void*)cookie; if (client->root->callback->interface.v1.get != NULL) { uint16_t keylen= ntohs(header->request.keylen); void *key= (header + 1); rval= client->root->callback->interface.v1.get(cookie, key, keylen, get_response_handler); if (rval == PROTOCOL_BINARY_RESPONSE_KEY_ENOENT && (header->request.opcode == PROTOCOL_BINARY_CMD_GETQ || header->request.opcode == PROTOCOL_BINARY_CMD_GETKQ)) { /* Quiet commands shouldn't respond on cache misses */ rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; } } else { rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; } return rval; } /** * Callback for INCREMENT and INCREMENTQ * @param cookie the calling client * @param header the command * @param response_handler not used * @return the result of the operation */ static protocol_binary_response_status increment_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { (void)response_handler; protocol_binary_response_status rval; memcached_protocol_client_st *client= (void*)cookie; if (client->root->callback->interface.v1.increment != NULL) { uint16_t keylen= ntohs(header->request.keylen); protocol_binary_request_incr *request= (void*)header; uint64_t init= memcached_ntohll(request->message.body.initial); uint64_t delta= memcached_ntohll(request->message.body.delta); uint32_t timeout= ntohl(request->message.body.expiration); void *key= request->bytes + sizeof(request->bytes); uint64_t cas; uint64_t result; rval= client->root->callback->interface.v1.increment(cookie, key, keylen, delta, init, timeout, &result, &cas); if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && header->request.opcode == PROTOCOL_BINARY_CMD_INCREMENT) { /* Send a positive request */ protocol_binary_response_incr response= { .message= { .header.response= { .magic= PROTOCOL_BINARY_RES, .opcode= PROTOCOL_BINARY_CMD_INCREMENT, .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), .opaque= header->request.opaque, .cas= memcached_ntohll(cas), .bodylen= htonl(8) }, .body.value= memcached_htonll(result) } }; rval= response_handler(cookie, header, (void*)&response); } } else { rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; } return rval; } /** * Callback for noop. Inform the v1 interface about the noop packet, and * create and send a packet back to the client * * @param cookie the calling client * @param header the command * @param response_handler the response handler * @return the result of the operation */ static protocol_binary_response_status noop_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { memcached_protocol_client_st *client= (void*)cookie; if (client->root->callback->interface.v1.noop != NULL) { client->root->callback->interface.v1.noop(cookie); } protocol_binary_response_no_extras response= { .message= { .header.response= { .magic= PROTOCOL_BINARY_RES, .opcode= PROTOCOL_BINARY_CMD_NOOP, .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), .opaque= header->request.opaque, } } }; return response_handler(cookie, header, (void*)&response); } /** * Callback for APPEND and APPENDQ * @param cookie the calling client * @param header the command * @param response_handler not used * @return the result of the operation */ static protocol_binary_response_status append_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { (void)response_handler; protocol_binary_response_status rval; memcached_protocol_client_st *client= (void*)cookie; if (client->root->callback->interface.v1.append != NULL) { uint16_t keylen= ntohs(header->request.keylen); uint32_t datalen= ntohl(header->request.bodylen) - keylen; char *key= (void*)(header +1); char *data= key +keylen; uint64_t cas= memcached_ntohll(header->request.cas); uint64_t result_cas; rval= client->root->callback->interface.v1.append(cookie, key, keylen, data, datalen, cas, &result_cas); if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && header->request.opcode == PROTOCOL_BINARY_CMD_APPEND) { /* Send a positive request */ protocol_binary_response_no_extras response= { .message= { .header.response= { .magic= PROTOCOL_BINARY_RES, .opcode= PROTOCOL_BINARY_CMD_APPEND, .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), .opaque= header->request.opaque, .cas= memcached_ntohll(result_cas), }, } }; rval= response_handler(cookie, header, (void*)&response); } } else { rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; } return rval; } /** * Callback for PREPEND and PREPENDQ * @param cookie the calling client * @param header the command * @param response_handler not used * @return the result of the operation */ static protocol_binary_response_status prepend_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { (void)response_handler; protocol_binary_response_status rval; memcached_protocol_client_st *client= (void*)cookie; if (client->root->callback->interface.v1.prepend != NULL) { uint16_t keylen= ntohs(header->request.keylen); uint32_t datalen= ntohl(header->request.bodylen) - keylen; char *key= (char*)(header + 1); char *data= key + keylen; uint64_t cas= memcached_ntohll(header->request.cas); uint64_t result_cas; rval= client->root->callback->interface.v1.prepend(cookie, key, keylen, data, datalen, cas, &result_cas); if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && header->request.opcode == PROTOCOL_BINARY_CMD_PREPEND) { /* Send a positive request */ protocol_binary_response_no_extras response= { .message= { .header.response= { .magic= PROTOCOL_BINARY_RES, .opcode= PROTOCOL_BINARY_CMD_PREPEND, .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), .opaque= header->request.opaque, .cas= memcached_ntohll(result_cas), }, } }; rval= response_handler(cookie, header, (void*)&response); } } else { rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; } return rval; } /** * Callback for QUIT and QUITQ. Notify the client and shut down the connection * @param cookie the calling client * @param header the command * @param response_handler not used * @return the result of the operation */ static protocol_binary_response_status quit_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { memcached_protocol_client_st *client= (void*)cookie; if (client->root->callback->interface.v1.quit != NULL) { client->root->callback->interface.v1.quit(cookie); } protocol_binary_response_no_extras response= { .message= { .header.response= { .magic= PROTOCOL_BINARY_RES, .opcode= PROTOCOL_BINARY_CMD_QUIT, .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), .opaque= header->request.opaque } } }; if (header->request.opcode == PROTOCOL_BINARY_CMD_QUIT) { response_handler(cookie, header, (void*)&response); } /* I need a better way to signal to close the connection */ return PROTOCOL_BINARY_RESPONSE_EINTERNAL; } /** * Callback for REPLACE and REPLACEQ * @param cookie the calling client * @param header the command * @param response_handler not used * @return the result of the operation */ static protocol_binary_response_status replace_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { (void)response_handler; protocol_binary_response_status rval; memcached_protocol_client_st *client= (void*)cookie; if (client->root->callback->interface.v1.replace != NULL) { uint16_t keylen= ntohs(header->request.keylen); uint32_t datalen= ntohl(header->request.bodylen) - keylen - 8; protocol_binary_request_replace *request= (void*)header; uint32_t flags= ntohl(request->message.body.flags); uint32_t timeout= ntohl(request->message.body.expiration); char *key= ((char*)header) + sizeof(*header) + 8; char *data= key + keylen; uint64_t cas= memcached_ntohll(header->request.cas); uint64_t result_cas; rval= client->root->callback->interface.v1.replace(cookie, key, keylen, data, datalen, flags, timeout, cas, &result_cas); if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && header->request.opcode == PROTOCOL_BINARY_CMD_REPLACE) { /* Send a positive request */ protocol_binary_response_no_extras response= { .message= { .header.response= { .magic= PROTOCOL_BINARY_RES, .opcode= PROTOCOL_BINARY_CMD_REPLACE, .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), .opaque= header->request.opaque, .cas= memcached_ntohll(result_cas), }, } }; rval= response_handler(cookie, header, (void*)&response); } } else { rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; } return rval; } /** * Callback for SET and SETQ * @param cookie the calling client * @param header the command * @param response_handler not used * @return the result of the operation */ static protocol_binary_response_status set_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { (void)response_handler; protocol_binary_response_status rval; memcached_protocol_client_st *client= (void*)cookie; if (client->root->callback->interface.v1.set != NULL) { uint16_t keylen= ntohs(header->request.keylen); uint32_t datalen= ntohl(header->request.bodylen) - keylen - 8; protocol_binary_request_replace *request= (void*)header; uint32_t flags= ntohl(request->message.body.flags); uint32_t timeout= ntohl(request->message.body.expiration); char *key= ((char*)header) + sizeof(*header) + 8; char *data= key + keylen; uint64_t cas= memcached_ntohll(header->request.cas); uint64_t result_cas; rval= client->root->callback->interface.v1.set(cookie, key, keylen, data, datalen, flags, timeout, cas, &result_cas); if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS && header->request.opcode == PROTOCOL_BINARY_CMD_SET) { /* Send a positive request */ protocol_binary_response_no_extras response= { .message= { .header.response= { .magic= PROTOCOL_BINARY_RES, .opcode= PROTOCOL_BINARY_CMD_SET, .status= htons(PROTOCOL_BINARY_RESPONSE_SUCCESS), .opaque= header->request.opaque, .cas= memcached_ntohll(result_cas), }, } }; rval= response_handler(cookie, header, (void*)&response); } } else { rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; } return rval; } /** * Callback for STAT * @param cookie the calling client * @param header the command * @param response_handler not used * @return the result of the operation */ static protocol_binary_response_status stat_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { (void)response_handler; protocol_binary_response_status rval; memcached_protocol_client_st *client= (void*)cookie; if (client->root->callback->interface.v1.stat != NULL) { uint16_t keylen= ntohs(header->request.keylen); rval= client->root->callback->interface.v1.stat(cookie, (void*)(header + 1), keylen, stat_response_handler); } else { rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; } return rval; } /** * Callback for VERSION * @param cookie the calling client * @param header the command * @param response_handler not used * @return the result of the operation */ static protocol_binary_response_status version_command_handler(const void *cookie, protocol_binary_request_header *header, memcached_binary_protocol_raw_response_handler response_handler) { (void)response_handler; (void)header; protocol_binary_response_status rval; memcached_protocol_client_st *client= (void*)cookie; if (client->root->callback->interface.v1.version != NULL) { rval= client->root->callback->interface.v1.version(cookie, version_response_handler); } else { rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; } return rval; } /** * The map to remap between the com codes and the v1 logical setting */ static memcached_binary_protocol_command_handler comcode_v0_v1_remap[256]= { [PROTOCOL_BINARY_CMD_ADDQ]= add_command_handler, [PROTOCOL_BINARY_CMD_ADD]= add_command_handler, [PROTOCOL_BINARY_CMD_APPENDQ]= append_command_handler, [PROTOCOL_BINARY_CMD_APPEND]= append_command_handler, [PROTOCOL_BINARY_CMD_DECREMENTQ]= decrement_command_handler, [PROTOCOL_BINARY_CMD_DECREMENT]= decrement_command_handler, [PROTOCOL_BINARY_CMD_DELETEQ]= delete_command_handler, [PROTOCOL_BINARY_CMD_DELETE]= delete_command_handler, [PROTOCOL_BINARY_CMD_FLUSHQ]= flush_command_handler, [PROTOCOL_BINARY_CMD_FLUSH]= flush_command_handler, [PROTOCOL_BINARY_CMD_GETKQ]= get_command_handler, [PROTOCOL_BINARY_CMD_GETK]= get_command_handler, [PROTOCOL_BINARY_CMD_GETQ]= get_command_handler, [PROTOCOL_BINARY_CMD_GET]= get_command_handler, [PROTOCOL_BINARY_CMD_INCREMENTQ]= increment_command_handler, [PROTOCOL_BINARY_CMD_INCREMENT]= increment_command_handler, [PROTOCOL_BINARY_CMD_NOOP]= noop_command_handler, [PROTOCOL_BINARY_CMD_PREPENDQ]= prepend_command_handler, [PROTOCOL_BINARY_CMD_PREPEND]= prepend_command_handler, [PROTOCOL_BINARY_CMD_QUITQ]= quit_command_handler, [PROTOCOL_BINARY_CMD_QUIT]= quit_command_handler, [PROTOCOL_BINARY_CMD_REPLACEQ]= replace_command_handler, [PROTOCOL_BINARY_CMD_REPLACE]= replace_command_handler, [PROTOCOL_BINARY_CMD_SETQ]= set_command_handler, [PROTOCOL_BINARY_CMD_SET]= set_command_handler, [PROTOCOL_BINARY_CMD_STAT]= stat_command_handler, [PROTOCOL_BINARY_CMD_VERSION]= version_command_handler, }; /** * Try to execute a command. Fire the pre/post functions and the specialized * handler function if it's set. If not, the unknown probe should be fired * if it's present. * @param client the client connection to operate on * @param header the command to execute * @return true if success or false if a fatal error occured so that the * connection should be shut down. */ static protocol_binary_response_status execute_command(memcached_protocol_client_st *client, protocol_binary_request_header *header) { if (client->root->pedantic && memcached_binary_protocol_pedantic_check_request(header)) { /* @todo return invalid command packet */ } /* we got all data available, execute the callback! */ if (client->root->callback->pre_execute != NULL) { client->root->callback->pre_execute(client, header); } protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND; uint8_t cc= header->request.opcode; if (client->is_verbose) { print_cmd(cc); } switch (client->root->callback->interface_version) { case 0: if (client->root->callback->interface.v0.comcode[cc] != NULL) { rval= client->root->callback->interface.v0.comcode[cc](client, header, raw_response_handler); } break; case 1: if (comcode_v0_v1_remap[cc] != NULL) { rval= comcode_v0_v1_remap[cc](client, header, raw_response_handler); } break; default: /* Unknown interface. * It should be impossible to get here so I'll just call abort * to avoid getting a compiler warning :-) */ abort(); } if (rval == PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND && client->root->callback->unknown != NULL) { rval= client->root->callback->unknown(client, header, raw_response_handler); } if (rval != PROTOCOL_BINARY_RESPONSE_SUCCESS && rval != PROTOCOL_BINARY_RESPONSE_EINTERNAL && rval != PROTOCOL_BINARY_RESPONSE_NOT_SUPPORTED) { protocol_binary_response_no_extras response= { .message= { .header.response= { .magic= PROTOCOL_BINARY_RES, .opcode= cc, .status= htons(rval), .opaque= header->request.opaque, }, } }; rval= raw_response_handler(client, header, (void*)&response); } if (client->root->callback->post_execute != NULL) { client->root->callback->post_execute(client, header); } return rval; } /* ** ********************************************************************** ** "PROTOECTED" INTERFACE ** ********************************************************************** */ memcached_protocol_event_t memcached_binary_protocol_process_data(memcached_protocol_client_st *client, ssize_t *length, void **endptr) { /* try to parse all of the received packets */ protocol_binary_request_header *header; header= (void*)client->root->input_buffer; if (header->request.magic != (uint8_t)PROTOCOL_BINARY_REQ) { client->error= EINVAL; return MEMCACHED_PROTOCOL_ERROR_EVENT; } ssize_t len= *length; while (len >= (ssize_t)sizeof(*header) && (len >= (ssize_t)(sizeof(*header) + ntohl(header->request.bodylen)))) { /* I have the complete package */ client->current_command= header; protocol_binary_response_status rv= execute_command(client, header); if (rv == PROTOCOL_BINARY_RESPONSE_EINTERNAL) { *length= len; *endptr= (void*)header; return MEMCACHED_PROTOCOL_ERROR_EVENT; } else if (rv == PROTOCOL_BINARY_RESPONSE_NOT_SUPPORTED) { return MEMCACHED_PROTOCOL_PAUSE_EVENT; } ssize_t total= (ssize_t)(sizeof(*header) + ntohl(header->request.bodylen)); len -= total; if (len > 0) { intptr_t ptr= (intptr_t)header; ptr += total; if ((ptr % 8) == 0) { header= (void*)ptr; } else { /* Fix alignment */ memmove(client->root->input_buffer, (void*)ptr, (size_t)len); header= (void*)client->root->input_buffer; } } *length= len; *endptr= (void*)header; } return MEMCACHED_PROTOCOL_READ_EVENT; } /* ** ********************************************************************** ** PUBLIC INTERFACE ** ********************************************************************** */ memcached_binary_protocol_callback_st *memcached_binary_protocol_get_callbacks(memcached_protocol_st *instance) { return instance->callback; } void memcached_binary_protocol_set_callbacks(memcached_protocol_st *instance, memcached_binary_protocol_callback_st *callback) { instance->callback= callback; } memcached_binary_protocol_raw_response_handler memcached_binary_protocol_get_raw_response_handler(const void *cookie) { (void)cookie; return raw_response_handler; } void memcached_binary_protocol_set_pedantic(memcached_protocol_st *instance, bool enable) { instance->pedantic= enable; } bool memcached_binary_protocol_get_pedantic(memcached_protocol_st *instance) { return instance->pedantic; } libmemcached-1.0.8/libmemcachedprotocol/handler.c0000664000076400007640000003135211753573717022363 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ /* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ #include #include #include #include #include #include #include #include #include /* ** ********************************************************************** ** INTERNAL INTERFACE ** ********************************************************************** */ /** * The default function to receive data from the client. This function * just wraps the recv function to receive from a socket. * See man -s3socket recv for more information. * * @param cookie cookie indentifying a client, not used * @param sock socket to read from * @param buf the destination buffer * @param nbytes the number of bytes to read * @return the number of bytes transferred of -1 upon error */ static ssize_t default_recv(const void *cookie, memcached_socket_t sock, void *buf, size_t nbytes) { (void)cookie; return recv(sock, buf, nbytes, 0); } /** * The default function to send data to the server. This function * just wraps the send function to send through a socket. * See man -s3socket send for more information. * * @param cookie cookie indentifying a client, not used * @param sock socket to send to * @param buf the source buffer * @param nbytes the number of bytes to send * @return the number of bytes transferred of -1 upon error */ static ssize_t default_send(const void *cookie, memcached_socket_t fd, const void *buf, size_t nbytes) { (void)cookie; return send(fd, buf, nbytes, MSG_NOSIGNAL); } /** * Try to drain the output buffers without blocking * * @param client the client to drain * @return false if an error occured (connection should be shut down) * true otherwise (please note that there may be more data to * left in the buffer to send) */ static bool drain_output(struct memcached_protocol_client_st *client) { if (client->is_verbose) { fprintf(stderr, "%s:%d %s mute:%d output:%s length:%d\n", __FILE__, __LINE__, __func__, (int)client->mute, client->output ? "yes" : "no", client->output ? (int)(client->output->nbytes - client->output->offset) : 0); } /* Do we have pending data to send? */ while (client->output != NULL) { ssize_t len= client->root->send(client, client->sock, client->output->data + client->output->offset, client->output->nbytes - client->output->offset); if (len == -1) { if (get_socket_errno() == EWOULDBLOCK) { return true; } else if (get_socket_errno() != EINTR) { client->error= get_socket_errno(); return false; } } else { client->output->offset += (size_t)len; if (client->output->offset == client->output->nbytes) { /* This was the complete buffer */ struct chunk_st *old= client->output; client->output= client->output->next; if (client->output == NULL) { client->output_tail= NULL; } cache_free(client->root->buffer_cache, old); } } } return true; } /** * Allocate an output buffer and chain it into the output list * * @param client the client that needs the buffer * @return pointer to the new chunk if the allocation succeeds, NULL otherwise */ static struct chunk_st *allocate_output_chunk(struct memcached_protocol_client_st *client) { struct chunk_st *ret= cache_alloc(client->root->buffer_cache); if (ret == NULL) { return NULL; } ret->offset= ret->nbytes= 0; ret->next= NULL; ret->size= CHUNK_BUFFERSIZE; ret->data= (void*)(ret + 1); if (client->output == NULL) { client->output= client->output_tail= ret; } else { client->output_tail->next= ret; client->output_tail= ret; } return ret; } /** * Spool data into the send-buffer for a client. * * @param client the client to spool the data for * @param data the data to spool * @param length the number of bytes of data to spool * @return PROTOCOL_BINARY_RESPONSE_SUCCESS if success, * PROTOCOL_BINARY_RESPONSE_ENOMEM if we failed to allocate memory */ static protocol_binary_response_status spool_output(struct memcached_protocol_client_st *client, const void *data, size_t length) { if (client->is_verbose) { fprintf(stderr, "%s:%d %s mute:%d length:%d\n", __FILE__, __LINE__, __func__, (int)client->mute, (int)length); } if (client->mute) { return PROTOCOL_BINARY_RESPONSE_SUCCESS; } size_t offset= 0; struct chunk_st *chunk= client->output; while (offset < length) { if (chunk == NULL || (chunk->size - chunk->nbytes) == 0) { if ((chunk= allocate_output_chunk(client)) == NULL) { return PROTOCOL_BINARY_RESPONSE_ENOMEM; } } size_t bulk= length - offset; if (bulk > chunk->size - chunk->nbytes) { bulk= chunk->size - chunk->nbytes; } memcpy(chunk->data + chunk->nbytes, data, bulk); chunk->nbytes += bulk; offset += bulk; } return PROTOCOL_BINARY_RESPONSE_SUCCESS; } /** * Try to determine the protocol used on this connection. * If the first byte contains the magic byte PROTOCOL_BINARY_REQ we should * be using the binary protocol on the connection. I implemented the support * for the ASCII protocol by wrapping into the simple interface (aka v1), * so the implementors needs to provide an implementation of that interface * */ static memcached_protocol_event_t determine_protocol(struct memcached_protocol_client_st *client, ssize_t *length, void **endptr) { if (*client->root->input_buffer == (uint8_t)PROTOCOL_BINARY_REQ) { if (client->is_verbose) { fprintf(stderr, "%s:%d PROTOCOL: memcached_binary_protocol_process_data\n", __FILE__, __LINE__); } client->work= memcached_binary_protocol_process_data; } else if (client->root->callback->interface_version == 1) { if (client->is_verbose) { fprintf(stderr, "%s:%d PROTOCOL: memcached_ascii_protocol_process_data\n", __FILE__, __LINE__); } /* * The ASCII protocol can only be used if the implementors provide * an implementation for the version 1 of the interface.. * * @todo I should allow the implementors to provide an implementation * for version 0 and 1 at the same time and set the preferred * interface to use... */ client->work= memcached_ascii_protocol_process_data; } else { if (client->is_verbose) { fprintf(stderr, "%s:%d PROTOCOL: Unsupported protocol\n", __FILE__, __LINE__); } /* Let's just output a warning the way it is supposed to look like * in the ASCII protocol... */ const char *err= "CLIENT_ERROR: Unsupported protocol\r\n"; client->root->spool(client, err, strlen(err)); client->root->drain(client); return MEMCACHED_PROTOCOL_ERROR_EVENT; /* Unsupported protocol */ } return client->work(client, length, endptr); } /* ** ********************************************************************** ** * PUBLIC INTERFACE ** * See protocol_handler.h for function description ** ********************************************************************** */ struct memcached_protocol_st *memcached_protocol_create_instance(void) { struct memcached_protocol_st *ret= calloc(1, sizeof(*ret)); if (ret != NULL) { ret->recv= default_recv; ret->send= default_send; ret->drain= drain_output; ret->spool= spool_output; ret->input_buffer_size= 1 * 1024 * 1024; ret->input_buffer= malloc(ret->input_buffer_size); if (ret->input_buffer == NULL) { free(ret); ret= NULL; return NULL; } ret->buffer_cache= cache_create("protocol_handler", CHUNK_BUFFERSIZE + sizeof(struct chunk_st), 0, NULL, NULL); if (ret->buffer_cache == NULL) { free(ret->input_buffer); free(ret); } } return ret; } void memcached_protocol_destroy_instance(struct memcached_protocol_st *instance) { cache_destroy(instance->buffer_cache); free(instance->input_buffer); free(instance); } struct memcached_protocol_client_st *memcached_protocol_create_client(struct memcached_protocol_st *instance, memcached_socket_t sock) { struct memcached_protocol_client_st *ret= calloc(1, sizeof(memcached_protocol_client_st)); if (ret != NULL) { ret->root= instance; ret->sock= sock; ret->work= determine_protocol; } return ret; } void memcached_protocol_client_destroy(struct memcached_protocol_client_st *client) { free(client); } void memcached_protocol_client_set_verbose(struct memcached_protocol_client_st *client, bool arg) { if (client) { client->is_verbose= arg; } } memcached_protocol_event_t memcached_protocol_client_work(struct memcached_protocol_client_st *client) { /* Try to send data and read from the socket */ bool more_data= true; do { ssize_t len= client->root->recv(client, client->sock, client->root->input_buffer + client->input_buffer_offset, client->root->input_buffer_size - client->input_buffer_offset); if (len > 0) { /* Do we have the complete packet? */ if (client->input_buffer_offset > 0) { memcpy(client->root->input_buffer, client->input_buffer, client->input_buffer_offset); len += (ssize_t)client->input_buffer_offset; /* @todo use buffer-cache! */ free(client->input_buffer); client->input_buffer_offset= 0; } void *endptr; memcached_protocol_event_t events= client->work(client, &len, &endptr); if (events == MEMCACHED_PROTOCOL_ERROR_EVENT) { return MEMCACHED_PROTOCOL_ERROR_EVENT; } if (len > 0) { /* save the data for later on */ /* @todo use buffer-cache */ client->input_buffer= malloc((size_t)len); if (client->input_buffer == NULL) { client->error= ENOMEM; return MEMCACHED_PROTOCOL_ERROR_EVENT; } memcpy(client->input_buffer, endptr, (size_t)len); client->input_buffer_offset= (size_t)len; more_data= false; } } else if (len == 0) { /* Connection closed */ drain_output(client); return MEMCACHED_PROTOCOL_ERROR_EVENT; } else { if (get_socket_errno() != EWOULDBLOCK) { client->error= get_socket_errno(); /* mark this client as terminated! */ return MEMCACHED_PROTOCOL_ERROR_EVENT; } more_data= false; } } while (more_data); if (!drain_output(client)) { return MEMCACHED_PROTOCOL_ERROR_EVENT; } memcached_protocol_event_t ret= MEMCACHED_PROTOCOL_READ_EVENT; if (client->output) { ret|= MEMCACHED_PROTOCOL_READ_EVENT; } return ret; } libmemcached-1.0.8/libmemcachedprotocol/cache.h0000664000076400007640000001351611753573717022020 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ #pragma once #include #ifdef HAVE_UMEM_H # include # define cache_t umem_cache_t # define cache_alloc(a) umem_cache_alloc(a, UMEM_DEFAULT) # define cache_free(a, b) umem_cache_free(a, b) # define cache_create(a,b,c,d,e) umem_cache_create((char*)a, b, c, d, e, NULL, NULL, NULL, 0) # define cache_destroy(a) umem_cache_destroy(a); #else # ifndef NDEBUG /* may be used for debug purposes */ extern int cache_error; # endif /** * Constructor used to initialize allocated objects * * @param obj pointer to the object to initialized. * @param notused1 This parameter is currently not used. * @param notused2 This parameter is currently not used. * @return you should return 0, but currently this is not checked */ typedef int cache_constructor_t(void* obj, void* notused1, int notused2); /** * Destructor used to clean up allocated objects before they are * returned to the operating system. * * @param obj pointer to the object to initialized. * @param notused1 This parameter is currently not used. * @param notused2 This parameter is currently not used. * @return you should return 0, but currently this is not checked */ typedef void cache_destructor_t(void* obj, void* notused); /** * Definition of the structure to keep track of the internal details of * the cache allocator. Touching any of these variables results in * undefined behavior. */ typedef struct { /** Mutex to protect access to the structure */ pthread_mutex_t mutex; /** Name of the cache objects in this cache (provided by the caller) */ char *name; /** List of pointers to available buffers in this cache */ void **ptr; /** The size of each element in this cache */ size_t bufsize; /** The capacity of the list of elements */ size_t freetotal; /** The current number of free elements */ size_t freecurr; /** The constructor to be called each time we allocate more memory */ cache_constructor_t* constructor; /** The destructor to be called each time before we release memory */ cache_destructor_t* destructor; } cache_t; /** * Create an object cache. * * The object cache will let you allocate objects of the same size. It is fully * MT safe, so you may allocate objects from multiple threads without having to * do any syncrhonization in the application code. * * @param name the name of the object cache. This name may be used for debug purposes * and may help you track down what kind of object you have problems with * (buffer overruns, leakage etc) * @param bufsize the size of each object in the cache * @param align the alignment requirements of the objects in the cache. * @param constructor the function to be called to initialize memory when we need * to allocate more memory from the os. * @param destructor the function to be called before we release the memory back * to the os. * @return a handle to an object cache if successful, NULL otherwise. */ cache_t* cache_create(const char* name, size_t bufsize, size_t align, cache_constructor_t* constructor, cache_destructor_t* destructor); /** * Destroy an object cache. * * Destroy and invalidate an object cache. You should return all buffers allocated * with cache_alloc by using cache_free before calling this function. Not doing * so results in undefined behavior (the buffers may or may not be invalidated) * * @param handle the handle to the object cache to destroy. */ void cache_destroy(cache_t* handle); /** * Allocate an object from the cache. * * @param handle the handle to the object cache to allocate from * @return a pointer to an initialized object from the cache, or NULL if * the allocation cannot be satisfied. */ void* cache_alloc(cache_t* handle); /** * Return an object back to the cache. * * The caller should return the object in an initialized state so that * the object may be returned in an expected state from cache_alloc. * * @param handle handle to the object cache to return the object to * @param ptr pointer to the object to return. */ void cache_free(cache_t* handle, void* ptr); #endif // HAVE_UMEM_H libmemcached-1.0.8/libhashkit/0000775000076400007640000000000011757025117016527 5ustar00brianbrian00000000000000libmemcached-1.0.8/libhashkit/common.h0000664000076400007640000000413511753573717020205 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * HashKit library * * Copyright (C) 2011 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. * */ #pragma once #include #include #include #include #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif HASHKIT_LOCAL void md5_signature(const unsigned char *key, unsigned int length, unsigned char *result); HASHKIT_LOCAL int update_continuum(hashkit_st *hashkit); #ifdef __cplusplus } #endif libmemcached-1.0.8/libhashkit/jenkins.cc0000664000076400007640000001506711753573717020522 0ustar00brianbrian00000000000000/* * * By Bob Jenkins, 2006. bob_jenkins@burtleburtle.net. You may use this * code any way you wish, private, educational, or commercial. It's free. * Use for hash table lookup, or anything where one collision in 2^^32 is * acceptable. Do NOT use for cryptographic purposes. * http://burtleburtle.net/bob/hash/index.html * * Modified by Brian Pontz for libmemcached * TODO: * Add big endian support */ #include #define hashsize(n) ((uint32_t)1<<(n)) #define hashmask(n) (hashsize(n)-1) #define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) #define mix(a,b,c) \ { \ a -= c; a ^= rot(c, 4); c += b; \ b -= a; b ^= rot(a, 6); a += c; \ c -= b; c ^= rot(b, 8); b += a; \ a -= c; a ^= rot(c,16); c += b; \ b -= a; b ^= rot(a,19); a += c; \ c -= b; c ^= rot(b, 4); b += a; \ } #define final(a,b,c) \ { \ c ^= b; c -= rot(b,14); \ a ^= c; a -= rot(c,11); \ b ^= a; b -= rot(a,25); \ c ^= b; c -= rot(b,16); \ a ^= c; a -= rot(c,4); \ b ^= a; b -= rot(a,14); \ c ^= b; c -= rot(b,24); \ } #define JENKINS_INITVAL 13 /* jenkins_hash() -- hash a variable-length key into a 32-bit value k : the key (the unaligned variable-length array of bytes) length : the length of the key, counting by bytes initval : can be any 4-byte value Returns a 32-bit value. Every bit of the key affects every bit of the return value. Two keys differing by one or two bits will have totally different hash values. The best hash table sizes are powers of 2. There is no need to do mod a prime (mod is sooo slow!). If you need less than 32 bits, use a bitmask. For example, if you need only 10 bits, do h = (h & hashmask(10)); In which case, the hash table should have hashsize(10) elements. */ uint32_t hashkit_jenkins(const char *key, size_t length, void *) { uint32_t a,b,c; /* internal state */ union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */ /* Set up the internal state */ a = b = c = 0xdeadbeef + ((uint32_t)length) + JENKINS_INITVAL; u.ptr = key; #ifndef WORDS_BIGENDIAN if ((u.i & 0x3) == 0) { const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */ /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */ while (length > 12) { a += k[0]; b += k[1]; c += k[2]; mix(a,b,c); length -= 12; k += 3; } /*----------------------------- handle the last (probably partial) block */ /* * "k[2]&0xffffff" actually reads beyond the end of the string, but * then masks off the part it's not allowed to read. Because the * string is aligned, the masked-off tail is in the same word as the * rest of the string. Every machine with memory protection I've seen * does it on word boundaries, so is OK with this. But VALGRIND will * still catch it and complain. The masking trick does make the hash * noticably faster for short strings (like English words). */ switch(length) { case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break; case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break; case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break; case 8 : b+=k[1]; a+=k[0]; break; case 7 : b+=k[1]&0xffffff; a+=k[0]; break; case 6 : b+=k[1]&0xffff; a+=k[0]; break; case 5 : b+=k[1]&0xff; a+=k[0]; break; case 4 : a+=k[0]; break; case 3 : a+=k[0]&0xffffff; break; case 2 : a+=k[0]&0xffff; break; case 1 : a+=k[0]&0xff; break; case 0 : return c; /* zero length strings require no mixing */ default: return c; } } else if ((u.i & 0x1) == 0) { const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */ const uint8_t *k8; /*--------------- all but last block: aligned reads and different mixing */ while (length > 12) { a += k[0] + (((uint32_t)k[1])<<16); b += k[2] + (((uint32_t)k[3])<<16); c += k[4] + (((uint32_t)k[5])<<16); mix(a,b,c); length -= 12; k += 6; } /*----------------------------- handle the last (probably partial) block */ k8 = (const uint8_t *)k; switch(length) { case 12: c+=k[4]+(((uint32_t)k[5])<<16); b+=k[2]+(((uint32_t)k[3])<<16); a+=k[0]+(((uint32_t)k[1])<<16); break; case 11: c+=((uint32_t)k8[10])<<16; /* fall through */ case 10: c+=k[4]; b+=k[2]+(((uint32_t)k[3])<<16); a+=k[0]+(((uint32_t)k[1])<<16); break; case 9 : c+=k8[8]; /* fall through */ case 8 : b+=k[2]+(((uint32_t)k[3])<<16); a+=k[0]+(((uint32_t)k[1])<<16); break; case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */ case 6 : b+=k[2]; a+=k[0]+(((uint32_t)k[1])<<16); break; case 5 : b+=k8[4]; /* fall through */ case 4 : a+=k[0]+(((uint32_t)k[1])<<16); break; case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */ case 2 : a+=k[0]; break; case 1 : a+=k8[0]; break; case 0 : return c; /* zero length requires no mixing */ default: return c; } } else { /* need to read the key one byte at a time */ #endif /* little endian */ const uint8_t *k = (const uint8_t *)key; /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ while (length > 12) { a += k[0]; a += ((uint32_t)k[1])<<8; a += ((uint32_t)k[2])<<16; a += ((uint32_t)k[3])<<24; b += k[4]; b += ((uint32_t)k[5])<<8; b += ((uint32_t)k[6])<<16; b += ((uint32_t)k[7])<<24; c += k[8]; c += ((uint32_t)k[9])<<8; c += ((uint32_t)k[10])<<16; c += ((uint32_t)k[11])<<24; mix(a,b,c); length -= 12; k += 12; } /*-------------------------------- last block: affect all 32 bits of (c) */ switch(length) /* all the case statements fall through */ { case 12: c+=((uint32_t)k[11])<<24; case 11: c+=((uint32_t)k[10])<<16; case 10: c+=((uint32_t)k[9])<<8; case 9 : c+=k[8]; case 8 : b+=((uint32_t)k[7])<<24; case 7 : b+=((uint32_t)k[6])<<16; case 6 : b+=((uint32_t)k[5])<<8; case 5 : b+=k[4]; case 4 : a+=((uint32_t)k[3])<<24; case 3 : a+=((uint32_t)k[2])<<16; case 2 : a+=((uint32_t)k[1])<<8; case 1 : a+=k[0]; break; case 0 : return c; default : return c; } #ifndef WORDS_BIGENDIAN } #endif final(a,b,c); return c; } libmemcached-1.0.8/libhashkit/one_at_a_time.cc0000664000076400007640000000131311753573717021631 0ustar00brianbrian00000000000000/* HashKit * Copyright (C) 2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ /* This has is Jenkin's "One at A time Hash". http://en.wikipedia.org/wiki/Jenkins_hash_function */ #include uint32_t hashkit_one_at_a_time(const char *key, size_t key_length, void *context) { const char *ptr= key; uint32_t value= 0; (void)context; while (key_length--) { uint32_t val= (uint32_t) *ptr++; value += val; value += (value << 10); value ^= (value >> 6); } value += (value << 3); value ^= (value >> 11); value += (value << 15); return value; } libmemcached-1.0.8/libhashkit/include.am0000664000076400007640000000450211753573717020504 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root # # HashKit # Copyright (C) 2009 Brian Aker # All rights reserved. # # Use and distribution licensed under the BSD license. See # the COPYING file in the parent directory for full text. lib_LTLIBRARIES+= libhashkit/libhashkit.la noinst_HEADERS+= libhashkit/aes.h noinst_HEADERS+= libhashkit/common.h noinst_HEADERS+= libhashkit/is.h noinst_HEADERS+= libhashkit/rijndael.hpp noinst_HEADERS+= libhashkit/string.h nobase_include_HEADERS+= libhashkit/hashkit.h libhashkit_libhashkit_la_SOURCES= libhashkit_libhashkit_la_CXXFLAGS= 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/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/rijndael.cc libhashkit_libhashkit_la_SOURCES+= libhashkit/str_algorithm.cc libhashkit_libhashkit_la_SOURCES+= libhashkit/strerror.cc libhashkit_libhashkit_la_SOURCES+= libhashkit/string.cc if INCLUDE_HSIEH_SRC libhashkit_libhashkit_la_SOURCES+= libhashkit/hsieh.cc else libhashkit_libhashkit_la_SOURCES+= libhashkit/nohsieh.cc endif libhashkit_libhashkit_la_CXXFLAGS+= -DBUILDING_HASHKIT libhashkit_libhashkit_la_LIBADD= libhashkit_libhashkit_la_LDFLAGS= -version-info $(HASHKIT_LIBRARY_VERSION) # library used for testing 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) libmemcached-1.0.8/libhashkit/encrypt.cc0000664000076400007640000000442411753573717020540 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libhashkit 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 hashkit_string_st *hashkit_encrypt(hashkit_st *kit, const char* source, size_t source_length) { return aes_encrypt(static_cast(kit->_key), source, source_length); } hashkit_string_st *hashkit_decrypt(hashkit_st *kit, const char* source, size_t source_length) { return aes_decrypt(static_cast(kit->_key), source, source_length); } bool hashkit_key(hashkit_st *kit, const char *key, const size_t key_length) { if (kit->_key) { free(kit->_key); } kit->_key= aes_create_key(key, key_length); return bool(kit->_key); } libmemcached-1.0.8/libhashkit/hashkit.h0000664000076400007640000000325211753573717020347 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * HashKit library * * Copyright (C) 2011 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. * */ #pragma once #include libmemcached-1.0.8/libhashkit/rijndael.hpp0000664000076400007640000000364511753573717021052 0ustar00brianbrian00000000000000/** * rijndael-alg-fst.h * * @version 3.0 (December 2000) * * Optimised ANSI C code for the Rijndael cipher (now AES) * * @author Vincent Rijmen * @author Antoon Bosselaers * @author Paulo Barreto * * This code is hereby placed in the public domain. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''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 AUTHORS 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. */ #pragma once #define MAXKC (256/32) #define MAXKB (256/8) #define MAXNR 14 #define AES_MAXKC MAXKC #define AES_MAXKB MAXKB #define AES_MAXNR MAXNR typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32; int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits); int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits); void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]); void rijndaelDecrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 ct[16], u8 pt[16]); #ifdef INTERMEDIATE_VALUE_KAT void rijndaelEncryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds); void rijndaelDecryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds); #endif /* INTERMEDIATE_VALUE_KAT */ libmemcached-1.0.8/libhashkit/rijndael.cc0000664000076400007640000017427111753573717020654 0ustar00brianbrian00000000000000/** * rijndael-alg-fst.c * * @version 3.0 (December 2000) * * Optimised ANSI C code for the Rijndael cipher (now AES) * * @author Vincent Rijmen * @author Antoon Bosselaers * @author Paulo Barreto * * This code is hereby placed in the public domain. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''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 AUTHORS 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 #include #include /* Te0[x] = S [x].[02, 01, 01, 03]; Te1[x] = S [x].[03, 02, 01, 01]; Te2[x] = S [x].[01, 03, 02, 01]; Te3[x] = S [x].[01, 01, 03, 02]; Te4[x] = S [x].[01, 01, 01, 01]; Td0[x] = Si[x].[0e, 09, 0d, 0b]; Td1[x] = Si[x].[0b, 0e, 09, 0d]; Td2[x] = Si[x].[0d, 0b, 0e, 09]; Td3[x] = Si[x].[09, 0d, 0b, 0e]; Td4[x] = Si[x].[01, 01, 01, 01]; */ static const u32 Te0[256] = { 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU, 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U, 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU, 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU, 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU, 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU, 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU, 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U, 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU, 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU, 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U, 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU, 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU, 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU, 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU, 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU, 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U, 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU, 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU, 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU, 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU, 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U, 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U, 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U, 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U, 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU, 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U, 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U, 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU, 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU, 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U, 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U, 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U, 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU, 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U, 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU, 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U, 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU, 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U, 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U, 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU, 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U, 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U, 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U, 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U, 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U, 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U, 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U, 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U, 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU, 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U, 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U, 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U, 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U, 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U, 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U, 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU, 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U, 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U, 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, }; static const u32 Te1[256] = { 0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU, 0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U, 0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU, 0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U, 0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU, 0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U, 0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU, 0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U, 0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U, 0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU, 0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U, 0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U, 0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U, 0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU, 0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U, 0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U, 0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU, 0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U, 0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U, 0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U, 0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU, 0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU, 0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U, 0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU, 0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU, 0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U, 0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU, 0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U, 0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU, 0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U, 0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U, 0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U, 0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU, 0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U, 0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU, 0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U, 0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU, 0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U, 0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U, 0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU, 0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU, 0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU, 0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U, 0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U, 0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU, 0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U, 0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU, 0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U, 0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU, 0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U, 0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU, 0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU, 0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U, 0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU, 0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U, 0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU, 0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U, 0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U, 0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U, 0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU, 0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU, 0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U, 0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU, 0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U, }; static const u32 Te2[256] = { 0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU, 0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U, 0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU, 0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U, 0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU, 0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U, 0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU, 0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U, 0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U, 0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU, 0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U, 0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U, 0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U, 0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU, 0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U, 0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U, 0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU, 0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U, 0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U, 0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U, 0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU, 0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU, 0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U, 0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU, 0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU, 0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U, 0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU, 0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U, 0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU, 0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U, 0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U, 0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U, 0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU, 0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U, 0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU, 0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U, 0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU, 0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U, 0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U, 0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU, 0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU, 0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU, 0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U, 0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U, 0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU, 0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U, 0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU, 0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U, 0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU, 0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U, 0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU, 0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU, 0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U, 0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU, 0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U, 0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU, 0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U, 0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U, 0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U, 0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU, 0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU, 0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U, 0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU, 0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U, }; static const u32 Te3[256] = { 0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U, 0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U, 0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U, 0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU, 0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU, 0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU, 0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U, 0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU, 0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU, 0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U, 0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U, 0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU, 0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU, 0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU, 0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU, 0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU, 0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U, 0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU, 0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU, 0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U, 0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U, 0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U, 0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U, 0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U, 0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU, 0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U, 0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU, 0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU, 0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U, 0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U, 0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U, 0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU, 0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U, 0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU, 0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU, 0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U, 0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U, 0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU, 0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U, 0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU, 0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U, 0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U, 0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U, 0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U, 0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU, 0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U, 0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU, 0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U, 0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU, 0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U, 0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU, 0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU, 0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU, 0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU, 0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U, 0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U, 0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U, 0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U, 0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U, 0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U, 0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU, 0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U, 0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU, 0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU, }; static const u32 Te4[256] = { 0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU, 0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U, 0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU, 0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U, 0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU, 0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U, 0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU, 0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U, 0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U, 0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU, 0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U, 0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U, 0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U, 0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU, 0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U, 0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U, 0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU, 0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U, 0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U, 0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U, 0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU, 0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU, 0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U, 0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU, 0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU, 0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U, 0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU, 0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U, 0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU, 0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U, 0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U, 0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U, 0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU, 0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U, 0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU, 0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U, 0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU, 0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U, 0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U, 0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU, 0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU, 0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU, 0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U, 0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U, 0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU, 0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U, 0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU, 0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U, 0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU, 0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U, 0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU, 0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU, 0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U, 0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU, 0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U, 0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU, 0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U, 0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U, 0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U, 0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU, 0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU, 0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U, 0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU, 0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U, }; static const u32 Td0[256] = { 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU, 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U, 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U, 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU, 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U, 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU, 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U, 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U, 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U, 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U, 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU, 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U, 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU, 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U, 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU, 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U, 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U, 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U, 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU, 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U, 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU, 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U, 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU, 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U, 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU, 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU, 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U, 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU, 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U, 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU, 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U, 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U, 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U, 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU, 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U, 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U, 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU, 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U, 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U, 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U, 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U, 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U, 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU, 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U, 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U, 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U, 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U, 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U, 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU, 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU, 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU, 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU, 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U, 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U, 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU, 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU, 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U, 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU, 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U, 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, }; static const u32 Td1[256] = { 0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU, 0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U, 0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU, 0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U, 0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U, 0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U, 0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U, 0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U, 0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U, 0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU, 0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU, 0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU, 0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U, 0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU, 0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U, 0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U, 0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U, 0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU, 0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU, 0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U, 0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU, 0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U, 0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU, 0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU, 0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U, 0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U, 0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U, 0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU, 0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U, 0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU, 0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U, 0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U, 0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U, 0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU, 0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U, 0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U, 0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U, 0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U, 0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U, 0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U, 0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU, 0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU, 0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U, 0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU, 0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U, 0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU, 0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU, 0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U, 0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU, 0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U, 0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U, 0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U, 0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U, 0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U, 0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U, 0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U, 0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU, 0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U, 0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U, 0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU, 0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U, 0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U, 0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U, 0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U, }; static const u32 Td2[256] = { 0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U, 0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U, 0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U, 0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U, 0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU, 0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U, 0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U, 0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U, 0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U, 0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU, 0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U, 0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U, 0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU, 0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U, 0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U, 0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U, 0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U, 0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U, 0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U, 0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU, 0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U, 0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U, 0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U, 0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U, 0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U, 0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU, 0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU, 0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U, 0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU, 0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U, 0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU, 0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU, 0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU, 0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU, 0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U, 0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U, 0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U, 0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U, 0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U, 0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U, 0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U, 0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU, 0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU, 0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U, 0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U, 0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU, 0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU, 0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U, 0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U, 0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U, 0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U, 0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U, 0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U, 0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U, 0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU, 0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U, 0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U, 0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U, 0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U, 0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U, 0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U, 0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU, 0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U, 0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U, }; static const u32 Td3[256] = { 0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU, 0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU, 0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U, 0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U, 0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU, 0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU, 0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U, 0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU, 0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U, 0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU, 0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U, 0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U, 0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U, 0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U, 0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U, 0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU, 0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU, 0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U, 0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U, 0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU, 0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU, 0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U, 0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U, 0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U, 0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U, 0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU, 0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U, 0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U, 0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU, 0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU, 0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U, 0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U, 0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U, 0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU, 0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U, 0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U, 0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U, 0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U, 0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U, 0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U, 0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U, 0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU, 0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U, 0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U, 0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU, 0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU, 0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U, 0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU, 0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U, 0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U, 0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U, 0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U, 0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U, 0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U, 0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU, 0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU, 0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU, 0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU, 0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U, 0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U, 0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U, 0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU, 0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U, 0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U, }; static const u32 Td4[256] = { 0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U, 0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U, 0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU, 0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU, 0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U, 0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U, 0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U, 0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU, 0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U, 0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU, 0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU, 0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU, 0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U, 0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U, 0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U, 0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U, 0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U, 0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U, 0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU, 0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U, 0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U, 0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU, 0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U, 0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U, 0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U, 0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU, 0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U, 0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U, 0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU, 0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U, 0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U, 0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU, 0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U, 0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU, 0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU, 0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U, 0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U, 0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U, 0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U, 0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU, 0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U, 0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U, 0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU, 0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU, 0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU, 0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U, 0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU, 0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U, 0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U, 0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U, 0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U, 0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU, 0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U, 0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU, 0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU, 0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU, 0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU, 0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U, 0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU, 0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U, 0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU, 0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U, 0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U, 0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU, }; static const u32 rcon[] = { 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000, 0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ }; #define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00) #ifdef _MSC_VER #define GETU32(p) SWAP(*((u32 *)(p))) #define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); } #else #define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3])) #define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); } #endif /** * Expand the cipher key into the encryption key schedule. * * @return the number of rounds for the given cipher key size. */ int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits) { int i = 0; u32 temp; rk[0] = GETU32(cipherKey ); rk[1] = GETU32(cipherKey + 4); rk[2] = GETU32(cipherKey + 8); rk[3] = GETU32(cipherKey + 12); if (keyBits == 128) { for (;;) { temp = rk[3]; rk[4] = rk[0] ^ (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ (Te4[(temp ) & 0xff] & 0x0000ff00) ^ (Te4[(temp >> 24) ] & 0x000000ff) ^ rcon[i]; rk[5] = rk[1] ^ rk[4]; rk[6] = rk[2] ^ rk[5]; rk[7] = rk[3] ^ rk[6]; if (++i == 10) { return 10; } rk += 4; } } rk[4] = GETU32(cipherKey + 16); rk[5] = GETU32(cipherKey + 20); if (keyBits == 192) { for (;;) { temp = rk[ 5]; rk[ 6] = rk[ 0] ^ (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ (Te4[(temp ) & 0xff] & 0x0000ff00) ^ (Te4[(temp >> 24) ] & 0x000000ff) ^ rcon[i]; rk[ 7] = rk[ 1] ^ rk[ 6]; rk[ 8] = rk[ 2] ^ rk[ 7]; rk[ 9] = rk[ 3] ^ rk[ 8]; if (++i == 8) { return 12; } rk[10] = rk[ 4] ^ rk[ 9]; rk[11] = rk[ 5] ^ rk[10]; rk += 6; } } rk[6] = GETU32(cipherKey + 24); rk[7] = GETU32(cipherKey + 28); if (keyBits == 256) { for (;;) { temp = rk[ 7]; rk[ 8] = rk[ 0] ^ (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ (Te4[(temp ) & 0xff] & 0x0000ff00) ^ (Te4[(temp >> 24) ] & 0x000000ff) ^ rcon[i]; rk[ 9] = rk[ 1] ^ rk[ 8]; rk[10] = rk[ 2] ^ rk[ 9]; rk[11] = rk[ 3] ^ rk[10]; if (++i == 7) { return 14; } temp = rk[11]; rk[12] = rk[ 4] ^ (Te4[(temp >> 24) ] & 0xff000000) ^ (Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^ (Te4[(temp >> 8) & 0xff] & 0x0000ff00) ^ (Te4[(temp ) & 0xff] & 0x000000ff); rk[13] = rk[ 5] ^ rk[12]; rk[14] = rk[ 6] ^ rk[13]; rk[15] = rk[ 7] ^ rk[14]; rk += 8; } } return 0; } /** * Expand the cipher key into the decryption key schedule. * * @return the number of rounds for the given cipher key size. */ int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits) { int Nr, i, j; u32 temp; /* expand the cipher key: */ Nr = rijndaelKeySetupEnc(rk, cipherKey, keyBits); /* invert the order of the round keys: */ for (i = 0, j = 4*Nr; i < j; i += 4, j -= 4) { temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp; temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp; temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp; temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp; } /* apply the inverse MixColumn transform to all round keys but the first and the last: */ for (i = 1; i < Nr; i++) { rk += 4; rk[0] = Td0[Te4[(rk[0] >> 24) ] & 0xff] ^ Td1[Te4[(rk[0] >> 16) & 0xff] & 0xff] ^ Td2[Te4[(rk[0] >> 8) & 0xff] & 0xff] ^ Td3[Te4[(rk[0] ) & 0xff] & 0xff]; rk[1] = Td0[Te4[(rk[1] >> 24) ] & 0xff] ^ Td1[Te4[(rk[1] >> 16) & 0xff] & 0xff] ^ Td2[Te4[(rk[1] >> 8) & 0xff] & 0xff] ^ Td3[Te4[(rk[1] ) & 0xff] & 0xff]; rk[2] = Td0[Te4[(rk[2] >> 24) ] & 0xff] ^ Td1[Te4[(rk[2] >> 16) & 0xff] & 0xff] ^ Td2[Te4[(rk[2] >> 8) & 0xff] & 0xff] ^ Td3[Te4[(rk[2] ) & 0xff] & 0xff]; rk[3] = Td0[Te4[(rk[3] >> 24) ] & 0xff] ^ Td1[Te4[(rk[3] >> 16) & 0xff] & 0xff] ^ Td2[Te4[(rk[3] >> 8) & 0xff] & 0xff] ^ Td3[Te4[(rk[3] ) & 0xff] & 0xff]; } return Nr; } void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]) { u32 s0, s1, s2, s3, t0, t1, t2, t3; #ifndef FULL_UNROLL int r; #endif /* ?FULL_UNROLL */ /* * map byte array block to cipher state * and add initial round key: */ s0 = GETU32(pt ) ^ rk[0]; s1 = GETU32(pt + 4) ^ rk[1]; s2 = GETU32(pt + 8) ^ rk[2]; s3 = GETU32(pt + 12) ^ rk[3]; #ifdef FULL_UNROLL /* round 1: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7]; /* round 2: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11]; /* round 3: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15]; /* round 4: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19]; /* round 5: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23]; /* round 6: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27]; /* round 7: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31]; /* round 8: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35]; /* round 9: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39]; if (Nr > 10) { /* round 10: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[40]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[41]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[42]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[43]; /* round 11: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[44]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[45]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[46]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[47]; if (Nr > 12) { /* round 12: */ s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[48]; s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[49]; s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[50]; s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[51]; /* round 13: */ t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[52]; t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[53]; t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[54]; t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[55]; } } rk += Nr << 2; #else /* !FULL_UNROLL */ /* * Nr - 1 full rounds: */ r = Nr >> 1; for (;;) { t0 = Te0[(s0 >> 24) ] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[(s3 ) & 0xff] ^ rk[4]; t1 = Te0[(s1 >> 24) ] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[(s0 ) & 0xff] ^ rk[5]; t2 = Te0[(s2 >> 24) ] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[(s1 ) & 0xff] ^ rk[6]; t3 = Te0[(s3 >> 24) ] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[(s2 ) & 0xff] ^ rk[7]; rk += 8; if (--r == 0) { break; } s0 = Te0[(t0 >> 24) ] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[(t3 ) & 0xff] ^ rk[0]; s1 = Te0[(t1 >> 24) ] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[(t0 ) & 0xff] ^ rk[1]; s2 = Te0[(t2 >> 24) ] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[(t1 ) & 0xff] ^ rk[2]; s3 = Te0[(t3 >> 24) ] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[(t2 ) & 0xff] ^ rk[3]; } #endif /* ?FULL_UNROLL */ /* * apply last round and * map cipher state to byte array block: */ s0 = (Te4[(t0 >> 24) ] & 0xff000000) ^ (Te4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ (Te4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ (Te4[(t3 ) & 0xff] & 0x000000ff) ^ rk[0]; PUTU32(ct , s0); s1 = (Te4[(t1 >> 24) ] & 0xff000000) ^ (Te4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ (Te4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ (Te4[(t0 ) & 0xff] & 0x000000ff) ^ rk[1]; PUTU32(ct + 4, s1); s2 = (Te4[(t2 >> 24) ] & 0xff000000) ^ (Te4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ (Te4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ (Te4[(t1 ) & 0xff] & 0x000000ff) ^ rk[2]; PUTU32(ct + 8, s2); s3 = (Te4[(t3 >> 24) ] & 0xff000000) ^ (Te4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ (Te4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ (Te4[(t2 ) & 0xff] & 0x000000ff) ^ rk[3]; PUTU32(ct + 12, s3); } void rijndaelDecrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 ct[16], u8 pt[16]) { u32 s0, s1, s2, s3, t0, t1, t2, t3; #ifndef FULL_UNROLL int r; #endif /* ?FULL_UNROLL */ /* * map byte array block to cipher state * and add initial round key: */ s0 = GETU32(ct ) ^ rk[0]; s1 = GETU32(ct + 4) ^ rk[1]; s2 = GETU32(ct + 8) ^ rk[2]; s3 = GETU32(ct + 12) ^ rk[3]; #ifdef FULL_UNROLL /* round 1: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[ 4]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[ 5]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[ 6]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[ 7]; /* round 2: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[ 8]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[ 9]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[10]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[11]; /* round 3: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[12]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[13]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[14]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[15]; /* round 4: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[16]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[17]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[18]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[19]; /* round 5: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[20]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[21]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[22]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[23]; /* round 6: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[24]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[25]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[26]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[27]; /* round 7: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[28]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[29]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[30]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[31]; /* round 8: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[32]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[33]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[34]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[35]; /* round 9: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[36]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[37]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[38]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[39]; if (Nr > 10) { /* round 10: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[40]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[41]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[42]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[43]; /* round 11: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[44]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[45]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[46]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[47]; if (Nr > 12) { /* round 12: */ s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[48]; s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[49]; s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[50]; s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[51]; /* round 13: */ t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[52]; t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[53]; t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[54]; t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[55]; } } rk += Nr << 2; #else /* !FULL_UNROLL */ /* * Nr - 1 full rounds: */ r = Nr >> 1; for (;;) { t0 = Td0[(s0 >> 24) ] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[(s1 ) & 0xff] ^ rk[4]; t1 = Td0[(s1 >> 24) ] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[(s2 ) & 0xff] ^ rk[5]; t2 = Td0[(s2 >> 24) ] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[(s3 ) & 0xff] ^ rk[6]; t3 = Td0[(s3 >> 24) ] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[(s0 ) & 0xff] ^ rk[7]; rk += 8; if (--r == 0) { break; } s0 = Td0[(t0 >> 24) ] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[(t1 ) & 0xff] ^ rk[0]; s1 = Td0[(t1 >> 24) ] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[(t2 ) & 0xff] ^ rk[1]; s2 = Td0[(t2 >> 24) ] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[(t3 ) & 0xff] ^ rk[2]; s3 = Td0[(t3 >> 24) ] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[(t0 ) & 0xff] ^ rk[3]; } #endif /* ?FULL_UNROLL */ /* * apply last round and * map cipher state to byte array block: */ s0 = (Td4[(t0 >> 24) ] & 0xff000000) ^ (Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ (Td4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ (Td4[(t1 ) & 0xff] & 0x000000ff) ^ rk[0]; PUTU32(pt , s0); s1 = (Td4[(t1 >> 24) ] & 0xff000000) ^ (Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ (Td4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ (Td4[(t2 ) & 0xff] & 0x000000ff) ^ rk[1]; PUTU32(pt + 4, s1); s2 = (Td4[(t2 >> 24) ] & 0xff000000) ^ (Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ (Td4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ (Td4[(t3 ) & 0xff] & 0x000000ff) ^ rk[2]; PUTU32(pt + 8, s2); s3 = (Td4[(t3 >> 24) ] & 0xff000000) ^ (Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ (Td4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ (Td4[(t0 ) & 0xff] & 0x000000ff) ^ rk[3]; PUTU32(pt + 12, s3); } #ifdef INTERMEDIATE_VALUE_KAT void rijndaelEncryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds) { int r; u32 s0, s1, s2, s3, t0, t1, t2, t3; /* * map byte array block to cipher state * and add initial round key: */ s0 = GETU32(block ) ^ rk[0]; s1 = GETU32(block + 4) ^ rk[1]; s2 = GETU32(block + 8) ^ rk[2]; s3 = GETU32(block + 12) ^ rk[3]; rk += 4; /* * Nr - 1 full rounds: */ for (r = (rounds < Nr ? rounds : Nr - 1); r > 0; r--) { t0 = Te0[(s0 >> 24) ] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[(s3 ) & 0xff] ^ rk[0]; t1 = Te0[(s1 >> 24) ] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[(s0 ) & 0xff] ^ rk[1]; t2 = Te0[(s2 >> 24) ] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[(s1 ) & 0xff] ^ rk[2]; t3 = Te0[(s3 >> 24) ] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[(s2 ) & 0xff] ^ rk[3]; s0 = t0; s1 = t1; s2 = t2; s3 = t3; rk += 4; } /* * apply last round and * map cipher state to byte array block: */ if (rounds == Nr) { t0 = (Te4[(s0 >> 24) ] & 0xff000000) ^ (Te4[(s1 >> 16) & 0xff] & 0x00ff0000) ^ (Te4[(s2 >> 8) & 0xff] & 0x0000ff00) ^ (Te4[(s3 ) & 0xff] & 0x000000ff) ^ rk[0]; t1 = (Te4[(s1 >> 24) ] & 0xff000000) ^ (Te4[(s2 >> 16) & 0xff] & 0x00ff0000) ^ (Te4[(s3 >> 8) & 0xff] & 0x0000ff00) ^ (Te4[(s0 ) & 0xff] & 0x000000ff) ^ rk[1]; t2 = (Te4[(s2 >> 24) ] & 0xff000000) ^ (Te4[(s3 >> 16) & 0xff] & 0x00ff0000) ^ (Te4[(s0 >> 8) & 0xff] & 0x0000ff00) ^ (Te4[(s1 ) & 0xff] & 0x000000ff) ^ rk[2]; t3 = (Te4[(s3 >> 24) ] & 0xff000000) ^ (Te4[(s0 >> 16) & 0xff] & 0x00ff0000) ^ (Te4[(s1 >> 8) & 0xff] & 0x0000ff00) ^ (Te4[(s2 ) & 0xff] & 0x000000ff) ^ rk[3]; s0 = t0; s1 = t1; s2 = t2; s3 = t3; } PUTU32(block , s0); PUTU32(block + 4, s1); PUTU32(block + 8, s2); PUTU32(block + 12, s3); } void rijndaelDecryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds) { int r; u32 s0, s1, s2, s3, t0, t1, t2, t3; /* * map byte array block to cipher state * and add initial round key: */ s0 = GETU32(block ) ^ rk[0]; s1 = GETU32(block + 4) ^ rk[1]; s2 = GETU32(block + 8) ^ rk[2]; s3 = GETU32(block + 12) ^ rk[3]; rk += 4; /* * Nr - 1 full rounds: */ for (r = (rounds < Nr ? rounds : Nr) - 1; r > 0; r--) { t0 = Td0[(s0 >> 24) ] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[(s1 ) & 0xff] ^ rk[0]; t1 = Td0[(s1 >> 24) ] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[(s2 ) & 0xff] ^ rk[1]; t2 = Td0[(s2 >> 24) ] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[(s3 ) & 0xff] ^ rk[2]; t3 = Td0[(s3 >> 24) ] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[(s0 ) & 0xff] ^ rk[3]; s0 = t0; s1 = t1; s2 = t2; s3 = t3; rk += 4; } /* * complete the last round and * map cipher state to byte array block: */ t0 = (Td4[(s0 >> 24) ] & 0xff000000) ^ (Td4[(s3 >> 16) & 0xff] & 0x00ff0000) ^ (Td4[(s2 >> 8) & 0xff] & 0x0000ff00) ^ (Td4[(s1 ) & 0xff] & 0x000000ff); t1 = (Td4[(s1 >> 24) ] & 0xff000000) ^ (Td4[(s0 >> 16) & 0xff] & 0x00ff0000) ^ (Td4[(s3 >> 8) & 0xff] & 0x0000ff00) ^ (Td4[(s2 ) & 0xff] & 0x000000ff); t2 = (Td4[(s2 >> 24) ] & 0xff000000) ^ (Td4[(s1 >> 16) & 0xff] & 0x00ff0000) ^ (Td4[(s0 >> 8) & 0xff] & 0x0000ff00) ^ (Td4[(s3 ) & 0xff] & 0x000000ff); t3 = (Td4[(s3 >> 24) ] & 0xff000000) ^ (Td4[(s2 >> 16) & 0xff] & 0x00ff0000) ^ (Td4[(s1 >> 8) & 0xff] & 0x0000ff00) ^ (Td4[(s0 ) & 0xff] & 0x000000ff); if (rounds == Nr) { t0 ^= rk[0]; t1 ^= rk[1]; t2 ^= rk[2]; t3 ^= rk[3]; } PUTU32(block , t0); PUTU32(block + 4, t1); PUTU32(block + 8, t2); PUTU32(block + 12, t3); } #endif /* INTERMEDIATE_VALUE_KAT */ libmemcached-1.0.8/libhashkit/digest.cc0000664000076400007640000000316511753573717020334 0ustar00brianbrian00000000000000/* HashKit * Copyright (C) 2010 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ #include uint32_t hashkit_digest(const hashkit_st *self, const char *key, size_t key_length) { return self->base_hash.function(key, key_length, self->base_hash.context); } uint32_t libhashkit_digest(const char *key, size_t key_length, hashkit_hash_algorithm_t hash_algorithm) { switch (hash_algorithm) { case HASHKIT_HASH_DEFAULT: return libhashkit_one_at_a_time(key, key_length); case HASHKIT_HASH_MD5: return libhashkit_md5(key, key_length); case HASHKIT_HASH_CRC: return libhashkit_crc32(key, key_length); case HASHKIT_HASH_FNV1_64: return libhashkit_fnv1_64(key, key_length); case HASHKIT_HASH_FNV1A_64: return libhashkit_fnv1a_64(key, key_length); case HASHKIT_HASH_FNV1_32: return libhashkit_fnv1_32(key, key_length); case HASHKIT_HASH_FNV1A_32: return libhashkit_fnv1a_32(key, key_length); case HASHKIT_HASH_HSIEH: #ifdef HAVE_HSIEH_HASH return libhashkit_hsieh(key, key_length); #else return 1; #endif case HASHKIT_HASH_MURMUR: #ifdef HAVE_MURMUR_HASH return libhashkit_murmur(key, key_length); #else return 1; #endif case HASHKIT_HASH_JENKINS: return libhashkit_jenkins(key, key_length); case HASHKIT_HASH_CUSTOM: case HASHKIT_HASH_MAX: default: if (DEBUG) { fprintf(stderr, "hashkit_hash_t was extended but libhashkit_generate_value was not updated\n"); fflush(stderr); assert(0); } break; } return 1; } libmemcached-1.0.8/libhashkit/algorithm.cc0000664000076400007640000000571011753573717021041 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * HashKit library * * Copyright (C) 2006-2011 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 uint32_t libhashkit_one_at_a_time(const char *key, size_t key_length) { return hashkit_one_at_a_time(key, key_length, NULL); } uint32_t libhashkit_fnv1_64(const char *key, size_t key_length) { return hashkit_fnv1_64(key, key_length, NULL); } uint32_t libhashkit_fnv1a_64(const char *key, size_t key_length) { return hashkit_fnv1a_64(key, key_length, NULL); } uint32_t libhashkit_fnv1_32(const char *key, size_t key_length) { return hashkit_fnv1_32(key, key_length, NULL); } uint32_t libhashkit_fnv1a_32(const char *key, size_t key_length) { return hashkit_fnv1a_32(key, key_length, NULL); } uint32_t libhashkit_crc32(const char *key, size_t key_length) { return hashkit_crc32(key, key_length, NULL); } uint32_t libhashkit_hsieh(const char *key, size_t key_length) { return hashkit_hsieh(key, key_length, NULL); } uint32_t libhashkit_murmur(const char *key, size_t key_length) { return hashkit_murmur(key, key_length, NULL); } uint32_t libhashkit_jenkins(const char *key, size_t key_length) { return hashkit_jenkins(key, key_length, NULL); } uint32_t libhashkit_md5(const char *key, size_t key_length) { return hashkit_md5(key, key_length, NULL); } void libhashkit_md5_signature(const unsigned char *key, size_t length, unsigned char *result) { md5_signature(key, (uint32_t)length, result); } libmemcached-1.0.8/libhashkit/md5.cc0000664000076400007640000002706511753573717017547 0ustar00brianbrian00000000000000/* This Library has been modified from its original form by Brian Aker (brian@tangent.org) See below for original Copyright. */ /* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm */ /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing this software or this function. License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing the derived work. RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided "as is" without express or implied warranty of any kind. These notices must be retained in any copies of any part of this documentation and/or software. */ #include #include #include /* POINTER defines a generic pointer type */ typedef unsigned char *POINTER; typedef const unsigned char *CONST_POINTER; /* UINT4 defines a four byte word */ typedef unsigned int UINT4; /* MD5 context. */ typedef struct { UINT4 state[4]; /* state (ABCD) */ UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } MD5_CTX; static void MD5Init (MD5_CTX *context); /* context */ static void MD5Update ( MD5_CTX *context, /* context */ const unsigned char *input, /* input block */ unsigned int inputLen); /* length of input block */ static void MD5Final ( unsigned char digest[16], /* message digest */ MD5_CTX *context); /* context */ /* Constants for MD5Transform routine. */ #define S11 7 #define S12 12 #define S13 17 #define S14 22 #define S21 5 #define S22 9 #define S23 14 #define S24 20 #define S31 4 #define S32 11 #define S33 16 #define S34 23 #define S41 6 #define S42 10 #define S43 15 #define S44 21 static void MD5Transform (UINT4 state[4], const unsigned char block[64]); static void Encode (unsigned char *output, UINT4 *input, unsigned int len); static void Decode(UINT4 *output, const unsigned char *input, unsigned int len); static unsigned char PADDING[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* F, G, H and I are basic MD5 functions. */ #define F(x, y, z) (((x) & (y)) | ((~x) & (z))) #define G(x, y, z) (((x) & (z)) | ((y) & (~z))) #define H(x, y, z) ((x) ^ (y) ^ (z)) #define I(x, y, z) ((y) ^ ((x) | (~z))) /* ROTATE_LEFT rotates x left n bits. */ #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. Rotation is separate from addition to prevent recomputation. */ #define FF(a, b, c, d, x, s, ac) { \ (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define GG(a, b, c, d, x, s, ac) { \ (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define HH(a, b, c, d, x, s, ac) { \ (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define II(a, b, c, d, x, s, ac) { \ (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } /* Just a simple method for getting the signature result must be == 16 */ void md5_signature(const unsigned char *key, unsigned int length, unsigned char *result) { MD5_CTX my_md5; MD5Init(&my_md5); (void)MD5Update(&my_md5, key, length); MD5Final(result, &my_md5); } /* MD5 initialization. Begins an MD5 operation, writing a new context. */ static void MD5Init (MD5_CTX *context) /* context */ { context->count[0] = context->count[1] = 0; /* Load magic initialization constants. */ context->state[0] = 0x67452301; context->state[1] = 0xefcdab89; context->state[2] = 0x98badcfe; context->state[3] = 0x10325476; } /* MD5 block update operation. Continues an MD5 message-digest operation, processing another message block, and updating the context. */ static void MD5Update ( MD5_CTX *context, /* context */ const unsigned char *input, /* input block */ unsigned int inputLen) /* length of input block */ { unsigned int i, idx, partLen; /* Compute number of bytes mod 64 */ idx = (unsigned int)((context->count[0] >> 3) & 0x3F); /* Update number of bits */ if ((context->count[0] += ((UINT4)inputLen << 3)) < ((UINT4)inputLen << 3)) context->count[1]++; context->count[1] += ((UINT4)inputLen >> 29); partLen = 64 - idx; /* Transform as many times as possible. */ if (inputLen >= partLen) { memcpy((POINTER)&context->buffer[idx], (CONST_POINTER)input, partLen); MD5Transform(context->state, context->buffer); for (i = partLen; i + 63 < inputLen; i += 64) MD5Transform (context->state, (CONST_POINTER)&input[i]); idx = 0; } else i = 0; /* Buffer remaining input */ memcpy((POINTER)&context->buffer[idx], (CONST_POINTER)&input[i], inputLen-i); } /* MD5 finalization. Ends an MD5 message-digest operation, writing the the message digest and zeroizing the context. */ static void MD5Final ( unsigned char digest[16], /* message digest */ MD5_CTX *context) /* context */ { unsigned char bits[8]; unsigned int idx, padLen; /* Save number of bits */ Encode (bits, context->count, 8); /* Pad out to 56 mod 64. */ idx = (unsigned int)((context->count[0] >> 3) & 0x3f); padLen = (idx < 56) ? (56 - idx) : (120 - idx); MD5Update (context, PADDING, padLen); /* Append length (before padding) */ MD5Update (context, bits, 8); /* Store state in digest */ Encode (digest, context->state, 16); /* Zeroize sensitive information. */ memset((POINTER)context, 0, sizeof (*context)); } /* MD5 basic transformation. Transforms state based on block. */ static void MD5Transform ( UINT4 state[4], const unsigned char block[64]) { UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; Decode (x, block, 64); /* Round 1 */ FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ /* Round 2 */ GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ /* Round 3 */ HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ /* Round 4 */ II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ state[0] += a; state[1] += b; state[2] += c; state[3] += d; /* Zeroize sensitive information. */ memset((POINTER)x, 0, sizeof (x)); } /* Encodes input (UINT4) into output (unsigned char). Assumes len is a multiple of 4. */ static void Encode ( unsigned char *output, UINT4 *input, unsigned int len) { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) { output[j] = (unsigned char)(input[i] & 0xff); output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); } } /* Decodes input (unsigned char) into output (UINT4). Assumes len is a multiple of 4. */ static void Decode ( UINT4 *output, const unsigned char *input, unsigned int len) { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); } uint32_t hashkit_md5(const char *key, size_t key_length, void *context) { unsigned char results[16]; (void)context; md5_signature((unsigned char*)key, (unsigned int)key_length, results); return ((uint32_t) (results[3] & 0xFF) << 24) | ((uint32_t) (results[2] & 0xFF) << 16) | ((uint32_t) (results[1] & 0xFF) << 8) | (results[0] & 0xFF); } libmemcached-1.0.8/libhashkit/is.h0000664000076400007640000000344011753573717017326 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * HashKit library * * Copyright (C) 2011 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. * */ #pragma once #define hashkit_is_allocated(__object) ((__object)->options.is_allocated) #define hashkit_is_initialized(__object) ((__object)->options.is_initialized) libmemcached-1.0.8/libhashkit/aes.cc0000664000076400007640000001262511753573717017626 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libhashkit 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 #include #include #define AES_KEY_LENGTH 256 /* 128, 192, 256 */ #define AES_BLOCK_SIZE 16 enum encrypt_t { AES_ENCRYPT, AES_DECRYPT }; struct _key_t { int nr; uint32_t rk[4*(AES_MAXNR +1)]; }; struct aes_key_t { _key_t encode_key; _key_t decode_key; }; aes_key_t* aes_create_key(const char *key, const size_t key_length) { aes_key_t* _aes_key= (aes_key_t*)calloc(1, sizeof(aes_key_t)); if (_aes_key) { uint8_t rkey[AES_KEY_LENGTH/8]; uint8_t *rkey_end= rkey +AES_KEY_LENGTH/8; const char *key_end= key +key_length; memset(rkey, 0, sizeof(rkey)); /* Set initial key */ uint8_t *ptr= rkey; const char* sptr= key; for (; sptr < key_end; ptr++,sptr++) { if (ptr == rkey_end) { ptr= rkey; /* Just loop over tmp_key until we used all key */ } *ptr^= (uint8_t) *sptr; } _aes_key->decode_key.nr= rijndaelKeySetupDec(_aes_key->decode_key.rk, rkey, AES_KEY_LENGTH); _aes_key->encode_key.nr= rijndaelKeySetupEnc(_aes_key->encode_key.rk, rkey, AES_KEY_LENGTH); } return _aes_key; } aes_key_t* aes_clone_key(aes_key_t *_aes_key) { if (_aes_key == NULL) { return NULL; } aes_key_t* _aes_clone_key= (aes_key_t*)calloc(1, sizeof(aes_key_t)); if (_aes_clone_key) { memcpy(_aes_clone_key, _aes_key, sizeof(aes_key_t)); } return _aes_clone_key; } hashkit_string_st* aes_encrypt(aes_key_t *_aes_key, const char* source, size_t source_length) { if (_aes_key == NULL) { return NULL; } size_t num_blocks= source_length/AES_BLOCK_SIZE; hashkit_string_st* destination= hashkit_string_create(source_length); if (destination) { char *dest= hashkit_string_c_str_mutable(destination); for (size_t x= num_blocks; x > 0; x--) /* Encode complete blocks */ { rijndaelEncrypt(_aes_key->encode_key.rk, _aes_key->encode_key.nr, (const uint8_t*) source, (uint8_t*) dest); source+= AES_BLOCK_SIZE; dest+= AES_BLOCK_SIZE; } uint8_t block[AES_BLOCK_SIZE]; char pad_len= AES_BLOCK_SIZE - (source_length - AES_BLOCK_SIZE*num_blocks); memcpy(block, source, 16 -pad_len); memset(block + AES_BLOCK_SIZE -pad_len, pad_len, pad_len); rijndaelEncrypt(_aes_key->encode_key.rk, _aes_key->encode_key.nr, block, (uint8_t*) dest); hashkit_string_set_length(destination, AES_BLOCK_SIZE*(num_blocks + 1)); } return destination; } hashkit_string_st* aes_decrypt(aes_key_t *_aes_key, const char* source, size_t source_length) { if (_aes_key == NULL) { return NULL; } size_t num_blocks= source_length/AES_BLOCK_SIZE; if ((source_length != num_blocks*AES_BLOCK_SIZE) or num_blocks ==0 ) { return NULL; } hashkit_string_st* destination= hashkit_string_create(source_length); if (destination) { char *dest= hashkit_string_c_str_mutable(destination); for (size_t x = num_blocks-1; x > 0; x--) { rijndaelDecrypt(_aes_key->decode_key.rk, _aes_key->decode_key.nr, (const uint8_t*) source, (uint8_t*) dest); source+= AES_BLOCK_SIZE; dest+= AES_BLOCK_SIZE; } uint8_t block[AES_BLOCK_SIZE]; rijndaelDecrypt(_aes_key->decode_key.rk, _aes_key->decode_key.nr, (const uint8_t*) source, block); /* Use last char in the block as size */ unsigned int pad_len= (unsigned int) (unsigned char) block[AES_BLOCK_SIZE-1]; if (pad_len > AES_BLOCK_SIZE) { hashkit_string_free(destination); return NULL; } /* We could also check whole padding but we do not really need this */ memcpy(dest, block, AES_BLOCK_SIZE - pad_len); hashkit_string_set_length(destination, AES_BLOCK_SIZE*num_blocks - pad_len); } return destination; } libmemcached-1.0.8/libhashkit/fnv_64.cc0000664000076400007640000000514411753573717020156 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * HashKit library * * Copyright (C) 2011 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. * */ #include #if __WORDSIZE == 64 && defined(HAVE_FNV64_HASH) /* FNV hash'es lifted from Dustin Sallings work */ static uint64_t FNV_64_INIT= 0xcbf29ce484222325; static uint64_t FNV_64_PRIME= 0x100000001b3; uint32_t hashkit_fnv1_64(const char *key, size_t key_length, void *) { /* Thanks to pierre@demartines.com for the pointer */ uint64_t hash= FNV_64_INIT; for (size_t x= 0; x < key_length; x++) { hash *= FNV_64_PRIME; hash ^= (uint64_t)key[x]; } return (uint32_t)hash; } uint32_t hashkit_fnv1a_64(const char *key, size_t key_length, void *) { uint32_t hash= (uint32_t) FNV_64_INIT; for (size_t x= 0; x < key_length; x++) { uint32_t val= (uint32_t)key[x]; hash ^= val; hash *= (uint32_t) FNV_64_PRIME; } return hash; } #else uint32_t hashkit_fnv1_64(const char *, size_t, void *) { return 0; } uint32_t hashkit_fnv1a_64(const char *, size_t, void *) { return 0; } #endif libmemcached-1.0.8/libhashkit/ketama.cc0000664000076400007640000001104211753573717020310 0ustar00brianbrian00000000000000/* HashKit * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ #include #include #if 0 static uint32_t ketama_server_hash(const char *key, unsigned int key_length, int alignment) { unsigned char results[16]; md5_signature((unsigned char*)key, key_length, results); return ((uint32_t) (results[3 + alignment * 4] & 0xFF) << 24) | ((uint32_t) (results[2 + alignment * 4] & 0xFF) << 16) | ((uint32_t) (results[1 + alignment * 4] & 0xFF) << 8) | (results[0 + alignment * 4] & 0xFF); } static int continuum_points_cmp(const void *t1, const void *t2) { hashkit_continuum_point_st *ct1= (hashkit_continuum_point_st *)t1; hashkit_continuum_point_st *ct2= (hashkit_continuum_point_st *)t2; if (ct1->value == ct2->value) return 0; else if (ct1->value > ct2->value) return 1; else return -1; } int update_continuum(hashkit_st *hashkit) { uint32_t count; uint32_t continuum_index= 0; uint32_t value; uint32_t points_index; uint32_t points_count= 0; uint32_t points_per_server; uint32_t points_per_hash; uint64_t total_weight= 0; uint32_t live_servers; uint8_t *context; if (hashkit->active_fn != NULL || hashkit->weight_fn != NULL) { live_servers= 0; for (count= 0, context= hashkit->list; count < hashkit->list_size; count++, context+= hashkit->context_size) { if (hashkit->active_fn != NULL) { if (hashkit->active_fn(context)) live_servers++; else continue; } if (hashkit->weight_fn != NULL) total_weight+= hashkit->weight_fn(context); } } if (hashkit->active_fn == NULL) live_servers= (uint32_t)hashkit->list_size; if (live_servers == 0) return 0; if (hashkit->weight_fn == NULL) { points_per_server= HASHKIT_POINTS_PER_NODE; points_per_hash= 1; } else { points_per_server= HASHKIT_POINTS_PER_NODE_WEIGHTED; points_per_hash= 4; } if (live_servers > hashkit->continuum_count) { hashkit_continuum_point_st *new_continuum; new_continuum= realloc(hashkit->continuum, sizeof(hashkit_continuum_point_st) * (live_servers + HASHKIT_CONTINUUM_ADDITION) * points_per_server); if (new_continuum == NULL) return ENOMEM; hashkit->continuum= new_continuum; hashkit->continuum_count= live_servers + HASHKIT_CONTINUUM_ADDITION; } for (count= 0, context= hashkit->list; count < hashkit->list_size; count++, context+= hashkit->context_size) { if (hashkit->active_fn != NULL && hashkit->active_fn(context) == false) continue; if (hashkit->weight_fn != NULL) { float pct = (float)hashkit->weight_fn(context) / (float)total_weight; points_per_server= (uint32_t) ((floorf((float) (pct * HASHKIT_POINTS_PER_NODE_WEIGHTED / 4 * (float)live_servers + 0.0000000001))) * 4); } for (points_index= 0; points_index < points_per_server / points_per_hash; points_index++) { char sort_host[HASHKIT_CONTINUUM_KEY_SIZE]= ""; size_t sort_host_length; if (hashkit->continuum_key_fn == NULL) { sort_host_length= (size_t) snprintf(sort_host, HASHKIT_CONTINUUM_KEY_SIZE, "%u", points_index); } else { sort_host_length= hashkit->continuum_key_fn(sort_host, HASHKIT_CONTINUUM_KEY_SIZE, points_index, context); } if (hashkit->weight_fn == NULL) { if (hashkit->continuum_hash_fn == NULL) value= hashkit_default(sort_host, sort_host_length); else value= hashkit->continuum_hash_fn(sort_host, sort_host_length); hashkit->continuum[continuum_index].index= count; hashkit->continuum[continuum_index++].value= value; } else { unsigned int i; for (i = 0; i < points_per_hash; i++) { value= ketama_server_hash(sort_host, (uint32_t) sort_host_length, (int) i); hashkit->continuum[continuum_index].index= count; hashkit->continuum[continuum_index++].value= value; } } } points_count+= points_per_server; } hashkit->continuum_points_count= points_count; qsort(hashkit->continuum, hashkit->continuum_points_count, sizeof(hashkit_continuum_point_st), continuum_points_cmp); return 0; } #endif libmemcached-1.0.8/libhashkit/nohsieh.cc0000664000076400007640000000342711753573717020513 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * HashKit library * * Copyright (C) 2011 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 #ifdef HAVE_HSIEH_HASH #error "not supported" #else uint32_t hashkit_hsieh(const char *, size_t , void *) { return 0; } #endif libmemcached-1.0.8/libhashkit/crc32.cc0000664000076400007640000000731311753573717017770 0ustar00brianbrian00000000000000/* The crc32 functions and data was originally written by Spencer * Garrett and was gleaned from the PostgreSQL source * tree via the files contrib/ltree/crc32.[ch] and from FreeBSD at * src/usr.bin/cksum/crc32.c. */ #include static const uint32_t crc32tab[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, }; uint32_t hashkit_crc32(const char *key, size_t key_length, void *context) { uint64_t x; uint32_t crc= UINT32_MAX; (void)context; for (x= 0; x < key_length; x++) crc= (crc >> 8) ^ crc32tab[(crc ^ (uint64_t)key[x]) & 0xff]; return ((~crc) >> 16) & 0x7fff; } libmemcached-1.0.8/libhashkit/hashkit.cc0000664000076400007640000000442711753573717020512 0ustar00brianbrian00000000000000/* HashKit * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ #include static inline void _hashkit_init(hashkit_st *self) { self->base_hash.function= hashkit_one_at_a_time; self->base_hash.context= NULL; self->distribution_hash.function= hashkit_one_at_a_time; self->distribution_hash.context= NULL; self->flags.is_base_same_distributed= true; self->_key= NULL; } static inline hashkit_st *_hashkit_create(hashkit_st *self) { if (self) { self->options.is_allocated= false; } else { self= (hashkit_st*)calloc(1, sizeof(hashkit_st)); if (self == NULL) { return NULL; } self->options.is_allocated= true; } return self; } hashkit_st *hashkit_create(hashkit_st *self) { self= _hashkit_create(self); if (self == NULL) { return NULL; } _hashkit_init(self); return self; } void hashkit_free(hashkit_st *self) { if (self and self->_key) { free(self->_key); self->_key= NULL; } if (hashkit_is_allocated(self)) { free(self); } } hashkit_st *hashkit_clone(hashkit_st *destination, const hashkit_st *source) { if (source == NULL) { return hashkit_create(destination); } /* new_clone will be a pointer to destination */ destination= _hashkit_create(destination); // Should only happen on allocation failure. if (destination == NULL) { return NULL; } destination->base_hash= source->base_hash; destination->distribution_hash= source->distribution_hash; destination->flags= source->flags; destination->_key= aes_clone_key(static_cast(source->_key)); return destination; } bool hashkit_compare(const hashkit_st *first, const hashkit_st *second) { if (not first or not second) return false; if (first->base_hash.function == second->base_hash.function and first->base_hash.context == second->base_hash.context and first->distribution_hash.function == second->distribution_hash.function and first->distribution_hash.context == second->distribution_hash.context and first->flags.is_base_same_distributed == second->flags.is_base_same_distributed) { return true; } return false; } libmemcached-1.0.8/libhashkit/murmur.cc0000664000076400007640000000321011753573717020373 0ustar00brianbrian00000000000000/* "Murmur" hash provided by Austin, tanjent@gmail.com http://murmurhash.googlepages.com/ Note - This code makes a few assumptions about how your machine behaves - 1. We can read a 4-byte value from any address without crashing 2. sizeof(int) == 4 And it has a few limitations - 1. It will not work incrementally. 2. It will not produce the same results on little-endian and big-endian machines. Updated to murmur2 hash - BP */ #include #ifdef HAVE_MURMUR_HASH uint32_t hashkit_murmur(const char *key, size_t length, void *context) { /* 'm' and 'r' are mixing constants generated offline. They're not really 'magic', they just happen to work well. */ const unsigned int m= 0x5bd1e995; const uint32_t seed= (0xdeadbeef * (uint32_t)length); const int r= 24; // Initialize the hash to a 'random' value uint32_t h= seed ^ (uint32_t)length; // Mix 4 bytes at a time into the hash const unsigned char * data= (const unsigned char *)key; (void)context; while(length >= 4) { unsigned int k = *(unsigned int *)data; k *= m; k ^= k >> r; k *= m; h *= m; h ^= k; data += 4; length -= 4; } // Handle the last few bytes of the input array switch(length) { case 3: h ^= ((uint32_t)data[2]) << 16; case 2: h ^= ((uint32_t)data[1]) << 8; case 1: h ^= data[0]; h *= m; default: break; }; /* Do a few final mixes of the hash to ensure the last few bytes are well-incorporated. */ h ^= h >> 13; h *= m; h ^= h >> 15; return h; } #else uint32_t hashkit_murmur(const char *, size_t , void *) { return 0; } #endif libmemcached-1.0.8/libhashkit/has.cc0000664000076400007640000000455211753573717017631 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 bool libhashkit_has_algorithm(const hashkit_hash_algorithm_t algo) { switch (algo) { case HASHKIT_HASH_FNV1_64: case HASHKIT_HASH_FNV1A_64: #if __WORDSIZE == 64 && defined(HAVE_FNV64_HASH) return true; #else return false; #endif case HASHKIT_HASH_HSIEH: #ifdef HAVE_HSIEH_HASH return true; #else return false; #endif case HASHKIT_HASH_MURMUR: #ifdef HAVE_MURMUR_HASH return true; #else return false; #endif case HASHKIT_HASH_FNV1_32: case HASHKIT_HASH_FNV1A_32: case HASHKIT_HASH_DEFAULT: case HASHKIT_HASH_MD5: case HASHKIT_HASH_CRC: case HASHKIT_HASH_JENKINS: case HASHKIT_HASH_CUSTOM: return true; case HASHKIT_HASH_MAX: break; } return false; } libmemcached-1.0.8/libhashkit/str_algorithm.cc0000664000076400007640000000442411753573717021732 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * HashKit * * Copyright (C) 2011 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 const char * libhashkit_string_hash(hashkit_hash_algorithm_t type) { switch(type) { case HASHKIT_HASH_DEFAULT: return "DEFAULT"; case HASHKIT_HASH_MD5: return "MD5"; case HASHKIT_HASH_CRC: return "CRC"; case HASHKIT_HASH_FNV1_64: return "FNV1_64"; case HASHKIT_HASH_FNV1A_64: return "FNV1A_64"; case HASHKIT_HASH_FNV1_32: return "FNV1_32"; case HASHKIT_HASH_FNV1A_32: return "FNV1A_32"; case HASHKIT_HASH_HSIEH: return "HSIEH"; case HASHKIT_HASH_MURMUR: return "MURMUR"; case HASHKIT_HASH_JENKINS: return "JENKINS"; case HASHKIT_HASH_CUSTOM: return "CUSTOM"; default: case HASHKIT_HASH_MAX: return "INVALID"; } } libmemcached-1.0.8/libhashkit/aes.h0000664000076400007640000000402011753573717017456 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once struct aes_key_t; hashkit_string_st* aes_encrypt(aes_key_t* _aes_key, const char* source, size_t source_length); hashkit_string_st* aes_decrypt(aes_key_t* _aes_key, const char* source, size_t source_length); aes_key_t* aes_create_key(const char *key, const size_t key_length); aes_key_t* aes_clone_key(aes_key_t* _aes_key); libmemcached-1.0.8/libhashkit/fnv_32.cc0000664000076400007640000000457011753573717020153 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * HashKit library * * Copyright (C) 2011 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. * */ #include /* FNV hash'es lifted from Dustin Sallings work */ static uint32_t FNV_32_INIT= 2166136261UL; static uint32_t FNV_32_PRIME= 16777619; uint32_t hashkit_fnv1_32(const char *key, size_t key_length, void *context) { uint32_t hash= FNV_32_INIT; (void)context; for (size_t x= 0; x < key_length; x++) { uint32_t val= (uint32_t)key[x]; hash *= FNV_32_PRIME; hash ^= val; } return hash; } uint32_t hashkit_fnv1a_32(const char *key, size_t key_length, void *context) { uint32_t hash= FNV_32_INIT; (void)context; for (size_t x= 0; x < key_length; x++) { uint32_t val= (uint32_t)key[x]; hash ^= val; hash *= FNV_32_PRIME; } return hash; } libmemcached-1.0.8/libhashkit/string.cc0000664000076400007640000001305711753573717020364 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libhashkit library * * Copyright (C) 2011-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 #include #include #define HASHKIT_BLOCK_SIZE 1024 struct hashkit_string_st { char *end; size_t current_size; char *string; }; inline static bool _string_check(hashkit_string_st *string, size_t need) { if (need and need > (size_t)(string->current_size - (size_t)(string->end - string->string))) { size_t current_offset= (size_t) (string->end - string->string); /* This is the block multiplier. To keep it larger and surive division errors we must round it up */ size_t adjust= (need - (size_t)(string->current_size - (size_t)(string->end - string->string))) / HASHKIT_BLOCK_SIZE; adjust++; size_t new_size= sizeof(char) * (size_t)((adjust * HASHKIT_BLOCK_SIZE) + string->current_size); /* Test for overflow */ if (new_size < need) { return false; } char *new_value= (char*)realloc(string->string, new_size); if (new_value == NULL) { return false; } string->string= new_value; string->end= string->string + current_offset; string->current_size+= (HASHKIT_BLOCK_SIZE * adjust); } return true; } static inline void _init_string(hashkit_string_st *self) { self->current_size= 0; self->end= self->string= NULL; } hashkit_string_st *hashkit_string_create(size_t initial_size) { hashkit_string_st* self= (hashkit_string_st*)calloc(1, sizeof(hashkit_string_st)); if (self) { if (_string_check(self, initial_size) == false) { free(self); return NULL; } } return self; } #if 0 static bool hashkit_string_append_null(hashkit_string_st *string) { if (_string_check(string, 1) == false) { return false; } *string->end= 0; return true; } #endif bool hashkit_string_append_character(hashkit_string_st *string, char character) { if (_string_check(string, 1) == false) { return false; } *string->end= character; string->end++; return true; } bool hashkit_string_append(hashkit_string_st *string, const char *value, size_t length) { if (_string_check(string, length) == false) { return false; } assert(length <= string->current_size); assert(string->string); assert(string->end >= string->string); memcpy(string->end, value, length); string->end+= length; return true; } char *hashkit_string_c_copy(hashkit_string_st *string) { if (hashkit_string_length(string) == 0) { return NULL; } char *c_ptr= static_cast(malloc((hashkit_string_length(string)+1) * sizeof(char))); if (c_ptr == NULL) { return NULL; } memcpy(c_ptr, hashkit_string_c_str(string), hashkit_string_length(string)); c_ptr[hashkit_string_length(string)]= 0; return c_ptr; } void hashkit_string_reset(hashkit_string_st *string) { string->end= string->string; } void hashkit_string_free(hashkit_string_st *ptr) { if (ptr == NULL) { return; } if (ptr->string) { free(ptr->string); } free(ptr); } bool hashkit_string_resize(hashkit_string_st& string, const size_t need) { return _string_check(&string, need); } size_t hashkit_string_length(const hashkit_string_st *self) { return size_t(self->end -self->string); } size_t hashkit_string_max_size(const hashkit_string_st *self) { return self->current_size; } char *hashkit_string_take(hashkit_string_st *self) { assert(self); if (self == NULL) { return NULL; } char *value= self->string; _init_string(self); return value; } char *hashkit_string_c_str_mutable(hashkit_string_st *self) { assert(self); if (self == NULL) { return NULL; } return self->string; } const char *hashkit_string_c_str(const hashkit_string_st* self) { assert(self); if (self == NULL) { return NULL; } return self->string; } void hashkit_string_set_length(hashkit_string_st *self, size_t length) { assert(self); if (self and _string_check(self, length)) { self->end= self->string +length; } } libmemcached-1.0.8/libhashkit/string.h0000664000076400007640000000445711753573717020232 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libhashkit library * * Copyright (C) 2011-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. * */ #pragma once hashkit_string_st *hashkit_string_create(size_t initial_size); bool hashkit_string_append_character(hashkit_string_st *string, char character); bool hashkit_string_append(hashkit_string_st *string, const char *value, size_t length); char *hashkit_string_c_copy(hashkit_string_st *string); void hashkit_string_reset(hashkit_string_st *string); bool hashkit_string_resize(hashkit_string_st& string, const size_t need); size_t hashkit_string_max_size(const hashkit_string_st *self); char *hashkit_string_take(hashkit_string_st *self); char *hashkit_string_c_str_mutable(hashkit_string_st *self); void hashkit_string_set_length(hashkit_string_st *self, size_t length); libmemcached-1.0.8/libhashkit/hsieh.cc0000664000076400007640000000330511753573717020151 0ustar00brianbrian00000000000000/* By Paul Hsieh (C) 2004, 2005. Covered under the Paul Hsieh * derivative license. * See: http://www.azillionmonkeys.com/qed/weblicense.html for license * details. * http://www.azillionmonkeys.com/qed/hash.html */ #include #undef get16bits #if (defined(__GNUC__) && defined(__i386__)) #define get16bits(d) (*((const uint16_t *) (d))) #endif #if !defined (get16bits) #define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\ +(uint32_t)(((const uint8_t *)(d))[0]) ) #endif #ifdef HAVE_HSIEH_HASH uint32_t hashkit_hsieh(const char *key, size_t key_length, void *) { uint32_t hash = 0, tmp; int rem; if (key_length <= 0 || key == NULL) return 0; rem = key_length & 3; key_length >>= 2; /* Main loop */ for (;key_length > 0; key_length--) { hash += get16bits (key); tmp = (get16bits (key+2) << 11) ^ hash; hash = (hash << 16) ^ tmp; key += 2*sizeof (uint16_t); hash += hash >> 11; } /* Handle end cases */ switch (rem) { case 3: hash += get16bits (key); hash ^= hash << 16; hash ^= (uint32_t)key[sizeof (uint16_t)] << 18; hash += hash >> 11; break; case 2: hash += get16bits (key); hash ^= hash << 11; hash += hash >> 17; break; case 1: hash += (unsigned char)(*key); hash ^= hash << 10; hash += hash >> 1; default: break; } /* Force "avalanching" of final 127 bits */ hash ^= hash << 3; hash += hash >> 5; hash ^= hash << 4; hash += hash >> 17; hash ^= hash << 25; hash += hash >> 6; return hash; } #else uint32_t hashkit_hsieh(const char *, size_t , void *) { return 0; } #endif libmemcached-1.0.8/libhashkit/strerror.cc0000664000076400007640000000130511753573717020731 0ustar00brianbrian00000000000000/* HashKit * Copyright (C) 2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ #include const char *hashkit_strerror(hashkit_st *ptr, hashkit_return_t rc) { (void)ptr; switch (rc) { case HASHKIT_SUCCESS: return "SUCCESS"; case HASHKIT_FAILURE: return "FAILURE"; case HASHKIT_MEMORY_ALLOCATION_FAILURE: return "MEMORY ALLOCATION FAILURE"; case HASHKIT_INVALID_ARGUMENT: return "INVALID ARGUMENT"; case HASHKIT_INVALID_HASH: return "INVALID hashkit_hash_algorithm_t"; case HASHKIT_MAXIMUM_RETURN: default: return "INVALID hashkit_return_t"; } } libmemcached-1.0.8/libhashkit/function.cc0000664000076400007640000001045411753573717020701 0ustar00brianbrian00000000000000/* HashKit * Copyright (C) 2010 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ #include static hashkit_return_t _set_function(struct hashkit_st::hashkit_function_st *self, hashkit_hash_algorithm_t hash_algorithm) { if (self == NULL) { return HASHKIT_INVALID_ARGUMENT; } switch (hash_algorithm) { case HASHKIT_HASH_MD5: self->function= hashkit_md5; break; case HASHKIT_HASH_CRC: self->function= hashkit_crc32; break; case HASHKIT_HASH_FNV1_64: if (libhashkit_has_algorithm(HASHKIT_HASH_FNV1_64)) { self->function= hashkit_fnv1_64; break; } return HASHKIT_INVALID_ARGUMENT; case HASHKIT_HASH_FNV1A_64: if (libhashkit_has_algorithm(HASHKIT_HASH_FNV1_64)) { self->function= hashkit_fnv1a_64; break; } return HASHKIT_INVALID_ARGUMENT; case HASHKIT_HASH_FNV1_32: self->function= hashkit_fnv1_32; break; case HASHKIT_HASH_FNV1A_32: self->function= hashkit_fnv1a_32; break; case HASHKIT_HASH_HSIEH: if (libhashkit_has_algorithm(HASHKIT_HASH_HSIEH)) { self->function= hashkit_hsieh; break; } return HASHKIT_INVALID_ARGUMENT; case HASHKIT_HASH_MURMUR: if (libhashkit_has_algorithm(HASHKIT_HASH_MURMUR)) { self->function= hashkit_murmur; break; } return HASHKIT_INVALID_ARGUMENT; case HASHKIT_HASH_JENKINS: self->function= hashkit_jenkins; break; case HASHKIT_HASH_CUSTOM: return HASHKIT_INVALID_ARGUMENT; case HASHKIT_HASH_DEFAULT: self->function= hashkit_one_at_a_time; break; case HASHKIT_HASH_MAX: self->function= hashkit_one_at_a_time; return HASHKIT_INVALID_HASH; } self->context= NULL; return HASHKIT_SUCCESS; } hashkit_return_t hashkit_set_function(hashkit_st *self, hashkit_hash_algorithm_t hash_algorithm) { return _set_function(&self->base_hash, hash_algorithm); } hashkit_return_t hashkit_set_distribution_function(hashkit_st *self, hashkit_hash_algorithm_t hash_algorithm) { return _set_function(&self->distribution_hash, hash_algorithm); } static hashkit_return_t _set_custom_function(struct hashkit_st::hashkit_function_st *self, hashkit_hash_fn function, void *context) { if (self == NULL) { return HASHKIT_INVALID_ARGUMENT; } if (function) { self->function= function; self->context= context; return HASHKIT_SUCCESS; } return HASHKIT_FAILURE; } hashkit_return_t hashkit_set_custom_function(hashkit_st *self, hashkit_hash_fn function, void *context) { if (self == NULL) { return HASHKIT_INVALID_ARGUMENT; } return _set_custom_function(&self->base_hash, function, context); } hashkit_return_t hashkit_set_custom_distribution_function(hashkit_st *self, hashkit_hash_fn function, void *context) { if (self == NULL) { return HASHKIT_INVALID_ARGUMENT; } return _set_custom_function(&self->distribution_hash, function, context); } static hashkit_hash_algorithm_t get_function_type(const hashkit_hash_fn function) { if (function == hashkit_one_at_a_time) { return HASHKIT_HASH_DEFAULT; } else if (function == hashkit_md5) { return HASHKIT_HASH_MD5; } else if (function == hashkit_crc32) { return HASHKIT_HASH_CRC; } else if (function == hashkit_fnv1_64) { return HASHKIT_HASH_FNV1_64; } else if (function == hashkit_fnv1a_64) { return HASHKIT_HASH_FNV1A_64; } else if (function == hashkit_fnv1_32) { return HASHKIT_HASH_FNV1_32; } else if (function == hashkit_fnv1a_32) { return HASHKIT_HASH_FNV1A_32; } else if (function == hashkit_hsieh) { return HASHKIT_HASH_HSIEH; } else if (function == hashkit_murmur) { return HASHKIT_HASH_MURMUR; } else if (function == hashkit_jenkins) { return HASHKIT_HASH_JENKINS; } return HASHKIT_HASH_CUSTOM; } hashkit_hash_algorithm_t hashkit_get_function(const hashkit_st *self) { if (self == NULL) { return HASHKIT_HASH_DEFAULT; } return get_function_type(self->base_hash.function); } hashkit_hash_algorithm_t hashkit_get_distribution_function(const hashkit_st *self) { if (self == NULL) { return HASHKIT_HASH_DEFAULT; } return get_function_type(self->distribution_hash.function); } libmemcached-1.0.8/libhashkit/behavior.cc0000664000076400007640000000034311753573717020647 0ustar00brianbrian00000000000000/* HashKit * Copyright (C) 2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. */ #include libmemcached-1.0.8/util/0000775000076400007640000000000011757025120015354 5ustar00brianbrian00000000000000libmemcached-1.0.8/util/log.hpp0000664000076400007640000001240311753573717016666 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Data Differential Utility 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. * */ #pragma once #include #include #include #include #include #include #include #define UTIL_MAX_ERROR_SIZE 2048 namespace datadifferential { namespace util { /** Verbosity levels. */ enum verbose_t { // Logging this will cause shutdown VERBOSE_FATAL= LOG_EMERG, // syslog:LOG_EMERG VERBOSE_ALERT= LOG_ALERT, // syslog:LOG_ALERT VERBOSE_CRITICAL= LOG_CRIT, // syslog:LOG_CRIT VERBOSE_ERROR= LOG_ERR, // syslog:LOG_ERR VERBOSE_WARN= LOG_WARNING, // syslog:LOG_WARNING VERBOSE_NOTICE= LOG_NOTICE, // syslog:LOG_NOTICE VERBOSE_INFO= LOG_INFO, // syslog:LOG_INFO VERBOSE_DEBUG= LOG_DEBUG // syslog:LOG_DEBUG }; struct log_info_st { std::string name; std::string filename; int fd; bool opt_syslog; bool opt_file; bool init_success; log_info_st(const std::string& name_arg, const std::string &filename_arg, bool syslog_arg) : name(name_arg), filename(filename_arg), fd(-1), opt_syslog(syslog_arg), opt_file(false), init_success(false) { if (opt_syslog) { openlog(name.c_str(), LOG_PID | LOG_NDELAY, LOG_USER); } init(); } void init() { if (filename.size()) { if (filename.compare("stderr") == 0) { fd= STDERR_FILENO; } else { fd= open(filename.c_str(), O_CREAT | O_WRONLY | O_APPEND, 0644); if (fd == -1) { if (opt_syslog) { char buffer[1024]; char *getcwd_ret= getcwd(buffer, sizeof(buffer)); syslog(LOG_ERR, "Could not open log file \"%.*s\", from \"%s\", open failed with (%s)", int(filename.size()), filename.c_str(), getcwd_ret, strerror(errno)); } std::cerr << "Could not open log file for writing, switching to stderr." << std::endl; fd= STDERR_FILENO; } } opt_file= true; } init_success= true; } bool initialized() const { return init_success; } int file() const { return fd; } void write(verbose_t verbose, const char *format, ...) { if (opt_file or opt_syslog) { va_list args; va_start(args, format); char mesg[BUFSIZ]; int mesg_length= vsnprintf(mesg, sizeof(mesg), format, args); va_end(args); if (opt_file) { char buffer[UTIL_MAX_ERROR_SIZE]; int buffer_length= snprintf(buffer, sizeof(buffer), "%7s %.*s\n", verbose_name(verbose), mesg_length, mesg); if (::write(file(), buffer, buffer_length) == -1) { std::cerr << "Could not write to log file." << std::endl; syslog(LOG_EMERG, "gearmand could not open log file %s, got error %s", filename.c_str(), strerror(errno)); } } if (opt_syslog) { syslog(int(verbose), "%7s %.*s", verbose_name(verbose), mesg_length, mesg); } } } ~log_info_st() { if (fd != -1 and fd != STDERR_FILENO) { close(fd); } if (opt_syslog) { closelog(); } } private: const char *verbose_name(verbose_t verbose) { switch (verbose) { case VERBOSE_FATAL: return "FATAL"; case VERBOSE_ALERT: return "ALERT"; case VERBOSE_CRITICAL: return "CRITICAL"; case VERBOSE_ERROR: return "ERROR"; case VERBOSE_WARN: return "WARNING"; case VERBOSE_NOTICE: return "NOTICE"; case VERBOSE_INFO: return "INFO"; case VERBOSE_DEBUG: return "DEBUG"; default: break; } return "UNKNOWN"; } }; } // namespace util } // namespace datadifferential libmemcached-1.0.8/util/include.am0000664000076400007640000000100311753573717017330 0ustar00brianbrian00000000000000# vim:ft=automake # DataDifferential Utility Library # Copyright (C) 2011 Data Differential # All rights reserved. # # Use and distribution licensed under the BSD license. See # the COPYING file in the parent directory for full text. # # Included from Top Level Makefile.am # All paths should be given relative to the root noinst_HEADERS+= \ util/daemon.hpp \ util/instance.hpp \ util/logfile.hpp \ util/log.hpp \ util/operation.hpp \ util/signal.hpp \ util/string.hpp \ util/pidfile.hpp libmemcached-1.0.8/util/operation.hpp0000664000076400007640000000542611753573717020114 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * DataDifferential Utility Library * * Copyright (C) 2011 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. * */ #pragma once #include #include #include namespace datadifferential { namespace util { class Operation { typedef std::vector Packet; public: typedef std::vector vector; Operation(const char *command, size_t command_length, bool expect_response= true) : _expect_response(expect_response), packet(), _response() { packet.resize(command_length); memcpy(&packet[0], command, command_length); } ~Operation() { } size_t size() const { return packet.size(); } const char* ptr() const { return &(packet)[0]; } bool has_response() const { return _expect_response; } void push(const char *buffer, size_t buffer_size) { size_t response_size= _response.size(); _response.resize(response_size +buffer_size); memcpy(&_response[0] +response_size, buffer, buffer_size); } // Return false on error bool response(std::string &); bool reconnect() const { return false; } private: bool _expect_response; Packet packet; Packet _response; }; } /* namespace util */ } /* namespace datadifferential */ libmemcached-1.0.8/util/instance.hpp0000664000076400007640000000565411753573717017723 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * DataDifferential Utility Library * * Copyright (C) 2011 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. * */ #pragma once #include #include #include #include #include #include #include #include "util/operation.hpp" struct addrinfo; namespace datadifferential { namespace util { class Instance { private: enum connection_state_t { NOT_WRITING, NEXT_CONNECT_ADDRINFO, CONNECT, CONNECTING, CONNECTED, WRITING, READING, FINISHED }; std::string _last_error; public: // Callbacks class Finish { public: virtual ~Finish() { } virtual bool call(const bool, const std::string &)= 0; }; public: Instance(const std::string& hostname_arg, const std::string& service_arg); Instance(const std::string& hostname_arg, const in_port_t port_arg); ~Instance(); bool run(); void set_finish(Finish *arg) { _finish_fn= arg; } void push(util::Operation *next) { _operations.push_back(next); } private: void close_socket(); void free_addrinfo(); bool more_to_read() const; std::string _host; std::string _service; int _sockfd; connection_state_t state; struct addrinfo *_addrinfo; struct addrinfo *_addrinfo_next; Finish *_finish_fn; Operation::vector _operations; }; } /* namespace util */ } /* namespace datadifferential */ libmemcached-1.0.8/util/string.hpp0000664000076400007640000000421411753573717017414 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * DataDifferential Utility Library * * Copyright (C) 2011 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. * */ /* Simple defines */ #include #include #pragma once #define util_literal_param(X) (X), (static_cast((sizeof(X) - 1))) #define util_literal_param_size(X) static_cast(sizeof(X) - 1) #define util_literal_compare_param(X) (static_cast((sizeof(X) - 1))), (X) #define util_string_make_from_cstr(X) (X), ((X) ? strlen(X) : 0) #define util_string_make_from_array(__array) (__array), (strlen(__array)) #define util_array_length(__array) sizeof(__array)/sizeof(&__array) libmemcached-1.0.8/util/instance.cc0000664000076400007640000001713711753573717017520 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * DataDifferential Utility Library * * Copyright (C) 2011 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 #include "util/instance.hpp" #include #include #include #include #include #include #include #include #ifdef HAVE_UNISTD_H #include #endif namespace datadifferential { namespace util { Instance::Instance(const std::string& hostname_arg, const std::string& service_arg) : _host(hostname_arg), _service(service_arg), _sockfd(INVALID_SOCKET), state(NOT_WRITING), _addrinfo(0), _addrinfo_next(0), _finish_fn(NULL), _operations() { } Instance::Instance(const std::string& hostname_arg, const in_port_t port_arg) : _host(hostname_arg), _sockfd(INVALID_SOCKET), state(NOT_WRITING), _addrinfo(0), _addrinfo_next(0), _finish_fn(NULL), _operations() { char tmp[BUFSIZ]; snprintf(tmp, sizeof(tmp), "%u", static_cast(port_arg)); _service= tmp; } Instance::~Instance() { close_socket(); free_addrinfo(); for (Operation::vector::iterator iter= _operations.begin(); iter != _operations.end(); ++iter) { delete *iter; } _operations.clear(); delete _finish_fn; } bool Instance::run() { while (not _operations.empty()) { Operation::vector::value_type operation= _operations.back(); switch (state) { case NOT_WRITING: { free_addrinfo(); struct addrinfo ai; memset(&ai, 0, sizeof(struct addrinfo)); ai.ai_socktype= SOCK_STREAM; ai.ai_protocol= IPPROTO_TCP; int ret= getaddrinfo(_host.c_str(), _service.c_str(), &ai, &_addrinfo); if (ret) { std::stringstream message; message << "Failed to connect on " << _host.c_str() << ":" << _service.c_str() << " with " << gai_strerror(ret); _last_error= message.str(); return false; } } _addrinfo_next= _addrinfo; state= CONNECT; break; case NEXT_CONNECT_ADDRINFO: if (_addrinfo_next->ai_next == NULL) { std::stringstream message; message << "Error connecting to " << _host.c_str() << "." << std::endl; _last_error= message.str(); return false; } _addrinfo_next= _addrinfo_next->ai_next; case CONNECT: close_socket(); _sockfd= socket(_addrinfo_next->ai_family, _addrinfo_next->ai_socktype, _addrinfo_next->ai_protocol); if (_sockfd == INVALID_SOCKET) { perror("socket"); continue; } if (connect(_sockfd, _addrinfo_next->ai_addr, _addrinfo_next->ai_addrlen) < 0) { switch(errno) { case EAGAIN: case EINTR: state= CONNECT; break; case EINPROGRESS: state= CONNECTING; break; case ECONNREFUSED: case ENETUNREACH: case ETIMEDOUT: default: state= NEXT_CONNECT_ADDRINFO; break; } } else { state= CONNECTING; } break; case CONNECTING: // Add logic for poll() for nonblocking. state= CONNECTED; break; case CONNECTED: case WRITING: { size_t packet_length= operation->size(); const char *packet= operation->ptr(); while(packet_length) { ssize_t write_size= send(_sockfd, packet, packet_length, 0); if (write_size < 0) { switch(errno) { default: std::cerr << "Failed dureng send(" << strerror(errno) << ")" << std::endl; break; } } packet_length-= static_cast(write_size); packet+= static_cast(write_size); } } state= READING; break; case READING: if (operation->has_response()) { size_t total_read; ssize_t read_length; do { char buffer[BUFSIZ]; read_length= ::recv(_sockfd, buffer, sizeof(buffer), 0); if (read_length < 0) { switch(errno) { default: _last_error.clear(); _last_error+= "Error occured while reading data from "; _last_error+= _host; return false; } } else if (read_length == 0) { _last_error.clear(); _last_error+= "Socket was shutdown while reading from "; _last_error+= _host; return false; } operation->push(buffer, static_cast(read_length)); total_read+= static_cast(read_length); } while (more_to_read()); } // end has_response state= FINISHED; break; case FINISHED: std::string response; bool success= operation->response(response); if (_finish_fn) { if (not _finish_fn->call(success, response)) { // Error was sent from _finish_fn return false; } } if (operation->reconnect()) { } _operations.pop_back(); delete operation; state= CONNECTED; break; } // end switch } return true; } // end run() bool Instance::more_to_read() const { struct pollfd fds; fds.fd= _sockfd; fds.events = POLLIN; if (poll(&fds, 1, 5) < 1) // Default timeout is 5 { return false; } return true; } void Instance::close_socket() { if (_sockfd == INVALID_SOCKET) { return; } /* in case of death shutdown to avoid blocking at close() */ if (shutdown(_sockfd, SHUT_RDWR) == SOCKET_ERROR && get_socket_errno() != ENOTCONN) { perror("shutdown"); } else if (closesocket(_sockfd) == SOCKET_ERROR) { perror("close"); } _sockfd= INVALID_SOCKET; } void Instance::free_addrinfo() { if (_addrinfo == NULL) { return; } freeaddrinfo(_addrinfo); _addrinfo= NULL; _addrinfo_next= NULL; } } /* namespace util */ } /* namespace datadifferential */ libmemcached-1.0.8/util/logfile.hpp0000664000076400007640000000402611753573717017530 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * DataDifferential Utility Library * * Copyright (C) 2011 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. * */ #pragma once #include #include namespace datadifferential { namespace util { class Logfile { public: Logfile(const std::string &arg); ~Logfile(); std::ofstream &log() { return _log_file; } bool open(); private: const std::string _filename; std::ofstream _log_file; }; } /* namespace util */ } /* namespace datadifferential */ libmemcached-1.0.8/util/daemon.cc0000664000076400007640000001040511753573717017146 0ustar00brianbrian00000000000000/* $Header: /cvsroot/wikipedia/willow/src/bin/willow/daemon.c,v 1.1 2005/05/02 19:15:21 kateturner Exp $ */ /* $NetBSD: daemon.c,v 1.9 2003/08/07 16:42:46 agc Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * Copyright (c) 2010 * Stewart Smith * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 #if defined __SUNPRO_C || defined __DECC || defined __HP_cc # pragma ident "@(#)$Header: /cvsroot/wikipedia/willow/src/bin/willow/daemon.c,v 1.1 2005/05/02 19:15:21 kateturner Exp $" # pragma ident "$NetBSD: daemon.c,v 1.9 2003/08/07 16:42:46 agc Exp $" #endif #include #include #include #include #include #include #include #include #include #include namespace datadifferential { namespace util { pid_t parent_pid; extern "C" { static void sigusr1_handler(int sig) { if (sig == SIGUSR1) { _exit(EXIT_SUCCESS); } } } bool daemon_is_ready(bool close_io) { if (kill(parent_pid, SIGUSR1) == -1) { perror("kill"); return false; } if (close_io == false) { return true;; } int fd; if ((fd = open("/dev/null", O_RDWR, 0)) < 0) { perror("open"); return false; } else { if (dup2(fd, STDIN_FILENO) < 0) { perror("dup2 stdin"); return false; } if (dup2(fd, STDOUT_FILENO) < 0) { perror("dup2 stdout"); return false; } if (dup2(fd, STDERR_FILENO) < 0) { perror("dup2 stderr"); return false; } if (fd > STDERR_FILENO) { if (close(fd) < 0) { perror("close"); return false; } } } return true; } #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wold-style-cast" #endif bool daemonize(bool is_chdir, bool wait_sigusr1) { struct sigaction new_action; new_action.sa_handler= sigusr1_handler; sigemptyset(&new_action.sa_mask); new_action.sa_flags= 0; sigaction(SIGUSR1, &new_action, NULL); parent_pid= getpid(); pid_t child= fork(); switch (child) { case -1: return false; case 0: break; default: if (wait_sigusr1) { /* parent */ int exit_code= EXIT_FAILURE; int status; while (waitpid(child, &status, 0) != child) { } if (WIFEXITED(status)) { exit_code= WEXITSTATUS(status); } if (WIFSIGNALED(status)) { exit_code= EXIT_FAILURE; } _exit(exit_code); } else { _exit(EXIT_SUCCESS); } } /* child */ if (setsid() == -1) { perror("setsid"); return false; } if (is_chdir) { if (chdir("/") < 0) { perror("chdir"); return false; } } return true; } } /* namespace util */ } /* namespace datadifferential */ libmemcached-1.0.8/util/pidfile.hpp0000664000076400007640000000405611753573717017526 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * DataDifferential Utility Library * * Copyright (C) 2011 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. * */ #pragma once #include namespace datadifferential { namespace util { class Pidfile { public: Pidfile(const std::string &arg); ~Pidfile(); const std::string &error_message() { return _error_message; } bool create(); private: int _last_errno; const std::string _filename; std::string _error_message; }; } /* namespace util */ } /* namespace datadifferential */ libmemcached-1.0.8/util/operation.cc0000664000076400007640000000444511753573717017712 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * DataDifferential Utility Library * * Copyright (C) 2011 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 #include "util/operation.hpp" #include namespace datadifferential { namespace util { bool Operation::response(std::string &arg) { if (_response.empty()) { return false; } if (not memcmp("OK\r\n", &_response[0], 3)) { } else if (not memcmp("OK ", &_response[0], 3)) { arg.append(&_response[3], _response.size() -3); } else if (not memcmp("ERR ", &_response[0], 4)) { arg.append(&_response[4], _response.size() -4); return false; } else { arg.append(&_response[0], _response.size()); } return true; } } /* namespace util */ } /* namespace datadifferential */ libmemcached-1.0.8/util/signal.hpp0000664000076400007640000000470011753573717017363 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Data Differential Utility 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. * */ #pragma once #include #include #ifdef HAVE_SIGNAL_H #include #endif namespace datadifferential { namespace util { enum shutdown_t { SHUTDOWN_RUNNING, SHUTDOWN_GRACEFUL, SHUTDOWN_FORCED }; class SignalThread { bool _exit_on_signal; sigset_t set; sem_t lock; uint64_t magic_memory; volatile shutdown_t __shutdown; pthread_mutex_t shutdown_mutex; pthread_t thread; public: SignalThread(bool exit_on_signal_arg= false); void test(); void post(); bool setup(); bool exit_on_signal() { return _exit_on_signal; } int wait(int& sig) { return sigwait(&set, &sig); } ~SignalThread(); void set_shutdown(shutdown_t arg); bool is_shutdown(); shutdown_t get_shutdown(); }; } /* namespace util */ } /* namespace datadifferential */ libmemcached-1.0.8/util/daemon.hpp0000664000076400007640000000377011753573717017357 0ustar00brianbrian00000000000000/* $Header: /cvsroot/wikipedia/willow/src/bin/willow/daemon.c,v 1.1 2005/05/02 19:15:21 kateturner Exp $ */ /* $NetBSD: daemon.c,v 1.9 2003/08/07 16:42:46 agc Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * Copyright (c) 2010 * Stewart Smith * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. */ #pragma once namespace datadifferential { namespace util { bool daemon_is_ready(bool close_io); bool daemonize(bool is_chdir= true, bool wait_sigusr1= true); } /* namespace util */ } /* namespace datadifferential */ libmemcached-1.0.8/util/pidfile.cc0000664000076400007640000001045211753573717017321 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * DataDifferential Utility Library * * Copyright (C) 2011 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 "config.h" #include "util/pidfile.hpp" #include #include #include #include #include #include #include #include #include #include extern "C" { char pid_file[1024 * 4]= { 0 }; static void remove_pidfile(void) { if (pid_file[0]) { if (unlink(pid_file) == -1) { std::cerr << "Could not remove pidfile: " << pid_file << "(" << strerror(errno) << ")" << std::endl; } pid_file[0]= 0; } } } namespace datadifferential { namespace util { Pidfile::Pidfile(const std::string &arg) : _last_errno(0), _filename(arg) { } Pidfile::~Pidfile() { if (not _filename.empty()) { if (access(_filename.c_str(), F_OK) == -1) { std::stringstream error_stream; error_stream << "Could not access the pid file: " << _filename << "(" << strerror(errno) << ")"; _error_message= error_stream.str(); } else if (unlink(_filename.c_str()) == -1) { std::stringstream error_stream; error_stream << "Could not remove the pid file: " << _filename << "(" << strerror(errno) << ")"; _error_message= error_stream.str(); } } pid_file[0]= 0; } bool Pidfile::create() { if (_filename.empty()) { return true; } if (access(_filename.c_str(), F_OK) == 0) { if (unlink(_filename.c_str()) == -1) { std::stringstream error_stream; error_stream << "Unable to remove exisiting file:" << _filename << "(" << strerror(errno) << ")"; _error_message= error_stream.str(); return false; } } int file; if ((file = open(_filename.c_str(), O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU|S_IRGRP|S_IROTH)) < 0) { std::stringstream error_stream; error_stream << "Could not open pid file for writing: " << _filename << "(" << strerror(errno) << ")"; _error_message= error_stream.str(); return false; } char buffer[BUFSIZ]; unsigned long temp= static_cast(getpid()); int length= snprintf(buffer, sizeof(buffer), "%lu\n", temp); if (write(file, buffer, length) != length) { std::stringstream error_stream; error_stream << "Could not write pid to file: " << _filename << "(" << strerror(errno) << ")"; _error_message= error_stream.str(); close(file); return false; } if (close(file) < 0) { _error_message+= "Could not close() file after writing pid to it: "; _error_message+= _filename; return false; } snprintf(pid_file, sizeof(pid_file), "%s", _filename.c_str()); atexit(remove_pidfile); return true; } } /* namespace util */ } /* namespace datadifferential */ libmemcached-1.0.8/THANKS0000664000076400007640000000116611753573717015336 0ustar00brianbrian00000000000000(This is not complete, please send email if I have missed someone.) Eirik A. Nygaard - IO Patch Cal Heldenbrand - Awesome feedback on performance Dustin Sallings - Insight into protocol Tobias Luetke - Performance Feedback Andre Cruz - Help with getting the CRC Hash function to match other connectors Brian Pontz - Hsieh hash Tim Bunce - Perl Driver work and feedback on API Kevin Dalley - Bug Fixes Patrick Galbraith - work on C++ interface Ross McFarland - Idea for sorting servers. Marcelo Fernandez - TCP/IP timeout pieces Yin Chen - Ketama support/weighted support Monty Taylor - Debian Packages, Cleanup work for configure libmemcached-1.0.8/libmemcached-1.2/0000775000076400007640000000000011757025117017300 5ustar00brianbrian00000000000000libmemcached-1.0.8/libmemcached-1.2/configure.h.in0000664000076400007640000000357711753573717022065 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif @DEPRECATED@ @LIBMEMCACHED_WITH_SASL_SUPPORT@ #define LIBMEMCACHED_VERSION_STRING "@VERSION@" #define LIBMEMCACHED_VERSION_HEX @PANDORA_HEX_VERSION@ #ifdef __cplusplus } #endif libmemcached-1.0.8/clients/0000775000076400007640000000000011757025120016040 5ustar00brianbrian00000000000000libmemcached-1.0.8/clients/execute.cc0000664000076400007640000000746711753573717020047 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ /* Execute a memcached_set() a set of pairs. Return the number of rows set. */ #include #include "clients/execute.h" unsigned int execute_set(memcached_st *memc, pairs_st *pairs, unsigned int number_of) { unsigned int x; unsigned int pairs_sent; for (x= 0, pairs_sent= 0; x < number_of; x++) { memcached_return_t rc= memcached_set(memc, pairs[x].key, pairs[x].key_length, pairs[x].value, pairs[x].value_length, 0, 0); if (memcached_failed(rc)) { fprintf(stderr, "%s:%d Failure on insert (%s) of %.*s\n", __FILE__, __LINE__, memcached_last_error_message(memc), (unsigned int)pairs[x].key_length, pairs[x].key); // We will try to reconnect and see if that fixes the issue memcached_quit(memc); } else { pairs_sent++; } } return pairs_sent; } /* Execute a memcached_get() on a set of pairs. Return the number of rows retrieved. */ unsigned int execute_get(memcached_st *memc, pairs_st *pairs, unsigned int number_of) { unsigned int x; unsigned int retrieved; for (retrieved= 0,x= 0; x < number_of; x++) { size_t value_length; uint32_t flags; unsigned int fetch_key= (unsigned int)((unsigned int)random() % number_of); memcached_return_t rc; char *value= memcached_get(memc, pairs[fetch_key].key, pairs[fetch_key].key_length, &value_length, &flags, &rc); if (memcached_failed(rc)) { fprintf(stderr, "%s:%d Failure on read(%s) of %.*s\n", __FILE__, __LINE__, memcached_last_error_message(memc), (unsigned int)pairs[fetch_key].key_length, pairs[fetch_key].key); } else { retrieved++; } ::free(value); } return retrieved; } /** * Callback function to count the number of results */ static memcached_return_t callback_counter(const memcached_st *ptr, memcached_result_st *result, void *context) { (void)ptr; (void)result; unsigned int *counter= (unsigned int *)context; *counter= *counter + 1; return MEMCACHED_SUCCESS; } /** * Try to run a large mget to get all of the keys * @param memc memcached handle * @param keys the keys to get * @param key_length the length of the keys * @param number_of the number of keys to try to get * @return the number of keys received */ unsigned int execute_mget(memcached_st *memc, const char * const *keys, size_t *key_length, unsigned int number_of) { unsigned int retrieved= 0; memcached_execute_fn callbacks[]= { callback_counter }; memcached_return_t rc; rc= memcached_mget_execute(memc, keys, key_length, (size_t)number_of, callbacks, &retrieved, 1); if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_BUFFERED || rc == MEMCACHED_END) { rc= memcached_fetch_execute(memc, callbacks, (void *)&retrieved, 1); if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_NOTFOUND && rc != MEMCACHED_END) { fprintf(stderr, "%s:%d Failed to execute mget: %s\n", __FILE__, __LINE__, memcached_strerror(memc, rc)); memcached_quit(memc); return 0; } } else { fprintf(stderr, "%s:%d Failed to execute mget: %s\n", __FILE__, __LINE__, memcached_strerror(memc, rc)); memcached_quit(memc); return 0; } return retrieved; } libmemcached-1.0.8/clients/memping.cc0000664000076400007640000000775311753573717020037 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #include "config.h" #include #include #include #include #include #include #include "client_options.h" #include "utilities.h" #include static bool opt_binary= false; static int opt_verbose= 0; static time_t opt_expire= 0; static char *opt_servers= NULL; static char *opt_username; static char *opt_passwd; #define PROGRAM_NAME "memping" #define PROGRAM_DESCRIPTION "Ping a server to see if it is alive" /* Prototypes */ void options_parse(int argc, char *argv[]); int main(int argc, char *argv[]) { options_parse(argc, argv); if (opt_servers == NULL) { char *temp; if ((temp= getenv("MEMCACHED_SERVERS"))) { opt_servers= strdup(temp); } else { std::cerr << "No Servers provided" << std::endl; exit(EXIT_FAILURE); } } int exit_code= EXIT_SUCCESS; memcached_server_st *servers= memcached_servers_parse(opt_servers); { for (uint32_t x= 0; x < memcached_server_list_count(servers); x++) { memcached_return_t instance_rc; const char *hostname= servers[x].hostname; in_port_t port= servers[x].port; if (libmemcached_util_ping2(hostname, port, opt_username, opt_passwd, &instance_rc) == false) { std::cerr << "Failed to ping " << hostname << ":" << port << " " << memcached_strerror(NULL, instance_rc) << std::endl; exit_code= EXIT_FAILURE; } } } memcached_server_list_free(servers); free(opt_servers); return exit_code; } void options_parse(int argc, char *argv[]) { memcached_programs_help_st help_options[]= { {0}, }; static struct option long_options[]= { {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, {(OPTIONSTRING)"quiet", no_argument, NULL, OPT_QUIET}, {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, {(OPTIONSTRING)"expire", required_argument, NULL, OPT_EXPIRE}, {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, {(OPTIONSTRING)"username", required_argument, NULL, OPT_USERNAME}, {(OPTIONSTRING)"password", required_argument, NULL, OPT_PASSWD}, {0, 0, 0, 0}, }; bool opt_version= false; bool opt_help= false; int option_index= 0; while (1) { int option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) break; switch (option_rv) { case 0: break; case OPT_BINARY: opt_binary= true; break; case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = OPT_VERBOSE; break; case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; case OPT_VERSION: /* --version or -V */ version_command(PROGRAM_NAME); break; case OPT_HELP: /* --help or -h */ help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options); break; case OPT_SERVERS: /* --servers or -s */ opt_servers= strdup(optarg); break; case OPT_EXPIRE: /* --expire */ opt_expire= (time_t)strtoll(optarg, (char **)NULL, 10); break; case OPT_USERNAME: opt_username= optarg; break; case OPT_PASSWD: opt_passwd= optarg; break; case OPT_QUIET: close_stdio(); break; case '?': /* getopt_long already printed an error message. */ exit(1); default: abort(); } } if (opt_version) { version_command(PROGRAM_NAME); exit(EXIT_SUCCESS); } if (opt_help) { help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options); exit(EXIT_SUCCESS); } } libmemcached-1.0.8/clients/ms_conn.c0000664000076400007640000024176211753573717017674 0ustar00brianbrian00000000000000/* * File: ms_conn.c * Author: Mingqiang Zhuang * * Created on February 10, 2009 * * (c) Copyright 2009, Schooner Information Technology, Inc. * http://www.schoonerinfotech.com/ * */ #include "config.h" #include #include #include #include #include #include #include #include #include #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #include "ms_setting.h" #include "ms_thread.h" #include "ms_atomic.h" #ifdef linux /* /usr/include/netinet/in.h defines macros from ntohs() to _bswap_nn to * optimize the conversion functions, but the prototypes generate warnings * from gcc. The conversion methods isn't the bottleneck for my app, so * just remove the warnings by undef'ing the optimization .. */ #undef ntohs #undef ntohl #undef htons #undef htonl #endif /* for network write */ #define TRANSMIT_COMPLETE 0 #define TRANSMIT_INCOMPLETE 1 #define TRANSMIT_SOFT_ERROR 2 #define TRANSMIT_HARD_ERROR 3 /* for generating key */ #define KEY_PREFIX_BASE 0x1010101010101010 /* not include ' ' '\r' '\n' '\0' */ #define KEY_PREFIX_MASK 0x1010101010101010 /* For parse the value length return by server */ #define KEY_TOKEN 1 #define VALUELEN_TOKEN 3 /* global increasing counter, to ensure the key prefix unique */ static uint64_t key_prefix_seq= KEY_PREFIX_BASE; /* global increasing counter, generating request id for UDP */ static volatile uint32_t udp_request_id= 0; extern pthread_key_t ms_thread_key; /* generate upd request id */ static uint32_t ms_get_udp_request_id(void); /* connect initialize */ static void ms_task_init(ms_conn_t *c); static int ms_conn_udp_init(ms_conn_t *c, const bool is_udp); static int ms_conn_sock_init(ms_conn_t *c); static int ms_conn_event_init(ms_conn_t *c); static int ms_conn_init(ms_conn_t *c, const int init_state, const int read_buffer_size, const bool is_udp); static void ms_warmup_num_init(ms_conn_t *c); static int ms_item_win_init(ms_conn_t *c); /* connection close */ void ms_conn_free(ms_conn_t *c); static void ms_conn_close(ms_conn_t *c); /* create network connection */ static int ms_new_socket(struct addrinfo *ai); static void ms_maximize_sndbuf(const int sfd); static int ms_network_connect(ms_conn_t *c, char *srv_host_name, const int srv_port, const bool is_udp, int *ret_sfd); static int ms_reconn(ms_conn_t *c); /* read and parse */ static int ms_tokenize_command(char *command, token_t *tokens, const int max_tokens); static int ms_ascii_process_line(ms_conn_t *c, char *command); static int ms_try_read_line(ms_conn_t *c); static int ms_sort_udp_packet(ms_conn_t *c, char *buf, int rbytes); static int ms_udp_read(ms_conn_t *c, char *buf, int len); static int ms_try_read_network(ms_conn_t *c); static void ms_verify_value(ms_conn_t *c, ms_mlget_task_item_t *mlget_item, char *value, int vlen); static void ms_ascii_complete_nread(ms_conn_t *c); static void ms_bin_complete_nread(ms_conn_t *c); static void ms_complete_nread(ms_conn_t *c); /* send functions */ static int ms_add_msghdr(ms_conn_t *c); static int ms_ensure_iov_space(ms_conn_t *c); static int ms_add_iov(ms_conn_t *c, const void *buf, int len); static int ms_build_udp_headers(ms_conn_t *c); static int ms_transmit(ms_conn_t *c); /* status adjustment */ static void ms_conn_shrink(ms_conn_t *c); static void ms_conn_set_state(ms_conn_t *c, int state); static bool ms_update_event(ms_conn_t *c, const int new_flags); static uint32_t ms_get_rep_sock_index(ms_conn_t *c, int cmd); static uint32_t ms_get_next_sock_index(ms_conn_t *c); static int ms_update_conn_sock_event(ms_conn_t *c); static bool ms_need_yield(ms_conn_t *c); static void ms_update_start_time(ms_conn_t *c); /* main loop */ static void ms_drive_machine(ms_conn_t *c); void ms_event_handler(const int fd, const short which, void *arg); /* ascii protocol */ static int ms_build_ascii_write_buf_set(ms_conn_t *c, ms_task_item_t *item); static int ms_build_ascii_write_buf_get(ms_conn_t *c, ms_task_item_t *item); static int ms_build_ascii_write_buf_mlget(ms_conn_t *c); /* binary protocol */ static int ms_bin_process_response(ms_conn_t *c); static void ms_add_bin_header(ms_conn_t *c, uint8_t opcode, uint8_t hdr_len, uint16_t key_len, uint32_t body_len); static void ms_add_key_to_iov(ms_conn_t *c, ms_task_item_t *item); static int ms_build_bin_write_buf_set(ms_conn_t *c, ms_task_item_t *item); static int ms_build_bin_write_buf_get(ms_conn_t *c, ms_task_item_t *item); static int ms_build_bin_write_buf_mlget(ms_conn_t *c); /** * each key has two parts, prefix and suffix. The suffix is a * string random get form the character table. The prefix is a * uint64_t variable. And the prefix must be unique. we use the * prefix to identify a key. And the prefix can't include * character ' ' '\r' '\n' '\0'. * * @return uint64_t */ uint64_t ms_get_key_prefix(void) { uint64_t key_prefix; pthread_mutex_lock(&ms_global.seq_mutex); key_prefix_seq|= KEY_PREFIX_MASK; key_prefix= key_prefix_seq; key_prefix_seq++; pthread_mutex_unlock(&ms_global.seq_mutex); return key_prefix; } /* ms_get_key_prefix */ /** * get an unique udp request id * * @return an unique UDP request id */ static uint32_t ms_get_udp_request_id(void) { return atomic_add_32_nv(&udp_request_id, 1); } /** * initialize current task structure * * @param c, pointer of the concurrency */ static void ms_task_init(ms_conn_t *c) { c->curr_task.cmd= CMD_NULL; c->curr_task.item= 0; c->curr_task.verify= false; c->curr_task.finish_verify= true; c->curr_task.get_miss= true; c->curr_task.get_opt= 0; c->curr_task.set_opt= 0; c->curr_task.cycle_undo_get= 0; c->curr_task.cycle_undo_set= 0; c->curr_task.verified_get= 0; c->curr_task.overwrite_set= 0; } /* ms_task_init */ /** * initialize udp for the connection structure * * @param c, pointer of the concurrency * @param is_udp, whether it's udp * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_conn_udp_init(ms_conn_t *c, const bool is_udp) { c->hdrbuf= 0; c->rudpbuf= 0; c->udppkt= 0; c->rudpsize= UDP_DATA_BUFFER_SIZE; c->hdrsize= 0; c->rudpbytes= 0; c->packets= 0; c->recvpkt= 0; c->pktcurr= 0; c->ordcurr= 0; c->udp= is_udp; if (c->udp || (! c->udp && ms_setting.facebook_test)) { c->rudpbuf= (char *)malloc((size_t)c->rudpsize); c->udppkt= (ms_udppkt_t *)malloc(MAX_UDP_PACKET * sizeof(ms_udppkt_t)); if ((c->rudpbuf == NULL) || (c->udppkt == NULL)) { if (c->rudpbuf != NULL) free(c->rudpbuf); if (c->udppkt != NULL) free(c->udppkt); fprintf(stderr, "malloc()\n"); return -1; } memset(c->udppkt, 0, MAX_UDP_PACKET * sizeof(ms_udppkt_t)); } return EXIT_SUCCESS; } /* ms_conn_udp_init */ /** * initialize the connection structure * * @param c, pointer of the concurrency * @param init_state, (conn_read, conn_write, conn_closing) * @param read_buffer_size * @param is_udp, whether it's udp * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_conn_init(ms_conn_t *c, const int init_state, const int read_buffer_size, const bool is_udp) { assert(c != NULL); c->rbuf= c->wbuf= 0; c->iov= 0; c->msglist= 0; c->rsize= read_buffer_size; c->wsize= WRITE_BUFFER_SIZE; c->iovsize= IOV_LIST_INITIAL; c->msgsize= MSG_LIST_INITIAL; /* for replication, each connection need connect all the server */ if (ms_setting.rep_write_srv > 0) { c->total_sfds= ms_setting.srv_cnt * ms_setting.sock_per_conn; } else { c->total_sfds= ms_setting.sock_per_conn; } c->alive_sfds= 0; c->rbuf= (char *)malloc((size_t)c->rsize); c->wbuf= (char *)malloc((size_t)c->wsize); c->iov= (struct iovec *)malloc(sizeof(struct iovec) * (size_t)c->iovsize); c->msglist= (struct msghdr *)malloc( sizeof(struct msghdr) * (size_t)c->msgsize); if (ms_setting.mult_key_num > 1) { c->mlget_task.mlget_item= (ms_mlget_task_item_t *) malloc( sizeof(ms_mlget_task_item_t) * (size_t)ms_setting.mult_key_num); } c->tcpsfd= (int *)malloc((size_t)c->total_sfds * sizeof(int)); if ((c->rbuf == NULL) || (c->wbuf == NULL) || (c->iov == NULL) || (c->msglist == NULL) || (c->tcpsfd == NULL) || ((ms_setting.mult_key_num > 1) && (c->mlget_task.mlget_item == NULL))) { if (c->rbuf != NULL) free(c->rbuf); if (c->wbuf != NULL) free(c->wbuf); if (c->iov != NULL) free(c->iov); if (c->msglist != NULL) free(c->msglist); if (c->mlget_task.mlget_item != NULL) free(c->mlget_task.mlget_item); if (c->tcpsfd != NULL) free(c->tcpsfd); fprintf(stderr, "malloc()\n"); return -1; } c->state= init_state; c->rvbytes= 0; c->rbytes= 0; c->rcurr= c->rbuf; c->wcurr= c->wbuf; c->iovused= 0; c->msgcurr= 0; c->msgused= 0; c->cur_idx= c->total_sfds; /* default index is a invalid value */ c->ctnwrite= false; c->readval= false; c->change_sfd= false; c->precmd.cmd= c->currcmd.cmd= CMD_NULL; c->precmd.isfinish= true; /* default the previous command finished */ c->currcmd.isfinish= false; c->precmd.retstat= c->currcmd.retstat= MCD_FAILURE; c->precmd.key_prefix= c->currcmd.key_prefix= 0; c->mlget_task.mlget_num= 0; c->mlget_task.value_index= -1; /* default invalid value */ if (ms_setting.binary_prot) { c->protocol= binary_prot; } else { c->protocol= ascii_prot; } /* initialize udp */ if (ms_conn_udp_init(c, is_udp) != 0) { return -1; } /* initialize task */ ms_task_init(c); if (! (ms_setting.facebook_test && is_udp)) { atomic_add_32(&ms_stats.active_conns, 1); } return EXIT_SUCCESS; } /* ms_conn_init */ /** * when doing 100% get operation, it could preset some objects * to warmup the server. this function is used to initialize the * number of the objects to preset. * * @param c, pointer of the concurrency */ static void ms_warmup_num_init(ms_conn_t *c) { /* no set operation, preset all the items in the window */ if (ms_setting.cmd_distr[CMD_SET].cmd_prop < PROP_ERROR) { c->warmup_num= c->win_size; c->remain_warmup_num= c->warmup_num; } else { c->warmup_num= 0; c->remain_warmup_num= c->warmup_num; } } /* ms_warmup_num_init */ /** * each connection has an item window, this function initialize * the window. The window is used to generate task. * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_item_win_init(ms_conn_t *c) { ms_thread_t *ms_thread= pthread_getspecific(ms_thread_key); int exp_cnt= 0; c->win_size= (int)ms_setting.win_size; c->set_cursor= 0; c->exec_num= ms_thread->thread_ctx->exec_num_perconn; c->remain_exec_num= c->exec_num; c->item_win= (ms_task_item_t *)malloc( sizeof(ms_task_item_t) * (size_t)c->win_size); if (c->item_win == NULL) { fprintf(stderr, "Can't allocate task item array for conn.\n"); return -1; } memset(c->item_win, 0, sizeof(ms_task_item_t) * (size_t)c->win_size); for (int i= 0; i < c->win_size; i++) { c->item_win[i].key_size= (int)ms_setting.distr[i].key_size; c->item_win[i].key_prefix= ms_get_key_prefix(); c->item_win[i].key_suffix_offset= ms_setting.distr[i].key_offset; c->item_win[i].value_size= (int)ms_setting.distr[i].value_size; c->item_win[i].value_offset= INVALID_OFFSET; /* default in invalid offset */ c->item_win[i].client_time= 0; /* set expire time base on the proportion */ if (exp_cnt < ms_setting.exp_ver_per * i) { c->item_win[i].exp_time= FIXED_EXPIRE_TIME; exp_cnt++; } else { c->item_win[i].exp_time= 0; } } ms_warmup_num_init(c); return EXIT_SUCCESS; } /* ms_item_win_init */ /** * each connection structure can include one or more sock * handlers. this function create these socks and connect the * server(s). * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_conn_sock_init(ms_conn_t *c) { ms_thread_t *ms_thread= pthread_getspecific(ms_thread_key); uint32_t i; int ret_sfd; uint32_t srv_idx= 0; assert(c != NULL); assert(c->tcpsfd != NULL); for (i= 0; i < c->total_sfds; i++) { ret_sfd= 0; if (ms_setting.rep_write_srv > 0) { /* for replication, each connection need connect all the server */ srv_idx= i % ms_setting.srv_cnt; } else { /* all the connections in a thread connects the same server */ srv_idx= ms_thread->thread_ctx->srv_idx; } if (ms_network_connect(c, ms_setting.servers[srv_idx].srv_host_name, ms_setting.servers[srv_idx].srv_port, ms_setting.udp, &ret_sfd) != 0) { break; } if (i == 0) { c->sfd= ret_sfd; } if (! ms_setting.udp) { c->tcpsfd[i]= ret_sfd; } c->alive_sfds++; } /* initialize udp sock handler if necessary */ if (ms_setting.facebook_test) { ret_sfd= 0; if (ms_network_connect(c, ms_setting.servers[srv_idx].srv_host_name, ms_setting.servers[srv_idx].srv_port, true, &ret_sfd) != 0) { c->udpsfd= 0; } else { c->udpsfd= ret_sfd; } } if ((i != c->total_sfds) || (ms_setting.facebook_test && (c->udpsfd == 0))) { if (ms_setting.udp) { close(c->sfd); } else { for (uint32_t j= 0; j < i; j++) { close(c->tcpsfd[j]); } } if (c->udpsfd != 0) { close(c->udpsfd); } return -1; } return EXIT_SUCCESS; } /* ms_conn_sock_init */ /** * each connection is managed by libevent, this function * initialize the event of the connection structure. * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_conn_event_init(ms_conn_t *c) { ms_thread_t *ms_thread= pthread_getspecific(ms_thread_key); short event_flags= EV_WRITE | EV_PERSIST; event_set(&c->event, c->sfd, event_flags, ms_event_handler, (void *)c); event_base_set(ms_thread->base, &c->event); c->ev_flags= event_flags; if (event_add(&c->event, NULL) == -1) { return -1; } return EXIT_SUCCESS; } /* ms_conn_event_init */ /** * setup a connection, each connection structure of each * thread must call this function to initialize. * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ int ms_setup_conn(ms_conn_t *c) { if (ms_item_win_init(c) != 0) { return -1; } if (ms_conn_init(c, conn_write, DATA_BUFFER_SIZE, ms_setting.udp) != 0) { return -1; } if (ms_conn_sock_init(c) != 0) { return -1; } if (ms_conn_event_init(c) != 0) { return -1; } return EXIT_SUCCESS; } /* ms_setup_conn */ /** * Frees a connection. * * @param c, pointer of the concurrency */ void ms_conn_free(ms_conn_t *c) { ms_thread_t *ms_thread= pthread_getspecific(ms_thread_key); if (c != NULL) { if (c->hdrbuf != NULL) free(c->hdrbuf); if (c->msglist != NULL) free(c->msglist); if (c->rbuf != NULL) free(c->rbuf); if (c->wbuf != NULL) free(c->wbuf); if (c->iov != NULL) free(c->iov); if (c->mlget_task.mlget_item != NULL) free(c->mlget_task.mlget_item); if (c->rudpbuf != NULL) free(c->rudpbuf); if (c->udppkt != NULL) free(c->udppkt); if (c->item_win != NULL) free(c->item_win); if (c->tcpsfd != NULL) free(c->tcpsfd); if (--ms_thread->nactive_conn == 0) { free(ms_thread->conn); } } } /* ms_conn_free */ /** * close a connection * * @param c, pointer of the concurrency */ static void ms_conn_close(ms_conn_t *c) { ms_thread_t *ms_thread= pthread_getspecific(ms_thread_key); assert(c != NULL); /* delete the event, the socket and the connection */ event_del(&c->event); for (uint32_t i= 0; i < c->total_sfds; i++) { if (c->tcpsfd[i] > 0) { close(c->tcpsfd[i]); } } c->sfd= 0; if (ms_setting.facebook_test) { close(c->udpsfd); } atomic_dec_32(&ms_stats.active_conns); ms_conn_free(c); if (ms_setting.run_time == 0) { pthread_mutex_lock(&ms_global.run_lock.lock); ms_global.run_lock.count++; pthread_cond_signal(&ms_global.run_lock.cond); pthread_mutex_unlock(&ms_global.run_lock.lock); } if (ms_thread->nactive_conn == 0) { pthread_exit(NULL); } } /* ms_conn_close */ /** * create a new sock * * @param ai, server address information * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_new_socket(struct addrinfo *ai) { int sfd; if ((sfd= socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) == -1) { fprintf(stderr, "socket() error: %s.\n", strerror(errno)); return -1; } return sfd; } /* ms_new_socket */ /** * Sets a socket's send buffer size to the maximum allowed by the system. * * @param sfd, file descriptor of socket */ static void ms_maximize_sndbuf(const int sfd) { socklen_t intsize= sizeof(int); unsigned int last_good= 0; unsigned int min, max, avg; unsigned int old_size; /* Start with the default size. */ if (getsockopt(sfd, SOL_SOCKET, SO_SNDBUF, &old_size, &intsize) != 0) { fprintf(stderr, "getsockopt(SO_SNDBUF)\n"); return; } /* Binary-search for the real maximum. */ min= old_size; max= MAX_SENDBUF_SIZE; while (min <= max) { avg= ((unsigned int)(min + max)) / 2; if (setsockopt(sfd, SOL_SOCKET, SO_SNDBUF, (void *)&avg, intsize) == 0) { last_good= avg; min= avg + 1; } else { max= avg - 1; } } } /* ms_maximize_sndbuf */ /** * socket connects the server * * @param c, pointer of the concurrency * @param srv_host_name, the host name of the server * @param srv_port, port of server * @param is_udp, whether it's udp * @param ret_sfd, the connected socket file descriptor * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_network_connect(ms_conn_t *c, char *srv_host_name, const int srv_port, const bool is_udp, int *ret_sfd) { int sfd; struct linger ling= { 0, 0 }; struct addrinfo *ai; struct addrinfo *next; struct addrinfo hints; char port_buf[NI_MAXSERV]; int error; int success= 0; int flags= 1; /* * the memset call clears nonstandard fields in some impementations * that otherwise mess things up. */ memset(&hints, 0, sizeof(hints)); #ifdef AI_ADDRCONFIG hints.ai_flags= AI_PASSIVE | AI_ADDRCONFIG; #else hints.ai_flags= AI_PASSIVE; #endif /* AI_ADDRCONFIG */ if (is_udp) { hints.ai_protocol= IPPROTO_UDP; hints.ai_socktype= SOCK_DGRAM; hints.ai_family= AF_INET; /* This left here because of issues with OSX 10.5 */ } else { hints.ai_family= AF_UNSPEC; hints.ai_protocol= IPPROTO_TCP; hints.ai_socktype= SOCK_STREAM; } snprintf(port_buf, NI_MAXSERV, "%d", srv_port); error= getaddrinfo(srv_host_name, port_buf, &hints, &ai); if (error != 0) { if (error != EAI_SYSTEM) fprintf(stderr, "getaddrinfo(): %s.\n", gai_strerror(error)); else perror("getaddrinfo()\n"); return -1; } for (next= ai; next; next= next->ai_next) { if ((sfd= ms_new_socket(next)) == -1) { freeaddrinfo(ai); return -1; } setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, (void *)&flags, sizeof(flags)); if (is_udp) { ms_maximize_sndbuf(sfd); } else { setsockopt(sfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&flags, sizeof(flags)); setsockopt(sfd, SOL_SOCKET, SO_LINGER, (void *)&ling, sizeof(ling)); setsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, (void *)&flags, sizeof(flags)); } if (is_udp) { c->srv_recv_addr_size= sizeof(struct sockaddr); memcpy(&c->srv_recv_addr, next->ai_addr, c->srv_recv_addr_size); } else { if (connect(sfd, next->ai_addr, next->ai_addrlen) == -1) { close(sfd); freeaddrinfo(ai); return -1; } } if (((flags= fcntl(sfd, F_GETFL, 0)) < 0) || (fcntl(sfd, F_SETFL, flags | O_NONBLOCK) < 0)) { fprintf(stderr, "setting O_NONBLOCK\n"); close(sfd); freeaddrinfo(ai); return -1; } if (ret_sfd != NULL) { *ret_sfd= sfd; } success++; } freeaddrinfo(ai); /* Return zero if we detected no errors in starting up connections */ return success == 0; } /* ms_network_connect */ /** * reconnect a disconnected sock * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_reconn(ms_conn_t *c) { ms_thread_t *ms_thread= pthread_getspecific(ms_thread_key); uint32_t srv_idx= 0; uint32_t srv_conn_cnt= 0; if (ms_setting.rep_write_srv > 0) { srv_idx= c->cur_idx % ms_setting.srv_cnt; srv_conn_cnt= ms_setting.sock_per_conn * ms_setting.nconns; } else { srv_idx= ms_thread->thread_ctx->srv_idx; srv_conn_cnt= ms_setting.nconns / ms_setting.srv_cnt; } /* close the old socket handler */ close(c->sfd); c->tcpsfd[c->cur_idx]= 0; if (atomic_add_32_nv(&ms_setting.servers[srv_idx].disconn_cnt, 1) % srv_conn_cnt == 0) { gettimeofday(&ms_setting.servers[srv_idx].disconn_time, NULL); fprintf(stderr, "Server %s:%d disconnect\n", ms_setting.servers[srv_idx].srv_host_name, ms_setting.servers[srv_idx].srv_port); } if (ms_setting.rep_write_srv > 0) { uint32_t i= 0; for (i= 0; i < c->total_sfds; i++) { if (c->tcpsfd[i] != 0) { break; } } /* all socks disconnect */ if (i == c->total_sfds) { return -1; } } else { do { /* reconnect success, break the loop */ if (ms_network_connect(c, ms_setting.servers[srv_idx].srv_host_name, ms_setting.servers[srv_idx].srv_port, ms_setting.udp, &c->sfd) == 0) { c->tcpsfd[c->cur_idx]= c->sfd; if (atomic_add_32_nv(&ms_setting.servers[srv_idx].reconn_cnt, 1) % (uint32_t)srv_conn_cnt == 0) { gettimeofday(&ms_setting.servers[srv_idx].reconn_time, NULL); int reconn_time= (int)(ms_setting.servers[srv_idx].reconn_time.tv_sec - ms_setting.servers[srv_idx].disconn_time .tv_sec); fprintf(stderr, "Server %s:%d reconnect after %ds\n", ms_setting.servers[srv_idx].srv_host_name, ms_setting.servers[srv_idx].srv_port, reconn_time); } break; } if (ms_setting.rep_write_srv == 0 && c->total_sfds > 0) { /* wait a second and reconnect */ sleep(1); } } while (ms_setting.rep_write_srv == 0 && c->total_sfds > 0); } if ((c->total_sfds > 1) && (c->tcpsfd[c->cur_idx] == 0)) { c->sfd= 0; c->alive_sfds--; } return EXIT_SUCCESS; } /* ms_reconn */ /** * reconnect several disconnected socks in the connection * structure, the ever-1-second timer of the thread will check * whether some socks in the connections disconnect. if * disconnect, reconnect the sock. * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ int ms_reconn_socks(ms_conn_t *c) { ms_thread_t *ms_thread= pthread_getspecific(ms_thread_key); uint32_t srv_idx= 0; int ret_sfd= 0; uint32_t srv_conn_cnt= 0; struct timeval cur_time; assert(c != NULL); if ((c->total_sfds == 1) || (c->total_sfds == c->alive_sfds)) { return EXIT_SUCCESS; } for (uint32_t i= 0; i < c->total_sfds; i++) { if (c->tcpsfd[i] == 0) { gettimeofday(&cur_time, NULL); /** * For failover test of replication, reconnect the socks after * it disconnects more than 5 seconds, Otherwise memslap will * block at connect() function and the work threads can't work * in this interval. */ if (cur_time.tv_sec - ms_setting.servers[srv_idx].disconn_time.tv_sec < 5) { break; } if (ms_setting.rep_write_srv > 0) { srv_idx= i % ms_setting.srv_cnt; srv_conn_cnt= ms_setting.sock_per_conn * ms_setting.nconns; } else { srv_idx= ms_thread->thread_ctx->srv_idx; srv_conn_cnt= ms_setting.nconns / ms_setting.srv_cnt; } if (ms_network_connect(c, ms_setting.servers[srv_idx].srv_host_name, ms_setting.servers[srv_idx].srv_port, ms_setting.udp, &ret_sfd) == 0) { c->tcpsfd[i]= ret_sfd; c->alive_sfds++; if (atomic_add_32_nv(&ms_setting.servers[srv_idx].reconn_cnt, 1) % (uint32_t)srv_conn_cnt == 0) { gettimeofday(&ms_setting.servers[srv_idx].reconn_time, NULL); int reconn_time= (int)(ms_setting.servers[srv_idx].reconn_time.tv_sec - ms_setting.servers[srv_idx].disconn_time .tv_sec); fprintf(stderr, "Server %s:%d reconnect after %ds\n", ms_setting.servers[srv_idx].srv_host_name, ms_setting.servers[srv_idx].srv_port, reconn_time); } } } } return EXIT_SUCCESS; } /* ms_reconn_socks */ /** * Tokenize the command string by replacing whitespace with '\0' and update * the token array tokens with pointer to start of each token and length. * Returns total number of tokens. The last valid token is the terminal * token (value points to the first unprocessed character of the string and * length zero). * * Usage example: * * while(ms_tokenize_command(command, ncommand, tokens, max_tokens) > 0) { * for(int ix = 0; tokens[ix].length != 0; ix++) { * ... * } * ncommand = tokens[ix].value - command; * command = tokens[ix].value; * } * * @param command, the command string to token * @param tokens, array to store tokens * @param max_tokens, maximum tokens number * * @return int, the number of tokens */ static int ms_tokenize_command(char *command, token_t *tokens, const int max_tokens) { char *s, *e; int ntokens= 0; assert(command != NULL && tokens != NULL && max_tokens > 1); for (s= e= command; ntokens < max_tokens - 1; ++e) { if (*e == ' ') { if (s != e) { tokens[ntokens].value= s; tokens[ntokens].length= (size_t)(e - s); ntokens++; *e= '\0'; } s= e + 1; } else if (*e == '\0') { if (s != e) { tokens[ntokens].value= s; tokens[ntokens].length= (size_t)(e - s); ntokens++; } break; /* string end */ } } return ntokens; } /* ms_tokenize_command */ /** * parse the response of server. * * @param c, pointer of the concurrency * @param command, the string responded by server * * @return int, if the command completed return EXIT_SUCCESS, else return * -1 */ static int ms_ascii_process_line(ms_conn_t *c, char *command) { int ret= 0; int64_t value_len; char *buffer= command; assert(c != NULL); /** * for command get, we store the returned value into local buffer * then continue in ms_complete_nread(). */ switch (buffer[0]) { case 'V': /* VALUE || VERSION */ if (buffer[1] == 'A') /* VALUE */ { token_t tokens[MAX_TOKENS]; ms_tokenize_command(command, tokens, MAX_TOKENS); value_len= strtol(tokens[VALUELEN_TOKEN].value, NULL, 10); c->currcmd.key_prefix= *(uint64_t *)tokens[KEY_TOKEN].value; /* * We read the \r\n into the string since not doing so is more * cycles then the waster of memory to do so. * * We are null terminating through, which will most likely make * some people lazy about using the return length. */ c->rvbytes= (int)(value_len + 2); c->readval= true; ret= -1; } break; case 'O': /* OK */ c->currcmd.retstat= MCD_SUCCESS; case 'S': /* STORED STATS SERVER_ERROR */ if (buffer[2] == 'A') /* STORED STATS */ { /* STATS*/ c->currcmd.retstat= MCD_STAT; } else if (buffer[1] == 'E') { /* SERVER_ERROR */ printf("<%d %s\n", c->sfd, buffer); c->currcmd.retstat= MCD_SERVER_ERROR; } else if (buffer[1] == 'T') { /* STORED */ c->currcmd.retstat= MCD_STORED; } else { c->currcmd.retstat= MCD_UNKNOWN_READ_FAILURE; } break; case 'D': /* DELETED DATA */ if (buffer[1] == 'E') { c->currcmd.retstat= MCD_DELETED; } else { c->currcmd.retstat= MCD_UNKNOWN_READ_FAILURE; } break; case 'N': /* NOT_FOUND NOT_STORED*/ if (buffer[4] == 'F') { c->currcmd.retstat= MCD_NOTFOUND; } else if (buffer[4] == 'S') { printf("<%d %s\n", c->sfd, buffer); c->currcmd.retstat= MCD_NOTSTORED; } else { c->currcmd.retstat= MCD_UNKNOWN_READ_FAILURE; } break; case 'E': /* PROTOCOL ERROR or END */ if (buffer[1] == 'N') { /* END */ c->currcmd.retstat= MCD_END; } else if (buffer[1] == 'R') { printf("<%d ERROR\n", c->sfd); c->currcmd.retstat= MCD_PROTOCOL_ERROR; } else if (buffer[1] == 'X') { c->currcmd.retstat= MCD_DATA_EXISTS; printf("<%d %s\n", c->sfd, buffer); } else { c->currcmd.retstat= MCD_UNKNOWN_READ_FAILURE; } break; case 'C': /* CLIENT ERROR */ printf("<%d %s\n", c->sfd, buffer); c->currcmd.retstat= MCD_CLIENT_ERROR; break; default: c->currcmd.retstat= MCD_UNKNOWN_READ_FAILURE; break; } /* switch */ return ret; } /* ms_ascii_process_line */ /** * after one operation completes, reset the concurrency * * @param c, pointer of the concurrency * @param timeout, whether it's timeout */ void ms_reset_conn(ms_conn_t *c, bool timeout) { assert(c != NULL); if (c->udp) { if ((c->packets > 0) && (c->packets < MAX_UDP_PACKET)) { memset(c->udppkt, 0, sizeof(ms_udppkt_t) * (size_t)c->packets); } c->packets= 0; c->recvpkt= 0; c->pktcurr= 0; c->ordcurr= 0; c->rudpbytes= 0; } c->currcmd.isfinish= true; c->ctnwrite= false; c->rbytes= 0; c->rcurr= c->rbuf; c->msgcurr = 0; c->msgused = 0; c->iovused = 0; ms_conn_set_state(c, conn_write); memcpy(&c->precmd, &c->currcmd, sizeof(ms_cmdstat_t)); /* replicate command state */ if (timeout) { ms_drive_machine(c); } } /* ms_reset_conn */ /** * if we have a complete line in the buffer, process it. * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_try_read_line(ms_conn_t *c) { if (c->protocol == binary_prot) { /* Do we have the complete packet header? */ if ((uint64_t)c->rbytes < sizeof(c->binary_header)) { /* need more data! */ return EXIT_SUCCESS; } else { #ifdef NEED_ALIGN if (((long)(c->rcurr)) % 8 != 0) { /* must realign input buffer */ memmove(c->rbuf, c->rcurr, c->rbytes); c->rcurr= c->rbuf; if (settings.verbose) { fprintf(stderr, "%d: Realign input buffer.\n", c->sfd); } } #endif protocol_binary_response_header *rsp; rsp= (protocol_binary_response_header *)c->rcurr; c->binary_header= *rsp; c->binary_header.response.extlen= rsp->response.extlen; c->binary_header.response.keylen= ntohs(rsp->response.keylen); c->binary_header.response.bodylen= ntohl(rsp->response.bodylen); c->binary_header.response.status= ntohs(rsp->response.status); if (c->binary_header.response.magic != PROTOCOL_BINARY_RES) { fprintf(stderr, "Invalid magic: %x\n", c->binary_header.response.magic); ms_conn_set_state(c, conn_closing); return EXIT_SUCCESS; } /* process this complete response */ if (ms_bin_process_response(c) == 0) { /* current operation completed */ ms_reset_conn(c, false); return -1; } else { c->rbytes-= (int32_t)sizeof(c->binary_header); c->rcurr+= sizeof(c->binary_header); } } } else { char *el, *cont; assert(c != NULL); assert(c->rcurr <= (c->rbuf + c->rsize)); if (c->rbytes == 0) return EXIT_SUCCESS; el= memchr(c->rcurr, '\n', (size_t)c->rbytes); if (! el) return EXIT_SUCCESS; cont= el + 1; if (((el - c->rcurr) > 1) && (*(el - 1) == '\r')) { el--; } *el= '\0'; assert(cont <= (c->rcurr + c->rbytes)); /* process this complete line */ if (ms_ascii_process_line(c, c->rcurr) == 0) { /* current operation completed */ ms_reset_conn(c, false); return -1; } else { /* current operation didn't complete */ c->rbytes-= (int32_t)(cont - c->rcurr); c->rcurr= cont; } assert(c->rcurr <= (c->rbuf + c->rsize)); } return -1; } /* ms_try_read_line */ /** * because the packet of UDP can't ensure the order, the * function is used to sort the received udp packet. * * @param c, pointer of the concurrency * @param buf, the buffer to store the ordered packages data * @param rbytes, the maximum capacity of the buffer * * @return int, if success, return the copy bytes, else return * -1 */ static int ms_sort_udp_packet(ms_conn_t *c, char *buf, int rbytes) { int len= 0; int wbytes= 0; uint16_t req_id= 0; uint16_t seq_num= 0; uint16_t packets= 0; unsigned char *header= NULL; /* no enough data */ assert(c != NULL); assert(buf != NULL); assert(c->rudpbytes >= UDP_HEADER_SIZE); /* calculate received packets count */ if (c->rudpbytes % UDP_MAX_PAYLOAD_SIZE >= UDP_HEADER_SIZE) { /* the last packet has some data */ c->recvpkt= c->rudpbytes / UDP_MAX_PAYLOAD_SIZE + 1; } else { c->recvpkt= c->rudpbytes / UDP_MAX_PAYLOAD_SIZE; } /* get the total packets count if necessary */ if (c->packets == 0) { c->packets= HEADER_TO_PACKETS((unsigned char *)c->rudpbuf); } /* build the ordered packet array */ for (int i= c->pktcurr; i < c->recvpkt; i++) { header= (unsigned char *)c->rudpbuf + i * UDP_MAX_PAYLOAD_SIZE; req_id= (uint16_t)HEADER_TO_REQID(header); assert(req_id == c->request_id % (1 << 16)); packets= (uint16_t)HEADER_TO_PACKETS(header); assert(c->packets == HEADER_TO_PACKETS(header)); seq_num= (uint16_t)HEADER_TO_SEQNUM(header); c->udppkt[seq_num].header= header; c->udppkt[seq_num].data= (char *)header + UDP_HEADER_SIZE; if (i == c->recvpkt - 1) { /* last received packet */ if (c->rudpbytes % UDP_MAX_PAYLOAD_SIZE == 0) { c->udppkt[seq_num].rbytes= UDP_MAX_PAYLOAD_SIZE - UDP_HEADER_SIZE; c->pktcurr++; } else { c->udppkt[seq_num].rbytes= c->rudpbytes % UDP_MAX_PAYLOAD_SIZE - UDP_HEADER_SIZE; } } else { c->udppkt[seq_num].rbytes= UDP_MAX_PAYLOAD_SIZE - UDP_HEADER_SIZE; c->pktcurr++; } } for (int i= c->ordcurr; i < c->recvpkt; i++) { /* there is some data to copy */ if ((c->udppkt[i].data != NULL) && (c->udppkt[i].copybytes < c->udppkt[i].rbytes)) { header= c->udppkt[i].header; len= c->udppkt[i].rbytes - c->udppkt[i].copybytes; if (len > rbytes - wbytes) { len= rbytes - wbytes; } assert(len <= rbytes - wbytes); assert(i == HEADER_TO_SEQNUM(header)); memcpy(buf + wbytes, c->udppkt[i].data + c->udppkt[i].copybytes, (size_t)len); wbytes+= len; c->udppkt[i].copybytes+= len; if ((c->udppkt[i].copybytes == c->udppkt[i].rbytes) && (c->udppkt[i].rbytes == UDP_MAX_PAYLOAD_SIZE - UDP_HEADER_SIZE)) { /* finish copying all the data of this packet, next */ c->ordcurr++; } /* last received packet, and finish copying all the data */ if ((c->recvpkt == c->packets) && (i == c->recvpkt - 1) && (c->udppkt[i].copybytes == c->udppkt[i].rbytes)) { break; } /* no space to copy data */ if (wbytes >= rbytes) { break; } /* it doesn't finish reading all the data of the packet from network */ if ((i != c->recvpkt - 1) && (c->udppkt[i].rbytes < UDP_MAX_PAYLOAD_SIZE - UDP_HEADER_SIZE)) { break; } } else { /* no data to copy */ break; } } return wbytes == 0 ? -1 : wbytes; } /* ms_sort_udp_packet */ /** * encapsulate upd read like tcp read * * @param c, pointer of the concurrency * @param buf, read buffer * @param len, length to read * * @return int, if success, return the read bytes, else return * -1 */ static int ms_udp_read(ms_conn_t *c, char *buf, int len) { int res= 0; int avail= 0; int rbytes= 0; int copybytes= 0; assert(c->udp); while (1) { if (c->rudpbytes + UDP_MAX_PAYLOAD_SIZE > c->rudpsize) { char *new_rbuf= realloc(c->rudpbuf, (size_t)c->rudpsize * 2); if (! new_rbuf) { fprintf(stderr, "Couldn't realloc input buffer.\n"); c->rudpbytes= 0; /* ignore what we read */ return -1; } c->rudpbuf= new_rbuf; c->rudpsize*= 2; } avail= c->rudpsize - c->rudpbytes; /* UDP each time read a packet, 1400 bytes */ res= (int)read(c->sfd, c->rudpbuf + c->rudpbytes, (size_t)avail); if (res > 0) { atomic_add_size(&ms_stats.bytes_read, res); c->rudpbytes+= res; rbytes+= res; if (res == avail) { continue; } else { break; } } if (res == 0) { /* "connection" closed */ return res; } if (res == -1) { /* no data to read */ return res; } } /* copy data to read buffer */ if (rbytes > 0) { copybytes= ms_sort_udp_packet(c, buf, len); } if (copybytes == -1) { atomic_add_size(&ms_stats.pkt_disorder, 1); } return copybytes; } /* ms_udp_read */ /* * read from network as much as we can, handle buffer overflow and connection * close. * before reading, move the remaining incomplete fragment of a command * (if any) to the beginning of the buffer. * return EXIT_SUCCESS if there's nothing to read on the first read. */ /** * read from network as much as we can, handle buffer overflow and connection * close. before reading, move the remaining incomplete fragment of a command * (if any) to the beginning of the buffer. * * @param c, pointer of the concurrency * * @return int, * return EXIT_SUCCESS if there's nothing to read on the first read. * return EXIT_FAILURE if get data * return -1 if error happens */ static int ms_try_read_network(ms_conn_t *c) { int gotdata= 0; int res; int64_t avail; assert(c != NULL); if ((c->rcurr != c->rbuf) && (! c->readval || (c->rvbytes > c->rsize - (c->rcurr - c->rbuf)) || (c->readval && (c->rcurr - c->rbuf > c->rbytes)))) { if (c->rbytes != 0) /* otherwise there's nothing to copy */ memmove(c->rbuf, c->rcurr, (size_t)c->rbytes); c->rcurr= c->rbuf; } while (1) { if (c->rbytes >= c->rsize) { char *new_rbuf= realloc(c->rbuf, (size_t)c->rsize * 2); if (! new_rbuf) { fprintf(stderr, "Couldn't realloc input buffer.\n"); c->rbytes= 0; /* ignore what we read */ return -1; } c->rcurr= c->rbuf= new_rbuf; c->rsize*= 2; } avail= c->rsize - c->rbytes - (c->rcurr - c->rbuf); if (avail == 0) { break; } if (c->udp) { res= (int32_t)ms_udp_read(c, c->rcurr + c->rbytes, (int32_t)avail); } else { res= (int)read(c->sfd, c->rcurr + c->rbytes, (size_t)avail); } if (res > 0) { if (! c->udp) { atomic_add_size(&ms_stats.bytes_read, res); } gotdata= 1; c->rbytes+= res; if (res == avail) { continue; } else { break; } } if (res == 0) { /* connection closed */ ms_conn_set_state(c, conn_closing); return -1; } if (res == -1) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break; /* Should close on unhandled errors. */ ms_conn_set_state(c, conn_closing); return -1; } } return gotdata; } /* ms_try_read_network */ /** * after get the object from server, verify the value if * necessary. * * @param c, pointer of the concurrency * @param mlget_item, pointer of mulit-get task item structure * @param value, received value string * @param vlen, received value string length */ static void ms_verify_value(ms_conn_t *c, ms_mlget_task_item_t *mlget_item, char *value, int vlen) { if (c->curr_task.verify) { assert(c->curr_task.item->value_offset != INVALID_OFFSET); char *orignval= &ms_setting.char_block[c->curr_task.item->value_offset]; char *orignkey= &ms_setting.char_block[c->curr_task.item->key_suffix_offset]; /* verify expire time if necessary */ if (c->curr_task.item->exp_time > 0) { struct timeval curr_time; gettimeofday(&curr_time, NULL); /* object expired but get it now */ if (curr_time.tv_sec - c->curr_task.item->client_time > c->curr_task.item->exp_time + EXPIRE_TIME_ERROR) { atomic_add_size(&ms_stats.exp_get, 1); if (ms_setting.verbose) { char set_time[64]; char cur_time[64]; strftime(set_time, 64, "%Y-%m-%d %H:%M:%S", localtime(&c->curr_task.item->client_time)); strftime(cur_time, 64, "%Y-%m-%d %H:%M:%S", localtime(&curr_time.tv_sec)); fprintf(stderr, "\n<%d expire time verification failed, " "object expired but get it now\n" "\tkey len: %d\n" "\tkey: %" PRIx64 " %.*s\n" "\tset time: %s current time: %s " "diff time: %d expire time: %d\n" "\texpected data: \n" "\treceived data len: %d\n" "\treceived data: %.*s\n", c->sfd, c->curr_task.item->key_size, c->curr_task.item->key_prefix, c->curr_task.item->key_size - (int)KEY_PREFIX_SIZE, orignkey, set_time, cur_time, (int)(curr_time.tv_sec - c->curr_task.item->client_time), c->curr_task.item->exp_time, vlen, vlen, value); fflush(stderr); } } } else { if ((c->curr_task.item->value_size != vlen) || (memcmp(orignval, value, (size_t)vlen) != 0)) { atomic_add_size(&ms_stats.vef_failed, 1); if (ms_setting.verbose) { fprintf(stderr, "\n<%d data verification failed\n" "\tkey len: %d\n" "\tkey: %" PRIx64" %.*s\n" "\texpected data len: %d\n" "\texpected data: %.*s\n" "\treceived data len: %d\n" "\treceived data: %.*s\n", c->sfd, c->curr_task.item->key_size, c->curr_task.item->key_prefix, c->curr_task.item->key_size - (int)KEY_PREFIX_SIZE, orignkey, c->curr_task.item->value_size, c->curr_task.item->value_size, orignval, vlen, vlen, value); fflush(stderr); } } } c->curr_task.finish_verify= true; if (mlget_item != NULL) { mlget_item->finish_verify= true; } } } /* ms_verify_value */ /** * For ASCII protocol, after store the data into the local * buffer, run this function to handle the data. * * @param c, pointer of the concurrency */ static void ms_ascii_complete_nread(ms_conn_t *c) { assert(c != NULL); assert(c->rbytes >= c->rvbytes); assert(c->protocol == ascii_prot); if (c->rvbytes > 2) { assert( c->rcurr[c->rvbytes - 1] == '\n' && c->rcurr[c->rvbytes - 2] == '\r'); } /* multi-get */ ms_mlget_task_item_t *mlget_item= NULL; if (((ms_setting.mult_key_num > 1) && (c->mlget_task.mlget_num >= ms_setting.mult_key_num)) || ((c->remain_exec_num == 0) && (c->mlget_task.mlget_num > 0))) { c->mlget_task.value_index++; mlget_item= &c->mlget_task.mlget_item[c->mlget_task.value_index]; if (mlget_item->item->key_prefix == c->currcmd.key_prefix) { c->curr_task.item= mlget_item->item; c->curr_task.verify= mlget_item->verify; c->curr_task.finish_verify= mlget_item->finish_verify; mlget_item->get_miss= false; } else { /* Try to find the task item in multi-get task array */ for (int i= 0; i < c->mlget_task.mlget_num; i++) { mlget_item= &c->mlget_task.mlget_item[i]; if (mlget_item->item->key_prefix == c->currcmd.key_prefix) { c->curr_task.item= mlget_item->item; c->curr_task.verify= mlget_item->verify; c->curr_task.finish_verify= mlget_item->finish_verify; mlget_item->get_miss= false; break; } } } } ms_verify_value(c, mlget_item, c->rcurr, c->rvbytes - 2); c->curr_task.get_miss= false; c->rbytes-= c->rvbytes; c->rcurr= c->rcurr + c->rvbytes; assert(c->rcurr <= (c->rbuf + c->rsize)); c->readval= false; c->rvbytes= 0; } /* ms_ascii_complete_nread */ /** * For binary protocol, after store the data into the local * buffer, run this function to handle the data. * * @param c, pointer of the concurrency */ static void ms_bin_complete_nread(ms_conn_t *c) { assert(c != NULL); assert(c->rbytes >= c->rvbytes); assert(c->protocol == binary_prot); int extlen= c->binary_header.response.extlen; int keylen= c->binary_header.response.keylen; uint8_t opcode= c->binary_header.response.opcode; /* not get command or not include value, just return */ if (((opcode != PROTOCOL_BINARY_CMD_GET) && (opcode != PROTOCOL_BINARY_CMD_GETQ)) || (c->rvbytes <= extlen + keylen)) { /* get miss */ if (c->binary_header.response.opcode == PROTOCOL_BINARY_CMD_GET) { c->currcmd.retstat= MCD_END; c->curr_task.get_miss= true; } c->readval= false; c->rvbytes= 0; ms_reset_conn(c, false); return; } /* multi-get */ ms_mlget_task_item_t *mlget_item= NULL; if (((ms_setting.mult_key_num > 1) && (c->mlget_task.mlget_num >= ms_setting.mult_key_num)) || ((c->remain_exec_num == 0) && (c->mlget_task.mlget_num > 0))) { c->mlget_task.value_index++; mlget_item= &c->mlget_task.mlget_item[c->mlget_task.value_index]; c->curr_task.item= mlget_item->item; c->curr_task.verify= mlget_item->verify; c->curr_task.finish_verify= mlget_item->finish_verify; mlget_item->get_miss= false; } ms_verify_value(c, mlget_item, c->rcurr + extlen + keylen, c->rvbytes - extlen - keylen); c->currcmd.retstat= MCD_END; c->curr_task.get_miss= false; c->rbytes-= c->rvbytes; c->rcurr= c->rcurr + c->rvbytes; assert(c->rcurr <= (c->rbuf + c->rsize)); c->readval= false; c->rvbytes= 0; if (ms_setting.mult_key_num > 1) { /* multi-get have check all the item */ if (c->mlget_task.value_index == c->mlget_task.mlget_num - 1) { ms_reset_conn(c, false); } } else { /* single get */ ms_reset_conn(c, false); } } /* ms_bin_complete_nread */ /** * we get here after reading the value of get commands. * * @param c, pointer of the concurrency */ static void ms_complete_nread(ms_conn_t *c) { assert(c != NULL); assert(c->rbytes >= c->rvbytes); assert(c->protocol == ascii_prot || c->protocol == binary_prot); if (c->protocol == binary_prot) { ms_bin_complete_nread(c); } else { ms_ascii_complete_nread(c); } } /* ms_complete_nread */ /** * Adds a message header to a connection. * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_add_msghdr(ms_conn_t *c) { struct msghdr *msg; assert(c != NULL); if (c->msgsize == c->msgused) { msg= realloc(c->msglist, (size_t)c->msgsize * 2 * sizeof(struct msghdr)); if (! msg) return -1; c->msglist= msg; c->msgsize*= 2; } msg= c->msglist + c->msgused; /** * this wipes msg_iovlen, msg_control, msg_controllen, and * msg_flags, the last 3 of which aren't defined on solaris: */ memset(msg, 0, sizeof(struct msghdr)); msg->msg_iov= &c->iov[c->iovused]; if (c->udp && (c->srv_recv_addr_size > 0)) { msg->msg_name= &c->srv_recv_addr; msg->msg_namelen= c->srv_recv_addr_size; } c->msgbytes= 0; c->msgused++; if (c->udp) { /* Leave room for the UDP header, which we'll fill in later. */ return ms_add_iov(c, NULL, UDP_HEADER_SIZE); } return EXIT_SUCCESS; } /* ms_add_msghdr */ /** * Ensures that there is room for another structure iovec in a connection's * iov list. * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_ensure_iov_space(ms_conn_t *c) { assert(c != NULL); if (c->iovused >= c->iovsize) { int i, iovnum; struct iovec *new_iov= (struct iovec *)realloc(c->iov, ((size_t)c->iovsize * 2) * sizeof(struct iovec)); if (! new_iov) return -1; c->iov= new_iov; c->iovsize*= 2; /* Point all the msghdr structures at the new list. */ for (i= 0, iovnum= 0; i < c->msgused; i++) { c->msglist[i].msg_iov= &c->iov[iovnum]; iovnum+= (int)c->msglist[i].msg_iovlen; } } return EXIT_SUCCESS; } /* ms_ensure_iov_space */ /** * Adds data to the list of pending data that will be written out to a * connection. * * @param c, pointer of the concurrency * @param buf, the buffer includes data to send * @param len, the data length in the buffer * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_add_iov(ms_conn_t *c, const void *buf, int len) { struct msghdr *m; int leftover; bool limit_to_mtu; assert(c != NULL); do { m= &c->msglist[c->msgused - 1]; /* * Limit UDP packets, to UDP_MAX_PAYLOAD_SIZE bytes. */ limit_to_mtu= c->udp; #ifdef IOV_MAX /* We may need to start a new msghdr if this one is full. */ if ((m->msg_iovlen == IOV_MAX) || (limit_to_mtu && (c->msgbytes >= UDP_MAX_SEND_PAYLOAD_SIZE))) { ms_add_msghdr(c); m= &c->msglist[c->msgused - 1]; } #endif if (ms_ensure_iov_space(c) != 0) return -1; /* If the fragment is too big to fit in the datagram, split it up */ if (limit_to_mtu && (len + c->msgbytes > UDP_MAX_SEND_PAYLOAD_SIZE)) { leftover= len + c->msgbytes - UDP_MAX_SEND_PAYLOAD_SIZE; len-= leftover; } else { leftover= 0; } m= &c->msglist[c->msgused - 1]; m->msg_iov[m->msg_iovlen].iov_base= (void *)buf; m->msg_iov[m->msg_iovlen].iov_len= (size_t)len; c->msgbytes+= len; c->iovused++; m->msg_iovlen++; buf= ((char *)buf) + len; len= leftover; } while (leftover > 0); return EXIT_SUCCESS; } /* ms_add_iov */ /** * Constructs a set of UDP headers and attaches them to the outgoing messages. * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_build_udp_headers(ms_conn_t *c) { int i; unsigned char *hdr; assert(c != NULL); c->request_id= ms_get_udp_request_id(); if (c->msgused > c->hdrsize) { void *new_hdrbuf; if (c->hdrbuf) new_hdrbuf= realloc(c->hdrbuf, (size_t)c->msgused * 2 * UDP_HEADER_SIZE); else new_hdrbuf= malloc((size_t)c->msgused * 2 * UDP_HEADER_SIZE); if (! new_hdrbuf) return -1; c->hdrbuf= (unsigned char *)new_hdrbuf; c->hdrsize= c->msgused * 2; } /* If this is a multi-packet request, drop it. */ if (c->udp && (c->msgused > 1)) { fprintf(stderr, "multi-packet request for UDP not supported.\n"); return -1; } hdr= c->hdrbuf; for (i= 0; i < c->msgused; i++) { c->msglist[i].msg_iov[0].iov_base= (void *)hdr; c->msglist[i].msg_iov[0].iov_len= UDP_HEADER_SIZE; *hdr++= (unsigned char)(c->request_id / 256); *hdr++= (unsigned char)(c->request_id % 256); *hdr++= (unsigned char)(i / 256); *hdr++= (unsigned char)(i % 256); *hdr++= (unsigned char)(c->msgused / 256); *hdr++= (unsigned char)(c->msgused % 256); *hdr++= (unsigned char)1; /* support facebook memcached */ *hdr++= (unsigned char)0; assert(hdr == ((unsigned char *)c->msglist[i].msg_iov[0].iov_base + UDP_HEADER_SIZE)); } return EXIT_SUCCESS; } /* ms_build_udp_headers */ /** * Transmit the next chunk of data from our list of msgbuf structures. * * @param c, pointer of the concurrency * * @return TRANSMIT_COMPLETE All done writing. * TRANSMIT_INCOMPLETE More data remaining to write. * TRANSMIT_SOFT_ERROR Can't write any more right now. * TRANSMIT_HARD_ERROR Can't write (c->state is set to conn_closing) */ static int ms_transmit(ms_conn_t *c) { assert(c != NULL); if ((c->msgcurr < c->msgused) && (c->msglist[c->msgcurr].msg_iovlen == 0)) { /* Finished writing the current msg; advance to the next. */ c->msgcurr++; } if (c->msgcurr < c->msgused) { ssize_t res; struct msghdr *m= &c->msglist[c->msgcurr]; res= sendmsg(c->sfd, m, 0); if (res > 0) { atomic_add_size(&ms_stats.bytes_written, res); /* We've written some of the data. Remove the completed * iovec entries from the list of pending writes. */ while (m->msg_iovlen > 0 && res >= (ssize_t)m->msg_iov->iov_len) { res-= (ssize_t)m->msg_iov->iov_len; m->msg_iovlen--; m->msg_iov++; } /* Might have written just part of the last iovec entry; * adjust it so the next write will do the rest. */ if (res > 0) { m->msg_iov->iov_base= (void *)((unsigned char *)m->msg_iov->iov_base + res); m->msg_iov->iov_len-= (size_t)res; } return TRANSMIT_INCOMPLETE; } if ((res == -1) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) { if (! ms_update_event(c, EV_WRITE | EV_PERSIST)) { fprintf(stderr, "Couldn't update event.\n"); ms_conn_set_state(c, conn_closing); return TRANSMIT_HARD_ERROR; } return TRANSMIT_SOFT_ERROR; } /* if res==0 or res==-1 and error is not EAGAIN or EWOULDBLOCK, * we have a real error, on which we close the connection */ fprintf(stderr, "Failed to write, and not due to blocking.\n"); ms_conn_set_state(c, conn_closing); return TRANSMIT_HARD_ERROR; } else { return TRANSMIT_COMPLETE; } } /* ms_transmit */ /** * Shrinks a connection's buffers if they're too big. This prevents * periodic large "mget" response from server chewing lots of client * memory. * * This should only be called in between requests since it can wipe output * buffers! * * @param c, pointer of the concurrency */ static void ms_conn_shrink(ms_conn_t *c) { assert(c != NULL); if (c->udp) return; if ((c->rsize > READ_BUFFER_HIGHWAT) && (c->rbytes < DATA_BUFFER_SIZE)) { char *newbuf; if (c->rcurr != c->rbuf) memmove(c->rbuf, c->rcurr, (size_t)c->rbytes); newbuf= (char *)realloc((void *)c->rbuf, DATA_BUFFER_SIZE); if (newbuf) { c->rbuf= newbuf; c->rsize= DATA_BUFFER_SIZE; } c->rcurr= c->rbuf; } if (c->udp && (c->rudpsize > UDP_DATA_BUFFER_HIGHWAT) && (c->rudpbytes + UDP_MAX_PAYLOAD_SIZE < UDP_DATA_BUFFER_SIZE)) { char *new_rbuf= (char *)realloc(c->rudpbuf, (size_t)c->rudpsize * 2); if (! new_rbuf) { c->rudpbuf= new_rbuf; c->rudpsize= UDP_DATA_BUFFER_SIZE; } /* TODO check error condition? */ } if (c->msgsize > MSG_LIST_HIGHWAT) { struct msghdr *newbuf= (struct msghdr *)realloc( (void *)c->msglist, MSG_LIST_INITIAL * sizeof(c->msglist[0])); if (newbuf) { c->msglist= newbuf; c->msgsize= MSG_LIST_INITIAL; } /* TODO check error condition? */ } if (c->iovsize > IOV_LIST_HIGHWAT) { struct iovec *newbuf= (struct iovec *)realloc((void *)c->iov, IOV_LIST_INITIAL * sizeof(c->iov[0])); if (newbuf) { c->iov= newbuf; c->iovsize= IOV_LIST_INITIAL; } /* TODO check return value */ } } /* ms_conn_shrink */ /** * Sets a connection's current state in the state machine. Any special * processing that needs to happen on certain state transitions can * happen here. * * @param c, pointer of the concurrency * @param state, connection state */ static void ms_conn_set_state(ms_conn_t *c, int state) { assert(c != NULL); if (state != c->state) { if (state == conn_read) { ms_conn_shrink(c); } c->state= state; } } /* ms_conn_set_state */ /** * update the event if socks change state. for example: when * change the listen scoket read event to sock write event, or * change socket handler, we could call this function. * * @param c, pointer of the concurrency * @param new_flags, new event flags * * @return bool, if success, return true, else return false */ static bool ms_update_event(ms_conn_t *c, const int new_flags) { assert(c != NULL); struct event_base *base= c->event.ev_base; if ((c->ev_flags == new_flags) && (ms_setting.rep_write_srv == 0) && (! ms_setting.facebook_test || (c->total_sfds == 1))) { return true; } if (event_del(&c->event) == -1) { /* try to delete the event again */ if (event_del(&c->event) == -1) { return false; } } event_set(&c->event, c->sfd, (short)new_flags, ms_event_handler, (void *)c); event_base_set(base, &c->event); c->ev_flags= (short)new_flags; if (event_add(&c->event, NULL) == -1) { return false; } return true; } /* ms_update_event */ /** * If user want to get the expected throughput, we could limit * the performance of memslap. we could give up some work and * just wait a short time. The function is used to check this * case. * * @param c, pointer of the concurrency * * @return bool, if success, return true, else return false */ static bool ms_need_yield(ms_conn_t *c) { ms_thread_t *ms_thread= pthread_getspecific(ms_thread_key); int64_t tps= 0; int64_t time_diff= 0; struct timeval curr_time; ms_task_t *task= &c->curr_task; if (ms_setting.expected_tps > 0) { gettimeofday(&curr_time, NULL); time_diff= ms_time_diff(&ms_thread->startup_time, &curr_time); tps= (int64_t)(((task->get_opt + task->set_opt) / (uint64_t)time_diff) * 1000000); /* current throughput is greater than expected throughput */ if (tps > ms_thread->thread_ctx->tps_perconn) { return true; } } return false; } /* ms_need_yield */ /** * used to update the start time of each operation * * @param c, pointer of the concurrency */ static void ms_update_start_time(ms_conn_t *c) { ms_task_item_t *item= c->curr_task.item; if ((ms_setting.stat_freq > 0) || c->udp || ((c->currcmd.cmd == CMD_SET) && (item->exp_time > 0))) { gettimeofday(&c->start_time, NULL); if ((c->currcmd.cmd == CMD_SET) && (item->exp_time > 0)) { /* record the current time */ item->client_time= c->start_time.tv_sec; } } } /* ms_update_start_time */ /** * run the state machine * * @param c, pointer of the concurrency */ static void ms_drive_machine(ms_conn_t *c) { bool stop= false; assert(c != NULL); while (! stop) { switch (c->state) { case conn_read: if (c->readval) { if (c->rbytes >= c->rvbytes) { ms_complete_nread(c); break; } } else { if (ms_try_read_line(c) != 0) { break; } } if (ms_try_read_network(c) != 0) { break; } /* doesn't read all the response data, wait event wake up */ if (! c->currcmd.isfinish) { if (! ms_update_event(c, EV_READ | EV_PERSIST)) { fprintf(stderr, "Couldn't update event.\n"); ms_conn_set_state(c, conn_closing); break; } stop= true; break; } /* we have no command line and no data to read from network, next write */ ms_conn_set_state(c, conn_write); memcpy(&c->precmd, &c->currcmd, sizeof(ms_cmdstat_t)); /* replicate command state */ break; case conn_write: if (! c->ctnwrite && ms_need_yield(c)) { usleep(10); if (! ms_update_event(c, EV_WRITE | EV_PERSIST)) { fprintf(stderr, "Couldn't update event.\n"); ms_conn_set_state(c, conn_closing); break; } stop= true; break; } if (! c->ctnwrite && (ms_exec_task(c) != 0)) { ms_conn_set_state(c, conn_closing); break; } /* record the start time before starting to send data if necessary */ if (! c->ctnwrite || (c->change_sfd && c->ctnwrite)) { if (c->change_sfd) { c->change_sfd= false; } ms_update_start_time(c); } /* change sfd if necessary */ if (c->change_sfd) { c->ctnwrite= true; stop= true; break; } /* execute task until nothing need be written to network */ if (! c->ctnwrite && (c->msgcurr == c->msgused)) { if (! ms_update_event(c, EV_WRITE | EV_PERSIST)) { fprintf(stderr, "Couldn't update event.\n"); ms_conn_set_state(c, conn_closing); break; } stop= true; break; } switch (ms_transmit(c)) { case TRANSMIT_COMPLETE: /* we have no data to write to network, next wait repose */ if (! ms_update_event(c, EV_READ | EV_PERSIST)) { fprintf(stderr, "Couldn't update event.\n"); ms_conn_set_state(c, conn_closing); c->ctnwrite= false; break; } ms_conn_set_state(c, conn_read); c->ctnwrite= false; stop= true; break; case TRANSMIT_INCOMPLETE: c->ctnwrite= true; break; /* Continue in state machine. */ case TRANSMIT_HARD_ERROR: c->ctnwrite= false; break; case TRANSMIT_SOFT_ERROR: c->ctnwrite= true; stop= true; break; default: break; } /* switch */ break; case conn_closing: /* recovery mode, need reconnect if connection close */ if (ms_setting.reconnect && (! ms_global.time_out || ((ms_setting.run_time == 0) && (c->remain_exec_num > 0)))) { if (ms_reconn(c) != 0) { ms_conn_close(c); stop= true; break; } ms_reset_conn(c, false); if (c->total_sfds == 1) { if (! ms_update_event(c, EV_WRITE | EV_PERSIST)) { fprintf(stderr, "Couldn't update event.\n"); ms_conn_set_state(c, conn_closing); break; } } break; } else { ms_conn_close(c); stop= true; break; } default: assert(0); } /* switch */ } } /* ms_drive_machine */ /** * the event handler of each thread * * @param fd, the file descriptor of socket * @param which, event flag * @param arg, argument */ void ms_event_handler(const int fd, const short which, void *arg) { ms_conn_t *c= (ms_conn_t *)arg; assert(c != NULL); c->which= which; /* sanity */ if (fd != c->sfd) { fprintf(stderr, "Catastrophic: event fd: %d doesn't match conn fd: %d\n", fd, c->sfd); ms_conn_close(c); exit(1); } assert(fd == c->sfd); ms_drive_machine(c); /* wait for next event */ } /* ms_event_handler */ /** * get the next socket descriptor index to run for replication * * @param c, pointer of the concurrency * @param cmd, command(get or set ) * * @return int, if success, return the index, else return EXIT_SUCCESS */ static uint32_t ms_get_rep_sock_index(ms_conn_t *c, int cmd) { uint32_t sock_index= 0; uint32_t i= 0; if (c->total_sfds == 1) { return EXIT_SUCCESS; } if (ms_setting.rep_write_srv == 0) { return sock_index; } do { if (cmd == CMD_SET) { for (i= 0; i < ms_setting.rep_write_srv; i++) { if (c->tcpsfd[i] > 0) { break; } } if (i == ms_setting.rep_write_srv) { /* random get one replication server to read */ sock_index= (uint32_t)random() % c->total_sfds; } else { /* random get one replication writing server to write */ sock_index= (uint32_t)random() % ms_setting.rep_write_srv; } } else if (cmd == CMD_GET) { /* random get one replication server to read */ sock_index= (uint32_t)random() % c->total_sfds; } } while (c->tcpsfd[sock_index] == 0); return sock_index; } /* ms_get_rep_sock_index */ /** * get the next socket descriptor index to run * * @param c, pointer of the concurrency * * @return int, return the index */ static uint32_t ms_get_next_sock_index(ms_conn_t *c) { uint32_t sock_index= 0; do { sock_index= (++c->cur_idx == c->total_sfds) ? 0 : c->cur_idx; } while (c->tcpsfd[sock_index] == 0); return sock_index; } /* ms_get_next_sock_index */ /** * update socket event of the connections * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_update_conn_sock_event(ms_conn_t *c) { assert(c != NULL); switch (c->currcmd.cmd) { case CMD_SET: if (ms_setting.facebook_test && c->udp) { c->sfd= c->tcpsfd[0]; c->udp= false; c->change_sfd= true; } break; case CMD_GET: if (ms_setting.facebook_test && ! c->udp) { c->sfd= c->udpsfd; c->udp= true; c->change_sfd= true; } break; default: break; } /* switch */ if (! c->udp && (c->total_sfds > 1)) { if (c->cur_idx != c->total_sfds) { if (ms_setting.rep_write_srv == 0) { c->cur_idx= ms_get_next_sock_index(c); } else { c->cur_idx= ms_get_rep_sock_index(c, c->currcmd.cmd); } } else { /* must select the first sock of the connection at the beginning */ c->cur_idx= 0; } c->sfd= c->tcpsfd[c->cur_idx]; assert(c->sfd != 0); c->change_sfd= true; } if (c->change_sfd) { if (! ms_update_event(c, EV_WRITE | EV_PERSIST)) { fprintf(stderr, "Couldn't update event.\n"); ms_conn_set_state(c, conn_closing); return -1; } } return EXIT_SUCCESS; } /* ms_update_conn_sock_event */ /** * for ASCII protocol, this function build the set command * string and send the command. * * @param c, pointer of the concurrency * @param item, pointer of task item which includes the object * information * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_build_ascii_write_buf_set(ms_conn_t *c, ms_task_item_t *item) { int value_offset; int write_len; char *buffer= c->wbuf; write_len= snprintf(buffer, c->wsize, " %u %d %d\r\n", 0, item->exp_time, item->value_size); if (write_len > c->wsize || write_len < 0) { /* ought to be always enough. just fail for simplicity */ fprintf(stderr, "output command line too long.\n"); return -1; } if (item->value_offset == INVALID_OFFSET) { value_offset= item->key_suffix_offset; } else { value_offset= item->value_offset; } if ((ms_add_iov(c, "set ", 4) != 0) || (ms_add_iov(c, (char *)&item->key_prefix, (int)KEY_PREFIX_SIZE) != 0) || (ms_add_iov(c, &ms_setting.char_block[item->key_suffix_offset], item->key_size - (int)KEY_PREFIX_SIZE) != 0) || (ms_add_iov(c, buffer, write_len) != 0) || (ms_add_iov(c, &ms_setting.char_block[value_offset], item->value_size) != 0) || (ms_add_iov(c, "\r\n", 2) != 0) || (c->udp && (ms_build_udp_headers(c) != 0))) { return -1; } return EXIT_SUCCESS; } /* ms_build_ascii_write_buf_set */ /** * used to send set command to server * * @param c, pointer of the concurrency * @param item, pointer of task item which includes the object * information * * @return int, if success, return EXIT_SUCCESS, else return -1 */ int ms_mcd_set(ms_conn_t *c, ms_task_item_t *item) { assert(c != NULL); c->currcmd.cmd= CMD_SET; c->currcmd.isfinish= false; c->currcmd.retstat= MCD_FAILURE; if (ms_update_conn_sock_event(c) != 0) { return -1; } c->msgcurr= 0; c->msgused= 0; c->iovused= 0; if (ms_add_msghdr(c) != 0) { fprintf(stderr, "Out of memory preparing request."); return -1; } /* binary protocol */ if (c->protocol == binary_prot) { if (ms_build_bin_write_buf_set(c, item) != 0) { return -1; } } else { if (ms_build_ascii_write_buf_set(c, item) != 0) { return -1; } } atomic_add_size(&ms_stats.obj_bytes, item->key_size + item->value_size); atomic_add_size(&ms_stats.cmd_set, 1); return EXIT_SUCCESS; } /* ms_mcd_set */ /** * for ASCII protocol, this function build the get command * string and send the command. * * @param c, pointer of the concurrency * @param item, pointer of task item which includes the object * information * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_build_ascii_write_buf_get(ms_conn_t *c, ms_task_item_t *item) { if ((ms_add_iov(c, "get ", 4) != 0) || (ms_add_iov(c, (char *)&item->key_prefix, (int)KEY_PREFIX_SIZE) != 0) || (ms_add_iov(c, &ms_setting.char_block[item->key_suffix_offset], item->key_size - (int)KEY_PREFIX_SIZE) != 0) || (ms_add_iov(c, "\r\n", 2) != 0) || (c->udp && (ms_build_udp_headers(c) != 0))) { return -1; } return EXIT_SUCCESS; } /* ms_build_ascii_write_buf_get */ /** * used to send the get command to server * * @param c, pointer of the concurrency * @param item, pointer of task item which includes the object * information * * @return int, if success, return EXIT_SUCCESS, else return -1 */ int ms_mcd_get(ms_conn_t *c, ms_task_item_t *item) { assert(c != NULL); c->currcmd.cmd= CMD_GET; c->currcmd.isfinish= false; c->currcmd.retstat= MCD_FAILURE; if (ms_update_conn_sock_event(c) != 0) { return -1; } c->msgcurr= 0; c->msgused= 0; c->iovused= 0; if (ms_add_msghdr(c) != 0) { fprintf(stderr, "Out of memory preparing request."); return -1; } /* binary protocol */ if (c->protocol == binary_prot) { if (ms_build_bin_write_buf_get(c, item) != 0) { return -1; } } else { if (ms_build_ascii_write_buf_get(c, item) != 0) { return -1; } } atomic_add_size(&ms_stats.cmd_get, 1); return EXIT_SUCCESS; } /* ms_mcd_get */ /** * for ASCII protocol, this function build the multi-get command * string and send the command. * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_build_ascii_write_buf_mlget(ms_conn_t *c) { ms_task_item_t *item; if (ms_add_iov(c, "get", 3) != 0) { return -1; } for (int i= 0; i < c->mlget_task.mlget_num; i++) { item= c->mlget_task.mlget_item[i].item; assert(item != NULL); if ((ms_add_iov(c, " ", 1) != 0) || (ms_add_iov(c, (char *)&item->key_prefix, (int)KEY_PREFIX_SIZE) != 0) || (ms_add_iov(c, &ms_setting.char_block[item->key_suffix_offset], item->key_size - (int)KEY_PREFIX_SIZE) != 0)) { return -1; } } if ((ms_add_iov(c, "\r\n", 2) != 0) || (c->udp && (ms_build_udp_headers(c) != 0))) { return -1; } return EXIT_SUCCESS; } /* ms_build_ascii_write_buf_mlget */ /** * used to send the multi-get command to server * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ int ms_mcd_mlget(ms_conn_t *c) { ms_task_item_t *item; assert(c != NULL); assert(c->mlget_task.mlget_num >= 1); c->currcmd.cmd= CMD_GET; c->currcmd.isfinish= false; c->currcmd.retstat= MCD_FAILURE; if (ms_update_conn_sock_event(c) != 0) { return -1; } c->msgcurr= 0; c->msgused= 0; c->iovused= 0; if (ms_add_msghdr(c) != 0) { fprintf(stderr, "Out of memory preparing request."); return -1; } /* binary protocol */ if (c->protocol == binary_prot) { if (ms_build_bin_write_buf_mlget(c) != 0) { return -1; } } else { if (ms_build_ascii_write_buf_mlget(c) != 0) { return -1; } } /* decrease operation time of each item */ for (int i= 0; i < c->mlget_task.mlget_num; i++) { item= c->mlget_task.mlget_item[i].item; atomic_add_size(&ms_stats.cmd_get, 1); } return EXIT_SUCCESS; } /* ms_mcd_mlget */ /** * binary protocol support */ /** * for binary protocol, parse the response of server * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_bin_process_response(ms_conn_t *c) { const char *errstr= NULL; assert(c != NULL); uint32_t bodylen= c->binary_header.response.bodylen; uint8_t opcode= c->binary_header.response.opcode; uint16_t status= c->binary_header.response.status; if (bodylen > 0) { c->rvbytes= (int32_t)bodylen; c->readval= true; return EXIT_FAILURE; } else { switch (status) { case PROTOCOL_BINARY_RESPONSE_SUCCESS: if (opcode == PROTOCOL_BINARY_CMD_SET) { c->currcmd.retstat= MCD_STORED; } else if (opcode == PROTOCOL_BINARY_CMD_DELETE) { c->currcmd.retstat= MCD_DELETED; } else if (opcode == PROTOCOL_BINARY_CMD_GET) { c->currcmd.retstat= MCD_END; } break; case PROTOCOL_BINARY_RESPONSE_ENOMEM: errstr= "Out of memory"; c->currcmd.retstat= MCD_SERVER_ERROR; break; case PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND: errstr= "Unknown command"; c->currcmd.retstat= MCD_UNKNOWN_READ_FAILURE; break; case PROTOCOL_BINARY_RESPONSE_KEY_ENOENT: errstr= "Not found"; c->currcmd.retstat= MCD_NOTFOUND; break; case PROTOCOL_BINARY_RESPONSE_EINVAL: errstr= "Invalid arguments"; c->currcmd.retstat= MCD_PROTOCOL_ERROR; break; case PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS: errstr= "Data exists for key."; break; case PROTOCOL_BINARY_RESPONSE_E2BIG: errstr= "Too large."; c->currcmd.retstat= MCD_SERVER_ERROR; break; case PROTOCOL_BINARY_RESPONSE_NOT_STORED: errstr= "Not stored."; c->currcmd.retstat= MCD_NOTSTORED; break; default: errstr= "Unknown error"; c->currcmd.retstat= MCD_UNKNOWN_READ_FAILURE; break; } /* switch */ if (errstr != NULL) { fprintf(stderr, "%s\n", errstr); } } return EXIT_SUCCESS; } /* ms_bin_process_response */ /* build binary header and add the header to the buffer to send */ /** * build binary header and add the header to the buffer to send * * @param c, pointer of the concurrency * @param opcode, operation code * @param hdr_len, length of header * @param key_len, length of key * @param body_len. length of body */ static void ms_add_bin_header(ms_conn_t *c, uint8_t opcode, uint8_t hdr_len, uint16_t key_len, uint32_t body_len) { protocol_binary_request_header *header; assert(c != NULL); header= (protocol_binary_request_header *)c->wcurr; header->request.magic= (uint8_t)PROTOCOL_BINARY_REQ; header->request.opcode= (uint8_t)opcode; header->request.keylen= htons(key_len); header->request.extlen= (uint8_t)hdr_len; header->request.datatype= (uint8_t)PROTOCOL_BINARY_RAW_BYTES; header->request.vbucket= 0; header->request.bodylen= htonl(body_len); header->request.opaque= 0; header->request.cas= 0; ms_add_iov(c, c->wcurr, sizeof(header->request)); } /* ms_add_bin_header */ /** * add the key to the socket write buffer array * * @param c, pointer of the concurrency * @param item, pointer of task item which includes the object * information */ static void ms_add_key_to_iov(ms_conn_t *c, ms_task_item_t *item) { ms_add_iov(c, (char *)&item->key_prefix, (int)KEY_PREFIX_SIZE); ms_add_iov(c, &ms_setting.char_block[item->key_suffix_offset], item->key_size - (int)KEY_PREFIX_SIZE); } /** * for binary protocol, this function build the set command * and add the command to send buffer array. * * @param c, pointer of the concurrency * @param item, pointer of task item which includes the object * information * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_build_bin_write_buf_set(ms_conn_t *c, ms_task_item_t *item) { assert(c->wbuf == c->wcurr); int value_offset; protocol_binary_request_set *rep= (protocol_binary_request_set *)c->wcurr; uint16_t keylen= (uint16_t)item->key_size; uint32_t bodylen= (uint32_t)sizeof(rep->message.body) + (uint32_t)keylen + (uint32_t)item->value_size; ms_add_bin_header(c, PROTOCOL_BINARY_CMD_SET, sizeof(rep->message.body), keylen, bodylen); rep->message.body.flags= 0; rep->message.body.expiration= htonl((uint32_t)item->exp_time); ms_add_iov(c, &rep->message.body, sizeof(rep->message.body)); ms_add_key_to_iov(c, item); if (item->value_offset == INVALID_OFFSET) { value_offset= item->key_suffix_offset; } else { value_offset= item->value_offset; } ms_add_iov(c, &ms_setting.char_block[value_offset], item->value_size); return EXIT_SUCCESS; } /* ms_build_bin_write_buf_set */ /** * for binary protocol, this function build the get command and * add the command to send buffer array. * * @param c, pointer of the concurrency * @param item, pointer of task item which includes the object * information * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_build_bin_write_buf_get(ms_conn_t *c, ms_task_item_t *item) { assert(c->wbuf == c->wcurr); ms_add_bin_header(c, PROTOCOL_BINARY_CMD_GET, 0, (uint16_t)item->key_size, (uint32_t)item->key_size); ms_add_key_to_iov(c, item); return EXIT_SUCCESS; } /* ms_build_bin_write_buf_get */ /** * for binary protocol, this function build the multi-get * command and add the command to send buffer array. * * @param c, pointer of the concurrency * @param item, pointer of task item which includes the object * information * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_build_bin_write_buf_mlget(ms_conn_t *c) { ms_task_item_t *item; assert(c->wbuf == c->wcurr); for (int i= 0; i < c->mlget_task.mlget_num; i++) { item= c->mlget_task.mlget_item[i].item; assert(item != NULL); ms_add_bin_header(c, PROTOCOL_BINARY_CMD_GET, 0, (uint16_t)item->key_size, (uint32_t)item->key_size); ms_add_key_to_iov(c, item); c->wcurr+= sizeof(protocol_binary_request_get); } c->wcurr= c->wbuf; return EXIT_SUCCESS; } /* ms_build_bin_write_buf_mlget */ libmemcached-1.0.8/clients/ms_task.h0000664000076400007640000000654711753573717017706 0ustar00brianbrian00000000000000/* * File: ms_task.h * Author: Mingqiang Zhuang * * Created on February 10, 2009 * * (c) Copyright 2009, Schooner Information Technology, Inc. * http://www.schoonerinfotech.com/ * */ #ifndef MS_TASK_H #define MS_TASK_H #include #include #if !defined(__cplusplus) # include #endif #include #ifdef __cplusplus extern "C" { #endif #define UNIT_ITEMS_COUNT 1024 /* each window unit has 1024 items */ #define KEY_PREFIX_SIZE (sizeof(uint64_t)) /* key prefix length: 8 bytes */ #define INVALID_OFFSET (-1) /* invalid offset in the character table */ #define FIXED_EXPIRE_TIME 60 /* default expire time is 60s */ #define EXPIRE_TIME_ERROR 5 /* default expire time error is 5s */ /* information of a task item(object) */ typedef struct task_item { uint64_t key_prefix; /* prefix of the key, 8 bytes, binary */ int key_size; /* key size */ int key_suffix_offset; /* suffix offset in the global character table */ int value_size; /* data size */ int value_offset; /* data offset in the global character table */ time_t client_time; /* the current client time */ int exp_time; /* expire time */ } ms_task_item_t; /* task item for multi-get */ typedef struct mlget_task_item { ms_task_item_t *item; /* task item */ bool verify; /* whether verify data or not */ bool finish_verify; /* whether finish data verify or not */ bool get_miss; /* whether get miss or not */ } ms_mlget_task_item_t; /* information of multi-get task */ typedef struct mlget_task { ms_mlget_task_item_t *mlget_item; /* multi-get task array */ int mlget_num; /* how many tasks in mlget_task array */ int value_index; /* the nth value received by the connect, for multi-get */ } ms_mlget_task_t; /* structure used to store the state of the running task */ typedef struct task { int cmd; /* command name */ bool verify; /* whether verify data or not */ bool finish_verify; /* whether finish data verify or not */ bool get_miss; /* whether get miss or not */ ms_task_item_t *item; /* task item */ /* counter for command distribution adjustment */ uint64_t get_opt; /* number of total get operations */ uint64_t set_opt; /* number of total set operations, no including warmup set count */ int cycle_undo_get; /* number of undo get in an adjustment cycle */ int cycle_undo_set; /* number of undo set in an adjustment cycle */ uint64_t verified_get; /* number of total verified get operations */ uint64_t overwrite_set; /* number of total overwrite set operations */ } ms_task_t; struct conn; /* the state machine call the function to execute task.*/ int ms_exec_task(struct conn *c); /* calculate the difference value of two time points */ int64_t ms_time_diff(struct timeval *start_time, struct timeval *end_time); #ifdef __cplusplus } #endif #endif /* end of MS_TASK_H */ libmemcached-1.0.8/clients/include.am0000664000076400007640000001121311753573717020020 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root CLIENTS_LDADDS= \ clients/libutilities.la \ libmemcached/libmemcached.la if HAVE_SASL CLIENTS_LDADDS+= $(LIBSASL) endif bin_PROGRAMS+= \ clients/memcapable \ clients/memcat \ clients/memcp \ clients/memdump \ clients/memerror \ clients/memexist \ clients/memtouch \ clients/memflush \ clients/memparse \ clients/memping \ clients/memrm \ clients/memslap \ clients/memstat if BUILD_MEMASLAP if HAVE_LIBEVENT if !BUILD_WIN32_WRAPPERS bin_PROGRAMS+= clients/memaslap endif endif endif noinst_HEADERS+= \ clients/client_options.h \ clients/execute.h \ clients/generator.h \ clients/ms_atomic.h \ clients/ms_conn.h \ clients/ms_memslap.h \ clients/ms_setting.h \ clients/ms_sigsegv.h \ clients/ms_stats.h \ clients/ms_task.h \ clients/ms_thread.h \ clients/utilities.h noinst_LTLIBRARIES+= clients/libutilities.la clients_libutilities_la_SOURCES= clients/utilities.cc clients_memcat_SOURCES= clients/memcat.cc clients_memcat_LDADD= $(CLIENTS_LDADDS) clients_memparse_SOURCES= clients/memparse.cc clients_memparse_LDADD= $(CLIENTS_LDADDS) clients_memcp_SOURCES= clients/memcp.cc clients_memcp_LDADD= $(CLIENTS_LDADDS) clients_memdump_SOURCES= clients/memdump.cc clients_memdump_LDADD= $(CLIENTS_LDADDS) clients_memstat_SOURCES= clients/memstat.cc clients_memstat_LDADD= $(CLIENTS_LDADDS) clients_memrm_SOURCES= clients/memrm.cc clients_memrm_LDADD= $(CLIENTS_LDADDS) clients_memexist_SOURCES= clients/memexist.cc clients_memexist_LDADD= $(CLIENTS_LDADDS) clients_memtouch_SOURCES= clients/memtouch.cc clients_memtouch_LDADD= $(CLIENTS_LDADDS) clients_memflush_SOURCES= clients/memflush.cc clients_memflush_LDADD= $(CLIENTS_LDADDS) clients_memping_SOURCES= clients/memping.cc clients_memping_LDADD= $(CLIENTS_LDADDS) libmemcached/libmemcachedutil.la clients_memerror_SOURCES= clients/memerror.cc clients_memerror_LDADD= $(CLIENTS_LDADDS) clients_memslap_SOURCES = clients/memslap.cc clients_memslap_SOURCES+= clients/generator.cc clients/execute.cc clients_memslap_CXXFLAGS = ${PTHREAD_CFLAGS} clients_memslap_LDADD= $(CLIENTS_LDADDS) clients_memslap_LDADD+= $(PTHREAD_LIBS) clients_memaslap_SOURCES= \ clients/memaslap.c \ clients/ms_conn.c \ clients/ms_setting.c \ clients/ms_sigsegv.c \ clients/ms_stats.c \ clients/ms_task.c \ clients/ms_thread.c clients_memaslap_SOURCES+= clients/generator.cc clients/execute.cc clients_memaslap_LDADD= $(LTLIBEVENT) $(CLIENTS_LDADDS) clients_memcapable_SOURCES= \ clients/memcapable.cc \ libmemcached/byteorder.cc clients_memcapable_LDADD= $(CLIENTS_LDADDS) test-start-server: clients/memflush --servers=localhost clients/memcp --servers=localhost /etc/services clients/memcat --servers=localhost /etc/services clients/memrm --servers=localhost /etc/services clients/memstat --servers=localhost clients/memslap --servers=localhost clients/memslap --servers=localhost --concurrency=10 clients/memslap --servers=localhost --concurrency=10 --initial-load=1000 clients/memslap --servers=localhost --concurrency=10 --initial-load=1000 --execute-number=10 clients/memslap --servers=localhost --concurrency=10 --initial-load=1000 --execute-number=10 --test=get clients/memslap --servers=localhost --concurrency=10 --initial-load=1000 --execute-number=10 --test=set clients/memslap --servers=localhost --concurrency=10 --initial-load=1000 --execute-number=10 --test=set --non-blocking client-valgrind: libtool --mode=execute valgrind --leak-check=yes --show-reachable=yes clients/memslap --servers=localhost libtool --mode=execute valgrind --leak-check=yes --show-reachable=yes clients/memslap --servers=localhost --concurrency=10 libtool --mode=execute valgrind --leak-check=yes --show-reachable=yes clients/memslap --servers=localhost --concurrency=10 --initial-load=1000 libtool --mode=execute valgrind --leak-check=yes --show-reachable=yes clients/memslap --servers=localhost --concurrency=10 --initial-load=1000 --execute-number=10 libtool --mode=execute valgrind --leak-check=yes --show-reachable=yes clients/memslap --servers=localhost --concurrency=10 --initial-load=1000 --execute-number=10 --test=get libtool --mode=execute valgrind --leak-check=yes --show-reachable=yes clients/memslap --servers=localhost --concurrency=10 --initial-load=1000 --execute-number=10 --test=set libtool --mode=execute valgrind --leak-check=yes --show-reachable=yes clients/memslap --servers=localhost --concurrency=10 --initial-load=1000 --execute-number=10 --test=set --non-blocking libmemcached-1.0.8/clients/execute.h0000664000076400007640000000132711753573717017676 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #pragma once #include #include "libmemcached/memcached.h" #include "clients/generator.h" #ifdef __cplusplus extern "C" { #endif unsigned int execute_set(memcached_st *memc, pairs_st *pairs, unsigned int number_of); unsigned int execute_get(memcached_st *memc, pairs_st *pairs, unsigned int number_of); unsigned int execute_mget(memcached_st *memc, const char * const *keys, size_t *key_length, unsigned int number_of); #ifdef __cplusplus } // extern "C" #endif libmemcached-1.0.8/clients/utilities.h0000664000076400007640000000267011753573717020251 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #pragma once #include #include #include "clients/client_options.h" #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #ifdef __sun /* For some odd reason the option struct on solaris defines the argument * as char* and not const char* */ #define OPTIONSTRING char* #else #define OPTIONSTRING const char* #endif typedef struct memcached_programs_help_st memcached_programs_help_st; struct memcached_programs_help_st { char *not_used_yet; }; #ifdef __cplusplus extern "C" { #endif char *strdup_cleanup(const char *str); void cleanup(void); long int timedif(struct timeval a, struct timeval b); void version_command(const char *command_name); void help_command(const char *command_name, const char *description, const struct option *long_options, memcached_programs_help_st *options); void process_hash_option(memcached_st *memc, char *opt_hash); bool initialize_sasl(memcached_st *memc, char *user, char *password); void shutdown_sasl(void); void initialize_sockets(void); void close_stdio(void); #ifdef __cplusplus } // extern "C" #endif libmemcached-1.0.8/clients/memslap.cc0000664000076400007640000003333511753573717020034 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-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. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "client_options.h" #include "utilities.h" #include "generator.h" #include "execute.h" #define DEFAULT_INITIAL_LOAD 10000 #define DEFAULT_EXECUTE_NUMBER 10000 #define DEFAULT_CONCURRENCY 1 #define PROGRAM_NAME "memslap" #define PROGRAM_DESCRIPTION "Generates a load against a memcached custer of servers." /* Global Thread counter */ volatile unsigned int master_wakeup; pthread_mutex_t sleeper_mutex; pthread_cond_t sleep_threshhold; /* Types */ enum test_t { SET_TEST, GET_TEST, MGET_TEST }; struct thread_context_st { unsigned int key_count; pairs_st *initial_pairs; unsigned int initial_number; pairs_st *execute_pairs; unsigned int execute_number; char **keys; size_t *key_lengths; test_t test; memcached_st *memc; const memcached_st* root; thread_context_st(const memcached_st* memc_arg, test_t test_arg) : key_count(0), initial_pairs(NULL), initial_number(0), execute_pairs(NULL), execute_number(0), keys(0), key_lengths(NULL), test(test_arg), memc(NULL), root(memc_arg) { } void init() { memc= memcached_clone(NULL, root); } ~thread_context_st() { if (execute_pairs) { pairs_free(execute_pairs); } memcached_free(memc); } }; struct conclusions_st { long int load_time; long int read_time; unsigned int rows_loaded; unsigned int rows_read; conclusions_st() : load_time(0), read_time(0), rows_loaded(0), rows_read() { } }; /* Prototypes */ void options_parse(int argc, char *argv[]); void conclusions_print(conclusions_st *conclusion); void scheduler(memcached_server_st *servers, conclusions_st *conclusion); pairs_st *load_create_data(memcached_st *memc, unsigned int number_of, unsigned int *actual_loaded); void flush_all(memcached_st *memc); static bool opt_binary= 0; static int opt_verbose= 0; static int opt_flush= 0; static int opt_non_blocking_io= 0; static int opt_tcp_nodelay= 0; static unsigned int opt_execute_number= 0; static unsigned int opt_createial_load= 0; static unsigned int opt_concurrency= 0; static int opt_displayflag= 0; static char *opt_servers= NULL; static bool opt_udp_io= false; test_t opt_test= SET_TEST; extern "C" { static void *run_task(void *p) { thread_context_st *context= (thread_context_st *)p; context->init(); pthread_mutex_lock(&sleeper_mutex); while (master_wakeup) { pthread_cond_wait(&sleep_threshhold, &sleeper_mutex); } pthread_mutex_unlock(&sleeper_mutex); /* Do Stuff */ switch (context->test) { case SET_TEST: assert(context->execute_pairs); execute_set(context->memc, context->execute_pairs, context->execute_number); break; case GET_TEST: execute_get(context->memc, context->initial_pairs, context->initial_number); break; case MGET_TEST: execute_mget(context->memc, (const char*const*)context->keys, context->key_lengths, context->initial_number); break; } delete context; pthread_exit(0); } } int main(int argc, char *argv[]) { conclusions_st conclusion; srandom((unsigned int)time(NULL)); options_parse(argc, argv); if (opt_servers == NULL) { char *temp; if ((temp= getenv("MEMCACHED_SERVERS"))) { opt_servers= strdup(temp); } else { fprintf(stderr, "No Servers provided\n"); return EXIT_FAILURE; } } memcached_server_st *servers= memcached_servers_parse(opt_servers); pthread_mutex_init(&sleeper_mutex, NULL); pthread_cond_init(&sleep_threshhold, NULL); scheduler(servers, &conclusion); free(opt_servers); (void)pthread_mutex_destroy(&sleeper_mutex); (void)pthread_cond_destroy(&sleep_threshhold); conclusions_print(&conclusion); memcached_server_list_free(servers); return EXIT_SUCCESS; } void scheduler(memcached_server_st *servers, conclusions_st *conclusion) { unsigned int actual_loaded= 0; /* Fix warning */ struct timeval start_time, end_time; pairs_st *pairs= NULL; memcached_st *memc= memcached_create(NULL); memcached_server_push(memc, servers); /* We need to set udp behavior before adding servers to the client */ if (opt_udp_io) { if (memcached_failed(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, opt_udp_io))) { std::cerr << "Failed to enable UDP." << std::endl; memcached_free(memc); exit(EXIT_FAILURE); } } memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, (uint64_t)opt_binary); if (opt_flush) { flush_all(memc); } if (opt_createial_load) { pairs= load_create_data(memc, opt_createial_load, &actual_loaded); } char **keys= static_cast(calloc(actual_loaded, sizeof(char*))); size_t *key_lengths= static_cast(calloc(actual_loaded, sizeof(size_t))); if (keys == NULL or key_lengths == NULL) { free(keys); free(key_lengths); keys= NULL; key_lengths= NULL; } else { for (uint32_t x= 0; x < actual_loaded; ++x) { keys[x]= pairs[x].key; key_lengths[x]= pairs[x].key_length; } } /* We set this after we have loaded */ { if (opt_non_blocking_io) memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 1); if (opt_tcp_nodelay) memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1); } pthread_mutex_lock(&sleeper_mutex); master_wakeup= 1; pthread_mutex_unlock(&sleeper_mutex); pthread_t *threads= new (std::nothrow) pthread_t[opt_concurrency]; if (not threads) { exit(EXIT_FAILURE); } for (uint32_t x= 0; x < opt_concurrency; x++) { thread_context_st *context= new thread_context_st(memc, opt_test); context->test= opt_test; context->initial_pairs= pairs; context->initial_number= actual_loaded; context->keys= keys; context->key_lengths= key_lengths; if (opt_test == SET_TEST) { context->execute_pairs= pairs_generate(opt_execute_number, 400); context->execute_number= opt_execute_number; } /* now you create the thread */ if (pthread_create(threads +x, NULL, run_task, (void *)context) != 0) { fprintf(stderr,"Could not create thread\n"); exit(1); } } pthread_mutex_lock(&sleeper_mutex); master_wakeup= 0; pthread_mutex_unlock(&sleeper_mutex); pthread_cond_broadcast(&sleep_threshhold); gettimeofday(&start_time, NULL); for (uint32_t x= 0; x < opt_concurrency; x++) { void *retval; pthread_join(threads[x], &retval); } delete [] threads; gettimeofday(&end_time, NULL); conclusion->load_time= timedif(end_time, start_time); conclusion->read_time= timedif(end_time, start_time); free(keys); free(key_lengths); pairs_free(pairs); memcached_free(memc); } void options_parse(int argc, char *argv[]) { memcached_programs_help_st help_options[]= { {0}, }; static struct option long_options[]= { {(OPTIONSTRING)"concurrency", required_argument, NULL, OPT_SLAP_CONCURRENCY}, {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, {(OPTIONSTRING)"quiet", no_argument, NULL, OPT_QUIET}, {(OPTIONSTRING)"execute-number", required_argument, NULL, OPT_SLAP_EXECUTE_NUMBER}, {(OPTIONSTRING)"flag", no_argument, &opt_displayflag, OPT_FLAG}, {(OPTIONSTRING)"flush", no_argument, &opt_flush, OPT_FLUSH}, {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, {(OPTIONSTRING)"initial-load", required_argument, NULL, OPT_SLAP_INITIAL_LOAD}, /* Number to load initially */ {(OPTIONSTRING)"non-blocking", no_argument, &opt_non_blocking_io, OPT_SLAP_NON_BLOCK}, {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, {(OPTIONSTRING)"tcp-nodelay", no_argument, &opt_tcp_nodelay, OPT_SLAP_TCP_NODELAY}, {(OPTIONSTRING)"test", required_argument, NULL, OPT_SLAP_TEST}, {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, {(OPTIONSTRING)"udp", no_argument, NULL, OPT_UDP}, {0, 0, 0, 0}, }; bool opt_help= false; bool opt_version= false; int option_index= 0; while (1) { int option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) break; switch (option_rv) { case 0: break; case OPT_UDP: if (opt_test == GET_TEST) { fprintf(stderr, "You can not run a get test in UDP mode. UDP mode " "does not currently support get ops.\n"); exit(1); } opt_udp_io= true; break; case OPT_BINARY: opt_binary= true; break; case OPT_VERBOSE: /* --verbose or -v */ opt_verbose= OPT_VERBOSE; break; case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; case OPT_VERSION: /* --version or -V */ opt_version= true; break; case OPT_HELP: /* --help or -h */ opt_help= true; break; case OPT_SERVERS: /* --servers or -s */ opt_servers= strdup(optarg); break; case OPT_SLAP_TEST: if (strcmp(optarg, "get") == 0) { if (opt_udp_io == 1) { fprintf(stderr, "You can not run a get test in UDP mode. UDP mode " "does not currently support get ops.\n"); exit(EXIT_FAILURE); } opt_test= GET_TEST ; } else if (strcmp(optarg, "set") == 0) { opt_test= SET_TEST; } else if (strcmp(optarg, "mget") == 0) { opt_test= MGET_TEST; } else { fprintf(stderr, "Your test, %s, is not a known test\n", optarg); exit(EXIT_FAILURE); } break; case OPT_SLAP_CONCURRENCY: opt_concurrency= (unsigned int)strtoul(optarg, (char **)NULL, 10); break; case OPT_SLAP_EXECUTE_NUMBER: opt_execute_number= (unsigned int)strtoul(optarg, (char **)NULL, 10); break; case OPT_SLAP_INITIAL_LOAD: opt_createial_load= (unsigned int)strtoul(optarg, (char **)NULL, 10); break; case OPT_QUIET: close_stdio(); break; case '?': /* getopt_long already printed an error message. */ exit(EXIT_FAILURE); default: abort(); } } if (opt_version) { version_command(PROGRAM_NAME); exit(EXIT_SUCCESS); } if (opt_help) { help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options); exit(EXIT_SUCCESS); } if ((opt_test == GET_TEST or opt_test == MGET_TEST) and opt_createial_load == 0) opt_createial_load= DEFAULT_INITIAL_LOAD; if (opt_execute_number == 0) opt_execute_number= DEFAULT_EXECUTE_NUMBER; if (opt_concurrency == 0) opt_concurrency= DEFAULT_CONCURRENCY; } void conclusions_print(conclusions_st *conclusion) { printf("\tThreads connecting to servers %u\n", opt_concurrency); #ifdef NOT_FINISHED printf("\tLoaded %u rows\n", conclusion->rows_loaded); printf("\tRead %u rows\n", conclusion->rows_read); #endif if (opt_test == SET_TEST) printf("\tTook %ld.%03ld seconds to load data\n", conclusion->load_time / 1000, conclusion->load_time % 1000); else printf("\tTook %ld.%03ld seconds to read data\n", conclusion->read_time / 1000, conclusion->read_time % 1000); } void flush_all(memcached_st *memc) { memcached_flush(memc, 0); } pairs_st *load_create_data(memcached_st *memc, unsigned int number_of, unsigned int *actual_loaded) { memcached_st *memc_clone= memcached_clone(NULL, memc); /* We always used non-blocking IO for load since it is faster */ memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); pairs_st *pairs= pairs_generate(number_of, 400); *actual_loaded= execute_set(memc_clone, pairs, number_of); memcached_free(memc_clone); return pairs; } libmemcached-1.0.8/clients/memrm.cc0000664000076400007640000001243311753573717017507 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #include "config.h" #include #include #include #include #include #include #include "client_options.h" #include "utilities.h" static int opt_binary= 0; static int opt_verbose= 0; static time_t opt_expire= 0; static char *opt_servers= NULL; static char *opt_hash= NULL; static char *opt_username; static char *opt_passwd; #define PROGRAM_NAME "memrm" #define PROGRAM_DESCRIPTION "Erase a key or set of keys from a memcached cluster." /* Prototypes */ static void options_parse(int argc, char *argv[]); int main(int argc, char *argv[]) { memcached_st *memc; memcached_server_st *servers; options_parse(argc, argv); initialize_sockets(); if (opt_servers == 0) { char *temp; if ((temp= getenv("MEMCACHED_SERVERS"))) { opt_servers= strdup(temp); } else { std::cerr << "No Servers provided" << std::endl; return EXIT_FAILURE; } } memc= memcached_create(NULL); process_hash_option(memc, opt_hash); servers= memcached_servers_parse(opt_servers); memcached_server_push(memc, servers); memcached_server_list_free(servers); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, (uint64_t) opt_binary); if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0) { memcached_free(memc); std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl; return EXIT_FAILURE; } if (opt_username) { memcached_return_t ret; if (memcached_failed(ret= memcached_set_sasl_auth_data(memc, opt_username, opt_passwd))) { std::cerr << memcached_last_error_message(memc) << std::endl; memcached_free(memc); return EXIT_FAILURE; } } int return_code= EXIT_SUCCESS; while (optind < argc) { memcached_return_t rc= memcached_delete(memc, argv[optind], strlen(argv[optind]), opt_expire); if (rc == MEMCACHED_NOTFOUND) { if (opt_verbose) { std::cerr << "Could not find key \"" << argv[optind] << "\"" << std::endl; } } else if (memcached_fatal(rc)) { if (opt_verbose) { std::cerr << "Failed to delete key \"" << argv[optind] << "\" :" << memcached_last_error_message(memc) << std::endl; } return_code= EXIT_FAILURE; } else // success { if (opt_verbose) { std::cout << "Deleted key " << argv[optind]; if (opt_expire) { std::cout << " expires: " << opt_expire << std::endl; } std::cout << std::endl; } } optind++; } memcached_free(memc); if (opt_servers) { free(opt_servers); } if (opt_hash) { free(opt_hash); } return return_code; } static void options_parse(int argc, char *argv[]) { memcached_programs_help_st help_options[]= { {0}, }; static struct option long_options[]= { {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, {(OPTIONSTRING)"quiet", no_argument, NULL, OPT_QUIET}, {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, {(OPTIONSTRING)"expire", required_argument, NULL, OPT_EXPIRE}, {(OPTIONSTRING)"hash", required_argument, NULL, OPT_HASH}, {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, {(OPTIONSTRING)"username", required_argument, NULL, OPT_USERNAME}, {(OPTIONSTRING)"password", required_argument, NULL, OPT_PASSWD}, {0, 0, 0, 0}, }; bool opt_version= false; bool opt_help= false; int option_index= 0; while (1) { int option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) { break; } switch (option_rv) { case 0: break; case OPT_BINARY: opt_binary = 1; break; case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = OPT_VERBOSE; break; case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; case OPT_VERSION: /* --version or -V */ opt_version= true; break; case OPT_HELP: /* --help or -h */ opt_help= true; break; case OPT_SERVERS: /* --servers or -s */ opt_servers= strdup(optarg); break; case OPT_EXPIRE: /* --expire */ opt_expire= (time_t)strtoll(optarg, (char **)NULL, 10); break; case OPT_HASH: opt_hash= strdup(optarg); break; case OPT_USERNAME: opt_username= optarg; break; case OPT_PASSWD: opt_passwd= optarg; break; case OPT_QUIET: close_stdio(); break; case '?': /* getopt_long already printed an error message. */ exit(EXIT_SUCCESS); default: abort(); } } if (opt_version) { version_command(PROGRAM_NAME); exit(EXIT_SUCCESS); } if (opt_help) { help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options); exit(EXIT_SUCCESS); } } libmemcached-1.0.8/clients/ms_setting.h0000664000076400007640000001451711753573717020415 0ustar00brianbrian00000000000000/* * File: ms_setting.h * Author: Mingqiang Zhuang * * Created on February 10, 2009 * * (c) Copyright 2009, Schooner Information Technology, Inc. * http://www.schoonerinfotech.com/ * */ #ifndef MS_SETTING_H #define MS_SETTING_H #include "ms_memslap.h" #ifdef __cplusplus extern "C" { #endif #define MCD_SRVS_NUM_INIT 8 #define MCD_HOST_LENGTH 64 #define KEY_RANGE_COUNT_INIT 8 #define VALUE_RANGE_COUNT_INIT 8 #define PROP_ERROR 0.001 #define MIN_KEY_SIZE 16 #define MAX_KEY_SIZE 250 #define MAX_VALUE_SIZE (1024 * 1024) /* the content of the configuration file for memslap running without configuration file */ #define DEFAULT_CONGIF_STR \ "key\n" \ "64 64 1\n" \ "value\n" \ "1024 1024 1\n" \ "cmd\n" \ "0 0.1\n" \ "1 0.9" /* Used to parse the value length return by server and path string */ typedef struct token_s { char *value; size_t length; } token_t; #define MAX_TOKENS 10 /* server information */ typedef struct mcd_sever { char srv_host_name[MCD_HOST_LENGTH]; /* host name of server */ int srv_port; /* server port */ /* for calculating how long the server disconnects */ volatile uint32_t disconn_cnt; /* number of disconnections count */ volatile uint32_t reconn_cnt; /* number of reconnections count */ struct timeval disconn_time; /* start time of disconnection */ struct timeval reconn_time; /* end time of reconnection */ } ms_mcd_server_t; /* information of an item distribution including key and value */ typedef struct distr { size_t key_size; /* size of key */ int key_offset; /* offset of one key in character block */ size_t value_size; /* size of value */ } ms_distr_t; /* information of key distribution */ typedef struct key_distr { size_t start_len; /* start of the key length range */ size_t end_len; /* end of the key length range */ double key_prop; /* key proportion */ } ms_key_distr_t; /* information of value distribution */ typedef struct value_distr { size_t start_len; /* start of the value length range */ size_t end_len; /* end of the value length range */ double value_prop; /* value proportion */ } ms_value_distr_t; /* memcached command types */ typedef enum cmd_type { CMD_SET, CMD_GET, CMD_NULL } ms_cmd_type_t; /* types in the configuration file */ typedef enum conf_type { CONF_KEY, CONF_VALUE, CONF_CMD, CONF_NULL } ms_conf_type_t; /* information of command distribution */ typedef struct cmd_distr { ms_cmd_type_t cmd_type; /* command type */ double cmd_prop; /* proportion of the command */ } ms_cmd_distr_t; /* global setting structure */ typedef struct setting { uint32_t ncpu; /* cpu count of this system */ uint32_t nthreads; /* total thread count, must equal or less than cpu cores */ uint32_t nconns; /* total conn count, must multiply by total thread count */ int64_t exec_num; /* total execute number */ int run_time; /* total run time */ uint32_t char_blk_size; /* global character block size */ char *char_block; /* global character block with random character */ ms_distr_t *distr; /* distribution from configure file */ char *srv_str; /* string includes servers information */ char *cfg_file; /* configure file name */ ms_mcd_server_t *servers; /* servers array */ uint32_t total_srv_cnt; /* total servers count of the servers array */ uint32_t srv_cnt; /* servers count */ ms_key_distr_t *key_distr; /* array of key distribution */ int total_key_rng_cnt; /* total key range count of the array */ int key_rng_cnt; /* actual key range count */ ms_value_distr_t *value_distr; /* array of value distribution */ int total_val_rng_cnt; /* total value range count of the array */ int val_rng_cnt; /* actual value range count */ ms_cmd_distr_t cmd_distr[CMD_NULL]; /* total we have CMD_NULL commands */ int cmd_used_count; /* supported command count */ size_t fixed_value_size; /* fixed value size */ size_t avg_val_size; /* average value size */ size_t avg_key_size; /* average value size */ double verify_percent; /* percent of data verification */ double exp_ver_per; /* percent of data verification with expire time */ double overwrite_percent; /* percent of overwrite */ int mult_key_num; /* number of keys used by multi-get once */ size_t win_size; /* item window size per connection */ bool udp; /* whether or not use UDP */ int stat_freq; /* statistic frequency second */ bool reconnect; /* whether it reconnect when connection close */ bool verbose; /* whether it outputs detailed information when verification */ bool facebook_test; /* facebook test, TCP set and multi-get with UDP */ uint32_t sock_per_conn; /* number of socks per connection structure */ bool binary_prot; /* whether it use binary protocol */ int expected_tps; /* expected throughput */ uint32_t rep_write_srv; /* which servers are used to do replication writing */ } ms_setting_st; extern ms_setting_st ms_setting; /* previous part of initialization of setting structure */ void ms_setting_init_pre(void); /* post part of initialization of setting structure */ void ms_setting_init_post(void); /* clean up the global setting structure */ void ms_setting_cleanup(void); #define UNUSED_ARGUMENT(x) (void)x #ifdef __cplusplus } #endif #endif /* end of MS_SETTING_H */ libmemcached-1.0.8/clients/ms_setting.c0000664000076400007640000006466411753573717020420 0ustar00brianbrian00000000000000/* * File: ms_setting.c * Author: Mingqiang Zhuang * * Created on February 10, 2009 * * (c) Copyright 2009, Schooner Information Technology, Inc. * http://www.schoonerinfotech.com/ * */ #include "config.h" #include #include #include #include #include #include #include #include #include "ms_setting.h" #include "ms_conn.h" #define MAX_EXEC_NUM 0x4000000000000000 /* 1 << 62 */ #define ADDR_ALIGN(addr) ((addr + 15) & ~(16 - 1)) /* 16 bytes aligned */ #define RAND_CHAR_SIZE (10 * 1024 * 1024) /* 10M character table */ #define RESERVED_RAND_CHAR_SIZE (2 * 1024 * 1024) /* reserved 2M to avoid pointer sloping over */ #define DEFAULT_CONFIG_NAME ".memslap.cnf" #define DEFAULT_THREADS_NUM 1 /* default start one thread */ #define DEFAULT_CONNS_NUM 16 /* default each thread with 16 connections */ #define DEFAULT_EXE_NUM 0 /* default execute number is 0 */ #define DEFAULT_VERIFY_RATE 0.0 /* default it doesn't do data verification */ #define DEFAULT_OVERWRITE_RATE 0.0 /* default it doesn't do overwrite */ #define DEFAULT_DIV 1 /* default it runs single get */ #define DEFAULT_RUN_TIME 600 /* default run time 10 minutes */ #define DEFAULT_WINDOW_SIZE (10 * UNIT_ITEMS_COUNT) /* default window size is 10k */ #define DEFAULT_SOCK_PER_CONN 1 /* default socks per connection is 1 */ /* Use this for string generation */ #define CHAR_COUNT 64 /* number of characters used to generate character table */ const char ALPHANUMBERICS[]= "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-"; ms_setting_st ms_setting; /* store the settings specified by user */ /* read setting from configuration file */ static void ms_get_serverlist(char *str); static uint32_t ms_get_cpu_count(void); ms_conf_type_t ms_get_conf_type(char *line); static int ms_is_line_data(char *line); static int ms_read_is_data(char *line, ssize_t nread); static void ms_no_config_file(void); static void ms_parse_cfg_file(char *cfg_file); /* initialize setting structure */ static void ms_init_random_block(void); static void ms_calc_avg_size(void); static int ms_shuffle_distr(ms_distr_t *distr, int length); static void ms_build_distr(void); static void ms_print_setting(void); static void ms_setting_slapmode_init_pre(void); static void ms_setting_slapmode_init_post(void); #if !defined(HAVE_GETLINE) #include static ssize_t getline (char **line, size_t *line_size, FILE *fp) { char delim= '\n'; ssize_t result= 0; size_t cur_len= 0; if (line == NULL || line_size == NULL || fp == NULL) { errno = EINVAL; return -1; } if (*line == NULL || *line_size == 0) { char *new_line; *line_size = 120; new_line= (char *) realloc (*line, *line_size); if (new_line == NULL) { result= -1; return result; } *line= new_line; } for (;;) { int i= getc(fp); if (i == EOF) { result = -1; break; } /* Make enough space for len+1 (for final NUL) bytes. */ if (cur_len + 1 >= *line_size) { size_t needed_max= SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; size_t needed= (2 * (*line_size)) + 1; char *new_line; if (needed_max < needed) needed= needed_max; if (cur_len + 1 >= needed) { result= -1; errno= EOVERFLOW; return result; } new_line= (char *)realloc(*line, needed); if (new_line == NULL) { result= -1; return result; } *line= new_line; *line_size= needed; } (*line)[cur_len]= (char)i; cur_len++; if (i == delim) break; } (*line)[cur_len] = '\0'; if (cur_len != 0) return (ssize_t)cur_len; return result; } #endif /** * parse the server list string, and build the servers * information structure array. this function is used to parse * the command line options specified by user. * * @param str, the string of server list */ static void ms_get_serverlist(char *str) { ms_mcd_server_t *srvs= NULL; /** * Servers list format is like this. For example: * "localhost:11108, localhost:11109" */ memcached_server_st *server_pool; server_pool = memcached_servers_parse(str); for (uint32_t loop= 0; loop < memcached_server_list_count(server_pool); loop++) { assert(ms_setting.srv_cnt < ms_setting.total_srv_cnt); strcpy(ms_setting.servers[ms_setting.srv_cnt].srv_host_name, server_pool[loop].hostname); ms_setting.servers[ms_setting.srv_cnt].srv_port= server_pool[loop].port; ms_setting.servers[ms_setting.srv_cnt].disconn_cnt= 0; ms_setting.servers[ms_setting.srv_cnt].reconn_cnt= 0; ms_setting.srv_cnt++; if (ms_setting.srv_cnt >= ms_setting.total_srv_cnt) { srvs= (ms_mcd_server_t *)realloc( ms_setting.servers, (size_t)ms_setting.total_srv_cnt * sizeof(ms_mcd_server_t) * 2); if (srvs == NULL) { fprintf(stderr, "Can't reallocate servers structure.\n"); exit(1); } ms_setting.servers= srvs; ms_setting.total_srv_cnt*= 2; } } memcached_server_free(server_pool); } /* ms_get_serverlist */ /** * used to get the CPU count of the current system * * @return return the cpu count if get, else return EXIT_FAILURE */ static uint32_t ms_get_cpu_count() { #ifdef HAVE__SC_NPROCESSORS_ONLN return sysconf(_SC_NPROCESSORS_CONF); #else # ifdef HAVE_CPU_SET_T int cpu_count= 0; cpu_set_t cpu_set; sched_getaffinity(0, sizeof(cpu_set_t), &cpu_set); for (int i= 0; i < (sizeof(cpu_set_t) * 8); i++) { if (CPU_ISSET(i, &cpu_set)) { cpu_count++; } } return cpu_count; # endif #endif /* the system with one cpu at least */ return EXIT_FAILURE; } /* ms_get_cpu_count */ /** * used to get the configure type based on the type string read * from the configuration file. * * @param line, string of one line * * @return ms_conf_type_t */ ms_conf_type_t ms_get_conf_type(char *line) { if (! memcmp(line, "key", strlen("key"))) { return CONF_KEY; } else if (! memcmp(line, "value", strlen("value"))) { return CONF_VALUE; } else if (! memcmp(line, "cmd", strlen("cmd"))) { return CONF_CMD; } else { return CONF_NULL; } } /* ms_get_conf_type */ /** * judge whether the line is a line with useful data. used to * parse the configuration file. * * @param line, string of one line * * @return if success, return EXIT_FAILURE, else return EXIT_SUCCESS */ static int ms_is_line_data(char *line) { assert(line != NULL); char *begin_ptr= line; while (isspace(*begin_ptr)) { begin_ptr++; } if ((begin_ptr[0] == '\0') || (begin_ptr[0] == '#')) return EXIT_SUCCESS; return EXIT_FAILURE; } /* ms_is_line_data */ /** * function to bypass blank line and comments * * @param line, string of one line * @param nread, length of the line * * @return if it's EOF or not line data, return EXIT_SUCCESS, else return EXIT_FAILURE */ static int ms_read_is_data(char *line, ssize_t nread) { if ((nread == EOF) || ! ms_is_line_data(line)) return EXIT_SUCCESS; return EXIT_FAILURE; } /* ms_read_is_data */ /** * if no configuration file, use this function to create the default * configuration file. */ static void ms_no_config_file() { char userpath[PATH_MAX]; struct passwd *usr= NULL; FILE *fd; usr= getpwuid(getuid()); snprintf(userpath, PATH_MAX, "%s/%s", usr->pw_dir, DEFAULT_CONFIG_NAME); if (access (userpath, F_OK | R_OK) == 0) goto exit; fd= fopen(userpath, "w+"); if (fd == NULL) { fprintf(stderr, "Could not create default configure file %s\n", userpath); perror(strerror(errno)); exit(1); } fprintf(fd, "%s", DEFAULT_CONGIF_STR); fclose(fd); exit: ms_setting.cfg_file= strdup(userpath); } /* ms_no_config_file */ /** * parse the configuration file * * @param cfg_file, the configuration file name */ static void ms_parse_cfg_file(char *cfg_file) { FILE *f; size_t start_len, end_len; double proportion; char *line= NULL; size_t read_len; ssize_t nread; int cmd_type; ms_conf_type_t conf_type; int end_of_file= 0; ms_key_distr_t *key_distr= NULL; ms_value_distr_t *val_distr= NULL; if (cfg_file == NULL) { ms_no_config_file(); cfg_file= ms_setting.cfg_file; } /*read key value configure file*/ if ((f= fopen(cfg_file, "r")) == NULL) { fprintf(stderr, "Can not open file: '%s'.\n", cfg_file); exit(1); } while (1) { if ((((nread= getline(&line, &read_len, f)) == 1) || ! ms_read_is_data(line, nread)) && (nread != EOF)) /* bypass blank line */ continue; if (nread == EOF) { fprintf(stderr, "Bad configuration file, no configuration find.\n"); exit(1); } conf_type= ms_get_conf_type(line); break; } while (! end_of_file) { switch (conf_type) { case CONF_KEY: while (1) { if ((((nread= getline(&line, &read_len, f)) == 1) || ! ms_read_is_data(line, nread)) && (nread != EOF)) /* bypass blank line */ continue; if (nread != EOF) { if (sscanf(line, "%zu %zu %lf ", &start_len, &end_len, &proportion) != 3) { conf_type= ms_get_conf_type(line); break; } ms_setting.key_distr[ms_setting.key_rng_cnt].start_len= start_len; ms_setting.key_distr[ms_setting.key_rng_cnt].end_len= end_len; ms_setting.key_distr[ms_setting.key_rng_cnt].key_prop= proportion; ms_setting.key_rng_cnt++; if (ms_setting.key_rng_cnt >= ms_setting.total_key_rng_cnt) { key_distr= (ms_key_distr_t *)realloc( ms_setting.key_distr, (size_t)ms_setting. total_key_rng_cnt * sizeof(ms_key_distr_t) * 2); if (key_distr == NULL) { fprintf(stderr, "Can't reallocate key distribution structure.\n"); exit(1); } ms_setting.key_distr= key_distr; ms_setting.total_key_rng_cnt*= 2; } continue; } end_of_file= 1; break; } break; case CONF_VALUE: while (1) { if ((((nread= getline(&line, &read_len, f)) == 1) || ! ms_read_is_data(line, nread)) && (nread != EOF)) /* bypass blank line */ continue; if (nread != EOF) { if (sscanf(line, "%zu %zu %lf", &start_len, &end_len, &proportion) != 3) { conf_type= ms_get_conf_type(line); break; } ms_setting.value_distr[ms_setting.val_rng_cnt].start_len= start_len; ms_setting.value_distr[ms_setting.val_rng_cnt].end_len= end_len; ms_setting.value_distr[ms_setting.val_rng_cnt].value_prop= proportion; ms_setting.val_rng_cnt++; if (ms_setting.val_rng_cnt >= ms_setting.total_val_rng_cnt) { val_distr= (ms_value_distr_t *)realloc( ms_setting.value_distr, (size_t)ms_setting. total_val_rng_cnt * sizeof(ms_value_distr_t) * 2); if (val_distr == NULL) { fprintf(stderr, "Can't reallocate key distribution structure.\n"); exit(1); } ms_setting.value_distr= val_distr; ms_setting.total_val_rng_cnt*= 2; } continue; } end_of_file= 1; break; } break; case CONF_CMD: while (1) { if ((((nread= getline(&line, &read_len, f)) == 1) || ! ms_read_is_data(line, nread)) && (nread != EOF)) /* bypass blank line */ continue; if (nread != EOF) { if (sscanf(line, "%d %lf", &cmd_type, &proportion) != 2) { conf_type= ms_get_conf_type(line); break; } if (cmd_type >= CMD_NULL) { continue; } ms_setting.cmd_distr[ms_setting.cmd_used_count].cmd_type= cmd_type; ms_setting.cmd_distr[ms_setting.cmd_used_count].cmd_prop= proportion; ms_setting.cmd_used_count++; continue; } end_of_file= 1; break; } case CONF_NULL: while (1) { if ((((nread= getline(&line, &read_len, f)) == 1) || ! ms_read_is_data(line, nread)) && (nread != EOF)) /* bypass blank line */ continue; if (nread != EOF) { if ((conf_type= ms_get_conf_type(line)) != CONF_NULL) { break; } continue; } end_of_file= 1; break; } break; default: assert(0); break; } /* switch */ } fclose(f); if (line != NULL) { free(line); } } /* ms_parse_cfg_file */ /* calculate the average size of key and value */ static void ms_calc_avg_size() { double avg_val_size= 0.0; double avg_key_size= 0.0; double val_pro= 0.0; double key_pro= 0.0; double averge_len= 0.0; size_t start_len= 0; size_t end_len= 0; for (int j= 0; j < ms_setting.val_rng_cnt; j++) { val_pro= ms_setting.value_distr[j].value_prop; start_len= ms_setting.value_distr[j].start_len; end_len= ms_setting.value_distr[j].end_len; averge_len= val_pro * ((double)(start_len + end_len)) / 2; avg_val_size+= averge_len; } for (int j= 0; j < ms_setting.key_rng_cnt; j++) { key_pro= ms_setting.key_distr[j].key_prop; start_len= ms_setting.key_distr[j].start_len; end_len= ms_setting.key_distr[j].end_len; averge_len= key_pro * ((double)(start_len + end_len)) / 2; avg_key_size+= averge_len; } ms_setting.avg_val_size= (size_t)avg_val_size; ms_setting.avg_key_size= (size_t)avg_key_size; } /* ms_calc_avg_size */ /** * used to shuffle key and value distribution array to ensure * (key, value) pair with different set. * * @param distr, pointer of distribution structure array * @param length, length of the array * * @return always return EXIT_SUCCESS */ static int ms_shuffle_distr(ms_distr_t *distr, int length) { int i, j; int tmp_offset; size_t tmp_size; int64_t rnd; for (i= 0; i < length; i++) { rnd= random(); j= (int)(rnd % (length - i)) + i; switch (rnd % 3) { case 0: tmp_size= distr[j].key_size; distr[j].key_size= distr[i].key_size; distr[i].key_size= tmp_size; break; case 1: tmp_offset= distr[j].key_offset; distr[j].key_offset= distr[i].key_offset; distr[i].key_offset= tmp_offset; break; case 2: tmp_size= distr[j].value_size; distr[j].value_size= distr[i].value_size; distr[i].value_size= tmp_size; break; default: break; } /* switch */ } return EXIT_SUCCESS; } /* ms_shuffle_distr */ /** * according to the key and value distribution, to build the * (key, value) pair distribution. the (key, value) pair * distribution array is global, each connection set or get * object keeping this distribution, for the final result, we * can reach the expected key and value distribution. */ static void ms_build_distr() { int offset= 0; int end= 0; int key_cnt= 0; int value_cnt= 0; size_t average_len= 0; size_t diff_len= 0; size_t start_len= 0; size_t end_len= 0; int rnd= 0; ms_distr_t *distr= NULL; int units= (int)ms_setting.win_size / UNIT_ITEMS_COUNT; /* calculate average value size and key size */ ms_calc_avg_size(); ms_setting.char_blk_size= RAND_CHAR_SIZE; int key_scope_size= (int)((ms_setting.char_blk_size - RESERVED_RAND_CHAR_SIZE) / UNIT_ITEMS_COUNT); ms_setting.distr= (ms_distr_t *)malloc( sizeof(ms_distr_t) * ms_setting.win_size); if (ms_setting.distr == NULL) { fprintf(stderr, "Can't allocate distribution array."); exit(1); } /** * character block is divided by how many different key * size, each different key size has the same size character * range. */ for (int m= 0; m < units; m++) { for (int i= 0; i < UNIT_ITEMS_COUNT; i++) { ms_setting.distr[m * UNIT_ITEMS_COUNT + i].key_offset= ADDR_ALIGN(key_scope_size * i); } } /* initialize key size distribution */ for (int m= 0; m < units; m++) { for (int j= 0; j < ms_setting.key_rng_cnt; j++) { key_cnt= (int)(UNIT_ITEMS_COUNT * ms_setting.key_distr[j].key_prop); start_len= ms_setting.key_distr[j].start_len; end_len= ms_setting.key_distr[j].end_len; if ((start_len < MIN_KEY_SIZE) || (end_len < MIN_KEY_SIZE)) { fprintf(stderr, "key length must be greater than 16 bytes.\n"); exit(1); } if (! ms_setting.binary_prot && ((start_len > MAX_KEY_SIZE) || (end_len > MAX_KEY_SIZE))) { fprintf(stderr, "key length must be less than 250 bytes.\n"); exit(1); } average_len= (start_len + end_len) / 2; diff_len= (end_len - start_len) / 2; for (int k= 0; k < key_cnt; k++) { if (offset >= (m + 1) * UNIT_ITEMS_COUNT) { break; } rnd= (int)random(); if (k % 2 == 0) { ms_setting.distr[offset].key_size= (diff_len == 0) ? average_len : average_len + (size_t)rnd % diff_len; } else { ms_setting.distr[offset].key_size= (diff_len == 0) ? average_len : average_len - (size_t)rnd % diff_len; } offset++; } } if (offset < (m + 1) * UNIT_ITEMS_COUNT) { end= (m + 1) * UNIT_ITEMS_COUNT - offset; for (int i= 0; i < end; i++) { ms_setting.distr[offset].key_size= ms_setting.avg_key_size; offset++; } } } offset= 0; /* initialize value distribution */ if (ms_setting.fixed_value_size != 0) { for (int i= 0; i < units * UNIT_ITEMS_COUNT; i++) { ms_setting.distr[i].value_size= ms_setting.fixed_value_size; } } else { for (int m= 0; m < units; m++) { for (int j= 0; j < ms_setting.val_rng_cnt; j++) { value_cnt= (int)(UNIT_ITEMS_COUNT * ms_setting.value_distr[j].value_prop); start_len= ms_setting.value_distr[j].start_len; end_len= ms_setting.value_distr[j].end_len; if ((start_len <= 0) || (end_len <= 0)) { fprintf(stderr, "value length must be greater than 0 bytes.\n"); exit(1); } if ((start_len > MAX_VALUE_SIZE) || (end_len > MAX_VALUE_SIZE)) { fprintf(stderr, "key length must be less than or equal to 1M.\n"); exit(1); } average_len= (start_len + end_len) / 2; diff_len= (end_len - start_len) / 2; for (int k= 0; k < value_cnt; k++) { if (offset >= (m + 1) * UNIT_ITEMS_COUNT) { break; } rnd= (int)random(); if (k % 2 == 0) { ms_setting.distr[offset].value_size= (diff_len == 0) ? average_len : average_len + (size_t)rnd % diff_len; } else { ms_setting.distr[offset].value_size= (diff_len == 0) ? average_len : average_len - (size_t)rnd % diff_len; } offset++; } } if (offset < (m + 1) * UNIT_ITEMS_COUNT) { end= (m + 1) * UNIT_ITEMS_COUNT - offset; for (int i= 0; i < end; i++) { ms_setting.distr[offset++].value_size= ms_setting.avg_val_size; } } } } /* shuffle distribution */ for (int i= 0; i < units; i++) { distr= &ms_setting.distr[i * UNIT_ITEMS_COUNT]; for (int j= 0; j < 4; j++) { ms_shuffle_distr(distr, UNIT_ITEMS_COUNT); } } } /* ms_build_distr */ /** * used to initialize the global character block. The character * block is used to generate the suffix of the key and value. we * only store a pointer in the character block for each key * suffix or value string. It can save much memory to store key * or value string. */ static void ms_init_random_block() { char *ptr= NULL; assert(ms_setting.char_blk_size > 0); ms_setting.char_block= (char *)malloc(ms_setting.char_blk_size); if (ms_setting.char_block == NULL) { fprintf(stderr, "Can't allocate global char block."); exit(1); } ptr= ms_setting.char_block; for (int i= 0; (size_t)i < ms_setting.char_blk_size; i++) { *(ptr++)= ALPHANUMBERICS[random() % CHAR_COUNT]; } } /* ms_init_random_block */ /** * after initialization, call this function to output the main * configuration user specified. */ static void ms_print_setting() { fprintf(stdout, "servers : %s\n", ms_setting.srv_str); fprintf(stdout, "threads count: %d\n", ms_setting.nthreads); fprintf(stdout, "concurrency: %d\n", ms_setting.nconns); if (ms_setting.run_time > 0) { fprintf(stdout, "run time: %ds\n", ms_setting.run_time); } else { fprintf(stdout, "execute number: %" PRId64 "\n", ms_setting.exec_num); } fprintf(stdout, "windows size: %" PRId64 "k\n", (int64_t)(ms_setting.win_size / 1024)); fprintf(stdout, "set proportion: set_prop=%.2f\n", ms_setting.cmd_distr[CMD_SET].cmd_prop); fprintf(stdout, "get proportion: get_prop=%.2f\n", ms_setting.cmd_distr[CMD_GET].cmd_prop); fflush(stdout); } /* ms_print_setting */ /** * previous part of slap mode initialization of setting structure */ static void ms_setting_slapmode_init_pre() { ms_setting.exec_num= DEFAULT_EXE_NUM; ms_setting.verify_percent= DEFAULT_VERIFY_RATE; ms_setting.exp_ver_per= DEFAULT_VERIFY_RATE; ms_setting.overwrite_percent= DEFAULT_OVERWRITE_RATE; ms_setting.mult_key_num= DEFAULT_DIV; ms_setting.fixed_value_size= 0; ms_setting.win_size= DEFAULT_WINDOW_SIZE; ms_setting.udp= false; ms_setting.reconnect= false; ms_setting.verbose= false; ms_setting.facebook_test= false; ms_setting.binary_prot= false; ms_setting.stat_freq= 0; ms_setting.srv_str= NULL; ms_setting.cfg_file= NULL; ms_setting.sock_per_conn= DEFAULT_SOCK_PER_CONN; ms_setting.expected_tps= 0; ms_setting.rep_write_srv= 0; } /* ms_setting_slapmode_init_pre */ /** * previous part of initialization of setting structure */ void ms_setting_init_pre() { memset(&ms_setting, 0, sizeof(ms_setting)); /* common initialize */ ms_setting.ncpu= ms_get_cpu_count(); ms_setting.nthreads= DEFAULT_THREADS_NUM; ms_setting.nconns= DEFAULT_CONNS_NUM; ms_setting.run_time= DEFAULT_RUN_TIME; ms_setting.total_srv_cnt= MCD_SRVS_NUM_INIT; ms_setting.servers= (ms_mcd_server_t *)malloc( (size_t)ms_setting.total_srv_cnt * sizeof(ms_mcd_server_t)); if (ms_setting.servers == NULL) { fprintf(stderr, "Can't allocate servers structure.\n"); exit(1); } ms_setting_slapmode_init_pre(); } /* ms_setting_init_pre */ /** * post part of slap mode initialization of setting structure */ static void ms_setting_slapmode_init_post() { ms_setting.total_key_rng_cnt= KEY_RANGE_COUNT_INIT; ms_setting.key_distr= (ms_key_distr_t *)malloc((size_t)ms_setting.total_key_rng_cnt * sizeof(ms_key_distr_t)); if (ms_setting.key_distr == NULL) { fprintf(stderr, "Can't allocate key distribution structure.\n"); exit(1); } ms_setting.total_val_rng_cnt= VALUE_RANGE_COUNT_INIT; ms_setting.value_distr= (ms_value_distr_t *)malloc((size_t)ms_setting.total_val_rng_cnt * sizeof( ms_value_distr_t)); if (ms_setting.value_distr == NULL) { fprintf(stderr, "Can't allocate value distribution structure.\n"); exit(1); } ms_parse_cfg_file(ms_setting.cfg_file); /* run time mode */ if ((ms_setting.exec_num == 0) && (ms_setting.run_time != 0)) { ms_setting.exec_num= (int64_t)MAX_EXEC_NUM; } else { /* execute number mode */ ms_setting.run_time= 0; } if (ms_setting.rep_write_srv > 0) { /* for replication test, need enable reconnect feature */ ms_setting.reconnect= true; } if (ms_setting.facebook_test && (ms_setting.mult_key_num < 2)) { fprintf(stderr, "facebook test must work with multi-get, " "please specify multi-get key number " "with '--division' option.\n"); exit(1); } if (ms_setting.facebook_test && ms_setting.udp) { fprintf(stderr, "facebook test couldn't work with UDP.\n"); exit(1); } if (ms_setting.udp && (ms_setting.sock_per_conn > 1)) { fprintf(stderr, "UDP doesn't support multi-socks " "in one connection structure.\n"); exit(1); } if ((ms_setting.rep_write_srv > 0) && (ms_setting.srv_cnt < 2)) { fprintf(stderr, "Please specify 2 servers at least for replication\n"); exit(1); } if ((ms_setting.rep_write_srv > 0) && (ms_setting.srv_cnt < ms_setting.rep_write_srv)) { fprintf(stderr, "Servers to do replication writing " "is larger than the total servers\n"); exit(1); } if (ms_setting.udp && (ms_setting.rep_write_srv > 0)) { fprintf(stderr, "UDP doesn't support replication.\n"); exit(1); } if (ms_setting.facebook_test && (ms_setting.rep_write_srv > 0)) { fprintf(stderr, "facebook test couldn't work with replication.\n"); exit(1); } ms_build_distr(); /* initialize global character block */ ms_init_random_block(); ms_print_setting(); } /* ms_setting_slapmode_init_post */ /** * post part of initialization of setting structure */ void ms_setting_init_post() { ms_get_serverlist(ms_setting.srv_str); ms_setting_slapmode_init_post(); } /** * clean up the global setting structure */ void ms_setting_cleanup() { if (ms_setting.distr != NULL) { free(ms_setting.distr); } if (ms_setting.char_block != NULL) { free(ms_setting.char_block); } if (ms_setting.srv_str != NULL) { free(ms_setting.srv_str); } if (ms_setting.cfg_file != NULL) { free(ms_setting.cfg_file); } if (ms_setting.servers != NULL) { free(ms_setting.servers); } if (ms_setting.key_distr != NULL) { free(ms_setting.key_distr); } if (ms_setting.value_distr != NULL) { free(ms_setting.value_distr); } } /* ms_setting_cleanup */ libmemcached-1.0.8/clients/memerror.cc0000664000076400007640000000466411753573717020231 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #include "config.h" #include #include #include #include #include #include #include #include #include #include "utilities.h" #define PROGRAM_NAME "memerror" #define PROGRAM_DESCRIPTION "Translate a memcached errror code into a string." /* Prototypes */ void options_parse(int argc, char *argv[]); int main(int argc, char *argv[]) { options_parse(argc, argv); if (argc < 2) { return EXIT_FAILURE; } while (optind < argc) { errno= 0; char *nptr; unsigned long value= strtoul(argv[optind], &nptr, 10); if ((nptr == argv[optind] and value == 0) or (value == ULONG_MAX and errno == ERANGE) or (value == 0 and errno == EINVAL)) { std::cerr << "strtoul() was unable to parse given value" << std::endl; return EXIT_FAILURE; } if (value < MEMCACHED_MAXIMUM_RETURN) { std::cout << memcached_strerror(NULL, (memcached_return_t)value) << std::endl; } else { std::cerr << memcached_strerror(NULL, MEMCACHED_MAXIMUM_RETURN) << std::endl; return EXIT_FAILURE; } optind++; } return EXIT_SUCCESS; } void options_parse(int argc, char *argv[]) { static struct option long_options[]= { {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, {0, 0, 0, 0}, }; bool opt_version= false; bool opt_help= false; int option_index= 0; while (1) { int option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) { break; } switch (option_rv) { case 0: break; case OPT_VERSION: /* --version or -V */ opt_version= true; break; case OPT_HELP: /* --help or -h */ opt_help= true; break; case '?': /* getopt_long already printed an error message. */ exit(EXIT_FAILURE); default: exit(EXIT_FAILURE); } } if (opt_version) { version_command(PROGRAM_NAME); exit(EXIT_SUCCESS); } if (opt_help) { help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, NULL); exit(EXIT_SUCCESS); } } libmemcached-1.0.8/clients/ms_thread.h0000664000076400007640000000510011753573717020173 0ustar00brianbrian00000000000000/* * File: ms_thread.h * Author: Mingqiang Zhuang * * Created on February 10, 2009 * * (c) Copyright 2009, Schooner Information Technology, Inc. * http://www.schoonerinfotech.com/ * */ /** * Asynchronous memslap has the similar implementation of * multi-threads with memcached. Asynchronous memslap creates * one or more self-governed threads; each thread is bound with * one CPU core if the system supports setting CPU core * affinity. And every thread has private variables. There is * less communication or some shared resources among all the * threads. It can improve the performance because there are * fewer locks and competition. In addition, each thread has a * libevent to manage the events of network. Each thread has one * or more self-governed concurrencies; each concurrency has one * or more socket connections. All the concurrencies don't * communicate with each other even though they are in the same * thread. */ #ifndef MS_THREAD_H #define MS_THREAD_H #include #include "ms_conn.h" #ifdef __cplusplus extern "C" { #endif /** Time relative to server start. Smaller than time_t on 64-bit systems. */ typedef unsigned int rel_time_t; /* Used to store the context of each thread */ typedef struct thread_ctx { uint32_t thd_idx; /* the thread index */ uint32_t nconns; /* how many connections included by the thread */ uint32_t srv_idx; /* index of the thread */ int tps_perconn; /* expected throughput per connection */ int64_t exec_num_perconn; /* execute number per connection */ } ms_thread_ctx_t; /* Used to store the private variables of each thread */ typedef struct thread { ms_conn_t *conn; /* conn array to store all the conn in the thread */ uint32_t nactive_conn; /* how many connects are active */ ms_thread_ctx_t *thread_ctx; /* thread context from the caller */ struct event_base *base; /* libevent handler created by this thread */ rel_time_t curr_time; /* current time */ struct event clock_event; /* clock event to time each one second */ bool initialized; /* whether clock_event has been initialized */ struct timeval startup_time; /* start time of the thread */ } ms_thread_t; /* initialize threads */ void ms_thread_init(void); /* cleanup some resource of threads when all the threads exit */ void ms_thread_cleanup(void); #ifdef __cplusplus } #endif #endif /* end of MS_THREAD_H */ libmemcached-1.0.8/clients/memcat.cc0000664000076400007640000001451611753573717017644 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #include #include #include #include #include #include #include #include "utilities.h" #define PROGRAM_NAME "memcat" #define PROGRAM_DESCRIPTION "Cat a set of key values to stdout." /* Prototypes */ void options_parse(int argc, char *argv[]); static int opt_binary= 0; static int opt_verbose= 0; static int opt_displayflag= 0; static char *opt_servers= NULL; static char *opt_hash= NULL; static char *opt_username; static char *opt_passwd; static char *opt_file; int main(int argc, char *argv[]) { memcached_st *memc; char *string; size_t string_length; uint32_t flags; memcached_return_t rc; memcached_server_st *servers; int return_code= EXIT_SUCCESS; options_parse(argc, argv); initialize_sockets(); if (!opt_servers) { char *temp; if ((temp= getenv("MEMCACHED_SERVERS"))) { opt_servers= strdup(temp); } else { std::cerr << "No servers provied" << std::endl; exit(EXIT_FAILURE); } } memc= memcached_create(NULL); process_hash_option(memc, opt_hash); servers= memcached_servers_parse(opt_servers); memcached_server_push(memc, servers); memcached_server_list_free(servers); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, (uint64_t)opt_binary); if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0) { memcached_free(memc); std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl; return EXIT_FAILURE; } if (opt_username) { memcached_return_t ret; if (memcached_failed(ret= memcached_set_sasl_auth_data(memc, opt_username, opt_passwd))) { std::cerr << memcached_last_error_message(memc) << std::endl; memcached_free(memc); return EXIT_FAILURE; } } while (optind < argc) { string= memcached_get(memc, argv[optind], strlen(argv[optind]), &string_length, &flags, &rc); if (rc == MEMCACHED_SUCCESS) { if (opt_displayflag) { if (opt_verbose) { std::cout << "key: " << argv[optind] << std::endl << "flags: " << flags << std::endl; } } else { if (opt_verbose) { std::cout << "key: " << argv[optind] << std::endl << "flags: " << flags << "length: " << string_length << std::endl << "value: "; } if (opt_file) { FILE *fp= fopen(opt_file, "w"); if (fp == NULL) { perror("fopen"); return_code= EXIT_FAILURE; break; } size_t written= fwrite(string, 1, string_length, fp); if (written != string_length) { std::cerr << "error writing file to file " << opt_file << " wrote " << written << ", should have written" << string_length << std::endl; return_code= EXIT_FAILURE; break; } if (fclose(fp)) { std::cerr << "error closing " << opt_file << std::endl; return_code= EXIT_FAILURE; break; } } else { std::cout.write(string, string_length); std::cout << std::endl; } free(string); } } else if (rc != MEMCACHED_NOTFOUND) { std::cerr << "error on " << argv[optind] << "(" << memcached_strerror(memc, rc) << ")"; if (memcached_last_error_errno(memc)) { std::cerr << " system error (" << strerror(memcached_last_error_errno(memc)) << ")" << std::endl; } std::cerr << std::endl; return_code= EXIT_FAILURE; break; } else // Unknown Issue { std::cerr << "error on " << argv[optind] << "("<< memcached_strerror(NULL, rc) << ")" << std::endl; return_code= EXIT_FAILURE; } optind++; } memcached_free(memc); if (opt_servers) { free(opt_servers); } if (opt_hash) { free(opt_hash); } return return_code; } void options_parse(int argc, char *argv[]) { int option_index= 0; memcached_programs_help_st help_options[]= { {0}, }; static struct option long_options[]= { {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, {(OPTIONSTRING)"quiet", no_argument, NULL, OPT_QUIET}, {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, {(OPTIONSTRING)"flag", no_argument, &opt_displayflag, OPT_FLAG}, {(OPTIONSTRING)"hash", required_argument, NULL, OPT_HASH}, {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, {(OPTIONSTRING)"username", required_argument, NULL, OPT_USERNAME}, {(OPTIONSTRING)"password", required_argument, NULL, OPT_PASSWD}, {(OPTIONSTRING)"file", required_argument, NULL, OPT_FILE}, {0, 0, 0, 0}, }; while (1) { int option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) break; switch (option_rv) { case 0: break; case OPT_BINARY: opt_binary = 1; break; case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = OPT_VERBOSE; break; case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; case OPT_VERSION: /* --version or -V */ version_command(PROGRAM_NAME); break; case OPT_HELP: /* --help or -h */ help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options); break; case OPT_SERVERS: /* --servers or -s */ opt_servers= strdup(optarg); break; case OPT_HASH: opt_hash= strdup(optarg); break; case OPT_USERNAME: opt_username= optarg; break; case OPT_PASSWD: opt_passwd= optarg; break; case OPT_FILE: opt_file= optarg; break; case OPT_QUIET: close_stdio(); break; case '?': /* getopt_long already printed an error message. */ exit(1); default: abort(); } } } libmemcached-1.0.8/clients/ms_atomic.h0000664000076400007640000000505711753573717020213 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #ifndef CLIENTS_MS_ATOMIC_H #define CLIENTS_MS_ATOMIC_H #if defined(__SUNPRO_C) # define _KERNEL # include # if SIZEOF_SIZE_T == 8 # define atomic_add_size(X, Y) atomic_add_64((X), (Y)) # define atomic_add_size_nv(X, Y) atomic_add_64((X), (Y)) # define atomic_dec_size(X, Y) atomic_add_64((X), (Y)) # define atomic_dec_size_nv(X, Y) atomic_add_64((X), (Y)) # else # define atomic_add_size(X, Y) atomic_add_32((X), (Y)) # define atomic_add_size_nv(X, Y) atomic_add_32((X), (Y)) # define atomic_dec_size(X, Y) atomic_add_32((X), (Y)) # define atomic_dec_size_nv(X, Y) atomic_add_32((X), (Y)) # endif # undef _KERNEL #elif HAVE_GCC_ATOMIC_BUILTINS # define atomic_add_8(X, Y) __sync_fetch_and_add((X), (Y)) # define atomic_add_16(X, Y) __sync_fetch_and_add((X), (Y)) # define atomic_add_32(X, Y) __sync_fetch_and_add((X), (Y)) # define atomic_add_size(X, Y) __sync_fetch_and_add((X), (Y)) # define atomic_dec_8(X) __sync_fetch_and_sub((X), 1) # define atomic_dec_16(X) __sync_fetch_and_sub((X), 1) # define atomic_dec_32(X) __sync_fetch_and_sub((X), 1) # define atomic_dec_size(X) __sync_fetch_and_sub((X), 1) /* The same as above, but these return the new value instead of void */ # define atomic_add_8_nv(X, Y) __sync_fetch_and_add((X), (Y)) # define atomic_add_16_nv(X, Y) __sync_fetch_and_add((X), (Y)) # define atomic_add_32_nv(X, Y) __sync_fetch_and_add((X), (Y)) # define atomic_add_size_nv(X, Y) __sync_fetch_and_add((X), (Y)) # define atomic_dec_8_nv(X) __sync_fetch_and_sub((X), 1) # define atomic_dec_16_nv(X) __sync_fetch_and_sub((X), 1) # define atomic_dec_32_nv(X) __sync_fetch_and_sub((X), 1) # define atomic_dec_size_nv(X) __sync_fetch_and_sub((X), 1) #else #warning "Atomic operators not found so memslap will not work correctly" # define atomic_add_8(X, Y) # define atomic_add_16(X, Y) # define atomic_add_32(X, Y) # define atomic_add_size(X, Y) # define atomic_dec_8(X) # define atomic_dec_16(X) # define atomic_dec_32(X) # define atomic_dec_size(X) /* The same as above, but these return the new value instead of void */ # define atomic_add_8_nv(X, Y) # define atomic_add_16_nv(X, Y) # define atomic_add_32_nv(X, Y) # define atomic_add_size_nv(X, Y) # define atomic_dec_8_nv(X) # define atomic_dec_16_nv(X) # define atomic_dec_32_nv(X) # define atomic_dec_size_nv(X) #endif /* defined(__SUNPRO_C) */ #endif /* CLIENTS_MS_ATOMIC_H */ libmemcached-1.0.8/clients/memcp.cc0000664000076400007640000002303111753573717017467 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #include "config.h" #include #include #include #include #include #include #include #include #include #ifdef HAVE_STRINGS_H #include #endif #include #include #include #include #include #include #include "client_options.h" #include "utilities.h" #define PROGRAM_NAME "memcp" #define PROGRAM_DESCRIPTION "Copy a set of files to a memcached cluster." /* Prototypes */ static void options_parse(int argc, char *argv[]); static bool opt_binary= false; static bool opt_udp= false; static bool opt_buffer= false; static int opt_verbose= 0; static char *opt_servers= NULL; static char *opt_hash= NULL; static int opt_method= OPT_SET; static uint32_t opt_flags= 0; static time_t opt_expires= 0; static char *opt_username; static char *opt_passwd; static long strtol_wrapper(const char *nptr, int base, bool *error) { long val; char *endptr; errno= 0; /* To distinguish success/failure after call */ val= strtol(nptr, &endptr, base); /* Check for various possible errors */ if ((errno == ERANGE and (val == LONG_MAX or val == LONG_MIN)) or (errno != 0 && val == 0)) { *error= true; return EXIT_SUCCESS; } if (endptr == nptr) { *error= true; return EXIT_SUCCESS; } *error= false; return val; } int main(int argc, char *argv[]) { options_parse(argc, argv); initialize_sockets(); memcached_st *memc= memcached_create(NULL); if (opt_udp) { if (opt_verbose) { std::cout << "Enabling UDP" << std::endl; } if (memcached_failed(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, opt_udp))) { memcached_free(memc); std::cerr << "Could not enable UDP protocol." << std::endl; return EXIT_FAILURE; } } if (opt_buffer) { if (opt_verbose) { std::cout << "Enabling MEMCACHED_BEHAVIOR_BUFFER_REQUESTS" << std::endl; } if (memcached_failed(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, opt_buffer))) { memcached_free(memc); std::cerr << "Could not enable MEMCACHED_BEHAVIOR_BUFFER_REQUESTS." << std::endl; return EXIT_FAILURE; } } process_hash_option(memc, opt_hash); if (opt_servers == NULL) { char *temp; if ((temp= getenv("MEMCACHED_SERVERS"))) { opt_servers= strdup(temp); } else { std::cerr << "No Servers provided" << std::endl; exit(EXIT_FAILURE); } } memcached_server_st *servers; if (opt_servers) { servers= memcached_servers_parse(opt_servers); } else { servers= memcached_servers_parse(argv[--argc]); } memcached_server_push(memc, servers); memcached_server_list_free(servers); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, opt_binary); if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0) { memcached_free(memc); std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl; return EXIT_FAILURE; } if (opt_username) { memcached_return_t ret; if (memcached_failed(ret= memcached_set_sasl_auth_data(memc, opt_username, opt_passwd))) { std::cerr << memcached_last_error_message(memc) << std::endl; memcached_free(memc); return EXIT_FAILURE; } } int exit_code= EXIT_SUCCESS; while (optind < argc) { int fd= open(argv[optind], O_RDONLY); if (fd < 0) { if (opt_verbose) { std::cerr << "memcp " << argv[optind] << " " << strerror(errno) << std::endl; optind++; } exit_code= EXIT_FAILURE; continue; } struct stat sbuf; (void)fstat(fd, &sbuf); char *ptr= rindex(argv[optind], '/'); if (ptr) { ptr++; } else { ptr= argv[optind]; } if (opt_verbose) { static const char *opstr[] = { "set", "add", "replace" }; printf("op: %s\nsource file: %s\nlength: %lu\n" "key: %s\nflags: %x\nexpires: %lu\n", opstr[opt_method - OPT_SET], argv[optind], (unsigned long)sbuf.st_size, ptr, opt_flags, (unsigned long)opt_expires); } char *file_buffer_ptr; if ((file_buffer_ptr= (char *)malloc(sizeof(char) * (size_t)sbuf.st_size)) == NULL) { std::cerr << "Error allocating file buffer(" << strerror(errno) << ")" << std::endl; exit(EXIT_FAILURE); } ssize_t read_length; if ((read_length= ::read(fd, file_buffer_ptr, (size_t)sbuf.st_size)) == -1) { std::cerr << "Error while reading file " << file_buffer_ptr << " (" << strerror(errno) << ")" << std::endl; exit(EXIT_FAILURE); } if (read_length != sbuf.st_size) { std::cerr << "Failure while reading file. Read length was not equal to stat() length" << std::endl; exit(EXIT_FAILURE); } memcached_return_t rc; if (opt_method == OPT_ADD) { rc= memcached_add(memc, ptr, strlen(ptr), file_buffer_ptr, (size_t)sbuf.st_size, opt_expires, opt_flags); } else if (opt_method == OPT_REPLACE) { rc= memcached_replace(memc, ptr, strlen(ptr), file_buffer_ptr, (size_t)sbuf.st_size, opt_expires, opt_flags); } else { rc= memcached_set(memc, ptr, strlen(ptr), file_buffer_ptr, (size_t)sbuf.st_size, opt_expires, opt_flags); } if (memcached_failed(rc)) { std::cerr << "Error occrrured during memcached_set(): " << memcached_last_error_message(memc) << std::endl; exit_code= EXIT_FAILURE; } ::free(file_buffer_ptr); ::close(fd); optind++; } if (opt_verbose) { std::cout << "Calling memcached_free()" << std::endl; } memcached_free(memc); if (opt_servers) { free(opt_servers); } if (opt_hash) { free(opt_hash); } return exit_code; } static void options_parse(int argc, char *argv[]) { memcached_programs_help_st help_options[]= { {0}, }; static struct option long_options[]= { {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, {(OPTIONSTRING)"quiet", no_argument, NULL, OPT_QUIET}, {(OPTIONSTRING)"udp", no_argument, NULL, OPT_UDP}, {(OPTIONSTRING)"buffer", no_argument, NULL, OPT_BUFFER}, {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, {(OPTIONSTRING)"flag", required_argument, NULL, OPT_FLAG}, {(OPTIONSTRING)"expire", required_argument, NULL, OPT_EXPIRE}, {(OPTIONSTRING)"set", no_argument, NULL, OPT_SET}, {(OPTIONSTRING)"add", no_argument, NULL, OPT_ADD}, {(OPTIONSTRING)"replace", no_argument, NULL, OPT_REPLACE}, {(OPTIONSTRING)"hash", required_argument, NULL, OPT_HASH}, {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, {(OPTIONSTRING)"username", required_argument, NULL, OPT_USERNAME}, {(OPTIONSTRING)"password", required_argument, NULL, OPT_PASSWD}, {0, 0, 0, 0}, }; bool opt_version= false; bool opt_help= false; int option_index= 0; while (1) { int option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) break; switch (option_rv) { case 0: break; case OPT_BINARY: opt_binary= true; break; case OPT_VERBOSE: /* --verbose or -v */ opt_verbose= OPT_VERBOSE; break; case OPT_DEBUG: /* --debug or -d */ opt_verbose= OPT_DEBUG; break; case OPT_VERSION: /* --version or -V */ opt_version= true; break; case OPT_HELP: /* --help or -h */ opt_help= true; break; case OPT_SERVERS: /* --servers or -s */ opt_servers= strdup(optarg); break; case OPT_FLAG: /* --flag */ { bool strtol_error; opt_flags= (uint32_t)strtol_wrapper(optarg, 16, &strtol_error); if (strtol_error == true) { fprintf(stderr, "Bad value passed via --flag\n"); exit(1); } } break; case OPT_EXPIRE: /* --expire */ { bool strtol_error; opt_expires= (time_t)strtol_wrapper(optarg, 16, &strtol_error); if (strtol_error == true) { fprintf(stderr, "Bad value passed via --flag\n"); exit(1); } } break; case OPT_SET: opt_method= OPT_SET; break; case OPT_REPLACE: opt_method= OPT_REPLACE; break; case OPT_ADD: opt_method= OPT_ADD; break; case OPT_HASH: opt_hash= strdup(optarg); break; case OPT_USERNAME: opt_username= optarg; break; case OPT_PASSWD: opt_passwd= optarg; break; case OPT_QUIET: close_stdio(); break; case OPT_UDP: opt_udp= true; break; case OPT_BUFFER: opt_buffer= true; break; case '?': /* getopt_long already printed an error message. */ exit(1); default: abort(); } } if (opt_version) { version_command(PROGRAM_NAME); exit(EXIT_SUCCESS); } if (opt_help) { help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options); exit(EXIT_SUCCESS); } } libmemcached-1.0.8/clients/memdump.cc0000664000076400007640000001203611753573717020035 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "client_options.h" #include "utilities.h" #define PROGRAM_NAME "memdump" #define PROGRAM_DESCRIPTION "Dump all values from one or many servers." /* Prototypes */ static void options_parse(int argc, char *argv[]); static bool opt_binary=0; static int opt_verbose= 0; static char *opt_servers= NULL; static char *opt_hash= NULL; static char *opt_username; static char *opt_passwd; /* Print the keys and counter how many were found */ static memcached_return_t key_printer(const memcached_st *, const char *key, size_t key_length, void *) { std::cout.write(key, key_length); std::cout << std::endl; return MEMCACHED_SUCCESS; } int main(int argc, char *argv[]) { memcached_dump_fn callbacks[1]; callbacks[0]= &key_printer; options_parse(argc, argv); memcached_st *memc= memcached_create(NULL); process_hash_option(memc, opt_hash); if (opt_servers == NULL) { char *temp; if ((temp= getenv("MEMCACHED_SERVERS"))) { opt_servers= strdup(temp); } else { std::cerr << "No Servers provided" << std::endl; exit(EXIT_FAILURE); } } memcached_server_st *servers; if (opt_servers) { servers= memcached_servers_parse(opt_servers); } else { servers= memcached_servers_parse(argv[--argc]); } memcached_server_push(memc, servers); memcached_server_list_free(servers); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, (uint64_t)opt_binary); if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0) { memcached_free(memc); std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl; return EXIT_FAILURE; } if (opt_username) { memcached_return_t ret; if (memcached_failed(ret= memcached_set_sasl_auth_data(memc, opt_username, opt_passwd))) { std::cerr << memcached_last_error_message(memc) << std::endl; memcached_free(memc); return EXIT_FAILURE; } } memcached_return_t rc= memcached_dump(memc, callbacks, NULL, 1); int exit_code= EXIT_SUCCESS; if (memcached_failed(rc)) { if (opt_verbose) { std::cerr << "Failed to dump keys: " << memcached_last_error_message(memc) << std::endl; } exit_code= EXIT_FAILURE; } memcached_free(memc); if (opt_servers) { free(opt_servers); } if (opt_hash) { free(opt_hash); } return exit_code; } static void options_parse(int argc, char *argv[]) { static struct option long_options[]= { {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, {(OPTIONSTRING)"quiet", no_argument, NULL, OPT_QUIET}, {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, {(OPTIONSTRING)"hash", required_argument, NULL, OPT_HASH}, {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, {(OPTIONSTRING)"username", required_argument, NULL, OPT_USERNAME}, {(OPTIONSTRING)"password", required_argument, NULL, OPT_PASSWD}, {0, 0, 0, 0} }; int option_index= 0; bool opt_version= false; bool opt_help= false; while (1) { int option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) break; switch (option_rv) { case 0: break; case OPT_BINARY: opt_binary= true; break; case OPT_VERBOSE: /* --verbose or -v */ opt_verbose= OPT_VERBOSE; break; case OPT_DEBUG: /* --debug or -d */ opt_verbose= OPT_DEBUG; break; case OPT_VERSION: /* --version or -V */ opt_verbose= true; break; case OPT_HELP: /* --help or -h */ opt_help= true; break; case OPT_SERVERS: /* --servers or -s */ opt_servers= strdup(optarg); break; case OPT_HASH: opt_hash= strdup(optarg); break; case OPT_USERNAME: opt_username= optarg; break; case OPT_PASSWD: opt_passwd= optarg; break; case OPT_QUIET: close_stdio(); break; case '?': /* getopt_long already printed an error message. */ exit(1); default: abort(); } } if (opt_version) { version_command(PROGRAM_NAME); exit(EXIT_SUCCESS); } if (opt_help) { help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, NULL); exit(EXIT_SUCCESS); } } libmemcached-1.0.8/clients/generator.cc0000664000076400007640000000401011753573717020350 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #include #include #include #include #include #include #include #include "generator.h" /* Use this for string generation */ static const char ALPHANUMERICS[]= "0123456789ABCDEFGHIJKLMNOPQRSTWXYZabcdefghijklmnopqrstuvwxyz"; #define ALPHANUMERICS_SIZE (sizeof(ALPHANUMERICS)-1) static size_t get_alpha_num(void) { return (size_t)random() % ALPHANUMERICS_SIZE; } static void get_random_string(char *buffer, size_t size) { char *buffer_ptr= buffer; while (--size) *buffer_ptr++= ALPHANUMERICS[get_alpha_num()]; *buffer_ptr++= ALPHANUMERICS[get_alpha_num()]; } void pairs_free(pairs_st *pairs) { if (pairs == NULL) { return; } /* We free until we hit the null pair we stores during creation */ for (uint32_t x= 0; pairs[x].key; x++) { free(pairs[x].key); if (pairs[x].value) { free(pairs[x].value); } } free(pairs); } pairs_st *pairs_generate(uint64_t number_of, size_t value_length) { pairs_st *pairs= (pairs_st*)calloc((size_t)number_of + 1, sizeof(pairs_st)); if (pairs == NULL) { goto error; } for (uint64_t x= 0; x < number_of; x++) { pairs[x].key= (char *)calloc(100, sizeof(char)); if (pairs[x].key == NULL) goto error; get_random_string(pairs[x].key, 100); pairs[x].key_length= 100; if (value_length) { pairs[x].value= (char *)calloc(value_length, sizeof(char)); if (pairs[x].value == NULL) goto error; get_random_string(pairs[x].value, value_length); pairs[x].value_length= value_length; } else { pairs[x].value= NULL; pairs[x].value_length= 0; } } return pairs; error: std::cerr << "Memory Allocation failure in pairs_generate." << std::endl; exit(EXIT_SUCCESS); } libmemcached-1.0.8/clients/memstat.cc0000664000076400007640000002627311753573717020053 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * * Authors: * Brian Aker * Toru Maesaka */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "client_options.h" #include "utilities.h" #define PROGRAM_NAME "memstat" #define PROGRAM_DESCRIPTION "Output the state of a memcached cluster." /* Prototypes */ static void options_parse(int argc, char *argv[]); static void run_analyzer(memcached_st *memc, memcached_stat_st *memc_stat); static void print_analysis_report(memcached_st *memc, memcached_analysis_st *report); static bool opt_binary= false; static bool opt_verbose= false; static bool opt_server_version= false; static bool opt_analyze= false; static char *opt_servers= NULL; static char *stat_args= NULL; static char *analyze_mode= NULL; static struct option long_options[]= { {(OPTIONSTRING)"args", required_argument, NULL, OPT_STAT_ARGS}, {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, {(OPTIONSTRING)"quiet", no_argument, NULL, OPT_QUIET}, {(OPTIONSTRING)"verbose", no_argument, NULL, OPT_VERBOSE}, {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, {(OPTIONSTRING)"debug", no_argument, NULL, OPT_DEBUG}, {(OPTIONSTRING)"server-version", no_argument, NULL, OPT_SERVER_VERSION}, {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, {(OPTIONSTRING)"analyze", optional_argument, NULL, OPT_ANALYZE}, {0, 0, 0, 0}, }; static memcached_return_t stat_printer(memcached_server_instance_st instance, const char *key, size_t key_length, const char *value, size_t value_length, void *context) { static memcached_server_instance_st last= NULL; (void)context; if (last != instance) { printf("Server: %s (%u)\n", memcached_server_name(instance), (uint32_t)memcached_server_port(instance)); last= instance; } printf("\t %.*s: %.*s\n", (int)key_length, key, (int)value_length, value); return MEMCACHED_SUCCESS; } static memcached_return_t server_print_callback(const memcached_st *, const memcached_server_st *instance, void *) { std::cerr << memcached_server_name(instance) << ":" << memcached_server_port(instance) << " " << int(instance->major_version) << "." << int(instance->minor_version) << "." << int(instance->micro_version) << std::endl; return MEMCACHED_SUCCESS; } int main(int argc, char *argv[]) { options_parse(argc, argv); initialize_sockets(); if (opt_servers == false) { char *temp; if ((temp= getenv("MEMCACHED_SERVERS"))) { opt_servers= strdup(temp); } else { std::cerr << "No Servers provided" << std::endl; return EXIT_FAILURE; } } memcached_st *memc= memcached_create(NULL); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, opt_binary); memcached_server_st *servers= memcached_servers_parse(opt_servers); free(opt_servers); memcached_return_t rc= memcached_server_push(memc, servers); memcached_server_list_free(servers); if (rc != MEMCACHED_SUCCESS and rc != MEMCACHED_SOME_ERRORS) { printf("Failure to communicate with servers (%s)\n", memcached_strerror(memc, rc)); exit(EXIT_FAILURE); } if (opt_server_version) { if (memcached_failed(memcached_version(memc))) { std::cerr << "Unable to obtain server version"; exit(EXIT_FAILURE); } memcached_server_fn callbacks[1]; callbacks[0]= server_print_callback; memcached_server_cursor(memc, callbacks, NULL, 1); } else if (opt_analyze) { memcached_stat_st *memc_stat= memcached_stat(memc, NULL, &rc); if (memc_stat == NULL) { exit(EXIT_FAILURE); } run_analyzer(memc, memc_stat); memcached_stat_free(memc, memc_stat); } else { rc= memcached_stat_execute(memc, stat_args, stat_printer, NULL); } memcached_free(memc); return rc == MEMCACHED_SUCCESS ? EXIT_SUCCESS: EXIT_FAILURE; } static void run_analyzer(memcached_st *memc, memcached_stat_st *memc_stat) { memcached_return_t rc; if (analyze_mode == NULL) { memcached_analysis_st *report; report= memcached_analyze(memc, memc_stat, &rc); if (rc != MEMCACHED_SUCCESS || report == NULL) { printf("Failure to analyze servers (%s)\n", memcached_strerror(memc, rc)); exit(1); } print_analysis_report(memc, report); free(report); } else if (strcmp(analyze_mode, "latency") == 0) { uint32_t flags, server_count= memcached_server_count(memc); uint32_t num_of_tests= 32; const char *test_key= "libmemcached_test_key"; memcached_st **servers; servers= static_cast(malloc(sizeof(memcached_st*) * server_count)); if (not servers) { fprintf(stderr, "Failed to allocate memory\n"); return; } for (uint32_t x= 0; x < server_count; x++) { memcached_server_instance_st instance= memcached_server_instance_by_position(memc, x); if ((servers[x]= memcached_create(NULL)) == NULL) { fprintf(stderr, "Failed to memcached_create()\n"); if (x > 0) memcached_free(servers[0]); x--; for (; x > 0; x--) memcached_free(servers[x]); free(servers); return; } memcached_server_add(servers[x], memcached_server_name(instance), memcached_server_port(instance)); } printf("Network Latency Test:\n\n"); struct timeval start_time, end_time; uint32_t slowest_server= 0; long elapsed_time, slowest_time= 0; for (uint32_t x= 0; x < server_count; x++) { memcached_server_instance_st instance= memcached_server_instance_by_position(memc, x); gettimeofday(&start_time, NULL); for (uint32_t y= 0; y < num_of_tests; y++) { size_t vlen; char *val= memcached_get(servers[x], test_key, strlen(test_key), &vlen, &flags, &rc); if (rc != MEMCACHED_NOTFOUND && rc != MEMCACHED_SUCCESS) break; free(val); } gettimeofday(&end_time, NULL); elapsed_time= (long) timedif(end_time, start_time); elapsed_time /= (long) num_of_tests; if (elapsed_time > slowest_time) { slowest_server= x; slowest_time= elapsed_time; } if (rc != MEMCACHED_NOTFOUND && rc != MEMCACHED_SUCCESS) { printf("\t %s (%d) => failed to reach the server\n", memcached_server_name(instance), memcached_server_port(instance)); } else { printf("\t %s (%d) => %ld.%ld seconds\n", memcached_server_name(instance), memcached_server_port(instance), elapsed_time / 1000, elapsed_time % 1000); } } if (server_count > 1 && slowest_time > 0) { memcached_server_instance_st slowest= memcached_server_instance_by_position(memc, slowest_server); printf("---\n"); printf("Slowest Server: %s (%d) => %ld.%ld seconds\n", memcached_server_name(slowest), memcached_server_port(slowest), slowest_time / 1000, slowest_time % 1000); } printf("\n"); for (uint32_t x= 0; x < server_count; x++) memcached_free(servers[x]); free(servers); free(analyze_mode); } else { fprintf(stderr, "Invalid Analyzer Option provided\n"); free(analyze_mode); } } static void print_analysis_report(memcached_st *memc, memcached_analysis_st *report) { uint32_t server_count= memcached_server_count(memc); memcached_server_instance_st most_consumed_server= memcached_server_instance_by_position(memc, report->most_consumed_server); memcached_server_instance_st least_free_server= memcached_server_instance_by_position(memc, report->least_free_server); memcached_server_instance_st oldest_server= memcached_server_instance_by_position(memc, report->oldest_server); printf("Memcached Cluster Analysis Report\n\n"); printf("\tNumber of Servers Analyzed : %u\n", server_count); printf("\tAverage Item Size (incl/overhead) : %u bytes\n", report->average_item_size); if (server_count == 1) { printf("\nFor a detailed report, you must supply multiple servers.\n"); return; } printf("\n"); printf("\tNode with most memory consumption : %s:%u (%llu bytes)\n", memcached_server_name(most_consumed_server), (uint32_t)memcached_server_port(most_consumed_server), (unsigned long long)report->most_used_bytes); printf("\tNode with least free space : %s:%u (%llu bytes remaining)\n", memcached_server_name(least_free_server), (uint32_t)memcached_server_port(least_free_server), (unsigned long long)report->least_remaining_bytes); printf("\tNode with longest uptime : %s:%u (%us)\n", memcached_server_name(oldest_server), (uint32_t)memcached_server_port(oldest_server), report->longest_uptime); printf("\tPool-wide Hit Ratio : %1.f%%\n", report->pool_hit_ratio); printf("\n"); } static void options_parse(int argc, char *argv[]) { memcached_programs_help_st help_options[]= { {0}, }; int option_index= 0; bool opt_version= false; bool opt_help= false; while (1) { int option_rv= getopt_long(argc, argv, "Vhvds:a", long_options, &option_index); if (option_rv == -1) break; switch (option_rv) { case 0: break; case OPT_VERBOSE: /* --verbose or -v */ opt_verbose= true; break; case OPT_DEBUG: /* --debug or -d */ opt_verbose= true; break; case OPT_BINARY: opt_binary= true; break; case OPT_SERVER_VERSION: opt_server_version= true; break; case OPT_VERSION: /* --version or -V */ opt_version= true; break; case OPT_HELP: /* --help or -h */ opt_help= true; break; case OPT_SERVERS: /* --servers or -s */ opt_servers= strdup(optarg); break; case OPT_STAT_ARGS: stat_args= strdup(optarg); break; case OPT_ANALYZE: /* --analyze or -a */ opt_analyze= OPT_ANALYZE; analyze_mode= (optarg) ? strdup(optarg) : NULL; break; case OPT_QUIET: close_stdio(); break; case '?': /* getopt_long already printed an error message. */ exit(1); default: abort(); } } if (opt_version) { version_command(PROGRAM_NAME); exit(EXIT_SUCCESS); } if (opt_help) { help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options); exit(EXIT_SUCCESS); } } libmemcached-1.0.8/clients/memparse.cc0000664000076400007640000000445711753573717020212 0ustar00brianbrian00000000000000/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 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 #include #include #include #include int main(int argc, char *argv[]) { if (argc < 2) { std::cerr << "No arguments provided." << std::endl; return EXIT_FAILURE; } for (int x= 1; x < argc; x++) { char buffer[BUFSIZ]; memcached_return_t rc; rc= libmemcached_check_configuration(argv[x], strlen(argv[x]), buffer, sizeof(buffer)); if (rc != MEMCACHED_SUCCESS) { std::cerr << "Failed to parse argument #" << x << " " << argv[x] << std::endl; std::cerr << buffer << std::endl; return EXIT_FAILURE; } } return EXIT_SUCCESS; } libmemcached-1.0.8/clients/ms_sigsegv.c0000664000076400007640000000500111753573717020366 0ustar00brianbrian00000000000000/* * File: ms_sigsegv.c * Author: Mingqiang Zhuang * * Created on March 15, 2009 * * (c) Copyright 2009, Schooner Information Technology, Inc. * http://www.schoonerinfotech.com/ * * Rewrite of stack dump: * Copyright (C) 2009 Sun Microsystems * Author Trond Norbye */ #include "config.h" #include #include #include #include #include #include "ms_memslap.h" #include "ms_setting.h" /* prototypes */ int ms_setup_sigsegv(void); int ms_setup_sigpipe(void); int ms_setup_sigint(void); /* signal seg reaches, this function will run */ static void ms_signal_segv(int signum, siginfo_t *info, void *ptr) { UNUSED_ARGUMENT(signum); UNUSED_ARGUMENT(info); UNUSED_ARGUMENT(ptr); pthread_mutex_lock(&ms_global.quit_mutex); fprintf(stderr, "Segmentation fault occurred.\nStack trace:\n"); pandora_print_callstack(stderr); fprintf(stderr, "End of stack trace\n"); pthread_mutex_unlock(&ms_global.quit_mutex); abort(); } /* signal int reaches, this function will run */ static void ms_signal_int(int signum, siginfo_t *info, void *ptr) { UNUSED_ARGUMENT(signum); UNUSED_ARGUMENT(info); UNUSED_ARGUMENT(ptr); pthread_mutex_lock(&ms_global.quit_mutex); fprintf(stderr, "SIGINT handled.\n"); pthread_mutex_unlock(&ms_global.quit_mutex); exit(1); } /* ms_signal_int */ /** * redirect signal seg * * @return if success, return EXIT_SUCCESS, else return -1 */ int ms_setup_sigsegv(void) { struct sigaction action; memset(&action, 0, sizeof(action)); action.sa_sigaction= ms_signal_segv; action.sa_flags= SA_SIGINFO; if (sigaction(SIGSEGV, &action, NULL) < 0) { perror("sigaction"); return EXIT_SUCCESS; } return -1; } /* ms_setup_sigsegv */ /** * redirect signal pipe * * @return if success, return EXIT_SUCCESS, else return -1 */ int ms_setup_sigpipe(void) { /* ignore the SIGPIPE signal */ signal(SIGPIPE, SIG_IGN); return -1; } /* ms_setup_sigpipe */ /** * redirect signal int * * @return if success, return EXIT_SUCCESS, else return -1 */ int ms_setup_sigint(void) { struct sigaction action_3; memset(&action_3, 0, sizeof(action_3)); action_3.sa_sigaction= ms_signal_int; action_3.sa_flags= SA_SIGINFO; if (sigaction(SIGINT, &action_3, NULL) < 0) { perror("sigaction"); return EXIT_SUCCESS; } return -1; } /* ms_setup_sigint */ #ifndef SIGSEGV_NO_AUTO_INIT static void __attribute((constructor)) ms_init(void) { ms_setup_sigsegv(); ms_setup_sigpipe(); ms_setup_sigint(); } #endif libmemcached-1.0.8/clients/memaslap.c0000664000076400007640000006257111753573717020036 0ustar00brianbrian00000000000000/* * memslap * * (c) Copyright 2009, Schooner Information Technology, Inc. * All rights reserved. * http://www.schoonerinfotech.com/ * * Use and distribution licensed under the BSD license. See * the COPYING file for full text. * * Authors: * Brian Aker * Mingqiang Zhuang * */ #include "config.h" #include #include #include #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #include "ms_sigsegv.h" #include "ms_setting.h" #include "ms_thread.h" #define PROGRAM_NAME "memslap" #define PROGRAM_DESCRIPTION \ "Generates workload against memcached servers." #ifdef __sun /* For some odd reason the option struct on solaris defines the argument * as char* and not const char* */ #define OPTIONSTRING char* #else #define OPTIONSTRING const char* #endif /* options */ static struct option long_options[]= { { (OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS }, { (OPTIONSTRING)"threads", required_argument, NULL, OPT_THREAD_NUMBER }, { (OPTIONSTRING)"concurrency", required_argument, NULL, OPT_CONCURRENCY }, { (OPTIONSTRING)"conn_sock", required_argument, NULL, OPT_SOCK_PER_CONN }, { (OPTIONSTRING)"execute_number", required_argument, NULL, OPT_EXECUTE_NUMBER }, { (OPTIONSTRING)"time", required_argument, NULL, OPT_TIME }, { (OPTIONSTRING)"cfg_cmd", required_argument, NULL, OPT_CONFIG_CMD }, { (OPTIONSTRING)"win_size", required_argument, NULL, OPT_WINDOW_SIZE }, { (OPTIONSTRING)"fixed_size", required_argument, NULL, OPT_FIXED_LTH }, { (OPTIONSTRING)"verify", required_argument, NULL, OPT_VERIFY }, { (OPTIONSTRING)"division", required_argument, NULL, OPT_GETS_DIVISION }, { (OPTIONSTRING)"stat_freq", required_argument, NULL, OPT_STAT_FREQ }, { (OPTIONSTRING)"exp_verify", required_argument, NULL, OPT_EXPIRE }, { (OPTIONSTRING)"overwrite", required_argument, NULL, OPT_OVERWRITE }, { (OPTIONSTRING)"reconnect", no_argument, NULL, OPT_RECONNECT }, { (OPTIONSTRING)"udp", no_argument, NULL, OPT_UDP }, { (OPTIONSTRING)"facebook", no_argument, NULL, OPT_FACEBOOK_TEST }, { (OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY_PROTOCOL }, { (OPTIONSTRING)"tps", required_argument, NULL, OPT_TPS }, { (OPTIONSTRING)"rep_write", required_argument, NULL, OPT_REP_WRITE_SRV }, { (OPTIONSTRING)"verbose", no_argument, NULL, OPT_VERBOSE }, { (OPTIONSTRING)"help", no_argument, NULL, OPT_HELP }, { (OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION }, { 0, 0, 0, 0 }, }; /* Prototypes */ static void ms_sync_lock_init(void); static void ms_sync_lock_destroy(void); static void ms_global_struct_init(void); static void ms_global_struct_destroy(void); static void ms_version_command(const char *command_name); static const char *ms_lookup_help(ms_options_t option); static int64_t ms_parse_time(void); static int64_t ms_parse_size(void); static void ms_options_parse(int argc, char *argv[]); static int ms_check_para(void); static void ms_statistic_init(void); static void ms_stats_init(void); static void ms_print_statistics(int in_time); static void ms_print_memslap_stats(struct timeval *start_time, struct timeval *end_time); static void ms_monitor_slap_mode(void); void ms_help_command(const char *command_name, const char *description); /* initialize the global locks */ static void ms_sync_lock_init() { ms_global.init_lock.count= 0; pthread_mutex_init(&ms_global.init_lock.lock, NULL); pthread_cond_init(&ms_global.init_lock.cond, NULL); ms_global.warmup_lock.count = 0; pthread_mutex_init(&ms_global.warmup_lock.lock, NULL); pthread_cond_init(&ms_global.warmup_lock.cond, NULL); ms_global.run_lock.count= 0; pthread_mutex_init(&ms_global.run_lock.lock, NULL); pthread_cond_init(&ms_global.run_lock.cond, NULL); pthread_mutex_init(&ms_global.quit_mutex, NULL); pthread_mutex_init(&ms_global.seq_mutex, NULL); } /* ms_sync_lock_init */ /* destroy the global locks */ static void ms_sync_lock_destroy() { pthread_mutex_destroy(&ms_global.init_lock.lock); pthread_cond_destroy(&ms_global.init_lock.cond); pthread_mutex_destroy(&ms_global.warmup_lock.lock); pthread_cond_destroy(&ms_global.warmup_lock.cond); pthread_mutex_destroy(&ms_global.run_lock.lock); pthread_cond_destroy(&ms_global.run_lock.cond); pthread_mutex_destroy(&ms_global.quit_mutex); pthread_mutex_destroy(&ms_global.seq_mutex); if (ms_setting.stat_freq > 0) { pthread_mutex_destroy(&ms_statistic.stat_mutex); } } /* ms_sync_lock_destroy */ /* initialize the global structure */ static void ms_global_struct_init() { ms_sync_lock_init(); ms_global.finish_warmup= false; ms_global.time_out= false; } /* destroy the global structure */ static void ms_global_struct_destroy() { ms_sync_lock_destroy(); } /** * output the version information * * @param command_name, the string of this process */ static void ms_version_command(const char *command_name) { printf("%s v%u.%u\n", command_name, 1U, 0U); exit(0); } /** * get the description of the option * * @param option, option of command line * * @return char*, description of the command option */ static const char *ms_lookup_help(ms_options_t option) { switch (option) { case OPT_SERVERS: return "List one or more servers to connect. Servers count must be less than\n" " threads count. e.g.: --servers=localhost:1234,localhost:11211"; case OPT_VERSION: return "Display the version of the application and then exit."; case OPT_HELP: return "Display this message and then exit."; case OPT_EXECUTE_NUMBER: return "Number of operations(get and set) to execute for the\n" " given test. Default 1000000."; case OPT_THREAD_NUMBER: return "Number of threads to startup, better equal to CPU numbers. Default 8."; case OPT_CONCURRENCY: return "Number of concurrency to simulate with load. Default 128."; case OPT_FIXED_LTH: return "Fixed length of value."; case OPT_VERIFY: return "The proportion of date verification, e.g.: --verify=0.01"; case OPT_GETS_DIVISION: return "Number of keys to multi-get once. Default 1, means single get."; case OPT_TIME: return "How long the test to run, suffix: s-seconds, m-minutes, h-hours,\n" " d-days e.g.: --time=2h."; case OPT_CONFIG_CMD: return "Load the configure file to get command,key and value distribution list."; case OPT_WINDOW_SIZE: return "Task window size of each concurrency, suffix: K, M e.g.: --win_size=10k.\n" " Default 10k."; case OPT_UDP: return "UDP support, default memslap uses TCP, TCP port and UDP port of\n" " server must be same."; case OPT_EXPIRE: return "The proportion of objects with expire time, e.g.: --exp_verify=0.01.\n" " Default no object with expire time"; case OPT_OVERWRITE: return "The proportion of objects need overwrite, e.g.: --overwrite=0.01.\n" " Default never overwrite object."; case OPT_STAT_FREQ: return "Frequency of dumping statistic information. suffix: s-seconds,\n" " m-minutes, e.g.: --resp_freq=10s."; case OPT_SOCK_PER_CONN: return "Number of TCP socks per concurrency. Default 1."; case OPT_RECONNECT: return "Reconnect support, when connection is closed it will be reconnected."; case OPT_VERBOSE: return "Whether it outputs detailed information when verification fails."; case OPT_FACEBOOK_TEST: return "Whether it enables facebook test feature, set with TCP and multi-get with UDP."; case OPT_BINARY_PROTOCOL: return "Whether it enables binary protocol. Default with ASCII protocol."; case OPT_TPS: return "Expected throughput, suffix: K, e.g.: --tps=10k."; case OPT_REP_WRITE_SRV: return "The first nth servers can write data, e.g.: --rep_write=2."; default: return "Forgot to document this option :)"; } /* switch */ } /* ms_lookup_help */ /** * output the help information * * @param command_name, the string of this process * @param description, description of this process * @param long_options, global options array */ void ms_help_command(const char *command_name, const char *description) { char *help_message= NULL; printf("%s v%u.%u\n", command_name, 1U, 0U); printf(" %s\n\n", description); printf( "Usage:\n" " memslap -hV | -s servers [-F config_file] [-t time | -x exe_num] [...]\n\n" "Options:\n"); for (int x= 0; long_options[x].name; x++) { printf(" -%c, --%s%c\n", long_options[x].val, long_options[x].name, long_options[x].has_arg ? '=' : ' '); if ((help_message= (char *)ms_lookup_help(long_options[x].val)) != NULL) { printf(" %s\n", help_message); } } printf( "\nExamples:\n" " memslap -s 127.0.0.1:11211 -S 5s\n" " memslap -s 127.0.0.1:11211 -t 2m -v 0.2 -e 0.05 -b\n" " memslap -s 127.0.0.1:11211 -F config -t 2m -w 40k -S 20s -o 0.2\n" " memslap -s 127.0.0.1:11211 -F config -t 2m -T 4 -c 128 -d 20 -P 40k\n" " memslap -s 127.0.0.1:11211 -F config -t 2m -d 50 -a -n 40\n" " memslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m\n" " memslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m -p 2\n\n"); exit(0); } /* ms_help_command */ /* used to parse the time string */ static int64_t ms_parse_time() { int64_t ret= 0; char unit= optarg[strlen(optarg) - 1]; optarg[strlen(optarg) - 1]= '\0'; ret= atoi(optarg); switch (unit) { case 'd': case 'D': ret*= 24; case 'h': case 'H': ret*= 60; case 'm': case 'M': ret*= 60; case 's': case 'S': break; default: ret= -1; break; } /* switch */ return ret; } /* ms_parse_time */ /* used to parse the size string */ static int64_t ms_parse_size() { int64_t ret= -1; char unit= optarg[strlen(optarg) - 1]; optarg[strlen(optarg) - 1]= '\0'; ret= strtoll(optarg, (char **)NULL, 10); switch (unit) { case 'k': case 'K': ret*= 1024; break; case 'm': case 'M': ret*= 1024 * 1024; break; case 'g': case 'G': ret*= 1024 * 1024 * 1024; break; default: ret= -1; break; } /* switch */ return ret; } /* ms_parse_size */ /* used to parse the options of command line */ static void ms_options_parse(int argc, char *argv[]) { int option_index= 0; int option_rv; while ((option_rv= getopt_long(argc, argv, "VhURbaBs:x:T:c:X:v:d:" "t:S:F:w:e:o:n:P:p:", long_options, &option_index)) != -1) { switch (option_rv) { case 0: break; case OPT_VERSION: /* --version or -V */ ms_version_command(PROGRAM_NAME); break; case OPT_HELP: /* --help or -h */ ms_help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION); break; case OPT_SERVERS: /* --servers or -s */ ms_setting.srv_str= strdup(optarg); break; case OPT_CONCURRENCY: /* --concurrency or -c */ ms_setting.nconns= (uint32_t)strtoul(optarg, (char **) NULL, 10); if (ms_setting.nconns <= 0) { fprintf(stderr, "Concurrency must be greater than 0.:-)\n"); exit(1); } break; case OPT_EXECUTE_NUMBER: /* --execute_number or -x */ ms_setting.exec_num= (int)strtol(optarg, (char **) NULL, 10); if (ms_setting.exec_num <= 0) { fprintf(stderr, "Execute number must be greater than 0.:-)\n"); exit(1); } break; case OPT_THREAD_NUMBER: /* --threads or -T */ ms_setting.nthreads= (uint32_t)strtoul(optarg, (char **) NULL, 10); if (ms_setting.nthreads <= 0) { fprintf(stderr, "Threads number must be greater than 0.:-)\n"); exit(1); } break; case OPT_FIXED_LTH: /* --fixed_size or -X */ ms_setting.fixed_value_size= (size_t)strtoull(optarg, (char **) NULL, 10); if ((ms_setting.fixed_value_size <= 0) || (ms_setting.fixed_value_size > MAX_VALUE_SIZE)) { fprintf(stderr, "Value size must be between 0 and 1M.:-)\n"); exit(1); } break; case OPT_VERIFY: /* --verify or -v */ ms_setting.verify_percent= atof(optarg); if ((ms_setting.verify_percent <= 0) || (ms_setting.verify_percent > 1.0)) { fprintf(stderr, "Data verification rate must be " "greater than 0 and less than 1.0. :-)\n"); exit(1); } break; case OPT_GETS_DIVISION: /* --division or -d */ ms_setting.mult_key_num= (int)strtol(optarg, (char **) NULL, 10); if (ms_setting.mult_key_num <= 0) { fprintf(stderr, "Multi-get key number must be greater than 0.:-)\n"); exit(1); } break; case OPT_TIME: /* --time or -t */ ms_setting.run_time= (int)ms_parse_time(); if (ms_setting.run_time == -1) { fprintf(stderr, "Please specify the run time. :-)\n" "'s' for second, 'm' for minute, 'h' for hour, " "'d' for day. e.g.: --time=24h (means 24 hours).\n"); exit(1); } if (ms_setting.run_time == 0) { fprintf(stderr, "Running time can not be 0. :-)\n"); exit(1); } break; case OPT_CONFIG_CMD: /* --cfg_cmd or -F */ ms_setting.cfg_file= strdup(optarg); break; case OPT_WINDOW_SIZE: /* --win_size or -w */ ms_setting.win_size= (size_t)ms_parse_size(); if (ms_setting.win_size == (size_t)-1) { fprintf( stderr, "Please specify the item window size. :-)\n" "e.g.: --win_size=10k (means 10k task window size).\n"); exit(1); } break; case OPT_UDP: /* --udp or -U*/ ms_setting.udp= true; break; case OPT_EXPIRE: /* --exp_verify or -e */ ms_setting.exp_ver_per= atof(optarg); if ((ms_setting.exp_ver_per <= 0) || (ms_setting.exp_ver_per > 1.0)) { fprintf(stderr, "Expire time verification rate must be " "greater than 0 and less than 1.0. :-)\n"); exit(1); } break; case OPT_OVERWRITE: /* --overwrite or -o */ ms_setting.overwrite_percent= atof(optarg); if ((ms_setting.overwrite_percent <= 0) || (ms_setting.overwrite_percent > 1.0)) { fprintf(stderr, "Objects overwrite rate must be " "greater than 0 and less than 1.0. :-)\n"); exit(1); } break; case OPT_STAT_FREQ: /* --stat_freq or -S */ ms_setting.stat_freq= (int)ms_parse_time(); if (ms_setting.stat_freq == -1) { fprintf(stderr, "Please specify the frequency of dumping " "statistic information. :-)\n" "'s' for second, 'm' for minute, 'h' for hour, " "'d' for day. e.g.: --time=24h (means 24 hours).\n"); exit(1); } if (ms_setting.stat_freq == 0) { fprintf(stderr, "The frequency of dumping statistic information " "can not be 0. :-)\n"); exit(1); } break; case OPT_SOCK_PER_CONN: /* --conn_sock or -n */ ms_setting.sock_per_conn= (uint32_t)strtoul(optarg, (char **) NULL, 10); if (ms_setting.sock_per_conn <= 0) { fprintf(stderr, "Number of socks of each concurrency " "must be greater than 0.:-)\n"); exit(1); } break; case OPT_RECONNECT: /* --reconnect or -R */ ms_setting.reconnect= true; break; case OPT_VERBOSE: /* --verbose or -b */ ms_setting.verbose= true; break; case OPT_FACEBOOK_TEST: /* --facebook or -a */ ms_setting.facebook_test= true; break; case OPT_BINARY_PROTOCOL: /* --binary or -B */ ms_setting.binary_prot= true; break; case OPT_TPS: /* --tps or -P */ ms_setting.expected_tps= (int)ms_parse_size(); if (ms_setting.expected_tps == -1) { fprintf(stderr, "Please specify the item expected throughput. :-)\n" "e.g.: --tps=10k (means 10k throughput).\n"); exit(1); } break; case OPT_REP_WRITE_SRV: /* --rep_write or -p */ ms_setting.rep_write_srv= (uint32_t)strtoul(optarg, (char **) NULL, 10); if (ms_setting.rep_write_srv <= 0) { fprintf(stderr, "Number of replication writing server must be greater " "than 0.:-)\n"); exit(1); } break; case '?': /* getopt_long already printed an error message. */ exit(1); default: abort(); } /* switch */ } } /* ms_options_parse */ static int ms_check_para() { if (ms_setting.srv_str == NULL) { char *temp; if ((temp= getenv("MEMCACHED_SERVERS"))) { ms_setting.srv_str= strdup(temp); } else { fprintf(stderr, "No Servers provided\n\n"); return -1; } } if (ms_setting.nconns % (uint32_t)ms_setting.nthreads != 0) { fprintf(stderr, "Concurrency must be the multiples of threads count.\n"); return -1; } if (ms_setting.win_size % UNIT_ITEMS_COUNT != 0) { fprintf(stderr, "Window size must be the multiples of 1024.\n\n"); return -1; } return EXIT_SUCCESS; } /* ms_check_para */ /* initialize the statistic structure */ static void ms_statistic_init() { pthread_mutex_init(&ms_statistic.stat_mutex, NULL); ms_init_stats(&ms_statistic.get_stat, "Get"); ms_init_stats(&ms_statistic.set_stat, "Set"); ms_init_stats(&ms_statistic.total_stat, "Total"); } /* ms_statistic_init */ /* initialize the global state structure */ static void ms_stats_init() { memset(&ms_stats, 0, sizeof(ms_stats_t)); if (ms_setting.stat_freq > 0) { ms_statistic_init(); } } /* ms_stats_init */ /* use to output the statistic */ static void ms_print_statistics(int in_time) { int obj_size= (int)(ms_setting.avg_key_size + ms_setting.avg_val_size); printf("\033[1;1H\033[2J\n"); ms_dump_format_stats(&ms_statistic.get_stat, in_time, ms_setting.stat_freq, obj_size); ms_dump_format_stats(&ms_statistic.set_stat, in_time, ms_setting.stat_freq, obj_size); ms_dump_format_stats(&ms_statistic.total_stat, in_time, ms_setting.stat_freq, obj_size); } /* ms_print_statistics */ /* used to print the states of memslap */ static void ms_print_memslap_stats(struct timeval *start_time, struct timeval *end_time) { char buf[1024]; char *pos= buf; pos+= snprintf(pos, sizeof(buf), "cmd_get: %lu\n", (unsigned long) ms_stats.cmd_get); pos+= snprintf(pos, sizeof(buf) - (size_t)(pos -buf), "cmd_set: %lu\n", (unsigned long) ms_stats.cmd_set); pos+= snprintf(pos, sizeof(buf) - (size_t)(pos -buf), "get_misses: %lu\n", (unsigned long) ms_stats.get_misses); if (ms_setting.verify_percent > 0) { pos+= snprintf(pos, sizeof(buf) - (size_t)(pos -buf), "verify_misses: %lu\n", (unsigned long) ms_stats.vef_miss); pos+= snprintf(pos, sizeof(buf) - (size_t)(pos -buf), "verify_failed: %lu\n", (unsigned long) ms_stats.vef_failed); } if (ms_setting.exp_ver_per > 0) { pos+= snprintf(pos, sizeof(buf) - (size_t)(pos -buf), "expired_get: %lu\n", (unsigned long) ms_stats.exp_get); pos+= snprintf(pos, sizeof(buf) - (size_t)(pos -buf), "unexpired_unget: %lu\n", (unsigned long) ms_stats.unexp_unget); } pos+= snprintf(pos, sizeof(buf) - (size_t)(pos -buf), "written_bytes: %lu\n", (unsigned long) ms_stats.bytes_written); pos+= snprintf(pos, sizeof(buf) - (size_t)(pos -buf), "read_bytes: %lu\n", (unsigned long) ms_stats.bytes_read); pos+= snprintf(pos, sizeof(buf) - (size_t)(pos -buf), "object_bytes: %lu\n", (unsigned long) ms_stats.obj_bytes); if (ms_setting.udp || ms_setting.facebook_test) { pos+= snprintf(pos, sizeof(buf) - (size_t)(pos -buf), "packet_disorder: %lu\n", (unsigned long) ms_stats.pkt_disorder); pos+= snprintf(pos, sizeof(buf) - (size_t)(pos -buf), "packet_drop: %lu\n", (unsigned long)ms_stats.pkt_drop); pos+= snprintf(pos, sizeof(buf) - (size_t)(pos -buf), "udp_timeout: %lu\n", (unsigned long)ms_stats.udp_timeout); } if (ms_setting.stat_freq > 0) { ms_dump_stats(&ms_statistic.get_stat); ms_dump_stats(&ms_statistic.set_stat); ms_dump_stats(&ms_statistic.total_stat); } int64_t time_diff= ms_time_diff(start_time, end_time); pos+= snprintf(pos, sizeof(buf) - (size_t)(pos -buf), "\nRun time: %.1fs Ops: %llu TPS: %.0Lf Net_rate: %.1fM/s\n", (double)time_diff / 1000000, (unsigned long long)(ms_stats.cmd_get + ms_stats.cmd_set), (ms_stats.cmd_get + ms_stats.cmd_set) / ((long double)time_diff / 1000000), (double)( ms_stats.bytes_written + ms_stats.bytes_read) / 1024 / 1024 / ((double)time_diff / 1000000)); assert(pos <= buf); fprintf(stdout, "%s", buf); fflush(stdout); } /* ms_print_memslap_stats */ /* the loop of the main thread, wait the work threads to complete */ static void ms_monitor_slap_mode() { int second= 0; struct timeval start_time, end_time; /* Wait all the threads complete initialization. */ pthread_mutex_lock(&ms_global.init_lock.lock); while (ms_global.init_lock.count < ms_setting.nthreads) { pthread_cond_wait(&ms_global.init_lock.cond, &ms_global.init_lock.lock); } pthread_mutex_unlock(&ms_global.init_lock.lock); /* only when there is no set operation it need warm up */ if (ms_setting.cmd_distr[CMD_SET].cmd_prop < PROP_ERROR) { /* Wait all the connects complete warm up. */ pthread_mutex_lock(&ms_global.warmup_lock.lock); while (ms_global.warmup_lock.count < ms_setting.nconns) { pthread_cond_wait(&ms_global.warmup_lock.cond, &ms_global.warmup_lock.lock); } pthread_mutex_unlock(&ms_global.warmup_lock.lock); } ms_global.finish_warmup= true; /* running in "run time" mode, user specify run time */ if (ms_setting.run_time > 0) { gettimeofday(&start_time, NULL); while (1) { sleep(1); second++; if ((ms_setting.stat_freq > 0) && (second % ms_setting.stat_freq == 0) && (ms_stats.active_conns >= ms_setting.nconns) && (ms_stats.active_conns <= INT_MAX)) { ms_print_statistics(second); } if (ms_setting.run_time <= second) { ms_global.time_out= true; break; } /* all connections disconnect */ if ((second > 5) && (ms_stats.active_conns == 0)) { break; } } gettimeofday(&end_time, NULL); sleep(1); /* wait all threads clean up */ } else { /* running in "execute number" mode, user specify execute number */ gettimeofday(&start_time, NULL); /* * We loop until we know that all connects have cleaned up. */ pthread_mutex_lock(&ms_global.run_lock.lock); while (ms_global.run_lock.count < ms_setting.nconns) { pthread_cond_wait(&ms_global.run_lock.cond, &ms_global.run_lock.lock); } pthread_mutex_unlock(&ms_global.run_lock.lock); gettimeofday(&end_time, NULL); } ms_print_memslap_stats(&start_time, &end_time); } /* ms_monitor_slap_mode */ /* the main function */ int main(int argc, char *argv[]) { srandom((unsigned int)time(NULL)); ms_global_struct_init(); /* initialization */ ms_setting_init_pre(); ms_options_parse(argc, argv); if (ms_check_para()) { ms_help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION); exit(1); } ms_setting_init_post(); ms_stats_init(); ms_thread_init(); /* waiting work thread complete its task */ ms_monitor_slap_mode(); /* clean up */ ms_thread_cleanup(); ms_global_struct_destroy(); ms_setting_cleanup(); return EXIT_SUCCESS; } /* main */ libmemcached-1.0.8/clients/memtouch.cc0000664000076400007640000001223711753573717020215 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #include #include #include #include #include #include #include #include "utilities.h" #define PROGRAM_NAME "memtouch" #define PROGRAM_DESCRIPTION "Update the expiration value of an alreasy existing value in the sever" /* Prototypes */ void options_parse(int argc, char *argv[]); static int opt_binary= 0; static int opt_verbose= 0; static char *opt_servers= NULL; static char *opt_hash= NULL; static char *opt_username; static char *opt_passwd; time_t expiration= 0; int main(int argc, char *argv[]) { int return_code= EXIT_SUCCESS; options_parse(argc, argv); initialize_sockets(); if (opt_servers == NULL) { char *temp; if ((temp= getenv("MEMCACHED_SERVERS"))) { opt_servers= strdup(temp); } else { std::cerr << "No Servers provided" << std::endl; return EXIT_FAILURE; } } memcached_st *memc= memcached_create(NULL); process_hash_option(memc, opt_hash); memcached_server_st *servers= memcached_servers_parse(opt_servers); memcached_server_push(memc, servers); memcached_server_list_free(servers); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, (uint64_t)opt_binary); if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0) { memcached_free(memc); std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl; return EXIT_FAILURE; } if (opt_username) { memcached_return_t ret; if (memcached_failed(ret= memcached_set_sasl_auth_data(memc, opt_username, opt_passwd))) { std::cerr << memcached_last_error_message(memc) << std::endl; memcached_free(memc); return EXIT_FAILURE; } } while (optind < argc) { memcached_return_t rc= memcached_touch(memc, argv[optind], strlen(argv[optind]), expiration); if (rc == MEMCACHED_NOTFOUND) { if (opt_verbose) { std::cout << "Could not find key \"" << argv[optind] << "\"" << std::endl; } return_code= EXIT_FAILURE; } else if (memcached_failed(rc)) { if (opt_verbose) { std::cerr << "Fatal error for key \"" << argv[optind] << "\" :" << memcached_last_error_message(memc) << std::endl; } return_code= EXIT_FAILURE; } else // success { if (opt_verbose) { std::cout << "Found key " << argv[optind] << std::endl; } } optind++; } memcached_free(memc); if (opt_servers) { free(opt_servers); } if (opt_hash) { free(opt_hash); } return return_code; } void options_parse(int argc, char *argv[]) { memcached_programs_help_st help_options[]= { {0}, }; static struct option long_options[]= { {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, {(OPTIONSTRING)"quiet", no_argument, NULL, OPT_QUIET}, {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, {(OPTIONSTRING)"hash", required_argument, NULL, OPT_HASH}, {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, {(OPTIONSTRING)"username", required_argument, NULL, OPT_USERNAME}, {(OPTIONSTRING)"password", required_argument, NULL, OPT_PASSWD}, {(OPTIONSTRING)"expire", required_argument, NULL, OPT_EXPIRE}, {0, 0, 0, 0}, }; bool opt_version= false; bool opt_help= false; int option_index= 0; while (1) { int option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) { break; } switch (option_rv) { case 0: break; case OPT_BINARY: opt_binary = true; break; case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = OPT_VERBOSE; break; case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; case OPT_VERSION: /* --version or -V */ opt_version= true; break; case OPT_HELP: /* --help or -h */ opt_help= true; break; case OPT_SERVERS: /* --servers or -s */ opt_servers= strdup(optarg); break; case OPT_HASH: opt_hash= strdup(optarg); break; case OPT_USERNAME: opt_username= optarg; break; case OPT_PASSWD: opt_passwd= optarg; break; case OPT_EXPIRE: expiration= time_t(strtoul(optarg, (char **)NULL, 10)); break; case OPT_QUIET: close_stdio(); break; case '?': /* getopt_long already printed an error message. */ exit(EXIT_FAILURE); default: abort(); } } if (opt_version) { version_command(PROGRAM_NAME); exit(EXIT_SUCCESS); } if (opt_help) { help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options); exit(EXIT_SUCCESS); } } libmemcached-1.0.8/clients/client_options.h0000664000076400007640000000145511753573717021267 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #pragma once typedef struct memcached_help_text_st memcached_help_text_st; enum memcached_options { OPT_SERVERS= 's', OPT_VERSION= 'V', OPT_HELP= 'h', OPT_VERBOSE= 'v', OPT_DEBUG= 'd', OPT_ANALYZE= 'a', OPT_FLAG= 257, OPT_EXPIRE, OPT_SET, OPT_REPLACE, OPT_ADD, OPT_SLAP_EXECUTE_NUMBER, OPT_SLAP_INITIAL_LOAD, OPT_SLAP_TEST, OPT_SLAP_CONCURRENCY, OPT_SLAP_NON_BLOCK, OPT_SLAP_TCP_NODELAY, OPT_FLUSH, OPT_HASH, OPT_BINARY, OPT_UDP, OPT_BUFFER, OPT_USERNAME, OPT_PASSWD, OPT_STAT_ARGS, OPT_SERVER_VERSION, OPT_QUIET, OPT_FILE= 'f' }; libmemcached-1.0.8/clients/ms_conn.h0000664000076400007640000002305111753573717017666 0ustar00brianbrian00000000000000/* * File: ms_conn.h * Author: Mingqiang Zhuang * * Created on February 10, 2009 * * (c) Copyright 2009, Schooner Information Technology, Inc. * http://www.schoonerinfotech.com/ * */ #ifndef MS_CONN_H #define MS_CONN_H #include #include #include #include #include "ms_task.h" #include #ifdef __cplusplus extern "C" { #endif #define DATA_BUFFER_SIZE (1024 * 1024 + 2048) /* read buffer, 1M + 2k, enough for the max value(1M) */ #define WRITE_BUFFER_SIZE (32 * 1024) /* write buffer, 32k */ #define UDP_DATA_BUFFER_SIZE (1 * 1024 * 1024) /* read buffer for UDP, 1M */ #define UDP_MAX_PAYLOAD_SIZE 1400 /* server limit UDP payload size */ #define UDP_MAX_SEND_PAYLOAD_SIZE 1400 /* mtu size is 1500 */ #define UDP_HEADER_SIZE 8 /* UDP header size */ #define MAX_SENDBUF_SIZE (256 * 1024 * 1024) /* Maximum socket buffer size */ #define SOCK_WAIT_TIMEOUT 30 /* maximum waiting time of UDP, 30s */ #define MAX_UDP_PACKET (1 << 16) /* maximum UDP packets, 65536 */ /* Initial size of the sendmsg() scatter/gather array. */ #define IOV_LIST_INITIAL 400 /* Initial number of sendmsg() argument structures to allocate. */ #define MSG_LIST_INITIAL 10 /* High water marks for buffer shrinking */ #define READ_BUFFER_HIGHWAT (2 * DATA_BUFFER_SIZE) #define UDP_DATA_BUFFER_HIGHWAT (4 * UDP_DATA_BUFFER_SIZE) #define IOV_LIST_HIGHWAT 600 #define MSG_LIST_HIGHWAT 100 /* parse udp header */ #define HEADER_TO_REQID(ptr) ((uint16_t)*ptr * 256 \ + (uint16_t)*(ptr + 1)) #define HEADER_TO_SEQNUM(ptr) ((uint16_t)*(ptr \ + 2) * 256 \ + (uint16_t)*(ptr + 3)) #define HEADER_TO_PACKETS(ptr) ((uint16_t)*(ptr \ + 4) * 256 \ + (uint16_t)*(ptr + 5)) /* states of connection */ enum conn_states { conn_read, /* reading in a command line */ conn_write, /* writing out a simple response */ conn_closing /* closing this connection */ }; /* returned states of memcached command */ enum mcd_ret { MCD_SUCCESS, /* command success */ MCD_FAILURE, /* command failure */ MCD_UNKNOWN_READ_FAILURE, /* unknown read failure */ MCD_PROTOCOL_ERROR, /* protocol error */ MCD_CLIENT_ERROR, /* client error, wrong command */ MCD_SERVER_ERROR, /* server error, server run command failed */ MCD_DATA_EXISTS, /* object is existent in server */ MCD_NOTSTORED, /* server doesn't set the object successfully */ MCD_STORED, /* server set the object successfully */ MCD_NOTFOUND, /* server not find the object */ MCD_END, /* end of the response of get command */ MCD_DELETED, /* server delete the object successfully */ MCD_STAT /* response of stats command */ }; /* used to store the current or previous running command state */ typedef struct cmdstat { int cmd; /* command name */ int retstat; /* return state of this command */ bool isfinish; /* if it read all the response data */ uint64_t key_prefix; /* key prefix */ } ms_cmdstat_t; /* udp packet structure */ typedef struct udppkt { uint8_t *header; /* udp header of the packet */ char *data; /* udp data of the packet */ int rbytes; /* number of data in the packet */ int copybytes; /* number of copied data in the packet */ } ms_udppkt_t; /* three protocols supported */ enum protocol { ascii_prot = 3, /* ASCII protocol */ binary_prot /* binary protocol */ }; /** * concurrency structure * * Each thread has a libevent to manage the events of network. * Each thread has one or more self-governed concurrencies; * each concurrency has one or more socket connections. This * concurrency structure includes all the private variables of * the concurrency. */ typedef struct conn { uint32_t conn_idx; /* connection index in the thread */ int sfd; /* current tcp sock handler of the connection structure */ int udpsfd; /* current udp sock handler of the connection structure*/ int state; /* state of the connection */ struct event event; /* event for libevent */ short ev_flags; /* event flag for libevent */ short which; /* which events were just triggered */ bool change_sfd; /* whether change sfd */ int *tcpsfd; /* TCP sock array */ uint32_t total_sfds; /* how many socks in the tcpsfd array */ uint32_t alive_sfds; /* alive socks */ uint32_t cur_idx; /* current sock index in tcpsfd array */ ms_cmdstat_t precmd; /* previous command state */ ms_cmdstat_t currcmd; /* current command state */ char *rbuf; /* buffer to read commands into */ char *rcurr; /* but if we parsed some already, this is where we stopped */ int rsize; /* total allocated size of rbuf */ int rbytes; /* how much data, starting from rcur, do we have unparsed */ bool readval; /* read value state, read known data size */ int rvbytes; /* total value size need to read */ char *wbuf; /* buffer to write commands out */ char *wcurr; /* for multi-get, where we stopped */ int wsize; /* total allocated size of wbuf */ bool ctnwrite; /* continue to write */ /* data for the mwrite state */ struct iovec *iov; int iovsize; /* number of elements allocated in iov[] */ int iovused; /* number of elements used in iov[] */ struct msghdr *msglist; int msgsize; /* number of elements allocated in msglist[] */ int msgused; /* number of elements used in msglist[] */ int msgcurr; /* element in msglist[] being transmitted now */ int msgbytes; /* number of bytes in current msg */ /* data for UDP clients */ bool udp; /* is this is a UDP "connection" */ uint32_t request_id; /* UDP request ID of current operation, if this is a UDP "connection" */ uint8_t *hdrbuf; /* udp packet headers */ int hdrsize; /* number of headers' worth of space is allocated */ struct sockaddr srv_recv_addr; /* Sent the most recent request to which server */ socklen_t srv_recv_addr_size; /* udp read buffer */ char *rudpbuf; /* buffer to read commands into for udp */ int rudpsize; /* total allocated size of rudpbuf */ int rudpbytes; /* how much data, starting from rudpbuf */ /* order udp packet */ ms_udppkt_t *udppkt; /* the offset of udp packet in rudpbuf */ int packets; /* number of total packets need to read */ int recvpkt; /* number of received packets */ int pktcurr; /* current packet in rudpbuf being ordered */ int ordcurr; /* current ordered packet */ ms_task_item_t *item_win; /* task sequence */ int win_size; /* current task window size */ uint64_t set_cursor; /* current set item index in the item window */ ms_task_t curr_task; /* current running task */ ms_mlget_task_t mlget_task; /* multi-get task */ int warmup_num; /* to run how many warm up operations*/ int remain_warmup_num; /* left how many warm up operations to run */ int64_t exec_num; /* to run how many task operations */ int64_t remain_exec_num; /* how many remained task operations to run */ /* response time statistic and time out control */ struct timeval start_time; /* start time of current operation(s) */ struct timeval end_time; /* end time of current operation(s) */ /* Binary protocol stuff */ protocol_binary_response_header binary_header; /* local temporary binary header */ enum protocol protocol; /* which protocol this connection speaks */ } ms_conn_t; /* used to generate the key prefix */ uint64_t ms_get_key_prefix(void); /** * setup a connection, each connection structure of each * thread must call this function to initialize. */ int ms_setup_conn(ms_conn_t *c); /* after one operation completes, reset the connection */ void ms_reset_conn(ms_conn_t *c, bool timeout); /** * reconnect several disconnected socks in the connection * structure, the ever-1-second timer of the thread will check * whether some socks in the connections disconnect. if * disconnect, reconnect the sock. */ int ms_reconn_socks(ms_conn_t *c); /* used to send set command to server */ int ms_mcd_set(ms_conn_t *c, ms_task_item_t *item); /* used to send the get command to server */ int ms_mcd_get(ms_conn_t *c, ms_task_item_t *item); /* used to send the multi-get command to server */ int ms_mcd_mlget(ms_conn_t *c); #ifdef __cplusplus } #endif #endif /* end of MS_CONN_H */ libmemcached-1.0.8/clients/ms_stats.c0000664000076400007640000001575011753573717020071 0ustar00brianbrian00000000000000/* * File: ms_stats.h * Author: Mingqiang Zhuang * * Created on March 25, 2009 * * (c) Copyright 2009, Schooner Information Technology, Inc. * http://www.schoonerinfotech.com/ * */ #include "config.h" #include #include "ms_stats.h" #define array_size(x) (sizeof(x) / sizeof((x)[0])) static int ms_local_log2(uint64_t value); static uint64_t ms_get_events(ms_stat_t *stat); /** * get the index of local log2 array * * @param value * * @return return the index of local log2 array */ static int ms_local_log2(uint64_t value) { int result= 0; while (result <= 63 && ((uint64_t)1 << result) < value) { result++; } return result; } /* ms_local_log2 */ /** * initialize statistic structure * * @param stat, pointer of the statistic structure * @param name, name of the statistic */ void ms_init_stats(ms_stat_t *stat, const char *name) { memset(stat, 0, sizeof(*stat)); stat->name= (char *)name; stat->min_time= (uint64_t)-1; stat->max_time= 0; stat->period_min_time= (uint64_t)-1; stat->period_max_time= 0; stat->log_product= 0; stat->total_time= 0; stat->pre_total_time= 0; stat->squares= 0; stat->pre_squares= 0; stat->pre_events= 0; stat->pre_log_product= 0; stat->get_miss= 0; stat->pre_get_miss= 0; } /* ms_init_stats */ /** * record one event * * @param stat, pointer of the statistic structure * @param total_time, response time of the command * @param get_miss, whether it gets miss */ void ms_record_event(ms_stat_t *stat, uint64_t total_time, int get_miss) { stat->total_time+= total_time; if (total_time < stat->min_time) { stat->min_time= total_time; } if (total_time > stat->max_time) { stat->max_time= total_time; } if (total_time < stat->period_min_time) { stat->period_min_time= total_time; } if (total_time > stat->period_max_time) { stat->period_max_time= total_time; } if (get_miss) { stat->get_miss++; } stat->dist[ms_local_log2(total_time)]++; stat->squares+= (double)(total_time * total_time); if (total_time != 0) { stat->log_product+= log((double)total_time); } } /* ms_record_event */ /** * get the events count * * @param stat, pointer of the statistic structure * * @return total events recorded */ static uint64_t ms_get_events(ms_stat_t *stat) { uint64_t events= 0; for (uint32_t i= 0; i < array_size(stat->dist); i++) { events+= stat->dist[i]; } return events; } /* ms_get_events */ /** * dump the statistics * * @param stat, pointer of the statistic structure */ void ms_dump_stats(ms_stat_t *stat) { uint64_t events= 0; int max_non_zero= 0; int min_non_zero= 0; double average= 0; for (uint32_t i= 0; i < array_size(stat->dist); i++) { events+= stat->dist[i]; if (stat->dist[i] != 0) { max_non_zero= (int)i; } } if (events == 0) { return; } average= (double)(stat->total_time / events); printf("%s Statistics (%lld events)\n", stat->name, (long long)events); printf(" Min: %8lld\n", (long long)stat->min_time); printf(" Max: %8lld\n", (long long)stat->max_time); printf(" Avg: %8lld\n", (long long)(stat->total_time / events)); printf(" Geo: %8.2lf\n", exp(stat->log_product / (double)events)); if (events > 1) { printf(" Std: %8.2lf\n", sqrt((stat->squares - (double)events * average * average) / ((double)events - 1))); } printf(" Log2 Dist:"); for (int i= 0; i <= max_non_zero - 4; i+= 4) { if ((stat->dist[i + 0] != 0) || (stat->dist[i + 1] != 0) || (stat->dist[i + 2] != 0) || (stat->dist[i + 3] != 0)) { min_non_zero= i; break; } } for (int i= min_non_zero; i <= max_non_zero; i++) { if ((i % 4) == 0) { printf("\n %2d:", (int)i); } printf(" %6" PRIu64 , stat->dist[i]); } printf("\n\n"); } /* ms_dump_stats */ /** * dump the format statistics * * @param stat, pointer of the statistic structure * @param run_time, the total run time * @param freq, statistic frequency * @param obj_size, average object size */ void ms_dump_format_stats(ms_stat_t *stat, int run_time, int freq, int obj_size) { uint64_t events= 0; double global_average= 0; uint64_t global_tps= 0; double global_rate= 0; double global_std= 0; double global_log= 0; uint64_t diff_time= 0; uint64_t diff_events= 0; double diff_squares= 0; double diff_log_product= 0; double period_average= 0; uint64_t period_tps= 0; double period_rate= 0; double period_std= 0; double period_log= 0; if ((events= ms_get_events(stat)) == 0) { return; } global_average= (double)(stat->total_time / events); global_tps= events / (uint64_t)run_time; global_rate= (double)events * obj_size / 1024 / 1024 / run_time; global_std= sqrt((stat->squares - (double)events * global_average * global_average) / (double)(events - 1)); global_log= exp(stat->log_product / (double)events); diff_time= stat->total_time - stat->pre_total_time; diff_events= events - stat->pre_events; if (diff_events >= 1) { period_average= (double)(diff_time / diff_events); period_tps= diff_events / (uint64_t)freq; period_rate= (double)diff_events * obj_size / 1024 / 1024 / freq; diff_squares= (double)stat->squares - (double)stat->pre_squares; period_std= sqrt((diff_squares - (double)diff_events * period_average * period_average) / (double)(diff_events - 1)); diff_log_product= stat->log_product - stat->pre_log_product; period_log= exp(diff_log_product / (double)diff_events); } printf("%s Statistics\n", stat->name); printf("%-8s %-8s %-12s %-12s %-10s %-10s %-8s %-10s %-10s %-10s %-10s\n", "Type", "Time(s)", "Ops", "TPS(ops/s)", "Net(M/s)", "Get_miss", "Min(us)", "Max(us)", "Avg(us)", "Std_dev", "Geo_dist"); printf( "%-8s %-8d %-12llu %-12lld %-10.1f %-10lld %-8lld %-10lld %-10lld %-10.2f %.2f\n", "Period", freq, (long long)diff_events, (long long)period_tps, global_rate, (long long)(stat->get_miss - stat->pre_get_miss), (long long)stat->period_min_time, (long long)stat->period_max_time, (long long)period_average, period_std, period_log); printf( "%-8s %-8d %-12llu %-12lld %-10.1f %-10lld %-8lld %-10lld %-10lld %-10.2f %.2f\n\n", "Global", run_time, (long long)events, (long long)global_tps, period_rate, (long long)stat->get_miss, (long long)stat->min_time, (long long)stat->max_time, (long long)global_average, global_std, global_log); stat->pre_events= events; stat->pre_squares= (uint64_t)stat->squares; stat->pre_total_time= stat->total_time; stat->pre_log_product= stat->log_product; stat->period_min_time= (uint64_t)-1; stat->period_max_time= 0; stat->pre_get_miss= stat->get_miss; } /* ms_dump_format_stats */ libmemcached-1.0.8/clients/memcapable.cc0000664000076400007640000016201711753573717020464 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ /* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ #undef NDEBUG #include #ifdef HAVE_POLL_H #include #else #include "poll/poll.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef linux /* /usr/include/netinet/in.h defines macros from ntohs() to _bswap_nn to * optimize the conversion functions, but the prototypes generate warnings * from gcc. The conversion methods isn't the bottleneck for my app, so * just remove the warnings by undef'ing the optimization .. */ #undef ntohs #undef ntohl #endif /* Should we generate coredumps when we enounter an error (-c) */ static bool do_core= false; /* connection to the server */ static memcached_socket_t sock; /* Should the output from test failures be verbose or quiet? */ static bool verbose= false; /* The number of seconds to wait for an IO-operation */ static int timeout= 2; /* * Instead of having to cast between the different datatypes we create * a union of all of the different types of pacages we want to send. * A lot of the different commands use the same packet layout, so I'll * just define the different types I need. The typedefs only contain * the header of the message, so we need some space for keys and body * To avoid to have to do multiple writes, lets add a chunk of memory * to use. 1k should be more than enough for header, key and body. */ typedef union { protocol_binary_request_no_extras plain; protocol_binary_request_flush flush; protocol_binary_request_incr incr; protocol_binary_request_set set; char bytes[1024]; } command; typedef union { protocol_binary_response_no_extras plain; protocol_binary_response_incr incr; protocol_binary_response_decr decr; char bytes[1024]; } response; enum test_return { TEST_SKIP, TEST_PASS, TEST_PASS_RECONNECT, TEST_FAIL }; /** * Try to get an addrinfo struct for a given port on a given host */ static struct addrinfo *lookuphost(const char *hostname, const char *port) { struct addrinfo *ai= 0; struct addrinfo hints; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family=AF_UNSPEC; hints.ai_protocol=IPPROTO_TCP; hints.ai_socktype=SOCK_STREAM; int error= getaddrinfo(hostname, port, &hints, &ai); if (error != 0) { if (error != EAI_SYSTEM) fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(error)); else perror("getaddrinfo()"); } return ai; } /** * Set the socket in nonblocking mode * @return -1 if failure, the socket otherwise */ static memcached_socket_t set_noblock(void) { #ifdef WIN32 u_long arg = 1; if (ioctlsocket(sock, FIONBIO, &arg) == SOCKET_ERROR) { perror("Failed to set nonblocking io"); closesocket(sock); return INVALID_SOCKET; } #else int flags= fcntl(sock, F_GETFL, 0); if (flags == -1) { perror("Failed to get socket flags"); memcached_close_socket(sock); return INVALID_SOCKET; } if ((flags & O_NONBLOCK) != O_NONBLOCK) { if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) == -1) { perror("Failed to set socket to nonblocking mode"); memcached_close_socket(sock); return INVALID_SOCKET; } } #endif return sock; } /** * Try to open a connection to the server * @param hostname the name of the server to connect to * @param port the port number (or service) to connect to * @return positive integer if success, -1 otherwise */ static memcached_socket_t connect_server(const char *hostname, const char *port) { struct addrinfo *ai= lookuphost(hostname, port); sock= INVALID_SOCKET; if (ai != NULL) { if ((sock= socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) != INVALID_SOCKET) { if (connect(sock, ai->ai_addr, ai->ai_addrlen) == SOCKET_ERROR) { fprintf(stderr, "Failed to connect socket: %s\n", strerror(get_socket_errno())); closesocket(sock); sock= INVALID_SOCKET; } else { sock= set_noblock(); } } else fprintf(stderr, "Failed to create socket: %s\n", strerror(get_socket_errno())); freeaddrinfo(ai); } return sock; } static ssize_t timeout_io_op(memcached_socket_t fd, short direction, void *buf, size_t len) { ssize_t ret; if (direction == POLLOUT) { ret= send(fd, buf, len, 0); } else { ret= recv(fd, buf, len, 0); } if (ret == SOCKET_ERROR && get_socket_errno() == EWOULDBLOCK) { struct pollfd fds; memset(&fds, 0, sizeof(struct pollfd)); fds.events= direction; fds.fd= fd; int err= poll(&fds, 1, timeout * 1000); if (err == 1) { if (direction == POLLOUT) { ret= send(fd, buf, len, 0); } else { ret= recv(fd, buf, len, 0); } } else if (err == 0) { errno= ETIMEDOUT; } else { perror("Failed to poll"); return -1; } } return ret; } /** * Ensure that an expression is true. If it isn't print out a message similar * to assert() and create a coredump if the user wants that. If not an error * message is returned. * */ static enum test_return ensure(bool val, const char *expression, const char *file, int line) { if (!val) { if (verbose) { fprintf(stderr, "\n%s:%d: %s", file, line, expression); } if (do_core) { abort(); } return TEST_FAIL; } return TEST_PASS; } #define verify(expression) do { if (ensure(expression, #expression, __FILE__, __LINE__) == TEST_FAIL) return TEST_FAIL; } while (0) #define execute(expression) do { if (ensure(expression == TEST_PASS, #expression, __FILE__, __LINE__) == TEST_FAIL) return TEST_FAIL; } while (0) /** * Send a chunk of memory over the socket (retry if the call is iterrupted */ static enum test_return retry_write(const void* buf, size_t len) { size_t offset= 0; const char* ptr= static_cast(buf); do { size_t num_bytes= len - offset; ssize_t nw= timeout_io_op(sock, POLLOUT, (void*)(ptr + offset), num_bytes); if (nw == -1) { verify(get_socket_errno() == EINTR || get_socket_errno() == EAGAIN); } else { offset+= (size_t)nw; } } while (offset < len); return TEST_PASS; } /** * Resend a packet to the server (All fields in the command header should * be in network byte order) */ static enum test_return resend_packet(command *cmd) { size_t length= sizeof (protocol_binary_request_no_extras) + ntohl(cmd->plain.message.header.request.bodylen); execute(retry_write(cmd, length)); return TEST_PASS; } /** * Send a command to the server. The command header needs to be updated * to network byte order */ static enum test_return send_packet(command *cmd) { /* Fix the byteorder of the header */ cmd->plain.message.header.request.keylen= ntohs(cmd->plain.message.header.request.keylen); cmd->plain.message.header.request.bodylen= ntohl(cmd->plain.message.header.request.bodylen); cmd->plain.message.header.request.cas= memcached_ntohll(cmd->plain.message.header.request.cas); execute(resend_packet(cmd)); return TEST_PASS; } /** * Read a fixed length chunk of data from the server */ static enum test_return retry_read(void *buf, size_t len) { size_t offset= 0; do { ssize_t nr= timeout_io_op(sock, POLLIN, ((char*) buf) + offset, len - offset); switch (nr) { case -1 : fprintf(stderr, "Errno: %d %s\n", get_socket_errno(), strerror(errno)); verify(get_socket_errno() == EINTR || get_socket_errno() == EAGAIN); break; case 0: return TEST_FAIL; default: offset+= (size_t)nr; } } while (offset < len); return TEST_PASS; } /** * Receive a response from the server and conver the fields in the header * to local byte order */ static enum test_return recv_packet(response *rsp) { execute(retry_read(rsp, sizeof(protocol_binary_response_no_extras))); /* Fix the byte order in the packet header */ rsp->plain.message.header.response.keylen= ntohs(rsp->plain.message.header.response.keylen); rsp->plain.message.header.response.status= ntohs(rsp->plain.message.header.response.status); rsp->plain.message.header.response.bodylen= ntohl(rsp->plain.message.header.response.bodylen); rsp->plain.message.header.response.cas= memcached_ntohll(rsp->plain.message.header.response.cas); size_t bodysz= rsp->plain.message.header.response.bodylen; if (bodysz > 0) execute(retry_read(rsp->bytes + sizeof (protocol_binary_response_no_extras), bodysz)); return TEST_PASS; } /** * Create a storage command (add, set, replace etc) * * @param cmd destination buffer * @param cc the storage command to create * @param key the key to store * @param keylen the length of the key * @param dta the data to store with the key * @param dtalen the length of the data to store with the key * @param flags the flags to store along with the key * @param exptime the expiry time for the key */ static void storage_command(command *cmd, uint8_t cc, const void* key, size_t keylen, const void* dta, size_t dtalen, uint32_t flags, uint32_t exptime) { /* all of the storage commands use the same command layout */ protocol_binary_request_set *request= &cmd->set; memset(request, 0, sizeof (*request)); request->message.header.request.magic= PROTOCOL_BINARY_REQ; request->message.header.request.opcode= cc; request->message.header.request.keylen= (uint16_t)keylen; request->message.header.request.extlen= 8; request->message.header.request.bodylen= (uint32_t)(keylen + 8 + dtalen); request->message.header.request.opaque= 0xdeadbeef; request->message.body.flags= flags; request->message.body.expiration= exptime; off_t key_offset= sizeof (protocol_binary_request_no_extras) + 8; memcpy(cmd->bytes + key_offset, key, keylen); if (dta != NULL) memcpy(cmd->bytes + key_offset + keylen, dta, dtalen); } /** * Create a basic command to send to the server * @param cmd destination buffer * @param cc the command to create * @param key the key to store * @param keylen the length of the key * @param dta the data to store with the key * @param dtalen the length of the data to store with the key */ static void raw_command(command *cmd, uint8_t cc, const void* key, size_t keylen, const void* dta, size_t dtalen) { /* all of the storage commands use the same command layout */ memset(cmd, 0, sizeof (*cmd)); cmd->plain.message.header.request.magic= PROTOCOL_BINARY_REQ; cmd->plain.message.header.request.opcode= cc; cmd->plain.message.header.request.keylen= (uint16_t)keylen; cmd->plain.message.header.request.bodylen= (uint32_t)(keylen + dtalen); cmd->plain.message.header.request.opaque= 0xdeadbeef; off_t key_offset= sizeof (protocol_binary_request_no_extras); if (key != NULL) memcpy(cmd->bytes + key_offset, key, keylen); if (dta != NULL) memcpy(cmd->bytes + key_offset + keylen, dta, dtalen); } /** * Create the flush command * @param cmd destination buffer * @param cc the command to create (FLUSH/FLUSHQ) * @param exptime when to flush * @param use_extra to force using of the extra field? */ static void flush_command(command *cmd, uint8_t cc, uint32_t exptime, bool use_extra) { memset(cmd, 0, sizeof (cmd->flush)); cmd->flush.message.header.request.magic= PROTOCOL_BINARY_REQ; cmd->flush.message.header.request.opcode= cc; cmd->flush.message.header.request.opaque= 0xdeadbeef; if (exptime != 0 || use_extra) { cmd->flush.message.header.request.extlen= 4; cmd->flush.message.body.expiration= htonl(exptime); cmd->flush.message.header.request.bodylen= 4; } } /** * Create a incr/decr command * @param cc the cmd to create (FLUSH/FLUSHQ) * @param key the key to operate on * @param keylen the number of bytes in the key * @param delta the number to add/subtract * @param initial the initial value if the key doesn't exist * @param exptime when the key should expire if it isn't set */ static void arithmetic_command(command *cmd, uint8_t cc, const void* key, size_t keylen, uint64_t delta, uint64_t initial, uint32_t exptime) { memset(cmd, 0, sizeof (cmd->incr)); cmd->incr.message.header.request.magic= PROTOCOL_BINARY_REQ; cmd->incr.message.header.request.opcode= cc; cmd->incr.message.header.request.keylen= (uint16_t)keylen; cmd->incr.message.header.request.extlen= 20; cmd->incr.message.header.request.bodylen= (uint32_t)(keylen + 20); cmd->incr.message.header.request.opaque= 0xdeadbeef; cmd->incr.message.body.delta= memcached_htonll(delta); cmd->incr.message.body.initial= memcached_htonll(initial); cmd->incr.message.body.expiration= htonl(exptime); off_t key_offset= sizeof (protocol_binary_request_no_extras) + 20; memcpy(cmd->bytes + key_offset, key, keylen); } /** * Validate the response header from the server * @param rsp the response to check * @param cc the expected command * @param status the expected status */ static enum test_return do_validate_response_header(response *rsp, uint8_t cc, uint16_t status) { verify(rsp->plain.message.header.response.magic == PROTOCOL_BINARY_RES); verify(rsp->plain.message.header.response.opcode == cc); verify(rsp->plain.message.header.response.datatype == PROTOCOL_BINARY_RAW_BYTES); verify(rsp->plain.message.header.response.status == status); verify(rsp->plain.message.header.response.opaque == 0xdeadbeef); if (status == PROTOCOL_BINARY_RESPONSE_SUCCESS) { switch (cc) { case PROTOCOL_BINARY_CMD_ADDQ: case PROTOCOL_BINARY_CMD_APPENDQ: case PROTOCOL_BINARY_CMD_DECREMENTQ: case PROTOCOL_BINARY_CMD_DELETEQ: case PROTOCOL_BINARY_CMD_FLUSHQ: case PROTOCOL_BINARY_CMD_INCREMENTQ: case PROTOCOL_BINARY_CMD_PREPENDQ: case PROTOCOL_BINARY_CMD_QUITQ: case PROTOCOL_BINARY_CMD_REPLACEQ: case PROTOCOL_BINARY_CMD_SETQ: verify("Quiet command shouldn't return on success" == NULL); default: break; } switch (cc) { case PROTOCOL_BINARY_CMD_ADD: case PROTOCOL_BINARY_CMD_REPLACE: case PROTOCOL_BINARY_CMD_SET: case PROTOCOL_BINARY_CMD_APPEND: case PROTOCOL_BINARY_CMD_PREPEND: verify(rsp->plain.message.header.response.keylen == 0); verify(rsp->plain.message.header.response.extlen == 0); verify(rsp->plain.message.header.response.bodylen == 0); verify(rsp->plain.message.header.response.cas != 0); break; case PROTOCOL_BINARY_CMD_FLUSH: case PROTOCOL_BINARY_CMD_NOOP: case PROTOCOL_BINARY_CMD_QUIT: case PROTOCOL_BINARY_CMD_DELETE: verify(rsp->plain.message.header.response.keylen == 0); verify(rsp->plain.message.header.response.extlen == 0); verify(rsp->plain.message.header.response.bodylen == 0); verify(rsp->plain.message.header.response.cas == 0); break; case PROTOCOL_BINARY_CMD_DECREMENT: case PROTOCOL_BINARY_CMD_INCREMENT: verify(rsp->plain.message.header.response.keylen == 0); verify(rsp->plain.message.header.response.extlen == 0); verify(rsp->plain.message.header.response.bodylen == 8); verify(rsp->plain.message.header.response.cas != 0); break; case PROTOCOL_BINARY_CMD_STAT: verify(rsp->plain.message.header.response.extlen == 0); /* key and value exists in all packets except in the terminating */ verify(rsp->plain.message.header.response.cas == 0); break; case PROTOCOL_BINARY_CMD_VERSION: verify(rsp->plain.message.header.response.keylen == 0); verify(rsp->plain.message.header.response.extlen == 0); verify(rsp->plain.message.header.response.bodylen != 0); verify(rsp->plain.message.header.response.cas == 0); break; case PROTOCOL_BINARY_CMD_GET: case PROTOCOL_BINARY_CMD_GETQ: verify(rsp->plain.message.header.response.keylen == 0); verify(rsp->plain.message.header.response.extlen == 4); verify(rsp->plain.message.header.response.cas != 0); break; case PROTOCOL_BINARY_CMD_GETK: case PROTOCOL_BINARY_CMD_GETKQ: verify(rsp->plain.message.header.response.keylen != 0); verify(rsp->plain.message.header.response.extlen == 4); verify(rsp->plain.message.header.response.cas != 0); break; default: /* Undefined command code */ break; } } else { verify(rsp->plain.message.header.response.cas == 0); verify(rsp->plain.message.header.response.extlen == 0); if (cc != PROTOCOL_BINARY_CMD_GETK) { verify(rsp->plain.message.header.response.keylen == 0); } } return TEST_PASS; } /* We call verify(validate_response_header), but that macro * expects a boolean expression, and the function returns * an enum.... Let's just create a macro to avoid cluttering * the code with all of the == TEST_PASS ;-) */ #define validate_response_header(a,b,c) \ do_validate_response_header(a,b,c) == TEST_PASS static enum test_return send_binary_noop(void) { command cmd; raw_command(&cmd, PROTOCOL_BINARY_CMD_NOOP, NULL, 0, NULL, 0); execute(send_packet(&cmd)); return TEST_PASS; } static enum test_return receive_binary_noop(void) { response rsp; execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, PROTOCOL_BINARY_CMD_NOOP, PROTOCOL_BINARY_RESPONSE_SUCCESS)); return TEST_PASS; } static enum test_return test_binary_noop(void) { execute(send_binary_noop()); execute(receive_binary_noop()); return TEST_PASS; } static enum test_return test_binary_quit_impl(uint8_t cc) { command cmd; response rsp; raw_command(&cmd, cc, NULL, 0, NULL, 0); execute(send_packet(&cmd)); if (cc == PROTOCOL_BINARY_CMD_QUIT) { execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, PROTOCOL_BINARY_CMD_QUIT, PROTOCOL_BINARY_RESPONSE_SUCCESS)); } /* Socket should be closed now, read should return EXIT_SUCCESS */ verify(timeout_io_op(sock, POLLIN, rsp.bytes, sizeof(rsp.bytes)) == 0); return TEST_PASS_RECONNECT; } static enum test_return test_binary_quit(void) { return test_binary_quit_impl(PROTOCOL_BINARY_CMD_QUIT); } static enum test_return test_binary_quitq(void) { return test_binary_quit_impl(PROTOCOL_BINARY_CMD_QUITQ); } static enum test_return test_binary_set_impl(const char* key, uint8_t cc) { command cmd; response rsp; uint64_t value= 0xdeadbeefdeadcafeULL; storage_command(&cmd, cc, key, strlen(key), &value, sizeof (value), 0, 0); /* set should always work */ for (int ii= 0; ii < 10; ii++) { if (ii == 0) { execute(send_packet(&cmd)); } else { execute(resend_packet(&cmd)); } if (cc == PROTOCOL_BINARY_CMD_SET) { execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_SUCCESS)); } else execute(test_binary_noop()); } /* * We need to get the current CAS id, and at this time we haven't * verified that we have a working get */ if (cc == PROTOCOL_BINARY_CMD_SETQ) { cmd.set.message.header.request.opcode= PROTOCOL_BINARY_CMD_SET; execute(resend_packet(&cmd)); execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, PROTOCOL_BINARY_CMD_SET, PROTOCOL_BINARY_RESPONSE_SUCCESS)); cmd.set.message.header.request.opcode= PROTOCOL_BINARY_CMD_SETQ; } /* try to set with the correct CAS value */ cmd.plain.message.header.request.cas= memcached_htonll(rsp.plain.message.header.response.cas); execute(resend_packet(&cmd)); if (cc == PROTOCOL_BINARY_CMD_SET) { execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_SUCCESS)); } else execute(test_binary_noop()); /* try to set with an incorrect CAS value */ cmd.plain.message.header.request.cas= memcached_htonll(rsp.plain.message.header.response.cas - 1); execute(resend_packet(&cmd)); execute(send_binary_noop()); execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS)); execute(receive_binary_noop()); return TEST_PASS; } static enum test_return test_binary_set(void) { return test_binary_set_impl("test_binary_set", PROTOCOL_BINARY_CMD_SET); } static enum test_return test_binary_setq(void) { return test_binary_set_impl("test_binary_setq", PROTOCOL_BINARY_CMD_SETQ); } static enum test_return test_binary_add_impl(const char* key, uint8_t cc) { command cmd; response rsp; uint64_t value= 0xdeadbeefdeadcafeULL; storage_command(&cmd, cc, key, strlen(key), &value, sizeof (value), 0, 0); /* first add should work, rest of them should fail (even with cas as wildcard */ for (int ii=0; ii < 10; ii++) { if (ii == 0) execute(send_packet(&cmd)); else execute(resend_packet(&cmd)); if (cc == PROTOCOL_BINARY_CMD_ADD || ii > 0) { uint16_t expected_result; if (ii == 0) expected_result= PROTOCOL_BINARY_RESPONSE_SUCCESS; else expected_result= PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; execute(send_binary_noop()); execute(recv_packet(&rsp)); execute(receive_binary_noop()); verify(validate_response_header(&rsp, cc, expected_result)); } else execute(test_binary_noop()); } return TEST_PASS; } static enum test_return test_binary_add(void) { return test_binary_add_impl("test_binary_add", PROTOCOL_BINARY_CMD_ADD); } static enum test_return test_binary_addq(void) { return test_binary_add_impl("test_binary_addq", PROTOCOL_BINARY_CMD_ADDQ); } static enum test_return binary_set_item(const char *key, const char *value) { command cmd; response rsp; storage_command(&cmd, PROTOCOL_BINARY_CMD_SET, key, strlen(key), value, strlen(value), 0, 0); execute(send_packet(&cmd)); execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, PROTOCOL_BINARY_CMD_SET, PROTOCOL_BINARY_RESPONSE_SUCCESS)); return TEST_PASS; } static enum test_return test_binary_replace_impl(const char* key, uint8_t cc) { command cmd; response rsp; uint64_t value= 0xdeadbeefdeadcafeULL; storage_command(&cmd, cc, key, strlen(key), &value, sizeof (value), 0, 0); /* first replace should fail, successive should succeed (when the item is added! */ for (int ii= 0; ii < 10; ii++) { if (ii == 0) { execute(send_packet(&cmd)); } else { execute(resend_packet(&cmd)); } if (cc == PROTOCOL_BINARY_CMD_REPLACE || ii == 0) { uint16_t expected_result; if (ii == 0) { expected_result=PROTOCOL_BINARY_RESPONSE_KEY_ENOENT; } else { expected_result=PROTOCOL_BINARY_RESPONSE_SUCCESS; } execute(send_binary_noop()); execute(recv_packet(&rsp)); execute(receive_binary_noop()); verify(validate_response_header(&rsp, cc, expected_result)); if (ii == 0) execute(binary_set_item(key, key)); } else { execute(test_binary_noop()); } } /* verify that replace with CAS value works! */ cmd.plain.message.header.request.cas= memcached_htonll(rsp.plain.message.header.response.cas); execute(resend_packet(&cmd)); if (cc == PROTOCOL_BINARY_CMD_REPLACE) { execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_SUCCESS)); } else execute(test_binary_noop()); /* try to set with an incorrect CAS value */ cmd.plain.message.header.request.cas= memcached_htonll(rsp.plain.message.header.response.cas - 1); execute(resend_packet(&cmd)); execute(send_binary_noop()); execute(recv_packet(&rsp)); execute(receive_binary_noop()); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS)); return TEST_PASS; } static enum test_return test_binary_replace(void) { return test_binary_replace_impl("test_binary_replace", PROTOCOL_BINARY_CMD_REPLACE); } static enum test_return test_binary_replaceq(void) { return test_binary_replace_impl("test_binary_replaceq", PROTOCOL_BINARY_CMD_REPLACEQ); } static enum test_return test_binary_delete_impl(const char *key, uint8_t cc) { command cmd; response rsp; raw_command(&cmd, cc, key, strlen(key), NULL, 0); /* The delete shouldn't work the first time, because the item isn't there */ execute(send_packet(&cmd)); execute(send_binary_noop()); execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT)); execute(receive_binary_noop()); execute(binary_set_item(key, key)); /* The item should be present now, resend*/ execute(resend_packet(&cmd)); if (cc == PROTOCOL_BINARY_CMD_DELETE) { execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_SUCCESS)); } execute(test_binary_noop()); return TEST_PASS; } static enum test_return test_binary_delete(void) { return test_binary_delete_impl("test_binary_delete", PROTOCOL_BINARY_CMD_DELETE); } static enum test_return test_binary_deleteq(void) { return test_binary_delete_impl("test_binary_deleteq", PROTOCOL_BINARY_CMD_DELETEQ); } static enum test_return test_binary_get_impl(const char *key, uint8_t cc) { command cmd; response rsp; raw_command(&cmd, cc, key, strlen(key), NULL, 0); execute(send_packet(&cmd)); execute(send_binary_noop()); if (cc == PROTOCOL_BINARY_CMD_GET || cc == PROTOCOL_BINARY_CMD_GETK) { execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT)); } execute(receive_binary_noop()); execute(binary_set_item(key, key)); execute(resend_packet(&cmd)); execute(send_binary_noop()); execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_SUCCESS)); execute(receive_binary_noop()); return TEST_PASS; } static enum test_return test_binary_get(void) { return test_binary_get_impl("test_binary_get", PROTOCOL_BINARY_CMD_GET); } static enum test_return test_binary_getk(void) { return test_binary_get_impl("test_binary_getk", PROTOCOL_BINARY_CMD_GETK); } static enum test_return test_binary_getq(void) { return test_binary_get_impl("test_binary_getq", PROTOCOL_BINARY_CMD_GETQ); } static enum test_return test_binary_getkq(void) { return test_binary_get_impl("test_binary_getkq", PROTOCOL_BINARY_CMD_GETKQ); } static enum test_return test_binary_incr_impl(const char* key, uint8_t cc) { command cmd; response rsp; arithmetic_command(&cmd, cc, key, strlen(key), 1, 0, 0); uint64_t ii; for (ii= 0; ii < 10; ++ii) { if (ii == 0) execute(send_packet(&cmd)); else execute(resend_packet(&cmd)); if (cc == PROTOCOL_BINARY_CMD_INCREMENT) { execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_SUCCESS)); verify(memcached_ntohll(rsp.incr.message.body.value) == ii); } else execute(test_binary_noop()); } /* @todo add incorrect CAS */ return TEST_PASS; } static enum test_return test_binary_incr(void) { return test_binary_incr_impl("test_binary_incr", PROTOCOL_BINARY_CMD_INCREMENT); } static enum test_return test_binary_incrq(void) { return test_binary_incr_impl("test_binary_incrq", PROTOCOL_BINARY_CMD_INCREMENTQ); } static enum test_return test_binary_decr_impl(const char* key, uint8_t cc) { command cmd; response rsp; arithmetic_command(&cmd, cc, key, strlen(key), 1, 9, 0); int ii; for (ii= 9; ii > -1; --ii) { if (ii == 9) execute(send_packet(&cmd)); else execute(resend_packet(&cmd)); if (cc == PROTOCOL_BINARY_CMD_DECREMENT) { execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_SUCCESS)); verify(memcached_ntohll(rsp.decr.message.body.value) == (uint64_t)ii); } else execute(test_binary_noop()); } /* decr 0 should not wrap */ execute(resend_packet(&cmd)); if (cc == PROTOCOL_BINARY_CMD_DECREMENT) { execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_SUCCESS)); verify(memcached_ntohll(rsp.decr.message.body.value) == 0); } else { /* @todo get the value and verify! */ } /* @todo add incorrect cas */ execute(test_binary_noop()); return TEST_PASS; } static enum test_return test_binary_decr(void) { return test_binary_decr_impl("test_binary_decr", PROTOCOL_BINARY_CMD_DECREMENT); } static enum test_return test_binary_decrq(void) { return test_binary_decr_impl("test_binary_decrq", PROTOCOL_BINARY_CMD_DECREMENTQ); } static enum test_return test_binary_version(void) { command cmd; response rsp; raw_command(&cmd, PROTOCOL_BINARY_CMD_VERSION, NULL, 0, NULL, 0); execute(send_packet(&cmd)); execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, PROTOCOL_BINARY_CMD_VERSION, PROTOCOL_BINARY_RESPONSE_SUCCESS)); return TEST_PASS; } static enum test_return test_binary_flush_impl(const char *key, uint8_t cc) { command cmd; response rsp; for (int ii= 0; ii < 2; ++ii) { execute(binary_set_item(key, key)); flush_command(&cmd, cc, 0, ii == 0); execute(send_packet(&cmd)); if (cc == PROTOCOL_BINARY_CMD_FLUSH) { execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_SUCCESS)); } else execute(test_binary_noop()); raw_command(&cmd, PROTOCOL_BINARY_CMD_GET, key, strlen(key), NULL, 0); execute(send_packet(&cmd)); execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, PROTOCOL_BINARY_CMD_GET, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT)); } return TEST_PASS; } static enum test_return test_binary_flush(void) { return test_binary_flush_impl("test_binary_flush", PROTOCOL_BINARY_CMD_FLUSH); } static enum test_return test_binary_flushq(void) { return test_binary_flush_impl("test_binary_flushq", PROTOCOL_BINARY_CMD_FLUSHQ); } static enum test_return test_binary_concat_impl(const char *key, uint8_t cc) { command cmd; response rsp; const char *value; if (cc == PROTOCOL_BINARY_CMD_APPEND || cc == PROTOCOL_BINARY_CMD_APPENDQ) { value="hello"; } else { value=" world"; } execute(binary_set_item(key, value)); if (cc == PROTOCOL_BINARY_CMD_APPEND || cc == PROTOCOL_BINARY_CMD_APPENDQ) { value=" world"; } else { value="hello"; } raw_command(&cmd, cc, key, strlen(key), value, strlen(value)); execute(send_packet(&cmd)); if (cc == PROTOCOL_BINARY_CMD_APPEND || cc == PROTOCOL_BINARY_CMD_PREPEND) { execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_SUCCESS)); } else { execute(test_binary_noop()); } raw_command(&cmd, PROTOCOL_BINARY_CMD_GET, key, strlen(key), NULL, 0); execute(send_packet(&cmd)); execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, PROTOCOL_BINARY_CMD_GET, PROTOCOL_BINARY_RESPONSE_SUCCESS)); verify(rsp.plain.message.header.response.bodylen - 4 == 11); verify(memcmp(rsp.bytes + 28, "hello world", 11) == 0); return TEST_PASS; } static enum test_return test_binary_append(void) { return test_binary_concat_impl("test_binary_append", PROTOCOL_BINARY_CMD_APPEND); } static enum test_return test_binary_prepend(void) { return test_binary_concat_impl("test_binary_prepend", PROTOCOL_BINARY_CMD_PREPEND); } static enum test_return test_binary_appendq(void) { return test_binary_concat_impl("test_binary_appendq", PROTOCOL_BINARY_CMD_APPENDQ); } static enum test_return test_binary_prependq(void) { return test_binary_concat_impl("test_binary_prependq", PROTOCOL_BINARY_CMD_PREPENDQ); } static enum test_return test_binary_stat(void) { command cmd; response rsp; raw_command(&cmd, PROTOCOL_BINARY_CMD_STAT, NULL, 0, NULL, 0); execute(send_packet(&cmd)); do { execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, PROTOCOL_BINARY_CMD_STAT, PROTOCOL_BINARY_RESPONSE_SUCCESS)); } while (rsp.plain.message.header.response.keylen != 0); return TEST_PASS; } static enum test_return send_string(const char *cmd) { execute(retry_write(cmd, strlen(cmd))); return TEST_PASS; } static enum test_return receive_line(char *buffer, size_t size) { size_t offset= 0; while (offset < size) { execute(retry_read(buffer + offset, 1)); if (buffer[offset] == '\n') { if (offset + 1 < size) { buffer[offset + 1]= '\0'; return TEST_PASS; } else return TEST_FAIL; } ++offset; } return TEST_FAIL; } static enum test_return receive_response(const char *msg) { char buffer[80]; execute(receive_line(buffer, sizeof(buffer))); if (strcmp(msg, buffer) != 0) { fprintf(stderr, "[%s]\n", buffer); } verify(strcmp(msg, buffer) == 0); return TEST_PASS; } static enum test_return receive_error_response(void) { char buffer[80]; execute(receive_line(buffer, sizeof(buffer))); verify(strncmp(buffer, "ERROR", 5) == 0 || strncmp(buffer, "CLIENT_ERROR", 12) == 0 || strncmp(buffer, "SERVER_ERROR", 12) == 0); return TEST_PASS; } static enum test_return test_ascii_quit(void) { /* Verify that quit handles unknown options */ execute(send_string("quit foo bar\r\n")); execute(receive_error_response()); /* quit doesn't support noreply */ execute(send_string("quit noreply\r\n")); execute(receive_error_response()); /* Verify that quit works */ execute(send_string("quit\r\n")); /* Socket should be closed now, read should return EXIT_SUCCESS */ char buffer[80]; verify(timeout_io_op(sock, POLLIN, buffer, sizeof(buffer)) == 0); return TEST_PASS_RECONNECT; } static enum test_return test_ascii_version(void) { /* Verify that version command handles unknown options */ execute(send_string("version foo bar\r\n")); execute(receive_error_response()); /* version doesn't support noreply */ execute(send_string("version noreply\r\n")); execute(receive_error_response()); /* Verify that verify works */ execute(send_string("version\r\n")); char buffer[256]; execute(receive_line(buffer, sizeof(buffer))); verify(strncmp(buffer, "VERSION ", 8) == 0); return TEST_PASS; } static enum test_return test_ascii_verbosity(void) { /* This command does not adhere to the spec! */ execute(send_string("verbosity foo bar my\r\n")); execute(receive_error_response()); execute(send_string("verbosity noreply\r\n")); execute(receive_error_response()); execute(send_string("verbosity 0 noreply\r\n")); execute(test_ascii_version()); execute(send_string("verbosity\r\n")); execute(receive_error_response()); execute(send_string("verbosity 1\r\n")); execute(receive_response("OK\r\n")); execute(send_string("verbosity 0\r\n")); execute(receive_response("OK\r\n")); return TEST_PASS; } static enum test_return test_ascii_set_impl(const char* key, bool noreply) { /* @todo add tests for bogus format! */ char buffer[1024]; snprintf(buffer, sizeof(buffer), "set %s 0 0 5%s\r\nvalue\r\n", key, noreply ? " noreply" : ""); execute(send_string(buffer)); if (!noreply) { execute(receive_response("STORED\r\n")); } return test_ascii_version(); } static enum test_return test_ascii_set(void) { return test_ascii_set_impl("test_ascii_set", false); } static enum test_return test_ascii_set_noreply(void) { return test_ascii_set_impl("test_ascii_set_noreply", true); } static enum test_return test_ascii_add_impl(const char* key, bool noreply) { /* @todo add tests for bogus format! */ char buffer[1024]; snprintf(buffer, sizeof(buffer), "add %s 0 0 5%s\r\nvalue\r\n", key, noreply ? " noreply" : ""); execute(send_string(buffer)); if (!noreply) { execute(receive_response("STORED\r\n")); } execute(send_string(buffer)); if (!noreply) { execute(receive_response("NOT_STORED\r\n")); } return test_ascii_version(); } static enum test_return test_ascii_add(void) { return test_ascii_add_impl("test_ascii_add", false); } static enum test_return test_ascii_add_noreply(void) { return test_ascii_add_impl("test_ascii_add_noreply", true); } static enum test_return ascii_get_unknown_value(char **key, char **value, ssize_t *ndata) { char buffer[1024]; execute(receive_line(buffer, sizeof(buffer))); verify(strncmp(buffer, "VALUE ", 6) == 0); char *end= strchr(buffer + 6, ' '); verify(end != NULL); if (end) { *end= '\0'; } *key= strdup(buffer + 6); verify(*key != NULL); char *ptr= end + 1; unsigned long val= strtoul(ptr, &end, 10); /* flags */ verify(ptr != end); verify(val == 0); verify(end != NULL); *ndata = (ssize_t)strtoul(end, &end, 10); /* size */ verify(ptr != end); verify(end != NULL); while (end and *end != '\n' and isspace(*end)) ++end; verify(end and *end == '\n'); *value= static_cast(malloc((size_t)*ndata)); verify(*value != NULL); execute(retry_read(*value, (size_t)*ndata)); execute(retry_read(buffer, 2)); verify(memcmp(buffer, "\r\n", 2) == 0); return TEST_PASS; } static enum test_return ascii_get_value(const char *key, const char *value) { char buffer[1024]; size_t datasize= strlen(value); verify(datasize < sizeof(buffer)); execute(receive_line(buffer, sizeof(buffer))); verify(strncmp(buffer, "VALUE ", 6) == 0); verify(strncmp(buffer + 6, key, strlen(key)) == 0); char *ptr= buffer + 6 + strlen(key) + 1; char *end; unsigned long val= strtoul(ptr, &end, 10); /* flags */ verify(ptr != end); verify(val == 0); verify(end != NULL); val= strtoul(end, &end, 10); /* size */ verify(ptr != end); verify(val == datasize); verify(end != NULL); while (end and *end != '\n' and isspace(*end)) { ++end; } verify(end and *end == '\n'); execute(retry_read(buffer, datasize)); verify(memcmp(buffer, value, datasize) == 0); execute(retry_read(buffer, 2)); verify(memcmp(buffer, "\r\n", 2) == 0); return TEST_PASS; } static enum test_return ascii_get_item(const char *key, const char *value, bool exist) { char buffer[1024]; size_t datasize= 0; if (value != NULL) { datasize= strlen(value); } verify(datasize < sizeof(buffer)); snprintf(buffer, sizeof(buffer), "get %s\r\n", key); execute(send_string(buffer)); if (exist) { execute(ascii_get_value(key, value)); } execute(retry_read(buffer, 5)); verify(memcmp(buffer, "END\r\n", 5) == 0); return TEST_PASS; } static enum test_return ascii_gets_value(const char *key, const char *value, unsigned long *cas) { char buffer[1024]; size_t datasize= strlen(value); verify(datasize < sizeof(buffer)); execute(receive_line(buffer, sizeof(buffer))); verify(strncmp(buffer, "VALUE ", 6) == 0); verify(strncmp(buffer + 6, key, strlen(key)) == 0); char *ptr= buffer + 6 + strlen(key) + 1; char *end; unsigned long val= strtoul(ptr, &end, 10); /* flags */ verify(ptr != end); verify(val == 0); verify(end != NULL); val= strtoul(end, &end, 10); /* size */ verify(ptr != end); verify(val == datasize); verify(end != NULL); *cas= strtoul(end, &end, 10); /* cas */ verify(ptr != end); verify(val == datasize); verify(end != NULL); while (end and *end != '\n' and isspace(*end)) { ++end; } verify(end and *end == '\n'); execute(retry_read(buffer, datasize)); verify(memcmp(buffer, value, datasize) == 0); execute(retry_read(buffer, 2)); verify(memcmp(buffer, "\r\n", 2) == 0); return TEST_PASS; } static enum test_return ascii_gets_item(const char *key, const char *value, bool exist, unsigned long *cas) { char buffer[1024]; size_t datasize= 0; if (value != NULL) { datasize= strlen(value); } verify(datasize < sizeof(buffer)); snprintf(buffer, sizeof(buffer), "gets %s\r\n", key); execute(send_string(buffer)); if (exist) execute(ascii_gets_value(key, value, cas)); execute(retry_read(buffer, 5)); verify(memcmp(buffer, "END\r\n", 5) == 0); return TEST_PASS; } static enum test_return ascii_set_item(const char *key, const char *value) { char buffer[300]; size_t len= strlen(value); snprintf(buffer, sizeof(buffer), "set %s 0 0 %u\r\n", key, (unsigned int)len); execute(send_string(buffer)); execute(retry_write(value, len)); execute(send_string("\r\n")); execute(receive_response("STORED\r\n")); return TEST_PASS; } static enum test_return test_ascii_replace_impl(const char* key, bool noreply) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "replace %s 0 0 5%s\r\nvalue\r\n", key, noreply ? " noreply" : ""); execute(send_string(buffer)); if (noreply) { execute(test_ascii_version()); } else { execute(receive_response("NOT_STORED\r\n")); } execute(ascii_set_item(key, "value")); execute(ascii_get_item(key, "value", true)); execute(send_string(buffer)); if (noreply) execute(test_ascii_version()); else execute(receive_response("STORED\r\n")); return test_ascii_version(); } static enum test_return test_ascii_replace(void) { return test_ascii_replace_impl("test_ascii_replace", false); } static enum test_return test_ascii_replace_noreply(void) { return test_ascii_replace_impl("test_ascii_replace_noreply", true); } static enum test_return test_ascii_cas_impl(const char* key, bool noreply) { char buffer[1024]; unsigned long cas; execute(ascii_set_item(key, "value")); execute(ascii_gets_item(key, "value", true, &cas)); snprintf(buffer, sizeof(buffer), "cas %s 0 0 6 %lu%s\r\nvalue2\r\n", key, cas, noreply ? " noreply" : ""); execute(send_string(buffer)); if (noreply) { execute(test_ascii_version()); } else { execute(receive_response("STORED\r\n")); } /* reexecute the same command should fail due to illegal cas */ execute(send_string(buffer)); if (noreply) { execute(test_ascii_version()); } else { execute(receive_response("EXISTS\r\n")); } return test_ascii_version(); } static enum test_return test_ascii_cas(void) { return test_ascii_cas_impl("test_ascii_cas", false); } static enum test_return test_ascii_cas_noreply(void) { return test_ascii_cas_impl("test_ascii_cas_noreply", true); } static enum test_return test_ascii_delete_impl(const char *key, bool noreply) { execute(ascii_set_item(key, "value")); execute(send_string("delete\r\n")); execute(receive_error_response()); /* BUG: the server accepts delete a b */ execute(send_string("delete a b c d e\r\n")); execute(receive_error_response()); char buffer[1024]; snprintf(buffer, sizeof(buffer), "delete %s%s\r\n", key, noreply ? " noreply" : ""); execute(send_string(buffer)); if (noreply) execute(test_ascii_version()); else execute(receive_response("DELETED\r\n")); execute(ascii_get_item(key, "value", false)); execute(send_string(buffer)); if (noreply) execute(test_ascii_version()); else execute(receive_response("NOT_FOUND\r\n")); return TEST_PASS; } static enum test_return test_ascii_delete(void) { return test_ascii_delete_impl("test_ascii_delete", false); } static enum test_return test_ascii_delete_noreply(void) { return test_ascii_delete_impl("test_ascii_delete_noreply", true); } static enum test_return test_ascii_get(void) { execute(ascii_set_item("test_ascii_get", "value")); execute(send_string("get\r\n")); execute(receive_error_response()); execute(ascii_get_item("test_ascii_get", "value", true)); execute(ascii_get_item("test_ascii_get_notfound", "value", false)); return TEST_PASS; } static enum test_return test_ascii_gets(void) { execute(ascii_set_item("test_ascii_gets", "value")); execute(send_string("gets\r\n")); execute(receive_error_response()); unsigned long cas; execute(ascii_gets_item("test_ascii_gets", "value", true, &cas)); execute(ascii_gets_item("test_ascii_gets_notfound", "value", false, &cas)); return TEST_PASS; } static enum test_return test_ascii_mget(void) { const uint32_t nkeys= 5; const char * const keys[]= { "test_ascii_mget1", "test_ascii_mget2", /* test_ascii_mget_3 does not exist :) */ "test_ascii_mget4", "test_ascii_mget5", "test_ascii_mget6" }; for (uint32_t x= 0; x < nkeys; ++x) { execute(ascii_set_item(keys[x], "value")); } /* Ask for a key that doesn't exist as well */ execute(send_string("get test_ascii_mget1 test_ascii_mget2 test_ascii_mget3 " "test_ascii_mget4 test_ascii_mget5 " "test_ascii_mget6\r\n")); char *returned[nkeys]; for (uint32_t x= 0; x < nkeys; ++x) { ssize_t nbytes = 0; char *v= NULL; execute(ascii_get_unknown_value(&returned[x], &v, &nbytes)); verify(nbytes == 5); verify(memcmp(v, "value", 5) == 0); free(v); } char buffer[5]; execute(retry_read(buffer, 5)); verify(memcmp(buffer, "END\r\n", 5) == 0); /* verify that we got all the keys we expected */ for (uint32_t x= 0; x < nkeys; ++x) { bool found= false; for (uint32_t y= 0; y < nkeys; ++y) { if (strcmp(keys[x], returned[y]) == 0) { found = true; break; } } verify(found); } for (uint32_t x= 0; x < nkeys; ++x) { free(returned[x]); } return TEST_PASS; } static enum test_return test_ascii_incr_impl(const char* key, bool noreply) { char cmd[300]; snprintf(cmd, sizeof(cmd), "incr %s 1%s\r\n", key, noreply ? " noreply" : ""); execute(ascii_set_item(key, "0")); for (int x= 1; x < 11; ++x) { execute(send_string(cmd)); if (noreply) execute(test_ascii_version()); else { char buffer[80]; execute(receive_line(buffer, sizeof(buffer))); int val= atoi(buffer); verify(val == x); } } execute(ascii_get_item(key, "10", true)); return TEST_PASS; } static enum test_return test_ascii_incr(void) { return test_ascii_incr_impl("test_ascii_incr", false); } static enum test_return test_ascii_incr_noreply(void) { return test_ascii_incr_impl("test_ascii_incr_noreply", true); } static enum test_return test_ascii_decr_impl(const char* key, bool noreply) { char cmd[300]; snprintf(cmd, sizeof(cmd), "decr %s 1%s\r\n", key, noreply ? " noreply" : ""); execute(ascii_set_item(key, "9")); for (int x= 8; x > -1; --x) { execute(send_string(cmd)); if (noreply) { execute(test_ascii_version()); } else { char buffer[80]; execute(receive_line(buffer, sizeof(buffer))); int val= atoi(buffer); verify(val == x); } } execute(ascii_get_item(key, "0", true)); /* verify that it doesn't wrap */ execute(send_string(cmd)); if (noreply) { execute(test_ascii_version()); } else { char buffer[80]; execute(receive_line(buffer, sizeof(buffer))); } execute(ascii_get_item(key, "0", true)); return TEST_PASS; } static enum test_return test_ascii_decr(void) { return test_ascii_decr_impl("test_ascii_decr", false); } static enum test_return test_ascii_decr_noreply(void) { return test_ascii_decr_impl("test_ascii_decr_noreply", true); } static enum test_return test_ascii_flush_impl(const char *key, bool noreply) { #if 0 /* Verify that the flush_all command handles unknown options */ /* Bug in the current memcached server! */ execute(send_string("flush_all foo bar\r\n")); execute(receive_error_response()); #endif execute(ascii_set_item(key, key)); execute(ascii_get_item(key, key, true)); if (noreply) { execute(send_string("flush_all noreply\r\n")); execute(test_ascii_version()); } else { execute(send_string("flush_all\r\n")); execute(receive_response("OK\r\n")); } execute(ascii_get_item(key, key, false)); return TEST_PASS; } static enum test_return test_ascii_flush(void) { return test_ascii_flush_impl("test_ascii_flush", false); } static enum test_return test_ascii_flush_noreply(void) { return test_ascii_flush_impl("test_ascii_flush_noreply", true); } static enum test_return test_ascii_concat_impl(const char *key, bool append, bool noreply) { const char *value; if (append) value="hello"; else value=" world"; execute(ascii_set_item(key, value)); if (append) { value=" world"; } else { value="hello"; } char cmd[400]; snprintf(cmd, sizeof(cmd), "%s %s 0 0 %u%s\r\n%s\r\n", append ? "append" : "prepend", key, (unsigned int)strlen(value), noreply ? " noreply" : "", value); execute(send_string(cmd)); if (noreply) { execute(test_ascii_version()); } else { execute(receive_response("STORED\r\n")); } execute(ascii_get_item(key, "hello world", true)); snprintf(cmd, sizeof(cmd), "%s %s_notfound 0 0 %u%s\r\n%s\r\n", append ? "append" : "prepend", key, (unsigned int)strlen(value), noreply ? " noreply" : "", value); execute(send_string(cmd)); if (noreply) { execute(test_ascii_version()); } else { execute(receive_response("NOT_STORED\r\n")); } return TEST_PASS; } static enum test_return test_ascii_append(void) { return test_ascii_concat_impl("test_ascii_append", true, false); } static enum test_return test_ascii_prepend(void) { return test_ascii_concat_impl("test_ascii_prepend", false, false); } static enum test_return test_ascii_append_noreply(void) { return test_ascii_concat_impl("test_ascii_append_noreply", true, true); } static enum test_return test_ascii_prepend_noreply(void) { return test_ascii_concat_impl("test_ascii_prepend_noreply", false, true); } static enum test_return test_ascii_stat(void) { execute(send_string("stats noreply\r\n")); execute(receive_error_response()); execute(send_string("stats\r\n")); char buffer[1024]; do { execute(receive_line(buffer, sizeof(buffer))); } while (strcmp(buffer, "END\r\n") != 0); return TEST_PASS_RECONNECT; } typedef enum test_return(*TEST_FUNC)(void); struct testcase { const char *description; TEST_FUNC function; }; struct testcase testcases[]= { { "ascii quit", test_ascii_quit }, { "ascii version", test_ascii_version }, { "ascii verbosity", test_ascii_verbosity }, { "ascii set", test_ascii_set }, { "ascii set noreply", test_ascii_set_noreply }, { "ascii get", test_ascii_get }, { "ascii gets", test_ascii_gets }, { "ascii mget", test_ascii_mget }, { "ascii flush", test_ascii_flush }, { "ascii flush noreply", test_ascii_flush_noreply }, { "ascii add", test_ascii_add }, { "ascii add noreply", test_ascii_add_noreply }, { "ascii replace", test_ascii_replace }, { "ascii replace noreply", test_ascii_replace_noreply }, { "ascii cas", test_ascii_cas }, { "ascii cas noreply", test_ascii_cas_noreply }, { "ascii delete", test_ascii_delete }, { "ascii delete noreply", test_ascii_delete_noreply }, { "ascii incr", test_ascii_incr }, { "ascii incr noreply", test_ascii_incr_noreply }, { "ascii decr", test_ascii_decr }, { "ascii decr noreply", test_ascii_decr_noreply }, { "ascii append", test_ascii_append }, { "ascii append noreply", test_ascii_append_noreply }, { "ascii prepend", test_ascii_prepend }, { "ascii prepend noreply", test_ascii_prepend_noreply }, { "ascii stat", test_ascii_stat }, { "binary noop", test_binary_noop }, { "binary quit", test_binary_quit }, { "binary quitq", test_binary_quitq }, { "binary set", test_binary_set }, { "binary setq", test_binary_setq }, { "binary flush", test_binary_flush }, { "binary flushq", test_binary_flushq }, { "binary add", test_binary_add }, { "binary addq", test_binary_addq }, { "binary replace", test_binary_replace }, { "binary replaceq", test_binary_replaceq }, { "binary delete", test_binary_delete }, { "binary deleteq", test_binary_deleteq }, { "binary get", test_binary_get }, { "binary getq", test_binary_getq }, { "binary getk", test_binary_getk }, { "binary getkq", test_binary_getkq }, { "binary incr", test_binary_incr }, { "binary incrq", test_binary_incrq }, { "binary decr", test_binary_decr }, { "binary decrq", test_binary_decrq }, { "binary version", test_binary_version }, { "binary append", test_binary_append }, { "binary appendq", test_binary_appendq }, { "binary prepend", test_binary_prepend }, { "binary prependq", test_binary_prependq }, { "binary stat", test_binary_stat }, { NULL, NULL} }; const int ascii_tests = 1; const int binary_tests = 2; struct test_type_st { bool ascii; bool binary; }; int main(int argc, char **argv) { static const char * const status_msg[]= {"[skip]", "[pass]", "[pass]", "[FAIL]"}; struct test_type_st tests= { true, true }; int total= 0; int failed= 0; const char *hostname= "localhost"; const char *port= "11211"; int cmd; bool prompt= false; const char *testname= NULL; while ((cmd= getopt(argc, argv, "qt:vch:p:PT:?ab")) != EOF) { switch (cmd) { case 'a': tests.ascii= true; tests.binary= false; break; case 'b': tests.ascii= false; tests.binary= true; break; case 't': timeout= atoi(optarg); if (timeout == 0) { fprintf(stderr, "Invalid timeout. Please specify a number for -t\n"); return EXIT_FAILURE; } break; case 'v': verbose= true; break; case 'c': do_core= true; break; case 'h': hostname= optarg; break; case 'p': port= optarg; break; case 'q': close_stdio(); break; case 'P': prompt= true; break; case 'T': testname= optarg; break; default: fprintf(stderr, "Usage: %s [-h hostname] [-p port] [-c] [-v] [-t n] [-P] [-T testname]'\n" "\t-c\tGenerate coredump if a test fails\n" "\t-v\tVerbose test output (print out the assertion)\n" "\t-t n\tSet the timeout for io-operations to n seconds\n" "\t-P\tPrompt the user before starting a test.\n" "\t\t\t\"skip\" will skip the test\n" "\t\t\t\"quit\" will terminate memcapable\n" "\t\t\tEverything else will start the test\n" "\t-T n\tJust run the test named n\n" "\t-a\tOnly test the ascii protocol\n" "\t-b\tOnly test the binary protocol\n", argv[0]); return EXIT_SUCCESS; } } initialize_sockets(); sock= connect_server(hostname, port); if (sock == INVALID_SOCKET) { fprintf(stderr, "Failed to connect to <%s:%s>: %s\n", hostname, port, strerror(get_socket_errno())); return EXIT_FAILURE; } for (int ii= 0; testcases[ii].description != NULL; ++ii) { if (testname != NULL && strcmp(testcases[ii].description, testname) != 0) { continue; } if ((testcases[ii].description[0] == 'a' && (tests.ascii) == 0) || (testcases[ii].description[0] == 'b' && (tests.binary) == 0)) { continue; } ++total; fprintf(stdout, "%-40s", testcases[ii].description); fflush(stdout); if (prompt) { fprintf(stdout, "\nPress when you are ready? "); char buffer[80] = {0}; if (fgets(buffer, sizeof(buffer), stdin) != NULL) { if (strncmp(buffer, "skip", 4) == 0) { fprintf(stdout, "%-40s%s\n", testcases[ii].description, status_msg[TEST_SKIP]); fflush(stdout); continue; } if (strncmp(buffer, "quit", 4) == 0) { exit(EXIT_SUCCESS); } } fprintf(stdout, "%-40s", testcases[ii].description); fflush(stdout); } bool reconnect= false; enum test_return ret= testcases[ii].function(); if (ret == TEST_FAIL) { reconnect= true; ++failed; if (verbose) fprintf(stderr, "\n"); } else if (ret == TEST_PASS_RECONNECT) reconnect= true; fprintf(stderr, "%s\n", status_msg[ret]); if (reconnect) { closesocket(sock); if ((sock= connect_server(hostname, port)) == INVALID_SOCKET) { fprintf(stderr, "Failed to connect to <%s:%s>: %s\n", hostname, port, strerror(get_socket_errno())); fprintf(stderr, "%d of %d tests failed\n", failed, total); return EXIT_FAILURE; } } } closesocket(sock); if (failed == 0) { fprintf(stdout, "All tests passed\n"); } else { fprintf(stderr, "%d of %d tests failed\n", failed, total); } return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } libmemcached-1.0.8/clients/memexist.cc0000664000076400007640000001174011753573717020225 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #include "config.h" #include #include #include #include #include #include #include "client_options.h" #include "utilities.h" static int opt_binary= 0; static int opt_verbose= 0; static char *opt_servers= NULL; static char *opt_hash= NULL; static char *opt_username; static char *opt_passwd; #define PROGRAM_NAME "memexist" #define PROGRAM_DESCRIPTION "Check for the existance of a key within a cluster." /* Prototypes */ static void options_parse(int argc, char *argv[]); int main(int argc, char *argv[]) { memcached_st *memc; memcached_server_st *servers; options_parse(argc, argv); initialize_sockets(); if (opt_servers == 0) { char *temp; if ((temp= getenv("MEMCACHED_SERVERS"))) { opt_servers= strdup(temp); } else { std::cerr << "No Servers provided" << std::endl; return EXIT_FAILURE; } } memc= memcached_create(NULL); process_hash_option(memc, opt_hash); servers= memcached_servers_parse(opt_servers); memcached_server_push(memc, servers); memcached_server_list_free(servers); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, (uint64_t) opt_binary); if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0) { memcached_free(memc); std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl; return EXIT_FAILURE; } if (opt_username) { memcached_return_t ret; if (memcached_failed(ret= memcached_set_sasl_auth_data(memc, opt_username, opt_passwd))) { std::cerr << memcached_last_error_message(memc) << std::endl; memcached_free(memc); return EXIT_FAILURE; } } int return_code= EXIT_SUCCESS; while (optind < argc) { memcached_return_t rc= memcached_exist(memc, argv[optind], strlen(argv[optind])); if (rc == MEMCACHED_NOTFOUND) { if (opt_verbose) { std::cout << "Could not find key \"" << argv[optind] << "\"" << std::endl; } return_code= EXIT_FAILURE; } else if (memcached_failed(rc)) { if (opt_verbose) { std::cerr << "Fatal error for key \"" << argv[optind] << "\" :" << memcached_last_error_message(memc) << std::endl; } return_code= EXIT_FAILURE; } else // success { if (opt_verbose) { std::cout << "Found key " << argv[optind] << std::endl; } } optind++; } memcached_free(memc); if (opt_servers) { free(opt_servers); } if (opt_hash) { free(opt_hash); } return return_code; } static void options_parse(int argc, char *argv[]) { memcached_programs_help_st help_options[]= { {0}, }; static struct option long_options[]= { {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, {(OPTIONSTRING)"quiet", no_argument, NULL, OPT_QUIET}, {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, {(OPTIONSTRING)"hash", required_argument, NULL, OPT_HASH}, {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, {(OPTIONSTRING)"username", required_argument, NULL, OPT_USERNAME}, {(OPTIONSTRING)"password", required_argument, NULL, OPT_PASSWD}, {0, 0, 0, 0}, }; bool opt_version= false; bool opt_help= false; int option_index= 0; while (1) { int option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) { break; } switch (option_rv) { case 0: break; case OPT_BINARY: opt_binary = 1; break; case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = OPT_VERBOSE; break; case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; case OPT_VERSION: /* --version or -V */ opt_version= true; break; case OPT_HELP: /* --help or -h */ opt_help= true; break; case OPT_SERVERS: /* --servers or -s */ opt_servers= strdup(optarg); break; case OPT_HASH: opt_hash= strdup(optarg); break; case OPT_USERNAME: opt_username= optarg; break; case OPT_PASSWD: opt_passwd= optarg; break; case OPT_QUIET: close_stdio(); break; case '?': /* getopt_long already printed an error message. */ exit(EXIT_SUCCESS); default: abort(); } } if (opt_version) { version_command(PROGRAM_NAME); exit(EXIT_SUCCESS); } if (opt_help) { help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options); exit(EXIT_SUCCESS); } } libmemcached-1.0.8/clients/memflush.cc0000664000076400007640000001030511753573717020206 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #include "config.h" #include #include #include #include #include #include #include "client_options.h" #include "utilities.h" static int opt_binary= 0; static int opt_verbose= 0; static time_t opt_expire= 0; static char *opt_servers= NULL; static char *opt_username; static char *opt_passwd; #define PROGRAM_NAME "memflush" #define PROGRAM_DESCRIPTION "Erase all data in a server of memcached servers." /* Prototypes */ void options_parse(int argc, char *argv[]); int main(int argc, char *argv[]) { options_parse(argc, argv); if (opt_servers == false) { char *temp; if ((temp= getenv("MEMCACHED_SERVERS"))) { opt_servers= strdup(temp); } else { std::cerr << "No Servers provided" << std::endl; exit(EXIT_FAILURE); } } memcached_st *memc= memcached_create(NULL); memcached_server_st *servers= memcached_servers_parse(opt_servers); memcached_server_push(memc, servers); memcached_server_list_free(servers); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, (uint64_t) opt_binary); if (opt_username and LIBMEMCACHED_WITH_SASL_SUPPORT == 0) { memcached_free(memc); std::cerr << "--username was supplied, but binary was not built with SASL support." << std::endl; return EXIT_FAILURE; } if (opt_username) { memcached_return_t ret; if (memcached_failed(ret= memcached_set_sasl_auth_data(memc, opt_username, opt_passwd))) { std::cerr << memcached_last_error_message(memc) << std::endl; memcached_free(memc); return EXIT_FAILURE; } } memcached_return_t rc = memcached_flush(memc, opt_expire); if (rc != MEMCACHED_SUCCESS) { std::cerr << memcached_last_error_message(memc) << std::endl; } memcached_free(memc); free(opt_servers); return EXIT_SUCCESS; } void options_parse(int argc, char *argv[]) { static struct option long_options[]= { {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, {(OPTIONSTRING)"quiet", no_argument, NULL, OPT_QUIET}, {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, {(OPTIONSTRING)"expire", required_argument, NULL, OPT_EXPIRE}, {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, {(OPTIONSTRING)"username", required_argument, NULL, OPT_USERNAME}, {(OPTIONSTRING)"password", required_argument, NULL, OPT_PASSWD}, {0, 0, 0, 0}, }; bool opt_version= false; bool opt_help= false; int option_index= 0; while (1) { int option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index); if (option_rv == -1) break; switch (option_rv) { case 0: break; case OPT_BINARY: opt_binary= true; break; case OPT_VERBOSE: /* --verbose or -v */ opt_verbose= OPT_VERBOSE; break; case OPT_DEBUG: /* --debug or -d */ opt_verbose= OPT_DEBUG; break; case OPT_VERSION: /* --version or -V */ opt_version= true; break; case OPT_HELP: /* --help or -h */ opt_help= true; break; case OPT_SERVERS: /* --servers or -s */ opt_servers= strdup(optarg); break; case OPT_EXPIRE: /* --expire */ opt_expire= (time_t)strtoll(optarg, (char **)NULL, 10); break; case OPT_USERNAME: opt_username= optarg; break; case OPT_PASSWD: opt_passwd= optarg; break; case OPT_QUIET: close_stdio(); break; case '?': /* getopt_long already printed an error message. */ exit(EXIT_FAILURE); default: abort(); } } if (opt_version) { version_command(PROGRAM_NAME); exit(EXIT_SUCCESS); } if (opt_help) { help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, NULL); exit(EXIT_SUCCESS); } } libmemcached-1.0.8/clients/generator.h0000664000076400007640000000114211753573717020215 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ /* Code to generate data to be pushed into memcached */ #pragma once typedef struct pairs_st pairs_st; struct pairs_st { char *key; size_t key_length; char *value; size_t value_length; }; #ifdef __cplusplus extern "C" { #endif pairs_st *pairs_generate(uint64_t number_of, size_t value_length); void pairs_free(pairs_st *pairs); #ifdef __cplusplus } // extern "C" #endif libmemcached-1.0.8/clients/ms_thread.c0000664000076400007640000002022311753573717020171 0ustar00brianbrian00000000000000/* * File: ms_thread.c * Author: Mingqiang Zhuang * * Created on February 10, 2009 * * (c) Copyright 2009, Schooner Information Technology, Inc. * http://www.schoonerinfotech.com/ * */ #include "config.h" #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #include "ms_thread.h" #include "ms_setting.h" #include "ms_atomic.h" /* global variable */ pthread_key_t ms_thread_key; /* array of thread context structure, each thread has a thread context structure */ static ms_thread_ctx_t *ms_thread_ctx; /* functions */ static void ms_set_current_time(void); static void ms_check_sock_timeout(void); static void ms_clock_handler(const int fd, const short which, void *arg); static uint32_t ms_set_thread_cpu_affinity(uint32_t cpu); static int ms_setup_thread(ms_thread_ctx_t *thread_ctx); static void *ms_worker_libevent(void *arg); static void ms_create_worker(void *(*func)(void *), void *arg); /** * time-sensitive callers can call it by hand with this, * outside the normal ever-1-second timer */ static void ms_set_current_time() { struct timeval timer; ms_thread_t *ms_thread= pthread_getspecific(ms_thread_key); gettimeofday(&timer, NULL); ms_thread->curr_time= (rel_time_t)timer.tv_sec; } /* ms_set_current_time */ /** * used to check whether UDP of command are waiting timeout * by the ever-1-second timer */ static void ms_check_sock_timeout(void) { ms_thread_t *ms_thread= pthread_getspecific(ms_thread_key); ms_conn_t *c= NULL; int time_diff= 0; for (uint32_t i= 0; i < ms_thread->thread_ctx->nconns; i++) { c= &ms_thread->conn[i]; if (c->udp) { time_diff= (int)(ms_thread->curr_time - (rel_time_t)c->start_time.tv_sec); /* wait time out */ if (time_diff > SOCK_WAIT_TIMEOUT) { /* calculate dropped packets count */ if (c->recvpkt > 0) { atomic_add_size(&ms_stats.pkt_drop, c->packets - c->recvpkt); } atomic_add_size(&ms_stats.udp_timeout, 1); ms_reset_conn(c, true); } } } } /* ms_check_sock_timeout */ /* if disconnect, the ever-1-second timer will call this function to reconnect */ static void ms_reconn_thread_socks(void) { ms_thread_t *ms_thread= pthread_getspecific(ms_thread_key); for (uint32_t i= 0; i < ms_thread->thread_ctx->nconns; i++) { ms_reconn_socks(&ms_thread->conn[i]); } } /* ms_reconn_thread_socks */ /** * the handler of the ever-1-second timer * * @param fd, the descriptors of the socket * @param which, event flags * @param arg, argument */ static void ms_clock_handler(const int fd, const short which, void *arg) { ms_thread_t *ms_thread= pthread_getspecific(ms_thread_key); struct timeval t= { .tv_sec= 1, .tv_usec= 0 }; UNUSED_ARGUMENT(fd); UNUSED_ARGUMENT(which); UNUSED_ARGUMENT(arg); ms_set_current_time(); if (ms_thread->initialized) { /* only delete the event if it's actually there. */ evtimer_del(&ms_thread->clock_event); ms_check_sock_timeout(); } else { ms_thread->initialized= true; } ms_reconn_thread_socks(); evtimer_set(&ms_thread->clock_event, ms_clock_handler, 0); event_base_set(ms_thread->base, &ms_thread->clock_event); evtimer_add(&ms_thread->clock_event, &t); } /* ms_clock_handler */ /** * used to bind thread to CPU if the system supports * * @param cpu, cpu index * * @return if success, return EXIT_SUCCESS, else return -1 */ static uint32_t ms_set_thread_cpu_affinity(uint32_t cpu) { uint32_t ret= 0; #ifdef HAVE_CPU_SET_T cpu_set_t cpu_set; CPU_ZERO(&cpu_set); CPU_SET(cpu, &cpu_set); if (sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set) == -1) { fprintf(stderr, "WARNING: Could not set CPU Affinity, continuing...\n"); ret= 1; } #else UNUSED_ARGUMENT(cpu); #endif return ret; } /* ms_set_thread_cpu_affinity */ /** * Set up a thread's information. * * @param thread_ctx, pointer of the thread context structure * * @return if success, return EXIT_SUCCESS, else return -1 */ static int ms_setup_thread(ms_thread_ctx_t *thread_ctx) { ms_thread_t *ms_thread= (ms_thread_t *)calloc(sizeof(*ms_thread), 1); pthread_setspecific(ms_thread_key, (void *)ms_thread); ms_thread->thread_ctx= thread_ctx; ms_thread->nactive_conn= thread_ctx->nconns; ms_thread->initialized= false; static volatile uint32_t cnt= 0; gettimeofday(&ms_thread->startup_time, NULL); ms_thread->base= event_init(); if (ms_thread->base == NULL) { if (atomic_add_32_nv(&cnt, 1) == 0) { fprintf(stderr, "Can't allocate event base.\n"); } return -1; } ms_thread->conn= (ms_conn_t *)malloc((size_t)thread_ctx->nconns * sizeof(ms_conn_t)); if (ms_thread->conn == NULL) { if (atomic_add_32_nv(&cnt, 1) == 0) { fprintf( stderr, "Can't allocate concurrency structure for thread descriptors."); } return -1; } memset(ms_thread->conn, 0, (size_t)thread_ctx->nconns * sizeof(ms_conn_t)); for (uint32_t i= 0; i < thread_ctx->nconns; i++) { ms_thread->conn[i].conn_idx= i; if (ms_setup_conn(&ms_thread->conn[i]) != 0) { /* only output this error once */ if (atomic_add_32_nv(&cnt, 1) == 0) { fprintf(stderr, "Initializing connection failed.\n"); } return -1; } } return EXIT_SUCCESS; } /* ms_setup_thread */ /** * Worker thread: main event loop * * @param arg, the pointer of argument * * @return void* */ static void *ms_worker_libevent(void *arg) { ms_thread_t *ms_thread= NULL; ms_thread_ctx_t *thread_ctx= (ms_thread_ctx_t *)arg; /** * If system has more than one cpu and supports set cpu * affinity, try to bind each thread to a cpu core; */ if (ms_setting.ncpu > 1) { ms_set_thread_cpu_affinity(thread_ctx->thd_idx % ms_setting.ncpu); } if (ms_setup_thread(thread_ctx) != 0) { exit(1); } /* each thread with a timer */ ms_clock_handler(0, 0, 0); pthread_mutex_lock(&ms_global.init_lock.lock); ms_global.init_lock.count++; pthread_cond_signal(&ms_global.init_lock.cond); pthread_mutex_unlock(&ms_global.init_lock.lock); ms_thread= pthread_getspecific(ms_thread_key); event_base_loop(ms_thread->base, 0); return NULL; } /* ms_worker_libevent */ /** * Creates a worker thread. * * @param func, the callback function * @param arg, the argument to pass to the callback function */ static void ms_create_worker(void *(*func)(void *), void *arg) { pthread_t thread; pthread_attr_t attr; int ret; pthread_attr_init(&attr); if ((ret= pthread_create(&thread, &attr, func, arg)) != 0) { fprintf(stderr, "Can't create thread: %s.\n", strerror(ret)); exit(1); } } /* ms_create_worker */ /* initialize threads */ void ms_thread_init() { ms_thread_ctx= (ms_thread_ctx_t *)malloc( sizeof(ms_thread_ctx_t) * (size_t)ms_setting.nthreads); if (ms_thread_ctx == NULL) { fprintf(stderr, "Can't allocate thread descriptors."); exit(1); } for (uint32_t i= 0; i < ms_setting.nthreads; i++) { ms_thread_ctx[i].thd_idx= i; ms_thread_ctx[i].nconns= ms_setting.nconns / ms_setting.nthreads; /** * If only one server, all the connections in all threads * connects the same server. For support multi-servers, simple * distribute thread to server. */ ms_thread_ctx[i].srv_idx= i % ms_setting.srv_cnt; ms_thread_ctx[i].tps_perconn= ms_setting.expected_tps / (int)ms_setting.nconns; ms_thread_ctx[i].exec_num_perconn= ms_setting.exec_num / ms_setting.nconns; } if (pthread_key_create(&ms_thread_key, NULL)) { fprintf(stderr, "Can't create pthread keys. Major malfunction!\n"); exit(1); } /* Create threads after we've done all the epoll setup. */ for (uint32_t i= 0; i < ms_setting.nthreads; i++) { ms_create_worker(ms_worker_libevent, (void *)&ms_thread_ctx[i]); } } /* ms_thread_init */ /* cleanup some resource of threads when all the threads exit */ void ms_thread_cleanup() { if (ms_thread_ctx != NULL) { free(ms_thread_ctx); } pthread_key_delete(ms_thread_key); } /* ms_thread_cleanup */ libmemcached-1.0.8/clients/utilities.cc0000664000076400007640000001226711753573717020412 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: * */ #include #include #include #include #include #include #include #include #include #include #include long int timedif(struct timeval a, struct timeval b) { long us, s; us = (int)(a.tv_usec - b.tv_usec); us /= 1000; s = (int)(a.tv_sec - b.tv_sec); s *= 1000; return s + us; } void version_command(const char *command_name) { printf("%s v%u.%u\n", command_name, 1U, 0U); exit(EXIT_SUCCESS); } void close_stdio(void) { int fd; if ((fd = open("/dev/null", O_RDWR, 0)) < 0) { return; } else { if (dup2(fd, STDIN_FILENO) < 0) { return; } if (dup2(fd, STDOUT_FILENO) < 0) { return; } if (dup2(fd, STDERR_FILENO) < 0) { return; } if (fd > STDERR_FILENO) { close(fd); } } } static const char *lookup_help(memcached_options option) { switch (option) { case OPT_SERVERS: return("List which servers you wish to connect to."); case OPT_VERSION: return("Display the version of the application and then exit."); case OPT_HELP: return("Display this message and then exit."); case OPT_VERBOSE: return("Give more details on the progression of the application."); case OPT_QUIET: return("stderr and stdin will be closed at application startup."); case OPT_DEBUG: return("Provide output only useful for debugging."); case OPT_FLAG: return("Provide flag information for storage operation."); case OPT_EXPIRE: return("Set the expire option for the object."); case OPT_SET: return("Use set command with memcached when storing."); case OPT_REPLACE: return("Use replace command with memcached when storing."); case OPT_ADD: return("Use add command with memcached when storing."); case OPT_SLAP_EXECUTE_NUMBER: return("Number of times to execute the given test."); case OPT_SLAP_INITIAL_LOAD: return("Number of key pairs to load before executing tests."); case OPT_SLAP_TEST: return("Test to run (currently \"get\" or \"set\")."); case OPT_SLAP_CONCURRENCY: return("Number of users to simulate with load."); case OPT_SLAP_NON_BLOCK: return("Set TCP up to use non-blocking IO."); case OPT_SLAP_TCP_NODELAY: return("Set TCP socket up to use nodelay."); case OPT_FLUSH: return("Flush servers before running tests."); case OPT_HASH: return("Select hash type."); case OPT_BINARY: return("Switch to binary protocol."); case OPT_ANALYZE: return("Analyze the provided servers."); case OPT_UDP: return("Use UDP protocol when communicating with server."); case OPT_BUFFER: return("Enable request buffering."); case OPT_USERNAME: return "Username to use for SASL authentication"; case OPT_PASSWD: return "Password to use for SASL authentication"; case OPT_FILE: return "Path to file in which to save result"; case OPT_STAT_ARGS: return "Argument for statistics"; case OPT_SERVER_VERSION: return "Memcached daemon software version"; default: break; }; assert(0); return "forgot to document this function :)"; } void help_command(const char *command_name, const char *description, const struct option *long_options, memcached_programs_help_st *options) { unsigned int x; (void)options; printf("%s v%u.%u\n\n", command_name, 1U, 0U); printf("\t%s\n\n", description); printf("Current options. A '=' means the option takes a value.\n\n"); for (x= 0; long_options[x].name; x++) { const char *help_message; printf("\t --%s%c\n", long_options[x].name, long_options[x].has_arg ? '=' : ' '); if ((help_message= lookup_help(memcached_options(long_options[x].val)))) printf("\t\t%s\n", help_message); } printf("\n"); exit(EXIT_SUCCESS); } void process_hash_option(memcached_st *memc, char *opt_hash) { uint64_t set; memcached_return_t rc; if (opt_hash == NULL) return; set= MEMCACHED_HASH_DEFAULT; /* Just here to solve warning */ if (!strcasecmp(opt_hash, "CRC")) { set= MEMCACHED_HASH_CRC; } else if (!strcasecmp(opt_hash, "FNV1_64")) { set= MEMCACHED_HASH_FNV1_64; } else if (!strcasecmp(opt_hash, "FNV1A_64")) { set= MEMCACHED_HASH_FNV1A_64; } else if (!strcasecmp(opt_hash, "FNV1_32")) { set= MEMCACHED_HASH_FNV1_32; } else if (!strcasecmp(opt_hash, "FNV1A_32")) { set= MEMCACHED_HASH_FNV1A_32; } else { fprintf(stderr, "hash: type not recognized %s\n", opt_hash); exit(EXIT_FAILURE); } rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, set); if (rc != MEMCACHED_SUCCESS) { fprintf(stderr, "hash: memcache error %s\n", memcached_strerror(memc, rc)); exit(EXIT_FAILURE); } } void initialize_sockets(void) { /* Define the function for all platforms to avoid #ifdefs in each program */ #if defined(WIN32) && WIN32 WSADATA wsaData; if (WSAStartup(MAKEWORD(2,0), &wsaData) != 0) { fprintf(stderr, "Socket Initialization Error. Program aborted\n"); exit(EXIT_FAILURE); } #endif } libmemcached-1.0.8/clients/ms_sigsegv.h0000664000076400007640000000077311753573717020406 0ustar00brianbrian00000000000000/* * File: ms_sigsegv.h * Author: Mingqiang Zhuang * * Created on March 15, 2009 * * (c) Copyright 2009, Schooner Information Technology, Inc. * http://www.schoonerinfotech.com/ * */ #ifndef MS_SIGSEGV_H #define MS_SIGSEGV_H #ifdef __cplusplus extern "C" { #endif /* redirect signal seg */ int ms_setup_sigsegv(void); /* redirect signal pipe */ int ms_setup_sigpipe(void); /* redirect signal int */ int ms_setup_sigint(void); #ifdef __cplusplus } #endif #endif /* end of MS_SIGSEGV_H */ libmemcached-1.0.8/clients/ms_memslap.h0000664000076400007640000000662711753573717020401 0ustar00brianbrian00000000000000/* * File: ms_memslap.h * Author: Mingqiang Zhuang * * Created on February 10, 2009 * * (c) Copyright 2009, Schooner Information Technology, Inc. * http://www.schoonerinfotech.com/ * */ #ifndef MS_MEMSLAP_H #define MS_MEMSLAP_H #include #include #include #include #include #include #include #include #if !defined(__cplusplus) # include #endif #include #include "ms_stats.h" #ifdef __cplusplus extern "C" { #endif /* command line option */ typedef enum { OPT_VERSION= 'V', OPT_HELP= 'h', OPT_UDP= 'U', OPT_SERVERS= 's', OPT_EXECUTE_NUMBER= 'x', OPT_THREAD_NUMBER= 'T', OPT_CONCURRENCY= 'c', OPT_FIXED_LTH= 'X', OPT_VERIFY= 'v', OPT_GETS_DIVISION= 'd', OPT_TIME= 't', OPT_CONFIG_CMD= 'F', OPT_WINDOW_SIZE= 'w', OPT_EXPIRE= 'e', OPT_STAT_FREQ= 'S', OPT_RECONNECT= 'R', OPT_VERBOSE= 'b', OPT_FACEBOOK_TEST= 'a', OPT_SOCK_PER_CONN= 'n', OPT_BINARY_PROTOCOL= 'B', OPT_OVERWRITE= 'o', OPT_TPS= 'P', OPT_REP_WRITE_SRV= 'p' } ms_options_t; /* global statistic of response time */ typedef struct statistic { pthread_mutex_t stat_mutex; /* synchronize the following members */ ms_stat_t get_stat; /* statistics of get command */ ms_stat_t set_stat; /* statistics of set command */ ms_stat_t total_stat; /* statistics of both get and set commands */ } ms_statistic_t; /* global status statistic structure */ typedef struct stats { volatile uint32_t active_conns; /* active connections */ size_t bytes_read; /* read bytes */ size_t bytes_written; /* written bytes */ size_t obj_bytes; /* object bytes */ size_t pre_cmd_get; /* previous total get command count */ size_t pre_cmd_set; /* previous total set command count */ size_t cmd_get; /* current total get command count */ size_t cmd_set; /* current total set command count */ size_t get_misses; /* total objects of get miss */ size_t vef_miss; /* total objects of verification miss */ size_t vef_failed; /* total objects of verification failed */ size_t unexp_unget; /* total objects which is unexpired but not get */ size_t exp_get; /* total objects which is expired but get */ volatile size_t pkt_disorder; /* disorder packages of UDP */ size_t pkt_drop; /* packages dropped of UDP */ size_t udp_timeout; /* how many times timeout of UDP happens */ } ms_stats_t; /* lock adapter */ typedef struct sync_lock { uint32_t count; pthread_mutex_t lock; pthread_cond_t cond; } ms_sync_lock_t; /* global variable structure */ typedef struct global { /* synchronize lock */ ms_sync_lock_t init_lock; ms_sync_lock_t warmup_lock; ms_sync_lock_t run_lock; /* mutex for outputing error log synchronously when memslap crashes */ pthread_mutex_t quit_mutex; /* mutex for generating key prefix */ pthread_mutex_t seq_mutex; /* global synchronous flags for slap mode */ bool finish_warmup; bool time_out; } ms_global_t; /* global structure */ ms_global_t ms_global; /* global stats information structure */ ms_stats_t ms_stats; /* global statistic structure */ ms_statistic_t ms_statistic; #ifdef __cplusplus } #endif #endif /* end of MS_MEMSLAP_H */ libmemcached-1.0.8/clients/ms_stats.h0000664000076400007640000000241611753573717020071 0ustar00brianbrian00000000000000/* * File: ms_stats.h * Author: Mingqiang Zhuang * * Created on March 25, 2009 * * (c) Copyright 2009, Schooner Information Technology, Inc. * http://www.schoonerinfotech.com/ * */ #ifndef MS_STAT_H #define MS_STAT_H #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* statistic structure of response time */ typedef struct { char *name; uint64_t total_time; uint64_t min_time; uint64_t max_time; uint64_t get_miss; uint64_t dist[65]; double squares; double log_product; uint64_t period_min_time; uint64_t period_max_time; uint64_t pre_get_miss; uint64_t pre_events; uint64_t pre_total_time; uint64_t pre_squares; double pre_log_product; } ms_stat_t; /* initialize statistic */ void ms_init_stats(ms_stat_t *stat, const char *name); /* record one event */ void ms_record_event(ms_stat_t *stat, uint64_t time, int get_miss); /* dump the statistics */ void ms_dump_stats(ms_stat_t *stat); /* dump the format statistics */ void ms_dump_format_stats(ms_stat_t *stat, int run_time, int freq, int obj_size); #ifdef __cplusplus } #endif #endif /* MS_STAT_H */ libmemcached-1.0.8/clients/ms_task.c0000664000076400007640000006712611753573717017701 0ustar00brianbrian00000000000000/* * File: ms_task.c * Author: Mingqiang Zhuang * * Created on February 10, 2009 * * (c) Copyright 2009, Schooner Information Technology, Inc. * http://www.schoonerinfotech.com/ * */ #include "config.h" #include #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #include "ms_thread.h" #include "ms_setting.h" #include "ms_atomic.h" /* command distribution adjustment cycle */ #define CMD_DISTR_ADJUST_CYCLE 1000 #define DISADJUST_FACTOR 0.03 /** * In one adjustment cycle, if undo set or get * operations proportion is more than 3% , means * there are too many new item or need more new * item in the window. This factor shows it. */ /* get item from task window */ static ms_task_item_t *ms_get_cur_opt_item(ms_conn_t *c); static ms_task_item_t *ms_get_next_get_item(ms_conn_t *c); static ms_task_item_t *ms_get_next_set_item(ms_conn_t *c); static ms_task_item_t *ms_get_random_overwrite_item(ms_conn_t *c); /* select next operation to do */ static void ms_select_opt(ms_conn_t *c, ms_task_t *task); /* set and get speed estimate for controlling and adjustment */ static bool ms_is_set_too_fast(ms_task_t *task); static bool ms_is_get_too_fast(ms_task_t *task); static void ms_kick_out_item(ms_task_item_t *item); /* miss rate adjustment */ static bool ms_need_overwrite_item(ms_task_t *task); static bool ms_adjust_opt(ms_conn_t *c, ms_task_t *task); /* deal with data verification initialization */ static void ms_task_data_verify_init(ms_task_t *task); static void ms_task_expire_verify_init(ms_task_t *task); /* select a new task to do */ static ms_task_t *ms_get_task(ms_conn_t *c, bool warmup); /* run the selected task */ static void ms_update_set_result(ms_conn_t *c, ms_task_item_t *item); static void ms_update_stat_result(ms_conn_t *c); static void ms_update_multi_get_result(ms_conn_t *c); static void ms_update_single_get_result(ms_conn_t *c, ms_task_item_t *item); static void ms_update_task_result(ms_conn_t *c); static void ms_single_getset_task_sch(ms_conn_t *c); static void ms_multi_getset_task_sch(ms_conn_t *c); static void ms_send_signal(ms_sync_lock_t *sync_lock); static void ms_warmup_server(ms_conn_t *c); static int ms_run_getset_task(ms_conn_t *c); /** * used to get the current operation item(object) * * @param c, pointer of the concurrency * * @return ms_task_item_t*, current operating item */ static ms_task_item_t *ms_get_cur_opt_item(ms_conn_t *c) { return c->curr_task.item; } /** * used to get the next item to do get operation * * @param c, pointer of the concurrency * * @return ms_task_item_t*, the pointer of the next item to do * get operation */ static ms_task_item_t *ms_get_next_get_item(ms_conn_t *c) { ms_task_item_t *item= NULL; if (c->set_cursor <= 0) { /* the first item in the window */ item= &c->item_win[0]; } else if (c->set_cursor > 0 && c->set_cursor < (uint32_t)c->win_size) { /* random get one item set before */ item= &c->item_win[random() % (int64_t)c->set_cursor]; } else { /* random get one item from the window */ item= &c->item_win[random() % c->win_size]; } return item; } /* ms_get_next_get_item */ /** * used to get the next item to do set operation * * @param c, pointer of the concurrency * * @return ms_task_item_t*, the pointer of the next item to do * set operation */ static ms_task_item_t *ms_get_next_set_item(ms_conn_t *c) { /** * when a set command successes, the cursor will plus 1. If set * fails, the cursor doesn't change. it isn't necessary to * increase the cursor here. */ return &c->item_win[(int64_t)c->set_cursor % c->win_size]; } /** * If we need do overwrite, we could select a item set before. * This function is used to get a item set before to do * overwrite. * * @param c, pointer of the concurrency * * @return ms_task_item_t*, the pointer of the previous item of * set operation */ static ms_task_item_t *ms_get_random_overwrite_item(ms_conn_t *c) { return ms_get_next_get_item(c); } /* ms_get_random_overwrite_item */ /** * According to the proportion of operations(get or set), select * an operation to do. * * @param c, pointer of the concurrency * @param task, pointer of current task in the concurrency */ static void ms_select_opt(ms_conn_t *c, ms_task_t *task) { double get_prop= ms_setting.cmd_distr[CMD_GET].cmd_prop; double set_prop= ms_setting.cmd_distr[CMD_SET].cmd_prop; /* update cycle operation number if necessary */ if ((task->cycle_undo_get == 0) || (task->cycle_undo_set == 0)) { task->cycle_undo_get+= (int)(CMD_DISTR_ADJUST_CYCLE * get_prop); task->cycle_undo_set+= (int)(CMD_DISTR_ADJUST_CYCLE * set_prop); } /** * According to operation distribution to choose doing which * operation. If it can't set new object to sever, just change * to do get operation. */ if ((set_prop > PROP_ERROR) && ((double)task->get_opt * set_prop >= (double)task->set_opt * get_prop)) { task->cmd= CMD_SET; task->item= ms_get_next_set_item(c); } else { task->cmd= CMD_GET; task->item= ms_get_next_get_item(c); } } /* ms_select_opt */ /** * used to judge whether the number of get operations done is * more than expected number of get operations to do right now. * * @param task, pointer of current task in the concurrency * * @return bool, if get too fast, return true, else return false */ static bool ms_is_get_too_fast(ms_task_t *task) { double get_prop= ms_setting.cmd_distr[CMD_GET].cmd_prop; double set_prop= ms_setting.cmd_distr[CMD_SET].cmd_prop; /* no get operation */ if (get_prop < PROP_ERROR) { return false; } int max_undo_set= (int)(set_prop / get_prop * (1.0 + DISADJUST_FACTOR)) * task->cycle_undo_get; if (((double)task->get_opt * set_prop > (double)task->set_opt * get_prop) && (task->cycle_undo_set > max_undo_set)) { return true; } return false; } /* ms_is_get_too_fast */ /** * used to judge whether the number of set operations done is * more than expected number of set operations to do right now. * * @param task, pointer of current task in the concurrency * * @return bool, if set too fast, return true, else return false */ static bool ms_is_set_too_fast(ms_task_t *task) { double get_prop= ms_setting.cmd_distr[CMD_GET].cmd_prop; double set_prop= ms_setting.cmd_distr[CMD_SET].cmd_prop; /* no set operation */ if (set_prop < PROP_ERROR) { return false; } /* If it does set operation too fast, skip some */ int max_undo_get= (int)((get_prop / set_prop * (1.0 + DISADJUST_FACTOR)) * (double)task->cycle_undo_set); if (((double)task->get_opt * set_prop < (double)task->set_opt * get_prop) && (task->cycle_undo_get > max_undo_get)) { return true; } return false; } /* ms_is_set_too_fast */ /** * kick out the old item in the window, and add a new item to * overwrite the old item. When we don't want to do overwrite * object, and the current item to do set operation is an old * item, we could kick out the old item and add a new item. Then * we can ensure we set new object every time. * * @param item, pointer of task item which includes the object * information */ static void ms_kick_out_item(ms_task_item_t *item) { /* allocate a new item */ item->key_prefix= ms_get_key_prefix(); item->key_suffix_offset++; item->value_offset= INVALID_OFFSET; /* new item use invalid value offset */ item->client_time= 0; } /* ms_kick_out_item */ /** * used to judge whether we need overwrite object based on the * options user specified * * @param task, pointer of current task in the concurrency * * @return bool, if need overwrite, return true, else return * false */ static bool ms_need_overwrite_item(ms_task_t *task) { ms_task_item_t *item= task->item; assert(item != NULL); assert(task->cmd == CMD_SET); /** * according to data overwrite percent to determine if do data * overwrite. */ if (task->overwrite_set < (double)task->set_opt * ms_setting.overwrite_percent) { return true; } return false; } /* ms_need_overwirte_item */ /** * used to adjust operation. the function must be called after * select operation. the function change get operation to set * operation, or set operation to get operation based on the * current case. * * @param c, pointer of the concurrency * @param task, pointer of current task in the concurrency * * @return bool, if success, return true, else return false */ static bool ms_adjust_opt(ms_conn_t *c, ms_task_t *task) { ms_task_item_t *item= task->item; assert(item != NULL); if (task->cmd == CMD_SET) { /* If did set operation too fast, skip some */ if (ms_is_set_too_fast(task)) { /* get the item instead */ if (item->value_offset != INVALID_OFFSET) { task->cmd= CMD_GET; return true; } } /* If the current item is not a new item, kick it out */ if (item->value_offset != INVALID_OFFSET) { if (ms_need_overwrite_item(task)) { /* overwrite */ task->overwrite_set++; } else { /* kick out the current item to do set operation */ ms_kick_out_item(item); } } else /* it's a new item */ { /* need overwrite */ if (ms_need_overwrite_item(task)) { /** * overwrite not use the item with current set cursor, revert * set cursor. */ c->set_cursor--; item= ms_get_random_overwrite_item(c); if (item->value_offset != INVALID_OFFSET) { task->item= item; task->overwrite_set++; } else /* item is a new item */ { /* select the item to run, and cancel overwrite */ task->item= item; } } } task->cmd= CMD_SET; return true; } else { if (item->value_offset == INVALID_OFFSET) { task->cmd= CMD_SET; return true; } /** * If It does get operation too fast, it will change the * operation to set. */ if (ms_is_get_too_fast(task)) { /* don't kick out the first item in the window */ if (! ms_is_set_too_fast(task)) { ms_kick_out_item(item); task->cmd= CMD_SET; return true; } else { return false; } } assert(item->value_offset != INVALID_OFFSET); task->cmd= CMD_GET; return true; } } /* ms_adjust_opt */ /** * used to initialize the task which need verify data. * * @param task, pointer of current task in the concurrency */ static void ms_task_data_verify_init(ms_task_t *task) { ms_task_item_t *item= task->item; assert(item != NULL); assert(task->cmd == CMD_GET); /** * according to data verification percent to determine if do * data verification. */ if (task->verified_get < (double)task->get_opt * ms_setting.verify_percent) { /** * currently it doesn't do verify, just increase the counter, * and do verification next proper get command */ if ((task->item->value_offset != INVALID_OFFSET) && (item->exp_time == 0)) { task->verify= true; task->finish_verify= false; task->verified_get++; } } } /* ms_task_data_verify_init */ /** * used to initialize the task which need verify expire time. * * @param task, pointer of current task in the concurrency */ static void ms_task_expire_verify_init(ms_task_t *task) { ms_task_item_t *item= task->item; assert(item != NULL); assert(task->cmd == CMD_GET); assert(item->exp_time > 0); task->verify= true; task->finish_verify= false; } /* ms_task_expire_verify_init */ /** * used to get one task, the function initializes the task * structure. * * @param c, pointer of the concurrency * @param warmup, whether it need warmup * * @return ms_task_t*, pointer of current task in the * concurrency */ static ms_task_t *ms_get_task(ms_conn_t *c, bool warmup) { ms_task_t *task= &c->curr_task; while (1) { task->verify= false; task->finish_verify= true; task->get_miss= true; if (warmup) { task->cmd= CMD_SET; task->item= ms_get_next_set_item(c); return task; } /* according to operation distribution to choose doing which operation */ ms_select_opt(c, task); if (! ms_adjust_opt(c, task)) { continue; } if ((ms_setting.verify_percent > 0) && (task->cmd == CMD_GET)) { ms_task_data_verify_init(task); } if ((ms_setting.exp_ver_per > 0) && (task->cmd == CMD_GET) && (task->item->exp_time > 0)) { ms_task_expire_verify_init(task); } break; } /** * Only update get and delete counter, set counter will be * updated after set operation successes. */ if (task->cmd == CMD_GET) { task->get_opt++; task->cycle_undo_get--; } return task; } /* ms_get_task */ /** * send a signal to the main monitor thread * * @param sync_lock, pointer of the lock */ static void ms_send_signal(ms_sync_lock_t *sync_lock) { pthread_mutex_lock(&sync_lock->lock); sync_lock->count++; pthread_cond_signal(&sync_lock->cond); pthread_mutex_unlock(&sync_lock->lock); } /* ms_send_signal */ /** * If user only want to do get operation, but there is no object * in server , so we use this function to warmup the server, and * set some objects to server. It runs at the beginning of task. * * @param c, pointer of the concurrency */ static void ms_warmup_server(ms_conn_t *c) { ms_task_t *task; ms_task_item_t *item; /** * Extra one loop to get the last command returned state. * Normally it gets the previous command returned state. */ if ((c->remain_warmup_num >= 0) && (c->remain_warmup_num != c->warmup_num)) { item= ms_get_cur_opt_item(c); /* only update the set command result state for data verification */ if ((c->precmd.cmd == CMD_SET) && (c->precmd.retstat == MCD_STORED)) { item->value_offset= item->key_suffix_offset; /* set success, update counter */ c->set_cursor++; } else if (c->precmd.cmd == CMD_SET && c->precmd.retstat != MCD_STORED) { printf("key: %" PRIx64 " didn't set success\n", item->key_prefix); } } /* the last time don't run a task */ if (c->remain_warmup_num-- > 0) { /* operate next task item */ task= ms_get_task(c, true); item= task->item; ms_mcd_set(c, item); } /** * finish warming up server, wait all connects initialize * complete. Then all connects can start do task at the same * time. */ if (c->remain_warmup_num == -1) { ms_send_signal(&ms_global.warmup_lock); c->remain_warmup_num--; /* never run the if branch */ } } /* ms_warmup_server */ /** * dispatch single get and set task * * @param c, pointer of the concurrency */ static void ms_single_getset_task_sch(ms_conn_t *c) { ms_task_t *task; ms_task_item_t *item; /* the last time don't run a task */ if (c->remain_exec_num-- > 0) { task= ms_get_task(c, false); item= task->item; if (task->cmd == CMD_SET) { ms_mcd_set(c, item); } else if (task->cmd == CMD_GET) { assert(task->cmd == CMD_GET); ms_mcd_get(c, item); } } } /* ms_single_getset_task_sch */ /** * dispatch multi-get and set task * * @param c, pointer of the concurrency */ static void ms_multi_getset_task_sch(ms_conn_t *c) { ms_task_t *task; ms_mlget_task_item_t *mlget_item; while (1) { if (c->remain_exec_num-- > 0) { task= ms_get_task(c, false); if (task->cmd == CMD_SET) /* just do it */ { ms_mcd_set(c, task->item); break; } else { assert(task->cmd == CMD_GET); mlget_item= &c->mlget_task.mlget_item[c->mlget_task.mlget_num]; mlget_item->item= task->item; mlget_item->verify= task->verify; mlget_item->finish_verify= task->finish_verify; mlget_item->get_miss= task->get_miss; c->mlget_task.mlget_num++; /* enough multi-get task items can be done */ if ((c->mlget_task.mlget_num >= ms_setting.mult_key_num) || ((c->remain_exec_num == 0) && (c->mlget_task.mlget_num > 0))) { ms_mcd_mlget(c); break; } } } else { if ((c->remain_exec_num <= 0) && (c->mlget_task.mlget_num > 0)) { ms_mcd_mlget(c); } break; } } } /* ms_multi_getset_task_sch */ /** * calculate the difference value of two time points * * @param start_time, the start time * @param end_time, the end time * * @return uint64_t, the difference value between start_time and end_time in us */ int64_t ms_time_diff(struct timeval *start_time, struct timeval *end_time) { int64_t endtime= end_time->tv_sec * 1000000 + end_time->tv_usec; int64_t starttime= start_time->tv_sec * 1000000 + start_time->tv_usec; assert(endtime >= starttime); return endtime - starttime; } /* ms_time_diff */ /** * after get the response from server for multi-get, the * function update the state of the task and do data verify if * necessary. * * @param c, pointer of the concurrency */ static void ms_update_multi_get_result(ms_conn_t *c) { ms_mlget_task_item_t *mlget_item; ms_task_item_t *item; char *orignval= NULL; char *orignkey= NULL; if (c == NULL) { return; } assert(c != NULL); for (int i= 0; i < c->mlget_task.mlget_num; i++) { mlget_item= &c->mlget_task.mlget_item[i]; item= mlget_item->item; orignval= &ms_setting.char_block[item->value_offset]; orignkey= &ms_setting.char_block[item->key_suffix_offset]; /* update get miss counter */ if (mlget_item->get_miss) { atomic_add_size(&ms_stats.get_misses, 1); } /* get nothing from server for this task item */ if (mlget_item->verify && ! mlget_item->finish_verify) { /* verify expire time if necessary */ if (item->exp_time > 0) { struct timeval curr_time; gettimeofday(&curr_time, NULL); /* object doesn't expire but can't get it now */ if (curr_time.tv_sec - item->client_time < item->exp_time - EXPIRE_TIME_ERROR) { atomic_add_size(&ms_stats.unexp_unget, 1); if (ms_setting.verbose) { char set_time[64]; char cur_time[64]; strftime(set_time, 64, "%Y-%m-%d %H:%M:%S", localtime(&item->client_time)); strftime(cur_time, 64, "%Y-%m-%d %H:%M:%S", localtime(&curr_time.tv_sec)); fprintf(stderr, "\n\t<%d expire time verification failed, object " "doesn't expire but can't get it now\n" "\tkey len: %d\n" "\tkey: %" PRIx64 " %.*s\n" "\tset time: %s current time: %s " "diff time: %d expire time: %d\n" "\texpected data len: %d\n" "\texpected data: %.*s\n" "\treceived data: \n", c->sfd, item->key_size, item->key_prefix, item->key_size - (int)KEY_PREFIX_SIZE, orignkey, set_time, cur_time, (int)(curr_time.tv_sec - item->client_time), item->exp_time, item->value_size, item->value_size, orignval); fflush(stderr); } } } else { atomic_add_size(&ms_stats.vef_miss, 1); if (ms_setting.verbose) { fprintf(stderr, "\n<%d data verification failed\n" "\tkey len: %d\n" "\tkey: %" PRIx64 " %.*s\n" "\texpected data len: %d\n" "\texpected data: %.*s\n" "\treceived data: \n", c->sfd, item->key_size, item->key_prefix, item->key_size - (int)KEY_PREFIX_SIZE, orignkey, item->value_size, item->value_size, orignval); fflush(stderr); } } } } c->mlget_task.mlget_num= 0; c->mlget_task.value_index= INVALID_OFFSET; } /* ms_update_multi_get_result */ /** * after get the response from server for single get, the * function update the state of the task and do data verify if * necessary. * * @param c, pointer of the concurrency * @param item, pointer of task item which includes the object * information */ static void ms_update_single_get_result(ms_conn_t *c, ms_task_item_t *item) { char *orignval= NULL; char *orignkey= NULL; if ((c == NULL) || (item == NULL)) { return; } assert(c != NULL); assert(item != NULL); orignval= &ms_setting.char_block[item->value_offset]; orignkey= &ms_setting.char_block[item->key_suffix_offset]; /* update get miss counter */ if ((c->precmd.cmd == CMD_GET) && c->curr_task.get_miss) { atomic_add_size(&ms_stats.get_misses, 1); } /* get nothing from server for this task item */ if ((c->precmd.cmd == CMD_GET) && c->curr_task.verify && ! c->curr_task.finish_verify) { /* verify expire time if necessary */ if (item->exp_time > 0) { struct timeval curr_time; gettimeofday(&curr_time, NULL); /* object doesn't expire but can't get it now */ if (curr_time.tv_sec - item->client_time < item->exp_time - EXPIRE_TIME_ERROR) { atomic_add_size(&ms_stats.unexp_unget, 1); if (ms_setting.verbose) { char set_time[64]; char cur_time[64]; strftime(set_time, 64, "%Y-%m-%d %H:%M:%S", localtime(&item->client_time)); strftime(cur_time, 64, "%Y-%m-%d %H:%M:%S", localtime(&curr_time.tv_sec)); fprintf(stderr, "\n\t<%d expire time verification failed, object " "doesn't expire but can't get it now\n" "\tkey len: %d\n" "\tkey: %" PRIx64 " %.*s\n" "\tset time: %s current time: %s " "diff time: %d expire time: %d\n" "\texpected data len: %d\n" "\texpected data: %.*s\n" "\treceived data: \n", c->sfd, item->key_size, item->key_prefix, item->key_size - (int)KEY_PREFIX_SIZE, orignkey, set_time, cur_time, (int)(curr_time.tv_sec - item->client_time), item->exp_time, item->value_size, item->value_size, orignval); fflush(stderr); } } } else { atomic_add_size(&ms_stats.vef_miss, 1); if (ms_setting.verbose) { fprintf(stderr, "\n<%d data verification failed\n" "\tkey len: %d\n" "\tkey: %" PRIx64 " %.*s\n" "\texpected data len: %d\n" "\texpected data: %.*s\n" "\treceived data: \n", c->sfd, item->key_size, item->key_prefix, item->key_size - (int)KEY_PREFIX_SIZE, orignkey, item->value_size, item->value_size, orignval); fflush(stderr); } } } } /* ms_update_single_get_result */ /** * after get the response from server for set the function * update the state of the task and do data verify if necessary. * * @param c, pointer of the concurrency * @param item, pointer of task item which includes the object * information */ static void ms_update_set_result(ms_conn_t *c, ms_task_item_t *item) { if ((c == NULL) || (item == NULL)) { return; } assert(c != NULL); assert(item != NULL); if (c->precmd.cmd == CMD_SET) { switch (c->precmd.retstat) { case MCD_STORED: if (item->value_offset == INVALID_OFFSET) { /* first set with the same offset of key suffix */ item->value_offset= item->key_suffix_offset; } else { /* not first set, just increase the value offset */ item->value_offset+= 1; } /* set successes, update counter */ c->set_cursor++; c->curr_task.set_opt++; c->curr_task.cycle_undo_set--; break; case MCD_SERVER_ERROR: default: break; } /* switch */ } } /* ms_update_set_result */ /** * update the response time result * * @param c, pointer of the concurrency */ static void ms_update_stat_result(ms_conn_t *c) { bool get_miss= false; if (c == NULL) { return; } assert(c != NULL); gettimeofday(&c->end_time, NULL); uint64_t time_diff= (uint64_t)ms_time_diff(&c->start_time, &c->end_time); pthread_mutex_lock(&ms_statistic.stat_mutex); switch (c->precmd.cmd) { case CMD_SET: ms_record_event(&ms_statistic.set_stat, time_diff, false); break; case CMD_GET: if (c->curr_task.get_miss) { get_miss= true; } ms_record_event(&ms_statistic.get_stat, time_diff, get_miss); break; default: break; } /* switch */ ms_record_event(&ms_statistic.total_stat, time_diff, get_miss); pthread_mutex_unlock(&ms_statistic.stat_mutex); } /* ms_update_stat_result */ /** * after get response from server for the current operation, and * before doing the next operation, update the state of the * current operation. * * @param c, pointer of the concurrency */ static void ms_update_task_result(ms_conn_t *c) { ms_task_item_t *item; if (c == NULL) { return; } assert(c != NULL); item= ms_get_cur_opt_item(c); if (item == NULL) { return; } assert(item != NULL); ms_update_set_result(c, item); if ((ms_setting.stat_freq > 0) && ((c->precmd.cmd == CMD_SET) || (c->precmd.cmd == CMD_GET))) { ms_update_stat_result(c); } /* update multi-get task item */ if (((ms_setting.mult_key_num > 1) && (c->mlget_task.mlget_num >= ms_setting.mult_key_num)) || ((c->remain_exec_num == 0) && (c->mlget_task.mlget_num > 0))) { ms_update_multi_get_result(c); } else { ms_update_single_get_result(c, item); } } /* ms_update_task_result */ /** * run get and set operation * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_run_getset_task(ms_conn_t *c) { /** * extra one loop to get the last command return state. get the * last command return state. */ if ((c->remain_exec_num >= 0) && (c->remain_exec_num != c->exec_num)) { ms_update_task_result(c); } /* multi-get */ if (ms_setting.mult_key_num > 1) { /* operate next task item */ ms_multi_getset_task_sch(c); } else { /* operate next task item */ ms_single_getset_task_sch(c); } /* no task to do, exit */ if ((c->remain_exec_num == -1) || ms_global.time_out) { return -1; } return EXIT_SUCCESS; } /* ms_run_getset_task */ /** * the state machine call the function to execute task. * * @param c, pointer of the concurrency * * @return int, if success, return EXIT_SUCCESS, else return -1 */ int ms_exec_task(struct conn *c) { if (! ms_global.finish_warmup) { ms_warmup_server(c); } else { if (ms_run_getset_task(c) != 0) { return -1; } } return EXIT_SUCCESS; } /* ms_exec_task */ libmemcached-1.0.8/config/0000775000076400007640000000000011757025120015644 5ustar00brianbrian00000000000000libmemcached-1.0.8/config/compile0000755000076400007640000000727111753633407017240 0ustar00brianbrian00000000000000#! /bin/sh # Wrapper for compilers which do not understand `-c -o'. scriptversion=2009-10-06.20; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software # Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand `-c -o'. Remove `-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file `INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; esac ofile= cfile= eat= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as `compile cc -o foo foo.c'. # So we strip `-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no `-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # `.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use `[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: libmemcached-1.0.8/config/config.sub0000755000076400007640000010316711753633407017646 0ustar00brianbrian00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 # Free Software Foundation, Inc. timestamp='2009-11-20' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nios | nios2 \ | ns16k | ns32k \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | ubicom32 \ | v850 | v850e \ | we32k \ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | picochip) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze) basic_machine=microblaze-xilinx ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; tile*) basic_machine=tile-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: libmemcached-1.0.8/config/pandora-plugin0000775000076400007640000007070011753573717020536 0ustar00brianbrian00000000000000#!/usr/bin/python # Copyright (C) 2009 Sun Microsystems, Inc. # Copyright (C) 2010, 2011 Monty Taylor # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA pandora_plugin_file = 'config/pandora-plugin.ini' # Find plugins in the tree and add them to the build system import ConfigParser, os, sys import datetime, time import subprocess plugin_am_file=None plugin_ac_file=None plugin_doc_index=None class ChangeProtectedFile(object): def __init__(self, fname): self.bogus_file= False self.real_fname= fname self.new_fname= "%s.new" % fname try: self.new_file= open(self.new_fname,'w+') except IOError: self.bogus_file= True def write(self, text): if not self.bogus_file: self.new_file.write(text) # We've written all of this out into .new files, now we only copy them # over the old ones if they are different, so that we don't cause # unnecessary recompiles def close(self): """Return True if the file had changed.""" if self.bogus_file: return self.new_file.seek(0) new_content = self.new_file.read() self.new_file.close() try: old_file = file(self.real_fname, 'r') old_content = old_file.read() old_file.close() except IOError: old_content = None if new_content != old_content: if old_content != None: os.unlink(self.real_fname) os.rename(self.new_fname, self.real_fname) return True else: try: os.unlink(self.new_fname) except: pass def write_external_configure(plugin, plugin_file): """Write the initial bits of the configure.ac file""" if not os.path.exists('m4'): os.mkdir('m4') plugin_file.write(""" AC_PREREQ(2.59)dnl Minimum Autoconf version required. AC_INIT([%(name)s],[%(version)s],[%(url)s]) AC_CONFIG_SRCDIR([%(main_source)s]) AC_CONFIG_AUX_DIR(config) PANDORA_CANONICAL_TARGET(less-warnings, warnings-always-on, require-cxx, force-gcc42,skip-visibility) PANDORA_REQUIRE_LIBPROTOBUF PANDORA_PROTOBUF_REQUIRE_VERSION([2.1.0]) PANDORA_REQUIRE_PROTOC AC_LANG_PUSH(C++) PANDORA_REQUIRE_PTHREAD PANDORA_REQUIRE_LIBDL AC_LANG_POP PANDORA_USE_BETTER_MALLOC PANDORA_DRIZZLE_BUILD """ % plugin) write_plugin_ac(plugin, plugin_file) plugin_file.write(""" AC_CONFIG_FILES(Makefile) AC_OUTPUT echo "---" echo "Configuration summary for $PACKAGE_NAME version $VERSION $PANDORA_RELEASE_COMMENT" echo "" echo " * Installation prefix: $prefix" echo " * System type: $host_vendor-$host_os" echo " * Host CPU: $host_cpu" echo " * C Compiler: $CC_VERSION" echo " * C++ Compiler: $CXX_VERSION" echo " * Debug enabled: $with_debug" echo " * Warnings as failure: $ac_cv_warnings_as_errors" echo " * C++ cstdint location: $ac_cv_cxx_cstdint" echo " * C++ hash_map location: $ac_cv_cxx_hash_map" echo " * C++ hash namespace: $ac_cv_cxx_hash_namespace" echo " * C++ shared_ptr namespace: $ac_cv_shared_ptr_namespace" echo "" echo "---" """ % plugin) def write_external_makefile(plugin, plugin_file): plugin_file.write(""" ACLOCAL_AMFLAGS = -I m4 --force VERSION=$(PANDORA_RELEASE_VERSION) pkgplugindir=%(pkgplugindir)s EXTRA_DIST = plugin.ini noinst_HEADERS= nobase_include_HEADERS= nobase_pkginclude_HEADERS= check_PROGRAMS= noinst_LTLIBRARIES= bin_PROGRAMS= """ % plugin) if plugin['headers'] != "": plugin_file.write("noinst_HEADERS += %(headers)s\n" % plugin) if plugin['install_headers'] != "": plugin_file.write("nobase_pkginclude_HEADERS += %(install_headers)s\n" % plugin) if plugin['testsuite']: if plugin.has_key('testsuitedir') and plugin['testsuitedir'] != "": plugin_file.write("EXTRA_DIST += %(testsuitedir)s\n" % plugin) plugin_file.write(""" pkgplugin_LTLIBRARIES=%(libname)s.la %(libname)s_la_LDFLAGS=-avoid-version -rpath $(pkgplugindir) $(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS) %(libname)s_la_LIBADD=%(libs)s %(libname)s_la_DEPENDENCIES=%(libs)s %(libname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN -DPANDORA_MODULE_NAME=%(module_name)s -DPANDORA_MODULE_AUTHOR='%(author)s' -DPANDORA_MODULE_TITLE='%(title)s' -DPANDORA_MODULE_VERSION='%(version)s' -DPANDORA_MODULE_LICENSE=%(license)s %(cppflags)s %(libname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s %(libname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s %(libname)s_la_SOURCES=%(sources)s check_PROGRAMS += %(tests)s """ % plugin) plugin_am_file=os.path.join(plugin['rel_path'],'plugin.am') if os.path.exists(plugin_am_file): plugin_file.write('include %s\n' % plugin_am_file) def write_external_plugin(): """Return True if the plugin had changed.""" plugin = read_plugin_ini('.') expand_plugin_ini(plugin) plugin_file = ChangeProtectedFile('configure.ac') write_external_configure(plugin, plugin_file) result = plugin_file.close() plugin_file = ChangeProtectedFile('Makefile.am') write_external_makefile(plugin, plugin_file) # Write some stub configure.ac and Makefile.am files that include the above result = plugin_file.close() or result return result def write_plugin(plugin, plugin_ini_list): # Since this function is recursive, make sure we're not already in it. if plugin.has_key('writing_status'): if plugin['writing_status'] == 'done': return else: print "Dependency loop detected with %s" % plugin['name'] exit(1) plugin['writing_status'] = 'dependencies' # Write all dependencies first to get around annoying automake bug for dependency in plugin['dependency_list']: found = False for find_plugin in plugin_ini_list: if find_plugin['module_name'] == dependency: found = True write_plugin(find_plugin, plugin_ini_list) break if found is False: print "Could not find dependency %s: %s" % (plugin['name'], dependency) exit(1) write_plugin_ac(plugin, plugin_ac_file) write_plugin_am(plugin, plugin_am_file) write_plugin_docs(plugin, plugin_doc_index, plugin_am_file) plugin['writing_status'] = 'done' def write_plugin_docs(plugin, doc_index, plugin_am): if plugin['docs'] is not None and os.path.isdir("docs/plugins"): if not os.path.exists(os.path.join("docs/plugins",plugin["name"])): os.symlink(os.path.abspath(plugin["docs"]), os.path.join("docs/plugins",plugin["name"])) doc_index.write(""" %(name)s/index""" % plugin) plugin_am.write(""" EXTRA_DIST+=${top_srcdir}/docs/plugins/%(name)s/*.rst """ % plugin) def write_plugin_ac(plugin, plugin_ac): # # Write plugin config instructions into plugin.ac file. # plugin_ac_file=os.path.join(plugin['rel_path'],'plugin.ac') plugin_m4_dir=os.path.join(plugin['rel_path'],'m4') plugin_m4_files=[] if os.path.exists(plugin_m4_dir) and os.path.isdir(plugin_m4_dir): for m4_file in os.listdir(plugin_m4_dir): if os.path.splitext(m4_file)[-1] == '.m4': plugin_m4_files.append(os.path.join(plugin['rel_path'], m4_file)) plugin_ac.write(""" dnl Config for %(title)s """ % plugin) for m4_file in plugin_m4_files: plugin_ac.write('m4_sinclude([%s])\n' % m4_file) plugin['plugin_dep_libs']=" ".join(["\${top_builddir}/%s" % f for f in plugin['libs'].split()]) plugin_ac.write(""" AC_ARG_WITH([%(name_with_dashes)s-plugin],[ dnl indented wierd to make the help output correct AS_HELP_STRING([--with-%(name_with_dashes)s-plugin],[Build %(title)s. @<:@default=%(enabled)s@:>@]) AS_HELP_STRING([--without-%(name_with_dashes)s-plugin],[Disable building %(title)s]) ],[ with_%(name)s_plugin="$withval" AS_IF([test "x$with_%(name)s_plugin" = "xyes"],[ requested_%(name)s_plugin="yes" ],[ requested_%(name)s_plugin="no" ]) ],[ with_%(name)s_plugin="%(enabled)s" requested_%(name)s_plugin="no" ]) AC_ARG_WITH([static-%(name_with_dashes)s-plugin],[ AS_HELP_STRING([--with-static-%(name_with_dashes)s-plugin],[Build Archive Storage Engine. @<:@default=%(static_yesno)s@:>@]) AS_HELP_STRING([--without-static-%(name_with_dashes)s-plugin],[Disable building Archive Storage Engine]) ],[ with_static_%(name)s_plugin=${withval} ],[ with_static_%(name)s_plugin=%(static_yesno)s ]) AS_IF([test "x${with_static_%(name)s_plugin}" = "xyes" -o "x${with_all_static}" = "xyes"],[ shared_%(name)s_plugin=no ],[ shared_%(name)s_plugin=yes ]) AC_ARG_ENABLE([%(name_with_dashes)s-plugin],[ dnl indented wierd to make the help output correct AS_HELP_STRING([--enable-%(name_with_dashes)s-plugin],[Enable loading %(title)s by default. @<:@default=%(default_yesno)s@:>@]) AS_HELP_STRING([--disable-%(name_with_dashes)s-plugin],[Disable loading %(title)s by default.]) ], [enable_%(name)s_plugin="$enableval"], [enable_%(name)s_plugin=%(default_yesno)s]) """ % plugin) if os.path.exists(plugin_ac_file): plugin_ac.write('m4_sinclude([%s])\n' % plugin_ac_file) # The plugin author has specified some check to make to determine # if the plugin can be built. If the plugin is turned on and this # check fails, then configure should error out. If the plugin is not # turned on, then the normal conditional build stuff should just let # it silently not build if plugin['has_build_conditional']: plugin_ac.write(""" AS_IF([test %(build_conditional)s], [], dnl build_conditional can only negate [ AS_IF([test "x${requested_%(name)s_plugin}" = "xyes"], [AC_MSG_ERROR([Plugin %(name)s was explicitly requested, yet failed build dependency checks. Aborting!])]) with_%(name)s_plugin=no ]) """ % plugin) if not plugin['unconditional']: plugin_ac.write(""" AM_CONDITIONAL([%(static_build_conditional_tag)s], [test %(build_conditional)s -a ! %(shared_build)s]) AM_CONDITIONAL([%(shared_build_conditional_tag)s], [test %(build_conditional)s -a %(shared_build)s]) AM_CONDITIONAL([%(build_conditional_tag)s], [test %(build_conditional)s]) """ % plugin) plugin_ac.write(""" AS_IF([test "x$with_%(name)s_plugin" = "xyes"],[ """ % plugin) if plugin['testsuite']: plugin_ac.write(""" pandora_plugin_test_list="%(name)s,${pandora_plugin_test_list}" """ % plugin) plugin_ac.write(""" AS_IF([test "x${with_static_%(name)s_plugin}" = "xyes" -o "x${with_all_static}" = "xyes"],[ AS_IF([test "x$enable_%(name)s_plugin" = "xyes"],[ pandora_builtin_load_list="%(module_name)s,${pandora_builtin_load_list}" pandora_builtin_load_symbols_list="_drizzled_%(module_name)s_plugin_,${pandora_builtin_load_symbols_list}" PANDORA_PLUGIN_DEP_LIBS="${PANDORA_PLUGIN_DEP_LIBS} %(plugin_dep_libs)s" ]) pandora_builtin_list="%(module_name)s,${pandora_builtin_list}" pandora_builtin_symbols_list="_drizzled_%(module_name)s_plugin_,${pandora_builtin_symbols_list}" pandora_plugin_libs="${pandora_plugin_libs} \${top_builddir}/%(root_plugin_dir)s/%(libname)s.la" ],[ AS_IF([test "x$enable_%(name)s_plugin" = "xyes"],[ pandora_default_plugin_list="%(name)s,${pandora_default_plugin_list}" ]) ]) """ % plugin) plugin_ac.write("])\n") def fix_file_paths(plugin, files): # TODO: determine path to plugin dir relative to top_srcdir... append it to # source files if they don't already have it new_files="" if plugin['plugin_dir'] != ".": for file in files.split(): if not file.startswith(plugin['rel_path']): file= os.path.join(plugin['rel_path'], file) new_files= "%s %s" % (new_files, file) else: new_files= " ".join(plugin['sources'].split()) if new_files != "": return new_files return files def expand_plugin_ini(plugin): if plugin['name'] == "**OUT-OF-TREE**": print "Out of tree plugins require the name field to be specified in plugin.ini" sys.exit(1) if plugin['plugin_dir'] == ".": plugin['rel_path']= plugin['plugin_dir'] plugin['unconditional']=True else: plugin['rel_path']= plugin['plugin_dir'][len(config['top_srcdir'])+len(os.path.sep):] plugin['unconditional']=False plugin['sources']= fix_file_paths(plugin, plugin['sources']) plugin['main_source']= plugin['sources'].split()[0] plugin['headers']= fix_file_paths(plugin, plugin['headers']) plugin['install_headers']= fix_file_paths(plugin, plugin['install_headers']) plugin['tests']= fix_file_paths(plugin, plugin['tests']) # Make a yes/no version for autoconf help messages if plugin['load_by_default']: plugin['default_yesno']="yes" else: plugin['default_yesno']="no" if plugin.has_key('extra_dist'): plugin['extra_dist']=" ".join([os.path.join(plugin['rel_path'],f) for f in plugin['extra_dist'].split()]) if plugin['static']: plugin['static_yesno']="yes" else: plugin['static_yesno']="no" plugin['build_conditional_tag']= "BUILD_%s_PLUGIN" % plugin['name'].upper() plugin['shared_build_conditional_tag']= "BUILD_%s_PLUGIN_SHARED" % plugin['name'].upper() plugin['static_build_conditional_tag']= "BUILD_%s_PLUGIN_STATIC" % plugin['name'].upper() plugin['name_with_dashes']= plugin['name'].replace('_','-') if plugin.has_key('build_conditional'): plugin['has_build_conditional']=True plugin['build_conditional']='"x${with_%(name)s_plugin}" = "xyes" -a %(build_conditional)s' % plugin else: plugin['has_build_conditional']=False plugin['build_conditional']='"x${with_%(name)s_plugin}" = "xyes"' %plugin plugin['shared_build']='"x${shared_%(name)s_plugin}" = "xyes"' %plugin if plugin['install']: plugin['library_type']= 'pkgplugin' else: plugin['library_type']= 'noinst' def find_testsuite(plugin_dir): for testdir in ['drizzle-tests','tests']: if os.path.isdir(os.path.join(plugin_dir,testdir)): return testdir if os.path.isdir(os.path.join('tests','suite',os.path.basename(plugin_dir))): return "" return None def find_docs(plugin_dir): if os.path.isfile(os.path.join(plugin_dir, "docs", "index.rst")): return os.path.join(plugin_dir, "docs") def read_plugin_ini(plugin_dir): sources_default="" if plugin_dir == ".": plugin_name="**OUT-OF-TREE**" module_name="**OUT-OF-TREE**" else: sources_default="%s.cc" % os.path.basename(plugin_dir) plugin_name = plugin_dir[plugin_dir.index(config['root_plugin_dir']) + len(config['root_plugin_dir']) + 1:] module_name = plugin_name.replace("/", config['module_name_separator']).replace("\\", config['module_name_separator']) plugin_name = plugin_name.replace("/", config['plugin_name_separator']).replace("\\", config['plugin_name_separator']) plugin_file= os.path.join(plugin_dir,config['plugin_ini_fname']) plugin_defaults= dict(sources=sources_default, headers="", install_headers="", cflags="", cppflags="", cxxflags="", libs="", ldflags="", author="", title="", description="", license="PLUGIN_LICENSE_GPL", name=plugin_name, module_name=module_name, load_by_default=config['default_load_by_default'], disabled="False", static="False", dependencies="", dependency_aliases="", tests="", install=config['default_install']) parser=ConfigParser.ConfigParser(defaults= plugin_defaults) parser.read(plugin_file) plugin=dict(parser.items('plugin')) plugin['plugin_dir'] = plugin_dir if plugin_dir == '.': if not plugin.has_key('url'): print "External Plugins are required to specifiy a url" plugin['url']= 'http://launchpad.net/%(name)s' % plugin sys.exit(1) if plugin_dir == '.' and not plugin.has_key('version'): print "External Plugins are required to specifiy a version" sys.exit(1) if not plugin.has_key('version'): plugin['version'] = config['default_plugin_version'] if plugin.has_key('load_by_default'): plugin['load_by_default']=parser.getboolean('plugin','load_by_default') if plugin.has_key('disabled'): plugin['disabled']=parser.getboolean('plugin','disabled') if plugin['disabled']: plugin['enabled']="no" else: plugin['enabled']="yes" if plugin.has_key('static'): try: plugin['static']= parser.getboolean('plugin','static') except: if plugin['static'][:5] == os.sys.platform[:5]: plugin['static']= True else: plugin['static']= False if plugin.has_key('install'): plugin['install']= parser.getboolean('plugin','install') if plugin.has_key('testsuite'): if plugin['testsuite'] == 'disable': plugin['testsuite']= False plugin['dist_testsuite']= find_testsuite(plugin_dir) else: plugin_testsuite= find_testsuite(plugin_dir) plugin['testsuitedir']=plugin_testsuite if plugin_testsuite is not None: plugin['testsuite']=True else: plugin['testsuite']=False plugin['docs']= find_docs(plugin_dir) plugin['cflags']+= ' ' + config['extra_cflags'] plugin['cppflags']+= ' ' + config['extra_cppflags'] plugin['cxxflags']+= ' ' + config['extra_cxxflags'] plugin['libname']= "lib%s%s%s" % (config['plugin_prefix'], plugin['name'], config['plugin_suffix']) if config['force_lowercase_libname']: plugin['libname']= plugin['libname'].lower() plugin['root_plugin_dir']= config['root_plugin_dir'] plugin['plugin_prefix']= config['plugin_prefix'] plugin['plugin_suffix']= config['plugin_suffix'] plugin['pkgplugindir']= config['pkgplugindir'] # Dependencies must have a module but dependency aliases are simply added # to the variable passed during compile. plugin['dependency_list'] = plugin['dependencies'].split() dependency_aliases = plugin['dependency_aliases'].split() plugin['dependencies'] = ','.join(plugin['dependency_list'] + plugin['dependency_aliases'].split()) dependency_libs = ["%s/lib%s%s.la" % (config['root_plugin_dir'], dependency.lower().replace('::', '_'), config['plugin_suffix']) for dependency in plugin['dependency_list']] plugin['libs'] = " ".join(plugin['libs'].split() + dependency_libs); # Libtool is going to expand: # -DPANDORA_MODULE_AUTHOR='"Padraig O'"'"'Sullivan"' # to: # "-DPANDORA_MODULE_AUTHOR=\"Padraig O'Sullivan\"" # So we have to replace internal ''s to '"'"' for key in ('author','title','description','version'): plugin[key]=plugin[key].replace('"','\\"') plugin[key]=plugin[key].replace("'","'\"'\"'") return plugin def write_plugin_am(plugin, plugin_am): """Write an automake fragment for this plugin. :param plugin: The plugin dict. :param plugin_am: The file to write to. """ # The .plugin.ini.stamp avoids changing the datestamp on plugin.ini which can # confuse VCS systems. plugin_am.write(""" EXTRA_DIST += %(rel_path)s/plugin.ini # Prevent errors when a plugin dir is removed %(rel_path)s/plugin.ini: """ % plugin) if plugin.has_key('extra_dist') and plugin['extra_dist'] != "": plugin_am.write("EXTRA_DIST += %(extra_dist)s\n" % plugin) if plugin['headers'] != "": plugin_am.write("noinst_HEADERS += %(headers)s\n" % plugin) if plugin['install_headers'] != "": plugin_am.write("nobase_pkginclude_HEADERS += %(install_headers)s\n" % plugin) if plugin['testsuite']: if plugin.has_key('testsuitedir') and plugin['testsuitedir'] != "": plugin_am.write("EXTRA_DIST += %(rel_path)s/%(testsuitedir)s\n" % plugin) if plugin.has_key('dist_testsuite') and plugin['dist_testsuite'] != "": plugin_am.write("EXTRA_DIST += %(rel_path)s/%(dist_testsuite)s\n" % plugin) if plugin['docs'] is not None: plugin_am.write("EXTRA_DIST += ${top_srcdir}/%(rel_path)s/docs/*.rst\n" % plugin) plugin_am.write(""" %(root_plugin_dir)s_%(plugin_prefix)s%(name)s_dir=${top_srcdir}/%(rel_path)s # Include sources in EXTRA_DIST because we might not build this, but we # still want the sources to wind up in a tarball EXTRA_DIST += %(rel_path)s/plugin.ini %(sources)s if %(static_build_conditional_tag)s noinst_LTLIBRARIES+=%(root_plugin_dir)s/%(libname)s.la %(root_plugin_dir)s_%(libname)s_la_LIBADD=%(libs)s %(root_plugin_dir)s_%(libname)s_la_DEPENDENCIES=%(libs)s %(root_plugin_dir)s_%(libname)s_la_LDFLAGS=$(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS) %(root_plugin_dir)s_%(libname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_MODULE_NAME=%(module_name)s -DPANDORA_MODULE_AUTHOR='%(author)s' -DPANDORA_MODULE_TITLE='%(title)s' -DPANDORA_MODULE_VERSION='%(version)s' -DPANDORA_MODULE_LICENSE=%(license)s -DPANDORA_MODULE_DEPENDENCIES='%(dependencies)s' %(cppflags)s %(root_plugin_dir)s_%(libname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s %(root_plugin_dir)s_%(libname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s %(root_plugin_dir)s_%(libname)s_la_SOURCES=%(sources)s check_PROGRAMS += %(tests)s PANDORA_DYNAMIC_LDADDS+=${top_builddir}/%(root_plugin_dir)s/%(libname)s.la endif EXTRA_DIST += %(rel_path)s/plugin.ini if %(shared_build_conditional_tag)s %(library_type)s_LTLIBRARIES+=%(root_plugin_dir)s/%(libname)s.la %(root_plugin_dir)s_%(libname)s_la_LDFLAGS=-avoid-version -rpath $(pkgplugindir) $(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS) %(root_plugin_dir)s_%(libname)s_la_LIBADD=%(libs)s %(root_plugin_dir)s_%(libname)s_la_DEPENDENCIES=%(libs)s %(root_plugin_dir)s_%(libname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN -DPANDORA_MODULE_NAME=%(module_name)s -DPANDORA_MODULE_AUTHOR='%(author)s' -DPANDORA_MODULE_TITLE='%(title)s' -DPANDORA_MODULE_VERSION='%(version)s' -DPANDORA_MODULE_LICENSE=%(license)s -DPANDORA_MODULE_DEPENDENCIES='%(dependencies)s' %(cppflags)s %(root_plugin_dir)s_%(libname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s %(root_plugin_dir)s_%(libname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s %(root_plugin_dir)s_%(libname)s_la_SOURCES=%(sources)s check_PROGRAMS += %(tests)s endif """ % plugin) plugin_am_file=os.path.join(plugin['rel_path'],'plugin.am') if os.path.exists(plugin_am_file): plugin_am.write('include %s\n' % plugin_am_file) # # MAIN STARTS HERE: # # Parse the pandora-plugin config file config_defaults= dict( top_srcdir='.', top_builddir='.', plugin_ini_fname='plugin.ini', plugin_prefix='', plugin_suffix='', extra_cflags='', extra_cppflags='', extra_cxxflags='', root_plugin_dir='', pkgplugindir='', default_install='True', default_plugin_version='', default_load_by_default='False', force_lowercase_libname='True', plugin_name_separator='_', module_name_separator='::' ) config_parser = ConfigParser.ConfigParser(defaults=config_defaults) config_parser.read(pandora_plugin_file) config = dict(config_parser.items('pandora-plugin')) config['force_lowercase_libname']=config_parser.getboolean('pandora-plugin','force_lowercase_libname') # I'm 3 seconds away from writing a comprehensive build solution if not os.path.exists('config/pandora_vc_revinfo'): if os.path.exists('.bzr'): bzr_revno= subprocess.Popen(["bzr", "revno"], stdout=subprocess.PIPE).communicate()[0].strip() rev_date= datetime.date.fromtimestamp(time.time()) config['default_plugin_version'] = "%d.%02d.%s" % (rev_date.year, rev_date.month, bzr_revno) else: config['default_plugin_version']=datetime.date.fromtimestamp(time.time()).isoformat() else: # need to read config/pandora_vc_revno pandora_vc_revno=open('config/pandora_vc_revinfo','r').read().split() rev_date="" bzr_revno="" for revno_line in pandora_vc_revno: (revno_key,revno_val)= revno_line.split("=") if revno_key == 'PANDORA_VC_REVNO': bzr_revno=revno_val.strip() elif revno_key == 'PANDORA_RELEASE_DATE': rev_date=revno_val.strip() config['default_plugin_version'] = "%s.%s" % (rev_date, bzr_revno) actions=[] for arg in sys.argv: if arg.startswith('--top_srcdir='): config['top_srcdir']=arg[12:] elif arg.startswith('--top_builddir='): config['top_builddir']=arg[14:] elif arg == "--force-all": actions=['plugin-list','pandora-plugin.am','write'] break else: actions.append(arg) if len(actions) == 0: actions.append('write') plugin_list=[] def accumulate_plugins(arg, dirname, fnames): # plugin_ini_fname is a name in dirname indicating dirname is a plugin. if config['plugin_ini_fname'] in fnames: arg.append(dirname) os.path.walk(os.path.join(config['top_srcdir'], config['root_plugin_dir']), accumulate_plugins, plugin_list) if not os.path.exists("config/pandora-plugin.am") or "write" in actions: plugin_am_file = ChangeProtectedFile(os.path.join('config', 'pandora-plugin.am')) plugin_am_file.write(""" # always the current list, generated every build so keep this lean. # pandora-plugin.list: datestamp preserved list ${srcdir}/config/pandora-plugin.list: .plugin.scan .plugin.scan: @cd ${top_srcdir} && python config/pandora-plugin plugin-list # Plugins affect configure; so to prevent configure running twice in a tarball # build (once up front, once with the right list of plugins, we ship the # generated list of plugins and the housekeeping material for that list so it # is likewise not updated. EXTRA_DIST += \ config/pandora-plugin.am \ config/pandora-plugin.ac \ config/pandora-plugin \ config/pandora-plugin.ini # Seed the list of plugin LDADDS which plugins may extend. PANDORA_DYNAMIC_LDADDS= # plugin.stamp: graph dominator for creating all per pandora-plugin.ac/am # files. This is invoked when the code to generate such files has altered.""") if not os.path.exists("config/pandora-plugin.ac") or "write" in actions: plugin_ac_file = ChangeProtectedFile(os.path.join('config', 'pandora-plugin.ac')) plugin_ac_file.write("dnl Generated file, run make to rebuild\n") plugin_ac_file.write(""" AC_ARG_WITH([all-static],[ AS_HELP_STRING([--with-all-static],[Link all plugins staticly into the server @<:@default=no@:>@]) ],[ with_all_static="$withval" ],[ with_all_static=no ]) """) if os.path.exists("docs/plugins"): if not os.path.exists("docs/plugins/list.rst") or "write" in actions: plugin_doc_index = ChangeProtectedFile("docs/plugins/list.rst") plugin_doc_index.write(""" Plugin Documentation ==================== .. toctree:: :maxdepth: 2 """) if os.path.exists('plugin.ini'): # Are we in a plugin dir which wants to have a self-sufficient build system? plugin_list=['.'] write_external_plugin() else: plugin_list_file = ChangeProtectedFile(os.path.join('config', 'pandora-plugin.list')) for p in plugin_list: plugin_list_file.write(p) plugin_list_file.write("\n") plugin_list.sort() plugin_list_file.close() if not os.path.exists("config/pandora-plugin.am") or 'write' in actions: plugin_am_file.write("\n${top_srcdir}/config/pandora-plugin.am: ${top_srcdir}/config/pandora-plugin.list ${top_srcdir}/config/pandora-plugin ") for plugin_dir in plugin_list: plugin_am_file.write("\\\n\t%s/plugin.ini " % plugin_dir) plugin_am_file.write("\n\tcd ${top_srcdir} && python config/pandora-plugin write\n") plugin_ini_list=[] # Load all plugin.ini files first so we can do dependency tracking. for plugin_dir in plugin_list: plugin = read_plugin_ini(plugin_dir) expand_plugin_ini(plugin) plugin_ini_list.append(plugin) # Check for duplicates plugin_name_list = [plugin['libname'] for plugin in plugin_ini_list] for plugin in plugin_ini_list: if plugin_name_list.count(plugin['libname']) != 1: print "Duplicate module name %s" % plugin['libname'] exit(1) for plugin in plugin_ini_list: write_plugin(plugin, plugin_ini_list) if plugin_am_file is not None: plugin_am_file.close() if plugin_ac_file is not None: plugin_ac_file.close() if plugin_doc_index is not None: plugin_doc_index.close() libmemcached-1.0.8/config/autorun.sh0000775000076400007640000000430111753573717017716 0ustar00brianbrian00000000000000#!/bin/sh # Copyright (C) 2011 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: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. 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. # 3. The name of the author 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. die() { echo "$@"; exit 1; } run() { echo "$ARGV0: running \`$@' $ARGS" $@ $ARGS } # Try to locate a program by using which, and verify that the file is an # executable locate_binary() { for f in $@ do file=`which $f 2>/dev/null | grep -v '^no '` if test -n "$file" -a -x "$file"; then echo $file return 0 fi done echo "" return 1 } AUTORECONF_FLAGS=" --install --force --verbose -Wall" if test -f config/pre_hook.sh then . config/pre_hook.sh fi if test x$AUTORECONF = x; then AUTORECONF=`locate_binary autoreconf` if test x$AUTORECONF = x; then die "Did not find a supported autoconf" fi fi run $AUTORECONF $AUTORECONF_FLAGS || die "Can't execute autoreconf" libmemcached-1.0.8/config/config.guess0000755000076400007640000012761511753633407020207 0ustar00brianbrian00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 # Free Software Foundation, Inc. timestamp='2009-11-20' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner. Please send patches (context # diff format) to and include a ChangeLog # entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[456]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) case ${UNAME_MACHINE} in pc98) echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-gnu else echo ${UNAME_MACHINE}-unknown-linux-gnueabi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in i386) eval $set_cc_for_build if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then UNAME_PROCESSOR="x86_64" fi fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: libmemcached-1.0.8/config/config.rpath0000775000076400007640000004364711753573717020212 0ustar00brianbrian00000000000000#! /bin/sh # Output a system dependent set of variables, describing how to set the # run time search path of shared libraries in an executable. # # Copyright 1996-2007 Free Software Foundation, Inc. # Taken from GNU libtool, 2001 # Originally by Gordon Matzigkeit , 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # The first argument passed to this file is the canonical host specification, # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld # should be set by the caller. # # The set of defined variables is at the end of this script. # Known limitations: # - On IRIX 6.5 with CC="cc", the run time search patch must not be longer # than 256 bytes, otherwise the compiler driver will dump core. The only # known workaround is to choose shorter directory names for the build # directory and/or the installation directory. # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a shrext=.so host="$1" host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` # Code taken from libtool.m4's _LT_CC_BASENAME. for cc_temp in $CC""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` # Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. wl= if test "$GCC" = yes; then wl='-Wl,' else case "$host_os" in aix*) wl='-Wl,' ;; darwin*) case $cc_basename in xlc*) wl='-Wl,' ;; esac ;; mingw* | cygwin* | pw32* | os2*) ;; hpux9* | hpux10* | hpux11*) wl='-Wl,' ;; irix5* | irix6* | nonstopux*) wl='-Wl,' ;; newsos6) ;; linux* | k*bsd*-gnu) case $cc_basename in icc* | ecc*) wl='-Wl,' ;; pgcc | pgf77 | pgf90) wl='-Wl,' ;; ccc*) wl='-Wl,' ;; como) wl='-lopt=' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) wl='-Wl,' ;; esac ;; esac ;; osf3* | osf4* | osf5*) wl='-Wl,' ;; rdos*) ;; solaris*) wl='-Wl,' ;; sunos4*) wl='-Qoption ld ' ;; sysv4 | sysv4.2uw2* | sysv4.3*) wl='-Wl,' ;; sysv4*MP*) ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) wl='-Wl,' ;; unicos*) wl='-Wl,' ;; uts4*) ;; esac fi # Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_direct=no hardcode_minus_L=no case "$host_os" in cygwin* | mingw* | pw32*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac ld_shlibs=yes if test "$with_gnu_ld" = yes; then # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. # Unlike libtool, we use -rpath here, not --rpath, since the documented # option of GNU ld is called -rpath, not --rpath. hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' case "$host_os" in aix3* | aix4* | aix5*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no fi ;; amigaos*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes # Samuel A. Falvo II reports # that the semantics of dynamic libraries on AmigaOS, at least up # to version 4, is to share data among multiple programs linked # with the same dynamic library. Since this doesn't match the # behavior of shared libraries on other platforms, we cannot use # them. ld_shlibs=no ;; beos*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then : else ld_shlibs=no fi ;; cygwin* | mingw* | pw32*) # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then : else ld_shlibs=no fi ;; interix[3-9]*) hardcode_direct=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; gnu* | linux* | k*bsd*-gnu) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then : else ld_shlibs=no fi ;; netbsd*) ;; solaris*) if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then ld_shlibs=no elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then : else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no ;; *) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' else ld_shlibs=no fi ;; esac ;; sunos4*) hardcode_direct=yes ;; *) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then : else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then hardcode_libdir_flag_spec= fi else case "$host_os" in aix3*) # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix4* | aix5*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix5*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac fi hardcode_direct=yes hardcode_libdir_separator=':' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && \ strings "$collect2name" | grep resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac fi # Begin _LT_AC_SYS_LIBPATH_AIX. echo 'int main () { return 0; }' > conftest.c ${CC} ${LDFLAGS} conftest.c -o conftest aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'` if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'` fi if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib" fi rm -f conftest.c conftest # End _LT_AC_SYS_LIBPATH_AIX. if test "$aix_use_runtimelinking" = yes; then hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' else hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" fi fi ;; amigaos*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes # see comment about different semantics on the GNU ld section ld_shlibs=no ;; bsdi[45]*) ;; cygwin* | mingw* | pw32*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec=' ' libext=lib ;; darwin* | rhapsody*) hardcode_direct=no if test "$GCC" = yes ; then : else case $cc_basename in xlc*) ;; *) ld_shlibs=no ;; esac fi ;; dgux*) hardcode_libdir_flag_spec='-L$libdir' ;; freebsd1*) ld_shlibs=no ;; freebsd2.2*) hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes ;; freebsd2*) hardcode_direct=yes hardcode_minus_L=yes ;; freebsd* | dragonfly*) hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes ;; hpux9*) hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; hpux10*) if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no ;; *) hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; netbsd*) hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes ;; newsos6) hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then hardcode_libdir_flag_spec='${wl}-rpath,$libdir' else case "$host_os" in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) hardcode_libdir_flag_spec='-R$libdir' ;; *) hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; osf3*) hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) if test "$GCC" = yes; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else # Both cc and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi hardcode_libdir_separator=: ;; solaris*) hardcode_libdir_flag_spec='-R$libdir' ;; sunos4*) hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes ;; sysv4) case $host_vendor in sni) hardcode_direct=yes # is this really true??? ;; siemens) hardcode_direct=no ;; motorola) hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac ;; sysv4.3*) ;; sysv4*MP*) if test -d /usr/nec; then ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) ;; sysv5* | sco3.2v5* | sco5v6*) hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' hardcode_libdir_separator=':' ;; uts4*) hardcode_libdir_flag_spec='-L$libdir' ;; *) ld_shlibs=no ;; esac fi # Check dynamic linker characteristics # Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. # Unlike libtool.m4, here we don't care about _all_ names of the library, but # only about the one the linker finds when passed -lNAME. This is the last # element of library_names_spec in libtool.m4, or possibly two of them if the # linker has special search rules. library_names_spec= # the last element of library_names_spec in libtool.m4 libname_spec='lib$name' case "$host_os" in aix3*) library_names_spec='$libname.a' ;; aix4* | aix5*) library_names_spec='$libname$shrext' ;; amigaos*) library_names_spec='$libname.a' ;; beos*) library_names_spec='$libname$shrext' ;; bsdi[45]*) library_names_spec='$libname$shrext' ;; cygwin* | mingw* | pw32*) shrext=.dll library_names_spec='$libname.dll.a $libname.lib' ;; darwin* | rhapsody*) shrext=.dylib library_names_spec='$libname$shrext' ;; dgux*) library_names_spec='$libname$shrext' ;; freebsd1*) ;; freebsd* | dragonfly*) case "$host_os" in freebsd[123]*) library_names_spec='$libname$shrext$versuffix' ;; *) library_names_spec='$libname$shrext' ;; esac ;; gnu*) library_names_spec='$libname$shrext' ;; hpux9* | hpux10* | hpux11*) case $host_cpu in ia64*) shrext=.so ;; hppa*64*) shrext=.sl ;; *) shrext=.sl ;; esac library_names_spec='$libname$shrext' ;; interix[3-9]*) library_names_spec='$libname$shrext' ;; irix5* | irix6* | nonstopux*) library_names_spec='$libname$shrext' case "$host_os" in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; *) libsuff= shlibsuff= ;; esac ;; esac ;; linux*oldld* | linux*aout* | linux*coff*) ;; linux* | k*bsd*-gnu) library_names_spec='$libname$shrext' ;; knetbsd*-gnu) library_names_spec='$libname$shrext' ;; netbsd*) library_names_spec='$libname$shrext' ;; newsos6) library_names_spec='$libname$shrext' ;; nto-qnx*) library_names_spec='$libname$shrext' ;; openbsd*) library_names_spec='$libname$shrext$versuffix' ;; os2*) libname_spec='$name' shrext=.dll library_names_spec='$libname.a' ;; osf3* | osf4* | osf5*) library_names_spec='$libname$shrext' ;; rdos*) ;; solaris*) library_names_spec='$libname$shrext' ;; sunos4*) library_names_spec='$libname$shrext$versuffix' ;; sysv4 | sysv4.3*) library_names_spec='$libname$shrext' ;; sysv4*MP*) library_names_spec='$libname$shrext' ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) library_names_spec='$libname$shrext' ;; uts4*) library_names_spec='$libname$shrext' ;; esac sed_quote_subst='s/\(["`$\\]\)/\\\1/g' escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` shlibext=`echo "$shrext" | sed -e 's,^\.,,'` escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then trap '(exit $?); exit' 1 2 13 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names starting with `-'. case $src in -*) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # Protect names starting with `-'. case $dst in -*) dst=./$dst;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; -*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test -z "$d" && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: libmemcached-1.0.8/config/missing0000755000076400007640000002623311753633407017260 0ustar00brianbrian00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2009-04-28.21; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; tar*) if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then exit 1 fi ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; tar*) shift # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case $firstarg in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case $firstarg in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: libmemcached-1.0.8/config/uncrustify.cfg0000664000076400007640000013560311753573717020570 0ustar00brianbrian00000000000000# # Uncrustify options (with comments) for Pandora Projects # nl_after_brace_close = TRUE # The type of line endings newlines = lf # auto/lf/crlf/cr # The original size of tabs in the input input_tab_size = 8 # number # The size of tabs in the output (only used if align_with_tabs=true) output_tab_size = 3 # number # The ascii value of the string escape char, usually 92 (\) or 94 (^). (Pawn) string_escape_char = 92 # number # Alternate string escape char for Pawn. Only works right before the quote char. string_escape_char2 = 0 # number # # Indenting # # The number of columns to indent per level. # Usually 2, 3, 4, or 8. indent_columns = 2 # number # How to use tabs when indenting code # 0=spaces only # 1=indent with tabs, align with spaces # 2=indent and align with tabs indent_with_tabs = 0 # number # Whether to indent strings broken by '\' so that they line up indent_align_string = true # false/true # The number of spaces to indent multi-line XML strings. # Requires indent_align_string=True indent_xml_string = 0 # number # Spaces to indent '{' from level indent_brace = 0 # number # Whether braces are indented to the body level indent_braces = false # false/true # Disabled indenting function braces if indent_braces is true indent_braces_no_func = false # false/true # Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. indent_brace_parent = false # false/true # Whether the 'namespace' body is indented indent_namespace = false # false/true # Whether the 'extern "C"' body is indented indent_extern = false # false/true # Whether the 'class' body is indented indent_class = true # false/true # Whether to indent the stuff after a leading class colon indent_class_colon = true # false/true # False=treat 'else\nif' as 'else if' for indenting purposes # True=indent the 'if' one level indent_else_if = false # false/true # True: indent continued function call parameters one indent level # False: align parameters under the open paren indent_func_call_param = false # false/true # Same as indent_func_call_param, but for function defs indent_func_def_param = false # false/true # Same as indent_func_call_param, but for function protos indent_func_proto_param = false # false/true # Same as indent_func_call_param, but for class declarations indent_func_class_param = false # false/true # Same as indent_func_call_param, but for class variable constructors indent_func_ctor_var_param = false # false/true # Same as indent_func_call_param, but for templates indent_template_param = false # false/true # Double the indent for indent_func_xxx_param options indent_func_param_double = false # false/true # Indentation column for standalone 'const' function decl/proto qualifier indent_func_const = 0 # number # Indentation column for standalone 'throw' function decl/proto qualifier indent_func_throw = 0 # number # The number of spaces to indent a continued '->' or '.' # Usually set to 0, 1, or indent_columns. indent_member = 3 # number # Spaces to indent single line ('//') comments on lines before code indent_sing_line_comments = 0 # number # If set, will indent trailing single line ('//') comments relative # to the code instead of trying to keep the same absolute column indent_relative_single_line_comments = false # false/true # Spaces to indent 'case' from 'switch' # Usually 0 or indent_columns. indent_switch_case = 0 # number # Spaces to shift the 'case' line, without affecting any other lines # Usually 0. indent_case_shift = 0 # number # Spaces to indent '{' from 'case'. # By default, the brace will appear under the 'c' in case. # Usually set to 0 or indent_columns. indent_case_brace = 0 # number # Whether to indent comments found in first column indent_col1_comment = false # false/true # How to indent goto labels # >0 : absolute column where 1 is the leftmost column # <=0 : subtract from brace indent indent_label = 1 # number # Same as indent_label, but for access specifiers that are followed by a colon indent_access_spec = 1 # number # Indent the code after an access specifier by one level. # If set, this option forces 'indent_access_spec=0' indent_access_spec_body = false # false/true # If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) indent_paren_nl = false # false/true # Controls the indent of a close paren after a newline. # 0: Indent to body level # 1: Align under the open paren # 2: Indent to the brace level indent_paren_close = 0 # number # Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren indent_comma_paren = false # false/true # Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren indent_bool_paren = false # false/true # If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) indent_square_nl = false # false/true # Don't change the relative indent of ESQL/C 'EXEC SQL' bodies indent_preserve_sql = false # false/true # # Spacing options # # Add or remove space around arithmetic operator '+', '-', '/', '*', etc sp_arith = force # ignore/add/remove/force # Add or remove space before assignment operator '=', '+=', etc sp_before_assign = remove # ignore/add/remove/force # Add or remove space after assignment operator '=', '+=', etc sp_after_assign = force # ignore/add/remove/force # Add or remove space around assignment '=' in enum sp_enum_assign = ignore # ignore/add/remove/force # Add or remove space around boolean operators '&&' and '||' sp_bool = force # ignore/add/remove/force # Add or remove space around compare operator '<', '>', '==', etc sp_compare = force # ignore/add/remove/force # Add or remove space inside '(' and ')' sp_inside_paren = remove # ignore/add/remove/force # Add or remove space between nested parens sp_paren_paren = remove # ignore/add/remove/force # Whether to balance spaces inside nested parens sp_balance_nested_parens = false # false/true # Add or remove space between ')' and '{' sp_paren_brace = ignore # ignore/add/remove/force # Add or remove space before pointer star '*' sp_before_ptr_star = force # ignore/add/remove/force # Add or remove space before pointer star '*' that isn't followed by a variable name # If set to 'ignore', sp_before_ptr_star is used instead. sp_before_unnamed_ptr_star = ignore # ignore/add/remove/force # Add or remove space between pointer stars '*' sp_between_ptr_star = remove # ignore/add/remove/force # Add or remove space after pointer star '*', if followed by a word. sp_after_ptr_star = remove # ignore/add/remove/force # Add or remove space after a pointer star '*', if followed by a func proto/def. sp_after_ptr_star_func = ignore # ignore/add/remove/force # Add or remove space before a pointer star '*', if followed by a func proto/def. sp_before_ptr_star_func = ignore # ignore/add/remove/force # Add or remove space before a reference sign '&' sp_before_byref = remove # ignore/add/remove/force # Add or remove space before a reference sign '&' that isn't followed by a variable name # If set to 'ignore', sp_before_byref is used instead. sp_before_unnamed_byref = ignore # ignore/add/remove/force # Add or remove space after reference sign '&', if followed by a word. sp_after_byref = force # ignore/add/remove/force # Add or remove space after a reference sign '&', if followed by a func proto/def. sp_after_byref_func = ignore # ignore/add/remove/force # Add or remove space before a reference sign '&', if followed by a func proto/def. sp_before_byref_func = ignore # ignore/add/remove/force # Add or remove space between type and word sp_after_type = force # ignore/add/remove/force # Add or remove space in 'template <' vs 'template<'. # If set to ignore, sp_before_angle is used. sp_template_angle = ignore # ignore/add/remove/force # Add or remove space before '<>' sp_before_angle = remove # ignore/add/remove/force # Add or remove space inside '<' and '>' sp_inside_angle = remove # ignore/add/remove/force # Add or remove space after '<>' sp_after_angle = force # ignore/add/remove/force # Add or remove space between '<>' and '(' as found in 'new List();' sp_angle_paren = ignore # ignore/add/remove/force # Add or remove space between '<>' and a word as in 'List m;' sp_angle_word = ignore # ignore/add/remove/force # Add or remove space before '(' of 'if', 'for', 'switch', and 'while' sp_before_sparen = force # ignore/add/remove/force # Add or remove space inside if-condition '(' and ')' sp_inside_sparen = remove # ignore/add/remove/force # Add or remove space after ')' of 'if', 'for', 'switch', and 'while' sp_after_sparen = force # ignore/add/remove/force # Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' sp_sparen_brace = add # ignore/add/remove/force # Add or remove space before empty statement ';' on 'if', 'for' and 'while' sp_special_semi = ignore # ignore/add/remove/force # Add or remove space before ';' sp_before_semi = remove # ignore/add/remove/force # Add or remove space before ';' in non-empty 'for' statements sp_before_semi_for = ignore # ignore/add/remove/force # Add or remove space before a semicolon of an empty part of a for statment. sp_before_semi_for_empty = force # ignore/add/remove/force # Add or remove space after the final semicolon of an empty part of a for statment: for ( ; ; ). sp_after_semi_for_empty = ignore # ignore/add/remove/force # Add or remove space before '[' (except '[]') sp_before_square = ignore # ignore/add/remove/force # Add or remove space before '[]' sp_before_squares = ignore # ignore/add/remove/force # Add or remove space inside '[' and ']' sp_inside_square = remove # ignore/add/remove/force # Add or remove space after ',' sp_after_comma = force # ignore/add/remove/force # Add or remove space before ',' sp_before_comma = remove # ignore/add/remove/force # Add or remove space after class ':' sp_after_class_colon = ignore # ignore/add/remove/force # Add or remove space before class ':' sp_before_class_colon = ignore # ignore/add/remove/force # Add or remove space between 'operator' and operator sign sp_after_operator = ignore # ignore/add/remove/force # Add or remove space between the operator symbol and the open paren, as in 'operator ++(' sp_after_operator_sym = ignore # ignore/add/remove/force # Add or remove space after C/D cast, ie 'cast(int)a' vs 'cast(int) a' or '(int)a' vs '(int) a' sp_after_cast = remove # ignore/add/remove/force # Add or remove spaces inside cast parens sp_inside_paren_cast = remove # ignore/add/remove/force # Add or remove space between the type and open paren in a C++ cast, ie 'int(exp)' vs 'int (exp)' sp_cpp_cast_paren = remove # ignore/add/remove/force # Add or remove space between 'sizeof' and '(' sp_sizeof_paren = remove # ignore/add/remove/force # Add or remove space after the tag keyword (Pawn) sp_after_tag = ignore # ignore/add/remove/force # Add or remove space inside enum '{' and '}' sp_inside_braces_enum = force # ignore/add/remove/force # Add or remove space inside struct/union '{' and '}' sp_inside_braces_struct = force # ignore/add/remove/force # Add or remove space inside '{' and '}' sp_inside_braces = force # ignore/add/remove/force # Add or remove space inside '{}' sp_inside_braces_empty = ignore # ignore/add/remove/force # Add or remove space between return type and function name # A minimum of 1 is forced except for pointer return types. sp_type_func = force # ignore/add/remove/force # Add or remove space between function name and '(' on function declaration sp_func_proto_paren = remove # ignore/add/remove/force # Add or remove space between function name and '(' on function definition sp_func_def_paren = remove # ignore/add/remove/force # Add or remove space inside empty function '()' sp_inside_fparens = ignore # ignore/add/remove/force # Add or remove space inside function '(' and ')' sp_inside_fparen = remove # ignore/add/remove/force # Add or remove space between ']' and '(' when part of a function call. sp_square_fparen = ignore # ignore/add/remove/force # Add or remove space between ')' and '{' of function sp_fparen_brace = add # ignore/add/remove/force # Add or remove space between function name and '(' on function calls sp_func_call_paren = remove # ignore/add/remove/force # Add or remove space between the user function name and '(' on function calls # You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. sp_func_call_user_paren = ignore # ignore/add/remove/force # Add or remove space between a constructor/destructor and the open paren sp_func_class_paren = remove # ignore/add/remove/force # Add or remove space between 'return' and '(' sp_return_paren = remove # ignore/add/remove/force # Add or remove space between '__attribute__' and '(' sp_attribute_paren = remove # ignore/add/remove/force # Add or remove space between 'defined' and '(' in '#if defined (FOO)' sp_defined_paren = remove # ignore/add/remove/force # Add or remove space between 'throw' and '(' in 'throw (something)' sp_throw_paren = ignore # ignore/add/remove/force # Add or remove space between macro and value sp_macro = ignore # ignore/add/remove/force # Add or remove space between macro function ')' and value sp_macro_func = ignore # ignore/add/remove/force # Add or remove space between 'else' and '{' if on the same line sp_else_brace = ignore # ignore/add/remove/force # Add or remove space between '}' and 'else' if on the same line sp_brace_else = ignore # ignore/add/remove/force # Add or remove space between '}' and the name of a typedef on the same line sp_brace_typedef = force # ignore/add/remove/force # Add or remove space between 'catch' and '{' if on the same line sp_catch_brace = ignore # ignore/add/remove/force # Add or remove space between '}' and 'catch' if on the same line sp_brace_catch = ignore # ignore/add/remove/force # Add or remove space between 'finally' and '{' if on the same line sp_finally_brace = ignore # ignore/add/remove/force # Add or remove space between '}' and 'finally' if on the same line sp_brace_finally = ignore # ignore/add/remove/force # Add or remove space between 'try' and '{' if on the same line sp_try_brace = ignore # ignore/add/remove/force # Add or remove space between get/set and '{' if on the same line sp_getset_brace = ignore # ignore/add/remove/force # Add or remove space before the '::' operator sp_before_dc = remove # ignore/add/remove/force # Add or remove space after the '::' operator sp_after_dc = remove # ignore/add/remove/force # Add or remove around the D named array initializer ':' operator sp_d_array_colon = ignore # ignore/add/remove/force # Add or remove space after the '!' (not) operator. sp_not = force # ignore/add/remove/force # Add or remove space after the '~' (invert) operator. sp_inv = remove # ignore/add/remove/force # Add or remove space after the '&' (address-of) operator. # This does not affect the spacing after a '&' that is part of a type. sp_addr = remove # ignore/add/remove/force # Add or remove space around the '.' or '->' operators sp_member = remove # ignore/add/remove/force # Add or remove space after the '*' (dereference) operator. # This does not affect the spacing after a '*' that is part of a type. sp_deref = remove # ignore/add/remove/force # Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7' sp_sign = remove # ignore/add/remove/force # Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;' sp_incdec = remove # ignore/add/remove/force # Add or remove space before a backslash-newline at the end of a line sp_before_nl_cont = add # ignore/add/remove/force # Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;' sp_after_oc_scope = ignore # ignore/add/remove/force # Add or remove space after the colon in message specs # '-(int) f:(int) x;' vs '-(int) f: (int) x;' sp_after_oc_colon = ignore # ignore/add/remove/force # Add or remove space before the colon in message specs # '-(int) f: (int) x;' vs '-(int) f : (int) x;' sp_before_oc_colon = ignore # ignore/add/remove/force # Add or remove space after the colon in message specs # '[object setValue:1];' vs '[object setValue: 1];' sp_after_send_oc_colon = ignore # ignore/add/remove/force # Add or remove space before the colon in message specs # '[object setValue:1];' vs '[object setValue :1];' sp_before_send_oc_colon = ignore # ignore/add/remove/force # Add or remove space after the (type) in message specs # '-(int) f: (int) x;' vs '-(int) f: (int)x;' sp_after_oc_type = ignore # ignore/add/remove/force # Add or remove space around the ':' in 'b ? t : f' sp_cond_colon = ignore # ignore/add/remove/force # Add or remove space around the '?' in 'b ? t : f' sp_cond_question = ignore # ignore/add/remove/force # Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make sense here. sp_case_label = remove # ignore/add/remove/force # # Code alignment (not left column spaces/tabs) # # Whether to keep non-indenting tabs align_keep_tabs = false # false/true # Whether to use tabs for alinging align_with_tabs = false # false/true # Whether to bump out to the next tab when aligning align_on_tabstop = false # false/true # Whether to left-align numbers align_number_left = false # false/true # Align variable definitions in prototypes and functions align_func_params = false # false/true # Align parameters in single-line functions that have the same name. # The function names must already be aligned with each other. align_same_func_call_params = false # false/true # The span for aligning variable definitions (0=don't align) align_var_def_span = 1 # number # How to align the star in variable definitions. # 0=Part of the type 'void * foo;' # 1=Part of the variable 'void *foo;' # 2=Dangling 'void *foo;' align_var_def_star_style = 1 # number # How to align the '&' in variable definitions. # 0=Part of the type # 1=Part of the variable # 2=Dangling align_var_def_amp_style = 0 # number # The threshold for aligning variable definitions (0=no limit) align_var_def_thresh = 1 # number # The gap for aligning variable definitions align_var_def_gap = 0 # number # Whether to align the colon in struct bit fields align_var_def_colon = false # false/true # Whether to align inline struct/enum/union variable definitions align_var_def_inline = false # false/true # The span for aligning on '=' in assignments (0=don't align) align_assign_span = 0 # number # The threshold for aligning on '=' in assignments (0=no limit) align_assign_thresh = 12 # number # The span for aligning on '=' in enums (0=don't align) align_enum_equ_span = 0 # number # The threshold for aligning on '=' in enums (0=no limit) align_enum_equ_thresh = 0 # number # The span for aligning struct/union (0=don't align) align_var_struct_span = 0 # number # The threshold for aligning struct/union member definitions (0=no limit) align_var_struct_thresh = 0 # number # The gap for aligning struct/union member definitions align_var_struct_gap = 0 # number # The span for aligning struct initializer values (0=don't align) align_struct_init_span = 3 # number # The minimum space between the type and the synonym of a typedef align_typedef_gap = 3 # number # The span for aligning single-line typedefs (0=don't align) align_typedef_span = 5 # number # How to align typedef'd functions with other typedefs # 0: Don't mix them at all # 1: align the open paren with the types # 2: align the function type name with the other type names align_typedef_func = 0 # number # Controls the positioning of the '*' in typedefs. Just try it. # 0: Align on typdef type, ignore '*' # 1: The '*' is part of type name: typedef int *pint; # 2: The '*' is part of the type, but dangling: typedef int *pint; align_typedef_star_style = 0 # number # Controls the positioning of the '&' in typedefs. Just try it. # 0: Align on typdef type, ignore '&' # 1: The '&' is part of type name: typedef int &pint; # 2: The '&' is part of the type, but dangling: typedef int &pint; align_typedef_amp_style = 0 # number # The span for aligning comments that end lines (0=don't align) align_right_cmt_span = 3 # number # If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment align_right_cmt_mix = false # false/true # If a trailing comment is more than this number of columns away from the text it follows, # it will qualify for being aligned. align_right_cmt_gap = 0 # number # The span for aligning function prototypes (0=don't align) align_func_proto_span = 0 # number # Minimum gap between the return type and the function name. align_func_proto_gap = 0 # number # Whether to mix aligning prototype and variable declarations. # If true, align_var_def_XXX options are used instead of align_func_proto_XXX options. align_mix_var_proto = false # false/true # Align single-line functions with function prototypes, uses align_func_proto_span align_single_line_func = false # false/true # Aligning the open brace of single-line functions. # Requires align_single_line_func=true, uses align_func_proto_span align_single_line_brace = false # false/true # Gap for align_single_line_brace. align_single_line_brace_gap = 0 # number # The span for aligning ObjC msg spec (0=don't align) align_oc_msg_spec_span = 0 # number # Whether to align macros wrapped with a backslash and a newline. # This will not work right if the macro contains a multi-line comment. align_nl_cont = true # false/true # The minimum space between label and value of a preprocessor define align_pp_define_gap = 4 # number # The span for aligning on '#define' bodies (0=don't align) align_pp_define_span = 3 # number # Align lines that start with '<<' with previous '<<'. Default=true align_left_shift = true # false/true # # Newline adding and removing options # # Whether to collapse empty blocks between '{' and '}' nl_collapse_empty_body = true # false/true # Don't split one-line braced assignments - 'foo_t f = { 1, 2 };' nl_assign_leave_one_liners = false # false/true # Don't split one-line braced statements inside a class xx { } body nl_class_leave_one_liners = false # false/true # Don't split one-line enums: 'enum foo { BAR = 15 };' nl_enum_leave_one_liners = false # false/true # Don't split one-line get or set functions nl_getset_leave_one_liners = false # false/true # Don't split one-line function definitions - 'int foo() { return 0; }' nl_func_leave_one_liners = false # false/true # Don't split one-line if/else statements - 'if(a) b++;' nl_if_leave_one_liners = false # false/true # Add or remove newlines at the start of the file nl_start_of_file = remove # ignore/add/remove/force # The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' nl_start_of_file_min = 0 # number # Add or remove newline at the end of the file nl_end_of_file = force # ignore/add/remove/force # The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') nl_end_of_file_min = 1 # number # Add or remove newline between '=' and '{' nl_assign_brace = force # ignore/add/remove/force # Add or remove newline between '=' and '[' (D only) nl_assign_square = force # ignore/add/remove/force # Add or remove newline after '= [' (D only). Will also affect the newline before the ']' nl_after_square_assign = force # ignore/add/remove/force # The number of newlines after a block of variable definitions nl_func_var_def_blk = 1 # number # Add or remove newline between a function call's ')' and '{', as in: # list_for_each(item, &list) { } nl_fcall_brace = force # ignore/add/remove/force # Add or remove newline between 'enum' and '{' nl_enum_brace = force # ignore/add/remove/force # Add or remove newline between 'struct and '{' nl_struct_brace = force # ignore/add/remove/force # Add or remove newline between 'union' and '{' nl_union_brace = force # ignore/add/remove/force # Add or remove newline between 'if' and '{' nl_if_brace = force # ignore/add/remove/force # Add or remove newline between '}' and 'else' nl_brace_else = force # ignore/add/remove/force # Add or remove newline between 'else if' and '{' # If set to ignore, nl_if_brace is used instead nl_elseif_brace = force # ignore/add/remove/force # Add or remove newline between 'else' and '{' nl_else_brace = force # ignore/add/remove/force # Add or remove newline between 'else' and 'if' nl_else_if = remove # ignore/add/remove/force # Add or remove newline between '}' and 'finally' nl_brace_finally = force # ignore/add/remove/force # Add or remove newline between 'finally' and '{' nl_finally_brace = force # ignore/add/remove/force # Add or remove newline between 'try' and '{' nl_try_brace = force # ignore/add/remove/force # Add or remove newline between get/set and '{' nl_getset_brace = force # ignore/add/remove/force # Add or remove newline between 'for' and '{' nl_for_brace = force # ignore/add/remove/force # Add or remove newline between 'catch' and '{' nl_catch_brace = force # ignore/add/remove/force # Add or remove newline between '}' and 'catch' nl_brace_catch = force # ignore/add/remove/force # Add or remove newline between 'while' and '{' nl_while_brace = force # ignore/add/remove/force # Add or remove newline between 'do' and '{' nl_do_brace = force # ignore/add/remove/force # Add or remove newline between '}' and 'while' of 'do' statement nl_brace_while = force # ignore/add/remove/force # Add or remove newline between 'switch' and '{' nl_switch_brace = force # ignore/add/remove/force # Add or remove newline when condition spans two or more lines nl_multi_line_cond = false # false/true # Force a newline in a define after the macro name for multi-line defines. nl_multi_line_define = true # false/true # Whether to put a newline before 'case' statement nl_before_case = true # false/true # Add or remove newline between ')' and 'throw' nl_before_throw = ignore # ignore/add/remove/force # Whether to put a newline after 'case' statement nl_after_case = true # false/true # Newline between namespace and { nl_namespace_brace = add # ignore/add/remove/force # Add or remove newline between 'template<>' and whatever follows. nl_template_class = add # ignore/add/remove/force # Add or remove newline between 'class' and '{' nl_class_brace = add # ignore/add/remove/force # Add or remove newline after each ',' in the constructor member initialization nl_class_init_args = force # ignore/add/remove/force # Add or remove newline between return type and function name in definition nl_func_type_name = ignore # ignore/add/remove/force # Add or remove newline between return type and function name in a prototype nl_func_proto_type_name = remove # ignore/add/remove/force # Add or remove newline between a function name and the opening '(' nl_func_paren = remove # ignore/add/remove/force # Add or remove newline after '(' in a function declaration nl_func_decl_start = remove # ignore/add/remove/force # Add or remove newline after each ',' in a function declaration nl_func_decl_args = remove # ignore/add/remove/force # Add or remove newline before the ')' in a function declaration nl_func_decl_end = remove # ignore/add/remove/force # Add or remove newline between function signature and '{' nl_fdef_brace = add # ignore/add/remove/force # Whether to put a newline after 'return' statement nl_after_return = true # false/true # Add or remove a newline between the return keyword and return expression. nl_return_expr = remove # ignore/add/remove/force # Whether to put a newline after semicolons, except in 'for' statements nl_after_semicolon = true # false/true # Whether to put a newline after brace open. # This also adds a newline before the matching brace close. nl_after_brace_open = true # false/true # If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is # placed between the open brace and a trailing single-line comment. nl_after_brace_open_cmt = false # false/true # Whether to put a newline after a virtual brace open. # These occur in un-braced if/while/do/for statement bodies. nl_after_vbrace_open = true # false/true # Whether to alter newlines in '#define' macros nl_define_macro = true # false/true # Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' nl_squeeze_ifdef = false # false/true # Add or remove newline before 'if' nl_before_if = ignore # ignore/add/remove/force # Add or remove newline after 'if' nl_after_if = ignore # ignore/add/remove/force # Add or remove newline before 'for' nl_before_for = ignore # ignore/add/remove/force # Add or remove newline after 'for' nl_after_for = ignore # ignore/add/remove/force # Add or remove newline before 'while' nl_before_while = ignore # ignore/add/remove/force # Add or remove newline after 'while' nl_after_while = ignore # ignore/add/remove/force # Add or remove newline before 'switch' nl_before_switch = force # ignore/add/remove/force # Add or remove newline after 'switch' nl_after_switch = force # ignore/add/remove/force # Add or remove newline before 'do' nl_before_do = ignore # ignore/add/remove/force # Add or remove newline after 'do' nl_after_do = ignore # ignore/add/remove/force # Whether to double-space commented-entries in struct/enum nl_ds_struct_enum_cmt = false # false/true # Whether to double-space before the close brace of a struct/union/enum nl_ds_struct_enum_close_brace = false # false/true # Add or remove a newline around a class colon. # Related to pos_class_colon, nl_class_init_args, and pos_comma. nl_class_colon = ignore # ignore/add/remove/force # Change simple unbraced if statements into a one-liner # 'if(b)\n i++;' => 'if(b) i++;' nl_create_if_one_liner = false # false/true # Change simple unbraced for statements into a one-liner # 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);' nl_create_for_one_liner = false # false/true # Change simple unbraced while statements into a one-liner # 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);' nl_create_while_one_liner = false # false/true # # Positioning options # # The position of arithmetic operators in wrapped expressions pos_arith = lead # ignore/lead/trail # The position of assignment in wrapped expressions pos_assign = trail # ignore/lead/trail # The position of boolean operators in wrapped expressions pos_bool = lead # ignore/lead/trail # The position of the comma in wrapped expressions pos_comma = trail # ignore/lead/trail # The position of the comma in the constructor initialization list pos_class_comma = trail # ignore/lead/trail # The position of colons between constructor and member initialization pos_class_colon = lead # ignore/lead/trail # # Line Splitting options # # Try to limit code width to N number of columns code_width = 76 # number # Whether to fully split long 'for' statements at semi-colons ls_for_split_full = true # false/true # Whether to fully split long function protos/calls at commas ls_func_split_full = true # false/true # # Blank line options # # The maximum consecutive newlines nl_max = 4 # number # The number of newlines after a function prototype, if followed by another function prototype nl_after_func_proto = 0 # number # The number of newlines after a function prototype, if not followed by another function prototype nl_after_func_proto_group = 3 # number # The number of newlines after '}' of a multi-line function body nl_after_func_body = 3 # number # The number of newlines after '}' of a single line function body nl_after_func_body_one_liner = 1 # number # The minimum number of newlines before a multi-line comment. # Doesn't apply if after a brace open or another multi-line comment. nl_before_block_comment = 2 # number # The minimum number of newlines before a single-line C comment. # Doesn't apply if after a brace open or other single-line C comments. nl_before_c_comment = 1 # number # The minimum number of newlines before a CPP comment. # Doesn't apply if after a brace open or other CPP comments. nl_before_cpp_comment = 0 # number # Whether to force a newline after a mulit-line comment. nl_after_multiline_comment = false # false/true # The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. # Will not change the newline count if after a brace open. # 0 = No change. nl_before_access_spec = 1 # number # The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. # 0 = No change. nl_after_access_spec = 1 # number # The number of newlines between a function def and the function comment. # 0 = No change. nl_comment_func_def = 0 # number # Whether to remove blank lines after '{' eat_blanks_after_open_brace = true # false/true # Whether to remove blank lines before '}' eat_blanks_before_close_brace = true # false/true # # Code modifying options (non-whitespace) # # Add or remove braces on single-line 'do' statement mod_full_brace_do = add # ignore/add/remove/force # Add or remove braces on single-line 'for' statement mod_full_brace_for = add # ignore/add/remove/force # Add or remove braces on single-line function defintions. (Pawn) mod_full_brace_function = ignore # ignore/add/remove/force # Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'. mod_full_brace_if = ignore # ignore/add/remove/force # Don't remove braces around statements that span N newlines mod_full_brace_nl = 0 # number # Add or remove braces on single-line 'while' statement mod_full_brace_while = add # ignore/add/remove/force # Add or remove unnecessary paren on 'return' statement mod_paren_on_return = remove # ignore/add/remove/force # Whether to change optional semicolons to real semicolons mod_pawn_semicolon = false # false/true # Add parens on 'while' and 'if' statement around bools mod_full_paren_if_bool = true # false/true # Whether to remove superfluous semicolons mod_remove_extra_semicolon = true # false/true # If a function body exceeds the specified number of newlines and doesn't have a comment after # the close brace, a comment will be added. mod_add_long_function_closebrace_comment = 5 # number # If a switch body exceeds the specified number of newlines and doesn't have a comment after # the close brace, a comment will be added. mod_add_long_switch_closebrace_comment = 5 # number # If TRUE, will sort consecutive single-line 'import' statements [Java, D] mod_sort_import = false # false/true # If TRUE, will sort consecutive single-line 'using' statements [C#] mod_sort_using = false # false/true # If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] # This is generally a bad idea, as it may break your code. mod_sort_include = false # false/true # If TRUE, it will move a 'break' that appears after a fully braced 'case' before the close brace. mod_move_case_break = false # false/true # If TRUE, it will remove a void 'return;' that appears as the last statement in a function. mod_remove_empty_return = true # false/true # # Comment modifications # # Try to wrap comments at cmt_width columns cmt_width = 0 # number # If false, disable all multi-line comment changes, including cmt_width and leading chars. # Default is true. cmt_indent_multi = true # false/true # Whether to group c-comments that look like they are in a block cmt_c_group = false # false/true # Whether to put an empty '/*' on the first line of the combined c-comment cmt_c_nl_start = false # false/true # Whether to put a newline before the closing '*/' of the combined c-comment cmt_c_nl_end = false # false/true # Whether to group cpp-comments that look like they are in a block cmt_cpp_group = false # false/true # Whether to put an empty '/*' on the first line of the combined cpp-comment cmt_cpp_nl_start = false # false/true # Whether to put a newline before the closing '*/' of the combined cpp-comment cmt_cpp_nl_end = false # false/true # Whether to change cpp-comments into c-comments cmt_cpp_to_c = false # false/true # Whether to put a star on subsequent comment lines cmt_star_cont = true # false/true # The number of spaces to insert at the start of subsequent comment lines cmt_sp_before_star_cont = 0 # number # The number of spaces to insert after the star on subsequent comment lines cmt_sp_after_star_cont = 1 # number # For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of # the comment are the same length. Default=True cmt_multi_check_last = true # false/true # The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. # Will substitue $(filename) with the current file's name. cmt_insert_file_header = "" # string # The filename that contains text to insert before a function implementation if the function isn't preceeded with a C/C++ comment. # Will substitue $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. # Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... } cmt_insert_func_header = "" # string # The filename that contains text to insert before a class if the class isn't preceeded with a C/C++ comment. # Will substitue $(class) with the class name. cmt_insert_class_header = "" # string # If a preprocessor is encountered when stepping backwards from a function name, then # this option decides whether the comment should be inserted. # Affects cmt_insert_func_header and cmt_insert_class_header. cmt_insert_before_preproc = false # false/true # # Preprocessor options # # Control indent of preprocessors inside #if blocks at brace level 0 pp_indent = remove # ignore/add/remove/force # Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false) pp_indent_at_level = false # false/true # If pp_indent_at_level=false, specifies the number of columns to indent per level. Default=1. pp_indent_count = 1 # number # Add or remove space after # based on pp_level of #if blocks pp_space = add # ignore/add/remove/force # Sets the number of spaces added with pp_space pp_space_count = 1 # number # The indent for #region and #endregion in C# and '#pragma region' in C/C++ pp_indent_region = 0 # number # Whether to indent the code between #region and #endregion pp_region_indent_code = false # false/true # If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level pp_indent_if = 0 # number # Control whether to indent the code between #if, #else and #endif when not at file-level pp_if_indent_code = false # false/true # Whether to indent '#define' at the brace level (true) or from column 1 (false) pp_define_at_level = false # false/true # You can force a token to be a type with the 'type' option. # Example: # type myfoo1 myfoo2 # # You can create custom macro-based indentation using macro-open, # macro-else and macro-close. # Example: # macro-open BEGIN_TEMPLATE_MESSAGE_MAP # macro-open BEGIN_MESSAGE_MAP # macro-close END_MESSAGE_MAP # # You can assign any keyword to any type with the set option. # set func_call_user _ N_ libmemcached-1.0.8/config/ltmain.sh0000755000076400007640000105021611753633364017505 0ustar00brianbrian00000000000000 # libtool (GNU libtool) 2.4 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --config show all configuration variables # --debug enable verbose shell tracing # -n, --dry-run display commands without modifying any files # --features display basic configuration information and exit # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed help message # # MODE must be one of the following: # # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program # finish complete the installation of libtool libraries # install install libraries or executables # link create a library or an executable # uninstall remove libraries from an installed directory # # MODE-ARGS vary depending on the MODE. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.4 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . # GNU libtool home page: . # General help using GNU software: . PROGRAM=libtool PACKAGE=libtool VERSION=2.4 TIMESTAMP="" package_revision=1.3293 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${EGREP="/bin/grep -E"} : ${FGREP="/bin/grep -F"} : ${GREP="/bin/grep"} : ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SED="/bin/sed"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_dirname may be replaced by extended shell implementation # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_basename may be replaced by extended shell implementation # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname may be replaced by extended shell implementation # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=: for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # Sed substitution that converts a w32 file name or path # which contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname: ${opt_mode+$opt_mode: }$*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "$my_tmpdir" } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "$1" | $SED \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_tr_sh # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_version # Echo version message to standard output and exit. func_version () { $opt_debug $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $opt_debug $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $opt_debug $SED -n '/^# Usage:/,/# Report bugs to/ { :print s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ p d } /^# .* home page:/b print /^# General help using/b print ' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $opt_debug func_error "missing argument for $1." exit_cmd=exit } # func_split_short_opt shortopt # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. func_split_short_opt () { my_sed_short_opt='1s/^\(..\).*$/\1/;q' my_sed_short_rest='1s/^..\(.*\)$/\1/;q' func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` } # func_split_short_opt may be replaced by extended shell implementation # func_split_long_opt longopt # Set func_split_long_opt_name and func_split_long_opt_arg shell # variables after splitting LONGOPT at the `=' sign. func_split_long_opt () { my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` } # func_split_long_opt may be replaced by extended shell implementation exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. nonopt= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "${1}=\$${1}\${2}" } # func_append may be replaced by extended shell implementation # func_append_quoted var value # Quote VALUE and append to the end of shell variable VAR, separated # by a space. func_append_quoted () { func_quote_for_eval "${2}" eval "${1}=\$${1}\\ \$func_quote_for_eval_result" } # func_append_quoted may be replaced by extended shell implementation # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "${@}"` } # func_arith may be replaced by extended shell implementation # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` } # func_len may be replaced by extended shell implementation # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_lo2o may be replaced by extended shell implementation # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_features () { echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Option defaults: opt_debug=: opt_dry_run=false opt_config=false opt_preserve_dup_deps=false opt_features=false opt_finish=false opt_help=false opt_help_all=false opt_silent=: opt_verbose=: opt_silent=false opt_verbose=false # Parse options once, thoroughly. This comes as soon as possible in the # script to make things like `--version' happen as quickly as we can. { # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" $opt_debug ;; --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) opt_config=: func_config ;; --dlopen|-dlopen) optarg="$1" opt_dlopen="${opt_dlopen+$opt_dlopen }$optarg" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) opt_features=: func_features ;; --finish) opt_finish=: set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help_all=: opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_mode="$optarg" case $optarg in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_silent=false func_append preserve_args " $opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" ;; --silent|--quiet) opt_silent=: func_append preserve_args " $opt" opt_verbose=false ;; --verbose|-v) opt_verbose=: func_append preserve_args " $opt" opt_silent=false ;; --tag) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_tag="$optarg" func_append preserve_args " $opt $optarg" func_enable_tag "$optarg" shift ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; # Separate optargs to long options: --*=*) func_split_long_opt "$opt" set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-n*|-v*) func_split_short_opt "$opt" set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done # Validate options: # save first non-option argument if test "$#" -gt 0; then nonopt="$opt" shift fi # preserve --debug test "$opt_debug" = : || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test "$opt_mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$opt_mode' for more information." } # Bail if the options were screwed $exit_cmd $EXIT_FAILURE } ## ----------- ## ## Main. ## ## ----------- ## # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case "$lt_sysroot:$1" in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$lt_sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $opt_debug # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result="" if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result" ; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $opt_debug if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $opt_debug # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $opt_debug if test -z "$2" && test -n "$1" ; then func_error "Could not determine host file name corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result="$1" fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $opt_debug if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " \`$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result="$3" fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $opt_debug case $4 in $1 ) func_to_host_path_result="$3$func_to_host_path_result" ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via `$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $opt_debug $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $opt_debug case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result="$1" } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result="$func_convert_core_msys_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via `$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $opt_debug if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd="func_convert_path_${func_stripname_result}" fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $opt_debug func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result="$1" } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_msys_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_mode_compile arg... func_mode_compile () { $opt_debug # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify \`-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" func_append_quoted lastarg "$arg" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with \`-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj="$func_basename_result" } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from \`$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode \`$opt_mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "\`$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument \`$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and \`=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test "$opt_mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$opt_mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename="" if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname" ; then func_basename "$dlprefile_dlname" dlprefile_dlbasename="$func_basename_result" else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename" ; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $opt_debug sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $opt_debug match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive which possess that section. Heuristic: eliminate # all those which have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $opt_debug if func_cygming_gnu_implib_p "$1" ; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1" ; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result="" fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -e 's/\([\\"]\)/\\\1/g' \ -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir="$arg" prev= continue ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-flto*|-fwhopr*|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps ; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." else echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test "$prefer_static_libs" = yes || test "$prefer_static_libs,$installed" = "built,no"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib="$l" done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$lt_sysroot$libdir" absdir="$lt_sysroot$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later func_append notinst_path " $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi case "$host" in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test "$installed" = no; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then echo if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$opt_mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$dir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$opt_mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs="$temp_deplibs" fi func_append newlib_search_path " $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|qnx|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. func_append verstring ":${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" func_append libobjs " $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$opt_mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$opt_mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" if test -n "$hardcode_libdir_flag_spec_ld"; then eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" else eval dep_rpath=\"$hardcode_libdir_flag_spec\" fi fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd1 in $cmds; do IFS="$save_ifs" # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test "$try_normal_branch" = yes \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=${output_objdir}/${output_la}.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " ${wl}-bind_at_load" func_append finalize_command " ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$opt_mode" = link || test "$opt_mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) func_append RM " $arg"; rmforce=yes ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then odir="$objdir" else odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" test "$opt_mode" = uninstall && odir="$dir" # Remember odir for removal later, being careful to avoid duplicates if test "$opt_mode" = clean; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case "$opt_mode" in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test "$opt_mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 libmemcached-1.0.8/config/depcomp0000755000076400007640000004426711753633410017237 0ustar00brianbrian00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2009-04-28.21; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free # Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputing dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u="sed s,\\\\\\\\,/,g" depmode=msvisualcpp fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: libmemcached-1.0.8/support/0000775000076400007640000000000011757025120016113 5ustar00brianbrian00000000000000libmemcached-1.0.8/support/libmemcached-fc.spec.in0000664000076400007640000000501411753573717022377 0ustar00brianbrian00000000000000Name: libmemcached Summary: memcached C library and command line tools Version: @VERSION@ Release: 1%{?dist} License: BSD Group: System Environment/Libraries URL: http://libmemcached.org/ Source0: http://download.tangent.org/libmemcached-%{version}.tar.gz # For test suite BuildRequires: memcached BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %description libmemcached, http://libmemcached.org/, is a C client library to the memcached server (http://danga.com/memcached). It has been designed to be light on memory usage, and provide full access to server side methods. It also implements several command line tools: memcat - Copy the value of a key to standard output. memflush - Flush the contents of your servers. memrm - Remove a key(s) from the serrver. memstat - Dump the stats of your servers to standard output. memslap - Generate testing loads on a memcached cluster. memcp - Copy files to memcached servers. memerror - Creates human readable messages from libmemecached error codes. %package devel Summary: Header files and development libraries for %{name} Group: Development/Libraries Requires: %{name} = %{version}-%{release} %description devel This package contains the header files and development libraries for %{name}. If you like to develop programs using %{name}, you will need to install %{name}-devel. %prep %setup -q %{__mkdir} examples %{__cp} tests/*.{c,cc,cpp,h} examples/ %build %configure %{__make} %install %{__rm} -rf %{buildroot} %{__make} install DESTDIR="%{buildroot}" AM_INSTALL_PROGRAM_FLAGS="" %check # test suite cannot run in mock (same port use for memcache server on all arch) # 1 test seems to fail.. #%{__make} test %clean %{__rm} -rf %{buildroot} %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %files %defattr (-,root,root,-) %doc AUTHORS COPYING NEWS README THANKS TODO %{_bindir}/mem* %exclude %{_libdir}/libmemcached.a %exclude %{_libdir}/libmemcached.la %exclude %{_libdir}/libmemcachedutil.a %exclude %{_libdir}/libmemcachedutil.la %{_libdir}/libmemcached.so.* %{_libdir}/libmemcachedutil.so.* %{_mandir}/man1/mem* %files devel %defattr (-,root,root,-) %doc examples %{_includedir}/libmemcached %{_libdir}/libmemcached.so %{_libdir}/libmemcachedutil.so %{_libdir}/pkgconfig/libmemcached.pc %{_mandir}/man3/libmemcached*.3.gz %{_mandir}/man3/memcached_*.3.gz %changelog * Sat Apr 25 2009 Remi Collet - 0.28-1 - Initial RPM from Brian Aker spec - create -devel subpackage - add %%post %%postun %%check section libmemcached-1.0.8/support/include.am0000664000076400007640000000046011753573717020075 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root EXTRA_DIST+= \ support/libmemcached.spec \ support/libmemcached-fc.spec.in \ support/set_benchmark.sh pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = support/libmemcached.pc libmemcached-1.0.8/support/libmemcached.pc.in0000664000076400007640000000040511753573717021460 0ustar00brianbrian00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: libmemcached URL: http://libmemcachd.org/ Description: libmemcached C/C++ library. Version: @VERSION@ Libs: -L${libdir} -lmemcached -lmemcachedutil Cflags: -I${includedir} libmemcached-1.0.8/support/libmemcached.spec.in0000664000076400007640000002661311757024540022006 0ustar00brianbrian00000000000000Name: libmemcached Summary: memcached C library and command line tools Version: @VERSION@ Release: 1 License: BSD Group: System Environment/Libraries URL: http://launchpad.net/libmemcached Source0: http://download.tangent.org/libmemcached-%{version}.tar.gz # For test suite BuildRequires: memcached BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %description libmemcached, http://libmemcached.org/, is a C client library to the memcached server (http://danga.com/memcached). It has been designed to be light on memory usage, and provide full access to server side methods. It also implements several command line tools: memcat - Copy the value of a key to standard output. memflush - Flush the contents of your servers. memrm - Remove a key(s) from the serrver. memstat - Dump the stats of your servers to standard output. memslap - Generate testing loads on a memcached cluster. memcp - Copy files to memcached servers. memerror - Creates human readable messages from libmemecached error codes. memcapable - Verify a memcached server for protocol behavior. memexist - Check for the existance of a key. memtouch - Update the expiration value of a key. %package devel Summary: Header files and development libraries for %{name} Group: Development/Libraries Requires: %{name} = %{version}-%{release} %description devel This package contains the header files and development libraries for %{name}. If you like to develop programs using %{name}, you will need to install %{name}-devel. %prep %setup -q %{__mkdir} examples %build %configure %{__make} %install %{__rm} -rf %{buildroot} %{__make} install DESTDIR="%{buildroot}" AM_INSTALL_PROGRAM_FLAGS="" %check # test suite cannot run in mock (same port use for memcache server on all arch) # 1 test seems to fail.. # %{__make} test %clean %{__rm} -rf %{buildroot} %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %files %defattr (-,root,root,-) %doc AUTHORS COPYING NEWS README THANKS TODO %{_bindir}/mem* %exclude %{_libdir}/libmemcached.la %exclude %{_libdir}/libhashkit.la %exclude %{_libdir}/libmemcachedutil.la %exclude %{_libdir}/libmemcachedprotocol.la %exclude %{_libdir}/libmemcached.a %exclude %{_libdir}/libhashkit.a %exclude %{_libdir}/libmemcachedutil.a %exclude %{_libdir}/libmemcachedprotocol.a %{_libdir}/libhashkit.so.2.0.0 %{_libdir}/libmemcached.so.10.0.0 %{_libdir}/libmemcachedutil.so.2.0.0 %{_libdir}/libmemcachedprotocol.so.0.0.0 %{_libdir}/libhashkit.so.2 %{_libdir}/libmemcached.so.10 %{_libdir}/libmemcachedprotocol.so.0 %{_libdir}/libmemcachedutil.so.2 %{_mandir}/man1/memaslap.1.gz %{_mandir}/man1/memcapable.1.gz %{_mandir}/man1/memcat.1.gz %{_mandir}/man1/memcp.1.gz %{_mandir}/man1/memdump.1.gz %{_mandir}/man1/memerror.1.gz %{_mandir}/man1/memexist.1.gz %{_mandir}/man1/memflush.1.gz %{_mandir}/man1/memparse.1.gz %{_mandir}/man1/memping.1.gz %{_mandir}/man1/memrm.1.gz %{_mandir}/man1/memslap.1.gz %{_mandir}/man1/memstat.1.gz %{_mandir}/man1/memtouch.1.gz %files devel %defattr (-,root,root,-) %doc examples %{_includedir}/libhashkit/hashkit.h %{_includedir}/libhashkit-1.0/algorithm.h %{_includedir}/libhashkit-1.0/behavior.h %{_includedir}/libhashkit-1.0/configure.h %{_includedir}/libhashkit-1.0/digest.h %{_includedir}/libhashkit-1.0/function.h %{_includedir}/libhashkit-1.0/has.h %{_includedir}/libhashkit-1.0/hashkit.h %{_includedir}/libhashkit-1.0/hashkit.hpp %{_includedir}/libhashkit-1.0/str_algorithm.h %{_includedir}/libhashkit-1.0/strerror.h %{_includedir}/libhashkit-1.0/types.h %{_includedir}/libhashkit-1.0/visibility.h %{_includedir}/libmemcachedprotocol-0.0/binary.h %{_includedir}/libmemcachedprotocol-0.0/callback.h %{_includedir}/libmemcachedprotocol-0.0/handler.h %{_includedir}/libmemcachedprotocol-0.0/vbucket.h %{_includedir}/libmemcachedutil-1.0/util.h %{_includedir}/libmemcachedutil-1.0/flush.h %{_includedir}/libmemcachedutil-1.0/pid.h %{_includedir}/libmemcachedutil-1.0/ping.h %{_includedir}/libmemcachedutil-1.0/ostream.hpp %{_includedir}/libmemcachedutil-1.0/pool.h %{_includedir}/libmemcachedutil-1.0/version.h %{_includedir}/libmemcached/memcached.h %{_includedir}/libmemcached/memcached.hpp %{_includedir}/libmemcached/util.h %{_includedir}/libmemcached-1.0/alloc.h %{_includedir}/libmemcached-1.0/allocators.h %{_includedir}/libmemcached-1.0/analyze.h %{_includedir}/libmemcached-1.0/auto.h %{_includedir}/libmemcached-1.0/basic_string.h %{_includedir}/libmemcached-1.0/behavior.h %{_includedir}/libmemcached-1.0/callback.h %{_includedir}/libmemcached-1.0/callbacks.h %{_includedir}/libmemcached-1.0/configure.h %{_includedir}/libmemcached-1.0/defaults.h %{_includedir}/libmemcached-1.0/delete.h %{_includedir}/libmemcached-1.0/deprecated_types.h %{_includedir}/libmemcached-1.0/dump.h %{_includedir}/libmemcached-1.0/error.h %{_includedir}/libmemcached-1.0/exception.hpp %{_includedir}/libmemcached-1.0/exist.h %{_includedir}/libmemcached-1.0/fetch.h %{_includedir}/libmemcached-1.0/flush.h %{_includedir}/libmemcached-1.0/flush_buffers.h %{_includedir}/libmemcached-1.0/get.h %{_includedir}/libmemcached-1.0/hash.h %{_includedir}/libmemcached-1.0/limits.h %{_includedir}/libmemcached-1.0/memcached.h %{_includedir}/libmemcached-1.0/memcached.hpp %{_includedir}/libmemcached-1.0/options.h %{_includedir}/libmemcached-1.0/parse.h %{_includedir}/libmemcached-1.0/platform.h %{_includedir}/libmemcached-1.0/quit.h %{_includedir}/libmemcached-1.0/result.h %{_includedir}/libmemcached-1.0/return.h %{_includedir}/libmemcached-1.0/sasl.h %{_includedir}/libmemcached-1.0/server.h %{_includedir}/libmemcached-1.0/server_list.h %{_includedir}/libmemcached-1.0/stats.h %{_includedir}/libmemcached-1.0/storage.h %{_includedir}/libmemcached-1.0/strerror.h %{_includedir}/libmemcached-1.0/struct/allocator.h %{_includedir}/libmemcached-1.0/struct/analysis.h %{_includedir}/libmemcached-1.0/struct/callback.h %{_includedir}/libmemcached-1.0/struct/memcached.h %{_includedir}/libmemcached-1.0/struct/result.h %{_includedir}/libmemcached-1.0/struct/sasl.h %{_includedir}/libmemcached-1.0/struct/server.h %{_includedir}/libmemcached-1.0/struct/stat.h %{_includedir}/libmemcached-1.0/struct/string.h %{_includedir}/libmemcached-1.0/touch.h %{_includedir}/libmemcached-1.0/triggers.h %{_includedir}/libmemcached-1.0/types.h %{_includedir}/libmemcached-1.0/types/behavior.h %{_includedir}/libmemcached-1.0/types/callback.h %{_includedir}/libmemcached-1.0/types/connection.h %{_includedir}/libmemcached-1.0/types/hash.h %{_includedir}/libmemcached-1.0/types/return.h %{_includedir}/libmemcached-1.0/types/server_distribution.h %{_includedir}/libmemcached-1.0/verbosity.h %{_includedir}/libmemcached-1.0/version.h %{_includedir}/libmemcached-1.0/visibility.h %{_includedir}/libhashkit-1.0/string.h %{_includedir}/libmemcached-1.0/encoding_key.h %{_libdir}/libhashkit.so %{_libdir}/libmemcached.so %{_libdir}/libmemcachedprotocol.so %{_libdir}/libmemcachedutil.so %{_libdir}/pkgconfig/libmemcached.pc %{_mandir}/man3/hashkit_clone.3.gz %{_mandir}/man3/hashkit_crc32.3.gz %{_mandir}/man3/hashkit_create.3.gz %{_mandir}/man3/hashkit_fnv1_32.3.gz %{_mandir}/man3/hashkit_fnv1_64.3.gz %{_mandir}/man3/hashkit_fnv1a_32.3.gz %{_mandir}/man3/hashkit_fnv1a_64.3.gz %{_mandir}/man3/hashkit_free.3.gz %{_mandir}/man3/hashkit_functions.3.gz %{_mandir}/man3/hashkit_hsieh.3.gz %{_mandir}/man3/hashkit_is_allocated.3.gz %{_mandir}/man3/hashkit_jenkins.3.gz %{_mandir}/man3/hashkit_md5.3.gz %{_mandir}/man3/hashkit_murmur.3.gz %{_mandir}/man3/hashkit_value.3.gz %{_mandir}/man3/libhashkit.3.gz %{_mandir}/man3/libmemcached.3.gz %{_mandir}/man3/libmemcached_check_configuration.3.gz %{_mandir}/man3/libmemcached_configuration.3.gz %{_mandir}/man3/libmemcached_examples.3.gz %{_mandir}/man3/libmemcachedutil.3.gz %{_mandir}/man3/memcached.3.gz %{_mandir}/man3/memcached_add.3.gz %{_mandir}/man3/memcached_add_by_key.3.gz %{_mandir}/man3/memcached_analyze.3.gz %{_mandir}/man3/memcached_append.3.gz %{_mandir}/man3/memcached_append_by_key.3.gz %{_mandir}/man3/memcached_behavior_get.3.gz %{_mandir}/man3/memcached_behavior_set.3.gz %{_mandir}/man3/memcached_callback_get.3.gz %{_mandir}/man3/memcached_callback_set.3.gz %{_mandir}/man3/memcached_cas.3.gz %{_mandir}/man3/memcached_cas_by_key.3.gz %{_mandir}/man3/memcached_clone.3.gz %{_mandir}/man3/memcached_create.3.gz %{_mandir}/man3/memcached_decrement.3.gz %{_mandir}/man3/memcached_decrement_with_initial.3.gz %{_mandir}/man3/memcached_delete.3.gz %{_mandir}/man3/memcached_delete_by_key.3.gz %{_mandir}/man3/memcached_destroy_sasl_auth_data.3.gz %{_mandir}/man3/memcached_dump.3.gz %{_mandir}/man3/memcached_fetch.3.gz %{_mandir}/man3/memcached_fetch_execute.3.gz %{_mandir}/man3/memcached_fetch_result.3.gz %{_mandir}/man3/memcached_flush_buffers.3.gz %{_mandir}/man3/memcached_free.3.gz %{_mandir}/man3/memcached_generate_hash.3.gz %{_mandir}/man3/memcached_generate_hash_value.3.gz %{_mandir}/man3/memcached_get.3.gz %{_mandir}/man3/memcached_get_by_key.3.gz %{_mandir}/man3/memcached_get_memory_allocators.3.gz %{_mandir}/man3/memcached_get_sasl_callbacks.3.gz %{_mandir}/man3/memcached_get_user_data.3.gz %{_mandir}/man3/memcached_increment.3.gz %{_mandir}/man3/memcached_increment_with_initial.3.gz %{_mandir}/man3/memcached_lib_version.3.gz %{_mandir}/man3/memcached_mget.3.gz %{_mandir}/man3/memcached_mget_by_key.3.gz %{_mandir}/man3/memcached_mget_execute.3.gz %{_mandir}/man3/memcached_mget_execute_by_key.3.gz %{_mandir}/man3/memcached_pool_behavior_get.3.gz %{_mandir}/man3/memcached_pool_behavior_set.3.gz %{_mandir}/man3/memcached_pool_create.3.gz %{_mandir}/man3/memcached_pool_destroy.3.gz %{_mandir}/man3/memcached_pool_pop.3.gz %{_mandir}/man3/memcached_pool_push.3.gz %{_mandir}/man3/memcached_pool_fetch.3.gz %{_mandir}/man3/memcached_pool_release.3.gz %{_mandir}/man3/memcached_pool_st.3.gz %{_mandir}/man3/memcached_pool.3.gz %{_mandir}/man3/memcached_prepend.3.gz %{_mandir}/man3/memcached_prepend_by_key.3.gz %{_mandir}/man3/memcached_quit.3.gz %{_mandir}/man3/memcached_replace.3.gz %{_mandir}/man3/memcached_replace_by_key.3.gz %{_mandir}/man3/memcached_sasl_set_auth_data.3.gz %{_mandir}/man3/memcached_server_add.3.gz %{_mandir}/man3/memcached_server_count.3.gz %{_mandir}/man3/memcached_server_cursor.3.gz %{_mandir}/man3/memcached_server_list.3.gz %{_mandir}/man3/memcached_server_list_append.3.gz %{_mandir}/man3/memcached_server_list_count.3.gz %{_mandir}/man3/memcached_server_list_free.3.gz %{_mandir}/man3/memcached_server_push.3.gz %{_mandir}/man3/memcached_servers_parse.3.gz %{_mandir}/man3/memcached_set.3.gz %{_mandir}/man3/memcached_set_by_key.3.gz %{_mandir}/man3/memcached_set_memory_allocators.3.gz %{_mandir}/man3/memcached_set_sasl_callbacks.3.gz %{_mandir}/man3/memcached_set_user_data.3.gz %{_mandir}/man3/memcached_stat.3.gz %{_mandir}/man3/memcached_stat_execute.3.gz %{_mandir}/man3/memcached_stat_get_keys.3.gz %{_mandir}/man3/memcached_last_error_message.3.gz %{_mandir}/man3/memcached_stat_get_value.3.gz %{_mandir}/man3/memcached_stat_servername.3.gz %{_mandir}/man3/memcached_strerror.3.gz %{_mandir}/man3/memcached_exist.3.gz %{_mandir}/man3/memcached_exist_by_key.3.gz %{_mandir}/man3/memcached_touch.3.gz %{_mandir}/man3/memcached_touch_by_key.3.gz %{_mandir}/man3/memcached_verbosity.3.gz %{_mandir}/man3/memcached_version.3.gz %changelog * Tue May 22 2012 Brian Aker - 1.0.8 * Fri Jan 8 2010 Brian Aker - 0.37 - Modified to be explicit in install include files. * Sat Apr 25 2009 Remi Collet - 0.28 - Initial RPM from Brian Aker spec - create -devel subpackage - add %%post %%postun %%check section libmemcached-1.0.8/support/set_benchmark.sh0000775000076400007640000000050411753573717021276 0ustar00brianbrian00000000000000#!/bin/bash src/memslap --concurrency=5 --execute-number=5000 --servers=localhost --test=set --flush src/memslap --concurrency=5 --execute-number=5000 --non-blocking --servers=localhost --test=set --flush src/memslap --concurrency=5 --execute-number=5000 --non-blocking --tcp-nodelay --servers=localhost --test=set --flush libmemcached-1.0.8/support/libmemcached.spec0000664000076400007640000002660711757025116021404 0ustar00brianbrian00000000000000Name: libmemcached Summary: memcached C library and command line tools Version: 1.0.8 Release: 1 License: BSD Group: System Environment/Libraries URL: http://launchpad.net/libmemcached Source0: http://download.tangent.org/libmemcached-%{version}.tar.gz # For test suite BuildRequires: memcached BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %description libmemcached, http://libmemcached.org/, is a C client library to the memcached server (http://danga.com/memcached). It has been designed to be light on memory usage, and provide full access to server side methods. It also implements several command line tools: memcat - Copy the value of a key to standard output. memflush - Flush the contents of your servers. memrm - Remove a key(s) from the serrver. memstat - Dump the stats of your servers to standard output. memslap - Generate testing loads on a memcached cluster. memcp - Copy files to memcached servers. memerror - Creates human readable messages from libmemecached error codes. memcapable - Verify a memcached server for protocol behavior. memexist - Check for the existance of a key. memtouch - Update the expiration value of a key. %package devel Summary: Header files and development libraries for %{name} Group: Development/Libraries Requires: %{name} = %{version}-%{release} %description devel This package contains the header files and development libraries for %{name}. If you like to develop programs using %{name}, you will need to install %{name}-devel. %prep %setup -q %{__mkdir} examples %build %configure %{__make} %install %{__rm} -rf %{buildroot} %{__make} install DESTDIR="%{buildroot}" AM_INSTALL_PROGRAM_FLAGS="" %check # test suite cannot run in mock (same port use for memcache server on all arch) # 1 test seems to fail.. # %{__make} test %clean %{__rm} -rf %{buildroot} %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %files %defattr (-,root,root,-) %doc AUTHORS COPYING NEWS README THANKS TODO %{_bindir}/mem* %exclude %{_libdir}/libmemcached.la %exclude %{_libdir}/libhashkit.la %exclude %{_libdir}/libmemcachedutil.la %exclude %{_libdir}/libmemcachedprotocol.la %exclude %{_libdir}/libmemcached.a %exclude %{_libdir}/libhashkit.a %exclude %{_libdir}/libmemcachedutil.a %exclude %{_libdir}/libmemcachedprotocol.a %{_libdir}/libhashkit.so.2.0.0 %{_libdir}/libmemcached.so.10.0.0 %{_libdir}/libmemcachedutil.so.2.0.0 %{_libdir}/libmemcachedprotocol.so.0.0.0 %{_libdir}/libhashkit.so.2 %{_libdir}/libmemcached.so.10 %{_libdir}/libmemcachedprotocol.so.0 %{_libdir}/libmemcachedutil.so.2 %{_mandir}/man1/memaslap.1.gz %{_mandir}/man1/memcapable.1.gz %{_mandir}/man1/memcat.1.gz %{_mandir}/man1/memcp.1.gz %{_mandir}/man1/memdump.1.gz %{_mandir}/man1/memerror.1.gz %{_mandir}/man1/memexist.1.gz %{_mandir}/man1/memflush.1.gz %{_mandir}/man1/memparse.1.gz %{_mandir}/man1/memping.1.gz %{_mandir}/man1/memrm.1.gz %{_mandir}/man1/memslap.1.gz %{_mandir}/man1/memstat.1.gz %{_mandir}/man1/memtouch.1.gz %files devel %defattr (-,root,root,-) %doc examples %{_includedir}/libhashkit/hashkit.h %{_includedir}/libhashkit-1.0/algorithm.h %{_includedir}/libhashkit-1.0/behavior.h %{_includedir}/libhashkit-1.0/configure.h %{_includedir}/libhashkit-1.0/digest.h %{_includedir}/libhashkit-1.0/function.h %{_includedir}/libhashkit-1.0/has.h %{_includedir}/libhashkit-1.0/hashkit.h %{_includedir}/libhashkit-1.0/hashkit.hpp %{_includedir}/libhashkit-1.0/str_algorithm.h %{_includedir}/libhashkit-1.0/strerror.h %{_includedir}/libhashkit-1.0/types.h %{_includedir}/libhashkit-1.0/visibility.h %{_includedir}/libmemcachedprotocol-0.0/binary.h %{_includedir}/libmemcachedprotocol-0.0/callback.h %{_includedir}/libmemcachedprotocol-0.0/handler.h %{_includedir}/libmemcachedprotocol-0.0/vbucket.h %{_includedir}/libmemcachedutil-1.0/util.h %{_includedir}/libmemcachedutil-1.0/flush.h %{_includedir}/libmemcachedutil-1.0/pid.h %{_includedir}/libmemcachedutil-1.0/ping.h %{_includedir}/libmemcachedutil-1.0/ostream.hpp %{_includedir}/libmemcachedutil-1.0/pool.h %{_includedir}/libmemcachedutil-1.0/version.h %{_includedir}/libmemcached/memcached.h %{_includedir}/libmemcached/memcached.hpp %{_includedir}/libmemcached/util.h %{_includedir}/libmemcached-1.0/alloc.h %{_includedir}/libmemcached-1.0/allocators.h %{_includedir}/libmemcached-1.0/analyze.h %{_includedir}/libmemcached-1.0/auto.h %{_includedir}/libmemcached-1.0/basic_string.h %{_includedir}/libmemcached-1.0/behavior.h %{_includedir}/libmemcached-1.0/callback.h %{_includedir}/libmemcached-1.0/callbacks.h %{_includedir}/libmemcached-1.0/configure.h %{_includedir}/libmemcached-1.0/defaults.h %{_includedir}/libmemcached-1.0/delete.h %{_includedir}/libmemcached-1.0/deprecated_types.h %{_includedir}/libmemcached-1.0/dump.h %{_includedir}/libmemcached-1.0/error.h %{_includedir}/libmemcached-1.0/exception.hpp %{_includedir}/libmemcached-1.0/exist.h %{_includedir}/libmemcached-1.0/fetch.h %{_includedir}/libmemcached-1.0/flush.h %{_includedir}/libmemcached-1.0/flush_buffers.h %{_includedir}/libmemcached-1.0/get.h %{_includedir}/libmemcached-1.0/hash.h %{_includedir}/libmemcached-1.0/limits.h %{_includedir}/libmemcached-1.0/memcached.h %{_includedir}/libmemcached-1.0/memcached.hpp %{_includedir}/libmemcached-1.0/options.h %{_includedir}/libmemcached-1.0/parse.h %{_includedir}/libmemcached-1.0/platform.h %{_includedir}/libmemcached-1.0/quit.h %{_includedir}/libmemcached-1.0/result.h %{_includedir}/libmemcached-1.0/return.h %{_includedir}/libmemcached-1.0/sasl.h %{_includedir}/libmemcached-1.0/server.h %{_includedir}/libmemcached-1.0/server_list.h %{_includedir}/libmemcached-1.0/stats.h %{_includedir}/libmemcached-1.0/storage.h %{_includedir}/libmemcached-1.0/strerror.h %{_includedir}/libmemcached-1.0/struct/allocator.h %{_includedir}/libmemcached-1.0/struct/analysis.h %{_includedir}/libmemcached-1.0/struct/callback.h %{_includedir}/libmemcached-1.0/struct/memcached.h %{_includedir}/libmemcached-1.0/struct/result.h %{_includedir}/libmemcached-1.0/struct/sasl.h %{_includedir}/libmemcached-1.0/struct/server.h %{_includedir}/libmemcached-1.0/struct/stat.h %{_includedir}/libmemcached-1.0/struct/string.h %{_includedir}/libmemcached-1.0/touch.h %{_includedir}/libmemcached-1.0/triggers.h %{_includedir}/libmemcached-1.0/types.h %{_includedir}/libmemcached-1.0/types/behavior.h %{_includedir}/libmemcached-1.0/types/callback.h %{_includedir}/libmemcached-1.0/types/connection.h %{_includedir}/libmemcached-1.0/types/hash.h %{_includedir}/libmemcached-1.0/types/return.h %{_includedir}/libmemcached-1.0/types/server_distribution.h %{_includedir}/libmemcached-1.0/verbosity.h %{_includedir}/libmemcached-1.0/version.h %{_includedir}/libmemcached-1.0/visibility.h %{_includedir}/libhashkit-1.0/string.h %{_includedir}/libmemcached-1.0/encoding_key.h %{_libdir}/libhashkit.so %{_libdir}/libmemcached.so %{_libdir}/libmemcachedprotocol.so %{_libdir}/libmemcachedutil.so %{_libdir}/pkgconfig/libmemcached.pc %{_mandir}/man3/hashkit_clone.3.gz %{_mandir}/man3/hashkit_crc32.3.gz %{_mandir}/man3/hashkit_create.3.gz %{_mandir}/man3/hashkit_fnv1_32.3.gz %{_mandir}/man3/hashkit_fnv1_64.3.gz %{_mandir}/man3/hashkit_fnv1a_32.3.gz %{_mandir}/man3/hashkit_fnv1a_64.3.gz %{_mandir}/man3/hashkit_free.3.gz %{_mandir}/man3/hashkit_functions.3.gz %{_mandir}/man3/hashkit_hsieh.3.gz %{_mandir}/man3/hashkit_is_allocated.3.gz %{_mandir}/man3/hashkit_jenkins.3.gz %{_mandir}/man3/hashkit_md5.3.gz %{_mandir}/man3/hashkit_murmur.3.gz %{_mandir}/man3/hashkit_value.3.gz %{_mandir}/man3/libhashkit.3.gz %{_mandir}/man3/libmemcached.3.gz %{_mandir}/man3/libmemcached_check_configuration.3.gz %{_mandir}/man3/libmemcached_configuration.3.gz %{_mandir}/man3/libmemcached_examples.3.gz %{_mandir}/man3/libmemcachedutil.3.gz %{_mandir}/man3/memcached.3.gz %{_mandir}/man3/memcached_add.3.gz %{_mandir}/man3/memcached_add_by_key.3.gz %{_mandir}/man3/memcached_analyze.3.gz %{_mandir}/man3/memcached_append.3.gz %{_mandir}/man3/memcached_append_by_key.3.gz %{_mandir}/man3/memcached_behavior_get.3.gz %{_mandir}/man3/memcached_behavior_set.3.gz %{_mandir}/man3/memcached_callback_get.3.gz %{_mandir}/man3/memcached_callback_set.3.gz %{_mandir}/man3/memcached_cas.3.gz %{_mandir}/man3/memcached_cas_by_key.3.gz %{_mandir}/man3/memcached_clone.3.gz %{_mandir}/man3/memcached_create.3.gz %{_mandir}/man3/memcached_decrement.3.gz %{_mandir}/man3/memcached_decrement_with_initial.3.gz %{_mandir}/man3/memcached_delete.3.gz %{_mandir}/man3/memcached_delete_by_key.3.gz %{_mandir}/man3/memcached_destroy_sasl_auth_data.3.gz %{_mandir}/man3/memcached_dump.3.gz %{_mandir}/man3/memcached_fetch.3.gz %{_mandir}/man3/memcached_fetch_execute.3.gz %{_mandir}/man3/memcached_fetch_result.3.gz %{_mandir}/man3/memcached_flush_buffers.3.gz %{_mandir}/man3/memcached_free.3.gz %{_mandir}/man3/memcached_generate_hash.3.gz %{_mandir}/man3/memcached_generate_hash_value.3.gz %{_mandir}/man3/memcached_get.3.gz %{_mandir}/man3/memcached_get_by_key.3.gz %{_mandir}/man3/memcached_get_memory_allocators.3.gz %{_mandir}/man3/memcached_get_sasl_callbacks.3.gz %{_mandir}/man3/memcached_get_user_data.3.gz %{_mandir}/man3/memcached_increment.3.gz %{_mandir}/man3/memcached_increment_with_initial.3.gz %{_mandir}/man3/memcached_lib_version.3.gz %{_mandir}/man3/memcached_mget.3.gz %{_mandir}/man3/memcached_mget_by_key.3.gz %{_mandir}/man3/memcached_mget_execute.3.gz %{_mandir}/man3/memcached_mget_execute_by_key.3.gz %{_mandir}/man3/memcached_pool_behavior_get.3.gz %{_mandir}/man3/memcached_pool_behavior_set.3.gz %{_mandir}/man3/memcached_pool_create.3.gz %{_mandir}/man3/memcached_pool_destroy.3.gz %{_mandir}/man3/memcached_pool_pop.3.gz %{_mandir}/man3/memcached_pool_push.3.gz %{_mandir}/man3/memcached_pool_fetch.3.gz %{_mandir}/man3/memcached_pool_release.3.gz %{_mandir}/man3/memcached_pool_st.3.gz %{_mandir}/man3/memcached_pool.3.gz %{_mandir}/man3/memcached_prepend.3.gz %{_mandir}/man3/memcached_prepend_by_key.3.gz %{_mandir}/man3/memcached_quit.3.gz %{_mandir}/man3/memcached_replace.3.gz %{_mandir}/man3/memcached_replace_by_key.3.gz %{_mandir}/man3/memcached_sasl_set_auth_data.3.gz %{_mandir}/man3/memcached_server_add.3.gz %{_mandir}/man3/memcached_server_count.3.gz %{_mandir}/man3/memcached_server_cursor.3.gz %{_mandir}/man3/memcached_server_list.3.gz %{_mandir}/man3/memcached_server_list_append.3.gz %{_mandir}/man3/memcached_server_list_count.3.gz %{_mandir}/man3/memcached_server_list_free.3.gz %{_mandir}/man3/memcached_server_push.3.gz %{_mandir}/man3/memcached_servers_parse.3.gz %{_mandir}/man3/memcached_set.3.gz %{_mandir}/man3/memcached_set_by_key.3.gz %{_mandir}/man3/memcached_set_memory_allocators.3.gz %{_mandir}/man3/memcached_set_sasl_callbacks.3.gz %{_mandir}/man3/memcached_set_user_data.3.gz %{_mandir}/man3/memcached_stat.3.gz %{_mandir}/man3/memcached_stat_execute.3.gz %{_mandir}/man3/memcached_stat_get_keys.3.gz %{_mandir}/man3/memcached_last_error_message.3.gz %{_mandir}/man3/memcached_stat_get_value.3.gz %{_mandir}/man3/memcached_stat_servername.3.gz %{_mandir}/man3/memcached_strerror.3.gz %{_mandir}/man3/memcached_exist.3.gz %{_mandir}/man3/memcached_exist_by_key.3.gz %{_mandir}/man3/memcached_touch.3.gz %{_mandir}/man3/memcached_touch_by_key.3.gz %{_mandir}/man3/memcached_verbosity.3.gz %{_mandir}/man3/memcached_version.3.gz %changelog * Tue May 22 2012 Brian Aker - 1.0.8 * Fri Jan 8 2010 Brian Aker - 0.37 - Modified to be explicit in install include files. * Sat Apr 25 2009 Remi Collet - 0.28 - Initial RPM from Brian Aker spec - create -devel subpackage - add %%post %%postun %%check section libmemcached-1.0.8/README.FIRST0000664000076400007640000000162411753573717016170 0ustar00brianbrian00000000000000Hi! If you are getting this code from http://launchpad.net/libmemcached then continue reading. Otherwise these directions are not for you (well maybe...). To obtain code from http://bazaar.launchpad.net/libmemcached you will need to issue the following command: bzr branch lp:libmemcached Once the tree is cloned you will need to build the "configure" script. You can do this by running the script: ./config/autorun.sh It will set up all of the files you need to build libmemcached. At that point it is just the typical "./configure; make; make test; make install" For a tarball release do a "make dist" and for an RPM type "make rpm". For patches, we prefer you push a branch to launchpad and then submit that branch to be merged. For more information, see: https://help.launchpad.net/Code/UploadingABranch https://help.launchpad.net/Code/Review Thanks and keep hacking! Cheers, -Brian Seattle, WA. libmemcached-1.0.8/configure0000775000076400007640000277404011756761710016337 0ustar00brianbrian00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.68 for libmemcached 1.0.8. # # Report bugs to . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: http://libmemcached.org/ about your system, including $0: any error possibly output before this message. Then $0: install a modern shell, or manually run the script $0: under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libmemcached' PACKAGE_TARNAME='libmemcached' PACKAGE_VERSION='1.0.8' PACKAGE_STRING='libmemcached 1.0.8' PACKAGE_BUGREPORT='http://libmemcached.org/' PACKAGE_URL='' ac_unique_file="libmemcached/memcached.cc" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_header_list= ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS HAVE_LIBEVENT_FALSE HAVE_LIBEVENT_TRUE LIBEVENT_LDFLAGS LIBEVENT_CPPFLAGS BUILD_WIN32_WRAPPERS_FALSE BUILD_WIN32_WRAPPERS_TRUE BUILD_POLL_FALSE BUILD_POLL_TRUE RT_LIB LIBUUID_LDFLAGS LIBUUID_CPPFLAGS LIBMEMCACHED_WITH_SASL_SUPPORT HAVE_SASL_FALSE HAVE_SASL_TRUE LIBSASL_LDFLAGS LIBSASL_CPPFLAGS LIBOBJS ALLOCA BUILD_CACHE_FALSE BUILD_CACHE_TRUE DEPRECATED BUILD_MEMASLAP_FALSE BUILD_MEMASLAP_TRUE INCLUDE_MURMUR_SRC_FALSE INCLUDE_MURMUR_SRC_TRUE INCLUDE_HSIEH_SRC_FALSE INCLUDE_HSIEH_SRC_TRUE BUILD_BYTEORDER_FALSE BUILD_BYTEORDER_TRUE PTHREAD_CFLAGS PTHREAD_LIBS PTHREAD_CC ax_pthread_config BUILDING_GEARMAN_FALSE BUILDING_GEARMAN_TRUE HAVE_LIBDRIZZLE_FALSE HAVE_LIBDRIZZLE_TRUE HAVE_LIBMEMCACHED_FALSE HAVE_LIBMEMCACHED_TRUE BUILDING_LIBMEMCACHED_FALSE BUILDING_LIBMEMCACHED_TRUE HAVE_LIBGEARMAN_FALSE HAVE_LIBGEARMAN_TRUE LIBGEARMAN_LDFLAGS LIBGEARMAN_CPPFLAGS GEARMAND_BINARY MEMCACHED_SASL_BINARY MEMCACHED_BINARY HAVE_VISIBILITY CFLAG_VISIBILITY CXXCPP OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB ac_ct_AR AR DLLTOOL OBJDUMP LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP SED LIBTOOL HASHKIT_LIBRARY_VERSION MEMCACHED_LIBRARY_VERSION MEMCACHED_PROTOCAL_LIBRARY_VERSION MEMCACHED_UTIL_LIBRARY_VERSION LEX YACC AM_LDFLAGS AM_CPPFLAGS AM_CXXFLAGS AM_CFLAGS HAVE_RECENT_SPHINX_FALSE HAVE_RECENT_SPHINX_TRUE HAVE_SPHINX_FALSE HAVE_SPHINX_TRUE HAVE_DPKG_GENSYMBOLS_FALSE HAVE_DPKG_GENSYMBOLS_TRUE SPHINXBUILD LCOV_GENHTML LCOV DPKG_GENSYMBOLS PERL BETTER_MALLOC_LIBS DTRACE_NEEDS_OBJECTS_FALSE DTRACE_NEEDS_OBJECTS_TRUE HAVE_DTRACE_FALSE HAVE_DTRACE_TRUE DTRACEFLAGS DTRACE INTLTOOL_WARNINGS SPHINX_WARNINGS GCOV_LIBS NO_WERROR PERMISSIVE_C_WARNINGS PERMISSIVE_WARNINGS BOOSTSKIP_WARNINGS INNOBASE_SKIP_WARNINGS PROTOSKIP_WARNINGS NO_OLD_STYLE_CAST NO_EFF_CXX NO_STRICT_ALIASING NO_SHADOW NO_UNREACHED NO_REDUNDANT_DECLS NO_CONVERSION LIBC_P CXX_VERSION CC_VERSION PANDORA_OPTIMIZE_BITFIELD TARGET_LINUX_FALSE TARGET_LINUX_TRUE TARGET_OSX_FALSE TARGET_OSX_TRUE BUILD_WIN32_FALSE BUILD_WIN32_TRUE TARGET_WINDOWS TARGET_FREEBSD TARGET_SOLARIS TARGET_OSX TARGET_LINUX am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE ac_ct_CXX CXXFLAGS CXX PANDORA_HEX_VERSION PANDORA_RELEASE_ID PANDORA_RELEASE_VERSION PANDORA_RELEASE_COMMENT ISAINFO EGREP GREP CPP am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC AM_BACKSLASH AM_DEFAULT_VERBOSITY am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_os target_vendor target_cpu target host_os host_vendor host_cpu host build_os build_vendor build_cpu build target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_dependency_tracking enable_64bit enable_largefile with_debug enable_assert enable_gcc_profile_mode enable_profiling enable_coverage enable_dtrace with_lib_prefix enable_umem enable_tcmalloc enable_mtmalloc enable_shared enable_static with_pic enable_fast_install with_gnu_ld with_sysroot enable_libtool_lock with_memcached with_memcached_sasl with_gearmand enable_hsieh_hash enable_murmur_hash enable_fnv64_hash enable_memaslap enable_deprecated ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP CXX CXXFLAGS CCC CXXCPP MEMCACHED_BINARY MEMCACHED_SASL_BINARY GEARMAND_BINARY LIBGEARMAN_CPPFLAGS LIBGEARMAN_LDFLAGS LIBSASL_CPPFLAGS LIBSASL_LDFLAGS LIBUUID_CPPFLAGS LIBUUID_LDFLAGS LIBEVENT_CPPFLAGS LIBEVENT_LDFLAGS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures libmemcached 1.0.8 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/libmemcached] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] --target=TARGET configure for building compilers for TARGET [HOST] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of libmemcached 1.0.8:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: `make V=1') --disable-silent-rules verbose build output (undo: `make V=0') --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --disable-64bit Build 64 bit binary [default=on] --disable-largefile omit support for large files --disable-assert Turn off assertions --enable-gcc-profile-mode Toggle gcc profile mode [default=off] --enable-profiling Toggle profiling [default=off] --enable-coverage Toggle coverage [default=off] --enable-dtrace Build with support for the DTRACE. [default=no] --enable-umem Enable linking with libumem [default=off] --enable-tcmalloc Enable linking with tcmalloc [default=off] --disable-mtmalloc Enable linking with mtmalloc [default=on] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --enable-hsieh_hash build with support for hsieh hashing. [default=off] --disable-murmur_hash build with support for murmur hashing. [default=on] --disable-fnv64_hash build with support for fnv64 hashing. [default=on] --enable-memaslap build with memaslap tool. [default=off] --enable-deprecated Enable deprecated interface [default=off] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-debug Add debug code/turns off optimizations (yes|no) [default=no] --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib --without-lib-prefix don't search for libraries in includedir and libdir --with-pic try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR (or the compiler's sysroot if not specified). --with-memcached=[PATH] absolute path to memcached executable --with-memcached_sasl=[PATH] absolute path to memcached_sasl executable --with-gearmand=[PATH] absolute path to gearmand executable Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor CXX C++ compiler command CXXFLAGS C++ compiler flags CXXCPP C++ preprocessor MEMCACHED_BINARY Absolute path to memcached executable MEMCACHED_SASL_BINARY Absolute path to memcached_sasl executable GEARMAND_BINARY Absolute path to gearmand executable LIBGEARMAN_CPPFLAGS C preprocessor flags for LIBGEARMAN headers LIBGEARMAN_LDFLAGS linker flags for LIBGEARMAN libraries LIBSASL_CPPFLAGS C preprocessor flags for LIBSASL headers LIBSASL_LDFLAGS linker flags for LIBSASL libraries LIBUUID_CPPFLAGS C preprocessor flags for LIBUUID headers LIBUUID_LDFLAGS linker flags for LIBUUID libraries LIBEVENT_CPPFLAGS C preprocessor flags for LIBEVENT headers LIBEVENT_LDFLAGS linker flags for LIBEVENT libraries Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF libmemcached configure 1.0.8 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## --------------------------------------- ## ## Report this to http://libmemcached.org/ ## ## --------------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES # --------------------------------------------- # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR # accordingly. ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 $as_echo_n "checking whether $as_decl_name is declared... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { #ifndef $as_decl_name #ifdef __cplusplus (void) $as_decl_use; #else (void) $as_decl_name; #endif #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes # INCLUDES, setting VAR accordingly. Returns whether the value could be # computed ac_fn_c_compute_int () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=0 ac_mid=0 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid; break else as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=-1 ac_mid=-1 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=$ac_mid; break else as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid else as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; '') ac_retval=1 ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 static long int longval () { return $2; } static unsigned long int ulongval () { return $2; } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu", i); } /* Do not output a trailing newline, as this causes \r\n confusion on some platforms. */ return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : echo >>conftest.val; read $3 &5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_cxx_try_cpp LINENO # ------------------------ # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp # ac_fn_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_link # ac_fn_cxx_try_run LINENO # ------------------------ # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_cxx_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_run # ac_fn_cxx_check_func LINENO FUNC VAR # ------------------------------------ # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_cxx_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_func # ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_cxx_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## --------------------------------------- ## ## Report this to http://libmemcached.org/ ## ## --------------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_mongrel # ac_fn_cxx_check_type LINENO TYPE VAR INCLUDES # --------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_cxx_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_type # ac_fn_cxx_check_decl LINENO SYMBOL VAR INCLUDES # ----------------------------------------------- # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR # accordingly. ac_fn_cxx_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 $as_echo_n "checking whether $as_decl_name is declared... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { #ifndef $as_decl_name #ifdef __cplusplus (void) $as_decl_use; #else (void) $as_decl_name; #endif #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_decl # ac_fn_c_find_intX_t LINENO BITS VAR # ----------------------------------- # Finds a signed integer type with width BITS, setting cache variable VAR # accordingly. ac_fn_c_find_intX_t () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5 $as_echo_n "checking for int$2_t... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" # Order is important - never check a type that is potentially smaller # than half of the expected target width. for ac_type in int$2_t 'int' 'long int' \ 'long long int' 'short int' 'signed char'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default enum { N = $2 / 2 - 1 }; int main () { static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default enum { N = $2 / 2 - 1 }; int main () { static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1) < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else case $ac_type in #( int$2_t) : eval "$3=yes" ;; #( *) : eval "$3=\$ac_type" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if eval test \"x\$"$3"\" = x"no"; then : else break fi done fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_find_intX_t # ac_fn_c_find_uintX_t LINENO BITS VAR # ------------------------------------ # Finds an unsigned integer type with width BITS, setting cache variable VAR # accordingly. ac_fn_c_find_uintX_t () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 $as_echo_n "checking for uint$2_t... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" # Order is important - never check a type that is potentially smaller # than half of the expected target width. for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ 'unsigned long long int' 'unsigned short int' 'unsigned char'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : case $ac_type in #( uint$2_t) : eval "$3=yes" ;; #( *) : eval "$3=\$ac_type" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if eval test \"x\$"$3"\" = x"no"; then : else break fi done fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_find_uintX_t # ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_cxx_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_compile cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by libmemcached $as_me 1.0.8, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi as_fn_append ac_header_list " winsock2.h" as_fn_append ac_header_list " poll.h" as_fn_append ac_header_list " sys/wait.h" as_fn_append ac_header_list " fnmatch.h" # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in config "$srcdir"/config; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in config \"$srcdir\"/config" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } if ${ac_cv_target+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then ac_cv_target=$ac_cv_host else ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; *) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' set x $ac_cv_target shift target_cpu=$1 target_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: target_os=$* IFS=$ac_save_IFS case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac # The aliases save the names the user supplied, while $host etc. # will get canonicalized. test -n "$target_alias" && test "$program_prefix$program_suffix$program_transform_name" = \ NONENONEs,x,x, && program_prefix=${target_alias}- am__api_version='1.11' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='libmemcached' VERSION='1.0.8' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. AMTAR=${AMTAR-"${am_missing_run}tar"} am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' ac_config_headers="$ac_config_headers config.h:config.in" DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" if test "x$ac_cv_header_minix_config_h" = xyes; then : MINIX=yes else MINIX= fi if test "$MINIX" = yes; then $as_echo "#define _POSIX_SOURCE 1" >>confdefs.h $as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h $as_echo "#define _MINIX 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 $as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } if ${ac_cv_safe_to_define___extensions__+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # define __EXTENSIONS__ 1 $ac_includes_default int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_safe_to_define___extensions__=yes else ac_cv_safe_to_define___extensions__=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 $as_echo "$ac_cv_safe_to_define___extensions__" >&6; } test $ac_cv_safe_to_define___extensions__ = yes && $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h $as_echo "#define _ALL_SOURCE 1" >>confdefs.h $as_echo "#define _GNU_SOURCE 1" >>confdefs.h $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h # Check whether --enable-64bit was given. if test "${enable_64bit+set}" = set; then : enableval=$enable_64bit; ac_enable_64bit="$enableval" else ac_enable_64bit="yes" fi for ac_prog in isainfo do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ISAINFO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ISAINFO"; then ac_cv_prog_ISAINFO="$ISAINFO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ISAINFO="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ISAINFO=$ac_cv_prog_ISAINFO if test -n "$ISAINFO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ISAINFO" >&5 $as_echo "$ISAINFO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ISAINFO" && break done test -n "$ISAINFO" || ISAINFO="no" if test "x$ISAINFO" != "xno"; then : isainfo_b=`${ISAINFO} -b` else isainfo_b="x" fi if test "$isainfo_b" != "x" -a "$isainfo_b" != "32"; then : isainfo_k=`${ISAINFO} -k` DTRACEFLAGS="${DTRACEFLAGS} -${isainfo_b}" if test "x$ac_enable_64bit" = "xyes"; then : if test "x${ac_cv_env_LDFLAGS_set}" = "x"; then : LDFLAGS="-L/usr/local/lib/${isainfo_k} ${LDFLAGS}" fi if test "x$libdir" = "x\${exec_prefix}/lib"; then : libdir="${libdir}/${isainfo_k}" fi if test "x${ac_cv_env_CFLAGS_set}" = "x"; then : CFLAGS="${CFLAGS} -m64" ac_cv_env_CFLAGS_set=set ac_cv_env_CFLAGS_value='-m64' fi if test "x${ac_cv_env_CXXFLAGS_set}" = "x"; then : CXXFLAGS="${CXXFLAGS} -m64" ac_cv_env_CXXFLAGS_set=set ac_cv_env_CXXFLAGS_value='-m64' fi if test "$target_cpu" = "sparc" -a "x$SUNCC" = "xyes"; then : AM_CFLAGS="-xmemalign=8s ${AM_CFLAGS}" AM_CXXFLAGS="-xmemalign=8s ${AM_CXXFLAGS}" fi fi fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CXX_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CXX_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi if test "x$CC" != xcc; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5 $as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5 $as_echo_n "checking whether cc understands -c and -o together... " >&6; } fi set dummy $CC; ac_cc=`$as_echo "$2" | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # We do the test twice because some compilers refuse to overwrite an # existing .o file with -o, though they will create one. ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then eval ac_cv_prog_cc_${ac_cc}_c_o=yes if test "x$CC" != xcc; then # Test first that cc exists at all. if { ac_try='cc -c conftest.$ac_ext >&5' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # cc works too. : else # cc exists but doesn't like -o. eval ac_cv_prog_cc_${ac_cc}_c_o=no fi fi fi else eval ac_cv_prog_cc_${ac_cc}_c_o=no fi rm -f core conftest* fi if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h fi acl_libdirstem=lib acl_libdirstem2= case "$host_os" in solaris*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit host" >&5 $as_echo_n "checking for 64-bit host... " >&6; } if ${gl_cv_solaris_64bit+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef _LP64 sixtyfour bits #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "sixtyfour bits" >/dev/null 2>&1; then : gl_cv_solaris_64bit=yes else gl_cv_solaris_64bit=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_solaris_64bit" >&5 $as_echo "$gl_cv_solaris_64bit" >&6; } if test $gl_cv_solaris_64bit = yes; then acl_libdirstem=lib/64 case "$host_cpu" in sparc*) acl_libdirstem2=lib/sparcv9 ;; i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; esac fi ;; *) searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` if test -n "$searchpath"; then acl_save_IFS="${IFS= }"; IFS=":" for searchdir in $searchpath; do if test -d "$searchdir"; then case "$searchdir" in */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; */../ | */.. ) # Better ignore directories of this form. They are misleading. ;; *) searchdir=`cd "$searchdir" && pwd` case "$searchdir" in */lib64 ) acl_libdirstem=lib64 ;; esac ;; esac fi done IFS="$acl_save_IFS" fi ;; esac test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" if test "X$prefix" = "XNONE"; then acl_final_prefix="$ac_default_prefix" else acl_final_prefix="$prefix" fi if test "X$exec_prefix" = "XNONE"; then acl_final_exec_prefix='${prefix}' else acl_final_exec_prefix="$exec_prefix" fi acl_save_prefix="$prefix" prefix="$acl_final_prefix" eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" prefix="$acl_save_prefix" if test "x${prefix}" = "x"; then : as_fn_error $? "--prefix requires an argument" "$LINENO" 5 fi # We need to prevent canonical target # from injecting -O2 into CFLAGS - but we won't modify anything if we have # set CFLAGS on the command line, since that should take ultimate precedence if test "x${ac_cv_env_CFLAGS_set}" = "x"; then : CFLAGS="" fi if test "x${ac_cv_env_CXXFLAGS_set}" = "x"; then : CXXFLAGS="" fi if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='libmemcached' VERSION='1.0.8' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. AMTAR=${AMTAR-"${am_missing_run}tar"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to create a ustar tar archive" >&5 $as_echo_n "checking how to create a ustar tar archive... " >&6; } # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar plaintar pax cpio none' _am_tools=${am_cv_prog_tar_ustar-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do { echo "$as_me:$LINENO: $_am_tar --version" >&5 ($_am_tar --version) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && break done am__tar="$_am_tar --format=ustar -chf - "'"$$tardir"' am__tar_="$_am_tar --format=ustar -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x ustar -w "$$tardir"' am__tar_='pax -L -x ustar -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H ustar -L' am__tar_='find "$tardir" -print | cpio -o -H ustar -L' am__untar='cpio -i -H ustar -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_ustar}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file { echo "$as_me:$LINENO: tardir=conftest.dir && eval $am__tar_ >conftest.tar" >&5 (tardir=conftest.dir && eval $am__tar_ >conftest.tar) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } rm -rf conftest.dir if test -s conftest.tar; then { echo "$as_me:$LINENO: $am__untar &5 ($am__untar &5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } grep GrepMe conftest.dir/file >/dev/null 2>&1 && break fi done rm -rf conftest.dir if ${am_cv_prog_tar_ustar+:} false; then : $as_echo_n "(cached) " >&6 else am_cv_prog_tar_ustar=$_am_tool fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_tar_ustar" >&5 $as_echo "$am_cv_prog_tar_ustar" >&6; } # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=0;; esac AM_BACKSLASH='\' vc_changelog=no pandora_building_from_vc=no if test -d ".bzr" ; then pandora_building_from_bzr=yes pandora_building_from_vc=yes else pandora_building_from_bzr=no fi if test -d ".svn" ; then pandora_building_from_svn=yes pandora_building_from_vc=yes else pandora_building_from_svn=no fi if test -d ".hg" ; then pandora_building_from_hg=yes pandora_building_from_vc=yes else pandora_building_from_hg=no fi if test -d ".git" ; then pandora_building_from_git=yes pandora_building_from_vc=yes else pandora_building_from_git=no fi PANDORA_RELEASE_ID=`echo $VERSION | sed 's/[^0-9]//g'` PANDORA_RELEASE_COMMENT="" cat >>confdefs.h <<_ACEOF #define PANDORA_RELEASE_VERSION "$VERSION" _ACEOF PANDORA_HEX_VERSION=`echo $VERSION | sed 's|\-a-z0-9*$||' | \ awk -F. '{printf "0x%0.2d%0.3d%0.3d", $1, $2, $3}'` # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi cat >>confdefs.h <<_ACEOF #define HOST_VENDOR "$host_vendor" _ACEOF cat >>confdefs.h <<_ACEOF #define HOST_OS "$host_os" _ACEOF cat >>confdefs.h <<_ACEOF #define HOST_CPU "$host_cpu" _ACEOF cat >>confdefs.h <<_ACEOF #define TARGET_VENDOR "$target_vendor" _ACEOF cat >>confdefs.h <<_ACEOF #define TARGET_OS "$target_os" _ACEOF cat >>confdefs.h <<_ACEOF #define TARGET_CPU "$target_cpu" _ACEOF case "$host_os" in *solaris*) if test "x${ac_cv_env_CPPFLAGS_set}" = "x"; then : CPPFLAGS="${CPPFLAGS} -I/usr/local/include" fi if test "x${ac_cv_env_LDFLAGS_set}" = "x"; then : LDFLAGS="${LDFLAGS} -L/usr/local/lib" fi ;; *freebsd*) if test "x${ac_cv_env_CPPFLAGS_set}" = "x"; then : CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include" fi if test "x${ac_cv_env_LDFLAGS_set}" = "x"; then : LDFLAGS="${LDFLAGS} -L/usr/local/lib" fi ;; esac PANDORA_OPTIMIZE_BITFIELD=1 case "$target_os" in *linux*) TARGET_LINUX="true" $as_echo "#define TARGET_OS_LINUX 1" >>confdefs.h ;; *darwin*) TARGET_OSX="true" $as_echo "#define TARGET_OS_OSX 1" >>confdefs.h ;; *solaris*) TARGET_SOLARIS="true" PANDORA_OPTIMIZE_BITFIELD=0 if test "x${USE_NLS}" = "xyes"; then : LIBS="${LIBS} -lintl" fi $as_echo "#define TARGET_OS_SOLARIS 1" >>confdefs.h ;; *freebsd*) TARGET_FREEBSD="true" $as_echo "#define TARGET_OS_FREEBSD 1" >>confdefs.h $as_echo "#define __APPLE_CC__ 1" >>confdefs.h ;; *mingw32*) TARGET_WINDOWS="true" $as_echo "#define TARGET_OS_WINDOWS 1" >>confdefs.h $as_echo "#define WINVER WindowsXP" >>confdefs.h $as_echo "#define _WIN32_WINNT 0x0501" >>confdefs.h $as_echo "#define EAI_SYSTEM 11" >>confdefs.h LIBS="$LIBS -lwsock32 -lws2_32" AM_CFLAGS="${AM_CFLAGS} -I\${top_srcdir}/win32/mingw -I\${top_builddir}/win32/mingw -I\${top_srcdir}/win32 -I\${top_builddir}/win32" ;; esac if test "x${TARGET_WINDOWS}" = "xtrue"; then BUILD_WIN32_TRUE= BUILD_WIN32_FALSE='#' else BUILD_WIN32_TRUE='#' BUILD_WIN32_FALSE= fi if test "x${TARGET_OSX}" = "xtrue"; then TARGET_OSX_TRUE= TARGET_OSX_FALSE='#' else TARGET_OSX_TRUE='#' TARGET_OSX_FALSE= fi if test "x${TARGET_LINUX}" = "xtrue"; then TARGET_LINUX_TRUE= TARGET_LINUX_FALSE='#' else TARGET_LINUX_TRUE='#' TARGET_LINUX_FALSE= fi ac_fn_c_check_decl "$LINENO" "__SUNPRO_C" "ac_cv_have_decl___SUNPRO_C" "$ac_includes_default" if test "x$ac_cv_have_decl___SUNPRO_C" = xyes; then : SUNCC="yes" else SUNCC="no" fi ac_fn_c_check_decl "$LINENO" "__ICC" "ac_cv_have_decl___ICC" "$ac_includes_default" if test "x$ac_cv_have_decl___ICC" = xyes; then : INTELCC="yes" else INTELCC="no" fi if test "$INTELCC" = "yes"; then : enable_rpath=no fi if test "$SUNCC" = "yes"; then : $as_echo "#define _STLP_NO_NEW_C_HEADERS 1" >>confdefs.h fi if test "x$TARGET_OSX" = "xtrue"; then : if test "x$ac_enable_fat_binaries" = "xyes"; then : AM_CFLAGS="-arch i386 -arch x86_64 -arch ppc" AM_CXXFLAGS="-arch i386 -arch x86_64 -arch ppc" AM_LDFLAGS="-arch i386 -arch x86_64 -arch ppc" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking \"C Compiler version--$GCC\"" >&5 $as_echo_n "checking \"C Compiler version--$GCC\"... " >&6; } if test "$GCC" = "yes"; then : CC_VERSION=`$CC --version | sed 1q` else if test "$SUNCC" = "yes"; then : CC_VERSION=`$CC -V 2>&1 | sed 1q` else CC_VERSION="" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: \"$CC_VERSION\"" >&5 $as_echo "\"$CC_VERSION\"" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking \"C++ Compiler version\"" >&5 $as_echo_n "checking \"C++ Compiler version\"... " >&6; } if test "$GCC" = "yes"; then : CXX_VERSION=`$CXX --version | sed 1q` else if test "$SUNCC" = "yes"; then : CXX_VERSION=`$CXX -V 2>&1 | sed 1q` else CXX_VERSION="" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: \"$CXX_VERSION\"" >&5 $as_echo "\"$CXX_VERSION\"" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 $as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } if ${ac_cv_struct_tm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { struct tm tm; int *p = &tm.tm_sec; return !p; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_struct_tm=time.h else ac_cv_struct_tm=sys/time.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 $as_echo "$ac_cv_struct_tm" >&6; } if test $ac_cv_struct_tm = sys/time.h; then $as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi # Check whether --enable-largefile was given. if test "${enable_largefile+set}" = set; then : enableval=$enable_largefile; fi if test "$enable_largefile" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 $as_echo_n "checking for special C compiler options needed for large files... " >&6; } if ${ac_cv_sys_largefile_CC+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then ac_save_CC=$CC while :; do # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : break fi rm -f core conftest.err conftest.$ac_objext CC="$CC -n32" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_largefile_CC=' -n32'; break fi rm -f core conftest.err conftest.$ac_objext break done CC=$ac_save_CC rm -f conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 $as_echo "$ac_cv_sys_largefile_CC" >&6; } if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 $as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } if ${ac_cv_sys_file_offset_bits+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _FILE_OFFSET_BITS 64 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=64; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_file_offset_bits=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 $as_echo "$ac_cv_sys_file_offset_bits" >&6; } case $ac_cv_sys_file_offset_bits in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits _ACEOF ;; esac rm -rf conftest* if test $ac_cv_sys_file_offset_bits = unknown; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 $as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } if ${ac_cv_sys_large_files+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _LARGE_FILES 1 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=1; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_large_files=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 $as_echo "$ac_cv_sys_large_files" >&6; } case $ac_cv_sys_large_files in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _LARGE_FILES $ac_cv_sys_large_files _ACEOF ;; esac rm -rf conftest* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 $as_echo_n "checking for library containing clock_gettime... " >&6; } if ${ac_cv_search_clock_gettime+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char clock_gettime (); int main () { return clock_gettime (); ; return 0; } _ACEOF for ac_lib in '' rt; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_clock_gettime=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_clock_gettime+:} false; then : break fi done if ${ac_cv_search_clock_gettime+:} false; then : else ac_cv_search_clock_gettime=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5 $as_echo "$ac_cv_search_clock_gettime" >&6; } ac_res=$ac_cv_search_clock_gettime if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi if test "x${ac_cv_search_clock_gettime}" != "xno"; then : $as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h fi for ac_header in sys/socket.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default" if test "x$ac_cv_header_sys_socket_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_SOCKET_H 1 _ACEOF fi done # off_t is not a builtin type # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of off_t" >&5 $as_echo_n "checking size of off_t... " >&6; } if ${ac_cv_sizeof_off_t+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (off_t))" "ac_cv_sizeof_off_t" "$ac_includes_default"; then : else if test "$ac_cv_type_off_t" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (off_t) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_off_t=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_off_t" >&5 $as_echo "$ac_cv_sizeof_off_t" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_OFF_T $ac_cv_sizeof_off_t _ACEOF if test "$ac_cv_sizeof_off_t" -eq 0; then : as_fn_error $? "\"${PACKAGE} needs an off_t type.\"" "$LINENO" 5 fi # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of size_t" >&5 $as_echo_n "checking size of size_t... " >&6; } if ${ac_cv_sizeof_size_t+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (size_t))" "ac_cv_sizeof_size_t" "$ac_includes_default"; then : else if test "$ac_cv_type_size_t" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (size_t) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_size_t=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_size_t" >&5 $as_echo "$ac_cv_sizeof_size_t" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_SIZE_T $ac_cv_sizeof_size_t _ACEOF if test "$ac_cv_sizeof_size_t" -eq 0; then : as_fn_error $? "\"${PACKAGE} needs an size_t type.\"" "$LINENO" 5 fi cat >>confdefs.h <<_ACEOF #define SIZEOF_SIZE_T $ac_cv_sizeof_size_t _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5 $as_echo_n "checking size of long long... " >&6; } if ${ac_cv_sizeof_long_long+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then : else if test "$ac_cv_type_long_long" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long long) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_long_long=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5 $as_echo "$ac_cv_sizeof_long_long" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long _ACEOF cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking if time_t is unsigned" >&5 $as_echo_n "checking if time_t is unsigned... " >&6; } if ${ac_cv_time_t_unsigned+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int array[(((time_t)-1) > 0) ? 1 : -1]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_time_t_unsigned=yes else ac_cv_time_t_unsigned=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_time_t_unsigned" >&5 $as_echo "$ac_cv_time_t_unsigned" >&6; } if test "$ac_cv_time_t_unsigned" = "yes"; then : $as_echo "#define TIME_T_UNSIGNED 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "setsockopt" "ac_cv_func_setsockopt" if test "x$ac_cv_func_setsockopt" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for setsockopt in -lsocket" >&5 $as_echo_n "checking for setsockopt in -lsocket... " >&6; } if ${ac_cv_lib_socket_setsockopt+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char setsockopt (); int main () { return setsockopt (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_setsockopt=yes else ac_cv_lib_socket_setsockopt=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_setsockopt" >&5 $as_echo "$ac_cv_lib_socket_setsockopt" >&6; } if test "x$ac_cv_lib_socket_setsockopt" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSOCKET 1 _ACEOF LIBS="-lsocket $LIBS" fi fi ac_fn_c_check_func "$LINENO" "bind" "ac_cv_func_bind" if test "x$ac_cv_func_bind" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bind in -lbind" >&5 $as_echo_n "checking for bind in -lbind... " >&6; } if ${ac_cv_lib_bind_bind+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lbind $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char bind (); int main () { return bind (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_bind_bind=yes else ac_cv_lib_bind_bind=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bind_bind" >&5 $as_echo "$ac_cv_lib_bind_bind" >&6; } if test "x$ac_cv_lib_bind_bind" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBBIND 1 _ACEOF LIBS="-lbind $LIBS" fi fi if test "$GCC" = "yes" -a "$INTELCC" = "no"; then : case "$target_cpu" in *ppc* | *powerpc*) AM_CFLAGS="-mno-fused-madd ${AM_CFLAGS}" AM_CXXFLAGS="-mno-fused-madd ${AM_CXXFLAGS}" ;; esac AM_CPPFLAGS="-ggdb ${AM_CPPFLAGS}" DEBUG_CFLAGS="-O0" DEBUG_CXXFLAGS="-O0" OPTIMIZE_CFLAGS="-O2" OPTIMIZE_CXXFLAGS="-O2" fi if test "$INTELCC" = "yes"; then : AM_CPPFLAGS="-g ${AM_CPPFLAGS}" DEBUG_CFLAGS="-O0" DEBUG_CXXFLAGS="-O0" OPTIMIZE_CFLAGS="-xHOST -O2 -no-prec-div -static" OPTIMIZE_CXXFLAGS="${OPTIMIZE_CFLAGS}" fi if test "$SUNCC" = "yes"; then : CC="${CC} -xc99=all" CXX="${CXX} -xlang=c99" AM_CFLAGS="-g -mt -xstrconst -Xa ${AM_CFLAGS}" AM_CXXFLAGS="-mt -compat=5 -library=stlport4 -library=Crun -template=no%extdef ${AM_CXXFLAGS}" DEBUG_CXXFLAGS="-g" OPTIMIZE_FLAGS="-xO3 -xlibmil -xdepend -xbuiltin" OPTIMIZE_CFLAGS="${OPTIMIZE_FLAGS}" OPTIMIZE_CXXFLAGS="-g0 ${OPTIMIZE_FLAGS}" fi # Check whether --with-debug was given. if test "${with_debug+set}" = set; then : withval=$with_debug; with_debug=$withval else with_debug=no fi if test "$with_debug" = "yes"; then : # Debugging. No optimization. AM_CFLAGS="${AM_CFLAGS} ${DEBUG_CFLAGS} -DDEBUG" AM_CXXFLAGS="${AM_CXXFLAGS} ${DEBUG_CXXFLAGS} -DDEBUG" $as_echo "#define DEBUG 1 " >>confdefs.h else # Optimized version. No debug AM_CFLAGS="${AM_CFLAGS} ${OPTIMIZE_CFLAGS}" AM_CXXFLAGS="${AM_CXXFLAGS} ${OPTIMIZE_CXXFLAGS}" $as_echo "#define DEBUG 0 " >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler provides atomic builtins" >&5 $as_echo_n "checking whether the compiler provides atomic builtins... " >&6; } if ${ac_cv_gcc_atomic_builtins+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { int foo= -10; int bar= 10; if (!__sync_fetch_and_add(&foo, bar) || foo) return -1; bar= __sync_lock_test_and_set(&foo, bar); if (bar || foo != 10) return -1; bar= __sync_val_compare_and_swap(&bar, foo, 15); if (bar) return -1; return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_gcc_atomic_builtins=yes else ac_cv_gcc_atomic_builtins=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_gcc_atomic_builtins" >&5 $as_echo "$ac_cv_gcc_atomic_builtins" >&6; } if test "x$ac_cv_gcc_atomic_builtins" = "xyes"; then : $as_echo "#define HAVE_GCC_ATOMIC_BUILTINS 1" >>confdefs.h fi for ac_header in assert.h do : ac_fn_c_check_header_mongrel "$LINENO" "assert.h" "ac_cv_header_assert_h" "$ac_includes_default" if test "x$ac_cv_header_assert_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ASSERT_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable assertions" >&5 $as_echo_n "checking whether to enable assertions... " >&6; } # Check whether --enable-assert was given. if test "${enable_assert+set}" = set; then : enableval=$enable_assert; ac_cv_assert="no" else ac_cv_assert="yes" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_assert" >&5 $as_echo "$ac_cv_assert" >&6; } if test "$ac_cv_assert" = "no"; then : $as_echo "#define NDEBUG 1" >>confdefs.h fi if test "$pandora_building_from_vc" = "yes"; then : ac_cv_warnings_as_errors=yes else ac_cv_warnings_as_errors=no fi # Check whether --enable-gcc-profile-mode was given. if test "${enable_gcc_profile_mode+set}" = set; then : enableval=$enable_gcc_profile_mode; ac_gcc_profile_mode="$enableval" else ac_gcc_profile_mode="no" fi # Check whether --enable-profiling was given. if test "${enable_profiling+set}" = set; then : enableval=$enable_profiling; ac_profiling="$enableval" else ac_profiling="no" fi # Check whether --enable-coverage was given. if test "${enable_coverage+set}" = set; then : enableval=$enable_coverage; ac_coverage="$enableval" else ac_coverage="no" fi if test "$GCC" = "yes"; then : if test "$ac_profiling" = "yes"; then : CC_PROFILING="-pg" GCOV_LIBS="-pg -lgcov" save_LIBS="${LIBS}" LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for read in -lc_p" >&5 $as_echo_n "checking for read in -lc_p... " >&6; } if ${ac_cv_lib_c_p_read+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lc_p $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char read (); int main () { return read (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_c_p_read=yes else ac_cv_lib_c_p_read=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_p_read" >&5 $as_echo "$ac_cv_lib_c_p_read" >&6; } if test "x$ac_cv_lib_c_p_read" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBC_P 1 _ACEOF LIBS="-lc_p $LIBS" fi LIBC_P="${LIBS}" LIBS="${save_LIBS}" else CC_PROFILING=" " fi if test "$ac_coverage" = "yes"; then : CC_COVERAGE="--coverage" GCOV_LIBS="-lgcov" fi if test "$ac_cv_warnings_as_errors" = "yes"; then : W_FAIL="-Werror" SPHINX_WARNINGS="-W -n" INTLTOOL_WARNINGS="yes" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to use -fdiagnostics-show-option" >&5 $as_echo_n "checking whether it is safe to use -fdiagnostics-show-option... " >&6; } if ${ac_cv_safe_to_use_fdiagnostics_show_option_+:} false; then : $as_echo_n "(cached) " >&6 else save_CFLAGS="$CFLAGS" CFLAGS="-fdiagnostics-show-option ${AM_CFLAGS} ${CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_safe_to_use_fdiagnostics_show_option_=yes else ac_cv_safe_to_use_fdiagnostics_show_option_=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_use_fdiagnostics_show_option_" >&5 $as_echo "$ac_cv_safe_to_use_fdiagnostics_show_option_" >&6; } if test "$ac_cv_safe_to_use_fdiagnostics_show_option_" = "yes"; then : F_DIAGNOSTICS_SHOW_OPTION="-fdiagnostics-show-option" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to use -floop-parallelize-all" >&5 $as_echo_n "checking whether it is safe to use -floop-parallelize-all... " >&6; } if ${ac_cv_safe_to_use_floop_parallelize_all_+:} false; then : $as_echo_n "(cached) " >&6 else save_CFLAGS="$CFLAGS" CFLAGS="-floop-parallelize-all ${AM_CFLAGS} ${CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_safe_to_use_floop_parallelize_all_=yes else ac_cv_safe_to_use_floop_parallelize_all_=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_use_floop_parallelize_all_" >&5 $as_echo "$ac_cv_safe_to_use_floop_parallelize_all_" >&6; } if test "$ac_cv_safe_to_use_floop_parallelize_all_" = "yes"; then : F_LOOP_PARALLELIZE_ALL="-floop-parallelize-all" fi NO_STRICT_ALIASING="-fno-strict-aliasing -Wno-strict-aliasing" NO_SHADOW="-Wno-shadow" if test "$INTELCC" = "yes"; then : BASE_WARNINGS="-w1 -Werror -Wcheck -Wp64 -Woverloaded-virtual -Wcast-qual -diag-disable 188" CC_WARNINGS="${BASE_WARNINGS}" CXX_WARNINGS="${BASE_WARNINGS}" PROTOSKIP_WARNINGS="-diag-disable 188,981,967,2259,1683,1684,2203" else BASE_WARNINGS_FULL="${W_CONVERSION} -Wstrict-aliasing -Wswitch-enum " CC_WARNINGS_FULL="-Wswitch-default -Wswitch-enum -Wwrite-strings" CXX_WARNINGS_FULL="" NO_OLD_STYLE_CAST="-Wno-old-style-cast" NO_EFF_CXX="-Wno-effc++" if test "${ac_cv_assert}" = "no"; then : NO_UNUSED="-Wno-unused-variable -Wno-unused-parameter" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to use -Wextra" >&5 $as_echo_n "checking whether it is safe to use -Wextra... " >&6; } if ${ac_cv_safe_to_use_Wextra_+:} false; then : $as_echo_n "(cached) " >&6 else save_CFLAGS="$CFLAGS" CFLAGS="${W_FAIL} -pedantic -Wextra ${AM_CFLAGS} ${CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_safe_to_use_Wextra_=yes else ac_cv_safe_to_use_Wextra_=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_use_Wextra_" >&5 $as_echo "$ac_cv_safe_to_use_Wextra_" >&6; } BASE_WARNINGS="${W_FAIL} -pedantic -Wall -Wundef -Wshadow -Wparentheses ${NO_UNUSED} ${F_DIAGNOSTICS_SHOW_OPTION} ${F_LOOP_PARALLELIZE_ALL} ${BASE_WARNINGS_FULL}" if test "$ac_cv_safe_to_use_Wextra_" = "yes"; then : BASE_WARNINGS="${BASE_WARNINGS} -Wextra" else BASE_WARNINGS="${BASE_WARNINGS} -W" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to use -Wformat" >&5 $as_echo_n "checking whether it is safe to use -Wformat... " >&6; } if ${ac_cv_safe_to_use_wformat_+:} false; then : $as_echo_n "(cached) " >&6 else save_CFLAGS="$CFLAGS" CFLAGS="-Wformat -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include void foo(); void foo() { uint64_t test_u= 0; printf("This is a %" PRIu64 "test\n", test_u); } int main () { foo(); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_safe_to_use_wformat_=yes else ac_cv_safe_to_use_wformat_=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_use_wformat_" >&5 $as_echo "$ac_cv_safe_to_use_wformat_" >&6; } if test "$ac_cv_safe_to_use_wformat_" = "yes"; then : BASE_WARNINGS="${BASE_WARNINGS} -Wformat -Wno-format-nonliteral -Wformat-security" BASE_WARNINGS_FULL="${BASE_WARNINGS_FULL} -Wformat=2 -Wno-format-nonliteral -Wformat-security" else BASE_WARNINGS="${BASE_WARNINGS} -Wno-format" BASE_WARNINGS_FULL="${BASE_WARNINGS_FULL} -Wno-format" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to use -Wconversion" >&5 $as_echo_n "checking whether it is safe to use -Wconversion... " >&6; } if ${ac_cv_safe_to_use_wconversion_+:} false; then : $as_echo_n "(cached) " >&6 else save_CFLAGS="$CFLAGS" CFLAGS="-Wconversion -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include void foo(bool a) { (void)a; } int main () { foo(0); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_safe_to_use_wconversion_=yes else ac_cv_safe_to_use_wconversion_=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_use_wconversion_" >&5 $as_echo "$ac_cv_safe_to_use_wconversion_" >&6; } if test "$ac_cv_safe_to_use_wconversion_" = "yes"; then : W_CONVERSION="-Wconversion" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to use -Wconversion with htons" >&5 $as_echo_n "checking whether it is safe to use -Wconversion with htons... " >&6; } if ${ac_cv_safe_to_use_Wconversion_+:} false; then : $as_echo_n "(cached) " >&6 else save_CFLAGS="$CFLAGS" CFLAGS="-Wconversion -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { uint16_t x= htons(80); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_safe_to_use_Wconversion_=yes else ac_cv_safe_to_use_Wconversion_=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_use_Wconversion_" >&5 $as_echo "$ac_cv_safe_to_use_Wconversion_" >&6; } if test "$ac_cv_safe_to_use_Wconversion_" = "no"; then : NO_CONVERSION="-Wno-conversion" fi fi CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wmissing-declarations -Wcast-align -Wsign-compare ${CC_WARNINGS_FULL}" CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long -Wsign-compare ${CXX_WARNINGS_FULL}" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to use -Wmissing-declarations from C++" >&5 $as_echo_n "checking whether it is safe to use -Wmissing-declarations from C++... " >&6; } if ${ac_cv_safe_to_use_Wmissing_declarations_+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu save_CXXFLAGS="$CXXFLAGS" CXXFLAGS="-Werror -pedantic -Wmissing-declarations ${AM_CXXFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_safe_to_use_Wmissing_declarations_=yes else ac_cv_safe_to_use_Wmissing_declarations_=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CXXFLAGS="$save_CXXFLAGS" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_use_Wmissing_declarations_" >&5 $as_echo "$ac_cv_safe_to_use_Wmissing_declarations_" >&6; } if test "$ac_cv_safe_to_use_Wmissing_declarations_" = "yes"; then : CXX_WARNINGS="${CXX_WARNINGS} -Wmissing-declarations" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to use -Wframe-larger-than" >&5 $as_echo_n "checking whether it is safe to use -Wframe-larger-than... " >&6; } if ${ac_cv_safe_to_use_Wframe_larger_than_+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu save_CXXFLAGS="$CXXFLAGS" CXXFLAGS="-Werror -pedantic -Wframe-larger-than=32768 ${AM_CXXFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_safe_to_use_Wframe_larger_than_=yes else ac_cv_safe_to_use_Wframe_larger_than_=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CXXFLAGS="$save_CXXFLAGS" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_use_Wframe_larger_than_" >&5 $as_echo "$ac_cv_safe_to_use_Wframe_larger_than_" >&6; } if test "$ac_cv_safe_to_use_Wframe_larger_than_" = "yes"; then : CXX_WARNINGS="${CXX_WARNINGS} -Wframe-larger-than=32768" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to use -Wlogical-op" >&5 $as_echo_n "checking whether it is safe to use -Wlogical-op... " >&6; } if ${ac_cv_safe_to_use_Wlogical_op_+:} false; then : $as_echo_n "(cached) " >&6 else save_CFLAGS="$CFLAGS" CFLAGS="${W_FAIL} -pedantic -Wlogical-op ${AM_CFLAGS} ${CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_safe_to_use_Wlogical_op_=yes else ac_cv_safe_to_use_Wlogical_op_=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_use_Wlogical_op_" >&5 $as_echo "$ac_cv_safe_to_use_Wlogical_op_" >&6; } if test "$ac_cv_safe_to_use_Wlogical_op_" = "yes"; then : CC_WARNINGS="${CC_WARNINGS} -Wlogical-op" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to use -Wredundant-decls from C++" >&5 $as_echo_n "checking whether it is safe to use -Wredundant-decls from C++... " >&6; } if ${ac_cv_safe_to_use_Wredundant_decls_+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu save_CXXFLAGS="${CXXFLAGS}" CXXFLAGS="${W_FAIL} -pedantic -Wredundant-decls ${AM_CXXFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ template struct C { void foo(); }; template void C::foo() { } template <> void C::foo(); $ac_includes_default int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_safe_to_use_Wredundant_decls_=yes else ac_cv_safe_to_use_Wredundant_decls_=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CXXFLAGS="${save_CXXFLAGS}" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_use_Wredundant_decls_" >&5 $as_echo "$ac_cv_safe_to_use_Wredundant_decls_" >&6; } if test "$ac_cv_safe_to_use_Wredundant_decls_" = "yes"; then : CXX_WARNINGS="${CXX_WARNINGS} -Wredundant-decls" else CXX_WARNINGS="${CXX_WARNINGS} -Wno-redundant-decls" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to use -Wattributes from C++" >&5 $as_echo_n "checking whether it is safe to use -Wattributes from C++... " >&6; } if ${ac_cv_safe_to_use_Wattributes_+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu save_CXXFLAGS="${CXXFLAGS}" CXXFLAGS="${W_FAIL} -pedantic -Wattributes -fvisibility=hidden ${AM_CXXFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include const ::google::protobuf::EnumDescriptor* Table_TableOptions_RowType_descriptor(); enum Table_TableOptions_RowType { Table_TableOptions_RowType_ROW_TYPE_DEFAULT = 0, Table_TableOptions_RowType_ROW_TYPE_FIXED = 1, Table_TableOptions_RowType_ROW_TYPE_DYNAMIC = 2, Table_TableOptions_RowType_ROW_TYPE_COMPRESSED = 3, Table_TableOptions_RowType_ROW_TYPE_REDUNDANT = 4, Table_TableOptions_RowType_ROW_TYPE_COMPACT = 5, Table_TableOptions_RowType_ROW_TYPE_PAGE = 6 }; namespace google { namespace protobuf { template <> inline const EnumDescriptor* GetEnumDescriptor() { return Table_TableOptions_RowType_descriptor(); } } } int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_safe_to_use_Wattributes_=yes else ac_cv_safe_to_use_Wattributes_=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CXXFLAGS="${save_CXXFLAGS}" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_use_Wattributes_" >&5 $as_echo "$ac_cv_safe_to_use_Wattributes_" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to use -Wno-attributes" >&5 $as_echo_n "checking whether it is safe to use -Wno-attributes... " >&6; } if ${ac_cv_safe_to_use_Wno_attributes_+:} false; then : $as_echo_n "(cached) " >&6 else save_CFLAGS="$CFLAGS" CFLAGS="${W_FAIL} -pedantic -Wno_attributes_ ${AM_CFLAGS} ${CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_safe_to_use_Wno_attributes_=yes else ac_cv_safe_to_use_Wno_attributes_=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_use_Wno_attributes_" >&5 $as_echo "$ac_cv_safe_to_use_Wno_attributes_" >&6; } if test "$ac_cv_safe_to_use_Wattributes_" != "yes"; then : if test "$ac_cv_safe_to_use_Wno_attributes_" = "yes"; then : CC_WARNINGS="${CC_WARNINGS} -Wno-attributes" NO_ATTRIBUTES="-Wno-attributes" fi fi NO_REDUNDANT_DECLS="-Wno-redundant-decls" PROTOSKIP_WARNINGS="-Wno-effc++ -Wno-shadow -Wno-missing-braces ${NO_ATTRIBUTES}" NO_WERROR="-Wno-error" PERMISSIVE_WARNINGS="-Wno-error -Wno-unused-function -fpermissive" PERMISSIVE_C_WARNINGS="-Wno-error -Wno-redundant-decls" if test "$host_vendor" = "apple"; then : BOOSTSKIP_WARNINGS="-Wno-uninitialized" fi fi fi if test "$SUNCC" = "yes"; then : if test "$ac_profiling" = "yes"; then : CC_PROFILING="-xinstrument=datarace" fi if test "$ac_cv_warnings_as_errors" = "yes"; then : W_FAIL="-errwarn=%all" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether E_PASTE_RESULT_NOT_TOKEN is usable" >&5 $as_echo_n "checking whether E_PASTE_RESULT_NOT_TOKEN is usable... " >&6; } if ${ac_cv_paste_result+:} false; then : $as_echo_n "(cached) " >&6 else save_CFLAGS="${CFLAGS}" CFLAGS="-errwarn=%all -erroff=E_PASTE_RESULT_NOT_TOKEN ${CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { int x= 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_paste_result=yes else ac_cv_paste_result=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="${save_CFLAGS}" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_paste_result" >&5 $as_echo "$ac_cv_paste_result" >&6; } if test $ac_cv_paste_result = yes; then : W_PASTE_RESULT=",E_PASTE_RESULT_NOT_TOKEN" fi CC_WARNINGS_FULL="-erroff=E_STATEMENT_NOT_REACHED,E_INTEGER_OVERFLOW_DETECTED${W_PASTE_RESULT}" CXX_WARNINGS_FULL="-erroff=inllargeuse" CC_WARNINGS="-v -errtags=yes ${W_FAIL} ${CC_WARNINGS_FULL}" CXX_WARNINGS="+w +w2 -xwe -xport64 -errtags=yes ${CXX_WARNINGS_FULL} ${W_FAIL}" PROTOSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn,partinit,notused,badargtype2w,wbadinit" BOOSTSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint,hidef,wvarhidenmem" PERMISSIVE_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint,hidef,wvarhidenmem,notused,badargtype2w,wunreachable" INNOBASE_SKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn,partinit,notused,badargtype2w,wbadinit,wunreachable" NO_UNREACHED="-erroff=E_STATEMENT_NOT_REACHED" NO_WERROR="-errwarn=%none" fi # Check whether --enable-dtrace was given. if test "${enable_dtrace+set}" = set; then : enableval=$enable_dtrace; ac_cv_enable_dtrace="$enableval" else ac_cv_enable_dtrace="no" fi if test "$ac_cv_enable_dtrace" = "yes"; then : for ac_prog in dtrace do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DTRACE+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DTRACE"; then ac_cv_prog_DTRACE="$DTRACE" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DTRACE="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DTRACE=$ac_cv_prog_DTRACE if test -n "$DTRACE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DTRACE" >&5 $as_echo "$DTRACE" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DTRACE" && break done for ac_header in sys/sdt.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/sdt.h" "ac_cv_header_sys_sdt_h" "$ac_includes_default" if test "x$ac_cv_header_sys_sdt_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_SDT_H 1 _ACEOF fi done if test "x$ac_cv_prog_DTRACE" = "xdtrace" -a "x${ac_cv_header_sys_sdt_h}" = "xyes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking if dtrace works" >&5 $as_echo_n "checking if dtrace works... " >&6; } if ${ac_cv_dtrace_works+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.d <<_ACEOF provider Example { probe increment(int); }; _ACEOF $DTRACE -h -o conftest.h -s conftest.d 2>/dev/zero if test $? -eq 0; then : ac_cv_dtrace_works=yes else ac_cv_dtrace_works=no fi rm -f conftest.h conftest.d fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_dtrace_works" >&5 $as_echo "$ac_cv_dtrace_works" >&6; } if test "x$ac_cv_dtrace_works" = "xyes"; then : $as_echo "#define HAVE_DTRACE 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if dtrace should instrument object files" >&5 $as_echo_n "checking if dtrace should instrument object files... " >&6; } if ${ac_cv_dtrace_needs_objects+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.d <<_ACEOF provider Example { probe increment(int); }; _ACEOF $DTRACE -G -o conftest.d.o -s conftest.d 2>/dev/zero if test $? -eq 0; then : ac_cv_dtrace_needs_objects=yes else ac_cv_dtrace_needs_objects=no fi rm -f conftest.d.o conftest.d fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_dtrace_needs_objects" >&5 $as_echo "$ac_cv_dtrace_needs_objects" >&6; } ac_cv_have_dtrace=yes fi fi if test "x$ac_cv_dtrace_works" = "xyes"; then HAVE_DTRACE_TRUE= HAVE_DTRACE_FALSE='#' else HAVE_DTRACE_TRUE='#' HAVE_DTRACE_FALSE= fi if test "x$ac_cv_dtrace_needs_objects" = "xyes"; then DTRACE_NEEDS_OBJECTS_TRUE= DTRACE_NEEDS_OBJECTS_FALSE='#' else DTRACE_NEEDS_OBJECTS_TRUE='#' DTRACE_NEEDS_OBJECTS_FALSE= fi use_additional=yes acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" # Check whether --with-lib-prefix was given. if test "${with_lib_prefix+set}" = set; then : withval=$with_lib_prefix; if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" fi fi fi if test $use_additional = yes; then if test "X$additional_includedir" != "X/usr/include"; then haveit= for x in $CPPFLAGS; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_includedir"; then CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" fi fi fi fi if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then haveit= for x in $LDFLAGS; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then if test -n "$GCC"; then case $host_os in linux*) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_libdir"; then LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" fi fi fi fi fi # Check whether --enable-umem was given. if test "${enable_umem+set}" = set; then : enableval=$enable_umem; ac_enable_umem="$enableval" else case "$target_os" in *solaris*) ac_enable_umem="yes" ;; *) ac_enable_umem="no" ;; esac fi # Check whether --enable-tcmalloc was given. if test "${enable_tcmalloc+set}" = set; then : enableval=$enable_tcmalloc; ac_enable_tcmalloc="$enableval" else ac_enable_tcmalloc="no" fi # Check whether --enable-mtmalloc was given. if test "${enable_mtmalloc+set}" = set; then : enableval=$enable_mtmalloc; ac_enable_mtmalloc="$enableval" else ac_enable_mtmalloc="yes" fi save_LIBS="${LIBS}" LIBS= if test "x$ac_enable_umem" = "xyes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for malloc in -lumem" >&5 $as_echo_n "checking for malloc in -lumem... " >&6; } if ${ac_cv_lib_umem_malloc+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lumem $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char malloc (); int main () { return malloc (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_umem_malloc=yes else ac_cv_lib_umem_malloc=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_umem_malloc" >&5 $as_echo "$ac_cv_lib_umem_malloc" >&6; } if test "x$ac_cv_lib_umem_malloc" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBUMEM 1 _ACEOF LIBS="-lumem $LIBS" fi else case "$target_os" in *linux*) if test "x$ac_enable_tcmalloc" != "xno"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for malloc in -ltcmalloc-minimal" >&5 $as_echo_n "checking for malloc in -ltcmalloc-minimal... " >&6; } if ${ac_cv_lib_tcmalloc_minimal_malloc+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ltcmalloc-minimal $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char malloc (); int main () { return malloc (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_tcmalloc_minimal_malloc=yes else ac_cv_lib_tcmalloc_minimal_malloc=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tcmalloc_minimal_malloc" >&5 $as_echo "$ac_cv_lib_tcmalloc_minimal_malloc" >&6; } if test "x$ac_cv_lib_tcmalloc_minimal_malloc" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBTCMALLOC_MINIMAL 1 _ACEOF LIBS="-ltcmalloc-minimal $LIBS" fi if test "x$ac_cv_lib_tcmalloc_minimal_malloc" != "xyes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for malloc in -ltcmalloc" >&5 $as_echo_n "checking for malloc in -ltcmalloc... " >&6; } if ${ac_cv_lib_tcmalloc_malloc+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ltcmalloc $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char malloc (); int main () { return malloc (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_tcmalloc_malloc=yes else ac_cv_lib_tcmalloc_malloc=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tcmalloc_malloc" >&5 $as_echo "$ac_cv_lib_tcmalloc_malloc" >&6; } if test "x$ac_cv_lib_tcmalloc_malloc" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBTCMALLOC 1 _ACEOF LIBS="-ltcmalloc $LIBS" fi fi fi ;; *solaris*) if test "x$ac_enable_mtmalloc" != "xno"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for malloc in -lmtmalloc" >&5 $as_echo_n "checking for malloc in -lmtmalloc... " >&6; } if ${ac_cv_lib_mtmalloc_malloc+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lmtmalloc $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char malloc (); int main () { return malloc (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_mtmalloc_malloc=yes else ac_cv_lib_mtmalloc_malloc=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mtmalloc_malloc" >&5 $as_echo "$ac_cv_lib_mtmalloc_malloc" >&6; } if test "x$ac_cv_lib_mtmalloc_malloc" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBMTMALLOC 1 _ACEOF LIBS="-lmtmalloc $LIBS" fi fi ;; esac fi BETTER_MALLOC_LIBS="${LIBS}" LIBS="${save_LIBS}" for ac_prog in perl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then ac_cv_prog_PERL="$PERL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PERL="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PERL=$ac_cv_prog_PERL if test -n "$PERL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 $as_echo "$PERL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PERL" && break done for ac_prog in dpkg-gensymbols do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DPKG_GENSYMBOLS+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DPKG_GENSYMBOLS"; then ac_cv_prog_DPKG_GENSYMBOLS="$DPKG_GENSYMBOLS" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DPKG_GENSYMBOLS="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DPKG_GENSYMBOLS=$ac_cv_prog_DPKG_GENSYMBOLS if test -n "$DPKG_GENSYMBOLS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DPKG_GENSYMBOLS" >&5 $as_echo "$DPKG_GENSYMBOLS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DPKG_GENSYMBOLS" && break done test -n "$DPKG_GENSYMBOLS" || DPKG_GENSYMBOLS=":" for ac_prog in lcov do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LCOV+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LCOV"; then ac_cv_prog_LCOV="$LCOV" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LCOV="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LCOV=$ac_cv_prog_LCOV if test -n "$LCOV"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LCOV" >&5 $as_echo "$LCOV" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$LCOV" && break done test -n "$LCOV" || LCOV="echo lcov not found" for ac_prog in genhtml do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LCOV_GENHTML+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LCOV_GENHTML"; then ac_cv_prog_LCOV_GENHTML="$LCOV_GENHTML" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LCOV_GENHTML="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LCOV_GENHTML=$ac_cv_prog_LCOV_GENHTML if test -n "$LCOV_GENHTML"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LCOV_GENHTML" >&5 $as_echo "$LCOV_GENHTML" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$LCOV_GENHTML" && break done test -n "$LCOV_GENHTML" || LCOV_GENHTML="echo genhtml not found" for ac_prog in sphinx-build do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_SPHINXBUILD+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$SPHINXBUILD"; then ac_cv_prog_SPHINXBUILD="$SPHINXBUILD" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_SPHINXBUILD="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi SPHINXBUILD=$ac_cv_prog_SPHINXBUILD if test -n "$SPHINXBUILD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SPHINXBUILD" >&5 $as_echo "$SPHINXBUILD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$SPHINXBUILD" && break done test -n "$SPHINXBUILD" || SPHINXBUILD=":" if test "x${SPHINXBUILD}" != "x:"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking if sphinx is new enough" >&5 $as_echo_n "checking if sphinx is new enough... " >&6; } if ${ac_cv_recent_sphinx+:} false; then : $as_echo_n "(cached) " >&6 else ${SPHINXBUILD} -Q -C -b man -d conftest.d . . >/dev/null 2>&1 if test $? -eq 0; then : ac_cv_recent_sphinx=yes else ac_cv_recent_sphinx=no fi rm -rf conftest.d fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_recent_sphinx" >&5 $as_echo "$ac_cv_recent_sphinx" >&6; } fi if test "x${DPKG_GENSYMBOLS}" != "x:"; then HAVE_DPKG_GENSYMBOLS_TRUE= HAVE_DPKG_GENSYMBOLS_FALSE='#' else HAVE_DPKG_GENSYMBOLS_TRUE='#' HAVE_DPKG_GENSYMBOLS_FALSE= fi if test "x${SPHINXBUILD}" != "x:"; then HAVE_SPHINX_TRUE= HAVE_SPHINX_FALSE='#' else HAVE_SPHINX_TRUE='#' HAVE_SPHINX_FALSE= fi if test "x${ac_cv_recent_sphinx}" = "xyes"; then HAVE_RECENT_SPHINX_TRUE= HAVE_RECENT_SPHINX_FALSE='#' else HAVE_RECENT_SPHINX_TRUE='#' HAVE_RECENT_SPHINX_FALSE= fi AM_CPPFLAGS="-I\$(top_srcdir) -I\$(top_builddir) ${AM_CPPFLAGS}" if test "$GCC" = "yes"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working -pipe" >&5 $as_echo_n "checking for working -pipe... " >&6; } if ${pandora_cv_use_pipe+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(int argc, char** argv) { (void) argc; (void) argv; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : pandora_cv_use_pipe=yes else pandora_cv_use_pipe=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pandora_cv_use_pipe" >&5 $as_echo "$pandora_cv_use_pipe" >&6; } if test "$pandora_cv_use_pipe" = "yes"; then : AM_CFLAGS="-pipe ${AM_CFLAGS}" AM_CXXFLAGS="-pipe ${AM_CXXFLAGS}" fi fi AM_CFLAGS="-std=c99 ${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}" AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}" for ac_prog in 'bison' do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_YACC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$YACC"; then ac_cv_prog_YACC="$YACC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_YACC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi YACC=$ac_cv_prog_YACC if test -n "$YACC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5 $as_echo "$YACC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$YACC" && break done test -n "$YACC" || YACC=":" for ac_prog in 'flex' do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LEX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LEX"; then ac_cv_prog_LEX="$LEX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LEX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LEX=$ac_cv_prog_LEX if test -n "$LEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LEX" >&5 $as_echo "$LEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$LEX" && break done test -n "$LEX" || LEX=":" #shared library versioning MEMCACHED_UTIL_LIBRARY_VERSION=2:0:0 MEMCACHED_PROTOCAL_LIBRARY_VERSION=0:0:0 MEMCACHED_LIBRARY_VERSION=10:0:0 # | | | # +------+ | +---+ # | | | # current:revision:age # | | | # | | +- increment if interfaces have been added # | | set to zero if interfaces have been removed or changed # | +- increment if source code has changed # | set to zero if current is incremented # +- increment if interfaces have been added, removed or changed HASHKIT_LIBRARY_VERSION=2:0:0 case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4' macro_revision='1.3293' ltmain="$ac_aux_dir/ltmain.sh" # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case "$ECHO" in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n $lt_cv_sys_max_cmd_len ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 $as_echo "$xsi_shell" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 $as_echo "$lt_shell_append" >&6; } if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test "$GCC" != yes; then reload_cmds=false fi ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 $as_echo "${with_sysroot}" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; sparc*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) LD="${LD-ld} -m elf64_sparc" ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[012]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done func_stripname_cnf () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname_cnf # Set options enable_dlopen=no enable_win32_dll=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac else enable_shared=yes fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; pic_mode="$withval" else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC="$CC" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' lt_prog_compiler_pic='-Xcompiler -fPIC' ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ F* | *Sun*Fortran*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test x"$lt_cv_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test x"$lt_cv_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_flag_spec_ld= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='${wl}--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec= hardcode_libdir_flag_spec_ld='-rpath $libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; freebsd1*) ld_shlibs=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_flag_spec_ld='+b $libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test x"$lt_cv_prog_compiler__b" = xyes; then archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test "$lt_cv_irix_exported_symbol" = yes; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='${wl}-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test "$ld_shlibs" = no && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([A-Za-z]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[123]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; haiku*) version_type=linux need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Add ABI-specific directories to the system library path. sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib" # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test "$hardcode_action" = relink || test "$inherit_rpath" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report which library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 $as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu else _lt_caught_CXX_error=yes fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu archive_cmds_need_lc_CXX=no allow_undefined_flag_CXX= always_export_symbols_CXX=no archive_expsym_cmds_CXX= compiler_needs_object_CXX=no export_dynamic_flag_spec_CXX= hardcode_direct_CXX=no hardcode_direct_absolute_CXX=no hardcode_libdir_flag_spec_CXX= hardcode_libdir_flag_spec_ld_CXX= hardcode_libdir_separator_CXX= hardcode_minus_L_CXX=no hardcode_shlibpath_var_CXX=unsupported hardcode_automatic_CXX=no inherit_rpath_CXX=no module_cmds_CXX= module_expsym_cmds_CXX= link_all_deplibs_CXX=unknown old_archive_cmds_CXX=$old_archive_cmds reload_flag_CXX=$reload_flag reload_cmds_CXX=$reload_cmds no_undefined_flag_CXX= whole_archive_flag_spec_CXX= enable_shared_with_static_runtimes_CXX=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o objext_CXX=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC compiler_CXX=$CC for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' else lt_prog_compiler_no_builtin_flag_CXX= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec_CXX= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } ld_shlibs_CXX=yes case $host_os in aix3*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds_CXX='' hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes file_list_spec_CXX='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct_CXX=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L_CXX=yes hardcode_libdir_flag_spec_CXX='-L$libdir' hardcode_libdir_separator_CXX= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec_CXX='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. always_export_symbols_CXX=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag_CXX='-berok' # Determine the default libpath from the value encoded in an empty # executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath__CXX+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath__CXX fi hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag_CXX="-z nodefs" archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath__CXX+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath__CXX fi hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag_CXX=' ${wl}-bernotok' allow_undefined_flag_CXX=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec_CXX='$convenience' fi archive_cmds_need_lc_CXX=yes # This is similar to how AIX traditionally builds its shared # libraries. archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag_CXX=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs_CXX=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec_CXX=' ' allow_undefined_flag_CXX=unsupported always_export_symbols_CXX=yes file_list_spec_CXX='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true' enable_shared_with_static_runtimes_CXX=yes # Don't use ranlib old_postinstall_cmds_CXX='chmod 644 $oldlib' postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ func_to_tool_file "$lt_outputfile"~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec_CXX='-L$libdir' export_dynamic_flag_spec_CXX='${wl}--export-all-symbols' allow_undefined_flag_CXX=unsupported always_export_symbols_CXX=no enable_shared_with_static_runtimes_CXX=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs_CXX=no fi ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes hardcode_shlibpath_var_CXX=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec_CXX='' fi link_all_deplibs_CXX=yes allow_undefined_flag_CXX="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" if test "$lt_cv_apple_cc_single_mod" != "yes"; then archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi else ld_shlibs_CXX=no fi ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; freebsd[12]*) # C++ shared libraries reported to be fairly broken before # switch to ELF ld_shlibs_CXX=no ;; freebsd-elf*) archive_cmds_need_lc_CXX=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions ld_shlibs_CXX=yes ;; gnu*) ;; haiku*) archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs_CXX=yes ;; hpux9*) hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' hardcode_libdir_separator_CXX=: export_dynamic_flag_spec_CXX='${wl}-E' hardcode_direct_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' hardcode_libdir_separator_CXX=: case $host_cpu in hppa*64*|ia64*) ;; *) export_dynamic_flag_spec_CXX='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no ;; *) hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; interix[3-9]*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi link_all_deplibs_CXX=yes ;; esac hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: inherit_rpath_CXX=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac archive_cmds_need_lc_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [1-5].* | *pgcpp\ [1-5].*) prelink_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' old_archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' archive_expsym_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec_CXX='-rpath $libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec_CXX='${wl}--export-dynamic' archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' hardcode_libdir_flag_spec_CXX='-R$libdir' whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object_CXX=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; m88k*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) ld_shlibs_CXX=yes ;; openbsd2*) # C++ shared libraries are fairly broken ld_shlibs_CXX=no ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no hardcode_direct_absolute_CXX=yes archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' export_dynamic_flag_spec_CXX='${wl}-E' whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else ld_shlibs_CXX=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' hardcode_libdir_separator_CXX=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; cxx*) case $host in osf3*) allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' ;; *) allow_undefined_flag_CXX=' -expect_unresolved \*' archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' hardcode_libdir_flag_spec_CXX='-rpath $libdir' ;; esac hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) archive_cmds_CXX='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ archive_cmds_need_lc_CXX=yes no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_shlibpath_var_CXX=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract' ;; esac link_all_deplibs_CXX=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then no_undefined_flag_CXX=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag_CXX='${wl}-z,text' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag_CXX='${wl}-z,text' allow_undefined_flag_CXX='${wl}-z,nodefs' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir' hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes export_dynamic_flag_spec_CXX='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~ '"$old_archive_cmds_CXX" reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~ '"$reload_cmds_CXX" ;; *) archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } test "$ld_shlibs_CXX" = no && can_build_shared=no GCC_CXX="$GXX" LD_CXX="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... # Dependencies to place before and after the object being linked: predep_objects_CXX= postdep_objects_CXX= predeps_CXX= postdeps_CXX= compiler_lib_search_path_CXX= cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; esac if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case ${prev}${p} in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test "$pre_test_object_deps_done" = no; then case ${prev} in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$compiler_lib_search_path_CXX"; then compiler_lib_search_path_CXX="${prev}${p}" else compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$postdeps_CXX"; then postdeps_CXX="${prev}${p}" else postdeps_CXX="${postdeps_CXX} ${prev}${p}" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$predep_objects_CXX"; then predep_objects_CXX="$p" else predep_objects_CXX="$predep_objects_CXX $p" fi else if test -z "$postdep_objects_CXX"; then postdep_objects_CXX="$p" else postdep_objects_CXX="$postdep_objects_CXX $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling CXX test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken case $host_os in interix[3-9]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. predep_objects_CXX= postdep_objects_CXX= postdeps_CXX= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then postdeps_CXX='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then postdeps_CXX='-library=Cstd -library=Crun' fi ;; esac ;; esac case " $postdeps_CXX " in *" -lc "*) archive_cmds_need_lc_CXX=no ;; esac compiler_lib_search_dirs_CXX= if test -n "${compiler_lib_search_path_CXX}"; then compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi lt_prog_compiler_wl_CXX= lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX= # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic_CXX='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic_CXX='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic_CXX='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all lt_prog_compiler_pic_CXX= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static_CXX= ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic_CXX=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac else case $host_os in aix[4-9]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' else lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic_CXX='-DDLL_EXPORT' ;; dgux*) case $cc_basename in ec++*) lt_prog_compiler_pic_CXX='-KPIC' ;; ghcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then lt_prog_compiler_pic_CXX='+Z' fi ;; aCC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic_CXX='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler lt_prog_compiler_wl_CXX='--backend -Wl,' lt_prog_compiler_pic_CXX='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fPIC' lt_prog_compiler_static_CXX='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fpic' lt_prog_compiler_static_CXX='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; xlc* | xlC* | bgxl[cC]* | mpixl[cC]*) # IBM XL 8.0, 9.0 on PPC and BlueGene lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-qpic' lt_prog_compiler_static_CXX='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) lt_prog_compiler_pic_CXX='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) lt_prog_compiler_wl_CXX='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 lt_prog_compiler_pic_CXX='-pic' ;; cxx*) # Digital/Compaq C++ lt_prog_compiler_wl_CXX='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x lt_prog_compiler_pic_CXX='-pic' lt_prog_compiler_static_CXX='-Bstatic' ;; lcc*) # Lucid lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 lt_prog_compiler_pic_CXX='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) lt_prog_compiler_can_build_shared_CXX=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic_CXX= ;; *) lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5 $as_echo "$lt_cv_prog_compiler_pic_CXX" >&6; } lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works_CXX=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works_CXX=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; } if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then case $lt_prog_compiler_pic_CXX in "" | " "*) ;; *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; esac else lt_prog_compiler_pic_CXX= lt_prog_compiler_can_build_shared_CXX=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works_CXX=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works_CXX=yes fi else lt_cv_prog_compiler_static_works_CXX=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; } if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then : else lt_prog_compiler_static_CXX= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_CXX=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_CXX=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' case $host_os in aix[4-9]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) export_symbols_cmds_CXX="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) ;; *) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms_CXX='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' ;; esac ;; *) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } test "$ld_shlibs_CXX" = no && can_build_shared=no with_gnu_ld_CXX=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc_CXX" in x|xyes) # Assume -lc should be added archive_cmds_need_lc_CXX=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds_CXX in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc_CXX+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl_CXX pic_flag=$lt_prog_compiler_pic_CXX compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag_CXX allow_undefined_flag_CXX= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc_CXX=no else lt_cv_archive_cmds_need_lc_CXX=yes fi allow_undefined_flag_CXX=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5 $as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; } archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[123]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; haiku*) version_type=linux need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Add ABI-specific directories to the system library path. sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib" # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action_CXX= if test -n "$hardcode_libdir_flag_spec_CXX" || test -n "$runpath_var_CXX" || test "X$hardcode_automatic_CXX" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct_CXX" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no && test "$hardcode_minus_L_CXX" != no; then # Linking always hardcodes the temporary library directory. hardcode_action_CXX=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action_CXX=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action_CXX=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 $as_echo "$hardcode_action_CXX" >&6; } if test "$hardcode_action_CXX" = relink || test "$inherit_rpath_CXX" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_commands="$ac_config_commands libtool" # Only expand once: CFLAG_VISIBILITY= HAVE_VISIBILITY=0 if test -n "$GCC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the -Werror option is usable" >&5 $as_echo_n "checking whether the -Werror option is usable... " >&6; } if ${gl_cv_cc_vis_werror+:} false; then : $as_echo_n "(cached) " >&6 else gl_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Werror" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_cc_vis_werror=yes else gl_cv_cc_vis_werror=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$gl_save_CFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_vis_werror" >&5 $as_echo "$gl_cv_cc_vis_werror" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for simple visibility declarations" >&5 $as_echo_n "checking for simple visibility declarations... " >&6; } if ${gl_cv_cc_visibility+:} false; then : $as_echo_n "(cached) " >&6 else gl_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fvisibility=hidden" if test $gl_cv_cc_vis_werror = yes; then CFLAGS="$CFLAGS -Werror" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ extern __attribute__((__visibility__("hidden"))) int hiddenvar; extern __attribute__((__visibility__("default"))) int exportedvar; extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); extern __attribute__((__visibility__("default"))) int exportedfunc (void); void dummyfunc (void) {} int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : gl_cv_cc_visibility=yes else gl_cv_cc_visibility=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$gl_save_CFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_visibility" >&5 $as_echo "$gl_cv_cc_visibility" >&6; } if test $gl_cv_cc_visibility = yes; then CFLAG_VISIBILITY="-fvisibility=hidden" HAVE_VISIBILITY=1 fi fi cat >>confdefs.h <<_ACEOF #define HAVE_VISIBILITY $HAVE_VISIBILITY _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ISO C++ 98 include files" >&5 $as_echo_n "checking for ISO C++ 98 include files... " >&6; } if ${ax_cv_cxx_stdcxx_98+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int main () { int x ; return 0; }, ax_cv_cxx_stdcxx_98=yes , ax_cv_cxx_stdcxx_98=no _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_stdcxx_98" >&5 $as_echo "$ax_cv_cxx_stdcxx_98" >&6; } if test "$ax_cv_cxx_stdcxx_98" = yes; then $as_echo "#define STDCXX_98_HEADERS /**/" >>confdefs.h fi if test "$ax_cv_cxx_stdcxx_98" = no; then as_fn_error $? "Your system lacks a new enough C++ compiler" "$LINENO" 5 fi if test -z "$MEMCACHED_BINARY"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether memcached executable path has been provided" >&5 $as_echo_n "checking whether memcached executable path has been provided... " >&6; } # Check whether --with-memcached was given. if test "${with_memcached+set}" = set; then : withval=$with_memcached; if test "$withval" != yes && test "$withval" != no; then : MEMCACHED_BINARY="$withval" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MEMCACHED_BINARY" >&5 $as_echo "$MEMCACHED_BINARY" >&6; } else MEMCACHED_BINARY="" { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if test "$withval" != no; then : # Extract the first word of "memcached", so it can be a program name with args. set dummy memcached; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MEMCACHED_BINARY+:} false; then : $as_echo_n "(cached) " >&6 else case $MEMCACHED_BINARY in [\\/]* | ?:[\\/]*) ac_cv_path_MEMCACHED_BINARY="$MEMCACHED_BINARY" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_MEMCACHED_BINARY="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi MEMCACHED_BINARY=$ac_cv_path_MEMCACHED_BINARY if test -n "$MEMCACHED_BINARY"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MEMCACHED_BINARY" >&5 $as_echo "$MEMCACHED_BINARY" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } # Extract the first word of "memcached", so it can be a program name with args. set dummy memcached; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MEMCACHED_BINARY+:} false; then : $as_echo_n "(cached) " >&6 else case $MEMCACHED_BINARY in [\\/]* | ?:[\\/]*) ac_cv_path_MEMCACHED_BINARY="$MEMCACHED_BINARY" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_MEMCACHED_BINARY="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi MEMCACHED_BINARY=$ac_cv_path_MEMCACHED_BINARY if test -n "$MEMCACHED_BINARY"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MEMCACHED_BINARY" >&5 $as_echo "$MEMCACHED_BINARY" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -f "$ac_cv_path_MEMCACHED_BINARY"; then : $as_echo "#define HAVE_MEMCACHED_BINARY 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define MEMCACHED_BINARY "$ac_cv_path_MEMCACHED_BINARY" _ACEOF else $as_echo "#define HAVE_MEMCACHED_BINARY 1" >>confdefs.h $as_echo "#define MEMCACHED_BINARY \"memcached/memcached\"" >>confdefs.h fi if test -z "$MEMCACHED_SASL_BINARY"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether memcached_sasl executable path has been provided" >&5 $as_echo_n "checking whether memcached_sasl executable path has been provided... " >&6; } # Check whether --with-memcached_sasl was given. if test "${with_memcached_sasl+set}" = set; then : withval=$with_memcached_sasl; if test "$withval" != yes && test "$withval" != no; then : MEMCACHED_SASL_BINARY="$withval" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MEMCACHED_SASL_BINARY" >&5 $as_echo "$MEMCACHED_SASL_BINARY" >&6; } else MEMCACHED_SASL_BINARY="" { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if test "$withval" != no; then : # Extract the first word of "memcached_sasl", so it can be a program name with args. set dummy memcached_sasl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MEMCACHED_SASL_BINARY+:} false; then : $as_echo_n "(cached) " >&6 else case $MEMCACHED_SASL_BINARY in [\\/]* | ?:[\\/]*) ac_cv_path_MEMCACHED_SASL_BINARY="$MEMCACHED_SASL_BINARY" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_MEMCACHED_SASL_BINARY="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi MEMCACHED_SASL_BINARY=$ac_cv_path_MEMCACHED_SASL_BINARY if test -n "$MEMCACHED_SASL_BINARY"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MEMCACHED_SASL_BINARY" >&5 $as_echo "$MEMCACHED_SASL_BINARY" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } # Extract the first word of "memcached_sasl", so it can be a program name with args. set dummy memcached_sasl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MEMCACHED_SASL_BINARY+:} false; then : $as_echo_n "(cached) " >&6 else case $MEMCACHED_SASL_BINARY in [\\/]* | ?:[\\/]*) ac_cv_path_MEMCACHED_SASL_BINARY="$MEMCACHED_SASL_BINARY" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_MEMCACHED_SASL_BINARY="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi MEMCACHED_SASL_BINARY=$ac_cv_path_MEMCACHED_SASL_BINARY if test -n "$MEMCACHED_SASL_BINARY"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MEMCACHED_SASL_BINARY" >&5 $as_echo "$MEMCACHED_SASL_BINARY" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -f "$ac_cv_path_MEMCACHED_SASL_BINARY"; then : $as_echo "#define HAVE_MEMCACHED_SASL_BINARY 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define MEMCACHED_SASL_BINARY "$ac_cv_path_MEMCACHED_SASL_BINARY" _ACEOF else $as_echo "#define HAVE_MEMCACHED_SASL_BINARY 0" >>confdefs.h $as_echo "#define MEMCACHED_SASL_BINARY 0" >>confdefs.h fi if test -z "$GEARMAND_BINARY"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gearmand executable path has been provided" >&5 $as_echo_n "checking whether gearmand executable path has been provided... " >&6; } # Check whether --with-gearmand was given. if test "${with_gearmand+set}" = set; then : withval=$with_gearmand; if test "$withval" != yes && test "$withval" != no; then : GEARMAND_BINARY="$withval" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GEARMAND_BINARY" >&5 $as_echo "$GEARMAND_BINARY" >&6; } else GEARMAND_BINARY="" { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if test "$withval" != no; then : # Extract the first word of "gearmand", so it can be a program name with args. set dummy gearmand; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_GEARMAND_BINARY+:} false; then : $as_echo_n "(cached) " >&6 else case $GEARMAND_BINARY in [\\/]* | ?:[\\/]*) ac_cv_path_GEARMAND_BINARY="$GEARMAND_BINARY" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_GEARMAND_BINARY="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi GEARMAND_BINARY=$ac_cv_path_GEARMAND_BINARY if test -n "$GEARMAND_BINARY"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GEARMAND_BINARY" >&5 $as_echo "$GEARMAND_BINARY" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } # Extract the first word of "gearmand", so it can be a program name with args. set dummy gearmand; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_GEARMAND_BINARY+:} false; then : $as_echo_n "(cached) " >&6 else case $GEARMAND_BINARY in [\\/]* | ?:[\\/]*) ac_cv_path_GEARMAND_BINARY="$GEARMAND_BINARY" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_GEARMAND_BINARY="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi GEARMAND_BINARY=$ac_cv_path_GEARMAND_BINARY if test -n "$GEARMAND_BINARY"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GEARMAND_BINARY" >&5 $as_echo "$GEARMAND_BINARY" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -f "$ac_cv_path_GEARMAND_BINARY"; then : $as_echo "#define HAVE_GEARMAND_BINARY 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define GEARMAND_BINARY "$ac_cv_path_GEARMAND_BINARY" _ACEOF else $as_echo "#define HAVE_GEARMAND_BINARY 0" >>confdefs.h $as_echo "#define GEARMAND_BINARY 0" >>confdefs.h fi if ${ax_cv_have_LIBGEARMAN+:} false; then : $as_echo_n "(cached) " >&6 else save_CPPFLAGS="$CPPFLAGS" save_LDFLAGS="$LDFLAGS" save_LIBS="$LIBS" if test "x$LIBGEARMAN_CPPFLAGS" != "x"; then : CPPFLAGS="$CPPFLAGS $LIBGEARMAN_CPPFLAGS" fi if test "x$LIBGEARMAN_LDFLAGS" != "x"; then : LDFLAGS="$LDFLAGS $LIBGEARMAN_LDFLAGS" fi ac_fn_c_check_header_mongrel "$LINENO" "libgearman/gearmand.h" "ac_cv_header_libgearman_gearmand_h" "$ac_includes_default" if test "x$ac_cv_header_libgearman_gearmand_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lgearman" >&5 $as_echo_n "checking for main in -lgearman... " >&6; } if ${ac_cv_lib_gearman_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgearman $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_gearman_main=yes else ac_cv_lib_gearman_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gearman_main" >&5 $as_echo "$ac_cv_lib_gearman_main" >&6; } if test "x$ac_cv_lib_gearman_main" = xyes; then : ax_cv_have_LIBGEARMAN=yes else ax_cv_have_LIBGEARMAN=no fi else ax_cv_have_LIBGEARMAN=no fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" fi if test "$ax_cv_have_LIBGEARMAN" = "yes"; then : $as_echo "#define HAVE_LIBGEARMAN 1" >>confdefs.h if true; then HAVE_LIBGEARMAN_TRUE= HAVE_LIBGEARMAN_FALSE='#' else HAVE_LIBGEARMAN_TRUE='#' HAVE_LIBGEARMAN_FALSE= fi $as_echo "#define HAVE_LIBGEARMAN 1" >>confdefs.h else if false; then HAVE_LIBGEARMAN_TRUE= HAVE_LIBGEARMAN_FALSE='#' else HAVE_LIBGEARMAN_TRUE='#' HAVE_LIBGEARMAN_FALSE= fi $as_echo "#define HAVE_LIBGEARMAN 0" >>confdefs.h fi if true; then BUILDING_LIBMEMCACHED_TRUE= BUILDING_LIBMEMCACHED_FALSE='#' else BUILDING_LIBMEMCACHED_TRUE='#' BUILDING_LIBMEMCACHED_FALSE= fi if false; then HAVE_LIBMEMCACHED_TRUE= HAVE_LIBMEMCACHED_FALSE='#' else HAVE_LIBMEMCACHED_TRUE='#' HAVE_LIBMEMCACHED_FALSE= fi if false; then HAVE_LIBDRIZZLE_TRUE= HAVE_LIBDRIZZLE_FALSE='#' else HAVE_LIBDRIZZLE_TRUE='#' HAVE_LIBDRIZZLE_FALSE= fi $as_echo "#define HAVE_LIBMEMCACHED 1" >>confdefs.h if false; then BUILDING_GEARMAN_TRUE= BUILDING_GEARMAN_FALSE='#' else BUILDING_GEARMAN_TRUE='#' BUILDING_GEARMAN_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getopt_long" >&5 $as_echo_n "checking for library containing getopt_long... " >&6; } if ${ac_cv_search_getopt_long+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char getopt_long (); int main () { return getopt_long (); ; return 0; } _ACEOF for ac_lib in '' gnugetopt; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_getopt_long=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_getopt_long+:} false; then : break fi done if ${ac_cv_search_getopt_long+:} false; then : else ac_cv_search_getopt_long=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getopt_long" >&5 $as_echo "$ac_cv_search_getopt_long" >&6; } ac_res=$ac_cv_search_getopt_long if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 $as_echo_n "checking for library containing gethostbyname... " >&6; } if ${ac_cv_search_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gethostbyname (); int main () { return gethostbyname (); ; return 0; } _ACEOF for ac_lib in '' nsl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_gethostbyname=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_gethostbyname+:} false; then : break fi done if ${ac_cv_search_gethostbyname+:} false; then : else ac_cv_search_gethostbyname=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 $as_echo "$ac_cv_search_gethostbyname" >&6; } ac_res=$ac_cv_search_gethostbyname if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi case "$target_os" in *linux*) if test "x$GCC" = "xyes"; then : LDFLAGS="$LDFLAGS -z relro -z now" fi ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ax_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5 $as_echo_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_join (); int main () { return pthread_join (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ax_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5 $as_echo "$ax_pthread_ok" >&6; } if test x"$ax_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthreads: Solaris/gcc # -mthreads: Mingw32/gcc, Lynx/gcc # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # ... -mt is also the pthreads flag for HP/aCC # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case "${host_cpu}-${host_os}" in *solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthreads/-mt/ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" ;; *-darwin*) ax_pthread_flags="-pthread $ax_pthread_flags" ;; esac if test x"$ax_pthread_ok" = xno; then for flag in $ax_pthread_flags; do case $flag in none) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5 $as_echo_n "checking whether pthreads work without any flags... " >&6; } ;; -*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5 $as_echo_n "checking whether pthreads work with $flag... " >&6; } PTHREAD_CFLAGS="$flag" ;; pthread-config) # Extract the first word of "pthread-config", so it can be a program name with args. set dummy pthread-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ax_pthread_config+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ax_pthread_config"; then ac_cv_prog_ax_pthread_config="$ax_pthread_config" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ax_pthread_config="yes" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_ax_pthread_config" && ac_cv_prog_ax_pthread_config="no" fi fi ax_pthread_config=$ac_cv_prog_ax_pthread_config if test -n "$ax_pthread_config"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_config" >&5 $as_echo "$ax_pthread_config" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test x"$ax_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag" >&5 $as_echo_n "checking for the pthreads library -l$flag... " >&6; } PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include static void routine(void *a) { a = 0; } static void *start_routine(void *a) { return a; } int main () { pthread_t th; pthread_attr_t attr; pthread_create(&th, 0, start_routine, 0); pthread_join(th, 0); pthread_attr_init(&attr); pthread_cleanup_push(routine, 0); pthread_cleanup_pop(0) /* ; */ ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ax_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5 $as_echo "$ax_pthread_ok" >&6; } if test "x$ax_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$ax_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5 $as_echo_n "checking for joinable pthread attribute... " >&6; } attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int attr = $attr; return attr /* ; */ ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : attr_name=$attr; break fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext done { $as_echo "$as_me:${as_lineno-$LINENO}: result: $attr_name" >&5 $as_echo "$attr_name" >&6; } if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then cat >>confdefs.h <<_ACEOF #define PTHREAD_CREATE_JOINABLE $attr_name _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5 $as_echo_n "checking if more special flags are required for pthreads... " >&6; } flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; *-osf* | *-hpux*) flag="-D_REENTRANT";; *solaris*) if test "$GCC" = "yes"; then flag="-D_REENTRANT" else flag="-mt -D_REENTRANT" fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5 $as_echo "${flag}" >&6; } if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PTHREAD_PRIO_INHERIT" >&5 $as_echo_n "checking for PTHREAD_PRIO_INHERIT... " >&6; } if ${ax_cv_PTHREAD_PRIO_INHERIT+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int i = PTHREAD_PRIO_INHERIT; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ax_cv_PTHREAD_PRIO_INHERIT=yes else ax_cv_PTHREAD_PRIO_INHERIT=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_PRIO_INHERIT" >&5 $as_echo "$ax_cv_PTHREAD_PRIO_INHERIT" >&6; } if test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"; then : $as_echo "#define HAVE_PTHREAD_PRIO_INHERIT 1" >>confdefs.h fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: must compile with xlc_r or cc_r if test x"$GCC" != xyes; then for ac_prog in xlc_r cc_r do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_PTHREAD_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PTHREAD_CC"; then ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_PTHREAD_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PTHREAD_CC=$ac_cv_prog_PTHREAD_CC if test -n "$PTHREAD_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5 $as_echo "$PTHREAD_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PTHREAD_CC" && break done test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}" else PTHREAD_CC=$CC fi else PTHREAD_CC="$CC" fi # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$ax_pthread_ok" = xyes; then $as_echo "#define HAVE_PTHREAD 1" >>confdefs.h : else ax_pthread_ok=no fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking the location of cstdint" >&5 $as_echo_n "checking the location of cstdint... " >&6; } ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu save_CXXFLAGS="${CXXFLAGS}" CXXFLAGS="${CXX_STANDARD} ${CXXFLAGS}" ac_cv_cxx_cstdint="" ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # AC_CACHE_CHECK([for location of cstdint], [ac_cv_cxx_cstdint], # [ # Look for cstdint cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { uint32_t t ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_cxx_cstdint="" else # Look for tr1/cstdint cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { uint32_t t ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_cxx_cstdint="" else # Look for boost/cstdint.hpp cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { uint32_t t ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_cxx_cstdint="" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # ]) ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu CXXFLAGS="${save_CXXFLAGS}" if test -n "$ac_cv_cxx_cstdint"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_cstdint" >&5 $as_echo "$ac_cv_cxx_cstdint" >&6; } else ac_cv_cxx_cstdint="" { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find a cstdint header." >&5 $as_echo "$as_me: WARNING: Could not find a cstdint header." >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_cstdint" >&5 $as_echo "$ac_cv_cxx_cstdint" >&6; } fi cat >>confdefs.h <<_ACEOF #define CSTDINT_H $ac_cv_cxx_cstdint _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking the location of cinttypes" >&5 $as_echo_n "checking the location of cinttypes... " >&6; } save_CXXFLAGS="${CXXFLAGS}" CXXFLAGS="${CXX_STANDARD} ${CXXFLAGS}" ac_cv_cxx_cinttypes="" ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # AC_CACHE_CHECK([for location of cinttypes], [ac_cv_cxx_cinttypes], # [ # Look for cinttypes cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { uint32_t foo= UINT32_C(1) ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_cxx_cinttypes="" else # Look for tr1/cinttypes cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { uint32_t foo= UINT32_C(1) ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_cxx_cinttypes="" else # Look for boost/cinttypes.hpp cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { uint32_t foo= UINT32_C(1) ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_cxx_cinttypes="" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # ]) ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu CXXFLAGS="${save_CXXFLAGS}" if test -n "$ac_cv_cxx_cinttypes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_cinttypes" >&5 $as_echo "$ac_cv_cxx_cinttypes" >&6; } else ac_cv_cxx_cinttypes="" { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find a cinttypes header." >&5 $as_echo "$as_me: WARNING: Could not find a cinttypes header." >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_cinttypes" >&5 $as_echo "$ac_cv_cxx_cinttypes" >&6; } fi $as_echo "#define __STDC_LIMIT_MACROS 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define CINTTYPES_H $ac_cv_cxx_cinttypes _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for htonll" >&5 $as_echo_n "checking for htonll... " >&6; } if ${ac_cv_have_htonll+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { return htonll(0) ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_have_htonll=yes else ac_cv_have_htonll=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_htonll" >&5 $as_echo "$ac_cv_have_htonll" >&6; } ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test "x$ac_cv_have_htonll" = "xyes"; then : $as_echo "#define HAVE_HTONLL 1" >>confdefs.h fi if test "x$ac_cv_have_htonll" = "xno"; then BUILD_BYTEORDER_TRUE= BUILD_BYTEORDER_FALSE='#' else BUILD_BYTEORDER_TRUE='#' BUILD_BYTEORDER_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working SO_SNDTIMEO" >&5 $as_echo_n "checking for working SO_SNDTIMEO... " >&6; } if ${ac_cv_have_so_sndtimeo+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test "$cross_compiling" = yes; then : ac_cv_have_so_sndtimeo=yes else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include int main () { int sock = socket(AF_INET, SOCK_STREAM, 0); struct timeval waittime; waittime.tv_sec= 0; waittime.tv_usec= 500; if (setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &waittime, (socklen_t)sizeof(struct timeval)) == -1) { if (errno == ENOPROTOOPT) { return 1; } } return 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_have_so_sndtimeo=yes else ac_cv_have_so_sndtimeo=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi if test "x$ac_cv_have_so_sndtimeo" = "xyes"; then : $as_echo "#define HAVE_SNDTIMEO 1" >>confdefs.h fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_so_sndtimeo" >&5 $as_echo "$ac_cv_have_so_sndtimeo" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working SO_RCVTIMEO" >&5 $as_echo_n "checking for working SO_RCVTIMEO... " >&6; } if ${ac_cv_have_so_rcvtimeo+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test "$cross_compiling" = yes; then : ac_cv_have_so_rcvtimeo=yes else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include int main () { int sock = socket(AF_INET, SOCK_STREAM, 0); struct timeval waittime; waittime.tv_sec= 0; waittime.tv_usec= 500; if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &waittime, (socklen_t)sizeof(struct timeval)) == -1) { if (errno == ENOPROTOOPT) { return 1; } } return 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_have_so_rcvtimeo=yes else ac_cv_have_so_rcvtimeo=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi if test "x$ac_cv_have_so_rcvtimeo" = "xyes"; then : $as_echo "#define HAVE_RCVTIMEO 1" >>confdefs.h fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_so_rcvtimeo" >&5 $as_echo "$ac_cv_have_so_rcvtimeo" >&6; } # Check whether --enable-hsieh_hash was given. if test "${enable_hsieh_hash+set}" = set; then : enableval=$enable_hsieh_hash; ac_cv_enable_hsieh_hash=yes else ac_cv_enable_hsieh_hash=no fi if test "$ac_cv_enable_hsieh_hash" = "yes"; then : $as_echo "#define HAVE_HSIEH_HASH 1" >>confdefs.h fi if test "$ac_cv_enable_hsieh_hash" = "yes"; then INCLUDE_HSIEH_SRC_TRUE= INCLUDE_HSIEH_SRC_FALSE='#' else INCLUDE_HSIEH_SRC_TRUE='#' INCLUDE_HSIEH_SRC_FALSE= fi # Check whether --enable-murmur_hash was given. if test "${enable_murmur_hash+set}" = set; then : enableval=$enable_murmur_hash; ac_cv_enable_murmur_hash=no else ac_cv_enable_murmur_hash=yes fi if test "$ac_cv_enable_murmur_hash" = "yes"; then : $as_echo "#define HAVE_MURMUR_HASH 1" >>confdefs.h fi if test "$ac_cv_enable_murmur_hash" = "yes"; then INCLUDE_MURMUR_SRC_TRUE= INCLUDE_MURMUR_SRC_FALSE='#' else INCLUDE_MURMUR_SRC_TRUE='#' INCLUDE_MURMUR_SRC_FALSE= fi # Check whether --enable-fnv64_hash was given. if test "${enable_fnv64_hash+set}" = set; then : enableval=$enable_fnv64_hash; ac_cv_enable_fnv64_hash=no else ac_cv_enable_fnv64_hash=yes fi if test "$ac_cv_enable_fnv64_hash" = "yes"; then : $as_echo "#define HAVE_FNV64_HASH 1" >>confdefs.h fi # Check whether --enable-memaslap was given. if test "${enable_memaslap+set}" = set; then : enableval=$enable_memaslap; ac_cv_enable_memaslap=yes else ac_cv_enable_memaslap=no fi if test "$ac_cv_enable_memaslap" = "yes"; then BUILD_MEMASLAP_TRUE= BUILD_MEMASLAP_FALSE='#' else BUILD_MEMASLAP_TRUE='#' BUILD_MEMASLAP_FALSE= fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for supported struct padding" >&5 $as_echo_n "checking for supported struct padding... " >&6; } if ${ac_cv_supported_struct_padding+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include "libmemcached/memcached/protocol_binary.h" int main () { protocol_binary_request_set request; int a = 1; switch (a) { case sizeof(request): case sizeof(request.bytes): break; default: a = 2; } ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_supported_struct_padding=no else ac_cv_supported_struct_padding=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_supported_struct_padding" >&5 $as_echo "$ac_cv_supported_struct_padding" >&6; } ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test "x$ac_cv_supported_struct_padding" = "xno"; then : as_fn_error $? "Unsupported struct padding done by compiler." "$LINENO" 5 fi # Check whether --enable-deprecated was given. if test "${enable_deprecated+set}" = set; then : enableval=$enable_deprecated; ac_enable_deprecated="$enableval" else ac_enable_deprecated="no" fi if test "$ac_enable_deprecated" = "yes"; then : DEPRECATED="#define MEMCACHED_ENABLE_DEPRECATED 1" fi for ac_func in alarm do : ac_fn_cxx_check_func "$LINENO" "alarm" "ac_cv_func_alarm" if test "x$ac_cv_func_alarm" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ALARM 1 _ACEOF fi done for ac_func in dup2 do : ac_fn_cxx_check_func "$LINENO" "dup2" "ac_cv_func_dup2" if test "x$ac_cv_func_dup2" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DUP2 1 _ACEOF fi done for ac_func in getline do : ac_fn_cxx_check_func "$LINENO" "getline" "ac_cv_func_getline" if test "x$ac_cv_func_getline" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETLINE 1 _ACEOF fi done for ac_func in gettimeofday do : ac_fn_cxx_check_func "$LINENO" "gettimeofday" "ac_cv_func_gettimeofday" if test "x$ac_cv_func_gettimeofday" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETTIMEOFDAY 1 _ACEOF fi done for ac_func in memchr do : ac_fn_cxx_check_func "$LINENO" "memchr" "ac_cv_func_memchr" if test "x$ac_cv_func_memchr" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MEMCHR 1 _ACEOF fi done for ac_func in memmove do : ac_fn_cxx_check_func "$LINENO" "memmove" "ac_cv_func_memmove" if test "x$ac_cv_func_memmove" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MEMMOVE 1 _ACEOF fi done for ac_func in memset do : ac_fn_cxx_check_func "$LINENO" "memset" "ac_cv_func_memset" if test "x$ac_cv_func_memset" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MEMSET 1 _ACEOF fi done for ac_func in pipe2 do : ac_fn_cxx_check_func "$LINENO" "pipe2" "ac_cv_func_pipe2" if test "x$ac_cv_func_pipe2" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PIPE2 1 _ACEOF fi done for ac_func in select do : ac_fn_cxx_check_func "$LINENO" "select" "ac_cv_func_select" if test "x$ac_cv_func_select" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SELECT 1 _ACEOF fi done for ac_func in setenv do : ac_fn_cxx_check_func "$LINENO" "setenv" "ac_cv_func_setenv" if test "x$ac_cv_func_setenv" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SETENV 1 _ACEOF fi done for ac_func in socket do : ac_fn_cxx_check_func "$LINENO" "socket" "ac_cv_func_socket" if test "x$ac_cv_func_socket" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SOCKET 1 _ACEOF fi done for ac_func in sqrt do : ac_fn_cxx_check_func "$LINENO" "sqrt" "ac_cv_func_sqrt" if test "x$ac_cv_func_sqrt" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SQRT 1 _ACEOF fi done for ac_func in strcasecmp do : ac_fn_cxx_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp" if test "x$ac_cv_func_strcasecmp" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRCASECMP 1 _ACEOF fi done for ac_func in strchr do : ac_fn_cxx_check_func "$LINENO" "strchr" "ac_cv_func_strchr" if test "x$ac_cv_func_strchr" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRCHR 1 _ACEOF fi done for ac_func in strdup do : ac_fn_cxx_check_func "$LINENO" "strdup" "ac_cv_func_strdup" if test "x$ac_cv_func_strdup" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRDUP 1 _ACEOF fi done for ac_func in strerror do : ac_fn_cxx_check_func "$LINENO" "strerror" "ac_cv_func_strerror" if test "x$ac_cv_func_strerror" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRERROR 1 _ACEOF fi done for ac_func in strtol do : ac_fn_cxx_check_func "$LINENO" "strtol" "ac_cv_func_strtol" if test "x$ac_cv_func_strtol" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRTOL 1 _ACEOF fi done for ac_func in strtoul do : ac_fn_cxx_check_func "$LINENO" "strtoul" "ac_cv_func_strtoul" if test "x$ac_cv_func_strtoul" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRTOUL 1 _ACEOF fi done for ac_func in strtoull do : ac_fn_cxx_check_func "$LINENO" "strtoull" "ac_cv_func_strtoull" if test "x$ac_cv_func_strtoull" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRTOULL 1 _ACEOF fi done for ac_header in arpa/inet.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "arpa/inet.h" "ac_cv_header_arpa_inet_h" "$ac_includes_default" if test "x$ac_cv_header_arpa_inet_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ARPA_INET_H 1 _ACEOF fi done for ac_header in errno.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "errno.h" "ac_cv_header_errno_h" "$ac_includes_default" if test "x$ac_cv_header_errno_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ERRNO_H 1 _ACEOF fi done for ac_header in execinfo.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "execinfo.h" "ac_cv_header_execinfo_h" "$ac_includes_default" if test "x$ac_cv_header_execinfo_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_EXECINFO_H 1 _ACEOF fi done for ac_header in fcntl.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "fcntl.h" "ac_cv_header_fcntl_h" "$ac_includes_default" if test "x$ac_cv_header_fcntl_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_FCNTL_H 1 _ACEOF fi done for ac_header in inttypes.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "inttypes.h" "ac_cv_header_inttypes_h" "$ac_includes_default" if test "x$ac_cv_header_inttypes_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_INTTYPES_H 1 _ACEOF fi done for ac_header in libintl.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "libintl.h" "ac_cv_header_libintl_h" "$ac_includes_default" if test "x$ac_cv_header_libintl_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBINTL_H 1 _ACEOF fi done for ac_header in limits.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "limits.h" "ac_cv_header_limits_h" "$ac_includes_default" if test "x$ac_cv_header_limits_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIMITS_H 1 _ACEOF fi done for ac_header in malloc.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "malloc.h" "ac_cv_header_malloc_h" "$ac_includes_default" if test "x$ac_cv_header_malloc_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MALLOC_H 1 _ACEOF fi done for ac_header in math.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "math.h" "ac_cv_header_math_h" "$ac_includes_default" if test "x$ac_cv_header_math_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MATH_H 1 _ACEOF fi done for ac_header in netdb.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "netdb.h" "ac_cv_header_netdb_h" "$ac_includes_default" if test "x$ac_cv_header_netdb_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NETDB_H 1 _ACEOF fi done for ac_header in netinet/in.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "netinet/in.h" "ac_cv_header_netinet_in_h" "$ac_includes_default" if test "x$ac_cv_header_netinet_in_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NETINET_IN_H 1 _ACEOF fi done for ac_header in pthread.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" if test "x$ac_cv_header_pthread_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PTHREAD_H 1 _ACEOF fi done for ac_header in stdarg.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "stdarg.h" "ac_cv_header_stdarg_h" "$ac_includes_default" if test "x$ac_cv_header_stdarg_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDARG_H 1 _ACEOF fi done for ac_header in stddef.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "stddef.h" "ac_cv_header_stddef_h" "$ac_includes_default" if test "x$ac_cv_header_stddef_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDDEF_H 1 _ACEOF fi done for ac_header in stdlib.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF fi done for ac_header in sys/time.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default" if test "x$ac_cv_header_sys_time_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_TIME_H 1 _ACEOF fi done for ac_header in unistd.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default" if test "x$ac_cv_header_unistd_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_UNISTD_H 1 _ACEOF fi done for ac_header in cxxabi.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "cxxabi.h" "ac_cv_header_cxxabi_h" "$ac_includes_default" if test "x$ac_cv_header_cxxabi_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_CXXABI_H 1 _ACEOF $as_echo "#define HAVE_CXXABI_H 1" >>confdefs.h else $as_echo "#define HAVE_CXXABI_H 0" >>confdefs.h fi done for ac_header in sys/sysctl.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "sys/sysctl.h" "ac_cv_header_sys_sysctl_h" "$ac_includes_default" if test "x$ac_cv_header_sys_sysctl_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_SYSCTL_H 1 _ACEOF fi done ac_fn_cxx_check_header_mongrel "$LINENO" "umem.h" "ac_cv_header_umem_h" "$ac_includes_default" if test "x$ac_cv_header_umem_h" = xyes; then : $as_echo "#define HAVE_UMEM_H 1" >>confdefs.h build_cache=no else build_cache=yes fi if test "x$build_cache" = "xyes"; then BUILD_CACHE_TRUE= BUILD_CACHE_FALSE='#' else BUILD_CACHE_TRUE='#' BUILD_CACHE_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler vendor" >&5 $as_echo_n "checking for C++ compiler vendor... " >&6; } if ${ax_cv_cxx_compiler_vendor+:} false; then : $as_echo_n "(cached) " >&6 else # note: don't check for gcc first since some other compilers define __GNUC__ vendors="intel: __ICC,__ECC,__INTEL_COMPILER ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__ pathscale: __PATHCC__,__PATHSCALE__ clang: __clang__ gnu: __GNUC__ sun: __SUNPRO_C,__SUNPRO_CC hp: __HP_cc,__HP_aCC dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland: __BORLANDC__,__TURBOC__ comeau: __COMO__ cray: _CRAYC kai: __KCC lcc: __LCC__ sgi: __sgi,sgi microsoft: _MSC_VER metrowerks: __MWERKS__ watcom: __WATCOMC__ portland: __PGI unknown: UNKNOWN" for ventest in $vendors; do case $ventest in *:) vendor=$ventest; continue ;; *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;; esac cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #if !($vencpp) thisisanerror; #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done ax_cv_cxx_compiler_vendor=`echo $vendor | cut -d: -f1` fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compiler_vendor" >&5 $as_echo "$ax_cv_cxx_compiler_vendor" >&6; } # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 $as_echo_n "checking for working alloca.h... " >&6; } if ${ac_cv_working_alloca_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { char *p = (char *) alloca (2 * sizeof (int)); if (p) return 0; ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_working_alloca_h=yes else ac_cv_working_alloca_h=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 $as_echo "$ac_cv_working_alloca_h" >&6; } if test $ac_cv_working_alloca_h = yes; then $as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 $as_echo_n "checking for alloca... " >&6; } if ${ac_cv_func_alloca_works+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __GNUC__ # define alloca __builtin_alloca #else # ifdef _MSC_VER # include # define alloca _alloca # else # ifdef HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ void *alloca (size_t); # endif # endif # endif # endif #endif int main () { char *p = (char *) alloca (1); if (p) return 0; ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_func_alloca_works=yes else ac_cv_func_alloca_works=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 $as_echo "$ac_cv_func_alloca_works" >&6; } if test $ac_cv_func_alloca_works = yes; then $as_echo "#define HAVE_ALLOCA 1" >>confdefs.h else # The SVR3 libPW and SVR4 libucb both contain incompatible functions # that cause trouble. Some versions do not even contain alloca or # contain a buggy version. If you still want to use their alloca, # use ar to extract alloca.o from them instead of compiling alloca.c. ALLOCA=\${LIBOBJDIR}alloca.$ac_objext $as_echo "#define C_ALLOCA 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 $as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } if ${ac_cv_os_cray+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined CRAY && ! defined CRAY2 webecray #else wenotbecray #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "webecray" >/dev/null 2>&1; then : ac_cv_os_cray=yes else ac_cv_os_cray=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 $as_echo "$ac_cv_os_cray" >&6; } if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define CRAY_STACKSEG_END $ac_func _ACEOF break fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 $as_echo_n "checking stack direction for C alloca... " >&6; } if ${ac_cv_c_stack_direction+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_c_stack_direction=0 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int find_stack_direction () { static char *addr = 0; auto char dummy; if (addr == 0) { addr = &dummy; return find_stack_direction (); } else return (&dummy > addr) ? 1 : -1; } int main () { return find_stack_direction () < 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : ac_cv_c_stack_direction=1 else ac_cv_c_stack_direction=-1 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 $as_echo "$ac_cv_c_stack_direction" >&6; } cat >>confdefs.h <<_ACEOF #define STACK_DIRECTION $ac_cv_c_stack_direction _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for error_at_line" >&5 $as_echo_n "checking for error_at_line... " >&6; } if ${ac_cv_lib_error_at_line+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { error_at_line (0, 0, "", 0, "an error occurred"); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_error_at_line=yes else ac_cv_lib_error_at_line=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_error_at_line" >&5 $as_echo "$ac_cv_lib_error_at_line" >&6; } if test $ac_cv_lib_error_at_line = no; then case " $LIBOBJS " in *" error.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS error.$ac_objext" ;; esac fi ac_fn_cxx_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" if test "x$ac_cv_type_pid_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF fi for ac_header in vfork.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "vfork.h" "ac_cv_header_vfork_h" "$ac_includes_default" if test "x$ac_cv_header_vfork_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_VFORK_H 1 _ACEOF fi done for ac_func in fork vfork do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done if test "x$ac_cv_func_fork" = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working fork" >&5 $as_echo_n "checking for working fork... " >&6; } if ${ac_cv_func_fork_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_fork_works=cross else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* By Ruediger Kuhlmann. */ return fork () < 0; ; return 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : ac_cv_func_fork_works=yes else ac_cv_func_fork_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_fork_works" >&5 $as_echo "$ac_cv_func_fork_works" >&6; } else ac_cv_func_fork_works=$ac_cv_func_fork fi if test "x$ac_cv_func_fork_works" = xcross; then case $host in *-*-amigaos* | *-*-msdosdjgpp*) # Override, as these systems have only a dummy fork() stub ac_cv_func_fork_works=no ;; *) ac_cv_func_fork_works=yes ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5 $as_echo "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;} fi ac_cv_func_vfork_works=$ac_cv_func_vfork if test "x$ac_cv_func_vfork" = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working vfork" >&5 $as_echo_n "checking for working vfork... " >&6; } if ${ac_cv_func_vfork_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_vfork_works=cross else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Thanks to Paul Eggert for this test. */ $ac_includes_default #include #ifdef HAVE_VFORK_H # include #endif /* On some sparc systems, changes by the child to local and incoming argument registers are propagated back to the parent. The compiler is told about this with #include , but some compilers (e.g. gcc -O) don't grok . Test for this by using a static variable whose address is put into a register that is clobbered by the vfork. */ static void #ifdef __cplusplus sparc_address_test (int arg) # else sparc_address_test (arg) int arg; #endif { static pid_t child; if (!child) { child = vfork (); if (child < 0) { perror ("vfork"); _exit(2); } if (!child) { arg = getpid(); write(-1, "", 0); _exit (arg); } } } int main () { pid_t parent = getpid (); pid_t child; sparc_address_test (0); child = vfork (); if (child == 0) { /* Here is another test for sparc vfork register problems. This test uses lots of local variables, at least as many local variables as main has allocated so far including compiler temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should reuse the register of parent for one of the local variables, since it will think that parent can't possibly be used any more in this routine. Assigning to the local variable will thus munge parent in the parent process. */ pid_t p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); /* Convince the compiler that p..p7 are live; otherwise, it might use the same hardware register for all 8 local variables. */ if (p != p1 || p != p2 || p != p3 || p != p4 || p != p5 || p != p6 || p != p7) _exit(1); /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent from child file descriptors. If the child closes a descriptor before it execs or exits, this munges the parent's descriptor as well. Test for this by closing stdout in the child. */ _exit(close(fileno(stdout)) != 0); } else { int status; struct stat st; while (wait(&status) != child) ; return ( /* Was there some problem with vforking? */ child < 0 /* Did the child fail? (This shouldn't happen.) */ || status /* Did the vfork/compiler bug occur? */ || parent != getpid() /* Did the file descriptor bug occur? */ || fstat(fileno(stdout), &st) != 0 ); } } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : ac_cv_func_vfork_works=yes else ac_cv_func_vfork_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_vfork_works" >&5 $as_echo "$ac_cv_func_vfork_works" >&6; } fi; if test "x$ac_cv_func_fork_works" = xcross; then ac_cv_func_vfork_works=$ac_cv_func_vfork { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5 $as_echo "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;} fi if test "x$ac_cv_func_vfork_works" = xyes; then $as_echo "#define HAVE_WORKING_VFORK 1" >>confdefs.h else $as_echo "#define vfork fork" >>confdefs.h fi if test "x$ac_cv_func_fork_works" = xyes; then $as_echo "#define HAVE_WORKING_FORK 1" >>confdefs.h fi for ac_header in stdlib.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 $as_echo_n "checking for GNU libc compatible malloc... " >&6; } if ${ac_cv_func_malloc_0_nonnull+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_malloc_0_nonnull=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *malloc (); #endif int main () { return ! malloc (0); ; return 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : ac_cv_func_malloc_0_nonnull=yes else ac_cv_func_malloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 $as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } if test $ac_cv_func_malloc_0_nonnull = yes; then : $as_echo "#define HAVE_MALLOC 1" >>confdefs.h else $as_echo "#define HAVE_MALLOC 0" >>confdefs.h case " $LIBOBJS " in *" malloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;; esac $as_echo "#define malloc rpl_malloc" >>confdefs.h fi for ac_header in stdlib.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible realloc" >&5 $as_echo_n "checking for GNU libc compatible realloc... " >&6; } if ${ac_cv_func_realloc_0_nonnull+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_realloc_0_nonnull=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *realloc (); #endif int main () { return ! realloc (0, 0); ; return 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : ac_cv_func_realloc_0_nonnull=yes else ac_cv_func_realloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_realloc_0_nonnull" >&5 $as_echo "$ac_cv_func_realloc_0_nonnull" >&6; } if test $ac_cv_func_realloc_0_nonnull = yes; then : $as_echo "#define HAVE_REALLOC 1" >>confdefs.h else $as_echo "#define HAVE_REALLOC 0" >>confdefs.h case " $LIBOBJS " in *" realloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS realloc.$ac_objext" ;; esac $as_echo "#define realloc rpl_realloc" >>confdefs.h fi ac_fn_cxx_check_decl "$LINENO" "strerror_r" "ac_cv_have_decl_strerror_r" "$ac_includes_default" if test "x$ac_cv_have_decl_strerror_r" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRERROR_R $ac_have_decl _ACEOF for ac_func in strerror_r do : ac_fn_cxx_check_func "$LINENO" "strerror_r" "ac_cv_func_strerror_r" if test "x$ac_cv_func_strerror_r" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRERROR_R 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strerror_r returns char *" >&5 $as_echo_n "checking whether strerror_r returns char *... " >&6; } if ${ac_cv_func_strerror_r_char_p+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_func_strerror_r_char_p=no if test $ac_cv_have_decl_strerror_r = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { char buf[100]; char x = *strerror_r (0, buf, sizeof buf); char *p = strerror_r (0, buf, sizeof buf); return !p || x; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_func_strerror_r_char_p=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else # strerror_r is not declared. Choose between # systems that have relatively inaccessible declarations for the # function. BeOS and DEC UNIX 4.0 fall in this category, but the # former has a strerror_r that returns char*, while the latter # has a strerror_r that returns `int'. # This test should segfault on the DEC system. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default extern char *strerror_r (); int main () { char buf[100]; char x = *strerror_r (0, buf, sizeof buf); return ! isalpha (x); ; return 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : ac_cv_func_strerror_r_char_p=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strerror_r_char_p" >&5 $as_echo "$ac_cv_func_strerror_r_char_p" >&6; } if test $ac_cv_func_strerror_r_char_p = yes; then $as_echo "#define STRERROR_R_CHAR_P 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 $as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } if ${ac_cv_header_stdbool_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef bool "error: bool is not defined" #endif #ifndef false "error: false is not defined" #endif #if false "error: false is not 0" #endif #ifndef true "error: true is not defined" #endif #if true != 1 "error: true is not 1" #endif #ifndef __bool_true_false_are_defined "error: __bool_true_false_are_defined is not defined" #endif struct s { _Bool s: 1; _Bool t; } s; char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; char d[(bool) 0.5 == true ? 1 : -1]; /* See body of main program for 'e'. */ char f[(_Bool) 0.0 == false ? 1 : -1]; char g[true]; char h[sizeof (_Bool)]; char i[sizeof s.t]; enum { j = false, k = true, l = false * true, m = true * 256 }; /* The following fails for HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html */ _Bool q = true; _Bool *pq = &q; int main () { bool e = &s; *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + !m + !n + !o + !p + !q + !pq); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_header_stdbool_h=yes else ac_cv_header_stdbool_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 $as_echo "$ac_cv_header_stdbool_h" >&6; } ac_fn_cxx_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" if test "x$ac_cv_type__Bool" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE__BOOL 1 _ACEOF fi if test $ac_cv_header_stdbool_h = yes; then $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h fi ac_fn_c_find_intX_t "$LINENO" "16" "ac_cv_c_int16_t" case $ac_cv_c_int16_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define int16_t $ac_cv_c_int16_t _ACEOF ;; esac ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t" case $ac_cv_c_int32_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define int32_t $ac_cv_c_int32_t _ACEOF ;; esac ac_fn_c_find_intX_t "$LINENO" "64" "ac_cv_c_int64_t" case $ac_cv_c_int64_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define int64_t $ac_cv_c_int64_t _ACEOF ;; esac ac_fn_c_find_intX_t "$LINENO" "8" "ac_cv_c_int8_t" case $ac_cv_c_int8_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define int8_t $ac_cv_c_int8_t _ACEOF ;; esac ac_fn_cxx_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" if test "x$ac_cv_type_off_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define off_t long int _ACEOF fi ac_fn_cxx_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" if test "x$ac_cv_type_pid_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF fi ac_fn_cxx_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" if test "x$ac_cv_type_ssize_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define ssize_t int _ACEOF fi ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t" case $ac_cv_c_uint16_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define uint16_t $ac_cv_c_uint16_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" case $ac_cv_c_uint32_t in #( no|yes) ;; #( *) $as_echo "#define _UINT32_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint32_t $ac_cv_c_uint32_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t" case $ac_cv_c_uint64_t in #( no|yes) ;; #( *) $as_echo "#define _UINT64_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint64_t $ac_cv_c_uint64_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t" case $ac_cv_c_uint8_t in #( no|yes) ;; #( *) $as_echo "#define _UINT8_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint8_t $ac_cv_c_uint8_t _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working volatile" >&5 $as_echo_n "checking for working volatile... " >&6; } if ${ac_cv_c_volatile+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { volatile int x; int * volatile y = (int *) 0; return !x && !y; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_c_volatile=yes else ac_cv_c_volatile=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_volatile" >&5 $as_echo "$ac_cv_c_volatile" >&6; } if test $ac_cv_c_volatile = no; then $as_echo "#define volatile /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5 $as_echo_n "checking for C/C++ restrict keyword... " >&6; } if ${ac_cv_c_restrict+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_restrict=no # The order here caters to the fact that C++ does not require restrict. for ac_kw in __restrict __restrict__ _Restrict restrict; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ typedef int * int_ptr; int foo (int_ptr $ac_kw ip) { return ip[0]; } int main () { int s[1]; int * $ac_kw t = s; t[0] = 0; return foo(t) ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_c_restrict=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_restrict" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5 $as_echo "$ac_cv_c_restrict" >&6; } case $ac_cv_c_restrict in restrict) ;; no) $as_echo "#define restrict /**/" >>confdefs.h ;; *) cat >>confdefs.h <<_ACEOF #define restrict $ac_cv_c_restrict _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GCC C++ ABI name demangling" >&5 $as_echo_n "checking whether the compiler supports GCC C++ ABI name demangling... " >&6; } if ${ax_cv_cxx_gcc_abi_demangle+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include template class A {}; int main () { A instance; int status = 0; char* c_name = 0; c_name = abi::__cxa_demangle(typeid(instance).name(), 0, 0, &status); std::string name(c_name); ::free(c_name); return name == "A"; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ax_cv_cxx_gcc_abi_demangle=yes else ax_cv_cxx_gcc_abi_demangle=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_gcc_abi_demangle" >&5 $as_echo "$ax_cv_cxx_gcc_abi_demangle" >&6; } if test "$ax_cv_cxx_gcc_abi_demangle" = yes; then $as_echo "#define HAVE_GCC_ABI_DEMANGLE 1" >>confdefs.h fi if ${ax_cv_have_LIBSASL+:} false; then : $as_echo_n "(cached) " >&6 else save_CPPFLAGS="$CPPFLAGS" save_LDFLAGS="$LDFLAGS" save_LIBS="$LIBS" if test "x$LIBSASL_CPPFLAGS" != "x"; then : CPPFLAGS="$CPPFLAGS $LIBSASL_CPPFLAGS" fi if test "x$LIBSASL_LDFLAGS" != "x"; then : LDFLAGS="$LDFLAGS $LIBSASL_LDFLAGS" fi ac_fn_cxx_check_header_mongrel "$LINENO" "sasl/sasl.h" "ac_cv_header_sasl_sasl_h" "$ac_includes_default" if test "x$ac_cv_header_sasl_sasl_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lsasl2" >&5 $as_echo_n "checking for main in -lsasl2... " >&6; } if ${ac_cv_lib_sasl2_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsasl2 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_sasl2_main=yes else ac_cv_lib_sasl2_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sasl2_main" >&5 $as_echo "$ac_cv_lib_sasl2_main" >&6; } if test "x$ac_cv_lib_sasl2_main" = xyes; then : ax_cv_have_LIBSASL=yes else ax_cv_have_LIBSASL=no fi else ax_cv_have_LIBSASL=no fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" fi if test "$ax_cv_have_LIBSASL" = "yes"; then : $as_echo "#define HAVE_LIBSASL 1" >>confdefs.h LIBSASL_LDFLAGS="-lsasl2" ax_cv_sasl=yes else ax_cv_sasl=no fi if test "x${ac_enable_sasl}" = "xyes"; then HAVE_SASL_TRUE= HAVE_SASL_FALSE='#' else HAVE_SASL_TRUE='#' HAVE_SASL_FALSE= fi if test "x$ac_enable_sasl" = "xyes"; then : LIBMEMCACHED_WITH_SASL_SUPPORT="#define LIBMEMCACHED_WITH_SASL_SUPPORT 1" else LIBMEMCACHED_WITH_SASL_SUPPORT="#define LIBMEMCACHED_WITH_SASL_SUPPORT 0" fi if ${ax_cv_have_LIBUUID+:} false; then : $as_echo_n "(cached) " >&6 else save_CPPFLAGS="$CPPFLAGS" save_LDFLAGS="$LDFLAGS" save_LIBS="$LIBS" if test "x$LIBUUID_CPPFLAGS" != "x"; then : CPPFLAGS="$CPPFLAGS $LIBUUID_CPPFLAGS" fi if test "x$LIBUUID_LDFLAGS" != "x"; then : LDFLAGS="$LDFLAGS $LIBUUID_LDFLAGS" fi ac_fn_cxx_check_header_mongrel "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "$ac_includes_default" if test "x$ac_cv_header_uuid_uuid_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -luuid" >&5 $as_echo_n "checking for main in -luuid... " >&6; } if ${ac_cv_lib_uuid_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-luuid $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_uuid_main=yes else ac_cv_lib_uuid_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_main" >&5 $as_echo "$ac_cv_lib_uuid_main" >&6; } if test "x$ac_cv_lib_uuid_main" = xyes; then : ax_cv_have_LIBUUID=yes else ax_cv_have_LIBUUID=no fi else ax_cv_have_LIBUUID=no fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" fi if test "$ax_cv_have_LIBUUID" = "yes"; then : $as_echo "#define HAVE_LIBUUID 1" >>confdefs.h LIBUUID_LDFLAGS="-luuid" $as_echo "#define HAVE_LIBUUID 1 " >>confdefs.h else $as_echo "#define HAVE_LIBUUID 0 " >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5 $as_echo_n "checking for clock_gettime in -lrt... " >&6; } if ${ac_cv_lib_rt_clock_gettime+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lrt $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char clock_gettime (); int main () { return clock_gettime (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_rt_clock_gettime=yes else ac_cv_lib_rt_clock_gettime=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5 $as_echo "$ac_cv_lib_rt_clock_gettime" >&6; } if test "x$ac_cv_lib_rt_clock_gettime" = xyes; then : RT_LIB="-lrt" $as_echo "#define HAVE_LIBRT 1 " >>confdefs.h else $as_echo "#define HAVE_LIBRT 0 " >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for floor in -lm" >&5 $as_echo_n "checking for floor in -lm... " >&6; } if ${ac_cv_lib_m_floor+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char floor (); int main () { return floor (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_m_floor=yes else ac_cv_lib_m_floor=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_floor" >&5 $as_echo "$ac_cv_lib_m_floor" >&6; } if test "x$ac_cv_lib_m_floor" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF LIBS="-lm $LIBS" fi for ac_func in sigignore do : ac_fn_cxx_check_func "$LINENO" "sigignore" "ac_cv_func_sigignore" if test "x$ac_cv_func_sigignore" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SIGIGNORE 1 _ACEOF fi done for ac_header in atomic.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "atomic.h" "ac_cv_header_atomic_h" "$ac_includes_default" if test "x$ac_cv_header_atomic_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ATOMIC_H 1 _ACEOF fi done if test "x$ac_cv_header_atomic_h" = "xyes"; then : for ac_func in atomic_add_64 do : ac_fn_cxx_check_func "$LINENO" "atomic_add_64" "ac_cv_func_atomic_add_64" if test "x$ac_cv_func_atomic_add_64" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ATOMIC_ADD_64 1 _ACEOF fi done for ac_func in atomic_add_32 do : ac_fn_cxx_check_func "$LINENO" "atomic_add_32" "ac_cv_func_atomic_add_32" if test "x$ac_cv_func_atomic_add_32" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ATOMIC_ADD_32 1 _ACEOF fi done if test "x$ac_cv_func_atomic_add_64" = "xyes" -a "x$ac_cv_func_atomic_add_32" = "xyes"; then : $as_echo "#define USE_ATOMIC_H 1" >>confdefs.h fi fi $as_echo "#define HAVE_LIBDRIZZLE 0" >>confdefs.h $as_echo "#define HAVE_DRIZZLED_BINARY 0" >>confdefs.h $as_echo "#define DRIZZLED_BINARY 0" >>confdefs.h $as_echo "#define GEARMAND_BLOBSLAP_WORKER 0" >>confdefs.h $as_echo "#define HAVE_LIBPQ 0" >>confdefs.h $as_echo "#define HAVE_LIBCURL 0" >>confdefs.h $as_echo "#define HAVE_MEMCACHED_LIGHT_BINARY 1" >>confdefs.h $as_echo "#define MEMCACHED_LIGHT_BINARY \"example/memcached_light\"" >>confdefs.h for ac_func in setppriv do : ac_fn_cxx_check_func "$LINENO" "setppriv" "ac_cv_func_setppriv" if test "x$ac_cv_func_setppriv" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SETPPRIV 1 _ACEOF ac_fn_cxx_check_header_mongrel "$LINENO" "priv.h" "ac_cv_header_priv_h" "$ac_includes_default" if test "x$ac_cv_header_priv_h" = xyes; then : $as_echo "#define HAVE_DROP_PRIVILEGES 1" >>confdefs.h build_solaris_privs=yes fi fi done for ac_header in $ac_header_list do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done if test "x$ac_cv_header_poll_h" = "xno"; then BUILD_POLL_TRUE= BUILD_POLL_FALSE='#' else BUILD_POLL_TRUE='#' BUILD_POLL_FALSE= fi if test "x$ac_cv_header_winsock2_h" = "xyes"; then BUILD_WIN32_WRAPPERS_TRUE= BUILD_WIN32_WRAPPERS_FALSE='#' else BUILD_WIN32_WRAPPERS_TRUE='#' BUILD_WIN32_WRAPPERS_FALSE= fi if test "x$ac_cv_header_winsock2_h" = "xyes"; then : AM_LDFLAGS="$AM_LDFLAGS -lws2_32" AM_CFLAGS="$AM_CFLAGS $NO_WERROR" AM_CXXFLAGS="$AM_CXXFLAGS $NO_WERROR" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MSG_NOSIGNAL" >&5 $as_echo_n "checking for MSG_NOSIGNAL... " >&6; } if ${ac_cv_msg_nosignal+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -I${srcdir}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int flags= MSG_NOSIGNAL ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_msg_nosignal="yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_msg_nosignal" >&5 $as_echo "$ac_cv_msg_nosignal" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MSG_DONTWAIT" >&5 $as_echo_n "checking for MSG_DONTWAIT... " >&6; } if ${ac_cv_msg_dontwait+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -I${srcdir}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int flags= MSG_DONTWAIT ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_msg_dontwait="yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_msg_dontwait" >&5 $as_echo "$ac_cv_msg_dontwait" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MSG_MORE" >&5 $as_echo_n "checking for MSG_MORE... " >&6; } if ${ac_cv_msg_more+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -I${srcdir}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int flags= MSG_MORE ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_msg_more="yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_msg_more" >&5 $as_echo "$ac_cv_msg_more" >&6; } if test "x$ac_cv_msg_nosignal" = "xyes"; then : $as_echo "#define HAVE_MSG_NOSIGNAL 1" >>confdefs.h fi if test "x$ac_cv_msg_dontwait" = "xyes"; then : $as_echo "#define HAVE_MSG_DONTWAIT 1" >>confdefs.h fi if test "x$ac_cv_msg_more" = "xyes"; then : $as_echo "#define HAVE_MSG_MORE 1" >>confdefs.h fi if ${ax_cv_have_LIBEVENT+:} false; then : $as_echo_n "(cached) " >&6 else save_CPPFLAGS="$CPPFLAGS" save_LDFLAGS="$LDFLAGS" save_LIBS="$LIBS" if test "x$LIBEVENT_CPPFLAGS" != "x"; then : CPPFLAGS="$CPPFLAGS $LIBEVENT_CPPFLAGS" fi if test "x$LIBEVENT_LDFLAGS" != "x"; then : LDFLAGS="$LDFLAGS $LIBEVENT_LDFLAGS" fi ac_fn_cxx_check_header_mongrel "$LINENO" "event.h" "ac_cv_header_event_h" "$ac_includes_default" if test "x$ac_cv_header_event_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -levent" >&5 $as_echo_n "checking for main in -levent... " >&6; } if ${ac_cv_lib_event_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-levent $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_event_main=yes else ac_cv_lib_event_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_event_main" >&5 $as_echo "$ac_cv_lib_event_main" >&6; } if test "x$ac_cv_lib_event_main" = xyes; then : ax_cv_have_LIBEVENT=yes else ax_cv_have_LIBEVENT=no fi else ax_cv_have_LIBEVENT=no fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" fi if test "$ax_cv_have_LIBEVENT" = "yes"; then : $as_echo "#define HAVE_LIBEVENT 1" >>confdefs.h LIBEVENT_LDFLAGS="-levent" else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to find libevent" >&5 $as_echo "$as_me: WARNING: Unable to find libevent" >&2;} fi if test "x${ax_cv_have_LIBEVENT}" = "xyes"; then HAVE_LIBEVENT_TRUE= HAVE_LIBEVENT_FALSE='#' else HAVE_LIBEVENT_TRUE='#' HAVE_LIBEVENT_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for endianness" >&5 $as_echo_n "checking for endianness... " >&6; } if ${ac_cv_c_endian+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { long val = 1; char *c = (char *) &val; exit(*c == 1); ; return 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : ac_cv_c_endian=big else ac_cv_c_endian=little fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_endian" >&5 $as_echo "$ac_cv_c_endian" >&6; } if test $ac_cv_c_endian = big; then $as_echo "#define ENDIAN_BIG 1" >>confdefs.h fi if test $ac_cv_c_endian = little; then $as_echo "#define ENDIAN_LITTLE 1" >>confdefs.h fi ac_config_files="$ac_config_files Makefile docs/conf.py libhashkit-1.0/configure.h libmemcached-1.0/configure.h libmemcached-1.2/configure.h libmemcached-2.0/configure.h support/libmemcached.pc support/libmemcached.spec support/libmemcached-fc.spec libtest/version.h" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BUILD_WIN32_TRUE}" && test -z "${BUILD_WIN32_FALSE}"; then as_fn_error $? "conditional \"BUILD_WIN32\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${TARGET_OSX_TRUE}" && test -z "${TARGET_OSX_FALSE}"; then as_fn_error $? "conditional \"TARGET_OSX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${TARGET_LINUX_TRUE}" && test -z "${TARGET_LINUX_FALSE}"; then as_fn_error $? "conditional \"TARGET_LINUX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_DTRACE_TRUE}" && test -z "${HAVE_DTRACE_FALSE}"; then as_fn_error $? "conditional \"HAVE_DTRACE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DTRACE_NEEDS_OBJECTS_TRUE}" && test -z "${DTRACE_NEEDS_OBJECTS_FALSE}"; then as_fn_error $? "conditional \"DTRACE_NEEDS_OBJECTS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_DPKG_GENSYMBOLS_TRUE}" && test -z "${HAVE_DPKG_GENSYMBOLS_FALSE}"; then as_fn_error $? "conditional \"HAVE_DPKG_GENSYMBOLS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_SPHINX_TRUE}" && test -z "${HAVE_SPHINX_FALSE}"; then as_fn_error $? "conditional \"HAVE_SPHINX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_RECENT_SPHINX_TRUE}" && test -z "${HAVE_RECENT_SPHINX_FALSE}"; then as_fn_error $? "conditional \"HAVE_RECENT_SPHINX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_LIBGEARMAN_TRUE}" && test -z "${HAVE_LIBGEARMAN_FALSE}"; then as_fn_error $? "conditional \"HAVE_LIBGEARMAN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_LIBGEARMAN_TRUE}" && test -z "${HAVE_LIBGEARMAN_FALSE}"; then as_fn_error $? "conditional \"HAVE_LIBGEARMAN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BUILDING_LIBMEMCACHED_TRUE}" && test -z "${BUILDING_LIBMEMCACHED_FALSE}"; then as_fn_error $? "conditional \"BUILDING_LIBMEMCACHED\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_LIBMEMCACHED_TRUE}" && test -z "${HAVE_LIBMEMCACHED_FALSE}"; then as_fn_error $? "conditional \"HAVE_LIBMEMCACHED\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_LIBDRIZZLE_TRUE}" && test -z "${HAVE_LIBDRIZZLE_FALSE}"; then as_fn_error $? "conditional \"HAVE_LIBDRIZZLE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BUILDING_GEARMAN_TRUE}" && test -z "${BUILDING_GEARMAN_FALSE}"; then as_fn_error $? "conditional \"BUILDING_GEARMAN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BUILD_BYTEORDER_TRUE}" && test -z "${BUILD_BYTEORDER_FALSE}"; then as_fn_error $? "conditional \"BUILD_BYTEORDER\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${INCLUDE_HSIEH_SRC_TRUE}" && test -z "${INCLUDE_HSIEH_SRC_FALSE}"; then as_fn_error $? "conditional \"INCLUDE_HSIEH_SRC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${INCLUDE_MURMUR_SRC_TRUE}" && test -z "${INCLUDE_MURMUR_SRC_FALSE}"; then as_fn_error $? "conditional \"INCLUDE_MURMUR_SRC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BUILD_MEMASLAP_TRUE}" && test -z "${BUILD_MEMASLAP_FALSE}"; then as_fn_error $? "conditional \"BUILD_MEMASLAP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BUILD_CACHE_TRUE}" && test -z "${BUILD_CACHE_FALSE}"; then as_fn_error $? "conditional \"BUILD_CACHE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_SASL_TRUE}" && test -z "${HAVE_SASL_FALSE}"; then as_fn_error $? "conditional \"HAVE_SASL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BUILD_POLL_TRUE}" && test -z "${BUILD_POLL_FALSE}"; then as_fn_error $? "conditional \"BUILD_POLL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BUILD_WIN32_WRAPPERS_TRUE}" && test -z "${BUILD_WIN32_WRAPPERS_FALSE}"; then as_fn_error $? "conditional \"BUILD_WIN32_WRAPPERS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_LIBEVENT_TRUE}" && test -z "${HAVE_LIBEVENT_FALSE}"; then as_fn_error $? "conditional \"HAVE_LIBEVENT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by libmemcached $as_me 1.0.8, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ libmemcached config.status 1.0.8 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_ld='`$ECHO "$hardcode_libdir_flag_spec_ld" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' compiler_lib_search_dirs='`$ECHO "$compiler_lib_search_dirs" | $SED "$delay_single_quote_subst"`' predep_objects='`$ECHO "$predep_objects" | $SED "$delay_single_quote_subst"`' postdep_objects='`$ECHO "$postdep_objects" | $SED "$delay_single_quote_subst"`' predeps='`$ECHO "$predeps" | $SED "$delay_single_quote_subst"`' postdeps='`$ECHO "$postdeps" | $SED "$delay_single_quote_subst"`' compiler_lib_search_path='`$ECHO "$compiler_lib_search_path" | $SED "$delay_single_quote_subst"`' LD_CXX='`$ECHO "$LD_CXX" | $SED "$delay_single_quote_subst"`' reload_flag_CXX='`$ECHO "$reload_flag_CXX" | $SED "$delay_single_quote_subst"`' reload_cmds_CXX='`$ECHO "$reload_cmds_CXX" | $SED "$delay_single_quote_subst"`' old_archive_cmds_CXX='`$ECHO "$old_archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' compiler_CXX='`$ECHO "$compiler_CXX" | $SED "$delay_single_quote_subst"`' GCC_CXX='`$ECHO "$GCC_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "$lt_prog_compiler_no_builtin_flag_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic_CXX='`$ECHO "$lt_prog_compiler_pic_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl_CXX='`$ECHO "$lt_prog_compiler_wl_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static_CXX='`$ECHO "$lt_prog_compiler_static_CXX" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o_CXX='`$ECHO "$lt_cv_prog_compiler_c_o_CXX" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc_CXX='`$ECHO "$archive_cmds_need_lc_CXX" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes_CXX='`$ECHO "$enable_shared_with_static_runtimes_CXX" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec_CXX='`$ECHO "$export_dynamic_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec_CXX='`$ECHO "$whole_archive_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' compiler_needs_object_CXX='`$ECHO "$compiler_needs_object_CXX" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds_CXX='`$ECHO "$old_archive_from_new_cmds_CXX" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds_CXX='`$ECHO "$old_archive_from_expsyms_cmds_CXX" | $SED "$delay_single_quote_subst"`' archive_cmds_CXX='`$ECHO "$archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds_CXX='`$ECHO "$archive_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' module_cmds_CXX='`$ECHO "$module_cmds_CXX" | $SED "$delay_single_quote_subst"`' module_expsym_cmds_CXX='`$ECHO "$module_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' with_gnu_ld_CXX='`$ECHO "$with_gnu_ld_CXX" | $SED "$delay_single_quote_subst"`' allow_undefined_flag_CXX='`$ECHO "$allow_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' no_undefined_flag_CXX='`$ECHO "$no_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_CXX='`$ECHO "$hardcode_libdir_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_ld_CXX='`$ECHO "$hardcode_libdir_flag_spec_ld_CXX" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator_CXX='`$ECHO "$hardcode_libdir_separator_CXX" | $SED "$delay_single_quote_subst"`' hardcode_direct_CXX='`$ECHO "$hardcode_direct_CXX" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute_CXX='`$ECHO "$hardcode_direct_absolute_CXX" | $SED "$delay_single_quote_subst"`' hardcode_minus_L_CXX='`$ECHO "$hardcode_minus_L_CXX" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var_CXX='`$ECHO "$hardcode_shlibpath_var_CXX" | $SED "$delay_single_quote_subst"`' hardcode_automatic_CXX='`$ECHO "$hardcode_automatic_CXX" | $SED "$delay_single_quote_subst"`' inherit_rpath_CXX='`$ECHO "$inherit_rpath_CXX" | $SED "$delay_single_quote_subst"`' link_all_deplibs_CXX='`$ECHO "$link_all_deplibs_CXX" | $SED "$delay_single_quote_subst"`' always_export_symbols_CXX='`$ECHO "$always_export_symbols_CXX" | $SED "$delay_single_quote_subst"`' export_symbols_cmds_CXX='`$ECHO "$export_symbols_cmds_CXX" | $SED "$delay_single_quote_subst"`' exclude_expsyms_CXX='`$ECHO "$exclude_expsyms_CXX" | $SED "$delay_single_quote_subst"`' include_expsyms_CXX='`$ECHO "$include_expsyms_CXX" | $SED "$delay_single_quote_subst"`' prelink_cmds_CXX='`$ECHO "$prelink_cmds_CXX" | $SED "$delay_single_quote_subst"`' postlink_cmds_CXX='`$ECHO "$postlink_cmds_CXX" | $SED "$delay_single_quote_subst"`' file_list_spec_CXX='`$ECHO "$file_list_spec_CXX" | $SED "$delay_single_quote_subst"`' hardcode_action_CXX='`$ECHO "$hardcode_action_CXX" | $SED "$delay_single_quote_subst"`' compiler_lib_search_dirs_CXX='`$ECHO "$compiler_lib_search_dirs_CXX" | $SED "$delay_single_quote_subst"`' predep_objects_CXX='`$ECHO "$predep_objects_CXX" | $SED "$delay_single_quote_subst"`' postdep_objects_CXX='`$ECHO "$postdep_objects_CXX" | $SED "$delay_single_quote_subst"`' predeps_CXX='`$ECHO "$predeps_CXX" | $SED "$delay_single_quote_subst"`' postdeps_CXX='`$ECHO "$postdeps_CXX" | $SED "$delay_single_quote_subst"`' compiler_lib_search_path_CXX='`$ECHO "$compiler_lib_search_path_CXX" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in SHELL \ ECHO \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ nm_file_list_spec \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_flag_spec_ld \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib \ compiler_lib_search_dirs \ predep_objects \ postdep_objects \ predeps \ postdeps \ compiler_lib_search_path \ LD_CXX \ reload_flag_CXX \ compiler_CXX \ lt_prog_compiler_no_builtin_flag_CXX \ lt_prog_compiler_pic_CXX \ lt_prog_compiler_wl_CXX \ lt_prog_compiler_static_CXX \ lt_cv_prog_compiler_c_o_CXX \ export_dynamic_flag_spec_CXX \ whole_archive_flag_spec_CXX \ compiler_needs_object_CXX \ with_gnu_ld_CXX \ allow_undefined_flag_CXX \ no_undefined_flag_CXX \ hardcode_libdir_flag_spec_CXX \ hardcode_libdir_flag_spec_ld_CXX \ hardcode_libdir_separator_CXX \ exclude_expsyms_CXX \ include_expsyms_CXX \ file_list_spec_CXX \ compiler_lib_search_dirs_CXX \ predep_objects_CXX \ postdep_objects_CXX \ predeps_CXX \ postdeps_CXX \ compiler_lib_search_path_CXX; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec \ reload_cmds_CXX \ old_archive_cmds_CXX \ old_archive_from_new_cmds_CXX \ old_archive_from_expsyms_cmds_CXX \ archive_cmds_CXX \ archive_expsym_cmds_CXX \ module_cmds_CXX \ module_expsym_cmds_CXX \ export_symbols_cmds_CXX \ prelink_cmds_CXX \ postlink_cmds_CXX; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "docs/conf.py") CONFIG_FILES="$CONFIG_FILES docs/conf.py" ;; "libhashkit-1.0/configure.h") CONFIG_FILES="$CONFIG_FILES libhashkit-1.0/configure.h" ;; "libmemcached-1.0/configure.h") CONFIG_FILES="$CONFIG_FILES libmemcached-1.0/configure.h" ;; "libmemcached-1.2/configure.h") CONFIG_FILES="$CONFIG_FILES libmemcached-1.2/configure.h" ;; "libmemcached-2.0/configure.h") CONFIG_FILES="$CONFIG_FILES libmemcached-2.0/configure.h" ;; "support/libmemcached.pc") CONFIG_FILES="$CONFIG_FILES support/libmemcached.pc" ;; "support/libmemcached.spec") CONFIG_FILES="$CONFIG_FILES support/libmemcached.spec" ;; "support/libmemcached-fc.spec") CONFIG_FILES="$CONFIG_FILES support/libmemcached-fc.spec" ;; "libtest/version.h") CONFIG_FILES="$CONFIG_FILES libtest/version.h" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "libtool":C) # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, # Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags="CXX " # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # DLL creation program. DLLTOOL=$lt_DLLTOOL # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and in which our libraries should be installed. lt_sysroot=$lt_sysroot # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # If ld is used when linking, flag to hardcode \$libdir into a binary # during linking. This must work even if \$libdir does not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects postdep_objects=$lt_postdep_objects predeps=$lt_predeps postdeps=$lt_postdeps # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain="$ac_aux_dir/ltmain.sh" # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) if test x"$xsi_shell" = xyes; then sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ func_dirname ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ } # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_basename ()$/,/^} # func_basename /c\ func_basename ()\ {\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ func_dirname_and_basename ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ func_stripname ()\ {\ \ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ \ # positional parameters, so assign one to ordinary parameter first.\ \ func_stripname_result=${3}\ \ func_stripname_result=${func_stripname_result#"${1}"}\ \ func_stripname_result=${func_stripname_result%"${2}"}\ } # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ func_split_long_opt ()\ {\ \ func_split_long_opt_name=${1%%=*}\ \ func_split_long_opt_arg=${1#*=}\ } # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ func_split_short_opt ()\ {\ \ func_split_short_opt_arg=${1#??}\ \ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ } # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ func_lo2o ()\ {\ \ case ${1} in\ \ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ \ *) func_lo2o_result=${1} ;;\ \ esac\ } # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_xform ()$/,/^} # func_xform /c\ func_xform ()\ {\ func_xform_result=${1%.*}.lo\ } # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_arith ()$/,/^} # func_arith /c\ func_arith ()\ {\ func_arith_result=$(( $* ))\ } # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_len ()$/,/^} # func_len /c\ func_len ()\ {\ func_len_result=${#1}\ } # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$lt_shell_append" = xyes; then sed -e '/^func_append ()$/,/^} # func_append /c\ func_append ()\ {\ eval "${1}+=\\${2}"\ } # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ func_append_quoted ()\ {\ \ func_quote_for_eval "${2}"\ \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ } # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 $as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} fi mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" cat <<_LT_EOF >> "$ofile" # ### BEGIN LIBTOOL TAG CONFIG: CXX # The linker used to build libraries. LD=$lt_LD_CXX # How to create reloadable object files. reload_flag=$lt_reload_flag_CXX reload_cmds=$lt_reload_cmds_CXX # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds_CXX # A language specific compiler. CC=$lt_compiler_CXX # Is the compiler the GNU compiler? with_gcc=$GCC_CXX # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic_CXX # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl_CXX # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static_CXX # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc_CXX # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object_CXX # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds_CXX archive_expsym_cmds=$lt_archive_expsym_cmds_CXX # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds_CXX module_expsym_cmds=$lt_module_expsym_cmds_CXX # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld_CXX # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag_CXX # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag_CXX # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX # If ld is used when linking, flag to hardcode \$libdir into a binary # during linking. This must work even if \$libdir does not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct_CXX # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute_CXX # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L_CXX # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic_CXX # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath_CXX # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs_CXX # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols_CXX # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds_CXX # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms_CXX # Symbols that must always be exported. include_expsyms=$lt_include_expsyms_CXX # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds_CXX # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds_CXX # Specify filename containing input files. file_list_spec=$lt_file_list_spec_CXX # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action_CXX # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects_CXX postdep_objects=$lt_postdep_objects_CXX predeps=$lt_predeps_CXX postdeps=$lt_postdeps_CXX # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path_CXX # ### END LIBTOOL TAG CONFIG: CXX _LT_EOF ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi echo "---" echo "Configuration summary for $PACKAGE_NAME version $VERSION" echo "" echo " * Installation prefix: $prefix" echo " * System type: $host_vendor-$host_os" echo " * Host CPU: $host_cpu" echo " * C Compiler: $CC_VERSION" echo " * Assertions enabled: $ac_cv_assert" echo " * Debug enabled: $with_debug" echo " * Warnings as failure: $ac_cv_warnings_as_errors" echo " * SASL support: $ac_enable_sasl" echo "" echo "---" case "$host_os" in *freebsd*) echo "*****" echo "*" echo "* NOTE: You are on FreeBSD. BSD make will not work." echo "*" echo "* use 'gmake' To build libmemcached" echo "*" echo "*****" ;; esac libmemcached-1.0.8/libmemcachedinternal/0000775000076400007640000000000011757025117020537 5ustar00brianbrian00000000000000libmemcached-1.0.8/libmemcachedinternal/include.am0000664000076400007640000000227311753573717022517 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root # This noinst lib contains things we want to be ABI private but still want to # either use in client programs or be able to test in test cases These symbols # will not be exposed in the shipped .so noinst_LTLIBRARIES+= libmemcachedinternal/libmemcachedinternal.la libmemcachedinternal_libmemcachedinternal_la_SOURCES= $(libmemcached_libmemcached_la_SOURCES) libmemcachedinternal_libmemcachedinternal_la_CFLAGS= \ ${AM_CFLAGS} \ ${NO_CONVERSION} \ -DBUILDING_LIBMEMCACHEDINTERNAL libmemcachedinternal_libmemcachedinternal_la_CPPFLAGS= \ ${AM_CPPFLAGS} \ ${NO_CONVERSION} \ -DBUILDING_LIBMEMCACHEDINTERNAL libmemcachedinternal_libmemcachedinternal_la_CXXFLAGS= \ ${AM_CXXFLAGS} \ ${NO_CONVERSION} \ -DBUILDING_LIBMEMCACHEDINTERNAL libmemcachedinternal_libmemcachedinternal_la_LDFLAGS= ${AM_LDFLAGS} libmemcachedinternal_libmemcachedinternal_la_LIBADD= $(libmemcached_libmemcached_la_LIBADD) libmemcachedinternal_libmemcachedinternal_la_DEPENDENCIES= $(libmemcached_libmemcached_la_DEPENDENCIES) libmemcached-1.0.8/libmemcachedinternal/util/0000775000076400007640000000000011757025117021514 5ustar00brianbrian00000000000000libmemcached-1.0.8/libmemcachedinternal/util/include.am0000664000076400007640000000165611753573717023500 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root # This noinst lib contains things we want to be ABI private but still want to # either use in client programs or be able to test in test cases These symbols # will not be exposed in the shipped .so noinst_LTLIBRARIES+= libmemcachedinternal/libmemcachedutilinternal.la libmemcachedinternal_libmemcachedutilinternal_la_SOURCES= $(libmemcached_libmemcachedutil_la_SOURCES) libmemcachedinternal_libmemcachedutilinternal_la_CXXFLAGS= \ ${AM_CXXFLAGS} \ ${NO_CONVERSION} \ -DBUILDING_LIBMEMCACHEDINTERNAL libmemcachedinternal_libmemcachedutilinternal_la_CXXFLAGS+= ${PTHREAD_CFLAGS} libmemcachedinternal_libmemcachedutilinternal_la_LIBADD= libmemcachedinternal/libmemcachedinternal.la ${PTHREAD_LIBS} libmemcachedinternal_libmemcachedutilinternal_la_DEPENDENCIES= libmemcachedinternal/libmemcachedinternal.la libmemcached-1.0.8/configure.ac0000664000076400007640000002232611756761656016716 0ustar00brianbrian00000000000000#!/usr/bin/env bash # LibmemcacheD # Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/ # Copyright (C) 2006-2010 Brian Aker, Monty Taylor, Trond Norbye # All rights reserved. # # Use and distribution licensed under the BSD license. See # the COPYING file in this directory for full text. AC_INIT([libmemcached],[1.0.8],[http://libmemcached.org/]) AC_CONFIG_AUX_DIR(config) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE AC_CANONICAL_HOST AC_CANONICAL_BUILD AC_PREREQ([2.61]) AC_CONFIG_MACRO_DIR(m4) AC_CONFIG_HEADERS([config.h:config.in])dnl Keep filename to 8.3 for MS-DOS. AC_CONFIG_SRCDIR([libmemcached/memcached.cc]) PANDORA_CANONICAL_TARGET(no-vc-changelog) AC_CHECK_PROGS([YACC], ['bison'], [:]) AC_CHECK_PROGS([LEX], ['flex'], [:]) #shared library versioning MEMCACHED_UTIL_LIBRARY_VERSION=2:0:0 MEMCACHED_PROTOCAL_LIBRARY_VERSION=0:0:0 MEMCACHED_LIBRARY_VERSION=10:0:0 # | | | # +------+ | +---+ # | | | # current:revision:age # | | | # | | +- increment if interfaces have been added # | | set to zero if interfaces have been removed or changed # | +- increment if source code has changed # | set to zero if current is incremented # +- increment if interfaces have been added, removed or changed AC_SUBST(MEMCACHED_UTIL_LIBRARY_VERSION) AC_SUBST(MEMCACHED_PROTOCAL_LIBRARY_VERSION) AC_SUBST(MEMCACHED_LIBRARY_VERSION) HASHKIT_LIBRARY_VERSION=2:0:0 AC_SUBST(HASHKIT_LIBRARY_VERSION) LT_PREREQ([2.2]) LT_INIT() LT_LANG([C++]) LT_LANG([C]) gl_VISIBILITY AX_CXX_HEADER_STDCXX_98 if test "$ax_cv_cxx_stdcxx_98" = no; then AC_MSG_ERROR([Your system lacks a new enough C++ compiler]) fi m4_include([m4/memcached.m4]) m4_include([m4/memcached_sasl.m4]) m4_include([m4/gearmand.m4]) m4_include([m4/libgearman.m4]) m4_include([memcached/version.m4]) AM_CONDITIONAL(BUILDING_LIBMEMCACHED, true) AM_CONDITIONAL(HAVE_LIBMEMCACHED, false) AM_CONDITIONAL(HAVE_LIBDRIZZLE, false) AC_DEFINE([HAVE_LIBMEMCACHED], [1], [Enables libmemcached Support]) AM_CONDITIONAL(BUILDING_GEARMAN, false) AC_SEARCH_LIBS(getopt_long, gnugetopt) AC_SEARCH_LIBS(gethostbyname, nsl) case "$target_os" in *linux*) AS_IF([test "x$GCC" = "xyes"], [ LDFLAGS="$LDFLAGS -z relro -z now" ]) ;; esac dnl Specialty checks AX_PTHREAD AX_CXX_CINTTYPES CONFIG_EXTRA DETECT_BYTEORDER SETSOCKOPT_SANITY ENABLE_HSIEH_HASH ENABLE_MURMUR_HASH ENABLE_FNV64_HASH ENABLE_MEMASLAP PROTOCOL_BINARY_TEST ENABLE_DEPRECATED AC_CHECK_FUNCS([alarm]) AC_CHECK_FUNCS([dup2]) AC_CHECK_FUNCS([getline]) AC_CHECK_FUNCS([gettimeofday]) AC_CHECK_FUNCS([memchr]) AC_CHECK_FUNCS([memmove]) AC_CHECK_FUNCS([memset]) AC_CHECK_FUNCS([pipe2]) AC_CHECK_FUNCS([select]) AC_CHECK_FUNCS([setenv]) AC_CHECK_FUNCS([socket]) AC_CHECK_FUNCS([sqrt]) AC_CHECK_FUNCS([strcasecmp]) AC_CHECK_FUNCS([strchr]) AC_CHECK_FUNCS([strdup]) AC_CHECK_FUNCS([strerror]) AC_CHECK_FUNCS([strtol]) AC_CHECK_FUNCS([strtoul]) AC_CHECK_FUNCS([strtoull]) AC_CHECK_HEADERS([arpa/inet.h]) AC_CHECK_HEADERS([errno.h]) AC_CHECK_HEADERS([execinfo.h]) AC_CHECK_HEADERS([fcntl.h]) AC_CHECK_HEADERS([inttypes.h]) AC_CHECK_HEADERS([libintl.h]) AC_CHECK_HEADERS([limits.h]) AC_CHECK_HEADERS([malloc.h]) AC_CHECK_HEADERS([math.h]) AC_CHECK_HEADERS([netdb.h]) AC_CHECK_HEADERS([netinet/in.h]) AC_CHECK_HEADERS([pthread.h]) AC_CHECK_HEADERS([stdarg.h]) AC_CHECK_HEADERS([stddef.h]) AC_CHECK_HEADERS([stdlib.h]) AC_CHECK_HEADERS([sys/time.h]) AC_CHECK_HEADERS([unistd.h]) AC_CHECK_HEADERS([cxxabi.h], AC_DEFINE([HAVE_CXXABI_H], [1], [Have cxxabi.h]), AC_DEFINE([HAVE_CXXABI_H], [0], [Have cxxabi.h])) AC_CHECK_HEADERS([sys/sysctl.h]) AC_CHECK_HEADER(umem.h, [ AC_DEFINE([HAVE_UMEM_H], 1, [Define this if you have umem.h]) build_cache=no ], [build_cache=yes]) AM_CONDITIONAL([BUILD_CACHE], [test "x$build_cache" = "xyes"]) AX_COMPILER_VENDOR AC_FUNC_ALLOCA AC_FUNC_ERROR_AT_LINE AC_FUNC_FORK AC_FUNC_MALLOC AC_FUNC_REALLOC AC_FUNC_STRERROR_R AC_HEADER_STDBOOL AC_TYPE_INT16_T AC_TYPE_INT32_T AC_TYPE_INT64_T AC_TYPE_INT8_T AC_TYPE_OFF_T AC_TYPE_PID_T AC_TYPE_SSIZE_T AC_TYPE_UINT16_T AC_TYPE_UINT32_T AC_TYPE_UINT64_T AC_TYPE_UINT8_T AC_C_BIGENDIAN AC_C_CONST AC_C_INLINE AC_C_VOLATILE AC_C_RESTRICT AX_CXX_GCC_ABI_DEMANGLE AX_SASL_CHECK dnl dnl The sasl functions should only be visible if we build with sasl support dnl AS_IF([test "x$ac_enable_sasl" = "xyes"], [ [ LIBMEMCACHED_WITH_SASL_SUPPORT="#define LIBMEMCACHED_WITH_SASL_SUPPORT 1" ] ], [ [ LIBMEMCACHED_WITH_SASL_SUPPORT="#define LIBMEMCACHED_WITH_SASL_SUPPORT 0" ] ]) AC_SUBST(LIBMEMCACHED_WITH_SASL_SUPPORT) AX_CHECK_LIBRARY([LIBUUID], [uuid/uuid.h], [uuid], [ LIBUUID_LDFLAGS="-luuid" AC_DEFINE([HAVE_LIBUUID], [ 1 ], [Have libuuid]) ], [ AC_DEFINE([HAVE_LIBUUID], [ 0 ], [Have libuuid]) ]) AC_CHECK_LIB([rt], [clock_gettime], [ RT_LIB="-lrt" AC_SUBST(RT_LIB) AC_DEFINE([HAVE_LIBRT], [ 1 ], [Have clock_gettime]) ], [ AC_DEFINE([HAVE_LIBRT], [ 0 ], [Have clock_gettime]) ]) AC_CHECK_LIB([m], [floor]) AC_CHECK_FUNCS([sigignore]) AC_CHECK_HEADERS([atomic.h]) AS_IF([test "x$ac_cv_header_atomic_h" = "xyes"],[ AC_CHECK_FUNCS(atomic_add_64) AC_CHECK_FUNCS(atomic_add_32) AS_IF([test "x$ac_cv_func_atomic_add_64" = "xyes" -a "x$ac_cv_func_atomic_add_32" = "xyes"],[ AC_DEFINE([USE_ATOMIC_H], [1], [Define to true if you want to use functions from atomic.h])])]) AC_DEFINE([HAVE_LIBDRIZZLE], [0], [Support for libdrizzle]) AC_DEFINE([HAVE_DRIZZLED_BINARY], [0], [Support for DrizzleD]) AC_DEFINE([DRIZZLED_BINARY], [0], [Support for DrizzleD]) AC_DEFINE([GEARMAND_BLOBSLAP_WORKER], [0], [Support for Gearman Blobslap worker]) AC_DEFINE([HAVE_LIBPQ], [0], [Support for Postgres]) AC_DEFINE([HAVE_LIBCURL], [0], [Support for libcurl]) AC_DEFINE([HAVE_MEMCACHED_LIGHT_BINARY], [1], [Support for memcached_light]) AC_DEFINE([MEMCACHED_LIGHT_BINARY], ["example/memcached_light"], [Support for memcached_light]) dnl Check for the requirements for running memcached with less privileges dnl than the default privilege set. On Solaris we need setppriv and priv.h dnl If you want to add support for other platforms you should check for dnl your requirements, define HAVE_DROP_PRIVILEGES, and make sure you add dnl the source file containing the implementation into memcached_SOURCE dnl in Makefile.am AC_CHECK_FUNCS(setppriv, [ AC_CHECK_HEADER(priv.h, [ AC_DEFINE([HAVE_DROP_PRIVILEGES], 1, [Define this if you have an implementation of drop_privileges()]) 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", [AM_LDFLAGS="$AM_LDFLAGS -lws2_32" AM_CFLAGS="$AM_CFLAGS $NO_WERROR" AM_CXXFLAGS="$AM_CXXFLAGS $NO_WERROR" ]) SOCKET_SEND_FLAGS AX_CHECK_LIBRARY([LIBEVENT], [event.h], [event], [ LIBEVENT_LDFLAGS="-levent" ], [ AC_MSG_WARN([Unable to find libevent]) ]) AM_CONDITIONAL(HAVE_LIBEVENT, test "x${ax_cv_have_LIBEVENT}" = "xyes") dnl Check if we're a little-endian or a big-endian system, needed by hash code AC_DEFUN([AC_C_ENDIAN], [AC_CACHE_CHECK(for endianness, ac_cv_c_endian, [ AC_RUN_IFELSE( [AC_LANG_PROGRAM([], [dnl long val = 1; char *c = (char *) &val; exit(*c == 1); ]) ],[ ac_cv_c_endian=big ],[ ac_cv_c_endian=little ]) ]) if test $ac_cv_c_endian = big; then AC_DEFINE(ENDIAN_BIG, 1, [machine is bigendian]) fi if test $ac_cv_c_endian = little; then AC_DEFINE(ENDIAN_LITTLE, 1, [machine is littleendian]) fi ]) AC_C_ENDIAN AC_CONFIG_FILES([ Makefile docs/conf.py libhashkit-1.0/configure.h libmemcached-1.0/configure.h libmemcached-1.2/configure.h libmemcached-2.0/configure.h support/libmemcached.pc support/libmemcached.spec support/libmemcached-fc.spec libtest/version.h ]) AC_OUTPUT echo "---" echo "Configuration summary for $PACKAGE_NAME version $VERSION" echo "" echo " * Installation prefix: $prefix" echo " * System type: $host_vendor-$host_os" echo " * Host CPU: $host_cpu" echo " * C Compiler: $CC_VERSION" echo " * Assertions enabled: $ac_cv_assert" echo " * Debug enabled: $with_debug" echo " * Warnings as failure: $ac_cv_warnings_as_errors" echo " * SASL support: $ac_enable_sasl" echo "" echo "---" case "$host_os" in *freebsd*) echo "*****" echo "*" echo "* NOTE: You are on FreeBSD. BSD make will not work." echo "*" echo "* use 'gmake' To build libmemcached" echo "*" echo "*****" ;; esac libmemcached-1.0.8/NEWS0000664000076400007640000000001611753573717015113 0ustar00brianbrian00000000000000See Changelog libmemcached-1.0.8/.quickly0000664000076400007640000000015711753573717016104 0ustar00brianbrian00000000000000project = libmemcached version = 0.4.2 template = pandora-build project-type = library pandora-version = 0.175 libmemcached-1.0.8/win32/0000775000076400007640000000000011757025117015347 5ustar00brianbrian00000000000000libmemcached-1.0.8/win32/include.am0000664000076400007640000000060211753573717017321 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root noinst_HEADERS+= win32/wrappers.h if BUILD_WIN32_WRAPPERS libhashkit_libhashkit_la_LDFLAGS+=-no-undefined libmemcached_libmemcached_la_LDFLAGS+=-no-undefined libmemcached_libmemcachedprotocol_la_LDFLAGS+=-no-undefined libmemcached_libmemcachedutil_la_LDFLAGS+=-no-undefined endif libmemcached-1.0.8/win32/wrappers.h0000664000076400007640000000262011753573717017375 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2010 Brian Aker, Trond Norbye * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: "Implementation" of the function we don't have on windows * to avoid a bunch of ifdefs in the rest of the code * */ #ifndef WIN32_WRAPPERS_H #define WIN32_WRAPPERS_H 1 #include /* * One of the Windows headers define interface as a macro, but that * is causing problems with the member named "interface" in some of the * structs. */ #undef interface #undef malloc #undef realloc /* * WinSock use a separate range for error codes. Let's just map to the * WinSock ones. */ #define EADDRINUSE WSAEADDRINUSE #define EWOULDBLOCK WSAEWOULDBLOCK #define EINPROGRESS WSAEINPROGRESS #define EALREADY WSAEALREADY #define EISCONN WSAEISCONN #define ENOTCONN WSAENOTCONN #define ENOBUFS WSAENOBUFS #define SHUT_RDWR SD_BOTH /* EAI_SYSTEM isn't defined anywhere... just set it to... 11? */ #define EAI_SYSTEM 11 /* Best effort mapping of functions to alternative functions */ #define index(a,b) strchr(a,b) #define rindex(a,b) strrchr(a,b) #define random() rand() #define srandom(a) while (false) {} #define kill(a, b) while (false) {} #define fork() (-1) #define waitpid(a,b,c) (-1) #define fnmatch(a,b,c) (-1) #define sleep(a) Sleep(a*1000) #endif /* WIN32_WRAPPERS_H */ libmemcached-1.0.8/poll/0000775000076400007640000000000011757025120015345 5ustar00brianbrian00000000000000libmemcached-1.0.8/poll/include.am0000664000076400007640000000031711753573717017330 0ustar00brianbrian00000000000000# vim:ft=automake # included from Top Level Makefile.am # All paths should be given relative to the root noinst_HEADERS+= poll/poll.h if BUILD_POLL libmemcached_libmemcached_la_SOURCES += poll/poll.c endif libmemcached-1.0.8/poll/poll.h0000664000076400007640000000127011753573717016504 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2010 Brian Aker, Trond Norbye * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: Implementation of poll by using select * */ #ifndef POLL_POLL_H #define POLL_POLL_H 1 #ifdef WIN32 #include #endif #ifdef __cplusplus extern "C" { #endif typedef struct pollfd { #ifdef WIN32 SOCKET fd; #else int fd; #endif short events; short revents; } pollfd_t; typedef int nfds_t; #define POLLIN 0x0001 #define POLLOUT 0x0004 #define POLLERR 0x0008 int poll(struct pollfd fds[], nfds_t nfds, int tmo); #ifdef __cplusplus } #endif #endif libmemcached-1.0.8/poll/poll.c0000664000076400007640000000305311753573717016500 0ustar00brianbrian00000000000000/* LibMemcached * Copyright (C) 2010 Brian Aker, Trond Norbye * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * * Summary: Implementation of poll by using select * */ #include "config.h" #include #include int poll(struct pollfd fds[], nfds_t nfds, int tmo) { fd_set readfds, writefds, errorfds; FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&errorfds); int maxfd= 0; for (nfds_t x= 0; x < nfds; ++x) { if (fds[x].events & (POLLIN | POLLOUT)) { #ifndef WIN32 if (fds[x].fd > maxfd) { maxfd= fds[x].fd; } #endif if (fds[x].events & POLLIN) { FD_SET(fds[x].fd, &readfds); } if (fds[x].events & POLLOUT) { FD_SET(fds[x].fd, &writefds); } } } struct timeval timeout= { .tv_sec = tmo / 1000, .tv_usec= (tmo % 1000) * 1000 }; struct timeval *tp= &timeout; if (tmo == -1) { tp= NULL; } int ret= select(maxfd + 1, &readfds, &writefds, &errorfds, tp); if (ret <= 0) { return ret; } /* Iterate through all of them because I need to clear the revent map */ for (nfds_t x= 0; x < nfds; ++x) { fds[x].revents= 0; if (FD_ISSET(fds[x].fd, &readfds)) { fds[x].revents |= POLLIN; } if (FD_ISSET(fds[x].fd, &writefds)) { fds[x].revents |= POLLOUT; } if (FD_ISSET(fds[x].fd, &errorfds)) { fds[x].revents |= POLLERR; } } return ret; } libmemcached-1.0.8/ChangeLog0000664000076400007640000004765611757023210016171 0ustar00brianbrian000000000000001.0.8 Tue May 22 15:06:04 EDT 2012 * Added support for setting options via ENV variable LIBMEMCACHED * Fix corner case on last used result. 1.0.7 Sat Apr 28 00:48:29 PDT 2012 * Add API call for exist calls. * Update all license files to be BSD. 1.0.6 Sat Apr 7 18:26:49 PDT 2012 * Fixes for gcc 4.7, lp:961812 * Fix for restart issue that happens under testing. * Fix for lp:962815. * Support for transparent AES encryption. 1.0.5 Tue Mar 13 22:56:47 PDT 2012 * Fixes for OSX. * Version is now parsed directly in the parser, which makes buffered operations now work with it.. * memstat has been extended so that it can be used to find the version of the server. * Update documentation. * Fixes for compile issues on Debian and Ubuntu 1.0.4 Thu Jan 26 22:33:54 PST 2012 * Fix for memcached_dump(). * Additional testing for memcached_stat_execute(). 1.0.3 Sun Jan 8 18:11:36 PST 2012 * Increased size of sort buffer used during Ketama. * Added support for new behavior to handle dead servers. * Overall haul of UDP IO. * Fixed C compile issue with memcached_exist() * Numerous bug fixes. * Clang support for OSX. * All commands now using vector send support. 1.0.2 Mon Oct 24 08:00:48 PDT 2011 * Dropped libmemcached/memcached_util.h (undocumented header file) * Added memcached_touch() and memcached_touch_by_key() * UDP support restructured to toggle on a complete memcached_st structure. 0.53 Mon Sep 26 20:50:33 PDT 2011 * Fix for FreeBSD/OpenBSD and -lm * Added memcached_exist() * Fix for memory when using config test. * CLI gained --quiet 0.52 Sun Sep 11 22:16:08 PDT 2011 * Build fixes for Ubuntu/Suse. * Fixes for OSX Lion. * Bug fix for looping back through dns lookups under certain failures. * Fixes related to dead server failures. 0.51 Thu Jul 21 11:08:58 PDT 2011 * memcached_callback_set() now takes its data argument as const * Update to tests. * Fix in parser for port number. 0.50 Mon Jun 20 10:36:57 PDT 2011 * Updates to C++ interface * Custom free allocators need to now check for value before calling free. * memcached_fetch_result() now uses the internal result when available (about 25 to 50% faster). * Fix for stats structure. * Updates to documentation. * memcached_fetch_result() now uses the internal result when available (about 25 to 50% faster). 0.49 Thu Apr 14 08:43:37 PDT 2011 * Fix calls to auto methods so that if value is not passed in nothing bad happens. * New parser calls for generating memcached_st objects. * New error system. * New flow control for messages means faster get/set calls. * Added new documentation system. * A behavior change has been now made that if you specify a weight for any server, we enable the weight flag and do weight balancing. * Added MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS to simplify the setting of AUTO REJECT for servers. 0.48 Tue Mar 15 23:05:18 PDT 2011 * Fix memory leak in server parse. * Move test framework out to be its own library (easier to work with Gearman). 0.47 Wed Feb 23 18:46:48 PST 2011 * Additional fixes for OpenBSD. * Bug fix 677609, 456080. * SIGPIPE fix for Linux send(). * memcapable can now test ascii or binary based on flags. * Additional build fixes for SASL. 0.46 Mon Feb 14 10:28:01 PST 2011 * Fixes a number of corner case bugs. * Fixes related to OpenBSD. * Better testing for protocol version. * Removes special case infinite wait on blocking setup. 0.45 Tue Feb 8 16:02:06 PST 2011 * Add support for systemtap 0.44 Wed Sep 22 21:57:57 PDT 2010 * Windows bug fixes. * Hudson port support in test harness. * Improved portability of test hanrness. * SASL fixes. 0.43 Wed Jul 28 16:29:47 PDT 2010 * Added --args to memstat so that a greater range of values can be returned. * Prelimanary support for Windows. * memcached_stat_execute() merged. 0.42 Tue Jul 6 12:29:50 PDT 2010 * Mistake in libtool caused issue with library version 0.41 Wed Jun 30 13:15:19 PDT 2010 * Added --file for memcat. * Added limemcached_ping() to libmemcached_util * Bugfix for some cases where connect would have issues with timeout. * Wrong value for errno given as error on an IO failure inside of poll. * Bug fix for issue where multiple interfaces with bad DNS were not being caught. 0.40 Thu Apr 22 19:01:25 PDT 2010 * Placed retry logic in for busted resolvers * Add an ignore for SIGPIPE to solve OSX issues. * A couple of fixed for memcached_light server. * Updated to debug mode to track io_wait 0.39 Tue Apr 6 12:35:13 PDT 2010 * Add support for prefix keys to binary protocol. * Remove the undocumented call memcached_server_remove(). * The undocumented call memcached_server_by_key() now returns const. * memcached_server_error_reset() has been deprecated. * memcached_server_list() has been deprecated. Use memcached_server_cursor() to walk the servers found in a memcached_st() structure. * memcached_verbosity() can now be run concurrently with other operations. * SASL support. * Fixes memory leak found in EJECT HOSTS. 0.38 Wed Feb 10 09:40:33 PST 2010 * C++ interface for libhashkit. * Modified memcached_set_memory_allocators() so that it requires a context pointer. * memcached_clone() now runs 5 times faster. * Functions used for callbacks are now given const memcached_st. * Added MEMCACHED_BEHAVIOR_CORK. * memslap now creates a configuration file at ~/.memslap.cnf * memcached_purge() now calls any callbacks registered during get execution. * Many fixes to memslap. * Updates for memcapable. * Compile fixes for OpenBSD. * Fix for possible recursive decent on IO failure. 0.37 Mon Jan 11 16:29:57 PST 2010 * Fixed build for libhashkit. * Fixed install path regression. * Modified RPM to strict check install. * Added documentation for memcached_server_cursor(); * Added memcached_servers_reset(). * Modified memcached_st to remove dead cursor_server member. 0.36 Wed Jan 6 18:23:50 PST 2010 * Merged in new memslap utility. * All of constants.h has been updated to match style (all old identifiers continue to work). * Added first pass for libhashkit. * Updated test Framework/extended tests. * Random read support during replication added. * Modified use_sort so that the option can be applied to any distribution type. * We removed the MEMCACHED_BEHAVIOR_KETAMA_COMPAT_MODE added in 0.35. Instead use memcached_behavior_set_distribution(). 0.35 Mon Nov 9 11:18:33 PST 2009 * Added support for by_key operations for inc/dec methods. * Added mget test to memslap. * Support for compatible ketama for SpyMemcached * Update C++ interface. * Fix for memcp 0.34 Tue Oct 13 08:39:51 PDT 2009 * Added support for setting behavior flags on a connection pool. * Don't increment server_failure_counter on normal disconnects. * Added prototype for a callback based protocol parser (server side) with examples so that you could let your own application speak the memcached protocol * Updated memcapable to test ASCII protocol. * Changed behavior so that server can be removed at first sign of failure. * Added memcached_server_get_last_disconnect() call 0.33 Wed Sep 23 10:11:58 PDT 2009 * Added memcapable to test servers for binary compatibility. * Updated C++ interface. Added basic support for C++ exceptions. Added multiple constructors the memcached client object. The C++ interface now takes parameters which are C++ types (such as std::string). * Several bug fixes for binary protocol support. * Fixed crashing issue with dumping from memcachd server (server internals were changed without documenting change). 0.32 Tue Sep 15 15:49:09 PDT 2009 * Change of behavior where linger is only modified for no-block and then it is set to zero. * Added Twitter's memcached_server_error() functions. * Fix for OSX compiles in development builds. * Updated C++ interface. * Updated memcached_mget and memcached_mget_by_key to take a size_t as a parameter instead of an unsigned int for number_of_keys. 0.31 Fri Jul 10 09:02:50 PDT 2009 * Added support or HA via replication. * malloc() removed for server key usage. * Update build system. * Added support for memcached_set_memory_allocators(). * Fixed bug in configure.ac for have_htoll. 0.30 Sun May 31 17:31:52 PDT 2009 * Added memcachd_dump command (and framework for memdump tool). * Realigned all structures to remove padding (and line up important bits for 64bit caches. * Remove some of sprintf() in storage calls(). * Removed printf() in stat call for unknown stat member. * memcached_generate_hash() function added. * Added tests to make sure all hash functions are stable. 0.29 Tue May 19 08:26:48 PDT 2009 * Fixed malloc usage to calloc for spots where we need zero filled memory. * All code warnings now treated as errors. * Fixes for debian packaging. * Added new pooling mechanism. * MEMCACHED_BEHAVIOR_NO_BLOCK no longer also sets MEMCACHED_BEHAVIOR_BUFFER_REQUESTS. * Updated generic rpm. 0.28 Tue Apr 14 18:56:28 PDT 2009 * Fixed bug in init sructure (reapplied) * Fixed bug in get/set by key (nikkhils@gmail.com) 0.27 Sun Mar 29 22:33:01 PDT 2009 * Added new UDP fire-forget mode. * Reworked performance for mget() to better make use of async protocol * Cleaned up execution of fetch (just one set of code now) * Fixed Jenkin's for big endian hosts. * Updates for memstat to determine network latency. * Updates for binary protocol. * Many updates to documentation. 0.26 Thu Jan 29 13:05:50 PST 2009 * Fix for decrement on hash key * Fixed assert that was catching bad memset() call in host_reset() * Fix purge issue for blocked IO which has been stacked. 0.25 Fri Nov 28 09:59:35 PST 2008 * Jenkins HASH added. * Update of Murmur hash code * Support explicit weights (Robey Pointer, Evan Weaver) * Bugfix for ketama continuum (Robey Pointer) * New behavior MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY (Robey Pointer) * Don't ever call stats for weighting servers, because it is unstable. 0.24 Tue Sep 16 02:59:03 PDT 2008 (never released) * Cleanup compile warnings. * Fix issues in partitioning by keys. * Fixed "fail case" to make sure when calling memcached_clone() no memcached_st is over written. * New memcached_server_by_key() method for finding a server from a key. * memcached_server_free() was added for freeing server structures. 0.23 Sun Sep 7 08:13:59 PDT 2008 * Added strings.h header for Solaris 9 * Solaris 64bit fix. * Support for weighted Ketama from Yin Chen. * Fix for Chinese * Fix for 0 length key to trigger bad key. * Added behaviors MEMCACHED_BEHAVIOR_SND_TIMEOUT, MEMCACHED_BEHAVIOR_RCV_TIMEOUT * Support for Binary Protocol added 0.22 Mon Jul 14 09:24:11 PDT 2008 * Fix where master key was no being checked for "bad key" * Fixed bugs in stats output (thread output was wrong) * Clarified MEMCACHED_BAD_KEY_PROVIDED is return for bad prefix key. * Found a bug in Flags return (Jacek Ostrowski) * Fixed issue with compiling on Visual Studio 0.21 Fri May 23 18:34:09 PDT 2008 * Change of char * to const char * for all key based functions. * New MEMCACHED_CALLBACK_PREFIX_KEY added. You can now create domains for values. * Fixed bug introducd in last version on memcp * Fix for death of file io to call shutdown() 0.20 Mon May 5 08:34:26 PDT 2008 * New consistent distribution tests. * Found a memory leak when a server constantly fails. * Fix in watchpoint macro * Changed default timeout to 1 second for poll timeouts * Wheel uses less memory/dynamic allocation for size (no longer limited to 512 hosts by default. * memslap memory leak fix * Added Ketama distribution * Fix assert.h compile problem on CentOS 0.19 Wed Apr 9 09:30:53 PDT 2008 * Documentation fix in libmemcached. * Fixed bug where sort was always occuring on hosts * Logic fix in branch prediction (thanks Jay!) * Read through cached support. * Fixed for cas by key operation. * Fix for memcached_server_st list structures to have correct count. * Added callback MEMCACHED_CALLBACK_DELETE_TRIGGER * Removed function call in favor of macro (aka cut out some instructions) 0.18 Sun Mar 16 21:57:55 PDT 2008 * Fix plus tests for non-zero value objects and flags. * MEMCACHED_HASH_MURMUR added for murmur algorithm provided. * MEMCACHED_BEHAVIOR_RETRY_TIMEOUT added to keep connecting from looping on timeout. * gcc branch prediction optimizations * Refactored entire tree to make include files cleaner * Fixed leaked socket. 0.17 Wed Feb 27 03:33:29 PST 2008 * MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT added for connect timeout in non-block mode. * Incompatible change in memcached_behavior_set() api. We now use a uint64_t, instead of a pointer. * Fix for storage of values for zero. * memcached_server_cursor() function added to API for cycling through servers. 0.16 Mon Feb 18 00:30:25 PST 2008 * Work on the UDP protocol * Added get_by_key, set_by_key tests for C++ API * Fix for limit_maxbytes to be 64bit in stats * Added Atom Smasher test (scale baby, scale!) * Servers are now sorted, meaning that servers are now ordered so that clients with the same lists, will have same distribution. (Idea from Ross McFarland). MEMCACHED_BEHAVIOR_SORT_HOSTS was added to enable this support. * Added MEMCACHED_BAD_KEY_PROVIDED error for auto, set, and get operations. MEMCACHED_BEHAVIOR_VERIFY_KEY was added to enable this feature. * More error messages on command line tools. * Fixed bugs in memcached_cas() operator. * Fix to loop through interfaces 0.15 Tue Jan 29 14:55:44 PST 2008 * More work on the C++ API. * Bug fixes around block corner cases. * Slight performance increase in both read() and write(). 0.14 Tue Jan 22 06:21:49 PST 2008 * For for bug found by Evan Weaver where increment() was not returning propper error of value was not found. * Fix for bad null pointer on flag by Toru Maesaka. * Refactor of all IO to just pass in the active server * Problem configuring (PKG_CHECK_MODULES) fixed by removal of "rpath" in support/libmemcached.pc.in (Thanks to Ross McFarland). * Added memcached_callback_get()/set() * First prototype of C++ interface * Updated docs for uint16_t changes in previous release 0.13 Sun Jan 13 06:51:50 PST 2008 * MEMCACHED_BEHAVIOR_USER_DATA added to store user pointer. * Fix for failure to connect to invalidate socket. * Patch from Marc Rossi to add --hash option for memcp, memrm, and memcat. * Kevin's patch for fixing EOF issues during a read. * Toru Maesaka patch for stats mismatch * Fix for when CRC return 0 * Fixed uint16_t issues around flags. Turns out the documentation on the protocol was wrong. * Lingering socket fixes for FreeBSD. * Patches from Kevin Dalley for FreeBSD 4.0 * Added multi delete functions. * All get key returns have C style null termination * If memcached_server_list_append is passed NULLs instead of pointers it returns NULL. * Added memcached_fetch_execute() method * Found a bug where memcached_fetch() was not null terminating the result value. * memcached_behavior() now has the ability to set "buffering" so that data is not automatically flushed. * Behavior change, buffered commands now return MEMCACHED_BUFFERED 0.12 Tue Dec 11 15:20:55 PST 2007 * Updates for consistent hashing * IPV6 support * Static allocation for hostname (performance) * Fixed bug where in non-block mode all data might not have been sent on close(). * Refactor of memcached_get() to use common code. * Change in value fetch, MEMCACHED_END is now returned when keys are no longer in the pipe. * Fixed bug where key could be out of range of characters * Added _by_key() methods to allow partitioning of values to particular servers. * MEMCACHED_DEFAILT_TIMEOUT is now set to a non -1 value. * Performance improvements in get operations. 0.11 Mon Nov 26 01:05:52 PST 2007 * Added option to memcache_behavior_set() so that poll() can be timed out. * Fixed memory leak in case of using memcached_fetch_result() where no value was returned. * Bug fixed in memcached_connect() which would cause servers that did not need to be enabled to be enabled (performance issue). * Rewrote bounds checking code for get calls. * "make test" now starts its own memcached servers. * Added Hseih hash (MEMCACHED_HASH_HSIEH), which is showing about 7% performance over standard hash. 0.10 Tue Nov 20 23:22:31 PST 2007 * Added append binary test. * Added MEMCACHED_BEHAVIOR_CACHE_LOOKUPS behavior so that you can save on multiple DNS lookups. * Added CAS support, though this is optional and must be enabled during runtime. * Added the utility memerror to create human readable error strings from memcached errors (aka convert ints to strings) * Fixed type in MEMCACHED_HOST_LOOKUP_FAILURE * Fixed bug where hostname might not be null terminated * Moved to using gethostbyname_r() on Linux to solve thread safety issue * Added -rpath support for pkg-config * Documentation fix for hash setting using memcached_behavior_set() 0.9 Thu Nov 15 07:44:00 PST 2007 * fix for when no servers are definied. * different buffers are now kept for different connections to speed up async efforts * Modified increment/decrement functions to return uint64_t values * Fixed bug in cases where zero length keys were provided * Thread cleanup issue in memslap * No hostname lookup on reconnect * Fix for flag settings (was doing hex by accident!) * Support for 1.2.4 server additions "prepend" and "append" added. * Added memcached_version()... not sure if I will make this public or not. 0.8 Mon Nov 5 10:40:41 PST 2007 * Adding support for CRC hash method * Adding support for UNIX sockets * Added additional HASHing methods of FNV1_64,FNV1A_64, FNV1_32, FNV1A_32 * Added pkgconfig support (PKG_CHECK_MODULES) * Fixed conflict with defined type in MySQL * Added memcached_result_st structure and functions to manipulate it. 0.7 Tue Oct 30 09:24:05 PDT 2007 * Poved to poll() from select() * Fixes in internal string class for allocation of large numbers of strings. * memcached_mget() function now sends keys as it parses them instead of building strings as it goes. * Propper flush now for making sure we get all IO sent even when in non-block mode. * Added --enable-debug rule for configure * All asserts() removed (hey this is going into production!) 0.6 Wed Oct 17 08:41:35 PDT 2007 * get value returns are now null terminated (request by Cal Heldenbrand) * Fixed connections for more hosts then two. * Rewrite of the read/write IO systems to handle different sorts of host failures. * Added man pages for all functions and tools * Raised buffer size for readinng/writing to 16K * You can now optionally set the socket size for recv/send via memached_behavior_set/get. 0.5 Tue Oct 9 00:22:25 PDT 2007 * Ruby maintainer mentioned TCP_NODELAY patch he had added. Added this to C library as well. (Eric Hodel drbrain@segment7.net) * Added support script for set_benchmark * Updated memslap to allow testing of TCP_NODELAY * Updated memslap to support --flush (aka dump memcache servers before testing) * Fixed bug in multiple hosts not being activated * Added environmental variable MEMCACHED_SERVERS which can be used to set the servers list. * fixed memcached_stat method (and now memstat works) * server connect now happens on demand. * Help for all command line applications 0.4 Wed Oct 3 10:28:50 PDT 2007 * Added buffered IO to write calls for keys * Added buffered IO for reads * memstat was broken (bad if/else on connect) * New non-blocking IO (not default yet). Mucho faster * Refactor of test system. * memslap crash solved 0.3 Mon Oct 1 06:37:52 PDT 2007 * Jeff Fisher provided a spec file * Added "make rpm" around dist file * Added support for Solaris * Added support for DTrace * Fixed read to be recv and write to be send * Bug fix where memstat would core if no server was found * Added memslap tool (load generator) * Numerous bug fixes in library * Added calls to library for creating host lists (see text cases to understand how to use this). 0.2 Thu Sep 27 03:46:57 PDT 2007 * First public version libmemcached-1.0.8/libtest/0000775000076400007640000000000011757025120016045 5ustar00brianbrian00000000000000libmemcached-1.0.8/libtest/test.hpp0000664000076400007640000000514611753573717017563 0ustar00brianbrian00000000000000/* 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. * */ /* Structures for generic tests. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include libmemcached-1.0.8/libtest/common.h0000664000076400007640000000452311753573717017532 0ustar00brianbrian00000000000000/* 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. * */ /* Common include file for libtest */ #pragma once #include #include #include #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_WAIT_H #include #endif #ifdef HAVE_SYS_RESOURCE_H #include #endif #ifdef HAVE_FNMATCH_H #include #endif #include #include #include #include #include #include #include #include #include libmemcached-1.0.8/libtest/timer.cc0000664000076400007640000000373211753573717017521 0ustar00brianbrian00000000000000/* 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 #include #include namespace libtest { std::ostream& operator<<(std::ostream& output, const libtest::Timer& arg) { struct timespec temp; arg.difference(temp); output << temp.tv_sec; output << ":"; output << temp.tv_nsec; return output; } } // namespace libtest libmemcached-1.0.8/libtest/cpu.cc0000664000076400007640000000511411753573717017164 0ustar00brianbrian00000000000000/* 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 #include #include #if defined(HAVE_SYS_SYSCTL_H) && HAVE_SYS_SYSCTL_H #include #endif namespace libtest { size_t number_of_cpus() { size_t number_of_cpu= 1; #if TARGET_OS_LINUX number_of_cpu= sysconf(_SC_NPROCESSORS_ONLN); #elif defined(HAVE_SYS_SYSCTL_H) && defined(CTL_HW) && defined(HW_NCPU) && defined(HW_AVAILCPU) && defined(HW_NCPU) int mib[4]; size_t len= sizeof(number_of_cpu); /* set the mib for hw.ncpu */ mib[0] = CTL_HW; mib[1] = HW_AVAILCPU; // alternatively, try HW_NCPU; /* get the number of CPUs from the system */ sysctl(mib, 2, &number_of_cpu, &len, NULL, 0); if (number_of_cpu < 1) { mib[1]= HW_NCPU; sysctl(mib, 2, &number_of_cpu, &len, NULL, 0 ); if (number_of_cpu < 1 ) { number_of_cpu = 1; } } #else fprintf(stderr, "Going with guessing\n"); #endif return number_of_cpu; } } // namespace libtest libmemcached-1.0.8/libtest/dream.h0000664000076400007640000000335011753573717017327 0ustar00brianbrian00000000000000/* 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. * */ #pragma once namespace libtest { void dream(time_t tv_sec, long tv_nsec= 0); } libmemcached-1.0.8/libtest/include.am0000664000076400007640000002001611756613302020012 0ustar00brianbrian00000000000000# vim:ft=automake # # included from Top Level Makefile.am # All paths should be given relative to the root # LIBTOOL_COMMAND= ${abs_top_builddir}/libtool --mode=execute VALGRIND_EXEC_COMMAND= $(LIBTOOL_COMMAND) valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE VALGRIND_COMMAND= TESTS_ENVIRONMENT="valgrind" $(VALGRIND_EXEC_COMMAND) HELGRIND_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=helgrind --read-var-info=yes --error-exitcode=1 --read-var-info=yes DRD_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=drd GDB_COMMAND= $(LIBTOOL_COMMAND) gdb -f -x libtest/run.gdb PTRCHECK_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=exp-ptrcheck --error-exitcode=1 export LIBTOOL_COMMAND export VALGRIND_COMMAND export HELGRIND_COMMAND export DRD_COMMAND export GDB_COMMAND valgrind: @echo make check TESTS_ENVIRONMENT="\"$(VALGRIND_EXEC_COMMAND)\"" gdb: @echo make check TESTS_ENVIRONMENT="\"$(GDB_COMMAND)\"" helgrind: @echo make check TESTS_ENVIRONMENT="\"$(HELGRIND_COMMAND)\"" drd: @echo make check TESTS_ENVIRONMENT="\"$(DRD_COMMAND)\"" EXTRA_DIST+= libtest/run.gdb CLEANFILES+= tmp_chroot/etc/* CLEANFILES+= tmp_chroot/var/drizzle/* CLEANFILES+= tmp_chroot/var/log/* CLEANFILES+= tmp_chroot/var/run/* CLEANFILES+= tmp_chroot/var/tmp/* .PHONY: distclean-libtest-check distclean-libtest-check: -rm -rf tmp_chroot noinst_HEADERS+= libtest/timer.hpp noinst_HEADERS+=libtest/binaries.h noinst_HEADERS+=libtest/cpu.hpp noinst_HEADERS+=libtest/blobslap_worker.h noinst_HEADERS+=libtest/callbacks.h noinst_HEADERS+=libtest/cmdline.h noinst_HEADERS+=libtest/collection.h noinst_HEADERS+=libtest/common.h noinst_HEADERS+=libtest/comparison.hpp noinst_HEADERS+=libtest/core.h noinst_HEADERS+=libtest/dream.h noinst_HEADERS+=libtest/error.h noinst_HEADERS+=libtest/failed.h noinst_HEADERS+=libtest/fatal.hpp noinst_HEADERS+=libtest/framework.h noinst_HEADERS+=libtest/gearmand.h noinst_HEADERS+=libtest/drizzled.h noinst_HEADERS+=libtest/get.h noinst_HEADERS+=libtest/has.hpp noinst_HEADERS+=libtest/http.hpp noinst_HEADERS+=libtest/is_pid.hpp noinst_HEADERS+=libtest/is_local.hpp noinst_HEADERS+=libtest/killpid.h noinst_HEADERS+=libtest/libtool.hpp noinst_HEADERS+=libtest/memcached.h noinst_HEADERS+=libtest/port.h noinst_HEADERS+=libtest/runner.h noinst_HEADERS+=libtest/server.h noinst_HEADERS+=libtest/server_container.h noinst_HEADERS+=libtest/signal.h noinst_HEADERS+=libtest/socket.hpp noinst_HEADERS+=libtest/stream.h noinst_HEADERS+=libtest/strerror.h noinst_HEADERS+=libtest/string.hpp noinst_HEADERS+=libtest/test.h noinst_HEADERS+=libtest/test.hpp noinst_HEADERS+=libtest/tmpfile.hpp noinst_HEADERS+=libtest/vchar.hpp noinst_HEADERS+=libtest/visibility.h noinst_HEADERS+=libtest/wait.h noinst_LTLIBRARIES+= libtest/libtest.la libtest_libtest_la_CXXFLAGS= libtest_libtest_la_DEPENDENCIES= libtest_libtest_la_LIBADD= libtest_libtest_la_SOURCES= libtest_libtest_la_SOURCES+= libtest/binaries.cc libtest_libtest_la_SOURCES+= libtest/cmdline.cc libtest_libtest_la_SOURCES+= libtest/comparison.cc libtest_libtest_la_SOURCES+= libtest/collection.cc libtest_libtest_la_SOURCES+= libtest/core.cc libtest_libtest_la_SOURCES+= libtest/cpu.cc libtest_libtest_la_SOURCES+= libtest/dream.cc libtest_libtest_la_SOURCES+= libtest/fatal.cc libtest_libtest_la_SOURCES+= libtest/framework.cc libtest_libtest_la_SOURCES+= libtest/has.cc libtest_libtest_la_SOURCES+= libtest/drizzled.cc libtest_libtest_la_SOURCES+= libtest/http.cc libtest_libtest_la_SOURCES+= libtest/is_local.cc libtest_libtest_la_SOURCES+= libtest/killpid.cc libtest_libtest_la_SOURCES+= libtest/libtool.cc libtest_libtest_la_SOURCES+= libtest/main.cc libtest_libtest_la_SOURCES+= libtest/port.cc libtest_libtest_la_SOURCES+= libtest/runner.cc libtest_libtest_la_SOURCES+= libtest/server.cc libtest_libtest_la_SOURCES+= libtest/server_container.cc libtest_libtest_la_SOURCES+= libtest/signal.cc libtest_libtest_la_SOURCES+= libtest/socket.cc libtest_libtest_la_SOURCES+= libtest/strerror.cc libtest_libtest_la_SOURCES+= libtest/timer.cc 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+= -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_DEPENDENCIES+= libtest_tmp_dir libtest_libtest_la_DEPENDENCIES+=libtest/abort libtest_libtest_la_DEPENDENCIES+=libtest/wait # Declare unittest so that we can append to it libtest_unittest_CXXFLAGS= libtest_unittest_LDADD= libtest_unittest_DEPENDENCIES= # We are either building in tree, or with if BUILDING_LIBMEMCACHED libtest_libtest_la_DEPENDENCIES+= libmemcached/libmemcached.la libtest_libtest_la_DEPENDENCIES+= libmemcached/libmemcachedutil.la libtest_libtest_la_LIBADD+= libmemcached/libmemcached.la libtest_libtest_la_LIBADD+= libmemcached/libmemcachedutil.la libtest_libtest_la_SOURCES+= libtest/memcached.cc libtest_libtest_la_CXXFLAGS+= -DHAVE_LIBMEMCACHED libtest_unittest_CXXFLAGS+= -DHAVE_LIBMEMCACHED libtest_unittest_LDADD+= libmemcached/libmemcached.la libtest_unittest_LDADD+= libmemcached/libmemcachedutil.la libtest_unittest_DEPENDENCIES+= libmemcached/libmemcached.la libtest_unittest_DEPENDENCIES+= libmemcached/libmemcachedutil.la else if HAVE_LIBMEMCACHED libtest_libtest_la_LIBADD+= $(libmemcached_LIBS) libtest_libtest_la_SOURCES+= libtest/memcached.cc else libtest_libtest_la_CXXFLAGS+= -DHAVE_LIBMEMCACHED=0 libtest_unittest_CXXFLAGS+= -DHAVE_LIBMEMCACHED=0 endif endif if HAVE_LIBDRIZZLE libtest_libtest_la_LIBADD+= $(libdrizzle_LIBS) libtest_libtest_la_CXXFLAGS+= $(libdrizzle_CFLAGS) endif if BUILDING_GEARMAN libtest_libtest_la_DEPENDENCIES+= libgearman/libgearman.la libtest_libtest_la_LIBADD+= libgearman/libgearman.la libtest_libtest_la_SOURCES+= libtest/blobslap_worker.cc libtest_libtest_la_SOURCES+= libtest/gearmand.cc libtest_libtest_la_SOURCES+= util/instance.cc libtest_libtest_la_SOURCES+= util/operation.cc libtest_unittest_LDADD+= libgearman/libgearman.la 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_SOURCES+= libtest/blobslap_worker.cc libtest_libtest_la_SOURCES+= libtest/gearmand.cc libtest_libtest_la_SOURCES+= util/instance.cc libtest_libtest_la_SOURCES+= util/operation.cc endif endif libtest_tmp_dir: tmp_chroot/var/log tmp_chroot/var/tmp tmp_chroot/var/run tmp_chroot/var/drizzle tmp_chroot: tmp_chroot/etc @$(mkdir_p) tmp_chroot tmp_chroot/etc: @$(mkdir_p) tmp_chroot/etc tmp_chroot/var: tmp_chroot @$(mkdir_p) tmp_chroot/var tmp_chroot/var/log: tmp_chroot/var @$(mkdir_p) tmp_chroot/var/log tmp_chroot/var/tmp: tmp_chroot/var @$(mkdir_p) tmp_chroot/var/tmp tmp_chroot/var/drizzle: tmp_chroot/var @$(mkdir_p) tmp_chroot/var/drizzle tmp_chroot/var/run: tmp_chroot/var @$(mkdir_p) tmp_chroot/var/run libtest_unittest_DEPENDENCIES+= libtest/libtest.la libtest_unittest_LDADD+= libtest/libtest.la libtest_unittest_SOURCES= libtest/unittest.cc check_PROGRAMS+= libtest/unittest noinst_PROGRAMS+= libtest/unittest test-unittest: libtest/unittest @libtest/unittest valgrind-unittest: libtest/unittest @$(VALGRIND_COMMAND) libtest/unittest TESTS_ENVIRONMENT="valgrind" gdb-unittest: libtest/unittest @$(GDB_COMMAND) libtest/unittest helgrind-unittest: libtest/unittest @$(HELGRIND_COMMAND) libtest/unittest drd-unittest: libtest/unittest @$(DRD_COMMAND) libtest/unittest libtest_skiptest_LDADD= libtest/libtest.la libtest_skiptest_SOURCES= libtest/skiptest.cc check_PROGRAMS+= libtest/skiptest noinst_PROGRAMS+= libtest/skiptest test-skip: libtest/skiptest @libtest/skiptest libtest_wait_SOURCES= libtest_wait_SOURCES+= libtest/wait.cc libtest_wait_SOURCES+= libtest/dream.cc noinst_PROGRAMS+= libtest/wait libtest_abort_SOURCES= libtest/abort.cc noinst_PROGRAMS+= libtest/abort libmemcached-1.0.8/libtest/comparison.hpp0000664000076400007640000001206611753763014020744 0ustar00brianbrian00000000000000/* 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. * */ #pragma once #include #if defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED #include #include #endif #if defined(HAVE_LIBGEARMAN) && HAVE_LIBGEARMAN #include #endif namespace libtest { LIBTEST_API bool gdb_is_caller(void); LIBTEST_API bool valgrind_is_caller(void); LIBTEST_API bool _in_valgrind(const char *file, int line, const char *func); template bool _compare_truth_hint(const char *file, int line, const char *func, T_comparable __expected, const char *assertation_label, T_hint __hint) { if (__expected == false) { libtest::stream::make_cerr(file, line, func) << "Assertation \"" << assertation_label << "\" failed, hint: " << __hint; return false; } return true; } template bool _compare(const char *file, int line, const char *func, const T1_comparable& __expected, const T2_comparable& __actual, bool use_io) { if (__expected != __actual) { if (use_io) { libtest::stream::make_cerr(file, line, func) << "Expected \"" << __expected << "\" got \"" << __actual << "\""; } return false; } return true; } template bool _compare_strcmp(const char *file, int line, const char *func, const T1_comparable& __expected, const T2_comparable& __actual) { if (__expected == NULL) { fatal_message("Expected value was NULL, programmer error"); } if (__actual == NULL) { libtest::stream::make_cerr(file, line, func) << "Expected " << __expected << " but got NULL"; return false; } if (strncmp(__expected, __actual, strlen(__expected))) { libtest::stream::make_cerr(file, line, func) << "Expected " << __expected << " passed \"" << __actual << "\""; return false; } return true; } template bool _compare_zero(const char *file, int line, const char *func, T_comparable __actual) { if (T_comparable(0) != __actual) { libtest::stream::make_cerr(file, line, func) << "Expected 0 got \"" << __actual << "\""; return false; } return true; } template bool _truth(const char *file, int line, const char *func, T_comparable __truth) { if (bool(__truth)) { libtest::stream::make_cerr(file, line, func) << "Assertion failed for " << func << "() with \"" << __truth << "\""; return false; } return true; } template bool _compare_hint(const char *file, int line, const char *func, T1_comparable __expected, T2_comparable __actual, T_hint __hint, bool io_error= true) { if (__expected != __actual) { if (io_error) { libtest::stream::make_cerr(file, line, func) << "Expected \"" << __expected << "\" got \"" << __actual << "\"" << " Additionally: \"" << __hint << "\""; } return false; } return true; } template bool _ne_compare_hint(const char *file, int line, const char *func, T1_comparable __expected, T2_comparable __actual, T_hint __hint, bool io_error= true) { if (__expected == __actual) { if (io_error) { libtest::stream::make_cerr(file, line, func) << "Expected \"" << __expected << "\" got \"" << __actual << "\"" << " Additionally: \"" << __hint << "\""; } return false; } return true; } } // namespace libtest libmemcached-1.0.8/libtest/wait.h0000664000076400007640000000561711753573717017213 0ustar00brianbrian00000000000000/* 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. * */ #pragma once #include #include #include #include namespace libtest { class Wait { public: Wait(const std::string &filename, uint32_t timeout= 6) : _successful(false) { uint32_t waited; uint32_t this_wait; uint32_t retry; if (filename.empty()) { _successful= false; return; } for (waited= 0, retry= 1; ; retry++, waited+= this_wait) { if (access(filename.c_str(), R_OK) == 0) { _successful= true; break; } else if (waited >= timeout) { break; } this_wait= retry * retry / 3 + 1; libtest::dream(this_wait, 0); } } Wait(const pid_t &_pid_arg, uint32_t timeout= 6) : _successful(false) { uint32_t waited; uint32_t this_wait; uint32_t retry; for (waited= 0, retry= 1; ; retry++, waited+= this_wait) { if (kill(_pid_arg, 0) == 0) { _successful= true; break; } else if (waited >= timeout) { break; } this_wait= retry * retry / 3 + 1; libtest::dream(this_wait, 0); } } bool successful() const { return _successful; } private: bool _successful; }; } // namespace libtest libmemcached-1.0.8/libtest/cmdline.cc0000664000076400007640000004246211753763014020006 0ustar00brianbrian00000000000000/* 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 #include using namespace libtest; #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef __USE_GNU static char **environ= NULL; #endif extern "C" { static int exited_successfully(int status) { if (status == 0) { return EXIT_SUCCESS; } if (WIFEXITED(status) == true) { return WEXITSTATUS(status); } else if (WIFSIGNALED(status) == true) { return WTERMSIG(status); } return EXIT_FAILURE; } } namespace { std::string print_argv(char * * & built_argv, const size_t& argc) { std::stringstream arg_buffer; for (size_t x= 0; x < argc; x++) { arg_buffer << built_argv[x] << " "; } return arg_buffer.str(); } std::string print_argv(char** argv) { std::stringstream arg_buffer; for (char** ptr= argv; *ptr; ptr++) { arg_buffer << *ptr << " "; } return arg_buffer.str(); } static Application::error_t int_to_error_t(int arg) { switch (arg) { case 127: return Application::INVALID; case 0: return Application::SUCCESS; default: case 1: return Application::FAILURE; } } } namespace libtest { Application::Application(const std::string& arg, const bool _use_libtool_arg) : _use_libtool(_use_libtool_arg), _use_valgrind(false), _use_gdb(false), _use_ptrcheck(false), _will_fail(false), _argc(0), _exectuble(arg), stdin_fd(STDIN_FILENO), stdout_fd(STDOUT_FILENO), stderr_fd(STDERR_FILENO), built_argv(NULL), _pid(-1) { if (_use_libtool) { if (libtool() == NULL) { fatal_message("libtool requested, but know libtool was found"); } } // Find just the name of the application with no path { size_t found= arg.find_last_of("/\\"); if (found) { _exectuble_name= arg.substr(found +1); } else { _exectuble_name= arg; } } if (_use_libtool and getenv("PWD")) { _exectuble_with_path+= getenv("PWD"); _exectuble_with_path+= "/"; } _exectuble_with_path+= _exectuble; } Application::~Application() { murder(); delete_argv(); } Application::error_t Application::run(const char *args[]) { stdin_fd.reset(); stdout_fd.reset(); stderr_fd.reset(); _stdout_buffer.clear(); _stderr_buffer.clear(); posix_spawn_file_actions_t file_actions; posix_spawn_file_actions_init(&file_actions); stdin_fd.dup_for_spawn(file_actions); stdout_fd.dup_for_spawn(file_actions); stderr_fd.dup_for_spawn(file_actions); posix_spawnattr_t spawnattr; posix_spawnattr_init(&spawnattr); sigset_t set; sigemptyset(&set); fatal_assert(posix_spawnattr_setsigmask(&spawnattr, &set) == 0); create_argv(args); int spawn_ret; if (_use_gdb) { std::string gdb_run_file= create_tmpfile(_exectuble_name); std::fstream file_stream; file_stream.open(gdb_run_file.c_str(), std::fstream::out | std::fstream::trunc); _gdb_filename= create_tmpfile(_exectuble_name); file_stream << "set logging redirect on" << std::endl << "set logging file " << _gdb_filename << std::endl << "set logging overwrite on" << std::endl << "set logging on" << std::endl << "set environment LIBTEST_IN_GDB=1" << std::endl << "run " << arguments() << std::endl << "thread apply all bt" << std::endl << "quit" << std::endl; fatal_assert(file_stream.good()); file_stream.close(); if (_use_libtool) { // libtool --mode=execute gdb -f -x binary char *argv[]= { const_cast(libtool()), const_cast("--mode=execute"), const_cast("gdb"), const_cast("-batch"), const_cast("-f"), const_cast("-x"), const_cast(gdb_run_file.c_str()), const_cast(_exectuble_with_path.c_str()), 0}; spawn_ret= posix_spawnp(&_pid, libtool(), &file_actions, &spawnattr, argv, environ); } else { // gdb binary char *argv[]= { const_cast("gdb"), const_cast("-batch"), const_cast("-f"), const_cast("-x"), const_cast(gdb_run_file.c_str()), const_cast(_exectuble_with_path.c_str()), 0}; spawn_ret= posix_spawnp(&_pid, "gdb", &file_actions, &spawnattr, argv, environ); } } else { if (_use_libtool) { spawn_ret= posix_spawn(&_pid, built_argv[0], &file_actions, &spawnattr, built_argv, NULL); } else { spawn_ret= posix_spawnp(&_pid, built_argv[0], &file_actions, &spawnattr, built_argv, NULL); } } posix_spawn_file_actions_destroy(&file_actions); posix_spawnattr_destroy(&spawnattr); stdin_fd.close(Application::Pipe::READ); stdout_fd.close(Application::Pipe::WRITE); stderr_fd.close(Application::Pipe::WRITE); if (spawn_ret != 0) { if (_will_fail == false) { Error << strerror(spawn_ret) << "(" << spawn_ret << ")"; } _pid= -1; return Application::INVALID; } return Application::SUCCESS; } bool Application::check() const { if (_pid > 1 and kill(_pid, 0) == 0) { return true; } return false; } void Application::murder() { if (check()) { int count= 5; while ((count--) > 0 and check()) { int kill_ret= kill(_pid, SIGTERM); if (kill_ret == 0) { int status= 0; pid_t waitpid_ret; if ((waitpid_ret= waitpid(_pid, &status, WNOHANG)) == -1) { switch (errno) { case ECHILD: case EINTR: break; default: Error << "waitpid() failed after kill with error of " << strerror(errno); break; } } if (waitpid_ret == 0) { libtest::dream(1, 0); } } else { Error << "kill(pid, SIGTERM) failed after kill with error of " << strerror(errno); continue; } break; } // If for whatever reason it lives, kill it hard if (check()) { (void)kill(_pid, SIGKILL); } } slurp(); } // false means that no data was returned bool Application::slurp() { struct pollfd fds[2]; fds[0].fd= stdout_fd.fd(); fds[0].events= POLLRDNORM; fds[0].revents= 0; fds[1].fd= stderr_fd.fd(); fds[1].events= POLLRDNORM; fds[1].revents= 0; int active_fd; if ((active_fd= poll(fds, 2, 0)) == -1) { int error; switch ((error= errno)) { #ifdef TARGET_OS_LINUX case ERESTART: #endif case EINTR: break; case EFAULT: case ENOMEM: fatal_message(strerror(error)); break; case EINVAL: fatal_message("RLIMIT_NOFILE exceeded, or if OSX the timeout value was invalid"); break; default: fatal_message(strerror(error)); break; } return false; } if (active_fd == 0) { return false; } bool data_was_read= false; if (fds[0].revents & POLLRDNORM) { if (stdout_fd.read(_stdout_buffer) == true) { data_was_read= true; } } if (fds[1].revents & POLLRDNORM) { if (stderr_fd.read(_stderr_buffer) == true) { data_was_read= true; } } return data_was_read; } Application::error_t Application::wait(bool nohang) { if (_pid == -1) { return Application::INVALID; } slurp(); error_t exit_code= FAILURE; { int status= 0; pid_t waited_pid; if ((waited_pid= waitpid(_pid, &status, nohang ? WNOHANG : 0)) == -1) { switch (errno) { case ECHILD: exit_code= Application::SUCCESS; break; case EINTR: break; default: Error << "Error occured while waitpid(" << strerror(errno) << ") on pid " << int(_pid); break; } } else if (waited_pid == 0) { exit_code= Application::SUCCESS; } else { if (waited_pid != _pid) { throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "Pid mismatch, %d != %d", int(waited_pid), int(_pid)); } exit_code= int_to_error_t(exited_successfully(status)); } } slurp(); #if 0 if (exit_code == Application::INVALID) { Error << print_argv(built_argv, _argc); } #endif return exit_code; } void Application::add_long_option(const std::string& name, const std::string& option_value) { std::string arg(name); arg+= option_value; _options.push_back(std::make_pair(arg, std::string())); } void Application::add_option(const std::string& arg) { _options.push_back(std::make_pair(arg, std::string())); } void Application::add_option(const std::string& name, const std::string& value) { _options.push_back(std::make_pair(name, value)); } Application::Pipe::Pipe(int arg) : _std_fd(arg) { _pipe_fd[READ]= -1; _pipe_fd[WRITE]= -1; _open[READ]= false; _open[WRITE]= false; } int Application::Pipe::Pipe::fd() { if (_std_fd == STDOUT_FILENO) { return _pipe_fd[READ]; } else if (_std_fd == STDERR_FILENO) { return _pipe_fd[READ]; } return _pipe_fd[WRITE]; // STDIN_FILENO } bool Application::Pipe::read(libtest::vchar_t& arg) { fatal_assert(_std_fd == STDOUT_FILENO or _std_fd == STDERR_FILENO); bool data_was_read= false; ssize_t read_length; char buffer[1024]= { 0 }; while ((read_length= ::read(_pipe_fd[READ], buffer, sizeof(buffer)))) { if (read_length == -1) { switch(errno) { case EAGAIN: break; default: Error << strerror(errno); break; } break; } data_was_read= true; arg.reserve(read_length +1); for (size_t x= 0; x < read_length; x++) { arg.push_back(buffer[x]); } // @todo Suck up all errput code here } return data_was_read; } void Application::Pipe::nonblock() { int ret; if ((ret= fcntl(_pipe_fd[READ], F_GETFL, 0)) == -1) { Error << "fcntl(F_GETFL) " << strerror(errno); throw strerror(errno); } if ((ret= fcntl(_pipe_fd[READ], F_SETFL, ret | O_NONBLOCK)) == -1) { Error << "fcntl(F_SETFL) " << strerror(errno); throw strerror(errno); } } void Application::Pipe::reset() { close(READ); close(WRITE); #if HAVE_PIPE2 if (pipe2(_pipe_fd, O_NONBLOCK) == -1) #else if (pipe(_pipe_fd) == -1) #endif { fatal_message(strerror(errno)); } _open[0]= true; _open[1]= true; if (true) { nonblock(); cloexec(); } } void Application::Pipe::cloexec() { int ret; if ((ret= fcntl(_pipe_fd[WRITE], F_GETFD, 0)) == -1) { Error << "fcntl(F_GETFD) " << strerror(errno); throw strerror(errno); } if ((ret= fcntl(_pipe_fd[WRITE], F_SETFD, ret | FD_CLOEXEC)) == -1) { Error << "fcntl(F_SETFD) " << strerror(errno); throw strerror(errno); } } Application::Pipe::~Pipe() { if (_pipe_fd[0] != -1) { ::close(_pipe_fd[0]); } if (_pipe_fd[1] != -1) { ::close(_pipe_fd[1]); } } void Application::Pipe::dup_for_spawn(posix_spawn_file_actions_t& file_actions) { int type= STDIN_FILENO == _std_fd ? 0 : 1; int ret; if ((ret= posix_spawn_file_actions_adddup2(&file_actions, _pipe_fd[type], _std_fd )) < 0) { Error << "posix_spawn_file_actions_adddup2(" << strerror(ret) << ")"; fatal_message(strerror(ret)); } if ((ret= posix_spawn_file_actions_addclose(&file_actions, _pipe_fd[type])) < 0) { Error << "posix_spawn_file_actions_adddup2(" << strerror(ret) << ")"; fatal_message(strerror(ret)); } } void Application::Pipe::close(const close_t& arg) { int type= int(arg); if (_open[type]) { int ret; if (::close(_pipe_fd[type]) == -1) { Error << "close(" << strerror(errno) << ")"; } _open[type]= false; _pipe_fd[type]= -1; } } void Application::create_argv(const char *args[]) { delete_argv(); fatal_assert(_argc == 0); if (_use_libtool) { _argc+= 2; // +2 for libtool --mode=execute } _argc+= 1; // For the command /* valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --track-origin=yes --malloc-fill=A5 --free-fill=DE --log-file= */ if (_use_valgrind) { _argc+= 8; } else if (_use_ptrcheck) { /* valgrind --error-exitcode=1 --tool=exp-ptrcheck --log-file= */ _argc+= 4; } else if (_use_gdb) // gdb { _argc+= 1; } for (Options::const_iterator iter= _options.begin(); iter != _options.end(); iter++) { _argc++; if ((*iter).second.empty() == false) { _argc++; } } if (args) { for (const char **ptr= args; *ptr; ++ptr) { _argc++; } } _argc+= 1; // for the NULL built_argv= new char * [_argc]; size_t x= 0; if (_use_libtool) { assert(libtool()); built_argv[x++]= strdup(libtool()); built_argv[x++]= strdup("--mode=execute"); } if (_use_valgrind) { /* valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE */ built_argv[x++]= strdup("valgrind"); built_argv[x++]= strdup("--error-exitcode=1"); built_argv[x++]= strdup("--leak-check=yes"); built_argv[x++]= strdup("--show-reachable=yes"); built_argv[x++]= strdup("--track-fds=yes"); #if 0 built_argv[x++]= strdup("--track-origin=yes"); #endif built_argv[x++]= strdup("--malloc-fill=A5"); built_argv[x++]= strdup("--free-fill=DE"); std::string log_file= create_tmpfile("valgrind"); char buffer[1024]; int length= snprintf(buffer, sizeof(buffer), "--log-file=%s", log_file.c_str()); fatal_assert(length > 0 and length < sizeof(buffer)); built_argv[x++]= strdup(buffer); } else if (_use_ptrcheck) { /* valgrind --error-exitcode=1 --tool=exp-ptrcheck --log-file= */ built_argv[x++]= strdup("valgrind"); built_argv[x++]= strdup("--error-exitcode=1"); built_argv[x++]= strdup("--tool=exp-ptrcheck"); _argc+= 4; std::string log_file= create_tmpfile("ptrcheck"); char buffer[1024]; int length= snprintf(buffer, sizeof(buffer), "--log-file=%s", log_file.c_str()); fatal_assert(length > 0 and length < sizeof(buffer)); built_argv[x++]= strdup(buffer); } else if (_use_gdb) { built_argv[x++]= strdup("gdb"); } built_argv[x++]= strdup(_exectuble_with_path.c_str()); for (Options::const_iterator iter= _options.begin(); iter != _options.end(); iter++) { built_argv[x++]= strdup((*iter).first.c_str()); if ((*iter).second.empty() == false) { built_argv[x++]= strdup((*iter).second.c_str()); } } if (args) { for (const char **ptr= args; *ptr; ++ptr) { built_argv[x++]= strdup(*ptr); } } built_argv[x++]= NULL; fatal_assert(x == _argc); } std::string Application::print() { return print_argv(built_argv, _argc); } std::string Application::arguments() { std::stringstream arg_buffer; for (size_t x= 1 + _use_libtool ? 2 : 0; x < _argc and built_argv[x]; x++) { arg_buffer << built_argv[x] << " "; } return arg_buffer.str(); } void Application::delete_argv() { if (built_argv) { for (size_t x= 0; x < _argc; x++) { if (built_argv[x]) { ::free(built_argv[x]); } } delete[] built_argv; built_argv= NULL; _argc= 0; } } int exec_cmdline(const std::string& command, const char *args[], bool use_libtool) { Application app(command, use_libtool); Application::error_t ret= app.run(args); if (ret != Application::SUCCESS) { return int(ret); } return int(app.wait(false)); } const char *gearmand_binary() { return GEARMAND_BINARY; } const char *drizzled_binary() { return DRIZZLED_BINARY; } } // namespace exec_cmdline libmemcached-1.0.8/libtest/drizzled.cc0000664000076400007640000001136211753573717020226 0ustar00brianbrian00000000000000/* 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 #include #include #include "util/instance.hpp" #include "util/operation.hpp" using namespace datadifferential; using namespace libtest; #include #include #include #include #include #include #include #include #include #include #include #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wold-style-cast" #endif #if defined(HAVE_LIBDRIZZLE) && HAVE_LIBDRIZZLE #include #endif using namespace libtest; namespace libtest { bool ping_drizzled(const in_port_t _port) { #if defined(HAVE_LIBDRIZZLE) && HAVE_LIBDRIZZLE { drizzle_st *drizzle= drizzle_create(NULL); if (drizzle == NULL) { return false; } drizzle_con_st *con; if ((con= drizzle_con_create(drizzle, NULL)) == NULL) { drizzle_free(drizzle); return false; } drizzle_con_set_tcp(con, "localhost", _port); drizzle_con_set_auth(con, "root", 0); bool success= false; drizzle_return_t rc; if ((rc= drizzle_con_connect(con)) == DRIZZLE_RETURN_OK) { drizzle_result_st *result= drizzle_ping(con, NULL, &rc); success= bool(result); drizzle_result_free(result); } if (success == true) { } else if (rc != DRIZZLE_RETURN_OK) { Error << drizzle_error(drizzle) << " localhost:" << _port; } drizzle_con_free(con); drizzle_free(drizzle); return success; } #endif return false; } } // namespace libtest class Drizzle : public libtest::Server { private: public: Drizzle(const std::string& host_arg, in_port_t port_arg) : libtest::Server(host_arg, port_arg, DRIZZLED_BINARY, false) { set_pid_file(); } bool ping() { size_t limit= 5; while (_app.check() and --limit) { if (ping_drizzled(_port)) { return true; } libtest::dream(1, 0); } return false; } const char *name() { return "drizzled"; }; void log_file_option(Application& app, const std::string& arg) { } bool has_log_file_option() const { return true; } bool broken_pid_file() { return true; } bool is_libtool() { return false; } bool has_syslog() const { return true; } bool has_port_option() const { return true; } void port_option(Application& app, in_port_t arg) { if (arg > 0) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "--drizzle-protocol.port=%d", int(arg)); app.add_option(buffer); } } bool build(size_t argc, const char *argv[]); }; bool Drizzle::build(size_t argc, const char *argv[]) { if (getuid() == 0 or geteuid() == 0) { add_option("--user=root"); } add_option("--verbose=INSPECT"); #if 0 add_option("--datadir=var/drizzle"); #endif for (size_t x= 0 ; x < argc ; x++) { add_option(argv[x]); } return true; } namespace libtest { libtest::Server *build_drizzled(const char *hostname, in_port_t try_port) { return new Drizzle(hostname, try_port); } } libmemcached-1.0.8/libtest/server_container.h0000664000076400007640000000656411753573717021621 0ustar00brianbrian00000000000000/* 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. * */ #pragma once #include #include #include #include #include #include #include #include namespace libtest { class server_startup_st { private: uint64_t _magic; std::string server_list; bool _socket; bool _sasl; uint32_t _count; std::string _username; std::string _password; public: uint8_t udp; std::vector servers; server_startup_st(); ~server_startup_st(); bool validate(); bool start_socket_server(const std::string& server_type, const in_port_t try_port, int argc, const char *argv[]); uint32_t count() const { return servers.size(); } void restart(); std::string option_string() const; const std::string& password() const { return _password; } const std::string& username() const { return _username; } bool socket() { return _socket; } bool sasl() { return _sasl; } void set_socket() { _socket= true; } void set_sasl(const std::string& username_arg, const std::string& password_arg) { _sasl= true; _username= username_arg; _password= password_arg; } // Just remove everything after shutdown void clear(); bool shutdown(); bool shutdown(uint32_t number_of_host); bool check() const; void push_server(Server *); Server *pop_server(); unsigned long int servers_to_run() const { return _servers_to_run; } void set_servers_to_run(unsigned long int arg) { _servers_to_run= arg; } private: unsigned long int _servers_to_run; }; bool server_startup(server_startup_st&, const std::string&, in_port_t try_port, int argc, const char *argv[], const bool opt_startup_message= true); } // namespace libtest libmemcached-1.0.8/libtest/blobslap_worker.h0000664000076400007640000000335611753573717021434 0ustar00brianbrian00000000000000/* 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. * */ #pragma once namespace libtest { Server *build_blobslap_worker(in_port_t try_port); } libmemcached-1.0.8/libtest/is_local.cc0000664000076400007640000000346211753573717020166 0ustar00brianbrian00000000000000/* 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 #include namespace libtest { bool test_is_local() { return (getenv("LIBTEST_LOCAL")); } } // namespace libtest libmemcached-1.0.8/libtest/binaries.h0000664000076400007640000000357311753573717020042 0ustar00brianbrian00000000000000/* 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. * */ #pragma once namespace libtest { LIBTEST_API bool has_memcached_binary(); LIBTEST_API bool has_memcached_sasl_binary(); LIBTEST_API bool has_gearmand_binary(); LIBTEST_API bool has_drizzled_binary(); } // namespace libtest libmemcached-1.0.8/libtest/string.hpp0000664000076400007640000000401511753573717020104 0ustar00brianbrian00000000000000/* 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. * */ #pragma once #include "util/string.hpp" #define test_literal_param util_literal_param #define test_literal_compare_param util_literal_compare_param #define test_literal_param_size util_literal_param_size #define test_string_make_from_cstr util_string_make_from_cstr #define test_string_make_from_array util_string_make_from_array #define test_array_length util_array_length libmemcached-1.0.8/libtest/framework.h0000664000076400007640000001037711753763014020232 0ustar00brianbrian00000000000000/* 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. * */ #pragma once #include /** Framework is the structure which is passed to the test implementation to be filled. This must be implemented in order for the test framework to load the tests. We call get_world() in order to fill this structure. */ #include class Framework { public: public: test_return_t create(); void create(test_callback_create_fn* arg) { _create= arg; } void destroy(test_callback_destroy_fn* arg) { _destroy= arg; } void collections(collection_st* arg) { _collections= arg; } void set_on_error(test_callback_error_fn *arg) { _on_error= arg; } test_return_t on_error(const enum test_return_t, void *); void set_socket() { _servers.set_socket(); } void set_sasl(const std::string& username_arg, const std::string& password_arg) { _servers.set_sasl(username_arg, password_arg); } libtest::server_startup_st& servers() { return _servers; } void set_runner(libtest::Runner *arg) { _runner= arg; } libtest::Runner *runner(); void exec(); libtest::Collection& collection(); Framework(libtest::SignalThread&, const std::string&); virtual ~Framework(); Framework(libtest::SignalThread&, const std::string&, const std::string&); bool match(const char* arg); void *creators_ptr() { return _creators_ptr; } libtest::SignalThread& signal() { return _signal; } uint32_t sum_total(); uint32_t sum_success(); uint32_t sum_skipped(); uint32_t sum_failed(); size_t size() { return _collection.size(); } uint32_t total() const { return _total; } uint32_t success() const { return _success; } uint32_t skipped() const { return _skipped; } uint32_t failed() const { return _failed; } private: Framework& operator=(const Framework&); collection_st *_collections; uint32_t _total; uint32_t _success; uint32_t _skipped; uint32_t _failed; /* These methods are called outside of any collection call. */ test_callback_create_fn *_create; test_callback_destroy_fn *_destroy; /** If an error occurs during the test, this is called. */ test_callback_error_fn *_on_error; /** Runner represents the callers for the tests. If not implemented we will use a set of default implementations. */ libtest::Runner *_runner; libtest::server_startup_st _servers; bool _socket; void *_creators_ptr; unsigned long int _servers_to_run; std::vector _collection; libtest::SignalThread& _signal; std::string _only_run; std::string _wildcard; }; libmemcached-1.0.8/libtest/tmpfile.hpp0000664000076400007640000000343611753573717020244 0ustar00brianbrian00000000000000/* 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. * */ #pragma once #include namespace libtest { std::string create_tmpfile(const std::string&); } // namespace libtest libmemcached-1.0.8/libtest/runner.h0000664000076400007640000000446111753573717017554 0ustar00brianbrian00000000000000/* 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. * */ #pragma once namespace libtest { /** Structure which houses the actual callers for the test cases contained in the collections. */ class Runner { public: virtual test_return_t flush(void*); virtual test_return_t run(test_callback_fn* func, void *object); virtual test_return_t pre(test_callback_fn* func, void *object); virtual test_return_t post(test_callback_fn* func, void *object); Runner(); void set_servers(libtest::server_startup_st& arg) { _servers= &arg; } bool check() { return _servers ? _servers->check() : true; } virtual ~Runner() { } private: libtest::server_startup_st* _servers; }; } // namespace Runner libmemcached-1.0.8/libtest/vchar.hpp0000664000076400007640000000441511753573717017705 0ustar00brianbrian00000000000000/* 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. * */ #pragma once #include #include #include #include #include namespace libtest { typedef std::vector vchar_ptr_t; typedef std::vector vchar_t; void make_vector(libtest::vchar_t& arg, const char *str, size_t length); namespace vchar { int compare(libtest::vchar_t& arg, const char *str, size_t length); void make(libtest::vchar_t& arg); void make(libtest::vchar_t& arg, size_t length); } // namespace vchar #define vchar_param(__arg) (&__arg[0]), (__arg.size()) std::ostream& operator<<(std::ostream& output, const libtest::vchar_t& arg); } // namespace libtest libmemcached-1.0.8/libtest/skiptest.cc0000664000076400007640000000367011756613237020243 0ustar00brianbrian00000000000000/* 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 #include #include #include using namespace libtest; static void *world_create(server_startup_st&, test_return_t& rc) { rc= TEST_SKIPPED; return NULL; } void get_world(Framework *world) { world->create(world_create); } libmemcached-1.0.8/libtest/port.h0000664000076400007640000000356411753763014017221 0ustar00brianbrian00000000000000/* 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. * */ /* Structures for generic tests. */ #pragma once namespace libtest { LIBTEST_API in_port_t default_port(); LIBTEST_API in_port_t get_free_port(); LIBTEST_API void release_port(in_port_t arg); } // namespace libtest libmemcached-1.0.8/libtest/killpid.cc0000664000076400007640000001137611753573717020034 0ustar00brianbrian00000000000000/* 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 #include #include #include #include #include #include #include #include #include #include #include using namespace libtest; bool kill_pid(pid_t pid_arg) { assert(pid_arg > 0); if (pid_arg < 1) { Error << "Invalid pid:" << pid_arg; return false; } if ((::kill(pid_arg, SIGTERM) == -1)) { switch (errno) { case EPERM: Error << "Does someone else have a process running locally for " << int(pid_arg) << "?"; return false; case ESRCH: Error << "Process " << int(pid_arg) << " not found."; return false; default: case EINVAL: Error << "kill() " << strerror(errno); return false; } } int status= 0; if (waitpid(pid_arg, &status, 0) == -1) { switch (errno) { // Just means that the server has already gone away case ECHILD: { return true; } } Error << "Error occured while waitpid(" << strerror(errno) << ") on pid " << int(pid_arg); return false; } return true; } bool check_pid(const std::string &filename) { if (filename.empty()) { return false; } FILE *fp; if ((fp= fopen(filename.c_str(), "r"))) { char pid_buffer[1024]; char *ptr= fgets(pid_buffer, sizeof(pid_buffer), fp); fclose(fp); if (ptr) { pid_t pid= (pid_t)atoi(pid_buffer); if (pid > 0) { return (::kill(pid, 0) == 0); } } } return false; } bool kill_file(const std::string &filename) { if (filename.empty()) { return true; } FILE *fp; if ((fp= fopen(filename.c_str(), "r"))) { char pid_buffer[1024]; char *ptr= fgets(pid_buffer, sizeof(pid_buffer), fp); fclose(fp); if (ptr) { pid_t pid= (pid_t)atoi(pid_buffer); if (pid != 0) { bool ret= kill_pid(pid); unlink(filename.c_str()); // If this happens we may be dealing with a dead server that left its pid file. return ret; } } } return false; } #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) #define LIBTEST_AT __FILE__ ":" TOSTRING(__LINE__) pid_t get_pid_from_file(const std::string &filename, std::stringstream& error_message) { pid_t ret= -1; FILE *fp; if (filename.empty()) { error_message << LIBTEST_AT << " empty pid file"; return ret; } if ((fp= fopen(filename.c_str(), "r"))) { char pid_buffer[1024]; char *ptr= fgets(pid_buffer, sizeof(pid_buffer), fp); fclose(fp); if (ptr) { ret= (pid_t)atoi(pid_buffer); if (ret < 1) { error_message << LIBTEST_AT << " Invalid pid was read from file " << filename; } } else { error_message << LIBTEST_AT << " File " << filename << " was empty "; } return ret; } else { char buffer[1024]; char *current_directory= getcwd(buffer, sizeof(buffer)); error_message << "Error while opening " << current_directory << "/" << filename << " " << strerror(errno); } return ret; } libmemcached-1.0.8/libtest/error.h0000664000076400007640000000362611753573717017376 0ustar00brianbrian00000000000000/* 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. * */ #pragma once enum test_return_t { TEST_SUCCESS, TEST_FAILURE, TEST_SKIPPED }; static inline bool test_success(test_return_t rc) { return (rc == TEST_SUCCESS); } static inline bool test_failed(test_return_t rc) { return (rc != TEST_SUCCESS); } libmemcached-1.0.8/libtest/socket.hpp0000664000076400007640000000343611753573717020074 0ustar00brianbrian00000000000000 /* 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. * */ #pragma once namespace libtest { const char *default_socket(); void set_default_socket(const char *socket); } // namespace libtest libmemcached-1.0.8/libtest/dream.cc0000664000076400007640000000374011753573717017470 0ustar00brianbrian00000000000000/* 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 #include namespace libtest { void dream(time_t tv_sec, long tv_nsec) { #ifdef WIN32 if (tv_sec == 0 and tv_nsec) { tv_sec++; } sleep(tv_sec); #else struct timespec requested; requested.tv_sec= tv_sec; requested.tv_nsec= tv_nsec; nanosleep(&requested, NULL); #endif } } libmemcached-1.0.8/libtest/callbacks.h0000664000076400007640000000411011753573717020151 0ustar00brianbrian00000000000000/* 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. * */ #pragma once #ifdef __cplusplus extern "C" { #endif typedef void* (test_callback_create_fn)(libtest::server_startup_st&, test_return_t&); typedef bool test_callback_destroy_fn(void *); typedef enum test_return_t (test_callback_fn)(void *); typedef enum test_return_t (test_callback_runner_fn)(test_callback_fn*, void *); typedef enum test_return_t (test_callback_error_fn)(const test_return_t, void *); #ifdef __cplusplus } #endif libmemcached-1.0.8/libtest/gearmand.cc0000664000076400007640000001034711753573717020157 0ustar00brianbrian00000000000000/* 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 #include #include #include "util/instance.hpp" #include "util/operation.hpp" using namespace datadifferential; using namespace libtest; #include #include #include #include #include #include #include #include #include #include #include #include #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wold-style-cast" #endif using namespace libtest; class Gearmand : public libtest::Server { private: public: Gearmand(const std::string& host_arg, in_port_t port_arg) : libtest::Server(host_arg, port_arg, GEARMAND_BINARY, true) { set_pid_file(); } bool ping() { gearman_client_st *client= gearman_client_create(NULL); if (client == NULL) { Error << "Could not allocate memory for gearman_client_create()"; return false; } gearman_client_set_timeout(client, 3000); if (gearman_success(gearman_client_add_server(client, hostname().c_str(), port()))) { gearman_return_t rc= gearman_client_echo(client, test_literal_param("This is my echo test")); if (gearman_success(rc)) { gearman_client_free(client); return true; } #if 0 Error << hostname().c_str() << ":" << port() << " was " << gearman_strerror(rc) << " extended: " << gearman_client_error(client); #endif } else { Error << "gearman_client_add_server() " << gearman_client_error(client); } gearman_client_free(client); return false;; } const char *name() { return "gearmand"; }; void log_file_option(Application& app, const std::string& arg) { if (arg.empty() == false) { std::string buffer("--log-file="); buffer+= arg; app.add_option("--verbose=DEBUG"); app.add_option(buffer); } } bool has_log_file_option() const { return true; } bool is_libtool() { return true; } bool has_syslog() const { return false; // --syslog.errmsg-enable } bool has_port_option() const { return true; } bool build(size_t argc, const char *argv[]); }; bool Gearmand::build(size_t argc, const char *argv[]) { if (getuid() == 0 or geteuid() == 0) { add_option("-u", "root"); } add_option("--listen=localhost"); for (size_t x= 0 ; x < argc ; x++) { add_option(argv[x]); } return true; } namespace libtest { libtest::Server *build_gearmand(const char *hostname, in_port_t try_port) { return new Gearmand(hostname, try_port); } } libmemcached-1.0.8/libtest/fatal.cc0000664000076400007640000000612711753763014017460 0ustar00brianbrian00000000000000/* 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 #include #include namespace libtest { fatal::fatal(const char *file_arg, int line_arg, const char *func_arg, const char *format, ...) : std::runtime_error(func_arg), _line(line_arg), _file(file_arg), _func(func_arg) { va_list args; va_start(args, format); char last_error[BUFSIZ]; int last_error_length= vsnprintf(last_error, sizeof(last_error), format, args); va_end(args); strncpy(_mesg, last_error, sizeof(_mesg)); snprintf(_error_message, sizeof(_error_message), "%s:%d FATAL:%s (%s)", _file, int(_line), last_error, _func); } static bool _disabled= false; static uint32_t _counter= 0; bool fatal::is_disabled() { return _disabled; } void fatal::disable() { _disabled= true; } void fatal::enable() { _disabled= false; } uint32_t fatal::disabled_counter() { return _counter; } void fatal::increment_disabled_counter() { _counter++; } disconnected::disconnected(const char *file, int line, const char *func, const char *instance, const in_port_t port, const char *format, ...) : _port(port), std::runtime_error(func) { strncpy(_instance, instance, sizeof(_instance)); va_list args; va_start(args, format); char last_error[BUFSIZ]; (void)vsnprintf(last_error, sizeof(last_error), format, args); va_end(args); snprintf(_error_message, sizeof(_error_message), "%s:%d FATAL:%s (%s)", file, int(line), last_error, func); } } // namespace libtest libmemcached-1.0.8/libtest/blobslap_worker.cc0000664000076400007640000000771111753573717021571 0ustar00brianbrian00000000000000/* 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 #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef __INTEL_COMPILER #pragma GCC diagnostic ignored "-Wold-style-cast" #endif namespace libtest { class BlobslapWorker : public Server { private: public: BlobslapWorker(in_port_t port_arg) : Server("localhost", port_arg, "benchmark/blobslap_worker", true) { set_pid_file(); } pid_t get_pid(bool error_is_ok) { if (pid_file().empty()) { Error << "pid_file was empty"; return -1; } Wait wait(pid_file(), 0); if (error_is_ok and not wait.successful()) { Error << "Pidfile was not found:" << pid_file(); return -1; } std::stringstream error_message; pid_t ret= get_pid_from_file(pid_file(), error_message); if (error_is_ok and is_pid_valid(ret) == false) { Error << error_message.str(); } return ret; } bool ping() { if (pid_file().empty()) { Error << "No pid file available"; return false; } Wait wait(pid_file(), 0); if (not wait.successful()) { Error << "Pidfile was not found:" << pid_file(); return false; } std::stringstream error_message; pid_t local_pid= get_pid_from_file(pid_file(), error_message); if (is_pid_valid(local_pid) == false) { Error << error_message.str(); return false; } // Use kill to determine is the process exist if (::kill(local_pid, 0) == 0) { return true; } return false; } const char *name() { return "blobslap_worker"; }; bool has_port_option() const { return true; } bool has_log_file_option() const { return true; } bool is_libtool() { return true; } bool build(size_t argc, const char *argv[]); }; #include bool BlobslapWorker::build(size_t argc, const char *argv[]) { std::stringstream arg_buffer; for (size_t x= 0 ; x < argc ; x++) { add_option(argv[x]); } return true; } Server *build_blobslap_worker(in_port_t try_port) { return new BlobslapWorker(try_port); } } // namespace libtest libmemcached-1.0.8/libtest/libtool.cc0000664000076400007640000000452311753573717020044 0ustar00brianbrian00000000000000/* 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 #include #include char _libtool[1024]= { 0 }; namespace libtest { const char *libtool(void) { if (_libtool[0] == 0) { std::string libtool_buffer; if (getenv("PWD")) { libtool_buffer+= getenv("PWD"); libtool_buffer+= "/"; } else { libtool_buffer+= "./"; } libtool_buffer+= "libtool"; if (access(libtool_buffer.c_str(), R_OK | W_OK | X_OK)) { Error << "Could not find libtool via access(" << libtool_buffer << ") :" << strerror(errno); return NULL; } snprintf(_libtool, sizeof(_libtool), "%s", libtool_buffer.c_str()); } return _libtool; } } // namespace libtest libmemcached-1.0.8/libtest/memcached.h0000664000076400007640000000443011753573717020145 0ustar00brianbrian00000000000000/* 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. * */ #pragma once namespace libtest { libtest::Server *build_memcached(const std::string& hostname, const in_port_t try_port); libtest::Server *build_memcached_light(const std::string& socket_file, const in_port_t try_port); libtest::Server *build_memcached_socket(const std::string& socket_file, const in_port_t try_port); libtest::Server *build_memcached_sasl(const std::string& hostname, const in_port_t try_port, const std::string& username, const std::string& password); libtest::Server *build_memcached_sasl_socket(const std::string& socket_file, const in_port_t try_port, const std::string& username, const std::string& password); } libmemcached-1.0.8/libtest/gearmand.h0000664000076400007640000000350411753573717020016 0ustar00brianbrian00000000000000/* 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. * */ #pragma once #include namespace libtest { struct Server; } namespace libtest { libtest::Server *build_gearmand(const char *hostname, in_port_t try_port); } libmemcached-1.0.8/libtest/server_container.cc0000664000076400007640000002263411754025664021745 0ustar00brianbrian00000000000000/* 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 #include #include #include #include #include #include #include #include // trim from end static inline std::string &rtrim(std::string &s) { s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun(std::isspace))).base(), s.end()); return s; } namespace libtest { void server_startup_st::push_server(Server *arg) { servers.push_back(arg); char port_str[NI_MAXSERV]; snprintf(port_str, sizeof(port_str), "%u", int(arg->port())); std::string server_config_string; if (arg->has_socket()) { server_config_string+= "--socket="; server_config_string+= '"'; server_config_string+= arg->socket(); server_config_string+= '"'; server_config_string+= " "; } else { server_config_string+= "--server="; server_config_string+= arg->hostname(); server_config_string+= ":"; server_config_string+= port_str; server_config_string+= " "; } server_list+= server_config_string; } Server* server_startup_st::pop_server() { Server *tmp= servers.back(); servers.pop_back(); return tmp; } // host_to_shutdown => host number to shutdown in array bool server_startup_st::shutdown(uint32_t host_to_shutdown) { if (servers.size() > host_to_shutdown) { Server* tmp= servers[host_to_shutdown]; if (tmp and tmp->kill() == false) { } else { return true; } } return false; } void server_startup_st::clear() { for (std::vector::iterator iter= servers.begin(); iter != servers.end(); iter++) { delete *iter; } servers.clear(); } bool server_startup_st::check() const { bool success= true; for (std::vector::const_iterator iter= servers.begin(); iter != servers.end(); iter++) { if ((*iter)->check() == false) { success= false; } } return success; } bool server_startup_st::shutdown() { bool success= true; for (std::vector::iterator iter= servers.begin(); iter != servers.end(); iter++) { if ((*iter)->has_pid() and (*iter)->kill() == false) { Error << "Unable to kill:" << *(*iter); success= false; } } return success; } void server_startup_st::restart() { for (std::vector::iterator iter= servers.begin(); iter != servers.end(); iter++) { (*iter)->start(); } } #define MAGIC_MEMORY 123575 server_startup_st::server_startup_st() : _magic(MAGIC_MEMORY), _socket(false), _sasl(false), _count(0), udp(0), _servers_to_run(5) { } server_startup_st::~server_startup_st() { clear(); } bool server_startup_st::validate() { return _magic == MAGIC_MEMORY; } bool server_startup(server_startup_st& construct, const std::string& server_type, in_port_t try_port, int argc, const char *argv[], const bool opt_startup_message) { if (try_port <= 0) { throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "was passed the invalid port number %d", int(try_port)); } libtest::Server *server= NULL; try { if (0) { } else if (server_type.compare("gearmand") == 0) { if (GEARMAND_BINARY) { if (HAVE_LIBGEARMAN) { server= build_gearmand("localhost", try_port); } } } else if (server_type.compare("drizzled") == 0) { if (DRIZZLED_BINARY) { if (HAVE_LIBDRIZZLE) { server= build_drizzled("localhost", try_port); } } } else if (server_type.compare("blobslap_worker") == 0) { if (GEARMAND_BINARY) { if (GEARMAND_BLOBSLAP_WORKER) { if (HAVE_LIBGEARMAN) { server= build_blobslap_worker(try_port); } } } } else if (server_type.compare("memcached-sasl") == 0) { if (MEMCACHED_SASL_BINARY) { if (HAVE_LIBMEMCACHED) { server= build_memcached_sasl("localhost", try_port, construct.username(), construct.password()); } } } else if (server_type.compare("memcached") == 0) { if (MEMCACHED_BINARY) { if (HAVE_LIBMEMCACHED) { server= build_memcached("localhost", try_port); } } } else if (server_type.compare("memcached-light") == 0) { if (MEMCACHED_LIGHT_BINARY) { if (HAVE_LIBMEMCACHED) { server= build_memcached_light("localhost", try_port); } } } if (server == NULL) { fatal_message("Launching of an unknown server was attempted"); } /* We will now cycle the server we have created. */ if (server->cycle() == false) { Error << "Could not start up server " << *server; delete server; return false; } server->build(argc, argv); if (false) { Out << "Pausing for startup, hit return when ready."; std::string gdb_command= server->base_command(); std::string options; #if 0 Out << "run " << server->args(options); #endif getchar(); } else if (server->start() == false) { delete server; return false; } else { if (opt_startup_message) { Outn(); Out << "STARTING SERVER(pid:" << server->pid() << "): " << server->running(); Outn(); } } } catch (...) { delete server; throw; } construct.push_server(server); return true; } bool server_startup_st::start_socket_server(const std::string& server_type, const in_port_t try_port, int argc, const char *argv[]) { (void)try_port; Outn(); Server *server= NULL; try { if (0) { } else if (server_type.compare("gearmand") == 0) { Error << "Socket files are not supported for gearmand yet"; } else if (server_type.compare("memcached-sasl") == 0) { if (MEMCACHED_SASL_BINARY) { if (HAVE_LIBMEMCACHED) { server= build_memcached_sasl_socket("localhost", try_port, username(), password()); } else { Error << "Libmemcached was not found"; } } else { Error << "No memcached binary is available"; } } else if (server_type.compare("memcached") == 0) { if (MEMCACHED_BINARY) { if (HAVE_LIBMEMCACHED) { server= build_memcached_socket("localhost", try_port); } else { Error << "Libmemcached was not found"; } } else { Error << "No memcached binary is available"; } } else { Error << "Failed to start " << server_type << ", no support was found to be compiled in for it."; } if (server == NULL) { Error << "Failure occured while creating server: " << server_type; return false; } /* We will now cycle the server we have created. */ if (server->cycle() == false) { Error << "Could not start up server " << *server; delete server; return false; } server->build(argc, argv); if (false) { Out << "Pausing for startup, hit return when ready."; std::string gdb_command= server->base_command(); std::string options; #if 0 Out << "run " << server->args(options); #endif getchar(); } else if (server->start() == false) { Error << "Failed to start " << *server; delete server; return false; } else { Out << "STARTING SERVER(pid:" << server->pid() << "): " << server->running(); } } catch (...) { delete server; throw; } push_server(server); set_default_socket(server->socket().c_str()); Outn(); return true; } std::string server_startup_st::option_string() const { std::string temp= server_list; rtrim(temp); return temp; } } // namespace libtest libmemcached-1.0.8/libtest/killpid.h0000664000076400007640000000370011753573717017666 0ustar00brianbrian00000000000000/* 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. * */ #pragma once bool kill_pid(pid_t pid_arg); bool kill_file(const std::string &filename); bool check_pid(const std::string &filename); pid_t get_pid_from_file(const std::string &filename, std::stringstream& error_message); static inline bool check_pid(pid_t pid_arg) { return (pid_arg > 1); } libmemcached-1.0.8/libtest/drizzled.h0000664000076400007640000000355311753573717020073 0ustar00brianbrian00000000000000/* 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. * */ #pragma once #include namespace libtest { struct Server; } namespace libtest { libtest::Server *build_drizzled(const char *hostname, in_port_t try_port); bool ping_drizzled(const in_port_t); } libmemcached-1.0.8/libtest/stream.h0000664000076400007640000001202011753763014017513 0ustar00brianbrian00000000000000/* 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. * */ #pragma once #include #include #include #include #include namespace libtest { namespace stream { namespace detail { template class channel { private: public: typedef std::basic_ostringstream stream_buffer; public: void operator()(const stream_buffer& s, std::ostream& _out, const char* filename, int line_number, const char* func) { if (filename) { _out << filename << ":" << line_number << ": in " << func << "() " << s.str() << std::endl; } else { _out << s.str() << std::endl; } } }; template class channelln { private: public: typedef std::basic_ostringstream stream_buffer; public: void operator()(const stream_buffer& s, std::ostream& _out, const char* filename, int line_number, const char* func) { if (filename) { _out << std::endl << filename << ":" << line_number << ": in " << func << "() " << s.str() << std::endl; } else { _out << std::endl << s.str() << std::endl; } } }; template