summaryrefslogtreecommitdiff
path: root/dbug/dbug.c
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-09-13 15:28:53 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-09-13 15:28:53 +0300
commitb214264aee2a6441abc7c8e73519c8267edcb8fa (patch)
tree2bec335394fcdef46b6edb575f67b62024df0d8b /dbug/dbug.c
parent41290e91b7be29ed72b8a41c7b6698ec1d2b96ab (diff)
downloadmariadb-git-b214264aee2a6441abc7c8e73519c8267edcb8fa.tar.gz
MDEV-20525 rocksdb debug compilation fails on Windows due to unresolved my_assert variable
MYSQL_PLUGIN_IMPORT did not work correctly for the RocksDB helper library rocksdb_aux_lib, because that library was not compiled with -DMYSQL_DYNAMIC_PLUGIN. Fix DBUG such that it does not depend on exported data, only on functions (which do not need MYSQL_PLUGIN_IMPORT decoration) Use a "getter" function _db_my_assert() instead of DLL-exported variable. Also, reduce object code duplication by moving more of the DBUG_ASSERT logic inside the _db_my_assert() function, and add unlikely() and ATTRIBUTE_COLD hints to ensure that the 'assertion failed' code will be separated from the main control flow logic. Thus, the compiler can move the unlikely() code to the end of the compiled function, reachable via a forward conditional branch, which the processor's branch predictor could assume 'not taken'.
Diffstat (limited to 'dbug/dbug.c')
-rw-r--r--dbug/dbug.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/dbug/dbug.c b/dbug/dbug.c
index 40620b5e9c6..2d629ac0741 100644
--- a/dbug/dbug.c
+++ b/dbug/dbug.c
@@ -2258,6 +2258,16 @@ static int default_my_dbug_sanity(void)
return 0;
}
+extern my_bool my_assert;
+ATTRIBUTE_COLD
+my_bool _db_my_assert(const char *file, int line, const char *msg)
+{
+ _db_flush_();
+ my_bool a = my_assert;
+ if (!a)
+ fprintf(stderr, "%s:%d: assert: %s\n", file, line, msg);
+ return a;
+}
#else
/*