ua_config.h.in 5.6 KB

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