Skip to main content

trace-c-api.cpp File

C++ source file with the definitions for the C trace API. More...

Included Headers

Functions Index

voidmicro_os_plus_trace_dump_args (int argc, char *argv[])

Write the argv[] array to the trace output channel. More...

voidmicro_os_plus_trace_flush (void)

Flush the trace output channel. More...

voidmicro_os_plus_trace_initialise (void)

Initialise the trace output channel. More...

intmicro_os_plus_trace_printf (const char *format,...)

Write a formatted string to the trace output channel. More...

intmicro_os_plus_trace_putchar (int c)

Write the single character to the trace output channel. More...

intmicro_os_plus_trace_puts (const char *s)

Write the string and a line terminator to the trace output channel. More...

intmicro_os_plus_trace_vprintf (const char *format, va_list arguments)

Write a formatted variable arguments list to the trace output channel. More...

ssize_tmicro_os_plus_trace_write (const void *buf, size_t nbyte)

Write the given number of bytes to the trace output channel. More...

Description

C++ source file with the definitions for the C trace API.

Definitions for the C-linkage wrapper functions (micro_os_plus_trace_printf(), etc.) that forward to the corresponding C++ internal tracer<implementation> functions.

The empty inline stubs (used when tracing is disabled) are located in trace-c-api-inlines.h, included at the bottom of trace-c-api.h.

File Listing

The file content with the documentation metadata removed is:

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
47{
49}
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
59{
61}
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
106{
108}
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// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.1 by Doxygen 1.17.0.