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:
parent
0abccc6370
commit
b883ec4c9d
@ -1,9 +1,11 @@
|
|||||||
#include "rust_internal.h"
|
#include "rust_internal.h"
|
||||||
|
|
||||||
#define KLOG(...) \
|
#define KLOG(...) \
|
||||||
|
do { \
|
||||||
if (_log.is_tracing(rust_log::KERN)) { \
|
if (_log.is_tracing(rust_log::KERN)) { \
|
||||||
log(rust_log::KERN, __VA_ARGS__); \
|
log(rust_log::KERN, __VA_ARGS__); \
|
||||||
} else
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
rust_kernel::rust_kernel(rust_srv *srv) :
|
rust_kernel::rust_kernel(rust_srv *srv) :
|
||||||
_region(&srv->local_region),
|
_region(&srv->local_region),
|
||||||
|
@ -2,17 +2,25 @@
|
|||||||
#define RUST_LOG_H
|
#define RUST_LOG_H
|
||||||
|
|
||||||
#define DLOG(dom, mask, ...) \
|
#define DLOG(dom, mask, ...) \
|
||||||
if ((dom)->get_log().is_tracing(mask)) { \
|
do { \
|
||||||
(dom)->log(mask, __VA_ARGS__); \
|
rust_dom *_dom = dom; \
|
||||||
} else
|
uint32_t _mask = mask; \
|
||||||
|
if ((_dom)->get_log().is_tracing(_mask)) { \
|
||||||
|
(_dom)->log(_mask, __VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
#define LOG(task, mask, ...) \
|
#define LOG(task, mask, ...) \
|
||||||
DLOG((task)->dom, mask, __VA_ARGS__)
|
DLOG((task)->dom, mask, __VA_ARGS__)
|
||||||
#define LOG_I(task, mask, ...) \
|
#define LOG_I(task, mask, ...) \
|
||||||
if ((task)->dom->get_log().is_tracing(mask)) { \
|
do { \
|
||||||
(task)->dom->get_log().reset_indent(0); \
|
rust_task *_task = task; \
|
||||||
(task)->dom->log(mask, __VA_ARGS__); \
|
uint32_t _mask = mask; \
|
||||||
(task)->dom->get_log().indent(); \
|
if ((_task)->dom->get_log().is_tracing(_mask)) { \
|
||||||
} else
|
(_task)->dom->get_log().reset_indent(0); \
|
||||||
|
(_task)->dom->log(_mask, __VA_ARGS__); \
|
||||||
|
(_task)->dom->get_log().indent(); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
#define LOGPTR(dom, msg, ptrval) \
|
#define LOGPTR(dom, msg, ptrval) \
|
||||||
DLOG(dom, rust_log::MEM, "%s 0x%" PRIxPTR, msg, ptrval)
|
DLOG(dom, rust_log::MEM, "%s 0x%" PRIxPTR, msg, ptrval)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user