From 4a59709ca12b744cf3778e7cabf5ae3cc571e827 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Fri, 10 Jul 2015 14:58:29 -0400 Subject: [PATCH] Fix Windows build. MSVC 2013 doesn't implement C++11 alignas. Use __declspec instead. Change-Id: I48a402d56d734f3f2c434b4bdf2a5bc671c50225 Reviewed-on: https://boringssl-review.googlesource.com/5421 Reviewed-by: Adam Langley --- crypto/poly1305/poly1305_test.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crypto/poly1305/poly1305_test.cc b/crypto/poly1305/poly1305_test.cc index fd1c89ac..05260752 100644 --- a/crypto/poly1305/poly1305_test.cc +++ b/crypto/poly1305/poly1305_test.cc @@ -24,6 +24,14 @@ #include "../test/stl_compat.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 key, in, mac; if (!t->GetBytes(&key, "Key") || @@ -40,8 +48,7 @@ static bool TestPoly1305(FileTest *t, void *arg) { poly1305_state state; CRYPTO_poly1305_init(&state, bssl::vector_data(&key)); CRYPTO_poly1305_update(&state, bssl::vector_data(&in), in.size()); - // |CRYPTO_poly1305_finish| requires a 16-byte-aligned output. - alignas(16) uint8_t out[16]; + ALIGNED uint8_t out[16]; CRYPTO_poly1305_finish(&state, out); if (!t->ExpectBytesEqual(out, 16, bssl::vector_data(&mac), mac.size())) { t->PrintLine("Single-shot Poly1305 failed.");