Commit 6371d113 authored by Yoni Fogel's avatar Yoni Fogel

refs #6286 Fix compile for CLANG.

Enabled some more asserts, disabled some static asserts for clang because it does not support constexprs

git-svn-id: file:///svn/toku/tokudb@54540 c7de825b-a66e-492c-adef-691d508d4ae1
parent f6d1933e
...@@ -61,22 +61,43 @@ void partitioned_counters_destroy(void); ...@@ -61,22 +61,43 @@ void partitioned_counters_destroy(void);
/* /*
*/ */
#define TOKUDB_STATUS_INIT(array,k,c,t,l,inc) do { \ #if defined(__clang__)
array.status[k].keyname = #k; \ // clang does not yet support constexprs, so cannot use strcmp, strncmp, etc in static_asserts
array.status[k].columnname = #c; \ #define TOKUDB_STATUS_INIT_CONSTEXPR_ASSERTS(c, inc) do { } while (0)
array.status[k].type = t; \ #else
array.status[k].legend = l; \
static_assert((inc) != 0, "Var must be included in at least one place"); \ constexpr char UU() static_tolower(const char a) {
return a >= 'A' && a <= 'Z' ? a - 'A' + 'a' : a;
}
constexpr int UU() static_strncasecmp(const char *a, const char *b, size_t len) {
return len == 0 ? 0 : (
static_tolower(*a) != static_tolower(*b) || *a == '\0' ?
static_tolower(*a) - static_tolower(*b) :
static_strncasecmp(a+1, b+1, len-1)
);
}
#define TOKUDB_STATUS_INIT_CONSTEXPR_ASSERTS(c, inc) do { \
static_assert(strcmp(#c, "NULL") && strcmp(#c, "0"), \ static_assert(strcmp(#c, "NULL") && strcmp(#c, "0"), \
"Use nullptr for no column name instead of NULL, 0, etc..."); \ "Use nullptr for no column name instead of NULL, 0, etc..."); \
static_assert((inc) == TOKU_ENGINE_STATUS || strcmp(#c, "nullptr"), \ static_assert((inc) == TOKU_ENGINE_STATUS || strcmp(#c, "nullptr"), \
"Missing column name."); \ "Missing column name."); \
static_assert(strncmp(#c, "TOKU", strlen("TOKU")) && \ static_assert(static_strncasecmp(#c, "TOKU", strlen("TOKU")), \
strncmp(#c, "toku", strlen("toku")), \
"Do not start column names with toku/tokudb. Names get TOKUDB_ prefix automatically."); \ "Do not start column names with toku/tokudb. Names get TOKUDB_ prefix automatically."); \
static_assert((inc) == TOKU_ENGINE_STATUS || \ static_assert((inc) == TOKU_ENGINE_STATUS || \
(strcmp(#c, "nullptr") && strcmp(#c, "NULL") && strcmp(#c, "0")) \ (strcmp(#c, "nullptr") && strcmp(#c, "NULL") && strcmp(#c, "0")) \
, "Missing column name."); \ , "Missing column name."); \
} while (0)
#endif
#define TOKUDB_STATUS_INIT(array,k,c,t,l,inc) do { \
array.status[k].keyname = #k; \
array.status[k].columnname = #c; \
array.status[k].type = t; \
array.status[k].legend = l; \
static_assert((inc) != 0, "Var must be included in at least one place"); \
TOKUDB_STATUS_INIT_CONSTEXPR_ASSERTS(c, inc); \
array.status[k].include = static_cast<toku_engine_status_include_type>(inc); \ array.status[k].include = static_cast<toku_engine_status_include_type>(inc); \
if (t == PARCOUNT) { \ if (t == PARCOUNT) { \
array.status[k].value.parcount = create_partitioned_counter(); \ array.status[k].value.parcount = create_partitioned_counter(); \
......
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