Debian Codegraph @

gtksourceview/gtksourcetrace.h

raw symbols SCIP
1 /*
2 * This file is part of GtkSourceView
3 *
4 * Copyright 2020 Christian Hergert <[email protected]>
5 *
6 * GtkSourceView is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * GtkSourceView is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this library; if not, see <http://www.gnu.org/licenses/>.
18 *
19 * SPDX-License-Identifier: LGPL-2.1-or-later
20 */
21
22 #pragma once
23
24 #include <glib.h>
25
26 #ifndef GETTEXT_PACKAGE
27 # error "config.h was not included before gtksourcetrace.h."
28 #endif
29
30 #ifdef HAVE_SYSPROF
31 # include <sysprof-capture.h>
32 #endif
33
34 G_BEGIN_DECLS
35
36 #ifdef HAVE_SYSPROF
37 # define GTK_SOURCE_PROFILER_ENABLED 1
38 # define GTK_SOURCE_PROFILER_CURRENT_TIME SYSPROF_CAPTURE_CURRENT_TIME
39 # define GTK_SOURCE_PROFILER_ACTIVE (sysprof_collector_is_active())
40 # define GTK_SOURCE_PROFILER_BEGIN_MARK \
41 G_STMT_START { \
42 gint64 __begin_time = SYSPROF_CAPTURE_CURRENT_TIME;
43 # define GTK_SOURCE_PROFILER_END_MARK(name, message) \
44 G_STMT_START { \
45 gint64 __duration = SYSPROF_CAPTURE_CURRENT_TIME - __begin_time; \
46 sysprof_collector_mark (__begin_time, __duration, "GtkSourceView", name, message); \
47 } G_STMT_END; \
48 } G_STMT_END
49 # define GTK_SOURCE_PROFILER_MARK(duration, name, message) \
50 G_STMT_START { \
51 sysprof_collector_mark (SYSPROF_CAPTURE_CURRENT_TIME - (duration), \
52 (duration), "GtkSourceView", name, message); \
53 } G_STMT_END
54 # define GTK_SOURCE_PROFILER_LOG(format, ...) \
55 G_STMT_START { \
56 if (GTK_SOURCE_PROFILER_ACTIVE) \
57 sysprof_collector_log_printf(G_LOG_LEVEL_DEBUG, G_LOG_DOMAIN, format, __VA_ARGS__); \
58 } G_STMT_END
59 #else
60 # undef GTK_SOURCE_PROFILER_ENABLED
61 # define GTK_SOURCE_PROFILER_ACTIVE (0)
62 # define GTK_SOURCE_PROFILER_CURRENT_TIME 0
63 # define GTK_SOURCE_PROFILER_MARK(duration, name, message) \
64 G_STMT_START { } G_STMT_END
65 # define GTK_SOURCE_PROFILER_BEGIN_MARK G_STMT_START {
66 # define GTK_SOURCE_PROFILER_END_MARK(name, message) (void)0; } G_STMT_END
67 # define GTK_SOURCE_PROFILER_LOG(format, ...) G_STMT_START { } G_STMT_END
68 #endif
69
70 G_END_DECLS