From: Clifford Wolf Date: Wed, 15 Oct 2014 18:36:32 +0000 (+0200) Subject: Replaced log_assert() do { ... } while (0) hack with a static inline function X-Git-Tag: yosys-0.4~49 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=82ed814fa1d0e8e58392210976069daa4faa3f4a;p=yosys.git Replaced log_assert() do { ... } while (0) hack with a static inline function --- diff --git a/kernel/log.h b/kernel/log.h index 904ba4759..421c50d3f 100644 --- a/kernel/log.h +++ b/kernel/log.h @@ -74,8 +74,12 @@ template static inline const char *log_id(T *obj) { void log_cell(RTLIL::Cell *cell, std::string indent = ""); +static inline void log_assert_worker(bool cond, const char *expr, const char *file, int line) { + if (!cond) log_error("Assert `%s' failed in %s:%d.\n", expr, file, line); +} + #define log_abort() YOSYS_NAMESPACE_PREFIX log_error("Abort in %s:%d.\n", __FILE__, __LINE__) -#define log_assert(_assert_expr_) do { if (_assert_expr_) break; YOSYS_NAMESPACE_PREFIX log_error("Assert `%s' failed in %s:%d.\n", #_assert_expr_, __FILE__, __LINE__); } while (0) +#define log_assert(_assert_expr_) YOSYS_NAMESPACE_PREFIX log_assert_worker(_assert_expr_, #_assert_expr_, __FILE__, __LINE__) #define log_ping() YOSYS_NAMESPACE_PREFIX log("-- %s:%d %s --\n", __FILE__, __LINE__, __PRETTY_FUNCTION__)