diag-trace
5.0.1
µOS++ Tracing Infrastructure
Toggle main menu visibility
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 for any
6
* 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 be
9
* obtained from https://opensource.org/licenses/mit.
10
*/
11
12
// ----------------------------------------------------------------------------
13
27
28
// ----------------------------------------------------------------------------
29
30
#include "
micro-os-plus/diag/trace.h
"
31
32
// ----------------------------------------------------------------------------
33
34
#if defined(MICRO_OS_PLUS_DIAG_TRACE_ENABLED)
35
36
// ----------------------------------------------------------------------------
37
38
#if defined(__clang__)
39
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
40
#endif
// defined(__clang__)
41
42
// ----------------------------------------------------------------------------
43
44
namespace
detail
=
micro_os_plus::trace::detail
;
45
46
// The C API is always bound to the `tracer<implementation>` policy class;
47
// extern "C" does not support templates, so it cannot expose other
48
// instances. Code that needs custom instances must call the C++
49
// API directly.
50
51
void
52
micro_os_plus_trace_initialise
(
void
)
53
{
54
detail::tracer<detail::implementation>::initialise
();
55
}
56
57
ssize_t
58
micro_os_plus_trace_write
(
const
void
* buf,
size_t
nbyte)
59
{
60
return
detail::tracer<detail::implementation>::write
(buf, nbyte);
61
}
62
63
void
64
micro_os_plus_trace_flush
(
void
)
65
{
66
detail::tracer<detail::implementation>::flush
();
67
}
68
69
// ----------------------------------------------------------------------------
70
71
int
72
micro_os_plus_trace_printf
(
const
char
* format, ...)
73
{
74
std::va_list arguments;
75
va_start (arguments, format);
76
77
int
ret
78
=
detail::tracer<detail::implementation>::vprintf
(format, arguments);
79
80
va_end (arguments);
81
return
ret;
82
}
83
84
int
85
micro_os_plus_trace_vprintf
(
const
char
* format, va_list arguments)
86
{
87
return
detail::tracer<detail::implementation>::vprintf
(format, arguments);
88
}
89
90
int
91
micro_os_plus_trace_puts
(
const
char
* s)
92
{
93
return
detail::tracer<detail::implementation>::puts
(s);
94
}
95
96
int
97
micro_os_plus_trace_putchar
(
int
c)
98
{
99
return
detail::tracer<detail::implementation>::putchar
(c);
100
}
101
102
void
103
micro_os_plus_trace_dump_args
(
int
argc,
char
* argv[])
104
{
105
detail::tracer<detail::implementation>::dump_args
(argc, argv);
106
}
107
108
// ----------------------------------------------------------------------------
109
110
#endif
// defined(MICRO_OS_PLUS_DIAG_TRACE_ENABLED)
111
112
// ----------------------------------------------------------------------------
micro_os_plus::trace::detail::tracer::initialise
static void initialise(void) noexcept
Initialise the trace output channel.
Definition
cpp-api.h:432
micro_os_plus::trace::detail::tracer::puts
static int puts(const char *s="") noexcept
Write the string and a line terminator to the trace output channel.
Definition
cpp-api-inlines.h:141
micro_os_plus::trace::detail::tracer::vprintf
static int vprintf(const char *format, std::va_list arguments) noexcept
Write a formatted variable arguments list to the trace output channel.
Definition
cpp-api-inlines.h:89
micro_os_plus::trace::detail::tracer::dump_args
static void dump_args(int argc, char *argv[], const char *name="main") noexcept
Send the argv[] array to the trace output channel.
Definition
cpp-api-inlines.h:210
micro_os_plus::trace::detail::tracer::write
static ssize_t write(const void *buf, std::size_t nbyte) noexcept
Write the given number of bytes to the trace output channel.
Definition
cpp-api.h:453
micro_os_plus::trace::detail::tracer::flush
static void flush(void) noexcept
Flush the trace output channel.
Definition
cpp-api.h:477
micro_os_plus::trace::detail::tracer::putchar
static int putchar(int c) noexcept
Write the single character to the trace output channel.
Definition
cpp-api-inlines.h:186
micro_os_plus_trace_dump_args
void micro_os_plus_trace_dump_args(int argc, char *argv[])
Write the argv[] array to the trace output channel.
Definition
trace-c-api.cpp:103
micro_os_plus_trace_initialise
void micro_os_plus_trace_initialise(void)
Initialise the trace output channel.
Definition
trace-c-api.cpp:52
micro_os_plus_trace_write
ssize_t micro_os_plus_trace_write(const void *buf, size_t nbyte)
Write the given number of bytes to the trace output channel.
Definition
trace-c-api.cpp:58
micro_os_plus_trace_flush
void micro_os_plus_trace_flush(void)
Flush the trace output channel.
Definition
trace-c-api.cpp:64
micro_os_plus_trace_printf
int micro_os_plus_trace_printf(const char *format,...)
Write a formatted string to the trace output channel.
Definition
trace-c-api.cpp:72
micro_os_plus_trace_puts
int micro_os_plus_trace_puts(const char *s)
Write the string and a line terminator to the trace output channel.
Definition
trace-c-api.cpp:91
micro_os_plus_trace_vprintf
int micro_os_plus_trace_vprintf(const char *format, va_list arguments)
Write a formatted variable arguments list to the trace output channel.
Definition
trace-c-api.cpp:85
micro_os_plus_trace_putchar
int micro_os_plus_trace_putchar(int c)
Write the single character to the trace output channel.
Definition
trace-c-api.cpp:97
micro_os_plus::trace::detail
Implementation details namespace.
Definition
cpp-api.h:286
trace.h
C++ header file with the declarations for the µOS++ Tracing Infrastructure.
src
trace-c-api.cpp
Generated by
1.17.0