diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-06-24 20:56:55 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-06-24 20:56:55 +0200 |
commit | 639baee61bdfefe124414db6b12d40061a086e5b (patch) | |
tree | 4ed7af579f6b5e0a05d3f7783382460d384c7e2b /include/lf.h | |
parent | 31a1934c9cc0c4781b4a8c30f60252b02a873a2a (diff) | |
download | mariadb-git-639baee61bdfefe124414db6b12d40061a086e5b.tar.gz |
cleanup: remove LF_REQUIRE_PINS, use compile_time_assert() instead of reimplementing it
Diffstat (limited to 'include/lf.h')
-rw-r--r-- | include/lf.h | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/include/lf.h b/include/lf.h index 07769d10943..21cf65941ff 100644 --- a/include/lf.h +++ b/include/lf.h @@ -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) \ |