ua_config.h.in 7.1 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_NONSTANDARD_STATELESS
  34. #cmakedefine UA_ENABLE_NONSTANDARD_UDP
  35. /**
  36. * Standard Includes
  37. * ----------------- */
  38. #ifndef _XOPEN_SOURCE
  39. # define _XOPEN_SOURCE 500
  40. #endif
  41. #ifndef _DEFAULT_SOURCE
  42. # define _DEFAULT_SOURCE
  43. #endif
  44. #include <stddef.h>
  45. /* Include stdint.h or workaround for older Visual Studios */
  46. #if !defined(_MSC_VER) || _MSC_VER >= 1600
  47. # include <stdint.h>
  48. #else
  49. # include "ms_stdint.h"
  50. #endif
  51. #ifndef __cplusplus
  52. # include <stdbool.h> /* C99 Boolean */
  53. /* Manual Boolean:
  54. typedef uint8_t bool;
  55. #define true 1
  56. #define false 0 */
  57. #endif
  58. #include <stdlib.h>
  59. /**
  60. * Memory Management
  61. * ---------------
  62. * The default malloc implementation from ``stdlib.h`` is used internally.
  63. * Override if required. */
  64. #if defined(_WIN32) && !defined(__clang__)
  65. # include <malloc.h>
  66. #endif
  67. #define UA_free(ptr) free(ptr)
  68. #define UA_malloc(size) malloc(size)
  69. #define UA_calloc(num, size) calloc(num, size)
  70. #define UA_realloc(ptr, size) realloc(ptr, size)
  71. #if defined(__GNUC__) || defined(__clang__)
  72. # define UA_alloca(size) __builtin_alloca (size)
  73. #elif defined(_WIN32)
  74. # define UA_alloca(SIZE) _alloca(SIZE)
  75. #else
  76. # include <alloca.h>
  77. # define UA_alloca(SIZE) alloca(SIZE)
  78. #endif
  79. /**
  80. * Function Export
  81. * ---------------
  82. * On Win32: Define ``UA_DYNAMIC_LINKING`` and ``UA_DYNAMIC_LINKING_EXPORT`` in
  83. * order to export symbols for a DLL. Define ``UA_DYNAMIC_LINKING`` only to
  84. * import symbols from a DLL.*/
  85. #cmakedefine UA_DYNAMIC_LINKING
  86. #if defined(_WIN32) && defined(UA_DYNAMIC_LINKING)
  87. # ifdef UA_DYNAMIC_LINKING_EXPORT /* export dll */
  88. # ifdef __GNUC__
  89. # define UA_EXPORT __attribute__ ((dllexport))
  90. # else
  91. # define UA_EXPORT __declspec(dllexport)
  92. # endif
  93. # else /* import dll */
  94. # ifdef __GNUC__
  95. # define UA_EXPORT __attribute__ ((dllimport))
  96. # else
  97. # define UA_EXPORT __declspec(dllimport)
  98. # endif
  99. # endif
  100. #else /* non win32 */
  101. # if __GNUC__ || __clang__
  102. # define UA_EXPORT __attribute__ ((visibility ("default")))
  103. # endif
  104. #endif
  105. #ifndef UA_EXPORT
  106. # define UA_EXPORT /* fallback to default */
  107. #endif
  108. /**
  109. * Inline Functions
  110. * ---------------- */
  111. #ifdef _MSC_VER
  112. # define UA_INLINE __inline
  113. #else
  114. # define UA_INLINE inline
  115. #endif
  116. /**
  117. * Non-aliasing pointers
  118. * -------------------- */
  119. #ifdef _MSC_VER
  120. # define UA_RESTRICT __restrict
  121. #elif defined(__GNUC__)
  122. # define UA_RESTRICT __restrict__
  123. #else
  124. # define UA_RESTRICT restrict
  125. #endif
  126. /**
  127. * Function attributes
  128. * ------------------- */
  129. #ifdef __GNUC__
  130. # define UA_FUNC_ATTR_MALLOC __attribute__((malloc))
  131. # define UA_FUNC_ATTR_PURE __attribute__ ((pure))
  132. # define UA_FUNC_ATTR_CONST __attribute__((const))
  133. # define UA_FUNC_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
  134. #else
  135. # define UA_FUNC_ATTR_MALLOC
  136. # define UA_FUNC_ATTR_PURE
  137. # define UA_FUNC_ATTR_CONST
  138. # define UA_FUNC_ATTR_WARN_UNUSED_RESULT
  139. #endif
  140. /**
  141. * String Manipulation
  142. * -------------------
  143. * The header ``string.h`` is defined in the C-standard. If no libc is provided
  144. * (e.g. on some embedded target), use the following definitions and the
  145. * implementation in ``/deps/libc_string.c`` */
  146. #ifndef UA_ENABLE_EMBEDDED_LIBC
  147. # include <string.h>
  148. #else
  149. void *memcpy(void *UA_RESTRICT dest, const void *UA_RESTRICT src, size_t n);
  150. void *memset(void *dest, int c, size_t n);
  151. size_t strlen(const char *s);
  152. int memcmp(const void *vl, const void *vr, size_t n);
  153. #endif
  154. /**
  155. * Binary Encoding Overlays
  156. * ------------------------
  157. * Integers and floating point numbers are transmitted in little-endian (IEEE 754
  158. * for floating point) encoding. If the target architecture uses the same
  159. * format, numeral datatypes can be memcpy'd (overlayed) on the binary stream.
  160. * This speeds up encoding.
  161. *
  162. * Integer Endianness
  163. * ^^^^^^^^^^^^^^^^^^
  164. * The definition ``UA_BINARY_OVERLAYABLE_INTEGER`` is true when the integer
  165. * representation of the target architecture is little-endian. */
  166. #if defined(_WIN32) || (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
  167. (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
  168. # define UA_BINARY_OVERLAYABLE_INTEGER true
  169. #elif defined(__ANDROID__) /* Andoid */
  170. # include <endian.h>
  171. # if __BYTE_ORDER == __LITTLE_ENDIAN
  172. # define UA_BINARY_OVERLAYABLE_INTEGER true
  173. # endif
  174. #elif defined(__linux__) /* Linux */
  175. # include <endian.h>
  176. # if __BYTE_ORDER == __LITTLE_ENDIAN
  177. # define UA_BINARY_OVERLAYABLE_INTEGER true
  178. # endif
  179. # if __FLOAT_BYTE_ORDER == __LITTLE_ENDIAN
  180. # define UA_BINARY_OVERLAYABLE_FLOAT true
  181. # endif
  182. #elif defined(__OpenBSD__) /* OpenBSD */
  183. # include <sys/endian.h>
  184. # if BYTE_ORDER == LITTLE_ENDIAN
  185. # define UA_BINARY_OVERLAYABLE_INTEGER true
  186. # endif
  187. #elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) /* Other BSD */
  188. # include <sys/endian.h>
  189. # if _BYTE_ORDER == _LITTLE_ENDIAN
  190. # define UA_BINARY_OVERLAYABLE_INTEGER true
  191. # endif
  192. #elif defined(__APPLE__) /* Apple (MacOS, iOS) */
  193. # include <libkern/OSByteOrder.h>
  194. # if defined(__LITTLE_ENDIAN__)
  195. # define UA_BINARY_OVERLAYABLE_INTEGER true
  196. # endif
  197. #elif defined(__QNX__) || defined(__QNXNTO__) /* QNX */
  198. # include <gulliver.h>
  199. # if defined(__LITTLEENDIAN__)
  200. # define UA_BINARY_OVERLAYABLE_INTEGER true
  201. # endif
  202. #endif
  203. #ifndef UA_BINARY_OVERLAYABLE_INTEGER
  204. # define UA_BINARY_OVERLAYABLE_INTEGER false
  205. #endif
  206. /**
  207. * Float Endianness
  208. * ^^^^^^^^^^^^^^^^
  209. * The definition ``UA_BINARY_OVERLAYABLE_FLOAT`` is true when the floating
  210. * point number representation of the target architecture is IEEE 754. Note that
  211. * this cannot be reliable detected with macros for the clang compiler
  212. * (beginning of 2017). Just override if necessary. */
  213. #if defined(_WIN32)
  214. # define UA_BINARY_OVERLAYABLE_FLOAT true
  215. #elif defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
  216. (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__) /* Defined only in GCC */
  217. # define UA_BINARY_OVERLAYABLE_FLOAT true
  218. #elif defined(__FLOAT_WORD_ORDER) && defined(__LITTLE_ENDIAN) && \
  219. (__FLOAT_WORD_ORDER == __LITTLE_ENDIAN) /* Defined only in GCC */
  220. # define UA_BINARY_OVERLAYABLE_FLOAT true
  221. #endif
  222. #ifndef UA_BINARY_OVERLAYABLE_FLOAT
  223. # define UA_BINARY_OVERLAYABLE_FLOAT false
  224. #endif
  225. #ifdef __cplusplus
  226. } // extern "C"
  227. #endif
  228. #endif /* UA_CONFIG_H_ */