From: Brian Aker Date: Sun, 16 Sep 2012 23:31:57 +0000 (-0700) Subject: Merge staging tree to 1.0 trunk. X-Git-Tag: 1.0.11~1 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=8a971e97129f99102be7452b91865325d58b4a70;hp=489157544c4bace78d18665f4304a88aaeef7069;p=awesomized%2Flibmemcached Merge staging tree to 1.0 trunk. --- diff --git a/bootstrap.sh b/bootstrap.sh index 109767bc..b8c45e51 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,8 +1,47 @@ #!/bin/bash +# +# Copyright (C) 2012 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. -if test -f configure; then make clean; make merge-clean; make distclean; fi; +if test -n $MAKE; then + MAKE="make" +fi + +if test -n $MAKE_J; then + MAKE_J="-j2" +fi -rm -r -f autom4te.cache/ config.h config.log config.status +if test -f configure; then $MAKE $MAKE_J clean; $MAKE $MAKE_J merge-clean; $MAKE $MAKE_J distclean; fi; + +rm -r -f autom4te.cache/ config.h config.log config.status configure ./config/autorun.sh if [ $(uname) = "Darwin" ]; then @@ -10,4 +49,7 @@ then else ./configure --enable-assert fi -make + +if test -z $JENKINS_URL; then +$MAKE $MAKE_J +fi diff --git a/clients/memcapable.cc b/clients/memcapable.cc index bc3b551f..25b470b0 100644 --- a/clients/memcapable.cc +++ b/clients/memcapable.cc @@ -39,6 +39,8 @@ #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 @@ -1715,7 +1717,8 @@ static enum test_return test_ascii_mget(void) "test_ascii_mget4 test_ascii_mget5 " "test_ascii_mget6\r\n")); - char *returned[nkeys]; + std::vector returned; + returned.resize(nkeys); for (uint32_t x= 0; x < nkeys; ++x) { diff --git a/clients/utilities.h b/clients/utilities.h index d036bccc..da973b5f 100644 --- a/clients/utilities.h +++ b/clients/utilities.h @@ -49,10 +49,10 @@ extern "C" { 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 version_command(const char *command_name) __attribute__ ((noreturn)); void help_command(const char *command_name, const char *description, const struct option *long_options, - memcached_programs_help_st *options); + memcached_programs_help_st *options) __attribute__ ((noreturn)); void process_hash_option(memcached_st *memc, char *opt_hash); bool initialize_sasl(memcached_st *memc, char *user, char *password); void shutdown_sasl(void); diff --git a/configure.ac b/configure.ac index eeaccd82..83177bca 100644 --- a/configure.ac +++ b/configure.ac @@ -286,8 +286,11 @@ fi AX_CHECK_SOCK_CLOEXEC([AC_DEFINE([HAVE_SOCK_CLOEXEC], [1], [Check for SOCK_CLOEXEC.])], [AC_DEFINE([HAVE_SOCK_CLOEXEC], [0], [Check for SOCK_CLOEXEC.])]) +AX_PTHREAD(, [AC_MSG_ERROR(could not find libpthread)]) + AX_HARDEN_COMPILER_FLAGS -AX_PTHREAD + +AX_DEBUG AC_CONFIG_FILES([ Makefile diff --git a/docs/include.am b/docs/include.am index 12eb61df..55e98972 100644 --- a/docs/include.am +++ b/docs/include.am @@ -155,8 +155,8 @@ sphinx-help: @echo " doctest to run all doctests embedded in the documentation (if enabled)" install-html: html-local - @rm -r -f /var/www/libmemcaced - @cp -r docs/html /var/www/libmemcaced + @rm -r -f /var/www/libmemcached/* + @cp -r docs/html /var/www/libmemcached html-local: docs/conf.py changes docs PYTHONPATH=${top_srcdir}/docs $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(SPHINX_BUILDDIR)/html diff --git a/libmemcached-1.0/error.h b/libmemcached-1.0/error.h index 81492597..7fdc18b8 100644 --- a/libmemcached-1.0/error.h +++ b/libmemcached-1.0/error.h @@ -41,6 +41,9 @@ extern "C" { #endif +LIBMEMCACHED_API + const char *memcached_error(const memcached_st *); + LIBMEMCACHED_API const char *memcached_last_error_message(const memcached_st *); diff --git a/libmemcached/analyze.cc b/libmemcached/analyze.cc index 7115d06f..03c7e85b 100644 --- a/libmemcached/analyze.cc +++ b/libmemcached/analyze.cc @@ -12,8 +12,8 @@ static void calc_largest_consumption(memcached_analysis_st *result, } static void calc_oldest_node(memcached_analysis_st *result, - const uint32_t server_num, - const uint32_t uptime) + const uint32_t server_num, + const uint32_t uptime) { if (result->longest_uptime < uptime) { @@ -96,7 +96,7 @@ memcached_analysis_st *memcached_analyze(memcached_st *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_oldest_node(result, x, uint32_t(memc_stat[x].uptime)); calc_least_free_node(result, x, memc_stat[x].limit_maxbytes, memc_stat[x].bytes); diff --git a/libmemcached/backtrace.cc b/libmemcached/backtrace.cc index 3924e0b0..871f27af 100644 --- a/libmemcached/backtrace.cc +++ b/libmemcached/backtrace.cc @@ -59,7 +59,7 @@ void custom_backtrace(void) #ifdef HAVE_EXECINFO_H void *array[50]; - size_t size= backtrace(array, 50); + int size= backtrace(array, 50); char **strings= backtrace_symbols(array, size); if (strings == NULL) @@ -67,7 +67,7 @@ void custom_backtrace(void) return; } - fprintf(stderr, "Number of stack frames obtained: %lu\n", (unsigned long)size); + fprintf(stderr, "Number of stack frames obtained: %d\n", size); char *named_function= (char *)std::realloc(NULL, 1024); @@ -77,7 +77,7 @@ void custom_backtrace(void) return; } - for (size_t x= 1; x < size; x++) + for (int x= 1; x < size; x++) { if (USE_DEMANGLE) { diff --git a/libmemcached/connect.cc b/libmemcached/connect.cc index 8d027df2..5d180d18 100644 --- a/libmemcached/connect.cc +++ b/libmemcached/connect.cc @@ -173,7 +173,8 @@ static memcached_return_t set_hostinfo(org::libmemcached::Instance* server) hints.ai_protocol= IPPROTO_TCP; } - server->address_info= NULL; + assert(server->address_info == NULL); + assert(server->address_info_next == NULL); int errcode; switch(errcode= getaddrinfo(server->hostname, str_port, &hints, &server->address_info)) { @@ -181,19 +182,49 @@ static memcached_return_t set_hostinfo(org::libmemcached::Instance* server) break; case EAI_AGAIN: + if (server->address_info) + { + freeaddrinfo(server->address_info); + server->address_info= NULL; + server->address_info_next= NULL; + } return memcached_set_error(*server, MEMCACHED_TIMEOUT, MEMCACHED_AT, memcached_string_make_from_cstr(gai_strerror(errcode))); case EAI_SYSTEM: + if (server->address_info) + { + freeaddrinfo(server->address_info); + server->address_info= NULL; + server->address_info_next= NULL; + } return memcached_set_errno(*server, errno, MEMCACHED_AT, memcached_literal_param("getaddrinfo(EAI_SYSTEM)")); case EAI_BADFLAGS: + if (server->address_info) + { + freeaddrinfo(server->address_info); + server->address_info= NULL; + server->address_info_next= NULL; + } return memcached_set_error(*server, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("getaddrinfo(EAI_BADFLAGS)")); case EAI_MEMORY: + if (server->address_info) + { + freeaddrinfo(server->address_info); + server->address_info= NULL; + server->address_info_next= NULL; + } return memcached_set_error(*server, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("getaddrinfo(EAI_MEMORY)")); default: { + if (server->address_info) + { + freeaddrinfo(server->address_info); + server->address_info= NULL; + server->address_info_next= NULL; + } return memcached_set_error(*server, MEMCACHED_HOST_LOOKUP_FAILURE, MEMCACHED_AT, memcached_string_make_from_cstr(gai_strerror(errcode))); } } @@ -425,24 +456,7 @@ static memcached_return_t network_connect(org::libmemcached::Instance* server) { 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 - } + memcached_return_t rc= set_hostinfo(server); if (memcached_failed(rc)) { diff --git a/libmemcached/csl/context.cc b/libmemcached/csl/context.cc index 1e6e18ae..16852d5b 100644 --- a/libmemcached/csl/context.cc +++ b/libmemcached/csl/context.cc @@ -97,13 +97,29 @@ void Context::error(const char *error_arg, yytokentype last_token, const char *l } } -const char *Context::set_hostname(const char *str, size_t size) +void Context::hostname(const char *str, size_t size, server_t& server_) { 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; + server_.port= MEMCACHED_DEFAULT_PORT; + server_.weight= 1; + server_.c_str= _hostname; + server_.size= size; +} + +bool Context::string_buffer(const char *str, size_t size, memcached_string_t& string_) +{ + if (memcached_string_set(_string_buffer, str, size)) + { + string_.c_str= memcached_string_value(_string_buffer); + string_.size= memcached_string_length(_string_buffer); + + return true; + } + + return false; } bool Context::set_hash(memcached_hash_t hash) diff --git a/libmemcached/csl/context.h b/libmemcached/csl/context.h index 12e028dd..97303c50 100644 --- a/libmemcached/csl/context.h +++ b/libmemcached/csl/context.h @@ -43,26 +43,28 @@ class Context { public: - Context(const char *option_string, size_t option_string_length, memcached_st *memc_arg, + Context(const char *option_string, size_t option_string_length, memcached_st *memc_, memcached_return_t &rc_arg) : previous_token(END), scanner(NULL), + buf(option_string), begin(NULL), pos(0), - memc(NULL), + length(option_string_length), + memc(memc_), 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; memc->state.is_parsing= true; + memcached_string_create(memc, + &_string_buffer, + 1024); } bool end() @@ -95,7 +97,9 @@ public: return _is_server; } - const char *set_hostname(const char *str, size_t size); + void hostname(const char*, size_t, server_t&); + + bool string_buffer(const char*, size_t, memcached_string_t&); const char *hostname() const { @@ -107,6 +111,7 @@ public: ~Context() { + memcached_string_free(&_string_buffer); destroy_scanner(); memc->state.is_parsing= false; } @@ -129,4 +134,5 @@ private: bool _end; char _hostname[NI_MAXHOST]; bool _has_hash; + memcached_string_st _string_buffer; }; diff --git a/libmemcached/csl/parser.cc b/libmemcached/csl/parser.cc index 92662144..87d08dbe 100644 --- a/libmemcached/csl/parser.cc +++ b/libmemcached/csl/parser.cc @@ -1664,7 +1664,7 @@ yyreduce: 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); + snprintf(buffer, sizeof(buffer), "Failed to add socket: %s", (yyvsp[(2) - (3)].string).c_str); parser_abort(context, buffer); } } diff --git a/libmemcached/csl/parser.yy b/libmemcached/csl/parser.yy index e70bba97..d263aea4 100644 --- a/libmemcached/csl/parser.yy +++ b/libmemcached/csl/parser.yy @@ -251,7 +251,7 @@ expression: 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); + snprintf(buffer, sizeof(buffer), "Failed to add socket: %s", $2.c_str); parser_abort(context, buffer); } } diff --git a/libmemcached/csl/scanner.cc b/libmemcached/csl/scanner.cc index 76242dfb..c391f48e 100644 --- a/libmemcached/csl/scanner.cc +++ b/libmemcached/csl/scanner.cc @@ -13,27 +13,17 @@ #pragma GCC diagnostic ignored "-Wmissing-declarations" #endif -#define YY_NO_INPUT - #define YY_EXTRA_TYPE Context* -#line 24 "libmemcached/csl/scanner.cc" +#line 22 "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 @@ -42,32 +32,16 @@ #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 @@ -98,6 +72,7 @@ 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 @@ -128,15 +103,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ -/* %endif */ - -/* %if-c++-only */ -/* %endif */ - #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ @@ -158,13 +126,8 @@ typedef unsigned int flex_uint32_t; #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, @@ -172,9 +135,6 @@ typedef unsigned int flex_uint32_t; * 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 @@ -193,11 +153,6 @@ typedef void* yyscan_t; #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. @@ -221,15 +176,7 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -241,14 +188,6 @@ typedef void* yyscan_t; 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 @@ -280,12 +219,7 @@ typedef size_t yy_size_t; #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 */ @@ -346,15 +280,6 @@ struct yy_buffer_state }; #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". @@ -370,15 +295,6 @@ struct yy_buffer_state */ #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 ); @@ -397,8 +313,6 @@ YY_BUFFER_STATE config__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscann 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 ); @@ -427,42 +341,32 @@ void config_free (void * ,yyscan_t yyscanner ); #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 66 #define YY_END_OF_BUFFER 67 /* This struct is not used in this scanner, @@ -1113,17 +1017,6 @@ static yyconst flex_int16_t yy_chk[1815] = 533, 533, 533, 533 } ; -static yyconst flex_int16_t yy_rule_linenum[66] = - { 0, - 99, 101, 103, 105, 107, 110, 114, 116, 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, 145, 147, 148, 150, 152, - 154, 155, 156, 157, 158, 159, 161, 162, 165, 170, - 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, - 182, 184, 193, 211, 218 - } ; - /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ @@ -1168,7 +1061,7 @@ static yyconst flex_int16_t yy_rule_linenum[66] = * */ -#line 60 "libmemcached/csl/scanner.l" +#line 58 "libmemcached/csl/scanner.l" #include #include @@ -1189,10 +1082,15 @@ static yyconst flex_int16_t yy_rule_linenum[66] = } \ } +#define YY_FATAL_ERROR(msg) \ +{ \ +} + #define YY_INPUT(buffer, result, max_size) get_lex_chars(buffer, result, max_size, PARAM) -#line 1196 "libmemcached/csl/scanner.cc" +#define YY_NO_INPUT 1 +#line 1094 "libmemcached/csl/scanner.cc" #define INITIAL 0 @@ -1201,20 +1099,13 @@ static yyconst flex_int16_t yy_rule_linenum[66] = * 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 { @@ -1251,14 +1142,8 @@ struct yyguts_t }; /* 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 @@ -1267,10 +1152,6 @@ 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. */ @@ -1300,14 +1181,14 @@ int config_get_lineno (yyscan_t yyscanner ); void config_set_lineno (int line_number ,yyscan_t yyscanner ); -/* %if-bison-bridge */ +int config_get_column (yyscan_t yyscanner ); + +void config_set_column (int column_no ,yyscan_t yyscanner ); 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. */ @@ -1320,12 +1201,6 @@ 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 @@ -1335,43 +1210,26 @@ 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 -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #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, @@ -1379,11 +1237,10 @@ static int input (yyscan_t yyscanner ); */ #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 = '*'; \ - size_t n; \ + unsigned n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1408,8 +1265,6 @@ static int input (yyscan_t yyscanner ); } \ }\ \ -/* %if-c++-only C++ definition \ */\ -/* %endif */ #endif @@ -1428,41 +1283,22 @@ static int input (yyscan_t yyscanner ); /* 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 @@ -1477,15 +1313,12 @@ extern int config_lex \ #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 @@ -1495,12 +1328,11 @@ YY_DECL register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -/* %% [7.0] user's declarations go here */ -#line 96 "libmemcached/csl/scanner.l" +#line 100 "libmemcached/csl/scanner.l" -#line 1504 "libmemcached/csl/scanner.cc" +#line 1336 "libmemcached/csl/scanner.cc" yylval = yylval_param; @@ -1516,18 +1348,10 @@ YY_DECL 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); @@ -1540,7 +1364,6 @@ YY_DECL 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. */ @@ -1551,7 +1374,6 @@ YY_DECL */ 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: @@ -1572,44 +1394,19 @@ yy_match: yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 1740 ); + while ( yy_current_state != 533 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; 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 < 66 ) - fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", - (long)yy_rule_linenum[yy_act], yytext ); - else if ( yy_act == 66 ) - fprintf( stderr, "--accepting default rule (\"%s\")\n", - yytext ); - else if ( yy_act == 67 ) - 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; @@ -1619,28 +1416,28 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 99 "libmemcached/csl/scanner.l" +#line 103 "libmemcached/csl/scanner.l" { return yytext[0];} YY_BREAK case 2: YY_RULE_SETUP -#line 101 "libmemcached/csl/scanner.l" +#line 105 "libmemcached/csl/scanner.l" { yylval->number= atoi(yytext); return (NUMBER); } YY_BREAK case 3: YY_RULE_SETUP -#line 103 "libmemcached/csl/scanner.l" +#line 107 "libmemcached/csl/scanner.l" { yylval->number= atoi(yytext +1); return PORT; } YY_BREAK case 4: YY_RULE_SETUP -#line 105 "libmemcached/csl/scanner.l" +#line 109 "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 107 "libmemcached/csl/scanner.l" +#line 111 "libmemcached/csl/scanner.l" ; /* skip whitespace */ YY_BREAK case 6: @@ -1648,224 +1445,224 @@ case 6: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 110 "libmemcached/csl/scanner.l" +#line 114 "libmemcached/csl/scanner.l" { return COMMENT; } YY_BREAK case 7: YY_RULE_SETUP -#line 114 "libmemcached/csl/scanner.l" +#line 118 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; yyextra->set_server(); return yyextra->previous_token= SERVER; } YY_BREAK case 8: YY_RULE_SETUP -#line 116 "libmemcached/csl/scanner.l" +#line 120 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET; } YY_BREAK case 9: YY_RULE_SETUP -#line 118 "libmemcached/csl/scanner.l" +#line 122 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= BINARY_PROTOCOL; } YY_BREAK case 10: YY_RULE_SETUP -#line 119 "libmemcached/csl/scanner.l" +#line 123 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= BUFFER_REQUESTS; } YY_BREAK case 11: YY_RULE_SETUP -#line 120 "libmemcached/csl/scanner.l" +#line 124 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= CONFIGURE_FILE; } YY_BREAK case 12: YY_RULE_SETUP -#line 121 "libmemcached/csl/scanner.l" +#line 125 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= CONNECT_TIMEOUT; } YY_BREAK case 13: YY_RULE_SETUP -#line 122 "libmemcached/csl/scanner.l" +#line 126 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= DISTRIBUTION; } YY_BREAK case 14: YY_RULE_SETUP -#line 123 "libmemcached/csl/scanner.l" +#line 127 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= HASH_WITH_NAMESPACE; } YY_BREAK case 15: YY_RULE_SETUP -#line 124 "libmemcached/csl/scanner.l" +#line 128 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= HASH; } YY_BREAK case 16: YY_RULE_SETUP -#line 125 "libmemcached/csl/scanner.l" +#line 129 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= IO_BYTES_WATERMARK; } YY_BREAK case 17: YY_RULE_SETUP -#line 126 "libmemcached/csl/scanner.l" +#line 130 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= IO_KEY_PREFETCH; } YY_BREAK case 18: YY_RULE_SETUP -#line 127 "libmemcached/csl/scanner.l" +#line 131 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= IO_MSG_WATERMARK; } YY_BREAK case 19: YY_RULE_SETUP -#line 128 "libmemcached/csl/scanner.l" +#line 132 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= NOREPLY; } YY_BREAK case 20: YY_RULE_SETUP -#line 129 "libmemcached/csl/scanner.l" +#line 133 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= NUMBER_OF_REPLICAS; } YY_BREAK case 21: YY_RULE_SETUP -#line 130 "libmemcached/csl/scanner.l" +#line 134 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= POLL_TIMEOUT; } YY_BREAK case 22: YY_RULE_SETUP -#line 131 "libmemcached/csl/scanner.l" +#line 135 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= RANDOMIZE_REPLICA_READ; } YY_BREAK case 23: YY_RULE_SETUP -#line 132 "libmemcached/csl/scanner.l" +#line 136 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= RCV_TIMEOUT; } YY_BREAK case 24: YY_RULE_SETUP -#line 133 "libmemcached/csl/scanner.l" +#line 137 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= REMOVE_FAILED_SERVERS; } YY_BREAK case 25: YY_RULE_SETUP -#line 134 "libmemcached/csl/scanner.l" +#line 138 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= RETRY_TIMEOUT; } YY_BREAK case 26: YY_RULE_SETUP -#line 135 "libmemcached/csl/scanner.l" +#line 139 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SND_TIMEOUT; } YY_BREAK case 27: YY_RULE_SETUP -#line 136 "libmemcached/csl/scanner.l" +#line 140 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET_RECV_SIZE; } YY_BREAK case 28: YY_RULE_SETUP -#line 137 "libmemcached/csl/scanner.l" +#line 141 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET_SEND_SIZE; } YY_BREAK case 29: YY_RULE_SETUP -#line 138 "libmemcached/csl/scanner.l" +#line 142 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SORT_HOSTS; } YY_BREAK case 30: YY_RULE_SETUP -#line 139 "libmemcached/csl/scanner.l" +#line 143 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SUPPORT_CAS; } YY_BREAK case 31: YY_RULE_SETUP -#line 140 "libmemcached/csl/scanner.l" +#line 144 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPALIVE; } YY_BREAK case 32: YY_RULE_SETUP -#line 141 "libmemcached/csl/scanner.l" +#line 145 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPIDLE; } YY_BREAK case 33: YY_RULE_SETUP -#line 142 "libmemcached/csl/scanner.l" +#line 146 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_NODELAY; } YY_BREAK case 34: YY_RULE_SETUP -#line 143 "libmemcached/csl/scanner.l" +#line 147 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= USE_UDP; } YY_BREAK case 35: YY_RULE_SETUP -#line 144 "libmemcached/csl/scanner.l" +#line 148 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= USER_DATA; } YY_BREAK case 36: YY_RULE_SETUP -#line 145 "libmemcached/csl/scanner.l" +#line 149 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= VERIFY_KEY; } YY_BREAK case 37: YY_RULE_SETUP -#line 147 "libmemcached/csl/scanner.l" +#line 151 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= POOL_MIN; } YY_BREAK case 38: YY_RULE_SETUP -#line 148 "libmemcached/csl/scanner.l" +#line 152 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= POOL_MAX; } YY_BREAK case 39: YY_RULE_SETUP -#line 150 "libmemcached/csl/scanner.l" +#line 154 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= NAMESPACE; } YY_BREAK case 40: YY_RULE_SETUP -#line 152 "libmemcached/csl/scanner.l" +#line 156 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= FETCH_VERSION; } YY_BREAK case 41: YY_RULE_SETUP -#line 154 "libmemcached/csl/scanner.l" +#line 158 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= INCLUDE; } YY_BREAK case 42: YY_RULE_SETUP -#line 155 "libmemcached/csl/scanner.l" +#line 159 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= RESET; } YY_BREAK case 43: YY_RULE_SETUP -#line 156 "libmemcached/csl/scanner.l" +#line 160 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= PARSER_DEBUG; } YY_BREAK case 44: YY_RULE_SETUP -#line 157 "libmemcached/csl/scanner.l" +#line 161 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= SERVERS; } YY_BREAK case 45: YY_RULE_SETUP -#line 158 "libmemcached/csl/scanner.l" +#line 162 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= END; } YY_BREAK case 46: YY_RULE_SETUP -#line 159 "libmemcached/csl/scanner.l" +#line 163 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return yyextra->previous_token= ERROR; } YY_BREAK case 47: YY_RULE_SETUP -#line 161 "libmemcached/csl/scanner.l" +#line 165 "libmemcached/csl/scanner.l" { return yyextra->previous_token= TRUE; } YY_BREAK case 48: YY_RULE_SETUP -#line 162 "libmemcached/csl/scanner.l" +#line 166 "libmemcached/csl/scanner.l" { return yyextra->previous_token= FALSE; } YY_BREAK case 49: YY_RULE_SETUP -#line 165 "libmemcached/csl/scanner.l" +#line 169 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return UNKNOWN_OPTION; @@ -1873,73 +1670,69 @@ YY_RULE_SETUP YY_BREAK case 50: YY_RULE_SETUP -#line 170 "libmemcached/csl/scanner.l" +#line 174 "libmemcached/csl/scanner.l" { return CONSISTENT; } YY_BREAK case 51: YY_RULE_SETUP -#line 171 "libmemcached/csl/scanner.l" +#line 175 "libmemcached/csl/scanner.l" { return MODULA; } YY_BREAK case 52: YY_RULE_SETUP -#line 172 "libmemcached/csl/scanner.l" +#line 176 "libmemcached/csl/scanner.l" { return RANDOM; } YY_BREAK case 53: YY_RULE_SETUP -#line 174 "libmemcached/csl/scanner.l" +#line 178 "libmemcached/csl/scanner.l" { return MD5; } YY_BREAK case 54: YY_RULE_SETUP -#line 175 "libmemcached/csl/scanner.l" +#line 179 "libmemcached/csl/scanner.l" { return CRC; } YY_BREAK case 55: YY_RULE_SETUP -#line 176 "libmemcached/csl/scanner.l" +#line 180 "libmemcached/csl/scanner.l" { return FNV1_64; } YY_BREAK case 56: YY_RULE_SETUP -#line 177 "libmemcached/csl/scanner.l" +#line 181 "libmemcached/csl/scanner.l" { return FNV1A_64; } YY_BREAK case 57: YY_RULE_SETUP -#line 178 "libmemcached/csl/scanner.l" +#line 182 "libmemcached/csl/scanner.l" { return FNV1_32; } YY_BREAK case 58: YY_RULE_SETUP -#line 179 "libmemcached/csl/scanner.l" +#line 183 "libmemcached/csl/scanner.l" { return FNV1A_32; } YY_BREAK case 59: YY_RULE_SETUP -#line 180 "libmemcached/csl/scanner.l" +#line 184 "libmemcached/csl/scanner.l" { return HSIEH; } YY_BREAK case 60: YY_RULE_SETUP -#line 181 "libmemcached/csl/scanner.l" +#line 185 "libmemcached/csl/scanner.l" { return MURMUR; } YY_BREAK case 61: YY_RULE_SETUP -#line 182 "libmemcached/csl/scanner.l" +#line 186 "libmemcached/csl/scanner.l" { return JENKINS; } YY_BREAK case 62: YY_RULE_SETUP -#line 184 "libmemcached/csl/scanner.l" +#line 188 "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; + yyextra->hostname(yytext, yyleng, yylval->server); return IPADDRESS; } YY_BREAK @@ -1949,17 +1742,12 @@ YY_RULE_SETUP { 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; + yyextra->hostname(yytext, yyleng, yylval->server); return HOSTNAME; } - yylval->string.c_str = yytext; - yylval->string.size = yyleng; + yyextra->string_buffer(yytext, yyleng, yylval->string); return STRING; } @@ -1967,17 +1755,16 @@ YY_RULE_SETUP case 64: /* rule 64 can match eol */ YY_RULE_SETUP -#line 211 "libmemcached/csl/scanner.l" +#line 206 "libmemcached/csl/scanner.l" { config_get_text(yyscanner)[yyleng -1]= 0; - yylval->string.c_str= yytext +1; - yylval->string.size= yyleng -2; + yyextra->string_buffer(yytext +1, yyleng -2, yylval->string); return QUOTED_STRING; } YY_BREAK case 65: YY_RULE_SETUP -#line 218 "libmemcached/csl/scanner.l" +#line 212 "libmemcached/csl/scanner.l" { yyextra->begin= yytext; return UNKNOWN; @@ -1985,10 +1772,10 @@ YY_RULE_SETUP YY_BREAK case 66: YY_RULE_SETUP -#line 223 "libmemcached/csl/scanner.l" +#line 217 "libmemcached/csl/scanner.l" ECHO; YY_BREAK -#line 1992 "libmemcached/csl/scanner.cc" +#line 1779 "libmemcached/csl/scanner.cc" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -2055,8 +1842,8 @@ case YY_STATE_EOF(INITIAL): 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; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; goto yy_find_action; } } @@ -2121,14 +1908,6 @@ case YY_STATE_EOF(INITIAL): } /* 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 * @@ -2137,11 +1916,7 @@ case YY_STATE_EOF(INITIAL): * 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; @@ -2276,25 +2051,17 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* 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] ) { @@ -2318,15 +2085,10 @@ static int yy_get_next_buffer (yyscan_t yyscanner) * 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; @@ -2347,11 +2109,6 @@ static int yy_get_next_buffer (yyscan_t yyscanner) 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) @@ -2359,9 +2116,6 @@ static int yy_get_next_buffer (yyscan_t yyscanner) static int input (yyscan_t yyscanner) #endif -/* %endif */ -/* %if-c++-only */ -/* %endif */ { int c; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -2426,25 +2180,18 @@ static int yy_get_next_buffer (yyscan_t yyscanner) *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; @@ -2462,11 +2209,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) * @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; @@ -2498,11 +2241,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) 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; @@ -2517,11 +2256,7 @@ static void config__load_buffer_state (yyscan_t yyscanner) * @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; @@ -2549,11 +2284,7 @@ static void config__load_buffer_state (yyscan_t yyscanner) * @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; @@ -2569,26 +2300,11 @@ static void config__load_buffer_state (yyscan_t 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; @@ -2608,13 +2324,8 @@ extern int isatty (int ); b->yy_bs_column = 0; } -/* %if-c-only */ - - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + b->yy_is_interactive = 0; -/* %endif */ -/* %if-c++-only */ -/* %endif */ errno = oerrno; } @@ -2622,11 +2333,7 @@ extern int isatty (int ); * @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 ) @@ -2650,18 +2357,13 @@ extern int isatty (int ); 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) @@ -2687,18 +2389,12 @@ void config_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) 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) @@ -2714,17 +2410,11 @@ void config_pop_buffer_state (yyscan_t 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; @@ -2767,9 +2457,7 @@ static void config_ensure_buffer_stack (yyscan_t yyscanner) 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 @@ -2804,9 +2492,7 @@ YY_BUFFER_STATE config__scan_buffer (char * base, yy_size_t size , yyscan_t yy 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 @@ -2820,13 +2506,11 @@ 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 yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @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. */ @@ -2859,21 +2543,16 @@ YY_BUFFER_STATE config__scan_bytes (yyconst char * yybytes, int _yybytes_len , 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. */ @@ -2894,9 +2573,6 @@ static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) /* 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. */ @@ -2906,8 +2582,6 @@ YY_EXTRA_TYPE config_get_extra (yyscan_t yyscanner) return yyextra; } -/* %endif */ - /** Get the current line number. * @param yyscanner The scanner object. */ @@ -2971,8 +2645,6 @@ char *config_get_text (yyscan_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. @@ -2983,8 +2655,6 @@ void config_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) yyextra = user_defined ; } -/* %endif */ - /** Set the current line number. * @param line_number * @param yyscanner The scanner object. @@ -3045,13 +2715,8 @@ void config_set_debug (int bdebug , yyscan_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; @@ -3064,8 +2729,6 @@ void config_set_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) yylval = yylval_param; } -/* %endif */ - /* User-visible API */ /* config_lex_init is special because it creates the scanner itself, so it is @@ -3130,9 +2793,6 @@ int config_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* 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; @@ -3165,9 +2825,7 @@ static int yy_init_globals (yyscan_t yyscanner) */ 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) { @@ -3192,14 +2850,11 @@ int config_lex_destroy (yyscan_t yyscanner) * 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. @@ -3247,14 +2902,9 @@ 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 223 "libmemcached/csl/scanner.l" +#line 217 "libmemcached/csl/scanner.l" @@ -3266,6 +2916,7 @@ void Context::init_scanner() void Context::destroy_scanner() { + (void)yy_fatal_error; // Removes warning about unused yy_fatal_error() config_lex_destroy(scanner); } diff --git a/libmemcached/csl/scanner.h b/libmemcached/csl/scanner.h index 6aa08a64..ab895707 100644 --- a/libmemcached/csl/scanner.h +++ b/libmemcached/csl/scanner.h @@ -17,21 +17,17 @@ #pragma GCC diagnostic ignored "-Wmissing-declarations" #endif -#define YY_NO_INPUT - #define YY_EXTRA_TYPE Context* -#line 28 "libmemcached/csl/scanner.h" +#line 26 "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 @@ -40,32 +36,16 @@ #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 @@ -96,6 +76,7 @@ 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 @@ -126,15 +107,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ -/* %endif */ - -/* %if-c++-only */ -/* %endif */ - #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ @@ -156,12 +130,6 @@ typedef unsigned int flex_uint32_t; #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 @@ -179,22 +147,9 @@ typedef void* yyscan_t; #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 -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif #ifndef YY_TYPEDEF_YY_BUFFER_STATE @@ -202,14 +157,6 @@ typedef void* yyscan_t; 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; @@ -219,12 +166,7 @@ typedef size_t yy_size_t; #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 */ @@ -271,18 +213,6 @@ struct yy_buffer_state }; #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 ); @@ -295,26 +225,17 @@ YY_BUFFER_STATE config__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscann 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 @@ -325,34 +246,17 @@ void config_free (void * ,yyscan_t yyscanner ); * 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. */ @@ -382,14 +286,14 @@ int config_get_lineno (yyscan_t yyscanner ); void config_set_lineno (int line_number ,yyscan_t yyscanner ); -/* %if-bison-bridge */ +int config_get_column (yyscan_t yyscanner ); + +void config_set_column (int column_no ,yyscan_t yyscanner ); 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. */ @@ -402,10 +306,6 @@ 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 @@ -415,24 +315,12 @@ 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 -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #endif /* Number of entries by which start-condition stack grows. */ @@ -440,40 +328,21 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); #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 @@ -486,9 +355,9 @@ extern int config_lex \ #undef YY_DECL #endif -#line 223 "libmemcached/csl/scanner.l" +#line 217 "libmemcached/csl/scanner.l" -#line 493 "libmemcached/csl/scanner.h" +#line 362 "libmemcached/csl/scanner.h" #undef config_IN_HEADER #endif /* config_HEADER_H */ diff --git a/libmemcached/csl/scanner.l b/libmemcached/csl/scanner.l index 8e404b5f..c5ae5cef 100644 --- a/libmemcached/csl/scanner.l +++ b/libmemcached/csl/scanner.l @@ -49,8 +49,6 @@ #pragma GCC diagnostic ignored "-Wmissing-declarations" #endif -#define YY_NO_INPUT - #define YY_EXTRA_TYPE Context* } @@ -77,6 +75,10 @@ } \ } +#define YY_FATAL_ERROR(msg) \ +{ \ +} + #define YY_INPUT(buffer, result, max_size) get_lex_chars(buffer, result, max_size, PARAM) @@ -84,14 +86,16 @@ %option 8bit %option bison-bridge +%option never-interactive %option case-insensitive -%option debug +%option noinput %option nounput %option noyywrap %option outfile="libmemcached/csl/scanner.cc" header-file="libmemcached/csl/scanner.h" %option perf-report %option prefix="config_" %option reentrant +%option warn %% @@ -182,36 +186,26 @@ 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; + yyextra->hostname(yytext, yyleng, yylval->server); 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; + yyextra->hostname(yytext, yyleng, yylval->server); return HOSTNAME; } - yylval->string.c_str = yytext; - yylval->string.size = yyleng; + yyextra->string_buffer(yytext, yyleng, yylval->string); return STRING; } L?\"(\\.|[^\\"])*\" { yyget_text(yyscanner)[yyleng -1]= 0; - yylval->string.c_str= yytext +1; - yylval->string.size= yyleng -2; + yyextra->string_buffer(yytext +1, yyleng -2, yylval->string); return QUOTED_STRING; } @@ -230,6 +224,7 @@ void Context::init_scanner() void Context::destroy_scanner() { + (void)yy_fatal_error; // Removes warning about unused yy_fatal_error() yylex_destroy(scanner); } diff --git a/libmemcached/csl/server.h b/libmemcached/csl/server.h index 92f7ed56..fe97eb91 100644 --- a/libmemcached/csl/server.h +++ b/libmemcached/csl/server.h @@ -42,8 +42,8 @@ struct server_t { - in_port_t port; - uint32_t weight; const char *c_str; size_t size; + in_port_t port; + uint32_t weight; }; diff --git a/libmemcached/do.cc b/libmemcached/do.cc index 0d05ea6d..db533680 100644 --- a/libmemcached/do.cc +++ b/libmemcached/do.cc @@ -48,7 +48,11 @@ memcached_return_t memcached_vdo(org::libmemcached::Instance* instance, vector[0].length= UDP_DATAGRAM_HEADER_LENGTH; msg.msg_iov= (struct iovec*)vector; +#if defined(TARGET_OS_OSX) && TARGET_OS_OSX + msg.msg_iovlen= int(count); +#else msg.msg_iovlen= count; +#endif uint32_t retry= 5; while (--retry) diff --git a/libmemcached/error.cc b/libmemcached/error.cc index 38c568c9..6ae5cba1 100644 --- a/libmemcached/error.cc +++ b/libmemcached/error.cc @@ -106,6 +106,11 @@ static void _set(memcached_st& memc, memcached_string_t *str, memcached_return_t rc= MEMCACHED_CONNECTION_FAILURE; } + if (rc == MEMCACHED_ERRNO and local_errno == ECONNRESET) + { + rc= MEMCACHED_CONNECTION_FAILURE; + } + if (local_errno == EINVAL) { rc= MEMCACHED_INVALID_ARGUMENTS; @@ -490,24 +495,29 @@ void memcached_error_free(memcached_server_st& self) self.error_messages= NULL; } +const char *memcached_error(const memcached_st *memc) +{ + return memcached_last_error_message(memc); +} + const char *memcached_last_error_message(const memcached_st *memc) { - if (memc == NULL) + if (memc) { - return memcached_strerror(memc, MEMCACHED_INVALID_ARGUMENTS); - } + if (memc->error_messages) + { + if (memc->error_messages->size == 0) + { + return memc->error_messages->message; + } - if (memc->error_messages == NULL) - { - return memcached_strerror(memc, MEMCACHED_SUCCESS); - } + return memcached_strerror(memc, memc->error_messages->rc); + } - if (memc->error_messages->size == 0) - { - return memcached_strerror(memc, memc->error_messages->rc); + return memcached_strerror(memc, MEMCACHED_SUCCESS); } - return memc->error_messages->message; + return memcached_strerror(memc, MEMCACHED_INVALID_ARGUMENTS); } bool memcached_has_current_error(memcached_st &memc) @@ -529,17 +539,17 @@ bool memcached_has_current_error(org::libmemcached::Instance& server) memcached_return_t memcached_last_error(const memcached_st *memc) { - if (memc == NULL) + if (memc) { - return MEMCACHED_INVALID_ARGUMENTS; - } + if (memc->error_messages) + { + return memc->error_messages->rc; + } - if (memc->error_messages == NULL) - { return MEMCACHED_SUCCESS; } - return memc->error_messages->rc; + return MEMCACHED_INVALID_ARGUMENTS; } int memcached_last_error_errno(const memcached_st *memc) diff --git a/libmemcached/hosts.cc b/libmemcached/hosts.cc index 4875615f..61c1b059 100644 --- a/libmemcached/hosts.cc +++ b/libmemcached/hosts.cc @@ -352,17 +352,29 @@ static memcached_return_t server_add(memcached_st *ptr, { assert_msg(ptr, "Programmer mistake, somehow server_add() was passed a NULL memcached_st"); - org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), (ptr->number_of_hosts + 1), org::libmemcached::Instance); + if (ptr->number_of_hosts) + { + assert(memcached_instance_list(ptr)); + } + + if (memcached_instance_list(ptr)) + { + assert(ptr->number_of_hosts); + } + + uint32_t host_list_size= ptr->number_of_hosts +1; + org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), host_list_size, org::libmemcached::Instance); if (new_host_list == NULL) { return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); } - memcached_instance_set(ptr, new_host_list); + memcached_instance_set(ptr, new_host_list, host_list_size); + assert(ptr->number_of_hosts == host_list_size); /* TODO: Check return type */ - org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, memcached_server_count(ptr)); + org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, memcached_server_count(ptr) -1); if (__instance_create_with(ptr, instance, hostname, port, weight, type) == NULL) { @@ -377,8 +389,6 @@ static memcached_return_t server_add(memcached_st *ptr, } } - ptr->number_of_hosts++; - return run_distribution(ptr); } @@ -390,23 +400,26 @@ memcached_return_t memcached_server_push(memcached_st *ptr, const memcached_serv return MEMCACHED_SUCCESS; } + uint32_t original_host_size= memcached_server_count(ptr); uint32_t count= memcached_server_list_count(list); + uint32_t host_list_size= count +original_host_size; - org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), (count + memcached_server_count(ptr)), org::libmemcached::Instance); + org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), host_list_size, org::libmemcached::Instance); if (new_host_list == NULL) { return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } - memcached_instance_set(ptr, new_host_list); + memcached_instance_set(ptr, new_host_list, host_list_size); - for (uint32_t x= 0; x < count; x++) + ptr->state.is_parsing= true; + for (uint32_t x= 0; x < count; ++x, ++original_host_size) { WATCHPOINT_ASSERT(list[x].hostname[0] != 0); // We have extended the array, and now we will find it, and use it. - org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, memcached_server_count(ptr)); + org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, original_host_size); WATCHPOINT_ASSERT(instance); memcached_string_t hostname= { memcached_string_make_from_cstr(list[x].hostname) }; @@ -414,6 +427,7 @@ memcached_return_t memcached_server_push(memcached_st *ptr, const memcached_serv hostname, list[x].port, list[x].weight, list[x].type) == NULL) { + ptr->state.is_parsing= false; return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); } @@ -421,9 +435,8 @@ memcached_return_t memcached_server_push(memcached_st *ptr, const memcached_serv { memcached_set_weighted_ketama(ptr, true); } - - ptr->number_of_hosts++; } + ptr->state.is_parsing= false; return run_distribution(ptr); } @@ -435,22 +448,28 @@ memcached_return_t memcached_instance_push(memcached_st *ptr, const struct org:: return MEMCACHED_SUCCESS; } - org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), (number_of_hosts +memcached_server_count(ptr)), org::libmemcached::Instance); + uint32_t original_host_size= memcached_server_count(ptr); + uint32_t host_list_size= number_of_hosts +original_host_size; + org::libmemcached::Instance* new_host_list= libmemcached_xrealloc(ptr, memcached_instance_list(ptr), host_list_size, org::libmemcached::Instance); if (new_host_list == NULL) { return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } - memcached_instance_set(ptr, new_host_list); + memcached_instance_set(ptr, new_host_list, host_list_size); - for (uint32_t x= 0; x < number_of_hosts; x++) - { + // We don't bother with lookups for this operation + ptr->state.is_parsing= true; + // We use original_host_size since size will now point to the first new + // instance allocated. + for (uint32_t x= 0; x < number_of_hosts; ++x, ++original_host_size) + { WATCHPOINT_ASSERT(list[x].hostname[0] != 0); // We have extended the array, and now we will find it, and use it. - org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, memcached_server_count(ptr)); + org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, original_host_size); WATCHPOINT_ASSERT(instance); memcached_string_t hostname= { memcached_string_make_from_cstr(list[x].hostname) }; @@ -458,6 +477,7 @@ memcached_return_t memcached_instance_push(memcached_st *ptr, const struct org:: hostname, list[x].port(), list[x].weight, list[x].type) == NULL) { + ptr->state.is_parsing= false; return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); } @@ -465,9 +485,8 @@ memcached_return_t memcached_instance_push(memcached_st *ptr, const struct org:: { memcached_set_weighted_ketama(ptr, true); } - - ptr->number_of_hosts++; } + ptr->state.is_parsing= false; return run_distribution(ptr); } diff --git a/libmemcached/instance.cc b/libmemcached/instance.cc index aacdad64..41f491e8 100644 --- a/libmemcached/instance.cc +++ b/libmemcached/instance.cc @@ -154,6 +154,7 @@ void __instance_free(org::libmemcached::Instance* self) self->address_info= NULL; self->address_info_next= NULL; } + assert(self->address_info_next == NULL); memcached_error_free(*self); @@ -307,23 +308,26 @@ static org::libmemcached::Instance* memcached_instance_clone(org::libmemcached:: void set_last_disconnected_host(org::libmemcached::Instance* self) { assert(self->root); - if (self->root == NULL) + if (self->root) { - return; - } + if (memcached_server_get_last_disconnect(self->root) and + memcached_server_get_last_disconnect(self->root)->version == self->version) + { + return; + } - if (memcached_server_get_last_disconnect(self->root) and - memcached_server_get_last_disconnect(self->root)->version == self->version) - { - return; - } + // const_cast + memcached_st *root= (memcached_st *)self->root; - // const_cast - memcached_st *root= (memcached_st *)self->root; + memcached_instance_free((org::libmemcached::Instance*)(root->last_disconnected_server)); - memcached_instance_free((org::libmemcached::Instance*)(root->last_disconnected_server)); - root->last_disconnected_server= memcached_instance_clone(self); - ((org::libmemcached::Instance*)memcached_server_get_last_disconnect(root))->version= self->version; + // We set is_parsing so that no lookup happens + root->state.is_parsing= true; + root->last_disconnected_server= memcached_instance_clone(self); + root->state.is_parsing= false; + + ((org::libmemcached::Instance*)memcached_server_get_last_disconnect(root))->version= self->version; + } } memcached_server_instance_st memcached_server_get_last_disconnect(const memcached_st *self) diff --git a/libmemcached/memcached.cc b/libmemcached/memcached.cc index 765b79ab..82d99f09 100644 --- a/libmemcached/memcached.cc +++ b/libmemcached/memcached.cc @@ -280,7 +280,7 @@ void memcached_servers_reset(memcached_st *self) { memcached_instance_list_free(memcached_instance_list(self), self->number_of_hosts); - memcached_instance_set(self, NULL); + memcached_instance_set(self, NULL, 0); self->number_of_hosts= 0; memcached_instance_free((org::libmemcached::Instance*)self->last_disconnected_server); self->last_disconnected_server= NULL; diff --git a/libmemcached/server.cc b/libmemcached/server.cc index f68e1f6b..20db52b8 100644 --- a/libmemcached/server.cc +++ b/libmemcached/server.cc @@ -194,10 +194,12 @@ uint32_t memcached_server_count(const memcached_st *self) const char *memcached_server_name(const memcached_server_instance_st self) { WATCHPOINT_ASSERT(self); - if (self == NULL) - return NULL; + if (self) + { + return self->hostname; + } - return self->hostname; + return NULL; } in_port_t memcached_server_port(const memcached_server_instance_st self) diff --git a/libmemcached/server_list.cc b/libmemcached/server_list.cc index 8205edc9..537e9edd 100644 --- a/libmemcached/server_list.cc +++ b/libmemcached/server_list.cc @@ -127,39 +127,36 @@ uint32_t memcached_instance_list_count(const memcached_st* self) : self->number_of_hosts; } -void memcached_instance_set(memcached_st* memc, org::libmemcached::Instance* list) +void memcached_instance_set(memcached_st* memc, org::libmemcached::Instance* list, const uint32_t host_list_size) { memc->servers= list; + memc->number_of_hosts= host_list_size; } void memcached_server_list_free(memcached_server_list_st self) { - if (self == NULL) + if (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]); + } - 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_free(self->root, self); } void memcached_instance_list_free(org::libmemcached::Instance* self, uint32_t instance_count) { - if (self == NULL) + if (self) { - return; - } + for (uint32_t x= 0; x < instance_count; x++) + { + assert_msg(memcached_is_allocated(&self[x]) == false, "You have called memcached_server_list_free(), but you did not pass it a valid memcached_server_list_st"); + __instance_free(&self[x]); + } - for (uint32_t x= 0; x < instance_count; 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"); - __instance_free(&self[x]); + libmemcached_free(self->root, self); } - - libmemcached_free(self->root, self); } diff --git a/libmemcached/server_list.hpp b/libmemcached/server_list.hpp index 95920194..ffbb6a36 100644 --- a/libmemcached/server_list.hpp +++ b/libmemcached/server_list.hpp @@ -44,4 +44,4 @@ uint32_t memcached_servers_set_count(memcached_server_list_st servers, uint32_t void memcached_instance_list_free(org::libmemcached::Instance* self, uint32_t count); -void memcached_instance_set(memcached_st*, org::libmemcached::Instance*); +void memcached_instance_set(memcached_st*, org::libmemcached::Instance*, const uint32_t host_list_size); diff --git a/libmemcached/string.cc b/libmemcached/string.cc index 268a437f..1c44e996 100644 --- a/libmemcached/string.cc +++ b/libmemcached/string.cc @@ -122,6 +122,18 @@ memcached_string_st *memcached_string_create(memcached_st *memc, memcached_strin 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; +} + static memcached_return_t memcached_string_append_null(memcached_string_st *string) { if (memcached_failed(_string_check(string, 1))) @@ -186,6 +198,18 @@ char *memcached_string_c_copy(memcached_string_st *string) return c_ptr; } +bool memcached_string_set(memcached_string_st& string, const char* value, size_t length) +{ + memcached_string_reset(&string); + if (memcached_success(memcached_string_append(&string, value, length))) + { + memcached_string_append_null(string); + return true; + } + + return false; +} + void memcached_string_reset(memcached_string_st *string) { string->end= string->string; diff --git a/libmemcached/string.hpp b/libmemcached/string.hpp index 61a428e2..e2978ccd 100644 --- a/libmemcached/string.hpp +++ b/libmemcached/string.hpp @@ -85,6 +85,8 @@ char *memcached_string_take_value(memcached_string_st *self); char *memcached_string_value_mutable(const memcached_string_st *self); +bool memcached_string_set(memcached_string_st&, const char*, size_t); + void memcached_string_set_length(memcached_string_st *self, size_t length); void memcached_string_set_length(memcached_string_st&, const size_t length); diff --git a/libmemcachedutil/ping.cc b/libmemcachedutil/ping.cc index 0154b530..e2831beb 100644 --- a/libmemcachedutil/ping.cc +++ b/libmemcachedutil/ping.cc @@ -54,30 +54,31 @@ bool libmemcached_util_ping(const char *hostname, in_port_t port, memcached_retu return false; } - (void)memcached_behavior_set(memc_ptr, MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, 400000); - - 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) + if (memcached_success((*ret= memcached_behavior_set(memc_ptr, MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, 400000)))) { - memcached_server_instance_st instance= - memcached_server_instance_by_position(memc_ptr, 0); + memcached_return_t rc= memcached_server_add(memc_ptr, hostname, port); + if (memcached_success(rc)) + { + rc= memcached_version(memc_ptr); + } - assert_msg(instance and memcached_server_error(instance), " "); - if (instance and memcached_server_error(instance)) + if (memcached_failed(rc) and rc == MEMCACHED_SOME_ERRORS) { - rc= memcached_server_error_return(instance); + memcached_server_instance_st instance= + memcached_server_instance_by_position(memc_ptr, 0); + + assert_msg(instance and memcached_server_error(instance), " "); + if (instance and memcached_server_error(instance)) + { + rc= memcached_server_error_return(instance); + } } + + *ret= rc; } memcached_free(memc_ptr); - *ret= rc; - - return memcached_success(rc); + return memcached_success(*ret); } bool libmemcached_util_ping2(const char *hostname, in_port_t port, const char *username, const char *password, memcached_return_t *ret) diff --git a/libtest/include.am b/libtest/include.am index 28c89c59..3dd6982a 100644 --- a/libtest/include.am +++ b/libtest/include.am @@ -5,7 +5,7 @@ # 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 --xml-file=./tmp_chroot/var/tmp/yatl-\%p.xml --xml=yes +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 diff --git a/m4/ax_harden_compiler_flags.m4 b/m4/ax_harden_compiler_flags.m4 index 8cc288ab..4cdf0147 100644 --- a/m4/ax_harden_compiler_flags.m4 +++ b/m4/ax_harden_compiler_flags.m4 @@ -47,66 +47,72 @@ # The Following flags are not checked for # -Wdeclaration-after-statement is counter to C99 +# AX_APPEND_COMPILE_FLAGS([-std=c++11]) -- Not ready yet +# AX_APPEND_COMPILE_FLAGS([-pedantic]) -- ? +# AX_APPEND_COMPILE_FLAGS([-Wstack-protector]) -- Issues on 32bit compile +# AX_APPEND_COMPILE_FLAGS([-fstack-protector-all]) -- Issues on 32bit compile #serial 1 -AC_DEFUN([AX_HARDEN_COMPILER_FLAGS], -[AC_REQUIRE([AX_APPEND_COMPILE_FLAGS]) -AC_REQUIRE([AX_CHECK_LINK_FLAG]) -AC_LANG_PUSH([C]) -AX_APPEND_COMPILE_FLAGS([-O2]) -AX_APPEND_COMPILE_FLAGS([-Werror]) -AX_APPEND_COMPILE_FLAGS([-Wall]) -AX_APPEND_COMPILE_FLAGS([-Wextra]) -AX_APPEND_COMPILE_FLAGS([-std=c99]) -AX_APPEND_COMPILE_FLAGS([-Wbad-function-cast]) -AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes]) -AX_APPEND_COMPILE_FLAGS([-Wnested-externs]) -AX_APPEND_COMPILE_FLAGS([-Wold-style-definition]) -AX_APPEND_COMPILE_FLAGS([-Woverride-init]) -AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes]) -AC_LANG_POP -AC_LANG_PUSH([C++]) -AX_APPEND_COMPILE_FLAGS([-O2]) -AX_APPEND_COMPILE_FLAGS([-Werror]) -AX_APPEND_COMPILE_FLAGS([-Wall]) -AX_APPEND_COMPILE_FLAGS([-Wextra]) -dnl AX_APPEND_COMPILE_FLAGS([-std=c++11]) -AX_APPEND_COMPILE_FLAGS([-Wpragmas]) -dnl AX_APPEND_COMPILE_FLAGS([-pedantic]) -AX_APPEND_COMPILE_FLAGS([--paramssp-buffer-size=1]) -AX_APPEND_COMPILE_FLAGS([-D_FORTIFY_SOURCE=2]) -AX_APPEND_COMPILE_FLAGS([-Waddress]) -AX_APPEND_COMPILE_FLAGS([-Warray-bounds]) -AX_APPEND_COMPILE_FLAGS([-Wchar-subscripts]) -AX_APPEND_COMPILE_FLAGS([-Wcomment]) -AX_APPEND_COMPILE_FLAGS([-Wctor-dtor-privacy]) -AX_APPEND_COMPILE_FLAGS([-Wfloat-equal]) -AX_APPEND_COMPILE_FLAGS([-Wformat=2]) -dnl AX_APPEND_COMPILE_FLAGS([-Wlong-long]) -AX_APPEND_COMPILE_FLAGS([-Wmaybe-uninitialized]) -AX_APPEND_COMPILE_FLAGS([-Wmissing-field-initializers]) -AX_APPEND_COMPILE_FLAGS([-Wmissing-noreturn]) -AX_APPEND_COMPILE_FLAGS([-Wnon-virtual-dtor]) -AX_APPEND_COMPILE_FLAGS([-Wnormalized=id]) -AX_APPEND_COMPILE_FLAGS([-Woverloaded-virtual]) -AX_APPEND_COMPILE_FLAGS([-Wpointer-arith]) -AX_APPEND_COMPILE_FLAGS([-Wredundant-decls]) -AX_APPEND_COMPILE_FLAGS([-Wshadow]) -AX_APPEND_COMPILE_FLAGS([-Wshorten-64-to-32]) -AX_APPEND_COMPILE_FLAGS([-Wsign-compare]) -AX_APPEND_COMPILE_FLAGS([-Wstack-protector]) -AX_APPEND_COMPILE_FLAGS([-Wstrict-overflow=1]) -AX_APPEND_COMPILE_FLAGS([-Wswitch-enum]) -AX_APPEND_COMPILE_FLAGS([-Wundef]) -AX_APPEND_COMPILE_FLAGS([-Wunused-result]) -AX_APPEND_COMPILE_FLAGS([-Wunused-variable]) -AX_APPEND_COMPILE_FLAGS([-Wwrite-strings]) -AX_APPEND_COMPILE_FLAGS([-floop-parallelize-all]) -AX_APPEND_COMPILE_FLAGS([-fstack-protector-all]) -AX_APPEND_COMPILE_FLAGS([-fwrapv]) -AX_APPEND_COMPILE_FLAGS([-ggdb]) -AX_CHECK_LINK_FLAG([-Werror]) -AX_CHECK_LINK_FLAG([-z relro -z now]) -AC_LANG_POP -])dnl AX_HARDEN_COMPILER_FLAGS + AC_DEFUN([AX_HARDEN_C_COMPILER_FLAGS], [ + AC_REQUIRE([AX_APPEND_COMPILE_FLAGS]) + AC_REQUIRE([AX_CHECK_LINK_FLAG]) + AC_REQUIRE([AX_VCS_CHECKOUT]) + + AC_LANG_PUSH([C]) + AX_APPEND_COMPILE_FLAGS([-O2]) + AX_APPEND_COMPILE_FLAGS([-Werror]) + AX_APPEND_COMPILE_FLAGS([-Wall]) + AX_APPEND_COMPILE_FLAGS([-Wextra]) + AX_APPEND_COMPILE_FLAGS([-std=c99]) + AX_APPEND_COMPILE_FLAGS([-Wbad-function-cast]) + AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes]) + AX_APPEND_COMPILE_FLAGS([-Wnested-externs]) + AX_APPEND_COMPILE_FLAGS([-Wold-style-definition]) + AX_APPEND_COMPILE_FLAGS([-Woverride-init]) + AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes]) + AC_LANG_POP + ]) + + AC_DEFUN([AX_HARDEN_CC_COMPILER_FLAGS], [ + AC_REQUIRE([AX_HARDEN_C_COMPILER_FLAGS]) + AC_LANG_PUSH([C++]) + AX_APPEND_COMPILE_FLAGS([-O2]) + AX_APPEND_COMPILE_FLAGS([-Werror]) + AX_APPEND_COMPILE_FLAGS([-Wall]) + AX_APPEND_COMPILE_FLAGS([-Wextra]) + AX_APPEND_COMPILE_FLAGS([-Wpragmas]) + AX_APPEND_COMPILE_FLAGS([--paramssp-buffer-size=1]) + AX_APPEND_COMPILE_FLAGS([-D_FORTIFY_SOURCE=2]) + AX_APPEND_COMPILE_FLAGS([-Waddress]) + AX_APPEND_COMPILE_FLAGS([-Warray-bounds]) + AX_APPEND_COMPILE_FLAGS([-Wchar-subscripts]) + AX_APPEND_COMPILE_FLAGS([-Wcomment]) + AX_APPEND_COMPILE_FLAGS([-Wctor-dtor-privacy]) + AX_APPEND_COMPILE_FLAGS([-Wfloat-equal]) + AX_APPEND_COMPILE_FLAGS([-Wformat=2]) + AX_APPEND_COMPILE_FLAGS([-Wlong-long]) + AX_APPEND_COMPILE_FLAGS([-Wmaybe-uninitialized]) + AX_APPEND_COMPILE_FLAGS([-Wmissing-field-initializers]) + AX_APPEND_COMPILE_FLAGS([-Wmissing-noreturn]) + AX_APPEND_COMPILE_FLAGS([-Wnon-virtual-dtor]) + AX_APPEND_COMPILE_FLAGS([-Wnormalized=id]) + AX_APPEND_COMPILE_FLAGS([-Woverloaded-virtual]) + AX_APPEND_COMPILE_FLAGS([-Wpointer-arith]) + AX_APPEND_COMPILE_FLAGS([-Wredundant-decls]) + AX_APPEND_COMPILE_FLAGS([-Wshadow]) + AX_APPEND_COMPILE_FLAGS([-Wshorten-64-to-32]) + AX_APPEND_COMPILE_FLAGS([-Wsign-compare]) + AX_APPEND_COMPILE_FLAGS([-Wstrict-overflow=1]) + AX_APPEND_COMPILE_FLAGS([-Wswitch-enum]) + AX_APPEND_COMPILE_FLAGS([-Wundef]) + AX_APPEND_COMPILE_FLAGS([-Wunused-result]) + AX_APPEND_COMPILE_FLAGS([-Wunused-variable]) + AX_APPEND_COMPILE_FLAGS([-Wwrite-strings]) + AX_APPEND_COMPILE_FLAGS([-floop-parallelize-all]) + AX_APPEND_COMPILE_FLAGS([-fwrapv]) + AX_APPEND_COMPILE_FLAGS([-ggdb]) + AX_CHECK_LINK_FLAG([-Werror]) + AX_CHECK_LINK_FLAG([-z relro -z now]) + AC_LANG_POP + ]) diff --git a/m4/ax_pthread_timedjoin_np.m4 b/m4/ax_pthread_timedjoin_np.m4 index 833b2846..a0e6c253 100644 --- a/m4/ax_pthread_timedjoin_np.m4 +++ b/m4/ax_pthread_timedjoin_np.m4 @@ -4,7 +4,7 @@ # # SYNOPSIS # -# AX_LIB_UUID +# AX_PTHREAD_TIMEDJOIN_NP # # DESCRIPTION # @@ -19,30 +19,37 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 2 +#serial 3 AC_DEFUN([AX_PTHREAD_TIMEDJOIN_NP], [ - AC_CACHE_CHECK([check for pthread_timedjoin_np], [ax_cv_pthread_timedjoin_np], [ - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$PTHREAD_LIBS" - AC_LANG_PUSH([C]) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([ -#include - ], [ - uuid_t out; - pthread_timedjoin_np(out); - ]), [ax_cv_pthread_timedjoin_np=yes ], [ax_cv_pthread_timedjoin_np=no ] - ]) + AC_REQUIRE([AX_PTHREAD]) + AC_CACHE_CHECK([check for pthread_timedjoin_np], [ax_cv_pthread_timedjoin_np], [ + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$PTHREAD_LIBS" + AC_LANG_PUSH([C]) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif - AC_LANG_POP - LDFLAGS="$save_LDFLAGS" +#include +#include + ], [ + pthread_t thread; + pthread_timedjoin_np(thread, NULL); + ])], + [ax_cv_pthread_timedjoin_np=yes], + []) - ]) + AC_LANG_POP + LDFLAGS="$save_LDFLAGS" - AS_IF([test "$ax_cv_pthread_timedjoin_np" = yes],[ - AC_DEFINE(HAVE_PTHREAD_TIMEDJOIN_NP,[1],[Define if pthread_timedjoin_np is present in pthread.h.])],[ - AC_DEFINE(HAVE_PTHREAD_TIMEDJOIN_NP,[0],[Define if pthread_timedjoin_np is present in pthread.h.]) - ]) -]) + ]) + + AS_IF([test "$ax_cv_pthread_timedjoin_np" = yes],[ + AC_DEFINE(HAVE_PTHREAD_TIMEDJOIN_NP,[1],[Define if pthread_timedjoin_np is present in pthread.h.])],[ + AC_DEFINE(HAVE_PTHREAD_TIMEDJOIN_NP,[0],[Define if pthread_timedjoin_np is present in pthread.h.]) + ]) + ]) diff --git a/m4/check_sock_cloexec.m4 b/m4/check_sock_cloexec.m4 index 30587745..6936ab40 100644 --- a/m4/check_sock_cloexec.m4 +++ b/m4/check_sock_cloexec.m4 @@ -1,18 +1,26 @@ -dnl CHECK_SOCK_CLOEXEC([action-if-found], [action-if-not-found]) -AC_DEFUN([AX_CHECK_SOCK_CLOEXEC], [{ - AC_MSG_CHECKING(whether SOCK_CLOEXEC is supported) - AC_TRY_RUN([/* SOCK_CLOEXEC test */ +# Author? +# AX_CHECK_SOCK_CLOEXEC([action-if-found], [action-if-not-found]) +# + +#serial 1 + +AC_DEFUN([AX_CHECK_SOCK_CLOEXEC], [ + AC_CACHE_CHECK([whether SOCK_CLOEXEC is supported], [ax_cv_sock_cloexec], [ + AC_LANG_PUSH([C]) + AC_RUN_IFELSE([ + AC_LANG_PROGRAM([ + + /* SOCK_CLOEXEC test */ #include #include -int main (int argc, char *argv []) -{ - int s= socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0); - return (s == -1); -} - ], - [AC_MSG_RESULT(yes) ; ax_cv_sock_cloexec="yes" ; $1], - [AC_MSG_RESULT(no) ; ax_cv_sock_cloexec="no" ; $2], - [AC_MSG_RESULT(not during cross-compile) ; ax_cv_sock_cloexec="no"] - ) -}]) + ], [ + int s= socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0); + return (s == -1); + ])], + [ax_cv_sock_cloexec=yes], + [ax_cv_sock_cloexec=no]) + ]) + + AS_IF([test x"ax_cv_sock_cloexec" = xyes], [AC_MSG_RESULT([yes]) ; $1], AC_MSG_RESULT([no]) ; $2) + ]) diff --git a/m4/debug.m4 b/m4/debug.m4 new file mode 100644 index 00000000..60557659 --- /dev/null +++ b/m4/debug.m4 @@ -0,0 +1,18 @@ +AC_DEFUN([AX_DEBUG],[ + 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.]) + ]) +]) diff --git a/m4/have_cinttypes.m4 b/m4/have_cinttypes.m4 index bcfea1c3..6d03cf5d 100644 --- a/m4/have_cinttypes.m4 +++ b/m4/have_cinttypes.m4 @@ -40,47 +40,54 @@ # 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 +#serial 2 - -AC_DEFUN([AX_CXX_CINTTYPES], - [ +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=""], - [ + AC_CACHE_CHECK([for location of cinttypes], [ac_cv_cxx_cinttypes], [ + save_CXXFLAGS="${CXXFLAGS}" + CXXFLAGS="${CXX_STANDARD} ${CXXFLAGS}" + AC_LANG_PUSH([C++]) + + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([#include ], [ + uint32_t foo= UINT32_C(1); + ])], + [ac_cxx_cinttypes_cinttypes=""]) + # Look for tr1/cinttypes - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], [ uint32_t foo= UINT32_C(1) ])], - [ac_cv_cxx_cinttypes=""], - [ + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([#include ], [ + uint32_t foo= UINT32_C(1); + ])], + [ac_cxx_cinttypes_tr1_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() + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([#include ], [ + uint32_t foo= UINT32_C(1); + ])], + [ac_cxx_cinttypes_boost_cinttypes_hpp=""]) + + AC_LANG_POP + CXXFLAGS="${save_CXXFLAGS}" + + AS_IF([test -n "$ac_cxx_cinttypes_cinttypes"], [ac_cv_cxx_cinttypes=$ac_cxx_cinttypes_cinttypes], + [test -n "$ac_cxx_cinttypes_tr1_cinttypes"], [ac_cv_cxx_cinttypes=$ac_cxx_cinttypes_tr1_cinttypes], + [test -n "$ac_cxx_cinttypes_boost_cinttypes_hpp"], [ac_cv_cxx_cinttypes=$ac_cxx_cinttypes_boost_cinttypes_hpp]) + ]) - 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 + AS_IF([ test -n "$ac_cv_cxx_cinttypes"], [ + AC_MSG_RESULT([$ac_cv_cxx_cinttypes]) + ],[ + ac_cv_cxx_cinttypes="" + AC_MSG_WARN([Could not find a cinttypes header.]) + AC_MSG_RESULT([$ac_cv_cxx_cinttypes]) + ]) AC_DEFINE([__STDC_LIMIT_MACROS],[1],[Use STDC Limit Macros in C++]) - AC_DEFINE_UNQUOTED(CINTTYPES_H,$ac_cv_cxx_cinttypes, [the location of ]) + AC_DEFINE_UNQUOTED([CINTTYPES_H],[$ac_cv_cxx_cinttypes],[the location of ]) ]) diff --git a/m4/have_cstdint.m4 b/m4/have_cstdint.m4 index ef084352..685d4ade 100644 --- a/m4/have_cstdint.m4 +++ b/m4/have_cstdint.m4 @@ -40,50 +40,46 @@ # 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 +#serial 2 -AC_DEFUN([AX_CXX_CSTDINT], - [ +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_CACHE_CHECK([for location of cstdint], [ac_cv_cxx_cstdint], [ + AC_LANG_PUSH([C++]) + save_CXXFLAGS="${CXXFLAGS}" + CXXFLAGS="${CXX_STANDARD} ${CXXFLAGS}" - 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_COMPILE_IFELSE([ + AC_LANG_PROGRAM([#include ], [ uint32_t t ])], + [ac_cxx_cstdint_cstdint=""]) - ]) - ]) -# ]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([#include ], [ uint32_t t ])], + [ac_cxx_cstdint_tr1_cstdint=""]) - AC_LANG_POP() + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([#include ], [ uint32_t t ])], + [ac_cxx_cstdint_boost_cstdint_hpp=""]) - 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_LANG_POP + CXXFLAGS="${save_CXXFLAGS}" - AC_DEFINE_UNQUOTED(CSTDINT_H,$ac_cv_cxx_cstdint, [the location of ]) + AS_IF([test -n "$ac_cxx_cstdint_cstdint"], [ac_cv_cxx_cstdint=$ac_cxx_cstdint_cstdint], + [test -n "$ac_cxx_cstdint_tr1_cstdint"], [ac_cv_cxx_cstdint=$ac_cxx_cstdint_tr1_cstdint], + [test -n "$ac_cxx_cstdint_boost_cstdint_hpp"], [ac_cv_cxx_cstdint=$ac_cxx_cstdint_boost_cstdint_hpp]) + ]) + + AS_IF([test -n "$ac_cv_cxx_cstdint"], [ + AC_MSG_RESULT([$ac_cv_cxx_cstdint]) + ],[ + ac_cv_cxx_cstdint="" + AC_MSG_WARN([Could not find a cstdint header.]) + AC_MSG_RESULT([$ac_cv_cxx_cstdint]) + ]) + +AC_DEFINE_UNQUOTED([CSTDINT_H],[$ac_cv_cxx_cstdint], [the location of ]) ]) diff --git a/m4/uuid.m4 b/m4/uuid.m4 index 9fc0cf33..67d5fa37 100644 --- a/m4/uuid.m4 +++ b/m4/uuid.m4 @@ -4,7 +4,8 @@ # # SYNOPSIS # -# AX_LIB_UUID +# AX_UUID +# AX_UUID_GENERATE_TIME_SAFE # # DESCRIPTION # @@ -19,28 +20,74 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 2 +#serial 3 -AC_DEFUN([AX_UUID_GENERATE_TIME_SAFE], [ - AC_CACHE_CHECK([check for uuid_generate_time_safe], [ax_cv_uuid_generate_time_safe], [ - save_LDFLAGS="$LDFLAGS" - LDFLAGS="-luuid" - AC_LANG_PUSH([C]) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([ -#include - ], [ - uuid_t out; - uuid_generate_time_safe(out); - ]), [ax_cv_uuid_generate_time_safe=yes ], [ax_cv_uuid_generate_time_safe=no ] - ]) +AC_DEFUN([AX_UUID], [ + AC_CHECK_HEADER([uuid/uuid.h], [ + AC_CACHE_CHECK([check to see if -luuid is not needed], [ax_cv_libuuid_is_required], [ + AC_LANG_PUSH([C]) + AC_RUN_IFELSE([ + AC_LANG_PROGRAM([#include ], [ + uuid_t out; + uuid_generate(out); + ])], + [ax_cv_libuuid_is_required=no], + [ax_cv_libuuid_is_required=maybe], + [AC_MSG_WARN([test program execution failed])]) + AC_LANG_POP + ]) + + AS_IF([test "$ax_cv_libuuid_is_required" = maybe], [ + AC_CACHE_CHECK([check to see if -luuid is needed], [ax_cv_libuuid_works], [ + save_LIBS="$LIBS" + LIBS="-luuid $LIBS" + AC_LANG_PUSH([C]) + AC_RUN_IFELSE([ + AC_LANG_PROGRAM([#include ], [ + uuid_t out; + uuid_generate(out); + ])], + [ax_cv_libuuid_works=yes], + [ax_cv_libuuid_works=no], + [AC_MSG_WARN([test program execution failed])]) + AC_LANG_POP + LIBS="$save_LIBS" + ]) + AS_IF([test "$ax_cv_libuuid_works" = yes], [ + AC_SUBST([LIBUUID_LDFLAGS],[-luuid])]) + ]) - AC_LANG_POP - LDFLAGS="$save_LDFLAGS" - ]) + AS_IF([test "$ax_cv_libuuid_is_required" = no], [UUID_UUID_H=yes]) + AS_IF([test "$ax_cv_libuuid_works" = yes], [UUID_UUID_H=yes]) + ]) - AS_IF([test "$ax_cv_uuid_generate_time_safe" = yes],[ - AC_DEFINE(HAVE_UUID_GENERATE_TIME_SAFE,[1],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])],[ - AC_DEFINE(HAVE_UUID_GENERATE_TIME_SAFE,[0],[Define if uuid_generate_time_safe is present in uuid/uuid.h.]) + AS_IF([test "$UUID_UUID_H" = yes], [ + AC_DEFINE([HAVE_UUID_UUID_H], [1], [Have uuid/uuid.h]) + ],[ + AC_DEFINE([HAVE_UUID_UUID_H], [0], [Have uuid/uuid.h]) + ]) ]) -]) + + AC_DEFUN([AX_UUID_GENERATE_TIME_SAFE], [ + AC_REQUIRE([AX_UUID]) + AC_CACHE_CHECK([for uuid_generate_time_safe], [ax_cv_uuid_generate_time_safe], [ + save_LIBS="$LIBS" + LIBS="$LIBUUID_LDFLAGS $LIBS" + AC_LANG_PUSH([C]) + AC_RUN_IFELSE([ + AC_LANG_PROGRAM([#include ], [ + uuid_t out; + uuid_generate_time_safe(out); + ])], + [ax_cv_uuid_generate_time_safe=yes], + [ax_cv_uuid_generate_time_safe=no], + [AC_MSG_WARN([test program execution failed])]) + AC_LANG_POP + LIBS="$save_LIBS" + ]) + + AS_IF([test "$ax_cv_uuid_generate_time_safe" = yes],[ + AC_DEFINE(HAVE_UUID_GENERATE_TIME_SAFE,[1],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])],[ + AC_DEFINE(HAVE_UUID_GENERATE_TIME_SAFE,[0],[Define if uuid_generate_time_safe is present in uuid/uuid.h.]) + ]) + ]) diff --git a/tests/include.am b/tests/include.am index b8e9e17f..2538d51c 100644 --- a/tests/include.am +++ b/tests/include.am @@ -107,6 +107,9 @@ test-cycle: tests/cycle test-memcapable: tests/memcapable @tests/memcapable +valgrind-memcapable: tests/memcapable + $(VALGRIND_COMMAND) tests/memcapable + pahole-mem: tests/testapp @$(PAHOLE_COMMAND) tests/testapp diff --git a/tests/libmemcached-1.0/include.am b/tests/libmemcached-1.0/include.am index 06cd8747..e5f00b9b 100644 --- a/tests/libmemcached-1.0/include.am +++ b/tests/libmemcached-1.0/include.am @@ -168,6 +168,9 @@ tests_libmemcached_1_0_testsocket_LDADD+= libhashkit/libhashkit.la check_PROGRAMS+= tests/libmemcached-1.0/testsocket noinst_PROGRAMS+= tests/libmemcached-1.0/testsocket +test-socket: tests/libmemcached-1.0/testsocket + @tests/libmemcached-1.0/testsocket + tests_libmemcached_1_0_sasl_SOURCES= tests_libmemcached_1_0_sasl_DEPENDENCIES= tests_libmemcached_1_0_sasl_LDADD= diff --git a/tests/libmemcached-1.0/mem_functions.cc b/tests/libmemcached-1.0/mem_functions.cc index 3b1701e8..a6adac1b 100644 --- a/tests/libmemcached-1.0/mem_functions.cc +++ b/tests/libmemcached-1.0/mem_functions.cc @@ -1754,6 +1754,11 @@ test_return_t block_add_regression(memcached_st *memc) global_pairs[x].key, global_pairs[x].key_length, &blob[0], blob.size(), time_t(0), uint32_t(0)); + if (rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE) + { + Error << memcached_last_error_message(memc); + return TEST_SKIPPED; + } test_compare(*memc, MEMCACHED_SUCCESS); test_compare(rc, MEMCACHED_SUCCESS); } @@ -3312,7 +3317,7 @@ test_return_t analyzer_test(memcached_st *memc) test_return_t util_version_test(memcached_st *memc) { - test_compare(MEMCACHED_SUCCESS, memcached_version(memc)); + test_compare(memcached_version(memc), MEMCACHED_SUCCESS); test_true(libmemcached_util_version_check(memc, 0, 0, 0)); bool if_successful= libmemcached_util_version_check(memc, 9, 9, 9); diff --git a/tests/libmemcached-1.0/parser.cc b/tests/libmemcached-1.0/parser.cc index fc9d3375..a027f50e 100644 --- a/tests/libmemcached-1.0/parser.cc +++ b/tests/libmemcached-1.0/parser.cc @@ -663,6 +663,7 @@ test_return_t test_hostname_port_weight(memcached_st *) struct socket_weight_t { const char *socket; size_t weight; + const char* type; }; static memcached_return_t dump_socket_information(const memcached_st *, @@ -671,15 +672,27 @@ static memcached_return_t dump_socket_information(const memcached_st *, { socket_weight_t *check= (socket_weight_t *)context; - if (strcmp(memcached_server_name(instance), check->socket)) + if (strcmp(memcached_server_type(instance), check->type) == 0) { - Error << memcached_server_name(instance) << " != " << check->socket; - return MEMCACHED_FAILURE; + if (strcmp(memcached_server_name(instance), check->socket) == 0) + { + if (instance->weight == check->weight) + { + return MEMCACHED_SUCCESS; + } + else + { + Error << instance->weight << " != " << check->weight; + } + } + else + { + Error << "'" << memcached_server_name(instance) << "'" << " != " << "'" << check->socket << "'"; + } } - - if (instance->weight == check->weight) + else { - return MEMCACHED_SUCCESS; + Error << "'" << memcached_server_type(instance) << "'" << " != " << "'" << check->type << "'"; } return MEMCACHED_FAILURE; @@ -697,7 +710,7 @@ test_return_t test_parse_socket(memcached_st *) memcached_st *memc= memcached(test_literal_param("--socket=\"/tmp/foo\"")); test_true(memc); - socket_weight_t check= { "/tmp/foo", 1 }; + socket_weight_t check= { "/tmp/foo", 1, "SOCKET"}; test_compare(MEMCACHED_SUCCESS, memcached_server_cursor(memc, callbacks, &check, 1)); memcached_free(memc); @@ -710,7 +723,7 @@ test_return_t test_parse_socket(memcached_st *) memcached_st *memc= memcached(test_literal_param("--socket=\"/tmp/foo\"/?23")); test_true(memc); - socket_weight_t check= { "/tmp/foo", 23 }; + socket_weight_t check= { "/tmp/foo", 23, "SOCKET"}; test_compare(MEMCACHED_SUCCESS, memcached_server_cursor(memc, callbacks, &check, 1)); memcached_free(memc);