ua_config.h.in 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #ifndef UA_CONFIG_H_
  5. #define UA_CONFIG_H_
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. /**
  10. * Library Version
  11. * --------------- */
  12. #define UA_OPEN62541_VER_MAJOR ${OPEN62541_VER_MAJOR}
  13. #define UA_OPEN62541_VER_MINOR ${OPEN62541_VER_MINOR}
  14. #define UA_OPEN62541_VER_PATCH ${OPEN62541_VER_PATCH}
  15. #define UA_OPEN62541_VER_LABEL "${OPEN62541_VER_LABEL}" /* Release candidate label, etc. */
  16. #define UA_OPEN62541_VER_COMMIT "${OPEN62541_VER_COMMIT}"
  17. /**
  18. * Options
  19. * ------- */
  20. #define UA_LOGLEVEL ${UA_LOGLEVEL}
  21. #cmakedefine UA_ENABLE_METHODCALLS
  22. #cmakedefine UA_ENABLE_NODEMANAGEMENT
  23. #cmakedefine UA_ENABLE_SUBSCRIPTIONS
  24. #cmakedefine UA_ENABLE_MULTITHREADING
  25. /**
  26. * Advanced Options
  27. * ---------------- */
  28. #cmakedefine UA_ENABLE_STATUSCODE_DESCRIPTIONS
  29. #cmakedefine UA_ENABLE_TYPENAMES
  30. #cmakedefine UA_ENABLE_EMBEDDED_LIBC
  31. #cmakedefine UA_ENABLE_DETERMINISTIC_RNG
  32. #cmakedefine UA_ENABLE_GENERATE_NAMESPACE0
  33. #cmakedefine UA_ENABLE_EXTERNAL_NAMESPACES
  34. #cmakedefine UA_ENABLE_NONSTANDARD_STATELESS
  35. #cmakedefine UA_ENABLE_NONSTANDARD_UDP
  36. #cmakedefine UA_ENABLE_DISCOVERY
  37. #cmakedefine UA_ENABLE_DISCOVERY_MULTICAST
  38. #cmakedefine UA_ENABLE_DISCOVERY_SEMAPHORE
  39. /**
  40. * Standard Includes
  41. * ----------------- */
  42. #ifndef _XOPEN_SOURCE
  43. #if defined(__QNX__) || defined(__QNXNTO__)
  44. # define _XOPEN_SOURCE 600
  45. #else
  46. # define _XOPEN_SOURCE 500
  47. #endif
  48. #endif
  49. #ifndef _DEFAULT_SOURCE
  50. # define _DEFAULT_SOURCE
  51. #endif
  52. // On older systems we need to define _BSD_SOURCE
  53. // _DEFAULT_SOURCE is an alias for that
  54. #ifndef _BSD_SOURCE
  55. # define _BSD_SOURCE
  56. #endif
  57. // Disable deprecation warnings for sprintf, strncpy, strerror
  58. #ifdef _MSC_VER
  59. # define _CRT_SECURE_NO_WARNINGS
  60. #endif
  61. #include <stddef.h>
  62. #include "ms_stdint.h" /* Includes stdint.h or workaround for older Visual Studios */
  63. #ifndef __cplusplus
  64. # include <stdbool.h> /* C99 Boolean */
  65. /* Manual Boolean:
  66. typedef uint8_t bool;
  67. #define true 1
  68. #define false 0 */
  69. #endif
  70. /* Manually define some function on libc */
  71. #ifndef UA_ENABLE_EMBEDDED_LIBC
  72. # include <string.h>
  73. #else
  74. void *memcpy(void *UA_RESTRICT dest, const void *UA_RESTRICT src, size_t n);
  75. void *memset(void *dest, int c, size_t n);
  76. size_t strlen(const char *s);
  77. int memcmp(const void *vl, const void *vr, size_t n);
  78. #endif
  79. /* Memory Management */
  80. #include <stdlib.h>
  81. #ifdef _WIN32
  82. # ifndef __clang__
  83. # include <malloc.h>
  84. # endif
  85. #endif
  86. #define UA_free(ptr) free(ptr)
  87. #define UA_malloc(size) malloc(size)
  88. #define UA_calloc(num, size) calloc(num, size)
  89. #define UA_realloc(ptr, size) realloc(ptr, size)
  90. #ifndef NO_ALLOCA
  91. # if defined(__GNUC__) || defined(__clang__)
  92. # define UA_alloca(size) __builtin_alloca (size)
  93. # elif defined(_WIN32)
  94. # define UA_alloca(SIZE) _alloca(SIZE)
  95. # else
  96. # include <alloca.h>
  97. # define UA_alloca(SIZE) alloca(SIZE)
  98. # endif
  99. #endif
  100. /**
  101. * Function Export
  102. * ---------------
  103. * On Win32: Define ``UA_DYNAMIC_LINKING`` and ``UA_DYNAMIC_LINKING_EXPORT`` in
  104. * order to export symbols for a DLL. Define ``UA_DYNAMIC_LINKING`` only to
  105. * import symbols from a DLL.*/
  106. #cmakedefine UA_DYNAMIC_LINKING
  107. #if defined(_WIN32) && defined(UA_DYNAMIC_LINKING)
  108. # ifdef UA_DYNAMIC_LINKING_EXPORT /* export dll */
  109. # ifdef __GNUC__
  110. # define UA_EXPORT __attribute__ ((dllexport))
  111. # else
  112. # define UA_EXPORT __declspec(dllexport)
  113. # endif
  114. # else /* import dll */
  115. # ifdef __GNUC__
  116. # define UA_EXPORT __attribute__ ((dllimport))
  117. # else
  118. # define UA_EXPORT __declspec(dllimport)
  119. # endif
  120. # endif
  121. #else /* non win32 */
  122. # if __GNUC__ || __clang__
  123. # define UA_EXPORT __attribute__ ((visibility ("default")))
  124. # endif
  125. #endif
  126. #ifndef UA_EXPORT
  127. # define UA_EXPORT /* fallback to default */
  128. #endif
  129. /**
  130. * Inline Functions
  131. * ---------------- */
  132. #ifdef _MSC_VER
  133. # define UA_INLINE __inline
  134. #else
  135. # define UA_INLINE inline
  136. #endif
  137. /**
  138. * Non-aliasing pointers
  139. * -------------------- */
  140. #ifdef _MSC_VER
  141. # define UA_RESTRICT __restrict
  142. #elif defined(__GNUC__)
  143. # define UA_RESTRICT __restrict__
  144. #else
  145. # define UA_RESTRICT restrict
  146. #endif
  147. /**
  148. * Function attributes
  149. * ------------------- */
  150. #ifdef __GNUC__
  151. # define UA_FUNC_ATTR_MALLOC __attribute__((malloc))
  152. # define UA_FUNC_ATTR_PURE __attribute__ ((pure))
  153. # define UA_FUNC_ATTR_CONST __attribute__((const))
  154. # define UA_FUNC_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
  155. #else
  156. # define UA_FUNC_ATTR_MALLOC
  157. # define UA_FUNC_ATTR_PURE
  158. # define UA_FUNC_ATTR_CONST
  159. # define UA_FUNC_ATTR_WARN_UNUSED_RESULT
  160. #endif
  161. /**
  162. * Binary Encoding Overlays
  163. * ------------------------
  164. * Integers and floating point numbers are transmitted in little-endian (IEE 754
  165. * for floating point) encoding. If the target architecture uses the same
  166. * format, numeral datatypes can be memcpy'd (overlayed) on the binary stream.
  167. * This speeds up encoding.
  168. *
  169. * Integer Endianness
  170. * ^^^^^^^^^^^^^^^^^^ */
  171. #if defined(_WIN32) || (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
  172. (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
  173. # define UA_BINARY_OVERLAYABLE_INTEGER 1
  174. #elif defined(__ANDROID__) /* Andoid */
  175. # include <endian.h>
  176. # if __BYTE_ORDER == __LITTLE_ENDIAN
  177. # define UA_BINARY_OVERLAYABLE_INTEGER 1
  178. # endif
  179. #elif defined(__linux__) /* Linux */
  180. # include <endian.h>
  181. # if __BYTE_ORDER == __LITTLE_ENDIAN
  182. # define UA_BINARY_OVERLAYABLE_INTEGER 1
  183. # endif
  184. # if __FLOAT_BYTE_ORDER == __LITTLE_ENDIAN
  185. # define UA_BINARY_OVERLAYABLE_FLOAT 1
  186. # endif
  187. #elif defined(__OpenBSD__) /* OpenBSD */
  188. # include <sys/endian.h>
  189. # if BYTE_ORDER == LITTLE_ENDIAN
  190. # define UA_BINARY_OVERLAYABLE_INTEGER 1
  191. # endif
  192. #elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) /* Other BSD */
  193. # include <sys/endian.h>
  194. # if _BYTE_ORDER == _LITTLE_ENDIAN
  195. # define UA_BINARY_OVERLAYABLE_INTEGER 1
  196. # endif
  197. #elif defined(__APPLE__) /* Apple (MacOS, iOS) */
  198. # include <libkern/OSByteOrder.h>
  199. # if defined(__LITTLE_ENDIAN__)
  200. # define UA_BINARY_OVERLAYABLE_INTEGER 1
  201. # endif
  202. #elif defined(__QNX__) || defined(__QNXNTO__) /* QNX */
  203. # include <gulliver.h>
  204. # if defined(__LITTLEENDIAN__)
  205. # define UA_BINARY_OVERLAYABLE_INTEGER 1
  206. # endif
  207. #endif
  208. #ifndef UA_BINARY_OVERLAYABLE_INTEGER
  209. # define UA_BINARY_OVERLAYABLE_INTEGER 0
  210. #endif
  211. /**
  212. * Float Endianness
  213. * ^^^^^^^^^^^^^^^^ */
  214. #if defined(_WIN32)
  215. # define UA_BINARY_OVERLAYABLE_FLOAT 1
  216. #elif defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
  217. (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__) /* Defined only in GCC */
  218. # define UA_BINARY_OVERLAYABLE_FLOAT 1
  219. #elif defined(__FLOAT_WORD_ORDER) && defined(__LITTLE_ENDIAN) && \
  220. (__FLOAT_WORD_ORDER == __LITTLE_ENDIAN) /* Defined only in GCC */
  221. # define UA_BINARY_OVERLAYABLE_FLOAT 1
  222. #endif
  223. #ifndef UA_BINARY_OVERLAYABLE_FLOAT
  224. # define UA_BINARY_OVERLAYABLE_FLOAT 0
  225. #endif
  226. #ifdef __cplusplus
  227. } // extern "C"
  228. #endif
  229. #endif /* UA_CONFIG_H_ */