ua_config.h.in 6.8 KB

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