| eRPC API Reference Rev. 1.8.1 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 #define ERPC_HAS_POSIX (1)
27 #else
28 #define ERPC_HAS_POSIX (0)
29 #endif
30 #endif
31
32 // Determine if we are targeting WIN32 environment
33 #if !defined(ERPC_HAS_WIN32)
34 #if defined(_WIN32)
35 #define ERPC_HAS_WIN32 (1)
36 #else
37 #define ERPC_HAS_WIN32 (0)
38 #endif
39 #endif
40
41 // Safely detect FreeRTOSConfig.h.
42 #define ERPC_HAS_FREERTOSCONFIG_H (0)
43 #if defined(__has_include)
44 #if __has_include("FreeRTOSConfig.h")
45 #undef ERPC_HAS_FREERTOSCONFIG_H
46 #define ERPC_HAS_FREERTOSCONFIG_H (1)
47 #endif
48 #endif
49
50 // Detect threading model if not already set.
51 #if !defined(ERPC_THREADS)
52 #if ERPC_HAS_POSIX
53 // Default to pthreads for POSIX systems.
54 #define ERPC_THREADS (ERPC_THREADS_PTHREADS)
55 #elif ERPC_HAS_FREERTOSCONFIG_H
56 // Use FreeRTOS if we can auto detect it.
57 #define ERPC_THREADS (ERPC_THREADS_FREERTOS)
58 #elif ERPC_HAS_WIN32
59 #define ERPC_THREADS (ERPC_THREADS_WIN32)
60 #else
61 // Otherwise default to no threads.
62 #define ERPC_THREADS (ERPC_THREADS_NONE)
63 #endif
64 #endif
65
66 // Handy macro to test threading model. You can also ERPC_THREADS directly to test for threading
67 // support, i.e. "#if ERPC_THREADS", because ERPC_THREADS_NONE has a value of 0.
68 #define ERPC_THREADS_IS(_n_) (ERPC_THREADS == (ERPC_THREADS_##_n_))
69
70 // Set default buffer size.
71 #if !defined(ERPC_DEFAULT_BUFFER_SIZE)
72 #define ERPC_DEFAULT_BUFFER_SIZE (256U)
74 #endif
75
76 // Set default buffers count.
77 #if !defined(ERPC_DEFAULT_BUFFERS_COUNT)
78 #define ERPC_DEFAULT_BUFFERS_COUNT (2U)
80 #endif
81
82 // Disable/enable noexcept.
83 #if !defined(ERPC_NOEXCEPT)
84 #if ERPC_HAS_POSIX
85 #define ERPC_NOEXCEPT (ERPC_NOEXCEPT_ENABLED)
86 #else
87 #define ERPC_NOEXCEPT (ERPC_NOEXCEPT_DISABLED)
88 #endif
89 #endif
90
91 //NOEXCEPT support
92 #if defined(__cplusplus) && __cplusplus >= 201103 && ERPC_NOEXCEPT
93 #define NOEXCEPT noexcept
94 #else
95 #define NOEXCEPT
96 #endif // NOEXCEPT
97
98 // Disabling nesting calls support as default.
99 #if !defined(ERPC_NESTED_CALLS)
100 #define ERPC_NESTED_CALLS (ERPC_NESTED_CALLS_DISABLED)
101 #endif
102
103 #if ERPC_NESTED_CALLS && !ERPC_THREADS
104 #error "Nested calls currently working only with Threads."
105 #endif
106
107 // Enabling nesting calls detection as default for debug.
108 #if !defined(ERPC_NESTED_CALLS_DETECTION)
109 #if defined(NDEBUG) || (ERPC_NESTED_CALLS == ERPC_NESTED_CALLS_ENABLED)
110 #define ERPC_NESTED_CALLS_DETECTION (ERPC_NESTED_CALLS_DETECTION_DISABLED)
111 #else
112 #define ERPC_NESTED_CALLS_DETECTION (ERPC_NESTED_CALLS_DETECTION_ENABLED)
113 #endif
114 #endif
115
116 // Disabling tracing the eRPC.
117 #if !defined(ERPC_MESSAGE_LOGGING)
118 #define ERPC_MESSAGE_LOGGING (ERPC_MESSAGE_LOGGING_DISABLED)
119 #endif
120
121 #if defined(__CC_ARM) || defined(__ARMCC_VERSION) /* Keil MDK */
122 #define THROW_BADALLOC throw(std::bad_alloc)
123 #define THROW throw()
124 #else
125 #define THROW_BADALLOC
126 #define THROW
127 #endif
128
129 #ifndef ERPC_TRANSPORT_MU_USE_MCMGR
130 #if defined(__has_include)
131 #if (__has_include("mcmgr.h"))
132 #define ERPC_TRANSPORT_MU_USE_MCMGR (ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED)
133 #else
134 #define ERPC_TRANSPORT_MU_USE_MCMGR (ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED)
135 #endif
136 #endif
137 #else
138 #if defined(__has_include)
139 #if ((!(__has_include("mcmgr.h"))) && (ERPC_TRANSPORT_MU_USE_MCMGR == ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED))
140 #error "Do not forget to add the MCMGR library into your project!"
141 #endif
142 #endif
143 #endif
144
145 // Disabling pre and post callback function related code.
146 #if !defined(ERPC_PRE_POST_ACTION)
147 #define ERPC_PRE_POST_ACTION (ERPC_PRE_POST_ACTION_DISABLED)
148 #endif
149
150 // Disabling pre and post default callback function code.
151 #if !defined(ERPC_PRE_POST_ACTION_DEFAULT)
152 #define ERPC_PRE_POST_ACTION_DEFAULT (ERPC_PRE_POST_ACTION_DEFAULT_DISABLED)
153 #endif
154
155 /* clang-format on */
156 #endif // _ERPC_DETECT_H_
157 // EOF
erpc_config.h