ua_config.h.in 6.9 KB

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