ua_config.h.in 6.5 KB

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