You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

config.h.in 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. #ifndef RSPAMD_CONFIG_H_IN
  2. #define RSPAMD_CONFIG_H_IN
  3. #cmakedefine BUILD_STATIC 1
  4. #cmakedefine CURL_FOUND 1
  5. #cmakedefine DEBUG_MODE 1
  6. #cmakedefine GIT_VERSION 1
  7. #cmakedefine GLIB_COMPAT 1
  8. #cmakedefine GLIB_HASH_COMPAT 1
  9. #cmakedefine GLIB_RE_COMPAT 1
  10. #cmakedefine GLIB_UNISCRIPT_COMPAT 1
  11. #cmakedefine HAVE_ARPA_INET_H 1
  12. #cmakedefine HAVE_ATOMIC_BUILTINS 1
  13. #cmakedefine HAVE_CLOCK_GETCPUCLOCKID 1
  14. #cmakedefine HAVE_CLOCK_GETTIME 1
  15. #cmakedefine HAVE_CLOCK_PROCESS_CPUTIME_ID 1
  16. #cmakedefine HAVE_CLOCK_VIRTUAL 1
  17. #cmakedefine HAVE_CPUID_H 1
  18. #cmakedefine HAVE_CTYPE_H 1
  19. #cmakedefine HAVE_DIRENT_H 1
  20. #cmakedefine HAVE_DIRFD 1
  21. #cmakedefine HAVE_ENDIAN_H 1
  22. #cmakedefine HAVE_FALLOCATE 1
  23. #cmakedefine HAVE_FCNTL_H 1
  24. #cmakedefine HAVE_FETCH_H 1
  25. #cmakedefine HAVE_FIPS_MODE 1
  26. #cmakedefine HAVE_FLOCK 1
  27. #cmakedefine HAVE_FPATHCONF 1
  28. #cmakedefine HAVE_GETPAGESIZE 1
  29. #cmakedefine HAVE_GLOB_H 1
  30. #cmakedefine HAVE_GRP_H 1
  31. #cmakedefine HAVE_INTTYPES_H 1
  32. #cmakedefine HAVE_IPV6_V6ONLY 1
  33. #cmakedefine HAVE_LIBGEN_H 1
  34. #cmakedefine HAVE_LIBUTIL_H 1
  35. #cmakedefine HAVE_LOCALE_H 1
  36. #cmakedefine HAVE_MACHINE_ENDIAN_H 1
  37. #cmakedefine HAVE_MAXPATHLEN 1
  38. #cmakedefine HAVE_FMEMOPEN 1
  39. #cmakedefine HAVE_MEMRCHR 1
  40. #cmakedefine HAVE_MKSTEMP 1
  41. #cmakedefine HAVE_MMAP_ANON 1
  42. #cmakedefine HAVE_NANOSLEEP 1
  43. #cmakedefine HAVE_NETDB_H 1
  44. #cmakedefine HAVE_NETINET_IN_H 1
  45. #cmakedefine HAVE_NETINET_TCP_H 1
  46. #cmakedefine HAVE_NFTW 1
  47. #cmakedefine HAVE_OCLOEXEC 1
  48. #cmakedefine HAVE_ONOFOLLOW 1
  49. #cmakedefine HAVE_OPENMEMSTREAM 1
  50. #cmakedefine HAVE_PATH_MAX 1
  51. /* OSX has broken JIT support in PCRE, disable it */
  52. #ifndef __APPLE__
  53. #cmakedefine HAVE_PCRE_JIT 1
  54. #cmakedefine HAVE_PCRE_JIT_FAST 1
  55. #endif
  56. #cmakedefine HAVE_PIDFILE 1
  57. #cmakedefine HAVE_PIDFILE_FILENO 1
  58. #cmakedefine HAVE_POLL_H 1
  59. #cmakedefine HAVE_POSIX_FALLOCATE 1
  60. #cmakedefine HAVE_PTHREAD_PROCESS_SHARED 1
  61. #cmakedefine HAVE_PWD_H 1
  62. #cmakedefine HAVE_RDTSC 1
  63. #cmakedefine HAVE_READAHEAD 1
  64. #cmakedefine HAVE_READPASSPHRASE_H 1
  65. #cmakedefine HAVE_RECVMMSG 1
  66. #cmakedefine HAVE_RUSAGE_SELF 1
  67. #cmakedefine HAVE_SA_SIGINFO 1
  68. #cmakedefine HAVE_SANE_SHMEM 1
  69. #cmakedefine HAVE_SCHED_YIELD 1
  70. #cmakedefine HAVE_SC_NPROCESSORS_ONLN 1
  71. #cmakedefine HAVE_SETPROCTITLE 1
  72. #cmakedefine HAVE_SIGALTSTACK 1
  73. #cmakedefine HAVE_SIGINFO_H 1
  74. #cmakedefine HAVE_SOCK_SEQPACKET 1
  75. #cmakedefine HAVE_SSL_TLSEXT_HOSTNAME 1
  76. #cmakedefine HAVE_STDBOOL_H 1
  77. #cmakedefine HAVE_STDINT_H 1
  78. #cmakedefine HAVE_STDIO_H 1
  79. #cmakedefine HAVE_STDLIB_H 1
  80. #cmakedefine HAVE_STRINGS_H 1
  81. #cmakedefine HAVE_STRING_H 1
  82. #cmakedefine HAVE_SYSLOG_H 1
  83. #cmakedefine HAVE_SYS_CDEFS_H 1
  84. #cmakedefine HAVE_SYS_ENDIAN_H 1
  85. #cmakedefine HAVE_SYS_EVENTFD_H 1
  86. #cmakedefine HAVE_SYS_FILE_H 1
  87. #cmakedefine HAVE_SYS_MMAN_H 1
  88. #cmakedefine HAVE_SYS_PARAM_H 1
  89. #cmakedefine HAVE_SYS_RESOURCE_H 1
  90. #cmakedefine HAVE_SYS_SOCKET_H 1
  91. #cmakedefine HAVE_SYS_STAT_H 1
  92. #cmakedefine HAVE_SYS_TIMEB_H 1
  93. #cmakedefine HAVE_SYS_TYPES_H 1
  94. #cmakedefine HAVE_SYS_UCONTEXT_H 1
  95. #cmakedefine HAVE_SYS_UIO_H 1
  96. #cmakedefine HAVE_SYS_UN_H 1
  97. #cmakedefine HAVE_SYS_WAIT_H 1
  98. #cmakedefine HAVE_TANH 1
  99. #cmakedefine HAVE_TERMIOS_H 1
  100. #cmakedefine HAVE_TIME_H 1
  101. #cmakedefine HAVE_UCONTEXT_H 1
  102. #cmakedefine HAVE_UNISTD_H 1
  103. #cmakedefine PARAM_H_HAS_BITSET 1
  104. #cmakedefine WITH_GPERF_TOOLS 1
  105. #cmakedefine WITH_HYPERSCAN 1
  106. #cmakedefine WITH_JEMALLOC 1
  107. #cmakedefine WITH_LUA 1
  108. #cmakedefine WITH_LUAJIT 1
  109. #cmakedefine WITH_PCRE2 1
  110. #cmakedefine WITH_SNOWBALL 1
  111. #cmakedefine WITH_SQLITE 1
  112. #cmakedefine WITH_LIBUNWIND 1
  113. #cmakedefine WITH_LUA_TRACE 1
  114. #cmakedefine WITH_LUA_REPL 1
  115. #cmakedefine DISABLE_PTHREAD_MUTEX 1
  116. /* Detect endianness */
  117. #ifdef HAVE_ENDIAN_H
  118. #include <endian.h>
  119. #elif defined(HAVE_SYS_ENDIAN_H)
  120. #include <sys/endian.h>
  121. #elif defined(HAVE_MACHINE_ENDIAN_H)
  122. #include <machine/endian.h>
  123. #elif defined(__sun)
  124. #include <sys/byteorder.h>
  125. #ifndef LITTLE_ENDIAN
  126. #define LITTLE_ENDIAN 1234
  127. #endif
  128. #ifndef BIG_ENDIAN
  129. #define BIG_ENDIAN 4321
  130. #endif
  131. #ifdef _LITTLE_ENDIAN
  132. #define BYTE_ORDER LITTLE_ENDIAN
  133. #else
  134. #define BYTE_ORDER BIG_ENDIAN
  135. #endif
  136. #endif
  137. #ifndef BYTE_ORDER
  138. #ifndef LITTLE_ENDIAN
  139. #define LITTLE_ENDIAN 1234
  140. #endif
  141. #ifndef BIG_ENDIAN
  142. #define BIG_ENDIAN 4321
  143. #endif
  144. #if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || \
  145. defined(__BIG_ENDIAN__) || \
  146. defined(__ARMEB__) || \
  147. defined(__THUMBEB__) || \
  148. defined(__AARCH64EB__) || \
  149. defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__)
  150. #define BYTE_ORDER BIG_ENDIAN
  151. #elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || \
  152. defined(__LITTLE_ENDIAN__) || \
  153. defined(__ARMEL__) || \
  154. defined(__THUMBEL__) || \
  155. defined(__AARCH64EL__) || \
  156. defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__)
  157. #define BYTE_ORDER LITTLE_ENDIAN
  158. #else
  159. #error "I don't know what architecture this is!"
  160. #endif
  161. #endif /* BYTE_ORDER */
  162. #define RSPAMD_SHAREDIR "${SHAREDIR}"
  163. #define RSPAMD_CONFDIR "${CONFDIR}"
  164. #define RSPAMD_LOCAL_CONFDIR "${LOCAL_CONFDIR}"
  165. #define RSPAMD_RUNDIR "${RUNDIR}"
  166. #define RSPAMD_LOGDIR "${LOGDIR}"
  167. #define RSPAMD_DBDIR "${DBDIR}"
  168. #define RSPAMD_PLUGINSDIR "${PLUGINSDIR}"
  169. #define RSPAMD_LUALIBDIR "${LUALIBDIR}"
  170. #define RSPAMD_RULESDIR "${RULESDIR}"
  171. #define RSPAMD_WWWDIR "${WWWDIR}"
  172. #define RSPAMD_PREFIX "${CMAKE_INSTALL_PREFIX}"
  173. #define RSPAMD_LIBDIR "${RSPAMD_LIBDIR}"
  174. #define RSPAMD_VERSION_MAJOR "${RSPAMD_VERSION_MAJOR}"
  175. #define RSPAMD_VERSION_MINOR "${RSPAMD_VERSION_MINOR}"
  176. #define RSPAMD_VERSION_MAJOR_NUM ${RSPAMD_VERSION_MAJOR_NUM}
  177. #define RSPAMD_VERSION_MINOR_NUM ${RSPAMD_VERSION_MINOR_NUM}
  178. #define RSPAMD_VERSION_BRANCH "${RSPAMD_VERSION_MAJOR}"
  179. #if defined(GIT_VERSION) && GIT_VERSION == 1
  180. # define RVERSION "${RSPAMD_VERSION}"
  181. # define RSPAMD_VERSION_FULL "${RSPAMD_VERSION}_${RSPAMD_ID}"
  182. # define RID "${RSPAMD_ID}"
  183. # define RSPAMD_VERSION_NUM 0x${RSPAMD_VERSION_MAJOR_NUM}${RSPAMD_VERSION_MINOR_NUM}00${RSPAMD_ID}ULL
  184. #else
  185. # define RSPAMD_VERSION_FULL "${RSPAMD_VERSION}"
  186. # define RVERSION "${RSPAMD_VERSION}"
  187. # define RSPAMD_VERSION_NUM 0x${RSPAMD_VERSION_MAJOR_NUM}${RSPAMD_VERSION_MINOR_NUM}000000000ULL
  188. # define RID "release"
  189. #endif
  190. #define RSPAMD_MASTER_SITE_URL "${RSPAMD_MASTER_SITE_URL}"
  191. #define MODULES_NUM ${RSPAMD_MODULES_NUM}
  192. /* sys/types */
  193. #ifdef HAVE_SYS_TYPES_H
  194. #include <sys/types.h>
  195. #endif
  196. /* cdefs */
  197. #ifdef HAVE_SYS_CDEFS_H
  198. #include <sys/cdefs.h>
  199. #endif
  200. /* sys/param */
  201. #ifdef HAVE_SYS_PARAM_H
  202. #include <sys/param.h>
  203. #endif
  204. /* stdint */
  205. #ifdef HAVE_STDINT_H
  206. #include <stdint.h>
  207. #elif defined(HAVE_INTTYPES_H)
  208. #include <inttypes.h>
  209. #endif
  210. /* stdbool */
  211. #ifdef HAVE_STDBOOL_H
  212. #include <stdbool.h>
  213. #endif
  214. /* stdlib */
  215. #ifdef HAVE_STDLIB_H
  216. #include <stdlib.h>
  217. #endif
  218. /* stdio */
  219. #ifdef HAVE_STDIO_H
  220. #include <stdio.h>
  221. #endif
  222. /* time */
  223. #ifdef HAVE_TIME_H
  224. #include <time.h>
  225. #endif
  226. /* string */
  227. #ifdef HAVE_STRING_H
  228. #include <string.h>
  229. #endif
  230. #ifdef HAVE_STRINGS_H
  231. #include <strings.h>
  232. #endif
  233. #include <errno.h>
  234. #include <glib.h>
  235. #include <gmodule.h>
  236. #ifdef GLIB_RE_COMPAT
  237. #include "gregex.h"
  238. #endif
  239. #ifdef GLIB_UNISCRIPT_COMPAT
  240. #include "guniscript.h"
  241. #endif
  242. #ifdef GLIB_COMPAT
  243. #include "gchecksum.h"
  244. #endif
  245. #if (GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 14)
  246. typedef off_t goffset;
  247. #endif
  248. #ifndef PARAM_H_HAS_BITSET
  249. /* Bit map related macros. */
  250. #ifndef NBBY
  251. # define NBBY 8 /* number of bits in a byte */
  252. #endif
  253. #define setbit(a, \
  254. i) (((unsigned char *)(a))[(i) / NBBY] |= 1 << ((i) % NBBY))
  255. #define clrbit(a, \
  256. i) (((unsigned char *)(a))[(i) / NBBY] &= ~(1 << ((i) % NBBY)))
  257. #define isset(a,i) \
  258. (((const unsigned char *)(a))[(i) / NBBY] & (1 << ((i) % NBBY)))
  259. #define isclr(a,i) \
  260. ((((const unsigned char *)(a))[(i) / NBBY] & (1 << ((i) % NBBY))) == 0)
  261. #endif
  262. #ifdef _MSC_VER
  263. # define RSPAMD_PACKED(name) \
  264. __pragma(pack(push, 1)) struct name __pragma(pack(pop))
  265. #elif defined(__GNUC__)
  266. # define RSPAMD_PACKED(name) struct __attribute__((packed)) name
  267. #else
  268. # define RSPAMD_PACKED(name) struct name
  269. #endif
  270. #ifndef RSPAMD_ALIGNED
  271. #if defined(_MSC_VER)
  272. # define RSPAMD_ALIGNED(x) __declspec(align(x))
  273. # define RSPAMD_OPTIMIZE(x)
  274. # define RSPAMD_ALWAYS_INLINE
  275. #elif defined(__GNUC__)
  276. # define RSPAMD_ALIGNED(x) __attribute__((aligned(x)))
  277. # define RSPAMD_ALWAYS_INLINE __attribute__((always_inline))
  278. #ifndef __clang__
  279. # define RSPAMD_OPTIMIZE(x) __attribute__((__optimize__ (x)))
  280. #else
  281. # define RSPAMD_OPTIMIZE(x)
  282. #endif
  283. #else
  284. # define RSPAMD_ALIGNED(x)
  285. # define RSPAMD_OPTIMIZE(x)
  286. # define RSPAMD_ALWAYS_INLINE
  287. #endif
  288. #endif
  289. #ifndef __cplusplus
  290. # ifdef G_ALIGNOF
  291. # define RSPAMD_ALIGNOF G_ALIGNOF
  292. # else
  293. # define RSPAMD_ALIGNOF(t) _Alignof(t)
  294. # endif
  295. #else
  296. /* glib G_ALIGNOF nor C11 _Alignof are not good enough for C++, nuff said... */
  297. # define RSPAMD_ALIGNOF(t) alignof(t)
  298. #endif
  299. /* Address sanitizer */
  300. #ifdef __clang__
  301. # if __has_feature(address_sanitizer)
  302. /* emulate gcc's __SANITIZE_ADDRESS__ flag */
  303. # define __SANITIZE_ADDRESS__
  304. # define RSPAMD_NO_SANITIZE \
  305. __attribute__((no_sanitize("address", "hwaddress")))
  306. # else
  307. # define RSPAMD_NO_SANITIZE
  308. # endif
  309. #elif defined(__GNUC__)
  310. /* GCC based */
  311. # if defined(__has_attribute)
  312. # if __has_attribute(__no_sanitize_address__)
  313. # define RSPAMD_NO_SANITIZE __attribute__((no_sanitize_address))
  314. # else
  315. # define RSPAMD_NO_SANITIZE
  316. # endif
  317. # else
  318. # define RSPAMD_NO_SANITIZE
  319. # endif
  320. #else
  321. # define RSPAMD_NO_SANITIZE
  322. #endif
  323. #ifndef BITSPERBYTE
  324. # define BITSPERBYTE (NBBY * sizeof (char))
  325. #endif
  326. #ifndef NBYTES
  327. # define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE)
  328. #endif
  329. #ifdef __cplusplus
  330. extern "C" {
  331. #endif
  332. extern uint64_t ottery_rand_uint64(void);
  333. #define UCL_RANDOM_FUNCTION ottery_rand_uint64()
  334. #ifdef __cplusplus
  335. }
  336. #endif
  337. /* Disable slab allocator if jemalloc is already in the system */
  338. #if defined(WITH_JEMALLOC) || defined(__FreeBSD__) || \
  339. (defined(__NetBSD__) && __NetBSD_Version__ >= 500000000)
  340. #if 0
  341. #define g_slice_alloc(sz) g_malloc(sz)
  342. #define g_slice_alloc0(sz) g_malloc0(sz)
  343. #define g_slice_free1(sz, p) g_free(p)
  344. #endif
  345. #endif
  346. #ifdef __cplusplus
  347. #define RSPAMD_CONSTRUCTOR(f) \
  348. static void f(void); \
  349. struct f##_t_ { f##_t_(void) { f(); } }; static f##_t_ f##_; \
  350. static void f(void)
  351. #else
  352. #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
  353. #define RSPAMD_CONSTRUCTOR(f) \
  354. static void f(void) __attribute__((constructor)); \
  355. static void f(void)
  356. #define RSPAMD_DESTRUCTOR(f) \
  357. static void f(void) __attribute__((destructor)); \
  358. static void f(void)
  359. #else
  360. /* In fact, everything else is not supported ¯\_(ツ)_/¯ */
  361. #error incompatible compiler found, need gcc > 2.7 or clang
  362. #endif
  363. #endif /* __cplusplus */
  364. #ifdef __GNUC__
  365. #define RSPAMD_CONST_FUNCTION __attribute__ ((const))
  366. #else
  367. #define RSPAMD_CONST_FUNCTION
  368. #endif
  369. #ifdef __GNUC__
  370. #define RSPAMD_UNREACHABLE __builtin_unreachable()
  371. #else
  372. #define RSPAMD_UNREACHABLE abort()
  373. #endif
  374. #define HAVE_OPENSSL 1
  375. #define HAVE_MATH_H 1
  376. #endif