ua_config.h.in 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #ifndef UA_CONFIG_H_
  2. #define UA_CONFIG_H_
  3. #ifndef _XOPEN_SOURCE
  4. # define _XOPEN_SOURCE 500
  5. # define _DEFAULT_SOURCE
  6. #endif
  7. #define UA_LOGLEVEL ${UA_LOGLEVEL}
  8. #cmakedefine UA_ENABLE_MULTITHREADING
  9. #cmakedefine UA_ENABLE_METHODCALLS
  10. #cmakedefine UA_ENABLE_SUBSCRIPTIONS
  11. #cmakedefine UA_ENABLE_TYPENAMES
  12. #cmakedefine UA_ENABLE_EMBEDDED_LIBC
  13. #cmakedefine UA_ENABLE_GENERATE_NAMESPACE0
  14. #cmakedefine UA_ENABLE_EXTERNAL_NAMESPACES
  15. #cmakedefine UA_ENABLE_NODEMANAGEMENT
  16. #cmakedefine UA_ENABLE_NONSTANDARD_UDP
  17. #cmakedefine UA_ENABLE_NONSTANDARD_STATELESS
  18. /**
  19. * Function Export
  20. * --------------- */
  21. #ifdef _WIN32
  22. # ifdef UA_DYNAMIC_LINKING
  23. # ifdef __GNUC__
  24. # define UA_EXPORT __attribute__ ((dllexport))
  25. # else
  26. # define UA_EXPORT __declspec(dllexport)
  27. # endif
  28. # else
  29. # ifdef __GNUC__
  30. # define UA_EXPORT __attribute__ ((dllexport))
  31. # else
  32. # define UA_EXPORT __declspec(dllimport)
  33. # endif
  34. # endif
  35. #else
  36. # if __GNUC__ || __clang__
  37. # define UA_EXPORT __attribute__ ((visibility ("default")))
  38. # else
  39. # define UA_EXPORT
  40. # endif
  41. #endif
  42. /**
  43. * Inline Functions
  44. * ---------------- */
  45. #ifdef _MSC_VER
  46. # define UA_INLINE __inline
  47. #else
  48. # define UA_INLINE inline
  49. #endif
  50. /**
  51. * Non-aliasing pointers
  52. * -------------------- */
  53. #ifdef _MSC_VER
  54. # define UA_RESTRICT __restrict
  55. #elif defined(__GNUC__)
  56. # define UA_RESTRICT __restrict__
  57. #else
  58. # define UA_RESTRICT restrict
  59. #endif
  60. /**
  61. * Function attributes
  62. * ------------------- */
  63. #ifdef __GNUC__
  64. # define UA_FUNC_ATTR_MALLOC __attribute__((malloc))
  65. # define UA_FUNC_ATTR_PURE __attribute__ ((pure))
  66. # define UA_FUNC_ATTR_CONST __attribute__((const))
  67. # define UA_FUNC_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
  68. #else
  69. # define UA_FUNC_ATTR_MALLOC
  70. # define UA_FUNC_ATTR_PURE
  71. # define UA_FUNC_ATTR_CONST
  72. # define UA_FUNC_ATTR_WARN_UNUSED_RESULT
  73. #endif
  74. /**
  75. * Integer Endianness
  76. * ------------------ */
  77. #if defined(__LITTLE_ENDIAN__) || defined(_WIN32) || (!defined(__ANDROID__) && BYTE_ORDER == ORDER_LITTLE_ENDIAN)
  78. # define htole16(x) (x)
  79. # define htole32(x) (x)
  80. # define htole64(x) (x)
  81. # define le16toh(x) (x)
  82. # define le32toh(x) (x)
  83. # define le64toh(x) (x)
  84. #else
  85. # if defined(__ANDROID__)
  86. # include <endian.h>
  87. # define le16toh(x) letoh16(x)
  88. # define le32toh(x) letoh32(x)
  89. # define le64toh(x) letoh64(x)
  90. # elif defined(__linux__)
  91. # include <endian.h>
  92. # elif defined(__OpenBSD__)
  93. # include <sys/endian.h>
  94. # elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
  95. # include <sys/endian.h>
  96. # define le16toh(x) letoh16(x)
  97. # define le32toh(x) letoh32(x)
  98. # define le64toh(x) letoh64(x)
  99. # elif defined(__APPLE__)
  100. # include <libkern/OSByteOrder.h>
  101. # define htole16(x) OSSwapHostToLittleInt16(x)
  102. # define htole32(x) OSSwapHostToLittleInt32(x)
  103. # define htole64(x) OSSwapHostToLittleInt64(x)
  104. # define le16toh(x) OSSwapLittleToHostInt16(x)
  105. # define le32toh(x) OSSwapLittleToHostInt32(x)
  106. # define le64toh(x) OSSwapLittleToHostInt64(x)
  107. # define __BYTE_ORDER BYTE_ORDER
  108. # elif defined(__QNX__) || defined(__QNXNTO__)
  109. # include <gulliver.h>
  110. # define htole16(x) ENDIAN_LE16(x)
  111. # define htole32(x) ENDIAN_LE32(x)
  112. # define htole64(x) ENDIAN_LE64(x)
  113. # define le16toh(x) ENDIAN_LE16(x)
  114. # define le32toh(x) ENDIAN_LE32(x)
  115. # define le64toh(x) ENDIAN_LE64(x)
  116. # else
  117. # define UA_ENCODING_INTEGER_GENERIC
  118. # warning No native function for endianness conversion available. Use a slow generic conversion.
  119. # endif
  120. #endif
  121. /**
  122. * Float Endianness
  123. * ---------------- */
  124. #if !defined(_WIN32)
  125. # if !defined(__FLOAT_WORD_ORDER__) || !defined(__BYTE_ORDER__) || \
  126. !defined(__ORDER_LITTLE_ENDIAN__) || !defined(__ORDER_BIG_ENDIAN__)
  127. # define UA_ENCODING_FLOAT_GENERIC
  128. # warning Unknown float representation. Use a slow manual IEEE 754 conversion.
  129. # else
  130. # if !(((__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__)) || \
  131. ((__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__)))
  132. # if ((__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__)) || \
  133. ((__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__))
  134. # define UA_ENCODING_FLOAT_SWAP
  135. # else
  136. # define UA_ENCODING_FLOAT_GENERIC
  137. # warning Unknown float representation. Use a slow manual IEEE 754 conversion.
  138. # endif
  139. # endif
  140. # endif
  141. #endif
  142. /**
  143. * Embed unavailable libc functions
  144. * -------------------------------- */
  145. #include <stddef.h>
  146. #ifdef UA_ENABLE_EMBEDDED_LIBC
  147. void *memcpy(void *UA_RESTRICT dest, const void *UA_RESTRICT src, size_t n);
  148. void *memset(void *dest, int c, size_t n);
  149. size_t strlen(const char *s);
  150. int memcmp(const void *vl, const void *vr, size_t n);
  151. #else
  152. # include <string.h>
  153. #endif
  154. #endif /* UA_CONFIG_H_ */