changeset e4f63f1d502d in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=e4f63f1d502d
description:
        base: Add a warn_if macro

        Add a warn if macro that is analogous to the panic_if and fatal_if.

diffstat:

 src/base/misc.hh |  14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diffs (24 lines):

diff -r 7c972b9aea16 -r e4f63f1d502d src/base/misc.hh
--- a/src/base/misc.hh  Sun Jun 21 20:48:33 2015 +0100
+++ b/src/base/misc.hh  Sun Jun 21 20:52:13 2015 +0100
@@ -219,6 +219,20 @@
     cond_message_once(want_hack, std::cerr, "hack", hack_verbose, __VA_ARGS__)
 
 /**
+ * Conditional warning macro that checks the supplied condition and
+ * only prints a warning if the condition is true. Useful to replace
+ * if + warn.
+ *
+ * @param cond Condition that is checked; if true -> warn
+ * @param ...  Printf-based format string with arguments, extends printout.
+ */
+#define warn_if(cond, ...) \
+    do { \
+        if ((cond)) \
+            warn(__VA_ARGS__); \
+    } while (0)
+
+/**
  * The chatty assert macro will function like a normal assert, but will allow 
the
  * specification of additional, helpful material to aid debugging why the
  * assertion actually failed.  Like the normal assertion, the chatty_assert
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to