(root)/
glib-2.79.0/
glib/
gtrace-private.h
       1  /*
       2   * Copyright © 2020 Endless Mobile, Inc.
       3   *
       4   * SPDX-License-Identifier: LGPL-2.1-or-later
       5   *
       6   * This library 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   * This library 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
      17   * License along with this library; if not, see <http://www.gnu.org/licenses/>.
      18   *
      19   * Author: Philip Withnall <withnall@endlessm.com>
      20   */
      21  
      22  #pragma once
      23  
      24  #ifdef HAVE_SYSPROF
      25  #include <sysprof-capture.h>
      26  #endif
      27  
      28  #include "glib.h"
      29  
      30  G_BEGIN_DECLS
      31  
      32  /*
      33   * G_TRACE_CURRENT_TIME:
      34   *
      35   * Get the current time, in nanoseconds since the tracing epoch. This (and only
      36   * this) is suitable for passing to tracing functions like g_trace_mark(). It is
      37   * not suitable for other timekeeping.
      38   *
      39   * The tracing epoch is implementation defined, but is guaranteed to be
      40   * unchanged within the lifetime of each thread. It is not comparable across
      41   * threads or process instances.
      42   *
      43   * If tracing support is disabled, this evaluates to `0`.
      44   *
      45   * Since: 2.66
      46   */
      47  #ifdef HAVE_SYSPROF
      48  #define G_TRACE_CURRENT_TIME SYSPROF_CAPTURE_CURRENT_TIME
      49  #else
      50  #define G_TRACE_CURRENT_TIME 0
      51  #endif
      52  
      53  void (g_trace_mark) (gint64       begin_time_nsec,
      54                       gint64       duration_nsec,
      55                       const gchar *group,
      56                       const gchar *name,
      57                       const gchar *message_format,
      58                       ...) G_GNUC_PRINTF (5, 6);
      59  
      60  #ifndef HAVE_SYSPROF
      61  /* Optimise the whole call out */
      62  #if defined(G_HAVE_ISO_VARARGS)
      63  #define g_trace_mark(b, d, g, n, m, ...)
      64  #elif defined(G_HAVE_GNUC_VARARGS)
      65  #define g_trace_mark(b, d, g, n, m...)
      66  #else
      67  /* no varargs macro support; the call will have to be optimised out by the compiler */
      68  #endif
      69  #endif
      70  
      71  guint   (g_trace_define_int64_counter) (const char *group,
      72                                          const char *name,
      73                                          const char *description);
      74  void    (g_trace_set_int64_counter)    (guint       id,
      75                                          gint64      value);
      76  
      77  #ifndef HAVE_SYSPROF
      78  #define g_trace_define_int64_counter(g, n, d) ((guint) -1)
      79  #define g_trace_set_int64_counter(i,v)
      80  #endif
      81  
      82  G_END_DECLS