X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fcommon.h;h=c7b84c94760d66ba97bb86cc833234abfc64e84e;hb=c2c9d14f605d54ec6e7d24551fdfa2ceee7d7258;hp=d0a4ab4ce69d6cfc7717e70ceb34090c27b4a523;hpb=30e386cd241ac56fd9205d12c143761475307705;p=awesomized%2Flibmemcached diff --git a/libmemcached/common.h b/libmemcached/common.h index d0a4ab4c..c7b84c94 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -42,71 +42,153 @@ #pragma once -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef TIME_WITH_SYS_TIME -# include -# include +#include + +#ifdef __cplusplus +# include +# include +# include +# include +# include +# include +# include +# include #else -# ifdef HAVE_SYS_TIME_H -# include -# else +# ifdef HAVE_STDDEF_H +# include +# endif +# ifdef HAVE_STDLIB_H +# include +# endif +# ifdef HAVE_STDLIB_H +# include +# endif +# include +# ifdef HAVE_TIME_H # include # endif +# ifdef HAVE_ERRNO_H +# include +# endif +# ifdef HAVE_LIMITS_H +# include +# endif #endif -/* Define this here, which will turn on the visibilty controls while we're - * building libmemcached. - */ -#define BUILDING_LIBMEMCACHED 1 +#ifdef HAVE_SYS_UN_H +# include +#endif +#ifdef HAVE_SYS_TIME_H +# include +#endif -#include +#ifdef HAVE_FCNTL_H +# include +#endif + +#ifdef HAVE_SYS_TYPES_H +# include +#endif + +#ifdef HAVE_UNISTD_H +# include +#endif + +#ifdef HAVE_SYS_SOCKET_H +# include +#endif + +#ifdef HAVE_STRINGS_H +# include +#endif + +#ifdef HAVE_DLFCN_H +# include +#endif + +#if defined(WIN32) || defined(__MINGW32__) +# include "libmemcached/windows.hpp" +#endif + +#include #include #include -#include +typedef struct memcached_st Memcached; + +#ifdef __cplusplus +# include "libmemcached/instance.hpp" +#endif +#include -typedef struct memcached_server_st * memcached_server_write_instance_st; +#ifdef HAVE_POLL_H +# include +#else +# include "libmemcached/poll.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif typedef memcached_return_t (*memcached_server_execute_fn)(memcached_st *ptr, memcached_server_write_instance_st server, void *context); -LIBMEMCACHED_LOCAL -memcached_server_write_instance_st memcached_server_instance_fetch(memcached_st *ptr, uint32_t server_key); +#ifdef __cplusplus +} // extern "C" +#endif + + +#ifdef __cplusplus +org::libmemcached::Instance* memcached_instance_fetch(memcached_st *ptr, uint32_t server_key); +#endif -LIBMEMCACHED_LOCAL memcached_return_t memcached_server_execute(memcached_st *ptr, memcached_server_execute_fn callback, void *context); - - /* These are private not to be installed headers */ +#include +#include #include -#include +#ifdef __cplusplus +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif #include #include #include -#include #include #include +#ifdef __cplusplus #include -#include +#endif +#include +#include -/* string value */ -struct memcached_continuum_item_st -{ - uint32_t index; - uint32_t value; -}; +#ifdef __cplusplus +#include +#include +#include +#include +#include +#include +#include +#endif + +#include #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) @@ -128,75 +210,28 @@ struct memcached_continuum_item_st extern "C" { #endif -LIBMEMCACHED_LOCAL -memcached_return_t memcached_connect(memcached_server_write_instance_st ptr); - -LIBMEMCACHED_LOCAL memcached_return_t run_distribution(memcached_st *ptr); -#define memcached_server_response_increment(A) (A)->cursor_active++ -#define memcached_server_response_decrement(A) (A)->cursor_active-- -#define memcached_server_response_reset(A) (A)->cursor_active=0 - -LIBMEMCACHED_LOCAL -void set_last_disconnected_host(memcached_server_write_instance_st ptr); - -LIBMEMCACHED_LOCAL -memcached_return_t memcached_key_test(const char * const *keys, - const size_t *key_length, - size_t number_of_keys); - -LIBMEMCACHED_LOCAL -memcached_return_t memcached_purge(memcached_server_write_instance_st ptr); - -LIBMEMCACHED_LOCAL -memcached_server_st *memcached_server_create_with(const memcached_st *memc, - memcached_server_write_instance_st host, - const char *hostname, - in_port_t port, - uint32_t weight, - memcached_connection_t type); - - -static inline memcached_return_t memcached_validate_key_length(size_t key_length, bool binary) -{ - unlikely (key_length == 0) - return MEMCACHED_BAD_KEY_PROVIDED; - - if (binary) - { - unlikely (key_length > 0xffff) - return MEMCACHED_BAD_KEY_PROVIDED; - } - else - { - unlikely (key_length >= MEMCACHED_MAX_KEY) - return MEMCACHED_BAD_KEY_PROVIDED; - } - - return MEMCACHED_SUCCESS; -} - -static inline void libmemcached_free(const memcached_st *ptr, void *mem) +#ifdef __cplusplus +static inline void memcached_server_response_increment(org::libmemcached::Instance* instance) { - ptr->allocators.free(ptr, mem, ptr->allocators.context); + instance->events(POLLIN); + instance->cursor_active_++; } +#endif -static inline void *libmemcached_malloc(const memcached_st *ptr, const size_t size) -{ - return ptr->allocators.malloc(ptr, size, ptr->allocators.context); -} +#define memcached_server_response_decrement(A) (A)->cursor_active_-- +#define memcached_server_response_reset(A) (A)->cursor_active_=0 -static inline void *libmemcached_realloc(const memcached_st *ptr, void *mem, const size_t size) -{ - return ptr->allocators.realloc(ptr, mem, size, ptr->allocators.context); -} +#define memcached_instance_response_increment(A) (A)->cursor_active_++ +#define memcached_instance_response_decrement(A) (A)->cursor_active_-- +#define memcached_instance_response_reset(A) (A)->cursor_active_=0 -static inline void *libmemcached_calloc(const memcached_st *ptr, size_t nelem, size_t size) -{ - return ptr->allocators.calloc(ptr, nelem, size, ptr->allocators.context); +#ifdef __cplusplus } +#endif #ifdef __cplusplus -} +bool memcached_purge(org::libmemcached::Instance*); +org::libmemcached::Instance* memcached_instance_by_position(const memcached_st *ptr, uint32_t server_key); #endif