From: Pekka Riikonen Date: Wed, 16 May 2007 06:03:47 +0000 (+0000) Subject: Added SILC_VERIFY macro, which is same as SILC_ASSERT but is X-Git-Tag: silc.client.1.1.beta4~2 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=41ca2c760fa7dd7c941a65654e0b380b2ccf1a27 Added SILC_VERIFY macro, which is same as SILC_ASSERT but is always compiled in. --- diff --git a/lib/silcutil/silcfsm.h b/lib/silcutil/silcfsm.h index 24daa6fa..d9c4be0f 100644 --- a/lib/silcutil/silcfsm.h +++ b/lib/silcutil/silcfsm.h @@ -291,7 +291,7 @@ typedef int (*SilcFSMStateCallback)(struct SilcFSMObject *fsm, ***/ #define SILC_FSM_CALL(function) \ do { \ - SILC_ASSERT(!silc_fsm_set_call(fsm, TRUE)); \ + SILC_VERIFY(!silc_fsm_set_call(fsm, TRUE)); \ function; \ if (!silc_fsm_set_call(fsm, FALSE)) \ return SILC_FSM_CONTINUE; \ diff --git a/lib/silcutil/silclog.h b/lib/silcutil/silclog.h index 64cd6c0e..4ae8ca9c 100644 --- a/lib/silcutil/silclog.h +++ b/lib/silcutil/silclog.h @@ -309,6 +309,32 @@ typedef SilcBool (*SilcLogHexdumpCb)(char *file, char *function, int line, #endif /* SILC_DEBUG */ /***/ +/****d* silcutil/SilcLogAPI/SILC_VERIFY + * + * NAME + * + * #define SILC_VERIFY(experssion) + * + * DESCRIPTION + * + * Verification macro that prints error message to stderr and calls + * abort() if the `expression' is false (ie. compares equal to zero) + * on debug builds (SILC_DEBUG defined), and prints error message to + * stderr on release builds (SILC_DEBUG undefined) but does not abort(). + * This macro is always compiled even if debugging (SILC_DEBUG) is not + * defined. + * + * SOURCE + */ +#if defined(SILC_DEBUG) +#define SILC_VERIFY(expr) assert((expr)); +#else +#define SILC_VERIFY(expr) \ + if (!(expr)) \ + SILC_LOG_ERROR(("SILC_VERIFY %s:%d", __FUNCTION__, __LINE__)); +#endif /* SILC_DEBUG */ +/***/ + /* Prototypes */ /****f* silcutil/SilcLogAPI/silc_log_set_file