Commit 7d60c463 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 4e681fc8
......@@ -61,22 +61,43 @@ void partitioned_counters_destroy(void);
/*
*/
#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"); \
#if defined(__clang__)
// clang does not yet support constexprs, so cannot use strcmp, strncmp, etc in static_asserts
#define TOKUDB_STATUS_INIT_CONSTEXPR_ASSERTS(c, inc) do { } while (0)
#else
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"), \
"Use nullptr for no column name instead of NULL, 0, etc..."); \
static_assert((inc) == TOKU_ENGINE_STATUS || strcmp(#c, "nullptr"), \
"Missing column name."); \
static_assert(strncmp(#c, "TOKU", strlen("TOKU")) && \
strncmp(#c, "toku", strlen("toku")), \
static_assert(static_strncasecmp(#c, "TOKU", strlen("TOKU")), \
"Do not start column names with toku/tokudb. Names get TOKUDB_ prefix automatically."); \
static_assert((inc) == TOKU_ENGINE_STATUS || \
(strcmp(#c, "nullptr") && strcmp(#c, "NULL") && strcmp(#c, "0")) \
, "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); \
if (t == PARCOUNT) { \
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