Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Smith <brian@briansmith.org>2016-01-18 09:12:57 +0300
committerDavid Benjamin <davidben@google.com>2016-01-26 02:05:04 +0300
commit7cae9f5b6cf48c00997865226241a902a17f861a (patch)
treefad0f444cb3c2d6b73567e324e0c4dbd3d93277c /crypto/poly1305
parent34749f47da6106fce8ac80d6a85e780a7cf22834 (diff)
Use |alignas| for alignment.
MSVC doesn't have stdalign.h and so doesn't support |alignas| in C code. Define |alignas(x)| as a synonym for |__decltype(align(x))| instead for it. This also fixes -Wcast-qual warnings in rsaz_exp.c. Change-Id: Ifce9031724cb93f5a4aa1f567e7af61b272df9d5 Reviewed-on: https://boringssl-review.googlesource.com/6924 Reviewed-by: Adam Langley <agl@google.com> Reviewed-by: David Benjamin <davidben@google.com>
Diffstat (limited to 'crypto/poly1305')
-rw-r--r--crypto/poly1305/poly1305_arm.c4
-rw-r--r--crypto/poly1305/poly1305_test.cc12
-rw-r--r--crypto/poly1305/poly1305_vec.c11
3 files changed, 12 insertions, 15 deletions
diff --git a/crypto/poly1305/poly1305_arm.c b/crypto/poly1305/poly1305_arm.c
index 5e78dc06..82876e18 100644
--- a/crypto/poly1305/poly1305_arm.c
+++ b/crypto/poly1305/poly1305_arm.c
@@ -21,6 +21,8 @@
#include <string.h>
+#include "../internal.h"
+
typedef struct {
uint32_t v[12]; /* for alignment; only using 10 */
@@ -170,7 +172,7 @@ static void fe1305x2_frombytearray(fe1305x2 *r, const uint8_t *x,
}
}
-static const fe1305x2 zero __attribute__((aligned(16)));
+static const alignas(16) fe1305x2 zero;
struct poly1305_state_st {
uint8_t data[sizeof(fe1305x2[5]) + 128];
diff --git a/crypto/poly1305/poly1305_test.cc b/crypto/poly1305/poly1305_test.cc
index 3a726683..cae30a42 100644
--- a/crypto/poly1305/poly1305_test.cc
+++ b/crypto/poly1305/poly1305_test.cc
@@ -20,17 +20,10 @@
#include <openssl/crypto.h>
#include <openssl/poly1305.h>
+#include "../internal.h"
#include "../test/file_test.h"
-// |CRYPTO_poly1305_finish| requires a 16-byte-aligned output.
-#if defined(OPENSSL_WINDOWS)
-// MSVC doesn't support C++11 |alignas|.
-#define ALIGNED __declspec(align(16))
-#else
-#define ALIGNED alignas(16)
-#endif
-
static bool TestPoly1305(FileTest *t, void *arg) {
std::vector<uint8_t> key, in, mac;
if (!t->GetBytes(&key, "Key") ||
@@ -47,7 +40,8 @@ static bool TestPoly1305(FileTest *t, void *arg) {
poly1305_state state;
CRYPTO_poly1305_init(&state, key.data());
CRYPTO_poly1305_update(&state, in.data(), in.size());
- ALIGNED uint8_t out[16];
+ // |CRYPTO_poly1305_finish| requires a 16-byte-aligned output.
+ alignas(16) uint8_t out[16];
CRYPTO_poly1305_finish(&state, out);
if (!t->ExpectBytesEqual(out, 16, mac.data(), mac.size())) {
t->PrintLine("Single-shot Poly1305 failed.");
diff --git a/crypto/poly1305/poly1305_vec.c b/crypto/poly1305/poly1305_vec.c
index 3235b58b..4a826cc2 100644
--- a/crypto/poly1305/poly1305_vec.c
+++ b/crypto/poly1305/poly1305_vec.c
@@ -20,12 +20,13 @@
#include <openssl/poly1305.h>
+#include "../internal.h"
+
#if !defined(OPENSSL_WINDOWS) && defined(OPENSSL_X86_64)
#include <emmintrin.h>
-#define ALIGN(x) __attribute__((aligned(x)))
/* inline is not a keyword in C89. */
#define INLINE
#define U8TO64_LE(m) (*(const uint64_t *)(m))
@@ -35,11 +36,11 @@
typedef __m128i xmmi;
typedef unsigned __int128 uint128_t;
-static const uint32_t ALIGN(16) poly1305_x64_sse2_message_mask[4] = {
+static const alignas(16) uint32_t poly1305_x64_sse2_message_mask[4] = {
(1 << 26) - 1, 0, (1 << 26) - 1, 0};
-static const uint32_t ALIGN(16) poly1305_x64_sse2_5[4] = {5, 0, 5, 0};
-static const uint32_t ALIGN(16) poly1305_x64_sse2_1shl128[4] = {(1 << 24), 0,
- (1 << 24), 0};
+static const alignas(16) uint32_t poly1305_x64_sse2_5[4] = {5, 0, 5, 0};
+static const alignas(16) uint32_t poly1305_x64_sse2_1shl128[4] = {
+ (1 << 24), 0, (1 << 24), 0};
static uint128_t INLINE add128(uint128_t a, uint128_t b) { return a + b; }