]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add constructors attribute detection
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 20 Jan 2018 12:09:31 +0000 (12:09 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 20 Jan 2018 12:09:31 +0000 (12:09 +0000)
config.h.in

index ce3ee965034dcf08f62903d0c9c2bd61211f073d..3bdb5bc75c5d04a31c7d157d6903dad6a85111aa 100644 (file)
@@ -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