From 7275dcef35d14ff5f82f3520fe6e6e0766bc13b5 Mon Sep 17 00:00:00 2001 From: "sasha@mysql.sashanet.com" <> Date: Sat, 26 Jan 2002 22:26:24 -0700 Subject: misc replication bugfixes including some needed modifications in IO_CACHE likely() and unlikely() branch prediction compiler hint macros clean-up of comments --- include/my_global.h | 16 ++++++++++++++++ include/my_sys.h | 5 +++-- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/my_global.h b/include/my_global.h index 7277bdcd715..40e70c521eb 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -51,6 +51,22 @@ #endif #endif /* _WIN32... */ +/* The macros below are borrowed from include/linux/compiler.h in the + Linux kernel. Use them to indicate the likelyhood of the truthfulness + of a condition. This serves two purposes - newer versions of gcc will be + able to optimize for branch predication, which could yield siginficant + performance gains in frequently executed sections of the code, and the + other reason to use them is for documentation +*/ + +#if __GNUC__ == 2 && __GNUC_MINOR__ < 96 +#define __builtin_expect(x, expected_value) (x) +#endif + +#define likely(x) __builtin_expect((x),1) +#define unlikely(x) __builtin_expect((x),0) + + /* Fix problem with S_ISLNK() on Linux */ #if defined(HAVE_LINUXTHREADS) #undef _GNU_SOURCE diff --git a/include/my_sys.h b/include/my_sys.h index 1d7c0b7ddb1..61f93d665cd 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -436,8 +436,9 @@ typedef int (*qsort2_cmp)(const void *, const void *, const void *); #define my_b_tell(info) ((info)->pos_in_file + \ (uint) (*(info)->current_pos - (info)->request_pos)) -#define my_b_append_tell(info) ((info)->end_of_file + \ - (uint) ((info)->write_pos - (info)->write_buffer)) + +/* tell write offset in the SEQ_APPEND cache */ +my_off_t my_b_append_tell(IO_CACHE* info); #define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \ *(info)->current_pos) -- cgit v1.2.1