diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-02-08 22:27:04 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-02-08 22:27:04 +0000 |
commit | 544fea1f9f6e29eda29a616bbafd47b908ad7b6f (patch) | |
tree | 7d1059216e3692b0cb3480508c8eab823dd928d8 | |
parent | 7f1ad00467415ca80d22e9865dab0792a9ee27fa (diff) | |
download | rspamd-544fea1f9f6e29eda29a616bbafd47b908ad7b6f.tar.gz rspamd-544fea1f9f6e29eda29a616bbafd47b908ad7b6f.zip |
Unify align macro.
-rw-r--r-- | config.h.in | 8 | ||||
-rw-r--r-- | contrib/blake2/blake2.h | 6 | ||||
-rw-r--r-- | src/libcryptobox/cryptobox.c | 10 | ||||
-rw-r--r-- | test/rspamd_http_test.c | 2 |
4 files changed, 18 insertions, 8 deletions
diff --git a/config.h.in b/config.h.in index c1e819fb2..e45f95f4c 100644 --- a/config.h.in +++ b/config.h.in @@ -472,6 +472,14 @@ typedef off_t goffset; #include <gmime/gmime.h> #endif +#ifndef ALIGN +#if defined(_MSC_VER) +# define ALIGN(x) __declspec(align(x)) +#else +# define ALIGN(x) __attribute__((aligned(x))) +#endif +#endif + /* Forwarded declaration */ struct module_ctx; struct rspamd_config; diff --git a/contrib/blake2/blake2.h b/contrib/blake2/blake2.h index 433c429e0..b0c852284 100644 --- a/contrib/blake2/blake2.h +++ b/contrib/blake2/blake2.h @@ -17,10 +17,12 @@ #include <stddef.h> #include <stdint.h> +#ifndef ALIGN #if defined(_MSC_VER) -#define ALIGN(x) __declspec(align(x)) +# define ALIGN(x) __declspec(align(x)) #else -#define ALIGN(x) __attribute__((aligned(x))) +# define ALIGN(x) __attribute__((aligned(x))) +#endif #endif #if defined(__cplusplus) diff --git a/src/libcryptobox/cryptobox.c b/src/libcryptobox/cryptobox.c index da43a137c..ecc3b5cfc 100644 --- a/src/libcryptobox/cryptobox.c +++ b/src/libcryptobox/cryptobox.c @@ -141,8 +141,8 @@ void rspamd_cryptobox_encrypt_nm_inplace (guchar *data, gsize len, const rspamd_nm_t nm, rspamd_sig_t sig) { poly1305_state mac_ctx; - guchar subkey[CHACHA_BLOCKBYTES]; - chacha_state s; + ALIGN(64) guchar subkey[CHACHA_BLOCKBYTES]; + ALIGN(64) chacha_state s; gsize r; xchacha_init (&s, (const chacha_key *)nm, (const chacha_iv24 *)nonce, 20); @@ -164,10 +164,10 @@ gboolean 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 subkey[CHACHA_BLOCKBYTES]; + ALIGN(64) poly1305_state mac_ctx; + ALIGN(64) guchar subkey[CHACHA_BLOCKBYTES]; rspamd_sig_t mac; - chacha_state s; + ALIGN(64) chacha_state s; gsize r; gboolean ret = TRUE; diff --git a/test/rspamd_http_test.c b/test/rspamd_http_test.c index 94a12ee81..581a4c284 100644 --- a/test/rspamd_http_test.c +++ b/test/rspamd_http_test.c @@ -30,7 +30,7 @@ static const int file_blocks = 8; static const int pconns = 100; -static const int ntests = 100; +static const int ntests = 300; static void rspamd_server_error (struct rspamd_http_connection_entry *conn_ent, |