Commit 43e47b84 authored by Sergei Golubchik's avatar Sergei Golubchik

don't use #pragma pack

include/waiting_threads.h:
  don't #pragma pack
mysys/lf_hash.c:
  typo in a comment
mysys/waiting_threads.c:
  use the size of data, not the size of (possibly padded) structure
parent c962f5b4
...@@ -30,13 +30,11 @@ typedef struct st_wt_resource_type { ...@@ -30,13 +30,11 @@ typedef struct st_wt_resource_type {
const void *(*make_key)(WT_RESOURCE_ID *id, uint *len); const void *(*make_key)(WT_RESOURCE_ID *id, uint *len);
} WT_RESOURCE_TYPE; } WT_RESOURCE_TYPE;
/* we want to compare this struct with memcmp, make it packed */
#pragma pack(1)
struct st_wt_resource_id { struct st_wt_resource_id {
ulonglong value; ulonglong value;
WT_RESOURCE_TYPE *type; WT_RESOURCE_TYPE *type;
}; };
#pragma pack() #define sizeof_WT_RESOURCE_ID (sizeof(ulonglong)+sizeof(void*))
#define WT_WAIT_STATS 24 #define WT_WAIT_STATS 24
#define WT_CYCLE_STATS 32 #define WT_CYCLE_STATS 32
......
...@@ -281,8 +281,9 @@ static inline const uchar* hash_key(const LF_HASH *hash, ...@@ -281,8 +281,9 @@ static inline const uchar* hash_key(const LF_HASH *hash,
} }
/* /*
compute the hash key value from the raw key. Compute the hash key value from the raw key.
note, that the hash value is limited to 2^31, because we need one
@note, that the hash value is limited to 2^31, because we need one
bit to distinguish between normal and dummy nodes. bit to distinguish between normal and dummy nodes.
*/ */
static inline uint calc_hash(LF_HASH *hash, const uchar *key, uint keylen) 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 *); ...@@ -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 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 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 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 after lf_hash_init, and then lf_alloc will allocate larger block that
......
...@@ -280,7 +280,7 @@ void wt_init() ...@@ -280,7 +280,7 @@ void wt_init()
DBUG_ENTER("wt_init"); DBUG_ENTER("wt_init");
lf_hash_init(&reshash, sizeof(WT_RESOURCE), LF_HASH_UNIQUE, 0, 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.constructor= wt_resource_init;
reshash.alloc.destructor= wt_resource_destroy; reshash.alloc.destructor= wt_resource_destroy;
/* /*
...@@ -396,9 +396,7 @@ void wt_thd_destroy(WT_THD *thd) ...@@ -396,9 +396,7 @@ void wt_thd_destroy(WT_THD *thd)
*/ */
int wt_resource_id_memcmp(void *a, void *b) int wt_resource_id_memcmp(void *a, void *b)
{ {
/* assert that the structure is not padded with random bytes */ return memcmp(a, b, sizeof_WT_RESOURCE_ID);
compile_time_assert(sizeof(WT_RESOURCE_ID)==sizeof(ulonglong)+sizeof(void*));
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) ...@@ -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 */ /* XXX if (rc->id.type->make_key) key= rc->id.type->make_key(&rc->id, &keylen); else */
{ {
key= &rc->id; 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) ...@@ -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 */ /* XXX if (restype->make_key) key= restype->make_key(resid, &keylen); else */
{ {
key= resid; key= resid;
keylen= sizeof(*resid); keylen= sizeof_WT_RESOURCE_ID;
} }
DBUG_PRINT("wt", ("first blocker")); DBUG_PRINT("wt", ("first blocker"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment