Commit 9707bdb7 authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

[t:3868] #3868 Replace tentative definition of function pointers in...

[t:3868] #3868 Replace tentative definition of function pointers in toku_assert.c with explicit mechanism: ydb layer passes in function pointers when env is created.

git-svn-id: file:///svn/toku/tokudb@33951 c7de825b-a66e-492c-adef-691d508d4ae1
parent 6d24ebc1
...@@ -123,6 +123,9 @@ const char * environmentdictionary = "tokudb.environment"; ...@@ -123,6 +123,9 @@ const char * environmentdictionary = "tokudb.environment";
const char * fileopsdirectory = "tokudb.directory"; const char * fileopsdirectory = "tokudb.directory";
static int env_get_iname(DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt); static int env_get_iname(DB_ENV* env, DBT* dname_dbt, DBT* iname_dbt);
static int toku_maybe_get_engine_status_text (char* buff, int buffsize); // for use by toku_assert
static void toku_maybe_set_env_panic(int code, char * msg); // for use by toku_assert
static const char single_process_lock_file[] = "/__tokudb_lock_dont_delete_me_"; static const char single_process_lock_file[] = "/__tokudb_lock_dont_delete_me_";
...@@ -1011,6 +1014,7 @@ toku_env_open(DB_ENV * env, const char *home, u_int32_t flags, int mode) { ...@@ -1011,6 +1014,7 @@ toku_env_open(DB_ENV * env, const char *home, u_int32_t flags, int mode) {
if (r == 0) { if (r == 0) {
errno = 0; // tabula rasa. If there's a crash after env was successfully opened, no misleading errno will have been left around by this code. errno = 0; // tabula rasa. If there's a crash after env was successfully opened, no misleading errno will have been left around by this code.
most_recent_env = env; most_recent_env = env;
toku_assert_set_fpointers(toku_maybe_get_engine_status_text, toku_maybe_set_env_panic);
} }
return r; return r;
} }
...@@ -2214,14 +2218,6 @@ env_get_engine_status_text(DB_ENV * env, char * buff, int bufsiz) { ...@@ -2214,14 +2218,6 @@ env_get_engine_status_text(DB_ENV * env, char * buff, int bufsiz) {
return r; return r;
} }
static int toku_maybe_get_engine_status_text (char* buff, int buffsize);
static void toku_maybe_set_env_panic(int code, char * msg);
// assign values to global pointers so that other files can access via tentative definition if linked to this library (.so)
int (*toku_maybe_get_engine_status_text_p)(char* buff, int buffsize) = toku_maybe_get_engine_status_text;
void (*toku_maybe_set_env_panic_p)(int code, char* msg) = toku_maybe_set_env_panic;
// intended for use by toku_assert logic, when env is not known // intended for use by toku_assert logic, when env is not known
static int static int
toku_maybe_get_engine_status_text (char * buff, int buffsize) { toku_maybe_get_engine_status_text (char * buff, int buffsize) {
......
...@@ -14,6 +14,10 @@ C_BEGIN ...@@ -14,6 +14,10 @@ C_BEGIN
#error NDEBUG should not be set #error NDEBUG should not be set
#endif #endif
void toku_assert_set_fpointers(int (*toku_maybe_get_engine_status_text_pointer)(char*, int),
void (*toku_maybe_set_env_panic_pointer)(int, char*));
void toku_do_assert(int /*expr*/,const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/, int/*errno*/) __attribute__((__visibility__("default"))); void toku_do_assert(int /*expr*/,const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/, int/*errno*/) __attribute__((__visibility__("default")));
void toku_do_assert_fail(const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/, int/*errno*/) __attribute__((__visibility__("default"))) __attribute__((__noreturn__)); void toku_do_assert_fail(const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/, int/*errno*/) __attribute__((__visibility__("default"))) __attribute__((__noreturn__));
......
...@@ -17,9 +17,15 @@ ...@@ -17,9 +17,15 @@
static void *backtrace_pointers[N_POINTERS]; static void *backtrace_pointers[N_POINTERS];
#endif #endif
int (*toku_maybe_get_engine_status_text_p)(char* buff, int buffsize); // tentative definition: if linked to ydb, will have non-zero value // Function pointers are zero by default so asserts can be used by brt-layer tests without an environment.
void (*toku_maybe_set_env_panic_p)(int code, char* msg); // tentative definition: if linked to ydb, will have non-zero value static int (*toku_maybe_get_engine_status_text_p)(char* buff, int buffsize) = 0;
static void (*toku_maybe_set_env_panic_p)(int code, char* msg) = 0;
void toku_assert_set_fpointers(int (*toku_maybe_get_engine_status_text_pointer)(char*, int),
void (*toku_maybe_set_env_panic_pointer)(int, char*)) {
toku_maybe_get_engine_status_text_p = toku_maybe_get_engine_status_text_pointer;
toku_maybe_set_env_panic_p = toku_maybe_set_env_panic_pointer;
}
void (*do_assert_hook)(void) = NULL; void (*do_assert_hook)(void) = NULL;
......
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