From: Monty Taylor Date: Mon, 6 Jul 2009 17:20:04 +0000 (-0500) Subject: Turned on -fvisibility=hidden. Added API markers to the code. X-Git-Tag: 0.31~4^2~9 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=e115444989a124cc1a433ea20c13e877317bb0ad;p=m6w6%2Flibmemcached Turned on -fvisibility=hidden. Added API markers to the code. --- diff --git a/configure.ac b/configure.ac index b2fb9880..a336819e 100644 --- a/configure.ac +++ b/configure.ac @@ -290,7 +290,7 @@ uint16_t x= htons(80); [W_FAIL=""]) #[W_FAIL="-Werror"]) - BASE_WARNINGS="-pedantic -Wall -Wextra ${W_FAIL} -Wundef -Wshadow -Wmissing-declarations -Wstrict-aliasing -Wformat=2 ${F_DIAGNOSTICS_SHOW_OPTION} ${W_CONVERSION}" + BASE_WARNINGS="-pedantic -Wall -Wextra ${W_FAIL} -Wundef -Wshadow -Wmissing-declarations -Wstrict-aliasing -Wformat=2 ${F_DIAGNOSTICS_SHOW_OPTION} ${W_CONVERSION} ${CFLAG_VISIBILITY}" CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wswitch-default -Wswitch-enum -Wcast-align" CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wold-style-cast -Weffc++ -Wno-long-long" diff --git a/libmemcached/Makefile.am b/libmemcached/Makefile.am index d9427040..583270cf 100644 --- a/libmemcached/Makefile.am +++ b/libmemcached/Makefile.am @@ -35,7 +35,7 @@ noinst_LTLIBRARIES = libmemcachedcallbacks.la libmemcachedcallbacks_la_CFLAGS = ${AM_CFLAGS} ${NO_STRICT_ALIASING} libmemcachedcallbacks_la_SOURCES = memcached_callback.c -libmemcached_la_CFLAGS= ${AM_CFLAGS} ${NO_CONVERSION} -DBUILDING_LIBMEMCACHED +libmemcached_la_CFLAGS= ${AM_CFLAGS} ${NO_CONVERSION} libmemcached_la_SOURCES = crc.c \ memcached.c \ memcached_auto.c \ diff --git a/libmemcached/common.h b/libmemcached/common.h index c413b1fe..d8371d18 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -34,11 +34,15 @@ # endif #endif +/* Define this here, which will turn on the visibilty controls while we're + * building libmemcached. + */ +#define BUILDING_LIBMEMCACHED 1 + #include "libmemcached/memcached.h" #include "libmemcached/memcached_watchpoint.h" -#if defined(BUILDING_LIBMEMCACHED) /* These are private not to be installed headers */ #include "libmemcached/memcached_io.h" #include "libmemcached/memcached_internal.h" @@ -51,10 +55,6 @@ struct memcached_continuum_item_st { uint32_t value; }; -#endif - - - #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) @@ -95,48 +95,61 @@ typedef enum { MEM_AUTO_EJECT_HOSTS= (1 << 16) } memcached_flags; -#if defined(BUILDING_LIBMEMCACHED) /* Hashing algo */ + +LIBMEMCACHED_LOCAL void md5_signature(const unsigned char *key, unsigned int length, unsigned char *result); +LIBMEMCACHED_LOCAL uint32_t hash_crc32(const char *data, size_t data_len); #ifdef HAVE_HSIEH_HASH +LIBMEMCACHED_LOCAL uint32_t hsieh_hash(const char *key, size_t key_length); #endif +LIBMEMCACHED_LOCAL uint32_t murmur_hash(const char *key, size_t key_length); +LIBMEMCACHED_LOCAL uint32_t jenkins_hash(const void *key, size_t length, uint32_t initval); +LIBMEMCACHED_LOCAL memcached_return memcached_connect(memcached_server_st *ptr); +LIBMEMCACHED_LOCAL memcached_return memcached_response(memcached_server_st *ptr, char *buffer, size_t buffer_length, memcached_result_st *result); +LIBMEMCACHED_LOCAL void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death); #define memcached_server_response_increment(A) (A)->cursor_active++ #define memcached_server_response_decrement(A) (A)->cursor_active-- #define memcached_server_response_reset(A) (A)->cursor_active=0 +LIBMEMCACHED_LOCAL memcached_return memcached_do(memcached_server_st *ptr, const void *commmand, size_t command_length, uint8_t with_flush); -memcached_return memcached_version(memcached_st *ptr); +LIBMEMCACHED_LOCAL memcached_return value_fetch(memcached_server_st *ptr, char *buffer, memcached_result_st *result); +LIBMEMCACHED_LOCAL void server_list_free(memcached_st *ptr, memcached_server_st *servers); +LIBMEMCACHED_LOCAL memcached_return memcached_key_test(char **keys, size_t *key_length, unsigned int number_of_keys); -memcached_return run_distribution(memcached_st *ptr); +LIBMEMCACHED_LOCAL uint32_t generate_hash(memcached_st *ptr, const char *key, size_t key_length); -memcached_return memcached_server_remove(memcached_server_st *st_ptr); #ifndef HAVE_HTONLL +LIBMEMCACHED_LOCAL extern uint64_t ntohll(uint64_t); +LIBMEMCACHED_LOCAL extern uint64_t htonll(uint64_t); #endif +LIBMEMCACHED_LOCAL memcached_return memcached_purge(memcached_server_st *ptr); static inline memcached_return memcached_validate_key_length(size_t key_length, @@ -157,6 +170,5 @@ static inline memcached_return memcached_validate_key_length(size_t key_length, return MEMCACHED_SUCCESS; } -#endif /* BUILDING_LIBMEMCACHED */ -#endif /* !defined(LIBMEMCACHED_COMMON_H) && defined(BUILDING_LIBMEMCACHED) */ +#endif /* LIBMEMCACHED_COMMON_H */ diff --git a/libmemcached/memcached.h b/libmemcached/memcached.h index 4693c55d..c2602116 100644 --- a/libmemcached/memcached.h +++ b/libmemcached/memcached.h @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -25,6 +26,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -112,24 +114,35 @@ struct memcached_st { uint32_t number_of_replicas; }; +LIBMEMCACHED_API +memcached_return memcached_version(memcached_st *ptr); /* Public API */ + +LIBMEMCACHED_API const char * memcached_lib_version(void); +LIBMEMCACHED_API memcached_st *memcached_create(memcached_st *ptr); +LIBMEMCACHED_API void memcached_free(memcached_st *ptr); +LIBMEMCACHED_API memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr); +LIBMEMCACHED_API memcached_return memcached_delete(memcached_st *ptr, const char *key, size_t key_length, time_t expiration); +LIBMEMCACHED_API memcached_return memcached_increment(memcached_st *ptr, const char *key, size_t key_length, uint32_t offset, uint64_t *value); +LIBMEMCACHED_API memcached_return memcached_decrement(memcached_st *ptr, const char *key, size_t key_length, uint32_t offset, uint64_t *value); +LIBMEMCACHED_API memcached_return memcached_increment_with_initial(memcached_st *ptr, const char *key, size_t key_length, @@ -137,6 +150,7 @@ memcached_return memcached_increment_with_initial(memcached_st *ptr, uint64_t initial, time_t expiration, uint64_t *value); +LIBMEMCACHED_API memcached_return memcached_decrement_with_initial(memcached_st *ptr, const char *key, size_t key_length, @@ -144,102 +158,138 @@ memcached_return memcached_decrement_with_initial(memcached_st *ptr, uint64_t initial, time_t expiration, uint64_t *value); +LIBMEMCACHED_API void memcached_stat_free(memcached_st *, memcached_stat_st *); +LIBMEMCACHED_API memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return *error); +LIBMEMCACHED_API memcached_return memcached_stat_servername(memcached_stat_st *stat, char *args, char *hostname, unsigned int port); +LIBMEMCACHED_API memcached_return memcached_flush(memcached_st *ptr, time_t expiration); +LIBMEMCACHED_API memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity); +LIBMEMCACHED_API void memcached_quit(memcached_st *ptr); +LIBMEMCACHED_API char *memcached_strerror(memcached_st *ptr, memcached_return rc); +LIBMEMCACHED_API memcached_return memcached_behavior_set(memcached_st *ptr, memcached_behavior flag, uint64_t data); +LIBMEMCACHED_API uint64_t memcached_behavior_get(memcached_st *ptr, memcached_behavior flag); /* The two public hash bits */ +LIBMEMCACHED_API uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash hash_algorithm); +LIBMEMCACHED_API uint32_t memcached_generate_hash(memcached_st *ptr, const char *key, size_t key_length); +LIBMEMCACHED_API memcached_return memcached_flush_buffers(memcached_st *mem); /* Server Public functions */ +LIBMEMCACHED_API memcached_return memcached_server_add_udp(memcached_st *ptr, const char *hostname, unsigned int port); +LIBMEMCACHED_API memcached_return memcached_server_add_unix_socket(memcached_st *ptr, const char *filename); +LIBMEMCACHED_API memcached_return memcached_server_add(memcached_st *ptr, const char *hostname, unsigned int port); +LIBMEMCACHED_API memcached_return memcached_server_add_udp_with_weight(memcached_st *ptr, const char *hostname, unsigned int port, uint32_t weight); +LIBMEMCACHED_API memcached_return memcached_server_add_unix_socket_with_weight(memcached_st *ptr, const char *filename, uint32_t weight); +LIBMEMCACHED_API memcached_return memcached_server_add_with_weight(memcached_st *ptr, const char *hostname, unsigned int port, uint32_t weight); +LIBMEMCACHED_API void memcached_server_list_free(memcached_server_st *ptr); +LIBMEMCACHED_API memcached_return memcached_server_push(memcached_st *ptr, memcached_server_st *list); +LIBMEMCACHED_API memcached_server_st *memcached_server_list_append(memcached_server_st *ptr, const char *hostname, unsigned int port, memcached_return *error); +LIBMEMCACHED_API memcached_server_st *memcached_server_list_append_with_weight(memcached_server_st *ptr, const char *hostname, unsigned int port, uint32_t weight, memcached_return *error); +LIBMEMCACHED_API unsigned int memcached_server_list_count(memcached_server_st *ptr); +LIBMEMCACHED_API memcached_server_st *memcached_servers_parse(const char *server_strings); +LIBMEMCACHED_API char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *stat, const char *key, memcached_return *error); +LIBMEMCACHED_API char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *stat, memcached_return *error); +LIBMEMCACHED_API memcached_return memcached_delete_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, time_t expiration); +LIBMEMCACHED_API memcached_return memcached_fetch_execute(memcached_st *ptr, memcached_execute_function *callback, void *context, unsigned int number_of_callbacks); +LIBMEMCACHED_API memcached_return memcached_callback_set(memcached_st *ptr, memcached_callback flag, void *data); +LIBMEMCACHED_API void *memcached_callback_get(memcached_st *ptr, memcached_callback flag, memcached_return *error); +LIBMEMCACHED_API memcached_return memcached_dump(memcached_st *ptr, memcached_dump_func *function, void *context, uint32_t number_of_callbacks); +LIBMEMCACHED_API memcached_return memcached_set_memory_allocators(memcached_st *ptr, memcached_malloc_function mem_malloc, memcached_free_function mem_free, memcached_realloc_function mem_realloc, memcached_calloc_function mem_calloc); +LIBMEMCACHED_API void memcached_get_memory_allocators(memcached_st *ptr, memcached_malloc_function *mem_malloc, memcached_free_function *mem_free, memcached_realloc_function *mem_realloc, memcached_calloc_function *mem_calloc); +LIBMEMCACHED_API void *memcached_get_user_data(memcached_st *ptr); +LIBMEMCACHED_API void *memcached_set_user_data(memcached_st *ptr, void *data); +LIBMEMCACHED_API +memcached_return run_distribution(memcached_st *ptr); #ifdef __cplusplus } #endif -#include #endif /* __MEMCACHED_H__ */ diff --git a/libmemcached/memcached_constants.h b/libmemcached/memcached_constants.h index 5d0e31d0..3bb157c5 100644 --- a/libmemcached/memcached_constants.h +++ b/libmemcached/memcached_constants.h @@ -9,10 +9,6 @@ #ifndef __MEMCACHED_CONSTANTS_H__ #define __MEMCACHED_CONSTANTS_H__ -#ifdef __cplusplus -extern "C" { -#endif - /* Public defines */ #define MEMCACHED_DEFAULT_PORT 11211 #define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */ @@ -143,8 +139,4 @@ typedef enum { MEMCACHED_CONNECTION_UNIX_SOCKET } memcached_connection; -#ifdef __cplusplus -} -#endif - #endif /* __MEMCACHED_CONSTANTS_H__ */ diff --git a/libmemcached/memcached_get.h b/libmemcached/memcached_get.h index 5535f345..dba3c919 100644 --- a/libmemcached/memcached_get.h +++ b/libmemcached/memcached_get.h @@ -14,16 +14,19 @@ extern "C" { #endif /* Public defines */ +LIBMEMCACHED_API char *memcached_get(memcached_st *ptr, const char *key, size_t key_length, size_t *value_length, uint32_t *flags, memcached_return *error); +LIBMEMCACHED_API memcached_return memcached_mget(memcached_st *ptr, char **keys, size_t *key_length, unsigned int number_of_keys); +LIBMEMCACHED_API char *memcached_get_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, @@ -31,6 +34,7 @@ char *memcached_get_by_key(memcached_st *ptr, uint32_t *flags, memcached_return *error); +LIBMEMCACHED_API memcached_return memcached_mget_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, @@ -38,11 +42,13 @@ memcached_return memcached_mget_by_key(memcached_st *ptr, size_t *key_length, unsigned int number_of_keys); +LIBMEMCACHED_API char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, size_t *value_length, uint32_t *flags, memcached_return *error); +LIBMEMCACHED_API memcached_result_st *memcached_fetch_result(memcached_st *ptr, memcached_result_st *result, memcached_return *error); diff --git a/libmemcached/memcached_internal.h b/libmemcached/memcached_internal.h index 13a896f2..52fb4c1f 100644 --- a/libmemcached/memcached_internal.h +++ b/libmemcached/memcached_internal.h @@ -14,9 +14,13 @@ extern "C" { #endif +LIBMEMCACHED_LOCAL void libmemcached_free(memcached_st *ptr, void *mem); +LIBMEMCACHED_LOCAL void *libmemcached_malloc(memcached_st *ptr, const size_t size); +LIBMEMCACHED_LOCAL void *libmemcached_realloc(memcached_st *ptr, void *mem, const size_t size); +LIBMEMCACHED_LOCAL void *libmemcached_calloc(memcached_st *ptr, size_t nelem, size_t size); #ifdef __cplusplus diff --git a/libmemcached/memcached_parse.c b/libmemcached/memcached_parse.c index 62896dea..ca1a08e6 100644 --- a/libmemcached/memcached_parse.c +++ b/libmemcached/memcached_parse.c @@ -5,7 +5,6 @@ Frankly its too damn useful not to be here though. */ -#include "libmemcached/memcached.h" #include "common.h" memcached_server_st *memcached_servers_parse(const char *server_strings) diff --git a/libmemcached/memcached_pool.h b/libmemcached/memcached_pool.h index 90e4c5ad..7efe65e9 100644 --- a/libmemcached/memcached_pool.h +++ b/libmemcached/memcached_pool.h @@ -17,12 +17,17 @@ extern "C" { struct memcached_pool_st; typedef struct memcached_pool_st memcached_pool_st; + +LIBMEMCACHED_API memcached_pool_st *memcached_pool_create(memcached_st* mmc, uint32_t initial, uint32_t max); +LIBMEMCACHED_API memcached_st* memcached_pool_destroy(memcached_pool_st* pool); +LIBMEMCACHED_API memcached_st* memcached_pool_pop(memcached_pool_st* pool, bool block, memcached_return* rc); +LIBMEMCACHED_API memcached_return memcached_pool_push(memcached_pool_st* pool, memcached_st* mmc); diff --git a/libmemcached/memcached_result.h b/libmemcached/memcached_result.h index 155a7abb..b06ea2ce 100644 --- a/libmemcached/memcached_result.h +++ b/libmemcached/memcached_result.h @@ -26,8 +26,11 @@ struct memcached_result_st { }; /* Result Struct */ +LIBMEMCACHED_API void memcached_result_free(memcached_result_st *result); +LIBMEMCACHED_API void memcached_result_reset(memcached_result_st *ptr); +LIBMEMCACHED_API memcached_result_st *memcached_result_create(memcached_st *ptr, memcached_result_st *result); #define memcached_result_key_value(A) (A)->key @@ -37,11 +40,14 @@ memcached_result_st *memcached_result_create(memcached_st *ptr, #define memcached_result_value(A) memcached_string_value((A)->value) #define memcached_result_length(A) memcached_string_length((A)->value) #else +LIBMEMCACHED_API char *memcached_result_value(memcached_result_st *ptr); +LIBMEMCACHED_API size_t memcached_result_length(memcached_result_st *ptr); #endif #define memcached_result_flags(A) (A)->flags #define memcached_result_cas(A) (A)->cas +LIBMEMCACHED_API memcached_return memcached_result_set_value(memcached_result_st *ptr, char *value, size_t length); #define memcached_result_set_flags(A,B) (A)->flags=(B) #define memcached_result_set_expiration(A,B) (A)->expiration=(B) diff --git a/libmemcached/memcached_server.h b/libmemcached/memcached_server.h index 1d68f24e..fa79df8f 100644 --- a/libmemcached/memcached_server.h +++ b/libmemcached/memcached_server.h @@ -47,26 +47,37 @@ struct memcached_server_st { #define memcached_server_list(A) (A)->hosts #define memcached_server_response_count(A) (A)->cursor_active +LIBMEMCACHED_API memcached_return memcached_server_cursor(memcached_st *ptr, memcached_server_function *callback, void *context, unsigned int number_of_callbacks); +LIBMEMCACHED_API memcached_server_st *memcached_server_by_key(memcached_st *ptr, const char *key, size_t key_length, memcached_return *error); /* These should not currently be used by end users */ +/* TODO: Is the above comment valid? If so, how can we unit test these if they + * aren't exported. If not, we should remove the comment */ +LIBMEMCACHED_API memcached_server_st *memcached_server_create(memcached_st *memc, memcached_server_st *ptr); +LIBMEMCACHED_API memcached_server_st *memcached_server_create_with(memcached_st *memc, memcached_server_st *host, const char *hostname, unsigned int port, uint32_t weight, memcached_connection type); +LIBMEMCACHED_API void memcached_server_free(memcached_server_st *ptr); +LIBMEMCACHED_API memcached_server_st *memcached_server_clone(memcached_server_st *clone, memcached_server_st *ptr); +LIBMEMCACHED_API memcached_analysis_st *memcached_analyze(memcached_st *memc, memcached_stat_st *stat, memcached_return *error); +LIBMEMCACHED_API +memcached_return memcached_server_remove(memcached_server_st *st_ptr); #ifdef __cplusplus } diff --git a/libmemcached/memcached_storage.h b/libmemcached/memcached_storage.h index 25adc983..834401a6 100644 --- a/libmemcached/memcached_storage.h +++ b/libmemcached/memcached_storage.h @@ -9,33 +9,41 @@ #ifndef __MEMCACHED_STORAGE_H__ #define __MEMCACHED_STORAGE_H__ +#include "libmemcached/memcached_types.h" + #ifdef __cplusplus extern "C" { #endif /* All of the functions for adding data to the server */ +LIBMEMCACHED_API memcached_return memcached_set(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); +LIBMEMCACHED_API memcached_return memcached_add(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); +LIBMEMCACHED_API memcached_return memcached_replace(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); +LIBMEMCACHED_API memcached_return memcached_append(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); +LIBMEMCACHED_API memcached_return memcached_prepend(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); +LIBMEMCACHED_API memcached_return memcached_cas(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, @@ -43,6 +51,7 @@ memcached_return memcached_cas(memcached_st *ptr, uint32_t flags, uint64_t cas); +LIBMEMCACHED_API memcached_return memcached_set_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, @@ -50,6 +59,7 @@ memcached_return memcached_set_by_key(memcached_st *ptr, time_t expiration, uint32_t flags); +LIBMEMCACHED_API memcached_return memcached_add_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, @@ -57,6 +67,7 @@ memcached_return memcached_add_by_key(memcached_st *ptr, time_t expiration, uint32_t flags); +LIBMEMCACHED_API memcached_return memcached_replace_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, @@ -64,6 +75,7 @@ memcached_return memcached_replace_by_key(memcached_st *ptr, time_t expiration, uint32_t flags); +LIBMEMCACHED_API memcached_return memcached_prepend_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, @@ -71,6 +83,7 @@ memcached_return memcached_prepend_by_key(memcached_st *ptr, time_t expiration, uint32_t flags); +LIBMEMCACHED_API memcached_return memcached_append_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, @@ -78,6 +91,7 @@ memcached_return memcached_append_by_key(memcached_st *ptr, time_t expiration, uint32_t flags); +LIBMEMCACHED_API memcached_return memcached_cas_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, diff --git a/libmemcached/memcached_string.h b/libmemcached/memcached_string.h index 58d109d2..8f347cd8 100644 --- a/libmemcached/memcached_string.h +++ b/libmemcached/memcached_string.h @@ -27,16 +27,23 @@ struct memcached_string_st { #define memcached_string_size(A) (A)->current_size #define memcached_string_value(A) (A)->string +LIBMEMCACHED_API memcached_string_st *memcached_string_create(memcached_st *ptr, memcached_string_st *string, size_t initial_size); +LIBMEMCACHED_API memcached_return memcached_string_check(memcached_string_st *string, size_t need); +LIBMEMCACHED_API char *memcached_string_c_copy(memcached_string_st *string); +LIBMEMCACHED_API memcached_return memcached_string_append_character(memcached_string_st *string, char character); +LIBMEMCACHED_API memcached_return memcached_string_append(memcached_string_st *string, char *value, size_t length); +LIBMEMCACHED_API memcached_return memcached_string_reset(memcached_string_st *string); +LIBMEMCACHED_API void memcached_string_free(memcached_string_st *string); #ifdef __cplusplus diff --git a/libmemcached/memcached_util.h b/libmemcached/memcached_util.h index ec8afa80..65732c87 100644 --- a/libmemcached/memcached_util.h +++ b/libmemcached/memcached_util.h @@ -10,14 +10,6 @@ #ifndef MEMCACHED_UTIL_H #define MEMCACHED_UTIL_H -#ifdef __cplusplus -extern "C" { -#endif - #include -#ifdef __cplusplus -} -#endif - #endif /* MEMCACHED_UTIL_H */ diff --git a/libmemcachedutil/memcached_pool.c b/libmemcachedutil/memcached_pool.c index 5c122eb6..708b7ce2 100644 --- a/libmemcachedutil/memcached_pool.c +++ b/libmemcachedutil/memcached_pool.c @@ -1,4 +1,4 @@ -#include "config.h" +#include "libmemcached/common.h" #include "libmemcached/memcached_pool.h" #include diff --git a/m4/protocol_binary.m4 b/m4/protocol_binary.m4 index d31bcb04..2c654e4a 100644 --- a/m4/protocol_binary.m4 +++ b/m4/protocol_binary.m4 @@ -4,7 +4,7 @@ dnl --------------------------------------------------------------------------- AC_DEFUN([PROTOCOL_BINARY_TEST], [AC_LANG_PUSH([C]) save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -I${srcdir}" + CFLAGS="$CFLAGS -I${srcdir} -DBUILDING_LIBMEMCACHED" AC_RUN_IFELSE([ AC_LANG_PROGRAM([[ #include "libmemcached/memcached/protocol_binary.h" diff --git a/tests/function.c b/tests/function.c index 128d9f8f..b806c883 100644 --- a/tests/function.c +++ b/tests/function.c @@ -2,13 +2,6 @@ Sample test application. */ -/* TODO: I'm torn about this. The file seems like a functional test, which - * should use only the exported API of the library. On the other hand, - * something needs to test some of the internals - so we're going to turn on - * internal symbols here... but I'd like to come up with another way to test - * the internals - */ -#define BUILDING_LIBMEMCACHED 1 #include "libmemcached/common.h" #include @@ -3593,8 +3586,8 @@ static test_return connection_pool_test(memcached_st *memc) static test_return replication_set_test(memcached_st *memc) { memcached_return rc; - memcached_st *clone= memcached_clone(NULL, memc); - memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0); + memcached_st *memc_clone= memcached_clone(NULL, memc); + memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0); rc= memcached_set(memc, "bubba", 5, "0", 1, 0, 0); assert(rc == MEMCACHED_SUCCESS); @@ -3625,14 +3618,14 @@ static test_return replication_set_test(memcached_st *memc) char key[2]= { [0]= (char)x }; size_t len; uint32_t flags; - char *val= memcached_get_by_key(clone, key, 1, "bubba", 5, + char *val= memcached_get_by_key(memc_clone, key, 1, "bubba", 5, &len, &flags, &rc); assert(rc == MEMCACHED_SUCCESS); assert(val != NULL); free(val); } - memcached_free(clone); + memcached_free(memc_clone); return TEST_SUCCESS; } @@ -3648,22 +3641,22 @@ static test_return replication_get_test(memcached_st *memc) */ for (uint32_t host= 0; host < memc->number_of_hosts; ++host) { - memcached_st *clone= memcached_clone(NULL, memc); - clone->hosts[host].port= 0; + memcached_st *memc_clone= memcached_clone(NULL, memc); + memc_clone->hosts[host].port= 0; for (int x= 'a'; x <= 'z'; ++x) { char key[2]= { [0]= (char)x }; size_t len; uint32_t flags; - char *val= memcached_get_by_key(clone, key, 1, "bubba", 5, + char *val= memcached_get_by_key(memc_clone, key, 1, "bubba", 5, &len, &flags, &rc); assert(rc == MEMCACHED_SUCCESS); assert(val != NULL); free(val); } - memcached_free(clone); + memcached_free(memc_clone); } return TEST_SUCCESS; @@ -3672,8 +3665,8 @@ static test_return replication_get_test(memcached_st *memc) static test_return replication_mget_test(memcached_st *memc) { memcached_return rc; - memcached_st *clone= memcached_clone(NULL, memc); - memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0); + memcached_st *memc_clone= memcached_clone(NULL, memc); + memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0); char *keys[]= { "bubba", "key1", "key2", "key3" }; size_t len[]= { 5, 4, 4, 4 }; @@ -3705,7 +3698,7 @@ static test_return replication_mget_test(memcached_st *memc) * This is to verify correct behavior in the library */ memcached_result_st result_obj; - for (uint32_t host= 0; host < clone->number_of_hosts; host++) + for (uint32_t host= 0; host < memc_clone->number_of_hosts; host++) { memcached_st *new_clone= memcached_clone(NULL, memc); new_clone->hosts[host].port= 0; @@ -3738,7 +3731,7 @@ static test_return replication_mget_test(memcached_st *memc) static test_return replication_delete_test(memcached_st *memc) { memcached_return rc; - memcached_st *clone= memcached_clone(NULL, memc); + memcached_st *memc_clone= memcached_clone(NULL, memc); /* Delete the items from all of the servers except 1 */ uint64_t repl= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS); @@ -3761,26 +3754,26 @@ static test_return replication_delete_test(memcached_st *memc) uint32_t hash= memcached_generate_hash(memc, keys[0], len[0]); for (uint32_t x= 0; x < (repl + 1); ++x) { - clone->hosts[hash].port= 0; - if (++hash == clone->number_of_hosts) + memc_clone->hosts[hash].port= 0; + if (++hash == memc_clone->number_of_hosts) hash= 0; } memcached_result_st result_obj; - for (uint32_t host= 0; host < clone->number_of_hosts; ++host) + for (uint32_t host= 0; host < memc_clone->number_of_hosts; ++host) { for (int x= 'a'; x <= 'z'; ++x) { char key[2]= { [0]= (char)x }; - rc= memcached_mget_by_key(clone, key, 1, keys, len, 4); + rc= memcached_mget_by_key(memc_clone, key, 1, keys, len, 4); assert(rc == MEMCACHED_SUCCESS); - memcached_result_st *results= memcached_result_create(clone, &result_obj); + memcached_result_st *results= memcached_result_create(memc_clone, &result_obj); assert(results); int hits= 0; - while ((results= memcached_fetch_result(clone, &result_obj, &rc)) != NULL) + while ((results= memcached_fetch_result(memc_clone, &result_obj, &rc)) != NULL) { ++hits; } @@ -3788,7 +3781,7 @@ static test_return replication_delete_test(memcached_st *memc) memcached_result_free(&result_obj); } } - memcached_free(clone); + memcached_free(memc_clone); return TEST_SUCCESS; }