diag-trace 5.0.0
µOS++ Tracing Infrastructure
Loading...
Searching...
No Matches
trace-c-api.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3 * Copyright (c) 2015-2026 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software
6 * for any purpose is hereby granted, under the terms of the MIT license.
7 *
8 * If a copy of the license was not distributed with this file, it can
9 * be obtained from https://opensource.org/licenses/mit.
10 */
11
12// ----------------------------------------------------------------------------
13
27
28// ----------------------------------------------------------------------------
29
31
32// ----------------------------------------------------------------------------
33
34#if defined(MICRO_OS_PLUS_DIAG_TRACE_ENABLED)
35
36// ----------------------------------------------------------------------------
37
38using namespace micro_os_plus::trace::detail;
39
40// The C API is always bound to the `tracer<implementation>` policy class;
41// extern "C" does not support templates, so it cannot expose other
42// instances. Code that needs custom instances must call the C++
43// API directly.
44
45void
50
51ssize_t
52micro_os_plus_trace_write (const void* buf, size_t nbyte)
53{
54 return tracer<implementation>::write (buf, nbyte);
55}
56
57void
62
63// ----------------------------------------------------------------------------
64
65int
66micro_os_plus_trace_printf (const char* format, ...)
67{
68 std::va_list arguments;
69 va_start (arguments, format);
70
71#pragma GCC diagnostic push
72#if defined(__clang__)
73#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
74#endif
75 int ret = tracer<implementation>::vprintf (format, arguments);
76#pragma GCC diagnostic pop
77
78 va_end (arguments);
79 return ret;
80}
81
82int
83micro_os_plus_trace_vprintf (const char* format, va_list arguments)
84{
85#pragma GCC diagnostic push
86#if defined(__clang__)
87#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
88#endif
89 return tracer<implementation>::vprintf (format, arguments);
90#pragma GCC diagnostic pop
91}
92
93int
95{
96#pragma GCC diagnostic push
97#if defined(__clang__)
98#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
99#endif
101#pragma GCC diagnostic pop
102}
103
104int
109
110void
111micro_os_plus_trace_dump_args (int argc, char* argv[])
112{
114}
115
116// ----------------------------------------------------------------------------
117
118#endif // defined(MICRO_OS_PLUS_DIAG_TRACE_ENABLED)
119
120// ----------------------------------------------------------------------------
static int puts(const char *s="") noexcept
Write the string and a line terminator to the trace output channel.
static int vprintf(const char *format, std::va_list arguments) noexcept
Write a formatted variable arguments list to the trace output channel.
static void dump_args(int argc, char *argv[], const char *name="main") noexcept
Send the argv[] array to the trace output channel.
static void flush(void) noexcept(noexcept(T::flush()))
Flush the trace output channel.
static ssize_t write(const void *buf, std::size_t nbyte) noexcept(noexcept(T::write(buf, nbyte)))
Write the given number of bytes to the trace output channel.
static void initialise(void) noexcept(noexcept(T::initialise()))
Initialise the trace output channel.
static int putchar(int c) noexcept
Write the single character to the trace output channel.
void micro_os_plus_trace_dump_args(int argc, char *argv[])
Write the argv[] array to the trace output channel.
void micro_os_plus_trace_initialise(void)
Initialise the trace output channel.
ssize_t micro_os_plus_trace_write(const void *buf, size_t nbyte)
Write the given number of bytes to the trace output channel.
void micro_os_plus_trace_flush(void)
Flush the trace output channel.
int micro_os_plus_trace_printf(const char *format,...)
Write a formatted string to the trace output channel.
int micro_os_plus_trace_puts(const char *s)
Write the string and a line terminator to the trace output channel.
int micro_os_plus_trace_vprintf(const char *format, va_list arguments)
Write a formatted variable arguments list to the trace output channel.
int micro_os_plus_trace_putchar(int c)
Write the single character to the trace output channel.
Implementation details namespace.
C++ header file with the declarations for the µOS++ Tracing Infrastructure.