ua_config.h.in 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. #ifndef _XOPEN_SOURCE
  21. # define _XOPEN_SOURCE 500
  22. #endif
  23. #ifndef _DEFAULT_SOURCE
  24. # define _DEFAULT_SOURCE
  25. #endif
  26. #define UA_LOGLEVEL ${UA_LOGLEVEL}
  27. #define UA_GIT_COMMIT_ID "${GIT_COMMIT_ID}"
  28. #cmakedefine UA_ENABLE_MULTITHREADING
  29. #cmakedefine UA_ENABLE_METHODCALLS
  30. #cmakedefine UA_ENABLE_SUBSCRIPTIONS
  31. #cmakedefine UA_ENABLE_DISCOVERY
  32. #cmakedefine UA_ENABLE_TYPENAMES
  33. #cmakedefine UA_ENABLE_GENERATE_NAMESPACE0
  34. #cmakedefine UA_ENABLE_EXTERNAL_NAMESPACES
  35. #cmakedefine UA_ENABLE_NODEMANAGEMENT
  36. #cmakedefine UA_ENABLE_EMBEDDED_LIBC
  37. #cmakedefine UA_ENABLE_NONSTANDARD_UDP
  38. #cmakedefine UA_ENABLE_NONSTANDARD_STATELESS
  39. /**
  40. * Function Export
  41. * --------------- */
  42. /* On Win32: Define UA_DYNAMIC_LINKING and UA_DYNAMIC_LINKING_EXPORT in order to
  43. export symbols for a DLL. Define UA_DYNAMIC_LINKING only to import symbols
  44. from a DLL.*/
  45. #cmakedefine UA_DYNAMIC_LINKING
  46. #if defined(_WIN32) && defined(UA_DYNAMIC_LINKING)
  47. # ifdef UA_DYNAMIC_LINKING_EXPORT /* export dll */
  48. # ifdef __GNUC__
  49. # define UA_EXPORT __attribute__ ((dllexport))
  50. # else
  51. # define UA_EXPORT __declspec(dllexport)
  52. # endif
  53. # else /* import dll */
  54. # ifdef __GNUC__
  55. # define UA_EXPORT __attribute__ ((dllimport))
  56. # else
  57. # define UA_EXPORT __declspec(dllimport)
  58. # endif
  59. # endif
  60. #else /* non win32 */
  61. # if __GNUC__ || __clang__
  62. # define UA_EXPORT __attribute__ ((visibility ("default")))
  63. # endif
  64. #endif
  65. #ifndef UA_EXPORT
  66. # define UA_EXPORT /* fallback to default */
  67. #endif
  68. /**
  69. * Inline Functions
  70. * ---------------- */
  71. #ifdef _MSC_VER
  72. # define UA_INLINE __inline
  73. #else
  74. # define UA_INLINE inline
  75. #endif
  76. /**
  77. * Non-aliasing pointers
  78. * -------------------- */
  79. #ifdef _MSC_VER
  80. # define UA_RESTRICT __restrict
  81. #elif defined(__GNUC__)
  82. # define UA_RESTRICT __restrict__
  83. #else
  84. # define UA_RESTRICT restrict
  85. #endif
  86. /**
  87. * Function attributes
  88. * ------------------- */
  89. #ifdef __GNUC__
  90. # define UA_FUNC_ATTR_MALLOC __attribute__((malloc))
  91. # define UA_FUNC_ATTR_PURE __attribute__ ((pure))
  92. # define UA_FUNC_ATTR_CONST __attribute__((const))
  93. # define UA_FUNC_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
  94. #else
  95. # define UA_FUNC_ATTR_MALLOC
  96. # define UA_FUNC_ATTR_PURE
  97. # define UA_FUNC_ATTR_CONST
  98. # define UA_FUNC_ATTR_WARN_UNUSED_RESULT
  99. #endif
  100. /**
  101. * Binary Encoding Overlays
  102. * ------------------------
  103. * Integers and floating point numbers are transmitted in little-endian (IEE 754
  104. * for floating point) encoding. If the target architecture uses the same
  105. * format, numeral datatypes can be memcpy'd (overlayed) on the binary stream.
  106. * This speeds up encoding.
  107. *
  108. * Integer Endianness
  109. * ^^^^^^^^^^^^^^^^^^ */
  110. #if defined(_WIN32) || (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
  111. (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) /* little endian detected */
  112. # define UA_BINARY_OVERLAYABLE_INTEGER true
  113. #elif defined(__ANDROID__) /* Andoid */
  114. # include <endian.h>
  115. # if __BYTE_ORDER == __LITTLE_ENDIAN
  116. # define UA_BINARY_OVERLAYABLE_INTEGER true
  117. # endif
  118. #elif defined(__linux__) /* Linux */
  119. # include <endian.h>
  120. # if __BYTE_ORDER == __LITTLE_ENDIAN
  121. # define UA_BINARY_OVERLAYABLE_INTEGER true
  122. # endif
  123. # if __FLOAT_BYTE_ORDER == __LITTLE_ENDIAN
  124. # define UA_BINARY_OVERLAYABLE_FLOAT true
  125. # endif
  126. #elif defined(__OpenBSD__) /* OpenBSD */
  127. # include <sys/endian.h>
  128. # if BYTE_ORDER == LITTLE_ENDIAN
  129. # define UA_BINARY_OVERLAYABLE_INTEGER true
  130. # endif
  131. #elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) /* Other BSD */
  132. # include <sys/endian.h>
  133. # if _BYTE_ORDER == _LITTLE_ENDIAN
  134. # define UA_BINARY_OVERLAYABLE_INTEGER true
  135. # endif
  136. #elif defined(__APPLE__) /* Apple (MacOS, iOS) */
  137. # include <libkern/OSByteOrder.h>
  138. # if defined(__LITTLE_ENDIAN__)
  139. # define UA_BINARY_OVERLAYABLE_INTEGER true
  140. # endif
  141. #elif defined(__QNX__) || defined(__QNXNTO__) /* QNX */
  142. # include <gulliver.h>
  143. # if defined(__LITTLEENDIAN__)
  144. # define UA_BINARY_OVERLAYABLE_INTEGER true
  145. # endif
  146. #endif
  147. #ifndef UA_BINARY_OVERLAYABLE_INTEGER
  148. # define UA_BINARY_OVERLAYABLE_INTEGER false
  149. #endif
  150. /**
  151. * Float Endianness
  152. * ^^^^^^^^^^^^^^^^ */
  153. #if defined(_WIN32)
  154. # define UA_BINARY_OVERLAYABLE_FLOAT true
  155. #elif defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
  156. (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__) /* Defined only in GCC */
  157. # define UA_BINARY_OVERLAYABLE_FLOAT true
  158. #elif defined(__FLOAT_WORD_ORDER) && defined(__LITTLE_ENDIAN) && \
  159. (__FLOAT_WORD_ORDER == __LITTLE_ENDIAN) /* Defined only in GCC */
  160. # define UA_BINARY_OVERLAYABLE_FLOAT true
  161. #endif
  162. #ifndef UA_BINARY_OVERLAYABLE_FLOAT
  163. # define UA_BINARY_OVERLAYABLE_FLOAT false
  164. #endif
  165. /**
  166. * Embed unavailable libc functions
  167. * -------------------------------- */
  168. #include <stddef.h>
  169. #ifdef UA_ENABLE_EMBEDDED_LIBC
  170. void *memcpy(void *UA_RESTRICT dest, const void *UA_RESTRICT src, size_t n);
  171. void *memset(void *dest, int c, size_t n);
  172. size_t strlen(const char *s);
  173. int memcmp(const void *vl, const void *vr, size_t n);
  174. #else
  175. # include <string.h>
  176. #endif
  177. #ifdef __cplusplus
  178. } // extern "C"
  179. #endif
  180. #endif /* UA_CONFIG_H_ */