summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2006-11-16 13:18:21 -0800
committerNathan Binkert <binkertn@umich.edu>2006-11-16 13:18:21 -0800
commitf028865d351fbeae38230183e58a77bc0ad0cc12 (patch)
tree092199ba9d6d54df555fa882029794db62e23d94
parentbd8cc3765034e18230a28c133d2a4173ba332ef4 (diff)
downloadgem5-f028865d351fbeae38230183e58a77bc0ad0cc12.tar.xz
add warn_once which will print any given warning message
only once. --HG-- extra : convert_revision : b64bb495c1bd0c4beb3db6ca28fad5af4d05ef8e
-rw-r--r--src/base/misc.hh13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/base/misc.hh b/src/base/misc.hh
index 87faf20e6..1c5720ce1 100644
--- a/src/base/misc.hh
+++ b/src/base/misc.hh
@@ -76,6 +76,19 @@ void __warn(const std::string&, cp::ArgList &, const char*, const char*, int);
#define warn(args...) \
__warn__(args, cp::ArgListNull())
+// Only print the warning message the first time it is seen. This
+// doesn't check the warning string itself, it just only lets one
+// warning come from the statement. So, even if the arguments change
+// and that would have resulted in a different warning message,
+// subsequent messages would still be supressed.
+#define warn_once(args...) do { \
+ static bool once = false; \
+ if (!once) { \
+ __warn__(args, cp::ArgListNull()); \
+ once = true; \
+ } \
+ } while (0)
+
//
// assert() that prints out the current cycle
//