eRPC API Reference
Rev. 1.12.0
NXP Semiconductors
Main Page
API Reference
Classes
Files
File List
File Members
erpc_config_internal.h
1
/*
2
* Copyright (c) 2016, Freescale Semiconductor, Inc.
3
* Copyright 2016-2017 NXP
4
* Copyright 2020 ACRIOS Systems s.r.o.
5
* All rights reserved.
6
*
7
*
8
* SPDX-License-Identifier: BSD-3-Clause
9
*/
10
11
#ifndef _ERPC_DETECT_H_
12
#define _ERPC_DETECT_H_
13
14
#include "
erpc_config.h
"
15
17
// Declarations
19
/* clang-format off */
20
21
// Determine if this is a POSIX system.
22
#if !defined(ERPC_HAS_POSIX)
23
// Detect Linux, BSD, Cygwin, and Mac OS X.
24
#if defined(__linux__) || defined(__GNU__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
25
defined(__OpenBSD__) || defined(__DragonFly__) || defined(__CYGWIN__) || defined(__MACH__) || \
26
defined(__MINGW32__)
27
#define ERPC_HAS_POSIX (1)
28
#else
29
#define ERPC_HAS_POSIX (0)
30
#endif
31
#endif
32
33
// Determine if we are targeting WIN32 environment
34
#if !defined(ERPC_HAS_WIN32)
35
#if defined(_WIN32)
36
#define ERPC_HAS_WIN32 (1)
37
#else
38
#define ERPC_HAS_WIN32 (0)
39
#endif
40
#endif
41
42
// Safely detect FreeRTOSConfig.h.
43
#define ERPC_HAS_FREERTOSCONFIG_H (0)
44
#if defined(__has_include)
45
#if __has_include("FreeRTOSConfig.h")
46
#undef ERPC_HAS_FREERTOSCONFIG_H
47
#define ERPC_HAS_FREERTOSCONFIG_H (1)
48
#endif
49
#endif
50
51
// Detect allocation policy if not already set.
52
#if !defined(ERPC_ALLOCATION_POLICY)
53
#if ERPC_HAS_FREERTOSCONFIG_H
54
#ifdef __cplusplus
55
extern
"C"
{
56
#endif
57
#include "FreeRTOSConfig.h"
58
#ifdef __cplusplus
59
}
60
#endif
61
#if defined(configSUPPORT_STATIC_ALLOCATION) && configSUPPORT_STATIC_ALLOCATION
62
#define ERPC_ALLOCATION_POLICY (ERPC_ALLOCATION_POLICY_STATIC)
63
#else
64
#define ERPC_ALLOCATION_POLICY (ERPC_ALLOCATION_POLICY_DYNAMIC)
65
#endif
66
#else
67
#define ERPC_ALLOCATION_POLICY (ERPC_ALLOCATION_POLICY_DYNAMIC)
68
#endif
69
#endif
70
71
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_STATIC
72
#if !defined(ERPC_CODEC_COUNT)
73
#define ERPC_CODEC_COUNT (2U)
74
#endif
75
#if !defined(ERPC_MESSAGE_LOGGERS_COUNT)
76
#define ERPC_MESSAGE_LOGGERS_COUNT (0U)
77
#endif
78
#if !defined(ERPC_CLIENTS_THREADS_AMOUNT)
79
#define ERPC_CLIENTS_THREADS_AMOUNT (1U)
80
#endif
81
#endif
82
83
// Safely detect tx_api.h.
84
#define ERPC_HAS_THREADX_API_H (0)
85
#if defined(__has_include)
86
#if __has_include("tx_api.h")
87
#undef ERPC_HAS_THREADX_API_H
88
#define ERPC_HAS_THREADX_API_H (1)
89
#endif
90
#endif
91
92
// Detect threading model if not already set.
93
#if !defined(ERPC_THREADS)
94
#if ERPC_HAS_POSIX
95
// Default to pthreads for POSIX systems.
96
#define ERPC_THREADS (ERPC_THREADS_PTHREADS)
97
#elif ERPC_HAS_FREERTOSCONFIG_H
98
// Use FreeRTOS if we can auto detect it.
99
#define ERPC_THREADS (ERPC_THREADS_FREERTOS)
100
#elif ERPC_HAS_WIN32
101
#define ERPC_THREADS (ERPC_THREADS_WIN32)
102
#elif ERPC_HAS_THREADX_API_H
103
#define ERPC_THREADS (ERPC_THREADS_THREADX)
104
#else
105
// Otherwise default to no threads.
106
#define ERPC_THREADS (ERPC_THREADS_NONE)
107
#endif
108
#endif
109
110
// Handy macro to test threading model. You can also ERPC_THREADS directly to test for threading
111
// support, i.e. "#if ERPC_THREADS", because ERPC_THREADS_NONE has a value of 0.
112
#define ERPC_THREADS_IS(_n_) (ERPC_THREADS == (ERPC_THREADS_##_n_))
113
114
// Set default buffer size.
115
#if !defined(ERPC_DEFAULT_BUFFER_SIZE)
116
#define ERPC_DEFAULT_BUFFER_SIZE (256U)
118
#endif
119
120
// Set default buffers count.
121
#if !defined(ERPC_DEFAULT_BUFFERS_COUNT)
122
#define ERPC_DEFAULT_BUFFERS_COUNT (2U)
124
#endif
125
126
// Disable/enable noexcept.
127
#if !defined(ERPC_NOEXCEPT)
128
#if ERPC_HAS_POSIX
129
#define ERPC_NOEXCEPT (ERPC_NOEXCEPT_ENABLED)
130
#else
131
#define ERPC_NOEXCEPT (ERPC_NOEXCEPT_DISABLED)
132
#endif
133
#endif
134
135
//NOEXCEPT support
136
#if defined(__cplusplus) && __cplusplus >= 201103 && ERPC_NOEXCEPT
137
#define NOEXCEPT noexcept
138
#else
139
#define NOEXCEPT
140
#endif // NOEXCEPT
141
142
// Disabling nesting calls support as default.
143
#if !defined(ERPC_NESTED_CALLS)
144
#define ERPC_NESTED_CALLS (ERPC_NESTED_CALLS_DISABLED)
145
#endif
146
147
#if ERPC_NESTED_CALLS && !ERPC_THREADS
148
#error "Nested calls currently working only with Threads."
149
#endif
150
151
// Enabling nesting calls detection as default for debug.
152
#if !defined(ERPC_NESTED_CALLS_DETECTION)
153
#if defined(NDEBUG) || (ERPC_NESTED_CALLS == ERPC_NESTED_CALLS_ENABLED)
154
#define ERPC_NESTED_CALLS_DETECTION (ERPC_NESTED_CALLS_DETECTION_DISABLED)
155
#else
156
#define ERPC_NESTED_CALLS_DETECTION (ERPC_NESTED_CALLS_DETECTION_ENABLED)
157
#endif
158
#endif
159
160
// Disabling tracing the eRPC.
161
#if !defined(ERPC_MESSAGE_LOGGING)
162
#define ERPC_MESSAGE_LOGGING (ERPC_MESSAGE_LOGGING_DISABLED)
163
#endif
164
165
#if defined(__CC_ARM) || defined(__ARMCC_VERSION)
/* Keil MDK */
166
#define THROW_BADALLOC throw(std::bad_alloc)
167
#define THROW throw()
168
#else
169
#define THROW_BADALLOC
170
#define THROW
171
#endif
172
173
#ifndef ERPC_TRANSPORT_MU_USE_MCMGR
174
#if defined(__has_include)
175
#if (__has_include("mcmgr.h"))
176
#define ERPC_TRANSPORT_MU_USE_MCMGR (ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED)
177
#else
178
#define ERPC_TRANSPORT_MU_USE_MCMGR (ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED)
179
#endif
180
#endif
181
#else
182
#if defined(__has_include)
183
#if ((!(__has_include("mcmgr.h"))) && (ERPC_TRANSPORT_MU_USE_MCMGR == ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED))
184
#error "Do not forget to add the MCMGR library into your project!"
185
#endif
186
#endif
187
#endif
188
189
// Disabling pre and post callback function related code.
190
#if !defined(ERPC_PRE_POST_ACTION)
191
#define ERPC_PRE_POST_ACTION (ERPC_PRE_POST_ACTION_DISABLED)
192
#endif
193
194
// Disabling pre and post default callback function code.
195
#if !defined(ERPC_PRE_POST_ACTION_DEFAULT)
196
#define ERPC_PRE_POST_ACTION_DEFAULT (ERPC_PRE_POST_ACTION_DEFAULT_DISABLED)
197
#endif
198
199
#if !defined(erpc_assert)
200
#if ERPC_HAS_FREERTOSCONFIG_H
201
#ifdef __cplusplus
202
extern
"C"
{
203
#endif
204
#include "FreeRTOS.h"
205
#include "task.h"
206
#ifdef __cplusplus
207
}
208
#endif
209
#define erpc_assert(condition) configASSERT(condition)
210
#elif defined(ERPC_THREADS) && (ERPC_THREADS == ERPC_THREADS_MBED)
211
#include "platform/mbed_assert.h"
212
#define erpc_assert(condition) MBED_ASSERT(condition)
213
#else
214
#ifdef __cplusplus
215
#include <cassert>
216
#else
217
#include "assert.h"
218
#endif
219
#define erpc_assert(condition) assert(condition)
220
#endif
221
#endif
222
223
// Disabling endianness agnostic feature.
224
#ifndef ENDIANNESS_HEADER
225
#define ENDIANNESS_HEADER "erpc_endianness_undefined.h"
226
#endif
227
228
/* clang-format on */
229
#endif // _ERPC_DETECT_H_
230
// EOF
erpc_config.h
Copyright 2016-2020 NXP Semiconductors. All rights reserved.