• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2020 Endless Mobile, Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
16  *
17  * Author: Philip Withnall <withnall@endlessm.com>
18  */
19 
20 #pragma once
21 
22 #ifdef HAVE_SYSPROF
23 #include <sysprof-capture.h>
24 #endif
25 
26 #include "glib.h"
27 
28 G_BEGIN_DECLS
29 
30 /*
31  * G_TRACE_CURRENT_TIME:
32  *
33  * Get the current time, in nanoseconds since the tracing epoch. This (and only
34  * this) is suitable for passing to tracing functions like g_trace_mark(). It is
35  * not suitable for other timekeeping.
36  *
37  * The tracing epoch is implementation defined, but is guaranteed to be
38  * unchanged within the lifetime of each thread. It is not comparable across
39  * threads or process instances.
40  *
41  * If tracing support is disabled, this evaluates to `0`.
42  *
43  * Since: 2.66
44  */
45 #ifdef HAVE_SYSPROF
46 #define G_TRACE_CURRENT_TIME SYSPROF_CAPTURE_CURRENT_TIME
47 #else
48 #define G_TRACE_CURRENT_TIME 0
49 #endif
50 
51 void (g_trace_mark) (gint64       begin_time_nsec,
52                      gint64       duration_nsec,
53                      const gchar *group,
54                      const gchar *name,
55                      const gchar *message_format,
56                      ...) G_GNUC_PRINTF (5, 6);
57 
58 #ifndef HAVE_SYSPROF
59 /* Optimise the whole call out */
60 #if defined(G_HAVE_ISO_VARARGS)
61 #define g_trace_mark(b, d, g, n, m, ...)
62 #elif defined(G_HAVE_GNUC_VARARGS)
63 #define g_trace_mark(b, d, g, n, m...)
64 #else
65 /* no varargs macro support; the call will have to be optimised out by the compiler */
66 #endif
67 #endif
68 
69 guint   (g_trace_define_int64_counter) (const char *group,
70                                         const char *name,
71                                         const char *description);
72 void    (g_trace_set_int64_counter)    (guint       id,
73                                         gint64      value);
74 
75 #ifndef HAVE_SYSPROF
76 #define g_trace_define_int64_counter(g, n, d) ((guint) -1)
77 #define g_trace_set_int64_counter(i,v)
78 #endif
79 
80 G_END_DECLS
81