Added SILC_VERIFY macro, which is same as SILC_ASSERT but is
authorPekka Riikonen <priikone@silcnet.org>
Wed, 16 May 2007 06:03:47 +0000 (06:03 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Wed, 16 May 2007 06:03:47 +0000 (06:03 +0000)
always compiled in.

lib/silcutil/silcfsm.h
lib/silcutil/silclog.h

index 24daa6fa5ec165627d59faf69e095f1ebea3e4f1..d9c4be0f07054a0420a53fca75bec04975fc0624 100644 (file)
@@ -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;                  \
index 64cd6c0ef1d277402dc5d9c86f7b2fed010256fa..4ae8ca9ccf08ad1034e9391e07a808833aa7fed7 100644 (file)
@@ -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