[gtk/popup-shadow-width] profiler: allow using gdk profiler functions without braces
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/popup-shadow-width] profiler: allow using gdk profiler functions without braces
- Date: Sat, 13 Feb 2021 20:47:15 +0000 (UTC)
commit 9663469d0f507ef59535eadfcd73a71c47ee9224
Author: Christian Hergert <chergert redhat com>
Date: Tue Feb 2 14:41:23 2021 -0800
profiler: allow using gdk profiler functions without braces
Just compiling these out means you have to write code slightly differently
so that you don't end up with "if ();" afterwards.
This adds a "do {} while (0)" so that we're still semantically a statement
but will also compile out.
gdk/gdkprofilerprivate.h | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/gdk/gdkprofilerprivate.h b/gdk/gdkprofilerprivate.h
index bd04850d9d..897f4f804e 100644
--- a/gdk/gdkprofilerprivate.h
+++ b/gdk/gdkprofilerprivate.h
@@ -73,23 +73,23 @@ void gdk_profiler_set_int_counter (guint id,
gint64 value);
#ifndef HAVE_SYSPROF
-#define gdk_profiler_add_mark(b, d, n, m)
-#define gdk_profiler_end_mark(b, n, m)
+#define gdk_profiler_add_mark(b, d, n, m) G_STMT_START {} G_STMT_END
+#define gdk_profiler_end_mark(b, n, m) G_STMT_START {} G_STMT_END
/* Optimise the whole call out */
#if defined(G_HAVE_ISO_VARARGS)
-#define gdk_profiler_add_markf(b, d, n, m, ...)
-#define gdk_profiler_end_markf(b, n, m, ...)
+#define gdk_profiler_add_markf(b, d, n, m, ...) G_STMT_START {} G_STMT_END
+#define gdk_profiler_end_markf(b, n, m, ...) G_STMT_START {} G_STMT_END
#elif defined(G_HAVE_GNUC_VARARGS)
-#define gdk_profiler_add_markf(b, d, n, m...)
-#define gdk_profiler_end_markf(b, n, m...)
+#define gdk_profiler_add_markf(b, d, n, m...) G_STMT_START {} G_STMT_END
+#define gdk_profiler_end_markf(b, n, m...) G_STMT_START {} G_STMT_END
#else
/* no varargs macro support; the call will have to be optimised out by the compiler */
#endif
#define gdk_profiler_define_counter(n, d) 0
#define gdk_profiler_define_int_counter(n, d) 0
-#define gdk_profiler_set_counter(i, v)
-#define gdk_profiler_set_int_counter(i, v)
+#define gdk_profiler_set_counter(i, v) G_STMT_START {} G_STMT_END
+#define gdk_profiler_set_int_counter(i, v) G_STMT_START {} G_STMT_END
#endif
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]