diff --git a/include/waiting_threads.h b/include/waiting_threads.h index 41828164d05..a5c22bbcbf1 100644 --- a/include/waiting_threads.h +++ b/include/waiting_threads.h @@ -30,13 +30,11 @@ 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(1) struct st_wt_resource_id { ulonglong value; WT_RESOURCE_TYPE *type; }; -#pragma pack() +#define sizeof_WT_RESOURCE_ID (sizeof(ulonglong)+sizeof(void*)) #define WT_WAIT_STATS 24 #define WT_CYCLE_STATS 32 diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c index 008abef0c8b..96ae3f338ab 100644 --- a/mysys/lf_hash.c +++ b/mysys/lf_hash.c @@ -281,8 +281,9 @@ static inline const uchar* hash_key(const LF_HASH *hash, } /* - compute the hash key value from the raw key. - note, that the hash value is limited to 2^31, because we need one + Compute the hash key value from the raw key. + + @note, that the hash value is limited to 2^31, because we need one bit to distinguish between normal and dummy nodes. */ static inline uint calc_hash(LF_HASH *hash, const uchar *key, uint keylen) @@ -300,7 +301,7 @@ static int initialize_bucket(LF_HASH *, LF_SLIST * volatile*, uint, LF_PINS *); /* Initializes lf_hash, the arguments are compatible with hash_init - @@note element_size sets both the size of allocated memory block for + @note element_size sets both the size of allocated memory block for lf_alloc and a size of memcpy'ed block size in lf_hash_insert. Typically they are the same, indeed. But LF_HASH::element_size can be decreased after lf_hash_init, and then lf_alloc will allocate larger block that diff --git a/mysys/waiting_threads.c b/mysys/waiting_threads.c index ef19018831b..edabc25ee51 100644 --- a/mysys/waiting_threads.c +++ b/mysys/waiting_threads.c @@ -280,7 +280,7 @@ void wt_init() DBUG_ENTER("wt_init"); lf_hash_init(&reshash, sizeof(WT_RESOURCE), LF_HASH_UNIQUE, 0, - sizeof(struct st_wt_resource_id), 0, 0); + sizeof_WT_RESOURCE_ID, 0, 0); reshash.alloc.constructor= wt_resource_init; reshash.alloc.destructor= wt_resource_destroy; /* @@ -396,9 +396,7 @@ 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)); + return memcmp(a, b, sizeof_WT_RESOURCE_ID); } /** @@ -657,7 +655,7 @@ static int unlock_lock_and_free_resource(WT_THD *thd, WT_RESOURCE *rc) /* XXX if (rc->id.type->make_key) key= rc->id.type->make_key(&rc->id, &keylen); else */ { key= &rc->id; - keylen= sizeof(rc->id); + keylen= sizeof_WT_RESOURCE_ID; } /* @@ -751,7 +749,7 @@ int wt_thd_will_wait_for(WT_THD *thd, WT_THD *blocker, WT_RESOURCE_ID *resid) /* XXX if (restype->make_key) key= restype->make_key(resid, &keylen); else */ { key= resid; - keylen= sizeof(*resid); + keylen= sizeof_WT_RESOURCE_ID; } DBUG_PRINT("wt", ("first blocker"));