ua_config.h.in 6.4 KB

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