ua_config.h.in 6.4 KB

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