Dynatrace OneAgent SDK for C/C++  1.7.1.1
onesdk_config.h
Go to the documentation of this file.
1 /*
2  Copyright 2017-2018 Dynatrace LLC
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 #ifndef ONESDK_CONFIG_H_INCLUDED
18 #define ONESDK_CONFIG_H_INCLUDED
19 
20 /* IWYU pragma: private, include "onesdk/onesdk_common.h" */
21 
26 /*========================================================================================================================================*/
27 
28 #include <stdint.h> /* for fixed width integer types (int32_t, uint32_t etc.) */
29 #include <stddef.h> /* for size_t */
30 
31 /*========================================================================================================================================*/
32 
33 #if defined(ONESDK_BUILD_LIBRARY) && !defined(ONESDK_BUILD_TEST) && defined(__cplusplus)
34 /* Make sure the SDK stub is not compiled as C++.
35  Among other things, this prevents inline function from being visible in the SDK stub, which is a good thing.
36  (In C we use 'static inline', which means if they're compiled for the SDK stub they will have internal linkage.) */
37 # error The SDK stub itself must be compiled as pure C
38 #endif
39 
40 /* Calling convention */
41 
43 #if defined(_WIN32)
44 # define ONESDK_CALL __stdcall
45 #else
46 # define ONESDK_CALL
47 #endif
48 
49 /* Macros for function visibility */
50 
52 #if defined(ONESDK_BUILD_LIBRARY)
53 # if defined(_WIN32)
54 # if defined(ONESDK_SHARED)
55 # define ONESDK_EXPORT __declspec(dllexport)
56 # else
57 # define ONESDK_EXPORT
58 # endif
59 # elif defined(_AIX)
60 # define ONESDK_EXPORT
61 # elif defined(__GNUC__) && ((__GNUC__ + 0) >= 4)
62 # if defined(ONESDK_SHARED)
63 # define ONESDK_EXPORT __attribute__((visibility("default")))
64 # else
65 # define ONESDK_EXPORT
66 # endif
67 # else
68 # define ONESDK_EXPORT
69 # endif
70 #else
71 # define ONESDK_EXPORT
72 #endif
73 
75 #if defined(_WIN32)
76 # define ONESDK_HIDDEN
77 #elif defined(_AIX)
78 # define ONESDK_HIDDEN
79 #elif defined(__GNUC__) && ((__GNUC__ + 0) >= 4)
80 # define ONESDK_HIDDEN __attribute__((visibility("hidden")))
81 #else
82 # define ONESDK_HIDDEN
83 #endif
84 
85 /* Macros for uniform external linkage specifications in C and C++ */
86 
87 #if defined(__cplusplus)
88 # define ONESDK_DECLARE_EXTERN_C extern "C"
89 # define ONESDK_DEFINE_EXTERN_C extern "C"
90 #else
91 # define ONESDK_DECLARE_EXTERN_C extern
92 # define ONESDK_DEFINE_EXTERN_C
93 #endif
94 
95 /* Macros for inline functions */
96 
98 #if defined(ONESDK_ATTRIBUTE_UNUSED)
99 /* OK, allow user to define this, in case our definition doesn't work with their compiler */
100 #elif defined(__GNUC__) && (__GNUC__ >= 4)
101 # define ONESDK_ATTRIBUTE_UNUSED __attribute__((__unused__))
102 #elif defined(__clang__)
103 # define ONESDK_ATTRIBUTE_UNUSED __attribute__((__unused__))
104 #else
105 # define ONESDK_ATTRIBUTE_UNUSED
106 #endif
107 
109 #if defined(ONESDK_INLINE)
110 /* OK, allow user to define this, in case our definition doesn't work with their compiler */
111 #elif defined(__cplusplus)
112 # define ONESDK_INLINE inline
113 #elif (__STDC_VERSION__ >= 199901L)
114 # define ONESDK_INLINE static inline
115 #elif defined(_MSC_VER) && ((_MSC_VER + 0) >= 1900) && !defined(_BullseyeCoverage)
116 # define ONESDK_INLINE static inline
117 #else
118 # define ONESDK_INLINE static
119 #endif
120 
121 /* Macros for declaring and defining functions */
122 
124 #define ONESDK_DECLARE_FUNCTION(return_type) ONESDK_DECLARE_EXTERN_C ONESDK_EXPORT return_type ONESDK_CALL
125 
126 #define ONESDK_DECLARE_INTERNAL_FUNCTION(return_type) ONESDK_DECLARE_EXTERN_C ONESDK_HIDDEN return_type ONESDK_CALL
127 
128 #define ONESDK_DEFINE_INLINE_FUNCTION(return_type) ONESDK_INLINE return_type ONESDK_ATTRIBUTE_UNUSED
129 
130 /*========================================================================================================================================*/
131 
132 /* Macros for endianness */
133 
134 #if defined(ONESDK_LITTLE_ENDIAN) || defined(ONESDK_BIG_ENDIAN)
135 /* OK, allow user to define this, in case our detection code doesn't work with their compiler */
136 #else
137 /* Try to detect endianness. */
138 /* Check for little endian... (yes, we could mash all this into one big expression, but it's confusing enough as it is) */
139 # if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && ((__BYTE_ORDER + 0) == (__LITTLE_ENDIAN + 0))
140 # define ONESDK_LITTLE_ENDIAN
141 # elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && ((__BYTE_ORDER__ + 0) == (__ORDER_LITTLE_ENDIAN__ + 0))
142 # define ONESDK_LITTLE_ENDIAN
143 # elif (defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || (defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN))
144 # define ONESDK_LITTLE_ENDIAN
145 # elif defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__)
146 # define ONESDK_LITTLE_ENDIAN
147 # elif defined(__i386__) || defined(__i386) || defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || defined(__amd64) || defined(_X86_) || defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64) || defined(__THW_INTEL__)
148 # define ONESDK_LITTLE_ENDIAN
149 # endif
150 /* Check for big endian... */
151 # if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && ((__BYTE_ORDER + 0) == (__BIG_ENDIAN + 0))
152 # define ONESDK_BIG_ENDIAN
153 # elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && ((__BYTE_ORDER__ + 0) == (__ORDER_BIG_ENDIAN__ + 0))
154 # define ONESDK_BIG_ENDIAN
155 # elif (defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)) || (defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN))
156 # define ONESDK_BIG_ENDIAN
157 # elif defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)
158 # define ONESDK_BIG_ENDIAN
159 # elif defined(__sparc__) || defined(__sparc)
160 # define ONESDK_BIG_ENDIAN
161 # elif defined(__s390__) || defined(__s390x__) || defined(__MVS__) || defined(__TOS_MVS__)
162 # define ONESDK_BIG_ENDIAN
163 # endif
164 #endif
165 
166 /* Make sure we didn't end up with both, little _and_ big endian. */
167 #if defined(ONESDK_LITTLE_ENDIAN) && defined(ONESDK_BIG_ENDIAN)
168 # error ONESDK_LITTLE_ENDIAN and ONESDK_BIG_ENDIAN defined at the same time.
169 #endif
170 
171 /*========================================================================================================================================*/
172 
178 #if defined(_WIN32)
179 typedef uint32_t onesdk_result_t;
180 #else
181 typedef int32_t onesdk_result_t;
182 #endif
183 
200 #if defined(_WIN32)
201 # define ONESDK_ERROR_BASE ((onesdk_result_t) 0xAFFE0000)
202 #else
203 # define ONESDK_ERROR_BASE ((onesdk_result_t)-0x50020000) // = same bit pattern as 0xAFFE0000
204 #endif
205 
206 /*========================================================================================================================================*/
207 
213 typedef int32_t onesdk_bool_t;
215 typedef int32_t onesdk_int32_t;
216 typedef int64_t onesdk_int64_t;
217 typedef uint32_t onesdk_uint32_t;
218 typedef uint64_t onesdk_uint64_t;
220 typedef size_t onesdk_size_t;
224 /*========================================================================================================================================*/
225 
227 #if defined(ONESDK_BUILD_DOC)
228 typedef char_or_wchar_t onesdk_xchar_t;
229 #elif defined(_WIN32)
230 typedef wchar_t onesdk_xchar_t;
231 #else
232 typedef char onesdk_xchar_t;
233 #endif
234 
236 #if defined(_WIN32)
237 # define ONESDK_XSTR_PRI_STR L"S"
238 #else
239 # define ONESDK_XSTR_PRI_STR "s"
240 #endif
241 
243 #if defined(_WIN32)
244 # define ONESDK_STR_PRI_XSTR "S"
245 #else
246 # define ONESDK_STR_PRI_XSTR "s"
247 #endif
248 
250 #if defined(_WIN32)
251 # define ONESDK_XSTR_IMPL(str) L ## str
252 #else
253 # define ONESDK_XSTR_IMPL(str) str
254 #endif
255 
257 #define ONESDK_XSTR(str) ONESDK_XSTR_IMPL(str)
258 
259 /*========================================================================================================================================*/
260 
261 #endif /* ONESDK_CONFIG_H_INCLUDED */
262 
uint32_t onesdk_uint32_t
Unsigned 32 bit integer.
Definition: onesdk_config.h:217
int64_t onesdk_int64_t
Signed 64 bit integer.
Definition: onesdk_config.h:216
int32_t onesdk_result_t
Type for result codes of the SDK stub.
Definition: onesdk_config.h:181
int32_t onesdk_bool_t
Type for boolean values. Zero means false, any non-zero value means true.
Definition: onesdk_config.h:213
char_or_wchar_t onesdk_xchar_t
The native character type of the operating system. wchar_t for Windows and char for other systems...
Definition: onesdk_config.h:228
uint64_t onesdk_uint64_t
Unsigned 64 bit integer.
Definition: onesdk_config.h:218
int32_t onesdk_int32_t
Signed 32 bit integer.
Definition: onesdk_config.h:215
size_t onesdk_size_t
Unsigned integer type used for sizes (e.g. array sizes) and counts.
Definition: onesdk_config.h:220