RTI Connext DDS Micro  Version 2.4.6
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
osapi_config.h
Go to the documentation of this file.
1 /*
2  * FILE: osapi_config.h - OS Configuration
3  *
4  * (c) Copyright, Real-Time Innovations, 2012-2015
5  *
6  * All rights reserved.
7  *
8  * No duplications, whole or partial, manual or electronic, may be made
9  * without express written permission. Any such copies, or
10  * revisions thereof, must display this notice unaltered.
11  * This code contains trade secrets of Real-Time Innovations, Inc.
12  *
13  * Modification History
14  * --------------------
15  * 23apr2013,eh MICRO-106: add RTI_HAVE_LONG_DOUBLE comment
16  * 23feb2012,tk Written
17  *
18  */
19 
20 /*ce \file
21  * \brief OS API Configuration
22  */
23 #ifndef osapi_config_h
24 #define osapi_config_h
25 
26 #define RTI_PRIVATE static
27 
28 /* OSAPI_PLATFORM_XXX
29  * Defines platforms supported by OSAPI.
30  *
31  * The platform includes:
32  * - OS API
33  * - Hardware dependencies
34  *
35  * The platform specific OSAPI should include. Any HW dependencies to support
36  * portable code. Likely candidates are clock/timer support.
37  */
38 #define OSAPI_PLATFORM_POSIX 1
39 #define OSAPI_PLATFORM_STOS 2 /* not currently supported */
40 #define OSAPI_PLATFORM_FREERTOS 3
41 #define OSAPI_PLATFORM_VXWORKS 4
42 #define OSAPI_PLATFORM_WINDOWS 5
43 #define OSAPI_PLATFORM_STELLARIS 6
44 
45 /* The global configuration is read first. Local definitions must
46  * check if the global configuration has set an option or not. Note that
47  * a module cannot disable a feature.
48  */
49 #ifdef HAVE_GLOBAL_CONFIG
50 #include "rti_me_config.h"
51 #endif
52 
53 /*
54  * ENABLE_FACE_COMPLIANCE:
55  * 0 - No compliance with FACE is required
56  * 1 - Comply with the SECURITY profile (not supported)
57  * 2 - Comply with the SAFTEY_BASE profile (not supported)
58  * 3 - Comply with the SAFETY_EXTENDED profile (supported)
59  * 4 - Comply with the GENERAL profile (supported)
60  */
61 #define FACE_COMPLIANCE_LEVEL_NONE 0
62 #define FACE_COMPLIANCE_LEVEL_SECURITY 1
63 #define FACE_COMPLIANCE_LEVEL_SAFETY_BASE 2
64 #define FACE_COMPLIANCE_LEVEL_SAFETY_EXTENDED 3
65 #define FACE_COMPLIANCE_LEVEL_GENERAL 4
66 
67 #ifndef ENABLE_FACE_COMPLIANCE
68 #define ENABLE_FACE_COMPLIANCE FACE_COMPLIANCE_LEVEL_NONE
69 #endif
70 
71 #if (ENABLE_FACE_COMPLIANCE > FACE_COMPLIANCE_LEVEL_NONE) && \
72  (ENABLE_FACE_COMPLIANCE < FACE_COMPLIANCE_LEVEL_SAFTEY_EXTENDED)
73 #error "RTI Connext Micro only support FACE profile Safety Extended and higher"
74 #endif
75 
76 #ifndef OSAPI_ENABLE_LOG
77 #if NDEBUG && defined(RTI_CERT)
78 #define OSAPI_ENABLE_LOG 0
79 #else
80 #define OSAPI_ENABLE_LOG 1
81 #endif
82 #endif
83 
84 #ifndef OSAPI_ENABLE_TRACE
85 #if NDEBUG || defined(RTI_CERT)
86 #define OSAPI_ENABLE_TRACE 0
87 #else
88 #define OSAPI_ENABLE_TRACE 1
89 #endif
90 #endif
91 
92 #if OSAPI_ENABLE_TRACE && !OSAPI_ENABLE_LOG
93 #warning "OSAPI_ENABLE_TRACE=1 requires OSAPI_ENABLE_LOG=1, but OSAPI_ENABLE_LOG=0. Forcing OSAPI_ENABLE_LOG=1"
94 #ifdef OSAPI_ENABLE_LOG
95 #undef OSAPI_ENABLE_LOG
96 #endif
97 #define OSAPI_ENABLE_LOG 1
98 #endif
99 
100 #ifndef OSAPI_ENABLE_PRECONDITION
101 #if NDEBUG || defined(RTI_CERT)
102 #define OSAPI_ENABLE_PRECONDITION 0
103 #else
104 #define OSAPI_ENABLE_PRECONDITION 1
105 #endif
106 #endif
107 
108 #if OSAPI_ENABLE_PRECONDITION
109 #define PRECOND_ARG(x_)
110 #else
111 #define PRECOND_ARG(x_) (void)(x_);
112 #endif
113 
114 #if defined(__GNUC__) && (__GNUC__ >= 4)
115 #define MUST_CHECK_RETURN __attribute__((warn_unused_result))
116 #define SHOULD_CHECK_RETURN
117 #define FUNCTION_SHOULD_TYPEDEF(ftdef_) \
118 typedef SHOULD_CHECK_RETURN ftdef_;
119 #define FUNCTION_MUST_TYPEDEF(ftdef_) \
120 typedef MUST_CHECK_RETURN ftdef_;
121 #elif defined(_MSC_VER) || defined(WIN32)
122 #include <CodeAnalysis\SourceAnnotations.h>
123 #define MUST_CHECK_RETURN [returnvalue:SA_Post(MustCheck=SA_Yes)]
124 #define SHOULD_CHECK_RETURN
125 #define FUNCTION_SHOULD_TYPEDEF(ftdef_) \
126 typedef ftdef_;
127 #define FUNCTION_MUST_TYPEDEF(ftdef_) \
128 typedef ftdef_;
129 #else
130 #define MUST_CHECK_RETURN
131 #define SHOULD_CHECK_RETURN
132 #define FUNCTION_SHOULD_TYPEDEF(ftdef_) \
133 typedef SHOULD_CHECK_RETURN ftdef_;
134 #define FUNCTION_MUST_TYPEDEF(ftdef_) \
135 typedef MUST_CHECK_RETURN ftdef_;
136 #endif
137 
138 #define UNUSED_ARG(x) (void)(x)
139 #define IGNORE_RETVAL(x) (void)(x)
140 
141 /* If the platform has not been specified, attempt to determine it.
142  */
143 #ifndef OSAPI_PLATFORM
144 #if defined(__APPLE__) && defined(__MACH__)
145 #define OSAPI_PLATFORM OSAPI_PLATFORM_POSIX
146 #define OSAPI_HAVE_PRINTF 1
147 #elif defined(__linux__)
148 #define OSAPI_PLATFORM OSAPI_PLATFORM_POSIX
149 #define OSAPI_HAVE_PRINTF 1
150 #elif defined(_MSC_VER) || defined(WIN32)
151 #define OSAPI_PLATFORM OSAPI_PLATFORM_WINDOWS
152 #define OSAPI_HAVE_PRINTF_S 1
153 #elif defined(__vxworks)
154 #define OSAPI_HAVE_PRINTF 1
155 #define OSAPI_PLATFORM OSAPI_PLATFORM_VXWORKS
156 #else
157 #error "Unable to determine OSAPI_PLATFORM. Please specify."
158 #endif
159 #endif
160 
161 /* INCLUDE_POSIX
162  *
163  * Set INCLUDE_POSIX is the target platform used the POSIX API. Note that
164  * 100% POSIX compliance is required, it is expected that nuances in the API
165  * is reflected in the POSIX platform files. This is a coarse grained
166  * inclusion.
167  */
168 #if OSAPI_PLATFORM == OSAPI_PLATFORM_POSIX
169 
170 #if ENABLE_FACE_COMPLIANCE > FACE_COMPLIANCE_LEVEL_NONE
171 #if OSAPI_HAVE_PRINTF
172 #undef OSAPI_HAVE_PRINTF
173 #define OSAPI_HAVE_PRINTF 0
174 #endif
175 #endif
176 
177 #ifdef _POSIX_C_SOURCE
178 #undef _POSIX_C_SOURCE
179 #endif
180 #define _POSIX_C_SOURCE 200112L
181 
182 #ifdef _XOPEN_SOURCE
183 #undef _XOPEN_SOURCE
184 #endif
185 #define _XOPEN_SOURCE 700
186 
187 #ifndef INCLUDE_POSIX
188 #define INCLUDE_POSIX
189 #endif
190 #if defined(__APPLE__) && defined(__MACH__)
191 #define _DARWIN_C_SOURCE
192 #endif
193 #ifndef RTI_UNIX
194 #define RTI_UNIX
195 #endif
196 #if defined(__linux__)
197 #if !defined(OS_ANDROID)
198 #include <features.h>
199 #else
200 #ifdef _GNU_SOURCE
201 #undef _GNU_SOURCE
202 #endif
203 #endif
204 #if defined (__GLIBC_PREREQ)
205 #if __GLIBC_PREREQ(2,9)
206 #include <endian.h>
207 #endif
208 #elif defined (OS_ANDROID)
209 #include <endian.h>
210 #endif
211 #endif
212 #include <stdio.h>
213 #include <stdlib.h>
214 #include <stdarg.h>
215 #include <errno.h>
216 #include <sys/time.h>
217 #include <time.h>
218 #include <sys/types.h>
219 #include <string.h>
220 #define HAVE_SOCKET_API
221 #define RTI_HAVE_FLOAT
222 #if defined(__APPLE__) && defined(__MACH__)
223 #include <malloc/malloc.h>
224 #define HAVE_MEMALIGN 0
225 #if ENABLE_FACE_COMPLIANCE > FACE_COMPLIANCE_LEVEL_NONE
226 #error "FACE compliance is not supported in Darwin"
227 #endif
228 #define USE_TIMER_GCD
229 #define USE_TIMER_THREAD_SEMAPHORE
230 #ifndef RTI_DARWIN
231 #define RTI_DARWIN
232 #endif /* RTI_DARWIN */
233 #if !defined(RTI_ENDIAN_BIG) && !defined(RTI_ENDIAN_LITTLE)
234 #ifdef __LITTLE_ENDIAN__
235 #define RTI_ENDIAN_LITTLE 1
236 #else
237 #define RTI_ENDIAN_BIG 1
238 #endif /* !defined(RTI_ENDIAN_BIG) && !defined(RTI_ENDIAN_LITTLE) */
239 #endif
240 /* Linux/GCC */
241 #elif defined(__linux__)
242 #if ENABLE_FACE_COMPLIANCE == FACE_COMPLIANCE_LEVEL_NONE
243 #include <malloc.h>
244 #endif
245 #include <time.h>
246 
247 #if ENABLE_FACE_COMPLIANCE == FACE_COMPLIANCE_LEVEL_NONE
248 #ifdef __ANDROID__
249 /* NOTE: This is supported in R8D, but missing from the header-file
250  * https://code.google.com/p/android/issues/detail?id=20140
251  */
252 extern int clock_nanosleep(clockid_t clock_id, int flags,
253  const struct timespec *request,
254  struct timespec *remain);
255 #if OSAPI_ENABLE_LOG
256 #include <android/log.h>
257 #endif
258 #endif
259 /*
260  * Tick generation on Linux can be done via real-time signals, real-time
261  * sleep or sleep. The default is real-time sleep.
262  * NOTE: real-time signals on Arm/Linux has odd behavior.
263  *
264  * To enable real-time signals enable the following macros and comment
265  * out USE_TIMER_THREAD_RT
266  * #define USE_TIMER_SIGNAL
267  * #define USE_TIMER_THREAD_SEMAPHORE
268  */
269 #define USE_TIMER_THREAD_RT
270 #else
271 #define USE_TIMER_THREAD_SLEEP
272 #endif
273 #ifndef RTI_LINUX
274 #define RTI_LINUX
275 #endif
276 #if !defined(RTI_ENDIAN_BIG) && !defined(RTI_ENDIAN_LITTLE)
277 #if __BYTE_ORDER == __LITTLE_ENDIAN
278 #define RTI_ENDIAN_LITTLE 1
279 #elif __BYTE_ORDER == __BIG_ENDIAN
280 #define RTI_ENDIAN_BIG 1
281 #else
282 #error "Unable to determine endianess. Please specify RTI_ENDIAN_BIG RTI_ENDIAN_LITTLE"
283 #error
284 #endif
285 #endif /* !defined(RTI_ENDIAN_BIG) && !defined(RTI_ENDIAN_LITTLE) */
286 /* #define HAVE_RTI_POSIX_SCHED_POLICY */
287 #endif
288 #endif
289 
290 /* Windows */
291 #if OSAPI_PLATFORM == OSAPI_PLATFORM_WINDOWS
292 #include <stdio.h>
293 #include <stdlib.h>
294 #include <stdarg.h>
295 #include <errno.h>
296 #define _WINSOCKAPI_
297 #ifndef RTI_WIN32
298 #define RTI_WIN32
299 #endif
300 #define HAVE_SOCKET_API
301 #define RTI_HAVE_FLOAT
302 #if !defined(RTI_ENDIAN_BIG) && !defined(RTI_ENDIAN_LITTLE)
303 #ifdef _M_IX86
304 #define RTI_ENDIAN_LITTLE 1
305 #else
306 #error "Unable to determine endianess. Please specify RTI_ENDIAN_BIG RTI_ENDIAN_LITTLE"
307 #endif
308 #endif
309 #endif
310 
311 /* VxWorks */
312 #if OSAPI_PLATFORM == OSAPI_PLATFORM_VXWORKS
313 #include <stdio.h>
314 #include <stdlib.h>
315 #include <stdarg.h>
316 #include <errno.h>
317 #include <time.h>
318 #ifdef CERT
319 #ifndef RTI_CERT
320 #define RTI_CERT
321 #endif
322 #endif
323 #ifdef RTI_RTP
324 #include <strings.h>
325 #include <string.h>
326 #else
327 #include <string.h>
328 #endif
329 #ifndef RTI_USE_MUNCH
330 #define RTI_USE_MUNCH
331 #endif
332 #ifndef RTI_VXWORKS
333 #define RTI_VXWORKS
334 #endif
335 #include <vxWorks.h>
336 #ifdef RTI_RTP
337 /* #define USE_TIMER_SIGNAL */
338 #define USE_TIMER_THREAD_RT
339 #else
340 #define USE_WD_TIMER
341 #define USE_TIMER_THREAD_SEMAPHORE
342 #include <wdLib.h>
343 #include <logLib.h>
344 #endif
345 #if !defined(va_copy) && defined(__va_copy)
346 #define va_copy __va_copy
347 #elif !defined(va_copy)
348 #error "Unable to determine which va_copy to use"
349 #endif
350 #define HAVE_SOCKET_API
351 #define RTI_HAVE_FLOAT
352 #if !defined(RTI_ENDIAN_BIG) && !defined(RTI_ENDIAN_LITTLE)
353 #ifdef __BIG_ENDIAN__
354 #define RTI_ENDIAN_BIG 1
355 #else
356 #define RTI_ENDIAN_LITTLE 1
357 #endif
358 #endif /* !defined(RTI_ENDIAN_BIG) && !defined(RTI_ENDIAN_LITTLE) */
359 
360 #define VXWORKS_VERSION_6_8_OR_BETTER \
361  ( ((VXWORKS_MAJOR_VERSION == 6) && (VXWORKS_MINOR_VERSION >= 8)) || \
362  (VXWORKS_MAJOR_VERSION > 6) \
363  )
364 
365 #define VXWORKS_VERSION_6_3_OR_BETTER \
366  ( ((VXWORKS_MAJOR_VERSION == 6) && (VXWORKS_MINOR_VERSION >= 3)) || \
367  (VXWORKS_MAJOR_VERSION > 6) \
368  )
369 
370 #define VXWORKS_VERSION_6_0_OR_BETTER \
371  ( ((VXWORKS_MAJOR_VERSION == 6) && (VXWORKS_MINOR_VERSION >= 0)) || \
372  (VXWORKS_MAJOR_VERSION > 6) \
373  )
374 
375 #define VXWORKS_VERSION_5_4_OR_BETTER \
376  ( ((VXWORKS_MAJOR_VERSION == 5) && (VXWORKS_MINOR_VERSION >= 4)) || \
377  (VXWORKS_MAJOR_VERSION > 5) \
378  )
379 
380 #endif
381 
382 /* Stellaris */
383 #if OSAPI_PLATFORM == OSAPI_PLATFORM_STELLARIS
384 #include <stdio.h>
385 #include <stdlib.h>
386 #include <stdarg.h>
387 #include <errno.h>
388 #define LWIP_NOSYS
389 #define RTI_ENDIAN_LITTLE 1
390 #endif
391 
392 /* FreeRTOS */
393 #if OSAPI_PLATFORM == OSAPI_PLATFORM_FREERTOS
394 #define RTI_FREERTOS
395 #include <stdio.h>
396 #include <stdlib.h>
397 #include <stdarg.h>
398 #include <string.h>
399 #include <errno.h>
400 #ifndef INC_FREERTOS_H
401 #include "FreeRTOS.h"
402 #endif
403 #define OSAPI_HAVE_PRINTF 1
404 #define HAVE_SOCKET_API
405 #define LWIP_SYS
406 #define RTI_ENDIAN_LITTLE 1
407 #define OSAPI_PLATFORM_FREERTOS_HOSTNAME "FreeRTOS-host"
408 #define TARGET "FreeRTOS-target"
409 #define BUILDABLE_SOURCE
410 #define TARGET "FreeRTOS-target"
411 #define OSAPI_PLATFORM_FREERTOS_STACK_SIZE_DEFAULT 256
412 
413 /* Configuration for FreeRTOS
414  *
415  */
416 
417 #endif
418 
419 
420 /* Some platforms do not support long double or have different sizes for that
421  * type than defined by IDL (16 bytes). On such platforms, DDS_LongDouble
422  * (as well as the unsigned version) is mapped to a character array that
423  * matches the expected size of that type by default. If you are using a
424  * platform whose native mapping has exactly the expected size, you can
425  * instruct Connext Micro to use the native type instead. That is, if
426  * sizeof(long double) == 16, you can tell Connext Micro to map DDS_LongDouble
427  * to long double by defining the following macro, RTI_HAVE_LONG_DOUBLE.
428  */
429 /* #define RTI_HAVE_LONG_DOUBLE */
430 
431 
432 
433 #endif /* osapi_config_h */

RTI Connext DDS Micro Version 2.4.6 Copyright © Mon Jan 25 2016 Real-Time Innovations, Inc