RTI Connext DDS Micro
Version 2.4.11
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 HAVE_SSIZE_T 1
104
105
/* Define the thread handle */
106
#define OSAPI_ThreadHandle pthread_t
107
#define OSAPI_ThreadId pthread_t
108
109
#define OSAPI_ProcessId pid_t
110
111
/* Assume all supported UNIX variations support the BSD socket API */
112
#define HAVE_SOCKET_API 1
113
114
/* Use free() */
115
#define OSAPI_ENABLE_STDC_FREE 1
116
#define OSAPI_ENABLE_STDC_REALLOC 1
117
118
/*******************************************************************************
119
* Darwin (Mac OS X, macOS) specific definitions
120
******************************************************************************/
121
#ifdef RTI_DARWIN
122
123
#if !defined(RTI_DARWIN7)
124
#include <uuid/uuid.h>
125
#endif
126
127
/* Timer selection:
128
* For strict POSIX use a sleeping thread, otherwise use a GCD timer
129
*/
130
#if !defined(USE_TIMER_THREAD_SEMAPHORE) && \
131
!defined(USE_TIMER_GCD) && \
132
!defined(USE_TIMER_THREAD_SLEEP)
133
#if !OSAPI_ENABLE_STRICT_POSIX && (ENABLE_FACE_COMPLIANCE == FACE_COMPLIANCE_LEVEL_NONE)
134
#include <malloc/malloc.h>
135
#include <dispatch/dispatch.h>
136
#define USE_TIMER_THREAD_SEMAPHORE
137
#define USE_TIMER_GCD
138
#else
139
#define USE_TIMER_THREAD_SLEEP
140
#endif
/* !OSAPI_STRICT_POSIX */
141
#endif
142
143
#ifndef OSAPI_LOG_WRITE_BUFFER
144
#define OSAPI_LOG_WRITE_BUFFER(buf_,len_) if (write(1,buf_,len_)){}
145
#endif
146
147
/*******************************************************************************
148
* Linux specific definitions
149
******************************************************************************/
150
#elif defined(RTI_LINUX)
151
152
#if defined(__ANDROID__)
153
#include <endian.h>
154
#else
155
#include <features.h>
156
#if defined (__GLIBC_PREREQ)
157
#if __GLIBC_PREREQ(2,9)
158
#include <endian.h>
159
#endif
160
#endif
161
#endif
/* else __ANDROID__ */
162
163
#if ENABLE_FACE_COMPLIANCE == FACE_COMPLIANCE_LEVEL_NONE
164
#include <malloc.h>
165
#ifdef __ANDROID__
166
/* NOTE: This is supported in R8D, but missing from the header-file
167
* https://code.google.com/p/android/issues/detail?id=20140
168
*/
169
extern
int
clock_nanosleep(clockid_t clock_id,
int
flags,
170
const
struct
timespec *request,
171
struct
timespec *remain);
172
#if OSAPI_ENABLE_LOG
173
#include <android/log.h>
174
#endif
175
#ifndef OSAPI_LOG_WRITE_BUFFER
176
#define OSAPI_LOG_WRITE_BUFFER(buf_,len_) \
177
if (__android_log_print(ANDROID_LOG_DEBUG,"com.rti.rtime",buffer)){}
178
#endif
179
#else
/* __ANDROID__ */
180
#ifndef OSAPI_LOG_WRITE_BUFFER
181
#define OSAPI_LOG_WRITE_BUFFER(buf_,len_) if (write(1,buf_,len_)){}
182
#endif
183
#endif
/* __ANDROID__ */
184
185
#if !defined(USE_TIMER_SIGNAL) && \
186
!defined(USE_TIMER_THREAD_RT) && \
187
!defined(USE_TIMER_THREAD_SLEEP)
188
/*
189
* Tick generation on Linux can be done via real-time signals, real-time
190
* sleep or sleep. The default is real-time sleep.
191
* NOTE: real-time signals on Arm/Linux has odd behavior.
192
*
193
* To enable real-time signals enable the following macros and comment
194
* out USE_TIMER_THREAD_RT
195
* #define USE_TIMER_SIGNAL
196
* #define USE_TIMER_THREAD_SEMAPHORE
197
*/
198
#ifdef USE_TIMER_SIGNAL
199
#include <signal.h>
200
#endif
201
#define USE_TIMER_THREAD_RT
202
#else
/* ENABLE_FACE_COMPLIANCE */
203
#define USE_TIMER_THREAD_SLEEP
204
#endif
/* !ENABLE_FACE_COMPLIANCE */
205
#endif
206
207
#else
/* __linux__ */
208
/*******************************************************************************
209
* Generic POSIX definitions
210
******************************************************************************/
211
#define USE_TIMER_THREAD_SLEEP
212
#ifndef OSAPI_LOG_WRITE_BUFFER
213
#define OSAPI_LOG_WRITE_BUFFER(buf_,len_) if (write(1,buf_,len_)){}
214
#endif
215
#endif
216
217
/* Disable printf for FACE compliance
218
* TODO: Check if write is supported
219
*/
220
#if ENABLE_FACE_COMPLIANCE > FACE_COMPLIANCE_LEVEL_NONE
221
#undef OSAPI_LOG_WRITE_BUFFER
222
#endif
223
224
#endif
/* osapi_os_posix_h */
RTI Connext DDS Micro Version 2.4.11
Copyright © Mon Jul 23 2018
Real-Time Innovations, Inc