From a58d20053dbd9192905bb4525f089a32f16b88f5 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 21 Oct 2008 20:10:49 +0200 Subject: [PATCH] win32: compilation failures, maria.test failure include/my_global.h: enable compile_time_assert for all compilers include/waiting_threads.h: 1. don't #extern "C" system includes, they don't like it. 2. remove any padding from WT_RESOURCE_ID structure - we want to compare it with memcmp mysys/waiting_threads.c: assert that WT_RESOURCE_ID can be compared with memcmp and has no random padding bytes --- include/my_global.h | 2 +- include/waiting_threads.h | 9 ++++++--- mysys/waiting_threads.c | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/my_global.h b/include/my_global.h index 6970fa5a0b6..c350982fbb0 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -478,7 +478,7 @@ C_MODE_END #include /* an assert that works at compile-time. only for constant expression */ -#ifndef __GNUC__ +#ifdef _some_old_compiler_that_does_not_understand_the_construct_below_ #define compile_time_assert(X) do { } while(0) #else #define compile_time_assert(X) \ diff --git a/include/waiting_threads.h b/include/waiting_threads.h index 0df17a47c61..322b5972ec0 100644 --- a/include/waiting_threads.h +++ b/include/waiting_threads.h @@ -19,10 +19,10 @@ #include #include -C_MODE_START - #include +C_MODE_START + typedef struct st_wt_resource_id WT_RESOURCE_ID; typedef struct st_wt_resource_type { @@ -30,10 +30,13 @@ typedef struct st_wt_resource_type { const void *(*make_key)(WT_RESOURCE_ID *id, uint *len); } WT_RESOURCE_TYPE; +/* we want to compare this struct with memcmp, make it packed */ +#pragma pack(push,1) struct st_wt_resource_id { - WT_RESOURCE_TYPE *type; ulonglong value; + WT_RESOURCE_TYPE *type; }; +#pragma pack(pop) #define WT_WAIT_STATS 24 #define WT_CYCLE_STATS 32 diff --git a/mysys/waiting_threads.c b/mysys/waiting_threads.c index 255317ea4cc..489be6edbad 100644 --- a/mysys/waiting_threads.c +++ b/mysys/waiting_threads.c @@ -347,6 +347,8 @@ void wt_thd_destroy(WT_THD *thd) */ int wt_resource_id_memcmp(void *a, void *b) { + /* assert that the structure is not padded with random bytes */ + compile_time_assert(sizeof(WT_RESOURCE_ID)==sizeof(ulonglong)+sizeof(void*)); return memcmp(a, b, sizeof(WT_RESOURCE_ID)); }