diff options
author | Andreas Sandberg <andreas.sandberg@arm.com> | 2015-06-21 20:52:13 +0100 |
---|---|---|
committer | Andreas Sandberg <andreas.sandberg@arm.com> | 2015-06-21 20:52:13 +0100 |
commit | cc813cd5f73ea37173ebda761ebdd4184bf99254 (patch) | |
tree | b7162c26a4e45c13578fb4c04fde92b5f37f1808 | |
parent | d541038549966dcfc8f5923fd8550021b3d72d91 (diff) | |
download | gem5-cc813cd5f73ea37173ebda761ebdd4184bf99254.tar.xz |
base: Add a warn_if macro
Add a warn if macro that is analogous to the panic_if and fatal_if.
-rw-r--r-- | src/base/misc.hh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/base/misc.hh b/src/base/misc.hh index 5f89e5f1d..b62548eb2 100644 --- a/src/base/misc.hh +++ b/src/base/misc.hh @@ -219,6 +219,20 @@ extern bool want_hack, hack_verbose; 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 |