Move all sources to 'src/'
[lttng-ust.git] / src / liblttng-ust / tracef.c
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (C) 2013-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 */
6
7 #define _LGPL_SOURCE
8 #include <stdio.h>
9 #include <ust-helper.h>
10
11 #define TRACEPOINT_CREATE_PROBES
12 #define TRACEPOINT_DEFINE
13 #include "lttng-ust-tracef-provider.h"
14
15 static inline
16 void __lttng_ust_vtracef(const char *fmt, va_list ap)
17 __attribute__((always_inline, format(printf, 1, 0)));
18 static inline
19 void __lttng_ust_vtracef(const char *fmt, va_list ap)
20 {
21 char *msg;
22 const int len = vasprintf(&msg, fmt, ap);
23
24 /* len does not include the final \0 */
25 if (len < 0)
26 goto end;
27 __tracepoint_cb_lttng_ust_tracef___event(msg, len,
28 LTTNG_UST_CALLER_IP());
29 free(msg);
30 end:
31 return;
32 }
33
34 /*
35 * FIXME: We should include <lttng/tracef.h> for the declarations here, but it
36 * fails with tracepoint magic above my paygrade.
37 */
38
39 void _lttng_ust_vtracef(const char *fmt, va_list ap)
40 __attribute__((format(printf, 1, 0)));
41 void _lttng_ust_vtracef(const char *fmt, va_list ap)
42 {
43 __lttng_ust_vtracef(fmt, ap);
44 }
45
46 void _lttng_ust_tracef(const char *fmt, ...)
47 __attribute__((format(printf, 1, 2)));
48 void _lttng_ust_tracef(const char *fmt, ...)
49 {
50 va_list ap;
51
52 va_start(ap, fmt);
53 __lttng_ust_vtracef(fmt, ap);
54 va_end(ap);
55 }
This page took 0.030788 seconds and 4 git commands to generate.