From 52f68c3a89697bf2169885bdeb3306fe84b11529 Mon Sep 17 00:00:00 2001 From: Date: Thu, 3 Apr 2008 23:58:50 -0700 Subject: [PATCH] Fixing likely and sort test. --- ChangeLog | 1 + libmemcached/common.h | 11 +++++------ tests/function.c | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) 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; } -- 2.30.2