C/C++ API Reference
Loading...
Searching...
No Matches
config.h
1// Copyright 2020 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14
15// Configurable options for the tokenized trace module.
16#pragma once
17
19
23#ifndef PW_TRACE_CONFIG_ARG_LABEL_SIZE_BYTES
24#define PW_TRACE_CONFIG_ARG_LABEL_SIZE_BYTES 20
25#endif // PW_TRACE_CONFIG_ARG_LABEL_SIZE_BYTES
26
29#ifndef PW_TRACE_QUEUE_SIZE_EVENTS
30#define PW_TRACE_QUEUE_SIZE_EVENTS 5
31#endif // PW_TRACE_QUEUE_SIZE_EVENTS
32
33// --- Config options for time source ----
34
36#ifndef PW_TRACE_TIME_TYPE
37#define PW_TRACE_TIME_TYPE uint32_t
38#endif // PW_TRACE_TIME_TYPE
39
43
47
54#ifndef PW_TRACE_GET_TIME_DELTA
55#define PW_TRACE_GET_TIME_DELTA(last_time, current_time) \
56 ((current_time) - (last_time))
57#ifdef __cplusplus
58
59#include <type_traits>
60
61static_assert(
62 std::is_unsigned<PW_TRACE_TIME_TYPE>::value,
63 "Default time delta implementation only works for unsigned time types.");
64#endif // __cplusplus
65#endif // PW_TRACE_GET_TIME_DELTA
66
67// --- Config options for callbacks ----
68
70#ifndef PW_TRACE_CONFIG_MAX_EVENT_CALLBACKS
71#define PW_TRACE_CONFIG_MAX_EVENT_CALLBACKS 2
72#endif // PW_TRACE_CONFIG_MAX_EVENT_CALLBACKS
73
75#ifndef PW_TRACE_CONFIG_MAX_SINKS
76#define PW_TRACE_CONFIG_MAX_SINKS 2
77#endif // PW_TRACE_CONFIG_MAX_SINKS
78
79// --- Config options for optional trace buffer ---
80
83#ifndef PW_TRACE_BUFFER_SIZE_BYTES
84#define PW_TRACE_BUFFER_SIZE_BYTES 256
85#endif // PW_TRACE_BUFFER_SIZE_BYTES
86
89#ifndef PW_TRACE_BUFFER_MAX_BLOCK_SIZE_BYTES
92#ifndef PW_TRACE_BUFFER_MAX_DATA_SIZE_BYTES
93#define PW_TRACE_BUFFER_MAX_DATA_SIZE_BYTES (32)
94#endif // PW_TRACE_BUFFER_MAX_BLOCK_SIZE_BYTES
95
96#ifndef PW_TRACE_BUFFER_MAX_HEADER_SIZE_BYTES
97#define PW_TRACE_BUFFER_MAX_HEADER_SIZE_BYTES \
98 (pw::varint::kMaxVarint64SizeBytes) + /* worst case delta time varint */ \
99 (sizeof(uint32_t)) + /* trace token size */ \
100 (pw::varint::kMaxVarint64SizeBytes) + /* worst case trace id varint */
101#endif // PW_TRACE_BUFFER_MAX_HEADER_SIZE_BYTES
102
103#define PW_TRACE_BUFFER_MAX_BLOCK_SIZE_BYTES \
104 PW_TRACE_BUFFER_MAX_HEADER_SIZE_BYTES + PW_TRACE_BUFFER_MAX_DATA_SIZE_BYTES
105#endif // PW_TRACE_BUFFER_MAX_BLOCK_SIZE_BYTES
106
#define PW_TRACE_TIME_TYPE
The type for trace time.
Definition: config.h:37
size_t pw_trace_GetTraceTimeTicksPerSecond(void)
uint32_t pw_trace_GetTraceTime(void)