Do not calculate arguments if trace-point is disabled. For this:
- move to macro do { ... } while (0) scheme
- use additional macro-layer to handle calls of trace-points where
a macro generates parameter list
(like trace_e1000e_mac_set_permanent(MAC_ARG(macaddr)))
This is needed to allow some additional logic in trace-point parameter
calculation, which will not be executed if this trace-point is
disabled.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
scripts/tracetool/format/h.py | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py
index aecf249d66..d0baccc453 100644
--- a/scripts/tracetool/format/h.py
+++ b/scripts/tracetool/format/h.py
@@ -73,12 +73,13 @@ def generate(events, backend, group):
cond = "true"
out('',
- 'static inline void %(api)s(%(args)s)',
- '{',
- ' if (%(cond)s) {',
- ' %(api_nocheck)s(%(names)s);',
- ' }',
- '}',
+ '#define %(api)s(...) _do_%(api)s(__VA_ARGS__)',
+ '#define _do_%(api)s(%(names)s) \\',
+ 'do { \\',
+ ' if (%(cond)s) { \\',
+ ' %(api_nocheck)s(%(names)s); \\',
+ ' } \\',
+ '} while (0)',
api=e.api(),
api_nocheck=e.api(e.QEMU_TRACE_NOCHECK),
args=e.args,
--
2.11.1