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 {
#define lf_rwunlock_by_pins(PINS) \
my_atomic_rwlock_wrunlock(&(PINS)->pinbox->pinarray.lock)
/*
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;
/* compile-time assert to make sure we have enough pins. */
#define _lf_pin(PINS, PIN, ADDR) \
( \
assert(PIN < LF_NUM_PINS_IN_THIS_FILE), \
my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)) \
)
#else
#define LF_REQUIRE_PINS(N)
#define _lf_pin(PINS, PIN, ADDR) my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR))
#endif
do { \
compile_time_assert(PIN < LF_PINBOX_PINS); \
my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)); \
} while(0)
#define _lf_unpin(PINS, PIN) _lf_pin(PINS, PIN, NULL)
#define lf_pin(PINS, PIN, ADDR) \
......
......@@ -412,8 +412,6 @@ found:
/* 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 -
add it back to the allocator stack
......
......@@ -27,8 +27,6 @@
#include <my_bit.h>
#include <lf.h>
LF_REQUIRE_PINS(3)
/* An element of the list */
typedef struct {
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,
DBUG_PRINT("wt", ("enter: thd=%s, blocker=%s, depth=%u",
arg->thd->name, blocker->name, depth));
LF_REQUIRE_PINS(1);
arg->last_locked_rc= 0;
if (depth > arg->max_depth)
......@@ -923,8 +921,6 @@ int wt_thd_will_wait_for(WT_THD *thd, WT_THD *blocker,
WT_RESOURCE *rc;
DBUG_ENTER("wt_thd_will_wait_for");
LF_REQUIRE_PINS(3);
DBUG_PRINT("wt", ("enter: thd=%s, blocker=%s, resid=%lu",
thd->name, blocker->name, (ulong)resid->value));
......
......@@ -211,8 +211,6 @@ static enum lockman_getlock_result getlock_result[10][10]=
#undef A
#undef x
LF_REQUIRE_PINS(4)
typedef struct lockman_lock {
uint64 resource;
struct lockman_lock *lonext;
......
......@@ -577,7 +577,6 @@ int trnman_can_read_from(TRN *trn, TrID trid)
{
TRN **found;
my_bool can;
LF_REQUIRE_PINS(3);
if (trid < trn->min_read_from)
return 1; /* Row is visible by all transactions in the system */
......@@ -618,7 +617,6 @@ int trnman_can_read_from(TRN *trn, TrID trid)
TRN *trnman_trid_to_trn(TRN *trn, TrID trid)
{
TRN **found;
LF_REQUIRE_PINS(3);
if (trid < trn->min_read_from)
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