Commit 639baee6 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: remove LF_REQUIRE_PINS, use compile_time_assert() instead of reimplementing it

parent 31a1934c
...@@ -131,25 +131,12 @@ typedef struct { ...@@ -131,25 +131,12 @@ typedef struct {
#define lf_rwunlock_by_pins(PINS) \ #define lf_rwunlock_by_pins(PINS) \
my_atomic_rwlock_wrunlock(&(PINS)->pinbox->pinarray.lock) my_atomic_rwlock_wrunlock(&(PINS)->pinbox->pinarray.lock)
/* /* compile-time assert to make sure we have enough pins. */
compile-time assert, to require "no less than N" pins
it's enough if it'll fail on at least one compiler, so
we'll enable it on GCC only, which supports zero-length arrays.
*/
#if defined(__GNUC__) && defined(MY_LF_EXTRA_DEBUG)
#define LF_REQUIRE_PINS(N) \
static const char require_pins[LF_PINBOX_PINS-N] \
__attribute__ ((unused)); \
static const int LF_NUM_PINS_IN_THIS_FILE= N;
#define _lf_pin(PINS, PIN, ADDR) \ #define _lf_pin(PINS, PIN, ADDR) \
( \ do { \
assert(PIN < LF_NUM_PINS_IN_THIS_FILE), \ compile_time_assert(PIN < LF_PINBOX_PINS); \
my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)) \ my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)); \
) } while(0)
#else
#define LF_REQUIRE_PINS(N)
#define _lf_pin(PINS, PIN, ADDR) my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR))
#endif
#define _lf_unpin(PINS, PIN) _lf_pin(PINS, PIN, NULL) #define _lf_unpin(PINS, PIN) _lf_pin(PINS, PIN, NULL)
#define lf_pin(PINS, PIN, ADDR) \ #define lf_pin(PINS, PIN, ADDR) \
......
...@@ -412,8 +412,6 @@ found: ...@@ -412,8 +412,6 @@ found:
/* lock-free memory allocator for fixed-size objects */ /* lock-free memory allocator for fixed-size objects */
LF_REQUIRE_PINS(1)
/* /*
callback for _lf_pinbox_real_free to free a list of unpinned objects - callback for _lf_pinbox_real_free to free a list of unpinned objects -
add it back to the allocator stack add it back to the allocator stack
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include <my_bit.h> #include <my_bit.h>
#include <lf.h> #include <lf.h>
LF_REQUIRE_PINS(3)
/* An element of the list */ /* An element of the list */
typedef struct { typedef struct {
intptr volatile link; /* a pointer to the next element in a listand a flag */ intptr volatile link; /* a pointer to the next element in a listand a flag */
......
...@@ -604,8 +604,6 @@ static int deadlock_search(struct deadlock_arg *arg, WT_THD *blocker, ...@@ -604,8 +604,6 @@ static int deadlock_search(struct deadlock_arg *arg, WT_THD *blocker,
DBUG_PRINT("wt", ("enter: thd=%s, blocker=%s, depth=%u", DBUG_PRINT("wt", ("enter: thd=%s, blocker=%s, depth=%u",
arg->thd->name, blocker->name, depth)); arg->thd->name, blocker->name, depth));
LF_REQUIRE_PINS(1);
arg->last_locked_rc= 0; arg->last_locked_rc= 0;
if (depth > arg->max_depth) if (depth > arg->max_depth)
...@@ -923,8 +921,6 @@ int wt_thd_will_wait_for(WT_THD *thd, WT_THD *blocker, ...@@ -923,8 +921,6 @@ int wt_thd_will_wait_for(WT_THD *thd, WT_THD *blocker,
WT_RESOURCE *rc; WT_RESOURCE *rc;
DBUG_ENTER("wt_thd_will_wait_for"); DBUG_ENTER("wt_thd_will_wait_for");
LF_REQUIRE_PINS(3);
DBUG_PRINT("wt", ("enter: thd=%s, blocker=%s, resid=%lu", DBUG_PRINT("wt", ("enter: thd=%s, blocker=%s, resid=%lu",
thd->name, blocker->name, (ulong)resid->value)); thd->name, blocker->name, (ulong)resid->value));
......
...@@ -211,8 +211,6 @@ static enum lockman_getlock_result getlock_result[10][10]= ...@@ -211,8 +211,6 @@ static enum lockman_getlock_result getlock_result[10][10]=
#undef A #undef A
#undef x #undef x
LF_REQUIRE_PINS(4)
typedef struct lockman_lock { typedef struct lockman_lock {
uint64 resource; uint64 resource;
struct lockman_lock *lonext; struct lockman_lock *lonext;
......
...@@ -577,7 +577,6 @@ int trnman_can_read_from(TRN *trn, TrID trid) ...@@ -577,7 +577,6 @@ int trnman_can_read_from(TRN *trn, TrID trid)
{ {
TRN **found; TRN **found;
my_bool can; my_bool can;
LF_REQUIRE_PINS(3);
if (trid < trn->min_read_from) if (trid < trn->min_read_from)
return 1; /* Row is visible by all transactions in the system */ return 1; /* Row is visible by all transactions in the system */
...@@ -618,7 +617,6 @@ int trnman_can_read_from(TRN *trn, TrID trid) ...@@ -618,7 +617,6 @@ int trnman_can_read_from(TRN *trn, TrID trid)
TRN *trnman_trid_to_trn(TRN *trn, TrID trid) TRN *trnman_trid_to_trn(TRN *trn, TrID trid)
{ {
TRN **found; TRN **found;
LF_REQUIRE_PINS(3);
if (trid < trn->min_read_from) if (trid < trn->min_read_from)
return 0; /* it's committed eons ago */ return 0; /* it's committed eons ago */
......
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