Add C++11 alignas support. Deleting 'alignas' branch

pull/200/head
Jeffrey Walton 2016-06-14 19:14:09 -04:00
parent a6090c64ed
commit c1f025343a
6 changed files with 39 additions and 20 deletions

View File

@ -69,6 +69,7 @@ struct CRYPTOPP_NO_VTABLE BLAKE2_IV<false>
CRYPTOPP_ALIGN_DATA(16) static const word32 iv[8]; CRYPTOPP_ALIGN_DATA(16) static const word32 iv[8];
}; };
CRYPTOPP_ALIGN_DATA(16)
const word32 BLAKE2_IV<false>::iv[8] = { const word32 BLAKE2_IV<false>::iv[8] = {
0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL, 0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL,
0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL 0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL
@ -84,6 +85,7 @@ struct CRYPTOPP_NO_VTABLE BLAKE2_IV<true>
CRYPTOPP_ALIGN_DATA(16) static const word64 iv[8]; CRYPTOPP_ALIGN_DATA(16) static const word64 iv[8];
}; };
CRYPTOPP_ALIGN_DATA(16)
const word64 BLAKE2_IV<true>::iv[8] = { const word64 BLAKE2_IV<true>::iv[8] = {
W64LIT(0x6a09e667f3bcc908), W64LIT(0xbb67ae8584caa73b), W64LIT(0x6a09e667f3bcc908), W64LIT(0xbb67ae8584caa73b),
W64LIT(0x3c6ef372fe94f82b), W64LIT(0xa54ff53a5f1d36f1), W64LIT(0x3c6ef372fe94f82b), W64LIT(0xa54ff53a5f1d36f1),
@ -105,6 +107,7 @@ struct CRYPTOPP_NO_VTABLE BLAKE2_Sigma<false>
CRYPTOPP_ALIGN_DATA(16) static const byte sigma[10][16]; CRYPTOPP_ALIGN_DATA(16) static const byte sigma[10][16];
}; };
CRYPTOPP_ALIGN_DATA(16)
const byte BLAKE2_Sigma<false>::sigma[10][16] = { const byte BLAKE2_Sigma<false>::sigma[10][16] = {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }, { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
@ -126,6 +129,7 @@ struct CRYPTOPP_NO_VTABLE BLAKE2_Sigma<true>
CRYPTOPP_ALIGN_DATA(16) static const byte sigma[12][16]; CRYPTOPP_ALIGN_DATA(16) static const byte sigma[12][16];
}; };
CRYPTOPP_ALIGN_DATA(16)
const byte BLAKE2_Sigma<true>::sigma[12][16] = { const byte BLAKE2_Sigma<true>::sigma[12][16] = {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }, { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },

View File

@ -250,6 +250,7 @@ void Camellia::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBloc
// The Camellia s-boxes // The Camellia s-boxes
CRYPTOPP_ALIGN_DATA(4)
const byte Camellia::Base::s1[256] = const byte Camellia::Base::s1[256] =
{ {
112,130,44,236,179,39,192,229,228,133,87,53,234,12,174,65, 112,130,44,236,179,39,192,229,228,133,87,53,234,12,174,65,

View File

@ -829,6 +829,12 @@ NAMESPACE_END
# define CRYPTOPP_NO_THROW # define CRYPTOPP_NO_THROW
#endif // CRYPTOPP_CXX11_NOEXCEPT #endif // CRYPTOPP_CXX11_NOEXCEPT
// Hack... CRYPTOPP_ALIGN_DATA is defined earlier, before C++11 alignas availability is determined
#if defined(CRYPTOPP_CXX11_ALIGNAS)
# undef CRYPTOPP_ALIGN_DATA
# define CRYPTOPP_ALIGN_DATA(x) alignas(x)
#endif // CRYPTOPP_CXX11_ALIGNAS
// OK to comment the following out, but please report it so we can fix it. // OK to comment the following out, but please report it so we can fix it.
#if (defined(__cplusplus) && (__cplusplus >= 199711L)) && !defined(CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE) #if (defined(__cplusplus) && (__cplusplus >= 199711L)) && !defined(CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE)
# error "std::uncaught_exception is not available. This is likely a configuration error." # error "std::uncaught_exception is not available. This is likely a configuration error."

View File

@ -827,6 +827,12 @@ NAMESPACE_END
# define CRYPTOPP_NO_THROW # define CRYPTOPP_NO_THROW
#endif // CRYPTOPP_CXX11_NOEXCEPT #endif // CRYPTOPP_CXX11_NOEXCEPT
// Hack... CRYPTOPP_ALIGN_DATA is defined earlier, before C++11 alignas availability is determined
#if defined(CRYPTOPP_CXX11_ALIGNAS)
# undef CRYPTOPP_ALIGN_DATA
# define CRYPTOPP_ALIGN_DATA(x) alignas(x)
#endif // CRYPTOPP_CXX11_ALIGNAS
// OK to comment the following out, but please report it so we can fix it. // OK to comment the following out, but please report it so we can fix it.
#if (defined(__cplusplus) && (__cplusplus >= 199711L)) && !defined(CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE) #if (defined(__cplusplus) && (__cplusplus >= 199711L)) && !defined(CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE)
# error "std::uncaught_exception is not available. This is likely a configuration error." # error "std::uncaught_exception is not available. This is likely a configuration error."

View File

@ -100,7 +100,8 @@ inline static void Xor16(byte *a, const byte *b, const byte *c)
} }
#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
static CRYPTOPP_ALIGN_DATA(16) const word64 s_clmulConstants64[] = { CRYPTOPP_ALIGN_DATA(16)
static const word64 s_clmulConstants64[] = {
W64LIT(0xe100000000000000), W64LIT(0xc200000000000000), W64LIT(0xe100000000000000), W64LIT(0xc200000000000000),
W64LIT(0x08090a0b0c0d0e0f), W64LIT(0x0001020304050607), W64LIT(0x08090a0b0c0d0e0f), W64LIT(0x0001020304050607),
W64LIT(0x0001020304050607), W64LIT(0x08090a0b0c0d0e0f)}; W64LIT(0x0001020304050607), W64LIT(0x08090a0b0c0d0e0f)};

View File

@ -95,8 +95,8 @@ static word64 Td[256];
// Unused; avoids linker error on Microsoft X64 non-AESNI platforms // Unused; avoids linker error on Microsoft X64 non-AESNI platforms
namespace rdtable {CRYPTOPP_ALIGN_DATA(16) word64 Te[256+2];} namespace rdtable {CRYPTOPP_ALIGN_DATA(16) word64 Te[256+2];}
# endif # endif
static CRYPTOPP_ALIGN_DATA(16) word32 Te[256*4]; CRYPTOPP_ALIGN_DATA(16) static word32 Te[256*4];
static CRYPTOPP_ALIGN_DATA(16) word32 Td[256*4]; CRYPTOPP_ALIGN_DATA(16) static word32 Td[256*4];
#endif // CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS #endif // CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
static volatile bool s_TeFilled = false, s_TdFilled = false; static volatile bool s_TeFilled = false, s_TdFilled = false;
@ -1103,7 +1103,8 @@ inline void AESNI_Dec_4_Blocks(__m128i &block0, __m128i &block1, __m128i &block2
block3 = _mm_aesdeclast_si128(block3, rk); block3 = _mm_aesdeclast_si128(block3, rk);
} }
static CRYPTOPP_ALIGN_DATA(16) const word32 s_one[] = {0, 0, 0, 1<<24}; CRYPTOPP_ALIGN_DATA(16)
static const word32 s_one[] = {0, 0, 0, 1<<24};
template <typename F1, typename F4> template <typename F1, typename F4>
inline size_t AESNI_AdvancedProcessBlocks(F1 func1, F4 func4, const __m128i *subkeys, unsigned int rounds, const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) inline size_t AESNI_AdvancedProcessBlocks(F1 func1, F4 func4, const __m128i *subkeys, unsigned int rounds, const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)