aboutsummaryrefslogtreecommitdiffstats
path: root/config.h.in
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-01-20 12:09:31 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-01-20 12:09:31 +0000
commitcf58caf06a1813eff48363b559ad18fb01ddaa90 (patch)
treeab30997be9ee335e183aa09b8050b9d6486f07c2 /config.h.in
parent404dfe01888353e3e475231c0e4d77eda2eb2d7b (diff)
downloadrspamd-cf58caf06a1813eff48363b559ad18fb01ddaa90.tar.gz
rspamd-cf58caf06a1813eff48363b559ad18fb01ddaa90.zip
[Minor] Add constructors attribute detection
Diffstat (limited to 'config.h.in')
-rw-r--r--config.h.in23
1 files changed, 23 insertions, 0 deletions
diff --git a/config.h.in b/config.h.in
index ce3ee9650..3bdb5bc75 100644
--- a/config.h.in
+++ b/config.h.in
@@ -365,4 +365,27 @@ extern uint64_t ottery_rand_uint64(void);
#endif
#endif
+#ifdef __cplusplus
+ #define RSPAMD_CONSTRUCTOR(f) \
+ static void f(void); \
+ struct f##_t_ { f##_t_(void) { f(); } }; static f##_t_ f##_; \
+ static void f(void)
+#elif defined(_MSC_VER)
+ #pragma section(".CRT$XCU",read)
+ #define INITIALIZER2_(f,p) \
+ static void f(void); \
+ __declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
+ __pragma(comment(linker,"/include:" p #f "_")) \
+ static void f(void)
+ #ifdef _WIN64
+ #define RSPAMD_CONSTRUCTOR(f) INITIALIZER2_(f,"")
+ #else
+ #define RSPAMD_CONSTRUCTOR(f) INITIALIZER2_(f,"_")
+ #endif
+#else
+ #define RSPAMD_CONSTRUCTOR(f) \
+ static void f(void) __attribute__((constructor)); \
+ static void f(void)
+#endif
+
#endif