ua_config.h.in 6.9 KB

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