From: Brian Aker Date: Tue, 20 Nov 2012 10:34:30 +0000 (-0500) Subject: Fix some compile time issues. X-Git-Tag: 1.0.15~18^2~1 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=08f651a522b5550deada129592ccdd510c2003bb;p=m6w6%2Flibmemcached Fix some compile time issues. --- diff --git a/clients/include.am b/clients/include.am index 7758e483..72fd39d4 100644 --- a/clients/include.am +++ b/clients/include.am @@ -79,9 +79,9 @@ 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_CXXFLAGS= @PTHREAD_CFLAGS@ clients_memslap_LDADD= $(CLIENTS_LDADDS) -clients_memslap_LDADD+= $(PTHREAD_LIBS) +clients_memslap_LDADD+= @PTHREAD_LIBS@ clients_memaslap_SOURCES= clients_memaslap_SOURCES+= clients/memaslap.c @@ -93,7 +93,9 @@ clients_memaslap_SOURCES+= clients/ms_task.c clients_memaslap_SOURCES+= clients/ms_thread.c clients_memaslap_SOURCES+= clients/generator.cc clients/execute.cc -clients_memaslap_LDADD= $(LTLIBEVENT) $(CLIENTS_LDADDS) +clients_memaslap_LDADD= +clients_memaslap_LDADD+= @LIBEVENT_LDFLAGS@ +clients_memaslap_LDADD+= $(CLIENTS_LDADDS) clients_memcapable_SOURCES= clients_memcapable_SOURCES+= clients/memcapable.cc diff --git a/clients/memaslap.c b/clients/memaslap.c index fba0ab4e..1b5c223a 100644 --- a/clients/memaslap.c +++ b/clients/memaslap.c @@ -114,7 +114,48 @@ 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); + +/** + * output the help information + * + * @param command_name, the string of this process + * @param description, description of this process + * @param long_options, global options array + */ +static __attribute__((noreturn)) 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 */ /* initialize the global locks */ @@ -294,49 +335,6 @@ static const char *ms_lookup_help(ms_options_t option) } /* 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() { diff --git a/clients/ms_conn.c b/clients/ms_conn.c index c4f1b87b..2cbc7e0b 100644 --- a/clients/ms_conn.c +++ b/clients/ms_conn.c @@ -758,6 +758,7 @@ static void ms_maximize_sndbuf(const int sfd) max= avg - 1; } } + (void)last_good; } /* ms_maximize_sndbuf */ @@ -1543,6 +1544,7 @@ static int ms_sort_udp_packet(ms_conn_t *c, char *buf, int rbytes) break; } } + (void)packets; return wbytes == 0 ? -1 : wbytes; } /* ms_sort_udp_packet */ @@ -3158,6 +3160,8 @@ int ms_mcd_mlget(ms_conn_t *c) atomic_add_size(&ms_stats.cmd_get, 1); } + (void)item; + return EXIT_SUCCESS; } /* ms_mcd_mlget */ diff --git a/clients/ms_sigsegv.c b/clients/ms_sigsegv.c index 5f0ae65c..303381f4 100644 --- a/clients/ms_sigsegv.c +++ b/clients/ms_sigsegv.c @@ -38,7 +38,9 @@ static void ms_signal_segv(int signum, siginfo_t *info, void *ptr) pthread_mutex_lock(&ms_global.quit_mutex); fprintf(stderr, "Segmentation fault occurred.\nStack trace:\n"); +#if 0 pandora_print_callstack(stderr); +#endif fprintf(stderr, "End of stack trace\n"); pthread_mutex_unlock(&ms_global.quit_mutex); abort(); diff --git a/configure.ac b/configure.ac index 451d139d..b255cefb 100644 --- a/configure.ac +++ b/configure.ac @@ -284,6 +284,7 @@ AS_IF([test "x$enable_static" = "xyes"], [AC_DEFINE([AX_ENABLE_BACKTRACE],[1],[Support for backtrace().])]) PANDORA_ENABLE_DTRACE +HAVE_GCC_ATOMICS AX_ENDIAN AX_ASSERT AX_HARDEN_COMPILER_FLAGS diff --git a/example/include.am b/example/include.am index 8dfa5f4a..25fab644 100644 --- a/example/include.am +++ b/example/include.am @@ -24,5 +24,3 @@ example_memcached_light_SOURCES+= util/pidfile.cc example_memcached_light_LDADD+= libmemcached/libmemcachedprotocol.la example_memcached_light_LDFLAGS+= @LIBEVENT_LDFLAGS@ - -include example/t/include.am diff --git a/example/t/include.am b/example/t/include.am deleted file mode 100644 index 394e4c6c..00000000 --- a/example/t/include.am +++ /dev/null @@ -1,40 +0,0 @@ -# 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_CXXFLAGS= -example_t_memcached_light_DEPENDENCIES= -example_t_memcached_light_LDADD= -example_t_memcached_light_SOURCES= - -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_t_memcached_light_DEPENDENCIES+= 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 diff --git a/example/t/memcached_light.cc b/example/t/memcached_light.cc deleted file mode 100644 index bfb78b91..00000000 --- a/example/t/memcached_light.cc +++ /dev/null @@ -1,248 +0,0 @@ -/* 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 (access(executable.c_str(), X_OK) != 0) - { - error= TEST_SKIPPED; - return NULL; - } - - 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; - return NULL; - } - - - 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(libtest::Framework* world) -{ - world->create(world_create); - world->destroy(world_destroy); - world->collections(collection); - world->set_runner(new MemcachedLightRunner); -} - diff --git a/libmemcached/byteorder.cc b/libmemcached/byteorder.cc index 1a96d987..eb37fda8 100644 --- a/libmemcached/byteorder.cc +++ b/libmemcached/byteorder.cc @@ -35,7 +35,8 @@ * */ -#include +#include "mem_config.h" +#include "libmemcached/byteorder.h" /* Byte swap a 64-bit number. */ #ifndef swap64 diff --git a/libmemcachedprotocol/binary_handler.c b/libmemcachedprotocol/binary_handler.c index 851c8751..d720424a 100644 --- a/libmemcachedprotocol/binary_handler.c +++ b/libmemcachedprotocol/binary_handler.c @@ -76,7 +76,7 @@ static protocol_binary_response_status raw_response_handler(const void *cookie, return PROTOCOL_BINARY_RESPONSE_EINTERNAL; } - size_t len= sizeof(protocol_binary_response_header) + memcached_htonl(response->response.bodylen); + size_t len= sizeof(protocol_binary_response_header) + htonl(response->response.bodylen); size_t offset= 0; char *ptr= (void*)response; diff --git a/libmemcachedprotocol/common.h b/libmemcachedprotocol/common.h index 8453ccd8..a4ddc2ca 100644 --- a/libmemcachedprotocol/common.h +++ b/libmemcachedprotocol/common.h @@ -36,7 +36,7 @@ #pragma once -#include "config.h" +#include "mem_config.h" #include #include diff --git a/libmemcachedprotocol/include.am b/libmemcachedprotocol/include.am index 33d00fe9..dd350f5a 100644 --- a/libmemcachedprotocol/include.am +++ b/libmemcachedprotocol/include.am @@ -22,13 +22,15 @@ libmemcached_libmemcachedprotocol_la_CFLAGS= libmemcached_libmemcachedprotocol_la_CFLAGS+= ${AM_CFLAGS} libmemcached_libmemcachedprotocol_la_CFLAGS+= ${NO_CONVERSION} libmemcached_libmemcachedprotocol_la_CFLAGS+= -DBUILDING_LIBMEMCACHED -libmemcached_libmemcachedprotocol_la_CFLAGS+= ${PTHREAD_CFLAGS} +libmemcached_libmemcachedprotocol_la_CFLAGS+= @PTHREAD_CFLAGS@ libmemcached_libmemcachedprotocol_la_CXXFLAGS= libmemcached_libmemcachedprotocol_la_CXXFLAGS+= ${AM_CXXFLAGS} libmemcached_libmemcachedprotocol_la_CXXFLAGS+= -DBUILDING_LIBMEMCACHED -libmemcached_libmemcachedprotocol_la_CXXFLAGS+= ${PTHREAD_CFLAGS} +libmemcached_libmemcachedprotocol_la_CXXFLAGS+= @PTHREAD_CFLAGS@ -libmemcached_libmemcachedprotocol_la_LIBADD= ${PTHREAD_LIBS} +libmemcached_libmemcachedprotocol_la_LIBADD= +libmemcached_libmemcachedprotocol_la_LIBADD+= @LIBEVENT_LDFLAGS@ +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 8c9b7a50..37d4846e 100644 --- a/libmemcachedutil/include.am +++ b/libmemcachedutil/include.am @@ -4,8 +4,7 @@ lib_LTLIBRARIES+= libmemcached/libmemcachedutil.la -noinst_HEADERS+= \ - libmemcachedutil/common.h +noinst_HEADERS+= libmemcachedutil/common.h libmemcached_libmemcachedutil_la_SOURCES= \ libmemcached/backtrace.cc \ @@ -18,9 +17,9 @@ libmemcached_libmemcachedutil_la_CXXFLAGS= \ ${AM_CXXFLAGS} \ ${NO_CONVERSION} \ -DBUILDING_LIBMEMCACHED -libmemcached_libmemcachedutil_la_CXXFLAGS+= ${PTHREAD_CFLAGS} +libmemcached_libmemcachedutil_la_CXXFLAGS+= @PTHREAD_CFLAGS@ libmemcached_libmemcachedutil_la_LIBADD= libmemcached/libmemcached.la -libmemcached_libmemcachedutil_la_LIBADD+= ${PTHREAD_LIBS} +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 diff --git a/m4/ax_gcc_atomic_builtins.m4 b/m4/ax_gcc_atomic_builtins.m4 new file mode 100644 index 00000000..bc989e08 --- /dev/null +++ b/m4/ax_gcc_atomic_builtins.m4 @@ -0,0 +1,37 @@ +# serial 1 +# +AC_DEFUN([HAVE_GCC_ATOMICS], + [AC_CACHE_CHECK([whether the compiler provides atomic builtins], + [ax_cv_gcc_atomic_builtins], + [AX_SAVE_FLAGS + AC_LANG_PUSH([C]) + AC_RUN_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; + } + ]])], + [ax_cv_gcc_atomic_builtins=yes], + [ax_cv_gcc_atomic_builtins=no], + [AC_MSG_WARN([test program execution failed])]) + AC_LANG_POP + AX_RESTORE_FLAGS + ]) + + AS_IF([test "x$ax_cv_gcc_atomic_builtins" = "xyes"], + [AC_DEFINE([HAVE_GCC_ATOMIC_BUILTINS],[1], + [Define to 1 if compiler provides atomic builtins.]) + ]) + ])