Avoid some gotchas with logging macros

I think this is sufficient to eliminate multiple evaluation and the
possibility of accidental miscompilation from the logging macros.
This commit is contained in:
Brian Anderson
2011-04-07 20:37:56 -04:00
parent 0abccc6370
commit b883ec4c9d
2 changed files with 25 additions and 15 deletions

View File

@@ -1,9 +1,11 @@
#include "rust_internal.h"
#define KLOG(...) \
if (_log.is_tracing(rust_log::KERN)) { \
log(rust_log::KERN, __VA_ARGS__); \
} else
do { \
if (_log.is_tracing(rust_log::KERN)) { \
log(rust_log::KERN, __VA_ARGS__); \
} \
} while(0)
rust_kernel::rust_kernel(rust_srv *srv) :
_region(&srv->local_region),