summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-15 11:28:41 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-15 11:28:41 +0100
commit6ceac089b6a8fee5aef14307b0561e98202947c5 (patch)
treebf105ef7acee480dc41c498fa8b7f0ba77a7effb
parent61f993a096adee992be9b5333f6c0090440f00ed (diff)
downloadrspamd-6ceac089b6a8fee5aef14307b0561e98202947c5.tar.gz
rspamd-6ceac089b6a8fee5aef14307b0561e98202947c5.zip
Fix some portability issues.
-rw-r--r--config.h.in16
-rw-r--r--contrib/libottery/ottery-internal.h6
-rw-r--r--src/libcryptobox/cryptobox.c16
-rw-r--r--src/libutil/regexp.c5
4 files changed, 26 insertions, 17 deletions
diff --git a/config.h.in b/config.h.in
index 04e6416ae..93721f82e 100644
--- a/config.h.in
+++ b/config.h.in
@@ -102,6 +102,18 @@
#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, \
diff --git a/contrib/libottery/ottery-internal.h b/contrib/libottery/ottery-internal.h
index 2d8a03185..7e3f46e05 100644
--- a/contrib/libottery/ottery-internal.h
+++ b/contrib/libottery/ottery-internal.h
@@ -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. */
diff --git a/src/libcryptobox/cryptobox.c b/src/libcryptobox/cryptobox.c
index 3169c01a0..0923905d7 100644
--- a/src/libcryptobox/cryptobox.c
+++ b/src/libcryptobox/cryptobox.c
@@ -27,6 +27,7 @@
#include <string.h>
#endif
+#include "config.h"
#include "cryptobox.h"
#include "platform_config.h"
#include "chacha20/chacha.h"
@@ -39,15 +40,6 @@
#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;
diff --git a/src/libutil/regexp.c b/src/libutil/regexp.c
index f713ca2f7..7ef3f178b 100644
--- a/src/libutil/regexp.c
+++ b/src/libutil/regexp.c
@@ -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;
}