util/perf: fix multiple tracepoints in a scope

Fixes

 "../src/util/perf/cpu_trace.h:32:8: error: redefinition of ‘_mesa_trace_scope___LINE__’"

This should work until someone wants multiple MESA_TRACE_SCOPE on the
same line :)

Acked-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Antonio Caggiano <antonio.caggiano@collabora.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18260>
This commit is contained in:
Chia-I Wu 2022-08-25 14:22:19 -07:00 committed by Marge Bot
parent 022cd156d4
commit 3163e637f4

View file

@ -28,9 +28,20 @@
#if __has_attribute(cleanup) && __has_attribute(unused)
#define MESA_TRACE_SCOPE(name) \
int _mesa_trace_scope_##__LINE__ \
__attribute__((cleanup(mesa_trace_scope_end), unused)) = \
#define _MESA_TRACE_SCOPE_VAR_CONCAT(name, suffix) name##suffix
#define _MESA_TRACE_SCOPE_VAR(suffix) \
_MESA_TRACE_SCOPE_VAR_CONCAT(_mesa_trace_scope_, suffix)
/* This must expand to a single non-scoped statement for
*
* if (cond)
* MESA_TRACE_SCOPE(...)
*
* to work.
*/
#define MESA_TRACE_SCOPE(name) \
int _MESA_TRACE_SCOPE_VAR(__LINE__) \
__attribute__((cleanup(mesa_trace_scope_end), unused)) = \
mesa_trace_scope_begin(name)
static inline int