From: Brian Aker Date: Sun, 25 Nov 2012 14:12:14 +0000 (-0500) Subject: Cleanup around linking. X-Git-Tag: 1.0.15~14^2~2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=3bb738d74511398cbe598b1a177a39bc93d8c84e;p=m6w6%2Flibmemcached Cleanup around linking. --- diff --git a/clients/include.am b/clients/include.am index 72fd39d4..bd38ef04 100644 --- a/clients/include.am +++ b/clients/include.am @@ -94,7 +94,7 @@ clients_memaslap_SOURCES+= clients/ms_thread.c clients_memaslap_SOURCES+= clients/generator.cc clients/execute.cc clients_memaslap_LDADD= -clients_memaslap_LDADD+= @LIBEVENT_LDFLAGS@ +clients_memaslap_LDADD+= @LIBEVENT_LIB@ clients_memaslap_LDADD+= $(CLIENTS_LDADDS) clients_memcapable_SOURCES= diff --git a/configure.ac b/configure.ac index a8fbcafa..0ca87389 100644 --- a/configure.ac +++ b/configure.ac @@ -47,6 +47,7 @@ m4_include([libhashkit/include.m4]) LT_PREREQ([2.2]) LT_INIT LT_LANG([C++]) +LT_LIB_M AX_ASSERT @@ -112,6 +113,7 @@ AC_CHECK_HEADERS_ONCE([dlfcn.h]) AC_CHECK_HEADERS_ONCE([errno.h]) AC_CHECK_HEADERS_ONCE([execinfo.h]) AC_CHECK_HEADERS_ONCE([fcntl.h]) +AC_CHECK_HEADERS_ONCE([fnmatch.h]) AC_CHECK_HEADERS_ONCE([inttypes.h]) AC_CHECK_HEADERS_ONCE([libintl.h]) AC_CHECK_HEADERS_ONCE([limits.h]) @@ -121,6 +123,7 @@ AC_CHECK_HEADERS_ONCE([math.h]) AC_CHECK_HEADERS_ONCE([netdb.h]) AC_CHECK_HEADERS_ONCE([netinet/in.h]) AC_CHECK_HEADERS_ONCE([netinet/tcp.h]) +AC_CHECK_HEADERS_ONCE([poll.h]) AC_CHECK_HEADERS_ONCE([pthread.h]) AC_CHECK_HEADERS_ONCE([spawn.h]) AC_CHECK_HEADERS_ONCE([stdarg.h]) @@ -131,13 +134,14 @@ AC_CHECK_HEADERS_ONCE([sys/socket.h]) AC_CHECK_HEADERS_ONCE([sys/sysctl.h]) AC_CHECK_HEADERS_ONCE([sys/time.h]) AC_CHECK_HEADERS_ONCE([sys/un.h]) +AC_CHECK_HEADERS_ONCE([sys/wait.h]) AC_CHECK_HEADERS_ONCE([syslog.h]) AC_CHECK_HEADERS_ONCE([time.h]) AC_CHECK_HEADERS_ONCE([unistd.h]) # Windows only -AC_CHECK_HEADERS([winsock2.h]) -AC_CHECK_HEADERS([ws2tcpip.h]) +AC_CHECK_HEADERS_ONCE([winsock2.h]) +AC_CHECK_HEADERS_ONCE([ws2tcpip.h]) # Checks for typedefs, structures, and compiler characteristics. @@ -160,6 +164,7 @@ AC_CHECK_FUNCS([pipe2]) AC_CHECK_FUNCS([putenv]) AC_CHECK_FUNCS([select]) AC_CHECK_FUNCS([setenv]) +AC_CHECK_FUNCS([sigignore]) AC_CHECK_FUNCS([socket]) AC_CHECK_FUNCS([sqrt]) AC_CHECK_FUNCS([strcasecmp]) @@ -214,14 +219,11 @@ AC_CHECK_LIB([rt],[clock_gettime], [AC_DEFINE([HAVE_CLOCK_GETTIME],[0],[Have clock_gettime])]) # Check for the ability to call dlopen -AS_IF([test "x$enable_static" = "xyes"], +AS_IF([test "x$enable_shared" = xyes], [AC_CHECK_LIB([dl],[dlopen], [AC_SUBST([DL_LIB],[-ldl]) AC_DEFINE([HAVE_LIBDL],[1],[Have dlopen])])], - [AC_DEFINE([HAVE_LIBDL], [0], [Have dlopen])]) - -AC_CHECK_LIB([m],[floor]) -AC_CHECK_FUNCS([sigignore]) + [AC_DEFINE([HAVE_LIBDL],[0],[Have dlopen])]) AC_CHECK_HEADERS([atomic.h]) AS_IF([test "x$ac_cv_header_atomic_h" = "xyes"], @@ -251,7 +253,6 @@ AC_CHECK_FUNCS([setppriv], build_solaris_privs=yes]) ]) -AC_CHECK_HEADERS_ONCE([winsock2.h poll.h sys/wait.h fnmatch.h]) AM_CONDITIONAL([BUILD_POLL],[test "x$ac_cv_header_poll_h" = "xno"]) AM_CONDITIONAL([BUILD_WIN32_WRAPPERS],[test "x$ac_cv_header_winsock2_h" = "xyes"]) AS_IF([test "x$ac_cv_header_winsock2_h" = "xyes"], @@ -263,7 +264,6 @@ SOCKET_SEND_FLAGS AX_UUID_GENERATE_TIME_SAFE - AC_DEFUN([CHECK_FOR_PTHREAD_AND_SASL], [AX_PTHREAD(, [AC_MSG_ERROR([could not find libpthread])]) AX_PTHREAD_TIMEDJOIN_NP @@ -279,9 +279,9 @@ AC_DEFUN([CHECK_FOR_PTHREAD_AND_SASL], CHECK_FOR_PTHREAD_AND_SASL -# backtrace() does not work with static builds. +# backtrace(), others require shared builds AS_IF([test "x$enable_shared" = "xyes"], - [AC_DEFINE([AX_ENABLE_BACKTRACE],[1],[Support for backtrace().])]) + [AC_DEFINE([HAVE_SHARED_ENABLED],[1],[Enable code which requires shared library support. Like backtrace().])]) AM_CONDITIONAL([SHARED_ENABLED],[test "x$enable_shared" = "xyes"]) PANDORA_ENABLE_DTRACE diff --git a/libhashkit/aes.cc b/libhashkit/aes.cc index 2e91e07c..c7083a6e 100644 --- a/libhashkit/aes.cc +++ b/libhashkit/aes.cc @@ -35,9 +35,9 @@ */ -#include +#include "libhashkit/common.h" -#include +#include "libhashkit/rijndael.hpp" #include diff --git a/libhashkit/include.am b/libhashkit/include.am index 3124a4e0..cfbacddc 100644 --- a/libhashkit/include.am +++ b/libhashkit/include.am @@ -22,6 +22,7 @@ noinst_HEADERS+= libhashkit/string.h nobase_include_HEADERS+= libhashkit/hashkit.h +libhashkit_libhashkit_la_LIBADD= libhashkit_libhashkit_la_SOURCES= libhashkit_libhashkit_la_CXXFLAGS= libhashkit_libhashkit_la_CFLAGS= @@ -58,7 +59,6 @@ endif libhashkit_libhashkit_la_CXXFLAGS+= -DBUILDING_HASHKIT libhashkit_libhashkit_la_CFLAGS+= -DBUILDING_HASHKIT -libhashkit_libhashkit_la_LIBADD= libhashkit_libhashkit_la_LDFLAGS= -version-info $(HASHKIT_LIBRARY_VERSION) # library used for testing @@ -66,4 +66,4 @@ noinst_LTLIBRARIES+= libhashkit/libhashkitinc.la libhashkit_libhashkitinc_la_SOURCES= ${libhashkit_libhashkit_la_SOURCES} libhashkit_libhashkitinc_la_CFLAGS= ${libhashkit_libhashkit_la_CFLAGS} -libhashkit_libhashkitinc_la_LDFLAGS= $(LIBM) +libhashkit_libhashkitinc_la_CXXFLAGS= ${libhashkit_libhashkit_la_CXXFLAGS} diff --git a/libhashkit/rijndael.cc b/libhashkit/rijndael.cc index 24b73628..93997ccb 100644 --- a/libhashkit/rijndael.cc +++ b/libhashkit/rijndael.cc @@ -63,7 +63,7 @@ #include #include -#include +#include "libhashkit/rijndael.hpp" /* Te0[x] = S [x].[02, 01, 01, 03]; diff --git a/libmemcached/backtrace.cc b/libmemcached/backtrace.cc index 98361ea5..782ea6a9 100644 --- a/libmemcached/backtrace.cc +++ b/libmemcached/backtrace.cc @@ -1,8 +1,8 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * libmcachedd client library. + * Libmemcached client library. * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2012 Data Differential, http://datadifferential.com/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,71 +35,97 @@ * */ -#include +#include "mem_config.h" -#ifdef AX_ENABLE_BACKTRACE +#include "libmemcached/backtrace.hpp" -#ifdef HAVE_EXECINFO_H -# include -#endif +#include +#include +#include -#ifdef HAVE_GCC_ABI_DEMANGLE -# include -#endif +#if defined(HAVE_SHARED_ENABLED) && HAVE_SHARED_ENABLED -#ifdef HAVE_DLFCN_H -# include +#ifdef HAVE_EXECINFO_H +#include #endif #ifdef HAVE_GCC_ABI_DEMANGLE +# include # define USE_DEMANGLE 1 #else # define USE_DEMANGLE 0 #endif +#ifdef HAVE_DLFCN_H +# include +#endif + const int MAX_DEPTH= 50; void custom_backtrace(void) { #ifdef HAVE_EXECINFO_H - void *array[MAX_DEPTH]; - - int backtrace_size= backtrace(array, MAX_DEPTH); - fprintf(stderr, "Number of stack frames obtained: %d\n", backtrace_size); + void *backtrace_buffer[MAX_DEPTH +1]; -#ifdef HAVE_DLFCN_H - Dl_info dlinfo; -#endif + int stack_frames= backtrace(backtrace_buffer, MAX_DEPTH); + if (stack_frames) + { + char **symbollist= backtrace_symbols(backtrace_buffer, stack_frames); + if (symbollist) + { + for (int x= 0; x < stack_frames; x++) + { + bool was_demangled= false; - for (int x= 0; x < backtrace_size; ++x) - { + if (USE_DEMANGLE) + { #ifdef HAVE_DLFCN_H - if (dladdr(array[x], &dlinfo) == 0) - { - continue; - } + Dl_info dlinfo; + if (dladdr(backtrace_buffer[x], &dlinfo)) + { + char demangled_buffer[1024]; + const char *called_in= ""; + if (dlinfo.dli_sname) + { + size_t demangled_size= sizeof(demangled_buffer); + int status; + char* demangled; + if ((demangled= abi::__cxa_demangle(dlinfo.dli_sname, demangled_buffer, &demangled_size, &status))) + { + called_in= demangled; + fprintf(stderr, "---> demangled: %s -> %s\n", demangled_buffer, demangled); + } + else + { + called_in= dlinfo.dli_sname; + } + + was_demangled= true; + fprintf(stderr, "#%d %lp in %s at %s\n", + x, backtrace_buffer[x], + called_in, + dlinfo.dli_fname); + } + } #endif + } - const char* symname= dlinfo.dli_sname; - - int status; - char* demangled= abi::__cxa_demangle(symname, NULL, 0, &status); - if (status == 0 and demangled) - { - symname= demangled; - } - - printf("object: %s, function: %s\n", dlinfo.dli_fname, symname); + if (was_demangled == false) + { + fprintf(stderr, "?%d %lp in %s\n", x, backtrace_buffer[x], symbollist[x]); + } + } - if (demangled) - { - free(demangled); + ::free(symbollist); } - } + } #endif // HAVE_EXECINFO_H +} + +#else // HAVE_SHARED_ENABLED -#else // AX_ENABLE_BACKTRACE void custom_backtrace(void) { + fprintf(stderr, "Backtrace null function called\n"); } #endif // AX_ENABLE_BACKTRACE diff --git a/libmemcached/include.am b/libmemcached/include.am index e230267e..2465b058 100644 --- a/libmemcached/include.am +++ b/libmemcached/include.am @@ -52,8 +52,10 @@ noinst_HEADERS+= libmemcached/virtual_bucket.h noinst_HEADERS+= libmemcached/watchpoint.h lib_LTLIBRARIES+= libmemcached/libmemcached.la +libmemcached_libmemcached_la_DEPENDENCIES= +libmemcached_libmemcached_la_LIBADD= +libmemcached_libmemcached_la_LDFLAGS= libmemcached_libmemcached_la_CFLAGS= -DBUILDING_LIBMEMCACHED - libmemcached_libmemcached_la_CXXFLAGS= -DBUILDING_LIBMEMCACHED libmemcached_libmemcached_la_SOURCES+= libmemcached/instance.cc @@ -110,17 +112,13 @@ libmemcached_libmemcached_la_SOURCES+= libmemcached/virtual_bucket.c libmemcached/options.cc: libmemcached/csl/parser.h - -libmemcached_libmemcached_la_DEPENDENCIES= -libmemcached_libmemcached_la_LIBADD= -libmemcached_libmemcached_la_LDFLAGS= libmemcached_libmemcached_la_LDFLAGS+= -version-info ${MEMCACHED_LIBRARY_VERSION} -libmemcached_libmemcached_la_LDFLAGS+= @DL_LIB@ +libmemcached_libmemcached_la_LIBADD+= @DL_LIB@ if HAVE_SASL libmemcached_libmemcached_la_CXXFLAGS+= @PTHREAD_CFLAGS@ libmemcached_libmemcached_la_LIBADD+= @PTHREAD_LIBS@ -libmemcached_libmemcached_la_LIBADD+= @SASL_LDFLAGS@ +libmemcached_libmemcached_la_LIBADD+= @SASL_LIB@ endif if HAVE_DTRACE diff --git a/libmemcachedinternal/include.am b/libmemcachedinternal/include.am index 75e58d63..fafef9a3 100644 --- a/libmemcachedinternal/include.am +++ b/libmemcachedinternal/include.am @@ -22,8 +22,6 @@ libmemcachedinternal_libmemcachedinternal_la_CXXFLAGS= \ ${AM_CXXFLAGS} \ ${NO_CONVERSION} \ -DBUILDING_LIBMEMCACHEDINTERNAL -libmemcachedinternal_libmemcachedinternal_la_LDFLAGS= -libmemcachedinternal_libmemcachedinternal_la_LDFLAGS+= @DL_LIB@ libmemcachedinternal_libmemcachedinternal_la_LIBADD= $(libmemcached_libmemcached_la_LIBADD) libmemcachedinternal_libmemcachedinternal_la_DEPENDENCIES= $(libmemcached_libmemcached_la_DEPENDENCIES) endif diff --git a/libmemcachedprotocol/include.am b/libmemcachedprotocol/include.am index dd350f5a..6a004598 100644 --- a/libmemcachedprotocol/include.am +++ b/libmemcachedprotocol/include.am @@ -30,7 +30,7 @@ libmemcached_libmemcachedprotocol_la_CXXFLAGS+= -DBUILDING_LIBMEMCACHED libmemcached_libmemcachedprotocol_la_CXXFLAGS+= @PTHREAD_CFLAGS@ libmemcached_libmemcachedprotocol_la_LIBADD= -libmemcached_libmemcachedprotocol_la_LIBADD+= @LIBEVENT_LDFLAGS@ +libmemcached_libmemcachedprotocol_la_LIBADD+= @LIBEVENT_LIB@ libmemcached_libmemcachedprotocol_la_LIBADD+= @PTHREAD_LIBS@ libmemcached_libmemcachedprotocol_la_LDFLAGS= ${AM_LDFLAGS} libmemcached_libmemcachedprotocol_la_LDFLAGS+= -version-info ${MEMCACHED_PROTOCAL_LIBRARY_VERSION} diff --git a/libmemcachedutil/include.am b/libmemcachedutil/include.am index 37d4846e..e0b1fe95 100644 --- a/libmemcachedutil/include.am +++ b/libmemcachedutil/include.am @@ -13,13 +13,17 @@ libmemcached_libmemcachedutil_la_SOURCES= \ libmemcachedutil/ping.cc \ libmemcachedutil/pool.cc \ libmemcachedutil/version.cc -libmemcached_libmemcachedutil_la_CXXFLAGS= \ +libmemcached_libmemcachedutil_la_LIBADD= +libmemcached_libmemcachedutil_la_LDFLAGS= +libmemcached_libmemcachedutil_la_CXXFLAGS= +libmemcached_libmemcachedutil_la_DEPENDENCIES= +libmemcached_libmemcachedutil_la_CXXFLAGS+= \ ${AM_CXXFLAGS} \ ${NO_CONVERSION} \ -DBUILDING_LIBMEMCACHED libmemcached_libmemcachedutil_la_CXXFLAGS+= @PTHREAD_CFLAGS@ -libmemcached_libmemcachedutil_la_LIBADD= libmemcached/libmemcached.la +libmemcached_libmemcachedutil_la_LDFLAGS+= ${AM_LDFLAGS} -version-info ${MEMCACHED_UTIL_LIBRARY_VERSION} +libmemcached_libmemcachedutil_la_LIBADD+= libmemcached/libmemcached.la libmemcached_libmemcachedutil_la_LIBADD+= @PTHREAD_LIBS@ -libmemcached_libmemcachedutil_la_LDFLAGS= ${AM_LDFLAGS} -version-info ${MEMCACHED_UTIL_LIBRARY_VERSION} -libmemcached_libmemcachedutil_la_DEPENDENCIES= libmemcached/libmemcached.la +libmemcached_libmemcachedutil_la_DEPENDENCIES+= libmemcached/libmemcached.la diff --git a/libtest/backtrace_test.cc b/libtest/backtrace_test.cc new file mode 100644 index 00000000..d4af4515 --- /dev/null +++ b/libtest/backtrace_test.cc @@ -0,0 +1,123 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Data Differential YATL (i.e. libtest) library + * + * Copyright (C) 2012 Data Differential, http://datadifferential.com/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include +#include +#include +#include + +#include "libmemcached/backtrace.hpp" + +class Test { +public: + Test() + { + } + + void call_backtrace() + { + std::cerr << __func__ << std::endl; + custom_backtrace(); + } +}; + +void SIGSEGV_handler(int sig_num, siginfo_t* info, void* ucontext) +{ + std::cerr << __func__ << std::endl; + (void)sig_num; + (void)info; + (void)ucontext; + + custom_backtrace(); +} + +int raise_SIGSEGV() +{ + std::cerr << std::endl << "Calling backtrace()" << std::endl; + custom_backtrace(); + std::cerr << std::endl << "Calling raise()" << std::endl; + return raise(SIGSEGV); +} + +int layer4() +{ + return raise_SIGSEGV(); +} + +int layer3() +{ + return layer4(); +} + +int layer2() +{ + return layer3(); +} + +int layer1() +{ + return layer2(); +} + +int main(int, char **) +{ + Test t; + + t.call_backtrace(); + + struct sigaction sigact; + + sigact.sa_sigaction= SIGSEGV_handler; + sigact.sa_flags= SA_RESTART | SA_SIGINFO; + + if (sigaction(SIGSEGV, &sigact, (struct sigaction *)NULL) != 0) + { + std::cerr << "error setting signal handler for " << strsignal(SIGSEGV) << "(" << SIGSEGV << ")" << std::endl; + + exit(EXIT_FAILURE); + } + + int ret= layer1(); + if (ret) + { + std::cerr << "raise() " << strerror(errno) << std::endl; + exit(EXIT_FAILURE); + } + + exit(EXIT_SUCCESS); +} diff --git a/libtest/include.am b/libtest/include.am index b09fe364..0e495faf 100644 --- a/libtest/include.am +++ b/libtest/include.am @@ -129,13 +129,13 @@ libtest_libtest_la_SOURCES+= libtest/tmpfile.cc libtest_libtest_la_SOURCES+= libtest/vchar.cc libtest_libtest_la_CXXFLAGS+= -DBUILDING_LIBTEST -libtest_libtest_la_CXXFLAGS+= $(PTHREAD_CFLAGS) +libtest_libtest_la_CXXFLAGS+= @PTHREAD_CFLAGS@ libtest_libtest_la_CXXFLAGS+= -DLIBTEST_TEMP="\"tmp_chroot\"" libtest_libtest_la_CXXFLAGS+= $(CURL_CFLAGS) -libtest_libtest_la_LIBADD+= $(PTHREAD_LIBS) libtest_libtest_la_LIBADD+= $(CURL_LIBS) -libtest_libtest_la_LIBADD+= $(RT_LIB) +libtest_libtest_la_LIBADD+= @PTHREAD_LIBS@ +libtest_libtest_la_LIBADD+= @RT_LIB@ libtest_libtest_la_DEPENDENCIES+= libtest_tmp_dir libtest_libtest_la_DEPENDENCIES+=libtest/abort @@ -190,8 +190,7 @@ libtest_unittest_DEPENDENCIES+= libgearman/libgearman.la libtest_unittest_DEPENDENCIES+= gearmand/gearmand else if HAVE_LIBGEARMAN -libtest_libtest_la_DEPENDENCIES+= libgearman/libgearman.la -libtest_libtest_la_LIBADD+= $(libgearman_LIBS) +libtest_libtest_la_LIBADD+= @LIBGEARMAN_LDFLAGS@ libtest_libtest_la_SOURCES+= libtest/blobslap_worker.cc libtest_libtest_la_SOURCES+= libtest/gearmand.cc libtest_libtest_la_SOURCES+= util/instance.cc @@ -260,3 +259,15 @@ noinst_PROGRAMS+= libtest/core-count libtest_abort_SOURCES= libtest/abort.cc noinst_PROGRAMS+= libtest/abort + +libtest_backtrace_SOURCES= +libtest_backtrace_LDADD= +libtest_backtrace_SOURCES+= libtest/backtrace_test.cc +libtest_backtrace_SOURCES+= libmemcached/backtrace.cc +libtest_backtrace_LDADD+= @DL_LIB@ +noinst_PROGRAMS+= libtest/backtrace +test-backtrace: libtest/backtrace + @libtest/backtrace + +gdb-backtrace: libtest/backtrace + @$(GDB_COMMAND) libtest/backtrace diff --git a/libtest/memcached.cc b/libtest/memcached.cc index d2ce941e..c54c6b90 100644 --- a/libtest/memcached.cc +++ b/libtest/memcached.cc @@ -38,9 +38,6 @@ #include -#include -#include - #include #include #include diff --git a/m4/ax_check_library.m4 b/m4/ax_check_library.m4 index 5998c792..8177acf0 100644 --- a/m4/ax_check_library.m4 +++ b/m4/ax_check_library.m4 @@ -60,7 +60,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 4 +#serial 6 AC_DEFUN([AX_CHECK_LIBRARY], [ AC_ARG_VAR($1[_CPPFLAGS], [C preprocessor flags for ]$1[ headers]) @@ -89,7 +89,11 @@ AC_DEFUN([AX_CHECK_LIBRARY], [ ]) AS_IF([test "$]AS_TR_SH([ax_cv_have_]$1)[" = "yes"], - AC_DEFINE([HAVE_]$1, [1], [Define to 1 if ]$1[ is found]) - m4_ifval( m4_normalize([$4]), [$4]), - m4_ifval( m4_normalize([$5]), [$5])) -]) + [AC_DEFINE([HAVE_]$1, [1], [Define to 1 if ]$1[ is found]) + AC_SUBST($1[_CPPFLAGS]) + AC_SUBST($1[_LDFLAGS]) + AC_SUBST($1[_LIB],[-l]$3) + m4_ifval( m4_normalize([$4]), [$4]), + m4_ifval( m4_normalize([$5]), [$5])]) + AM_CONDITIONAL([HAVE_]$1,[test "$]AS_TR_SH([ax_cv_have_]$1)[" = "yes"]) + ]) diff --git a/m4/ax_harden_compiler_flags.m4 b/m4/ax_harden_compiler_flags.m4 index caab7853..3d5eb2e3 100644 --- a/m4/ax_harden_compiler_flags.m4 +++ b/m4/ax_harden_compiler_flags.m4 @@ -134,14 +134,15 @@ AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS], _APPEND_COMPILE_FLAGS_ERROR([-fwrapv]) _APPEND_COMPILE_FLAGS_ERROR([-fmudflapt]) - AS_IF([test "x$ac_cv_vcs_checkout" = xyes], - [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check]) - AS_IF([test "x$ac_c_gcc_recent" = xyes], - [_APPEND_COMPILE_FLAGS_ERROR([-D_FORTIFY_SOURCE=2]) - _APPEND_COMPILE_FLAGS_ERROR([-Wstack-protector]) - _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector]) - _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector-all]) - ])]) + AS_IF([test "x$ax_enable_debug" = xno], + [AS_IF([test "x$ac_cv_vcs_checkout" = xyes], + [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check]) + AS_IF([test "x$ac_c_gcc_recent" = xyes], + [_APPEND_COMPILE_FLAGS_ERROR([-D_FORTIFY_SOURCE=2]) + _APPEND_COMPILE_FLAGS_ERROR([-Wstack-protector]) + _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector]) + _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector-all]) + ])])]) AS_IF([test "x$ac_cv_vcs_checkout" = xyes], [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])], @@ -210,14 +211,15 @@ AC_DEFUN([_HARDEN_CXX_COMPILER_FLAGS], _APPEND_COMPILE_FLAGS_ERROR([-fwrapv]) _APPEND_COMPILE_FLAGS_ERROR([-fmudflapt]) - AS_IF([test "x$ac_cv_vcs_checkout" = xyes], + AS_IF([test "x$ax_enable_debug" = xno], + [AS_IF([test "x$ac_cv_vcs_checkout" = xyes], [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check]) AS_IF([test "x$ac_c_gcc_recent" = xyes], [_APPEND_COMPILE_FLAGS_ERROR([-D_FORTIFY_SOURCE=2]) _APPEND_COMPILE_FLAGS_ERROR([-Wstack-protector]) _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector]) _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector-all]) - ])]) + ])])]) AS_IF([test "x$ac_cv_warnings_as_errors" = xyes], [_APPEND_COMPILE_FLAGS_ERROR([-Werror])]) diff --git a/m4/ax_libevent.m4 b/m4/ax_libevent.m4 index 41392f9d..686bff23 100644 --- a/m4/ax_libevent.m4 +++ b/m4/ax_libevent.m4 @@ -3,7 +3,9 @@ # # SYNOPSIS # -# AX_LIBEVENT(), AX_LIBEVENT2(), AX_LIBEVENT2_EVHTTP() +# AX_LIBEVENT([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +# AX_LIBEVENT2() +# AX_LIBEVENT2_EVHTTP() # # DESCRIPTION # @@ -18,101 +20,107 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 2 +#serial 4 AC_DEFUN([AX_LIBEVENT], [AC_PREREQ([2.63])dnl AC_CACHE_CHECK([test for a working libevent],[ax_cv_libevent], - [AX_SAVE_FLAGS - LIBS="-levent $LIBS" - AC_LANG_PUSH([C]) - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([ + [AX_SAVE_FLAGS + LIBS="-levent $LIBS" + AC_LANG_PUSH([C]) + AC_RUN_IFELSE([AC_LANG_PROGRAM([ #include #include #include #include - ],[ - struct event_base *tmp_event= event_init(); - event_base_free(tmp_event); - ])], - [ax_cv_libevent=yes], - [ax_cv_libevent=no], - [AC_MSG_WARN([test program execution failed])]) - AC_LANG_POP - AX_RESTORE_FLAGS - ]) + ],[ + struct event_base *tmp_event= event_init(); + event_base_free(tmp_event); + ])], + [ax_cv_libevent=yes], + [ax_cv_libevent=no], + [AC_MSG_WARN([test program execution failed])]) + AC_LANG_POP + AX_RESTORE_FLAGS + ]) AS_IF([test "x$ax_cv_libevent" = "xyes"], - [LIBEVENT_LDFLAGS="-levent" - AC_SUBST(LIBEVENT_LDFLAGS) - AC_DEFINE([HAVE_LIBEVENT],[1],[Define if event_init is present in event.h.])], - [AC_DEFINE([HAVE_LIBEVENT],[0],[Define if event_init is present in event.h.])]) + [AC_SUBST([LIBEVENT_LIB],[-levent]) + AC_DEFINE([HAVE_LIBEVENT],[1],[Define if event_init is present in event.h.])], + [AC_DEFINE([HAVE_LIBEVENT],[0],[Define if event_init is present in event.h.])]) AM_CONDITIONAL(HAVE_LIBEVENT, test "x$ax_cv_libevent" = "xyes") +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: + AS_IF([test "x$ax_cv_libevent" = xyes], + [$1], + [$2]) ]) - AC_DEFUN([AX_LIBEVENT2], - [AC_REQUIRE([AX_LIBEVENT]) - AC_CACHE_CHECK([test for a working libevent version 2],[ax_cv_libevent2], - [AX_SAVE_FLAGS - LIBS="-levent $LIBS" - AC_LANG_PUSH([C]) - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([ +AC_DEFUN([AX_LIBEVENT2], + [AC_REQUIRE([AX_LIBEVENT]) + AC_CACHE_CHECK([test for a working libevent version 2],[ax_cv_libevent2], + [AX_SAVE_FLAGS + LIBS="-levent $LIBS" + AC_LANG_PUSH([C]) + AC_RUN_IFELSE([AC_LANG_PROGRAM([ #include #include #include #include - ],[ - struct event_base *tmp_event= event_init(); - event_base_free(tmp_event); - ])], - [ax_cv_libevent2=yes], - [ax_cv_libevent2=no], - [AC_MSG_WARN([test program execution failed])]) - AC_LANG_POP - AX_RESTORE_FLAGS - ]) + ],[ + struct event_base *tmp_event= event_init(); + event_base_free(tmp_event); + ])], + [ax_cv_libevent2=yes], + [ax_cv_libevent2=no], + [AC_MSG_WARN([test program execution failed])]) + AC_LANG_POP([C]) + AX_RESTORE_FLAGS + ]) - AS_IF([test "x$ax_cv_libevent2" = xyes], - [LIBEVENT2_LDFLAGS="-levent" - AC_SUBST(LIBEVENT2_LDFLAGS) - AC_DEFINE([HAVE_LIBEVENT2],[1],[Define if event_init is present in event2/event.h.])], - [AC_DEFINE([HAVE_LIBEVENT2],[0],[Define if event_init is present in event2/event.h.])]) + AS_IF([test "x$ax_cv_libevent2" = xyes], + [AC_SUBST([LIBEVENT2_LIB],[-levent]) + AC_DEFINE([HAVE_LIBEVENT2],[1],[Define if event_init is present in event2/event.h.])], + [AC_DEFINE([HAVE_LIBEVENT2],[0],[Define if event_init is present in event2/event.h.])]) - AM_CONDITIONAL([HAVE_LIBEVENT2], [test "x$ax_cv_libevent2" = xyes]) - ]) + AM_CONDITIONAL([HAVE_LIBEVENT2], [test "x$ax_cv_libevent2" = xyes]) +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: + AS_IF([test "x$ax_cv_libevent2" = xyes], + [$1], + [$2]) + ])dnl AX_LIBEVENT2 - AC_DEFUN([AX_LIBEVENT2_EVHTTP], - [AC_REQUIRE([AX_LIBEVENT2]) - AC_CACHE_CHECK([test for a working libevent2 evhttp interface], [ax_cv_libevent2_evhttp], - [AX_SAVE_FLAGS - LIBS="-levent $LIBS" - AC_LANG_PUSH([C]) - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([ +# +AC_DEFUN([AX_LIBEVENT2_EVHTTP], + [AC_REQUIRE([AX_LIBEVENT2]) + AC_CACHE_CHECK([test for a working libevent2 evhttp interface], [ax_cv_libevent2_evhttp], + [AX_SAVE_FLAGS + LIBS="-levent $LIBS" + AC_LANG_PUSH([C]) + AC_RUN_IFELSE([AC_LANG_PROGRAM([ #include #include #include #include #include - ],[ - struct event_base *libbase= event_base_new(); - struct evhttp *libsrvr= evhttp_new(libbase); - ])], - [ax_cv_libevent2_evhttp=yes], - [ax_cv_libevent2_evhttp=no], - [AC_MSG_WARN([test program execution failed])]) - AC_LANG_POP - AX_RESTORE_FLAGS - ]) + ],[ + struct event_base *libbase= event_base_new(); + struct evhttp *libsrvr= evhttp_new(libbase); + ])], + [ax_cv_libevent2_evhttp=yes], + [ax_cv_libevent2_evhttp=no], + [AC_MSG_WARN([test program execution failed])]) + AC_LANG_POP([C]) + AX_RESTORE_FLAGS + ]) - AS_IF([test "x$ax_cv_libevent2_evhttp" = "xyes"], - [LIBEVENT2_LDFLAGS="-levent" - AC_SUBST(LIBEVENT2_LDFLAGS) - AC_DEFINE([HAVE_LIBEVENT2],[1],[Define if event_init is present in event2/event.h.])], - [AC_DEFINE([HAVE_LIBEVENT2],[0],[Define if event_init is present in event2/event.h.])]) + AS_IF([test "x$ax_cv_libevent2_evhttp" = "xyes"], + [AC_DEFINE([HAVE_LIBEVENT2_EVHTTP],[1],[Define if event_init is present in event2/http.h.])], + [AC_DEFINE([HAVE_LIBEVENT2_EVHTTP],[0],[Define if event_init is present in event2/http.h.])]) - AM_CONDITIONAL([HAVE_LIBEVENT2_EVHTTP],[test "x$ax_cv_libevent2_evhttp" = xyes]) - ]) + AM_CONDITIONAL([HAVE_LIBEVENT2_EVHTTP],[test "x$ax_cv_libevent2_evhttp" = xyes]) +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: + AS_IF([test "x$ax_cv_libevent2_evhttp" = xyes], + [$1], + [$2]) + ])dnl AX_LIBEVENT2_EVHTTP diff --git a/m4/ax_sasl.m4 b/m4/ax_sasl.m4 index 48b05c74..303fbd2b 100644 --- a/m4/ax_sasl.m4 +++ b/m4/ax_sasl.m4 @@ -46,7 +46,7 @@ AC_DEFUN([AX_SASL_CHECK], [ax_sasl_check=no AX_CHECK_LIBRARY([LIBSASL],[sasl/sasl.h],[sasl2], [ax_sasl_check=yes - AC_SUBST([SASL_LDFLAGS],[[-lsasl2]]) + AC_SUBST([SASL_LIB],[[-lsasl2]]) ]) AC_MSG_CHECKING([checking to see if sasl works]) AC_MSG_RESULT(["$ax_sasl_check"]) diff --git a/m4/ax_uuid.m4 b/m4/ax_uuid.m4 index 6864b45c..93c5f89f 100644 --- a/m4/ax_uuid.m4 +++ b/m4/ax_uuid.m4 @@ -21,7 +21,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 5 +#serial 6 AC_DEFUN([AX_UUID], [AC_PREREQ([2.63])dnl @@ -62,14 +62,14 @@ AC_DEFUN([AX_UUID], [ax_libuuid=yes]) ],[ax_libuuid=no]) - AS_IF([test "$ax_libuuid" = yes], + AS_IF([test "x$ax_libuuid" = xyes], [AC_DEFINE([HAVE_UUID_UUID_H],[1],[Have uuid/uuid.h]) - AS_IF([test "$ax_cv_libuuid_is_required" = yes],[ LIBUUID_LDFLAGS='-luuid' ])], + AS_IF([test "x$ax_cv_libuuid_is_required" = xyes],[ LIBUUID_LIB='-luuid' ])], [AC_DEFINE([HAVE_UUID_UUID_H],[0],[Have uuid/uuid.h]) ]) - AC_SUBST([LIBUUID_LDFLAGS]) - AM_CONDITIONAL([HAVE_LIBUUID],[test "$ax_libuuid" = yes]) + AC_SUBST([LIBUUID_LIB]) + AM_CONDITIONAL([HAVE_LIBUUID],[test "x$ax_libuuid" = xyes]) ]) AC_DEFUN([AX_UUID_GENERATE_TIME_SAFE], @@ -78,7 +78,7 @@ AC_DEFUN([AX_UUID], AC_CACHE_CHECK([for uuid_generate_time_safe], [ax_cv_uuid_generate_time_safe], [AX_SAVE_FLAGS - LIBS="$LIBUUID_LDFLAGS $LIBS" + LIBS="$LIBUUID_LIB $LIBS" AC_LANG_PUSH([C]) AC_RUN_IFELSE([ AC_LANG_PROGRAM([#include ],[ diff --git a/m4/libgearman.m4 b/m4/libgearman.m4 index 0501ed3e..a95c289f 100644 --- a/m4/libgearman.m4 +++ b/m4/libgearman.m4 @@ -1,10 +1,9 @@ # serial 1 AC_DEFUN([CHECK_FOR_LIBGEARMAND], - [AX_CHECK_LIBRARY([LIBGEARMAN], [libgearman/gearmand.h], [gearman], + [AX_CHECK_LIBRARY([LIBGEARMAN],[libgearman/gearman.h],[gearman], [ax_check_for_libgearman=yes], [ax_check_for_libgearman=no]) AS_IF([test "$ax_check_for_libgearman" = xyes], [AC_DEFINE([HAVE_LIBGEARMAN],[1],[Enables libgearman Support])], [AC_DEFINE([HAVE_LIBGEARMAN],[0],[Enables libgearman Support])]) - AM_CONDITIONAL(HAVE_LIBGEARMAN,[test "$ax_check_for_libgearman" = xyes]) ]) diff --git a/tests/libmemcached-1.0/include.am b/tests/libmemcached-1.0/include.am index 1add550f..499123d8 100644 --- a/tests/libmemcached-1.0/include.am +++ b/tests/libmemcached-1.0/include.am @@ -108,7 +108,7 @@ tests_libmemcached_1_0_testapp_DEPENDENCIES+= libtest/libtest.la tests_libmemcached_1_0_testapp_DEPENDENCIES+= libhashkit/libhashkit.la tests_libmemcached_1_0_testapp_DEPENDENCIES+= libmemcached/libmemcachedutil.la -tests_libmemcached_1_0_testapp_LDADD+= @LIBUUID_LDFLAGS@ +tests_libmemcached_1_0_testapp_LDADD+= @LIBUUID_LIB@ tests_libmemcached_1_0_testapp_LDADD+= @PTHREAD_LIBS@ tests_libmemcached_1_0_testapp_LDADD+= libmemcached/libmemcached.la tests_libmemcached_1_0_testapp_LDADD+= libmemcached/libmemcachedutil.la @@ -164,7 +164,7 @@ tests_libmemcached_1_0_testsocket_DEPENDENCIES+= libtest/libtest.la tests_libmemcached_1_0_testsocket_DEPENDENCIES+= libhashkit/libhashkit.la tests_libmemcached_1_0_testsocket_DEPENDENCIES+= libmemcached/libmemcachedutil.la -tests_libmemcached_1_0_testsocket_LDADD+= @LIBUUID_LDFLAGS@ +tests_libmemcached_1_0_testsocket_LDADD+= @LIBUUID_LIB@ tests_libmemcached_1_0_testsocket_LDADD+= @PTHREAD_LIBS@ tests_libmemcached_1_0_testsocket_LDADD+= libmemcached/libmemcached.la tests_libmemcached_1_0_testsocket_LDADD+= libmemcached/libmemcachedutil.la diff --git a/util/instance.cc b/util/instance.cc index a1665f36..1b997397 100644 --- a/util/instance.cc +++ b/util/instance.cc @@ -36,7 +36,7 @@ */ -#include +#include "mem_config.h" #include "util/instance.hpp" @@ -50,7 +50,23 @@ #include #ifdef HAVE_UNISTD_H -#include +# include +#endif + +#ifndef INVALID_SOCKET +# define INVALID_SOCKET -1 +#endif + +#ifndef SOCKET_ERROR +# define SOCKET_ERROR -1 +#endif + +#ifndef get_socket_errno +# define get_socket_errno() errno +#endif + +#ifndef closesocket +# define closesocket(a) close(a) #endif diff --git a/util/instance.hpp b/util/instance.hpp index 1855ef8d..853cc00c 100644 --- a/util/instance.hpp +++ b/util/instance.hpp @@ -37,12 +37,13 @@ #pragma once -#include -#include #include +#include #include -#include +#include +#include #include +#include #include "util/operation.hpp"