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