summaryrefslogtreecommitdiff
path: root/gdk/gdkprofilerprivate.h
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2020-02-12 11:05:01 +0100
committerAlexander Larsson <alexl@redhat.com>2020-02-12 11:05:01 +0100
commit01d5ad2056f9c896246219eb04ca1ae807a45768 (patch)
treeaecc056b7dd2c2e0911c223fada8ca4e06dfceb3 /gdk/gdkprofilerprivate.h
parentcc643df88b541b7505885ecff02c8576decf6bbd (diff)
downloadgtk+-01d5ad2056f9c896246219eb04ca1ae807a45768.tar.gz
profiler: Make profiler-is-running a macro
When we use if (GDK_PROFILER_IS_RUNNING) this means we get an inlined if (FALSE) when the compiler support is not compiled in, which gets rid of all the related code completely. We also expand to G_UNLIKELY(gdk_profiler_is_running ()) in the supported case which might cause somewhat better code generation.
Diffstat (limited to 'gdk/gdkprofilerprivate.h')
-rw-r--r--gdk/gdkprofilerprivate.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/gdk/gdkprofilerprivate.h b/gdk/gdkprofilerprivate.h
index 99558e3adf..1c68739e0e 100644
--- a/gdk/gdkprofilerprivate.h
+++ b/gdk/gdkprofilerprivate.h
@@ -23,6 +23,21 @@
G_BEGIN_DECLS
+/* Ensure we included config.h as needed for the below HAVE_SYSPROF_CAPTURE check */
+#ifndef GETTEXT_PACKAGE
+#error "config.h was not included before gdkprofilerprivate.h."
+#endif
+
+/* We make this a macro you use as if (GDK_PROFILER_IS_RUNNING) because that
+ * way we can ensure all the code is compiled out when not supported, and
+ * we can add a G_UNLIKELY() for better codegen if it is.
+ */
+#ifdef HAVE_SYSPROF_CAPTURE
+#define GDK_PROFILER_IS_RUNNING G_UNLIKELY (gdk_profiler_is_running ())
+#else
+#define GDK_PROFILER_IS_RUNNING FALSE
+#endif
+
void gdk_profiler_start (int fd);
void gdk_profiler_stop (void);
gboolean gdk_profiler_is_running (void);