X-Git-Url: https://git.donarmstrong.com/?p=rsem.git;a=blobdiff_plain;f=my_assert.h;h=3688d9630d27869880dc2a12010d34d1d95c1c70;hp=d63c3a2584b71b09537da0df482bc79126cc0fad;hb=HEAD;hpb=1b2999c4407ef8419fb89b66b843b7141caff4da diff --git a/my_assert.h b/my_assert.h index d63c3a2..3688d96 100644 --- a/my_assert.h +++ b/my_assert.h @@ -31,17 +31,18 @@ inline std::string cstrtos(const char* s) { } -inline void general_assert(int expr, const std::string& errmsg, bool putEnter = false) { - if (expr) return; +#define general_assert(expr, errmsg) if (!(expr)) general_report((errmsg), false) +#define general_assert_1(expr, errmsg) if (!(expr)) general_report((errmsg), true) +inline void general_report(const std::string& errmsg, bool putEnter) { if (putEnter) printf("\n"); fprintf(stderr, "%s\n", errmsg.c_str()); exit(-1); } -inline void pthread_assert(int rc, const std::string& func_name, const std::string& errmsg) { - if (rc == 0) return; +#define pthread_assert(rc, func_name, errmsg) if ((rc) != 0) pthread_report((rc), (func_name), (errmsg)) +inline void pthread_report(int rc, const std::string& func_name, const std::string& errmsg) { fprintf(stderr, "%s\n", errmsg.c_str()); if (func_name == "pthread_create") {