RTI Connext DDS Micro
Version 2.4.10
Main Page
Related Pages
Manuals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
osapi_os_posix.h
Go to the documentation of this file.
1
/*
2
* FILE: osapi_config_posix.h - OS configuration file for POSIX/POSIX like OSs
3
*
4
* (c) Copyright, Real-Time Innovations, 2012-2016
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
* 28jul2016,tk Refactored from osapi_config.h
16
*
17
*/
18
/*ce \file
19
* \brief OS API Configuration
20
*/
21
#ifndef osapi_os_posix_h
22
#define osapi_os_posix_h
23
24
25
#define OSAPI_INCLUDE_POSIX 1
26
27
/* OSAPI_ENABLE_STRICT_POSIX is used to disable using non-POSIX features,
28
* even if available. It is set per POSIX architecture
29
*/
30
#if defined(__APPLE__) && defined(__MACH__)
31
#ifndef RTI_DARWIN
32
#define RTI_DARWIN
33
#endif
34
/* OSAPI_ENABLE_STRICT_POSIX is used to disable using non-POSIX features,
35
* even if available. It is set per POSIX architecture
36
*/
37
#ifndef OSAPI_ENABLE_STRICT_POSIX
38
#define OSAPI_ENABLE_STRICT_POSIX 0
39
#endif
40
#elif defined(__linux__)
41
#ifndef RTI_LINUX
42
#define RTI_LINUX
43
#endif
44
#ifndef OSAPI_ENABLE_STRICT_POSIX
45
#define OSAPI_ENABLE_STRICT_POSIX 0
46
#endif
47
#elif defined(__VOS__)
48
#ifndef RTI_VOS
49
#define RTI_VOS
50
#endif
51
#ifndef OSAPI_ENABLE_STRICT_POSIX
52
#define OSAPI_ENABLE_STRICT_POSIX 1
53
#endif
54
#elif defined(__QNXNTO__)
55
#ifndef RTI_QNX6
56
#define RTI_QNX6
57
#endif
58
#ifndef OSAPI_ENABLE_STRICT_POSIX
59
#define OSAPI_ENABLE_STRICT_POSIX 1
60
#endif
61
#else
62
#error "Unable to detect POSIX variant. Please define OSAPI_OS_DEF_H."
63
#endif
64
65
/* Claim compliance with IEEE Std 1003.1, 2004 Edition */
66
#ifdef _POSIX_C_SOURCE
67
#undef _POSIX_C_SOURCE
68
#endif
69
#define _POSIX_C_SOURCE 200112L
70
71
#ifdef _XOPEN_SOURCE
72
#undef _XOPEN_SOURCE
73
#endif
74
#define _XOPEN_SOURCE 600
75
76
#ifndef RTI_UNIX
77
#define RTI_UNIX
78
#endif
79
80
/* This is needed to get non-POSIX APIs for Linux/Darwin */
81
#if !OSAPI_ENABLE_STRICT_POSIX
82
#ifdef RTI_DARWIN
83
#define _DARWIN_C_SOURCE
84
#endif
85
#ifdef RTI_LINUX
86
#ifndef _GNU_SOURCE
87
#define _GNU_SOURCE
88
#endif
89
#endif
90
#endif
/* OSAPI_STRICT_POSIX */
91
92
/* Standard POSIX headers */
93
#include <unistd.h>
94
#include <stdlib.h>
95
#include <errno.h>
96
#include <sys/time.h>
97
#include <time.h>
98
#include <string.h>
99
#include <pthread.h>
100
#include <sys/utsname.h>
101
#include <sys/types.h>
102
103
/* Define the thread handle */
104
#define OSAPI_ThreadHandle pthread_t
105
#define OSAPI_ThreadId pthread_t
106
107
#define OSAPI_ProcessId pid_t
108
109
/* Assume all supported UNIX variations support the BSD socket API */
110
#define HAVE_SOCKET_API 1
111
112
/* Use free() */
113
#define OSAPI_ENABLE_STDC_FREE 1
114
#define OSAPI_ENABLE_STDC_REALLOC 1
115
116
/*******************************************************************************
117
* Darwin (Mac OS X, macOS) specific definitions
118
******************************************************************************/
119
#ifdef RTI_DARWIN
120
121
#if !defined(RTI_DARWIN7)
122
#include <uuid/uuid.h>
123
#endif
124
125
/* Timer selection:
126
* For strict POSIX use a sleeping thread, otherwise use a GCD timer
127
*/
128
#if !defined(USE_TIMER_THREAD_SEMAPHORE) && \
129
!defined(USE_TIMER_GCD) && \
130
!defined(USE_TIMER_THREAD_SLEEP)
131
#if !OSAPI_ENABLE_STRICT_POSIX && (ENABLE_FACE_COMPLIANCE == FACE_COMPLIANCE_LEVEL_NONE)
132
#include <malloc/malloc.h>
133
#include <dispatch/dispatch.h>
134
#define USE_TIMER_THREAD_SEMAPHORE
135
#define USE_TIMER_GCD
136
#else
137
#define USE_TIMER_THREAD_SLEEP
138
#endif
/* !OSAPI_STRICT_POSIX */
139
#endif
140
141
#ifndef OSAPI_LOG_WRITE_BUFFER
142
#define OSAPI_LOG_WRITE_BUFFER(buf_,len_) if (write(1,buf_,len_)){}
143
#endif
144
145
/*******************************************************************************
146
* Linux specific definitions
147
******************************************************************************/
148
#elif defined(RTI_LINUX)
149
150
#if defined(__ANDROID__)
151
#include <endian.h>
152
#else
153
#include <features.h>
154
#if defined (__GLIBC_PREREQ)
155
#if __GLIBC_PREREQ(2,9)
156
#include <endian.h>
157
#endif
158
#endif
159
#endif
/* else __ANDROID__ */
160
161
#if ENABLE_FACE_COMPLIANCE == FACE_COMPLIANCE_LEVEL_NONE
162
#include <malloc.h>
163
#ifdef __ANDROID__
164
/* NOTE: This is supported in R8D, but missing from the header-file
165
* https://code.google.com/p/android/issues/detail?id=20140
166
*/
167
extern
int
clock_nanosleep(clockid_t clock_id,
int
flags,
168
const
struct
timespec *request,
169
struct
timespec *remain);
170
#if OSAPI_ENABLE_LOG
171
#include <android/log.h>
172
#endif
173
#ifndef OSAPI_LOG_WRITE_BUFFER
174
#define OSAPI_LOG_WRITE_BUFFER(buf_,len_) \
175
if (__android_log_print(ANDROID_LOG_DEBUG,"com.rti.rtime",buffer)){}
176
#endif
177
#else
/* __ANDROID__ */
178
#ifndef OSAPI_LOG_WRITE_BUFFER
179
#define OSAPI_LOG_WRITE_BUFFER(buf_,len_) if (write(1,buf_,len_)){}
180
#endif
181
#endif
/* __ANDROID__ */
182
183
#if !defined(USE_TIMER_SIGNAL) && \
184
!defined(USE_TIMER_THREAD_RT) && \
185
!defined(USE_TIMER_THREAD_SLEEP)
186
/*
187
* Tick generation on Linux can be done via real-time signals, real-time
188
* sleep or sleep. The default is real-time sleep.
189
* NOTE: real-time signals on Arm/Linux has odd behavior.
190
*
191
* To enable real-time signals enable the following macros and comment
192
* out USE_TIMER_THREAD_RT
193
* #define USE_TIMER_SIGNAL
194
* #define USE_TIMER_THREAD_SEMAPHORE
195
*/
196
#ifdef USE_TIMER_SIGNAL
197
#include <signal.h>
198
#endif
199
#define USE_TIMER_THREAD_RT
200
#else
/* ENABLE_FACE_COMPLIANCE */
201
#define USE_TIMER_THREAD_SLEEP
202
#endif
/* !ENABLE_FACE_COMPLIANCE */
203
#endif
204
205
#else
/* __linux__ */
206
/*******************************************************************************
207
* Generic POSIX definitions
208
******************************************************************************/
209
#define USE_TIMER_THREAD_SLEEP
210
#ifndef OSAPI_LOG_WRITE_BUFFER
211
#define OSAPI_LOG_WRITE_BUFFER(buf_,len_) if (write(1,buf_,len_)){}
212
#endif
213
#endif
214
215
/* Disable printf for FACE compliance
216
* TODO: Check if write is supported
217
*/
218
#if ENABLE_FACE_COMPLIANCE > FACE_COMPLIANCE_LEVEL_NONE
219
#undef OSAPI_LOG_WRITE_BUFFER
220
#endif
221
222
#endif
/* osapi_os_posix_h */
RTI Connext DDS Micro Version 2.4.10
Copyright © Fri Jun 30 2017
Real-Time Innovations, Inc