X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fcommon.h;h=99d4ce78f103e875a92c655b34d312730c2eaf5c;hb=75bbebb7976acf3cbfdf1525599180cf49e67f56;hp=d8371d18dfa69d89adbbd5561ea198472bdfd0ba;hpb=daae2d944f6f7763ec6d69d0016d10efb5fdc0ed;p=m6w6%2Flibmemcached diff --git a/libmemcached/common.h b/libmemcached/common.h index d8371d18..99d4ce78 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -48,6 +48,7 @@ #include "libmemcached/memcached_internal.h" #include "libmemcached/libmemcached_probes.h" #include "libmemcached/memcached/protocol_binary.h" +#include "libmemcached/byteorder.h" /* string value */ struct memcached_continuum_item_st { @@ -63,8 +64,8 @@ struct memcached_continuum_item_st { #else -#define likely(x) if(__builtin_expect(!!(x), 1)) -#define unlikely(x) if(__builtin_expect((x), 0)) +#define likely(x) if(__builtin_expect((x) != 0, 1)) +#define unlikely(x) if(__builtin_expect((x) != 0, 0)) #endif @@ -92,7 +93,8 @@ typedef enum { MEM_HASH_WITH_PREFIX_KEY= (1 << 13), MEM_NOREPLY= (1 << 14), MEM_USE_UDP= (1 << 15), - MEM_AUTO_EJECT_HOSTS= (1 << 16) + MEM_AUTO_EJECT_HOSTS= (1 << 16), + MEM_RANDOMIZE_REPLICA_READ= (1 << 17) } memcached_flags; /* Hashing algo */ @@ -135,28 +137,22 @@ 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 memcached_key_test(const char * const *keys, + const size_t *key_length, + size_t number_of_keys); LIBMEMCACHED_LOCAL uint32_t generate_hash(memcached_st *ptr, const char *key, size_t key_length); -#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, +static inline memcached_return 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) @@ -164,7 +160,7 @@ static inline memcached_return memcached_validate_key_length(size_t key_length, } else { - unlikely (key_length >= MEMCACHED_MAX_KEY) + unlikely (key_length >= MEMCACHED_MAX_KEY) return MEMCACHED_BAD_KEY_PROVIDED; }