ua_config.h.in 6.2 KB

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