ua_config.h.in 6.6 KB

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