From: Date: Fri, 4 Apr 2008 06:58:50 +0000 (-0700) Subject: Fixing likely and sort test. X-Git-Tag: _20~1^2~29 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=52f68c3a89697bf2169885bdeb3306fe84b11529;p=m6w6%2Flibmemcached Fixing likely and sort test. --- diff --git a/ChangeLog b/ChangeLog index 9eadd965..3d363ffa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ 0.19 + * Logic fix in branch prediction (thanks Jay!) * Read through cached support. * Fixed for cas by key operation. * Fix for memcached_server_st list structures to have correct count. diff --git a/libmemcached/common.h b/libmemcached/common.h index 288f421d..7e21afff 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -41,18 +41,17 @@ #include #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) -#define __builtin_expect(x, expected_value) (x) - -#define likely(x) __builtin_expect((x),1) -#define unlikely(x) __builtin_expect((x),0) - -#else #define likely(x) if((x)) #define unlikely(x) if((x)) +#else + +#define likely(x) if(__builtin_expect(!!(x), 1)) +#define unlikely(x) if(__builtin_expect((x), 0)) #endif + #ifdef HAVE_DTRACE #define _DTRACE_VERSION 1 #else diff --git a/tests/function.c b/tests/function.c index 38de6679..a306a4a4 100644 --- a/tests/function.c +++ b/tests/function.c @@ -65,8 +65,9 @@ uint32_t test_ports[TEST_PORT_COUNT]; memcached_return server_display_function(memcached_st *ptr, memcached_server_st *server, void *context) { /* Do Nothing */ - uint32_t *bigger= (uint32_t *)context; - assert(*bigger <= server->port); + uint32_t bigger= *((uint32_t *)(context)); + assert(bigger <= server->port); + *((uint32_t *)(context))= bigger; return MEMCACHED_SUCCESS; }