]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Fix some portability issues.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 15 Oct 2015 10:28:41 +0000 (11:28 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 15 Oct 2015 10:28:41 +0000 (11:28 +0100)
config.h.in
contrib/libottery/ottery-internal.h
src/libcryptobox/cryptobox.c
src/libutil/regexp.c

index 04e6416ae4764a85b946dff2f38d16945a7b1a80..93721f82e00d40d93ab7bfdfe4fcaa915314a4ab 100644 (file)
 #endif
 
 
+#ifndef RSPAMD_ALIGNED
+#if defined(_MSC_VER)
+# define RSPAMD_ALIGNED(x) __declspec(align(x))
+#elif defined(__GNUC__)
+# define RSPAMD_ALIGNED(x) __attribute__((aligned(x)))
+#else
+# define RSPAMD_ALIGNED(x)
+#endif
+#endif
+
+
+
 #cmakedefine HAVE_SYS_QUEUE_H    1
 #cmakedefine HAVE_SYS_MMAN_H     1
 #cmakedefine HAVE_SYS_SOCKET_H   1
@@ -339,7 +351,9 @@ typedef off_t goffset;
 
 #ifndef PARAM_H_HAS_BITSET
 /* Bit map related macros. */
-#define NBBY    8               /* number of bits in a byte */
+#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, \
index 2d8a0318525734c3ccb0bec285597c1ccfbefe58..7e3f46e05eecf917c7d888cae4ccd0310317aaf7 100644 (file)
@@ -196,16 +196,16 @@ struct ottery_config {
 
 #define ottery_state_nolock ottery_state
 
-struct __attribute__((aligned(16))) ottery_state {
+struct RSPAMD_ALIGNED(16) ottery_state {
   /**
    * Holds up to prf.output_len bytes that have been generated by the
    * pseudorandom function. */
-  __attribute__ ((aligned (16))) uint8_t buffer[MAX_OUTPUT_LEN];
+  uint8_t buffer[MAX_OUTPUT_LEN] RSPAMD_ALIGNED(16);
   /**
    * Holds the state information (typically nonces and keys) used by the
    * pseudorandom function. */
 
-  __attribute__ ((aligned (16))) uint8_t state[MAX_STATE_LEN];
+  uint8_t state[MAX_STATE_LEN] RSPAMD_ALIGNED(16);
   /**
    * Parameters and function pointers for the cryptographic pseudorandom
    * function that we're using. */
index 3169c01a04e796a9064cbd2200d9901fcf4e06c3..0923905d7f34dba000ff9f38daf25c656b19566e 100644 (file)
@@ -27,6 +27,7 @@
 #include <string.h>
 #endif
 
+#include "config.h"
 #include "cryptobox.h"
 #include "platform_config.h"
 #include "chacha20/chacha.h"
 #include <cpuid.h>
 #endif
 
-
-#ifndef ALIGNED
-#if defined(_MSC_VER)
-# define ALIGNED(x) __declspec(align(x))
-#else
-# define ALIGNED(x) __attribute__((aligned(x)))
-#endif
-#endif
-
 unsigned long cpu_config = 0;
 
 static const guchar n0[16] = {0};
@@ -174,7 +166,7 @@ void rspamd_cryptobox_encrypt_nm_inplace (guchar *data, gsize len,
                const rspamd_nm_t nm, rspamd_sig_t sig)
 {
        poly1305_state mac_ctx;
-       guchar ALIGNED(32) subkey[CHACHA_BLOCKBYTES];
+       guchar RSPAMD_ALIGNED(32) subkey[CHACHA_BLOCKBYTES];
        chacha_state s;
        gsize r;
 
@@ -215,7 +207,7 @@ void rspamd_cryptobox_encryptv_nm_inplace (struct rspamd_cryptobox_segment *segm
                const rspamd_nm_t nm, rspamd_sig_t sig)
 {
        struct rspamd_cryptobox_segment *cur = segments, *start_seg = segments;
-       guchar ALIGNED(32) subkey[CHACHA_BLOCKBYTES],
+       guchar RSPAMD_ALIGNED(32) subkey[CHACHA_BLOCKBYTES],
                outbuf[CHACHA_BLOCKBYTES * 16];
        poly1305_state mac_ctx;
        guchar *out, *in;
@@ -308,7 +300,7 @@ rspamd_cryptobox_decrypt_nm_inplace (guchar *data, gsize len,
                const rspamd_nonce_t nonce, const rspamd_nm_t nm, const rspamd_sig_t sig)
 {
        poly1305_state mac_ctx;
-       guchar ALIGNED(32) subkey[CHACHA_BLOCKBYTES];
+       guchar RSPAMD_ALIGNED(32) subkey[CHACHA_BLOCKBYTES];
        rspamd_sig_t mac;
        chacha_state s;
        gsize r;
index f713ca2f740e793e85923c6e22abe202b3a40ef9..7ef3f178b06f5ee586776439481ce31127dd1620 100644 (file)
@@ -664,9 +664,12 @@ rspamd_regexp_library_init (void)
                rc = pcre_config (PCRE_CONFIG_JIT, &jit);
 
                if (rc == 0 && jit == 1) {
+#ifdef PCRE_CONFIG_JITTARGET
                        pcre_config (PCRE_CONFIG_JITTARGET, &str);
-
                        msg_info ("pcre is compiled with JIT for %s", str);
+#else
+                       msg_info ("pcre is compiled with JIT for unknown target");
+#endif
 
                        can_jit = TRUE;
                }