RTI Connext DDS Micro  Version 2.4.11
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
osapi_cc_stdc.h
Go to the documentation of this file.
1 /*
2  * FILE: osapi_cc_stdc.h - Specific compiler related definitions
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 /*ce \file
18  * \brief OS API Configuration
19  */
20 #ifndef osapi_cc_stdc_h
21 #define osapi_cc_stdc_h
22 
23 /* NOTE: We (RTI) build for Windows using a cygwin cpp.exe to generate
24  * the dependencies. In addition, MSC only defines __STDC__ when using the /Za
25  * option. Thus, check for more than just __STDC__ as we test MSC
26  */
27 #if !defined(__STDC__) && !defined(_MSC_VER) && !defined(RTI_WIN32)
28 #error "osapi_cc_stdc.h used used with a non-standard C compiler"
29 #endif
30 
31 #include <limits.h>
32 #include <stddef.h>
33 
34 /*******************************************************************************
35  * Define types for for MS VS. The supported types can be found here:
36  *
37  * https://msdn.microsoft.com/en-us/library/s3f49ktz.aspx
38  ******************************************************************************/
39 #if defined(_MSC_VER) || defined(RTI_WIN32)
40 
41 typedef signed char RTI_INT8;
42 typedef unsigned char RTI_UINT8;
43 typedef signed short RTI_INT16;
44 typedef unsigned short RTI_UINT16;
45 typedef signed int RTI_INT32;
46 typedef unsigned int RTI_UINT32;
47 typedef signed long long RTI_INT64;
48 typedef unsigned long long RTI_UINT64;
49 
50 #define RTI_HAVE_FLOAT
51 typedef float RTI_FLOAT32;
52 
53 #define RTI_HAVE_DOUBLE
54 typedef double RTI_DOUBLE64;
55 
56 #if OSAPI_ENABLE_LONG_DOUBLE
57 #error "Native long double is not supported on Win32."
58 #else
59 typedef struct RTI_DOUBLE128
60 {
61  char bytes[16];
62 } RTI_DOUBLE128;
63 #endif
64 
65 #else /* checks when __STDC__ is defined */
66 
67 /*******************************************************************************
68  * Define/Check STDC compiler integer mappings
69  ******************************************************************************/
70 #if SCHAR_MAX == 127
71 /*i
72  */
73 typedef signed char RTI_INT8;
74 
75 /*i
76  */
77 typedef unsigned char RTI_UINT8;
78 #else
79 #error "SCHAR_MAX is unknown, could not determine RTI_INT8/UINT8."
80 #endif /* SCHAR_MAX */
81 
82 #if SHRT_MAX == 32767
83 /*i
84  */
85 typedef signed short RTI_INT16;
86 
87 /*i
88  */
89 typedef unsigned short RTI_UINT16;
90 #else
91 #error "SHRT_MAX is unknown, could not determine RTI_INT16/UINT16."
92 #endif /* SHRT_MAX */
93 
94 #if INT_MAX == 2147483647
95 /*i
96  */
97 typedef signed int RTI_INT32;
98 
99 /*i
100  */
101 typedef unsigned int RTI_UINT32;
102 #else
103 #error "INT_MAX is unknown, could not determine RTI_INT32/UINT32."
104 #endif /* INT_MAX */
105 
106 #ifdef LLONG_MAX
107 #if LLONG_MAX == 9223372036854775807LL
108 /*i
109  */
110  typedef signed long long int RTI_INT64;
111 
112  /*i
113  */
114  typedef unsigned long long int RTI_UINT64;
115 #else
116  #error "LLONG_MAX is unknown, could not determine RTI_INT64/UINT64."
117 #endif /* LLONG_MAX has unknown size */
118 #elif defined(__LONG_LONG_MAX__)
119 #if __LONG_LONG_MAX__ == 9223372036854775807LL
120 /*i
121  */
122  typedef signed long long int RTI_INT64;
123 
124  /*i
125  */
126  typedef unsigned long long int RTI_UINT64;
127 #else /* __LONG_LONG_MAX__ has unknown size */
128 #error "__LONG_LONG_MAX__ is unknown, could not determine RTI_INT64/UINT64."
129 #endif
130 #else /* no size defined */
131 #error "Could not determine RTI_INT64/RTI_UINT64 type"
132 #endif
133 
134 /*******************************************************************************
135  * Define compiler floating point mappings
136  ******************************************************************************/
137 #if (__SIZEOF_FLOAT__ == 4) || (__FLT_MAX_EXP__ == 128) || (FLT_MAX_EXP == 128) || defined(__VOS__)
138 typedef float RTI_FLOAT32;
139 #define RTI_HAVE_FLOAT
140 #else
141 #error "__SIZEOF_FLOAT__ is unknown (GCC), could not determine RTI_FLOAT32."
142 #endif
143 
144 #if (__SIZEOF_DOUBLE__ == 8) || (__DBL_MAX_EXP__ == 1024) || (DBL_MAX_EXP == 1024) || defined(__VOS__)
145 typedef double RTI_DOUBLE64;
146 #define RTI_HAVE_DOUBLE
147 #elif (__SIZEOF_LONG_LONG__ == 8)
148 /* Cummins application board defines double as 4 bytes
149  * and long long as 8 bytes
150  */
151 typedef long long RTI_DOUBLE64;
152 #else
153 #error "__SIZEOF_DOUBLE__ is unknown (GCC), could not determine RTI_DOUBLE64."
154 #endif
155 
156 #if OSAPI_ENABLE_LONG_DOUBLE
157 #if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 2))
158 typedef __float128 RTI_DOUBLE128;
159 #define RTI_HAVE_LONG_DOUBLE
160 #else
161 #error "Could not determine if long double is supported."
162 #endif
163 #else
164 typedef struct RTI_DOUBLE128
165 {
166  char bytes[16];
167 } RTI_DOUBLE128;
168 #endif
169 
170 #endif /* __STDC__ */
171 
172 /*******************************************************************************
173  * Define CPU endian
174  ******************************************************************************/
175 #if !defined(RTI_ENDIAN_LITTLE) && !defined(RTI_ENDIAN_BIG) && defined(__VOS__)
176 #define RTI_ENDIAN_BIG
177 #endif
178 
179 #if !defined(RTI_ENDIAN_LITTLE) && !defined(RTI_ENDIAN_BIG)
180 #ifdef __GNUC__
181 #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
182  defined(__LITTLE_ENDIAN__) || (__BYTE_ORDER == __LITTLE_ENDIAN)
183 #define RTI_ENDIAN_LITTLE 1
184 #undef RTI_ENDIAN_BIG
185 #elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) || \
186  defined(__BIG_ENDIAN__) || (__BYTE_ORDER == __BIG_ENDIAN)
187 #define RTI_ENDIAN_BIG 1
188 #undef RTI_ENDIAN_LITTLE
189 #else
190 #error "Unable to determine GCC byte-order"
191 #endif /* __BYTE_ORDER__ */
192 #elif defined(_MSC_VER)
193 #if defined(_M_IX86) || defined(_M_X64)
194 #define RTI_ENDIAN_LITTLE 1
195 #undef RTI_ENDIAN_BIG
196 #else
197 #error "Unable to determine MSC byte-order"
198 #endif
199 #else
200 #error "Unable to determine endianess."
201 #endif /* !_M_IX86 */
202 #endif
203 
204 /*******************************************************************************
205  * Define various compiler compile options
206  ******************************************************************************/
207 
208 /* Function attributes */
209 #if defined(__GNUC__) && (__GNUC__ >= 4)
210 #define MUST_CHECK_RETURN __attribute__((warn_unused_result))
211 #define SHOULD_CHECK_RETURN
212 #define FUNCTION_SHOULD_TYPEDEF(ftdef_) \
213 typedef SHOULD_CHECK_RETURN ftdef_;
214 #define FUNCTION_MUST_TYPEDEF(ftdef_) \
215 typedef MUST_CHECK_RETURN ftdef_;
216 #elif defined(_MSC_VER) || defined(WIN32)
217 #if _MSC_VER >= 1900
218 #define MUST_CHECK_RETURN _Check_return_
219 #else
220 #include <CodeAnalysis\SourceAnnotations.h>
221 #define MUST_CHECK_RETURN [returnvalue:SA_Post(MustCheck=SA_Yes)]
222 #endif
223 #define SHOULD_CHECK_RETURN
224 #define FUNCTION_SHOULD_TYPEDEF(ftdef_) \
225 typedef ftdef_;
226 #define FUNCTION_MUST_TYPEDEF(ftdef_) \
227 typedef ftdef_;
228 #else
229 #define SHOULD_CHECK_RETURN
230 #define FUNCTION_SHOULD_TYPEDEF(ftdef_) \
231 typedef ftdef_;
232 #define FUNCTION_MUST_TYPEDEF(ftdef_) \
233 typedef ftdef_;
234 #endif
235 
236 #endif /* osapi_cc_stdc_h */
237 

RTI Connext DDS Micro Version 2.4.11 Copyright © Mon Jul 23 2018 Real-Time Innovations, Inc