Skip to content

Commit c601213

Browse files
committed
Sync CRYPTOPP_{BIG|LITTLE}_ENDIAN with Autotools
Autotools sets up its config.h file with the '#define XXX 0' or '#define XXX 1' pattern. This check-in makes the sources Autotools aware. We need to verify CMake does the same
1 parent e185cbd commit c601213

23 files changed

+94
-93
lines changed

adv-simd.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ inline size_t AdvancedProcessBlocks64_6x2_NEON(F2 func2, F6 func6,
112112
CRYPTOPP_ASSERT(outBlocks);
113113
CRYPTOPP_ASSERT(length >= 8);
114114

115-
#if defined(CRYPTOPP_LITTLE_ENDIAN)
115+
#if (CRYPTOPP_LITTLE_ENDIAN)
116116
const uint32x4_t s_one = {0, 0, 0, 1<<24};
117117
const uint32x4_t s_two = {0, 2<<24, 0, 2<<24};
118118
#else
@@ -357,7 +357,7 @@ inline size_t AdvancedProcessBlocks128_6x1_NEON(F1 func1, F6 func6,
357357
CRYPTOPP_ASSERT(outBlocks);
358358
CRYPTOPP_ASSERT(length >= 16);
359359

360-
#if defined(CRYPTOPP_LITTLE_ENDIAN)
360+
#if (CRYPTOPP_LITTLE_ENDIAN)
361361
const uint32x4_t s_one = {0, 0, 0, 1<<24};
362362
const uint32x4_t s_two = {0, 2<<24, 0, 2<<24};
363363
#else
@@ -520,7 +520,7 @@ inline size_t AdvancedProcessBlocks128_4x1_NEON(F1 func1, F4 func4,
520520
CRYPTOPP_ASSERT(length >= 16);
521521
CRYPTOPP_UNUSED(unused);
522522

523-
#if defined(CRYPTOPP_LITTLE_ENDIAN)
523+
#if (CRYPTOPP_LITTLE_ENDIAN)
524524
const uint32x4_t s_one = {0, 0, 0, 1<<24};
525525
const uint32x4_t s_two = {0, 2<<24, 0, 2<<24};
526526
#else
@@ -660,7 +660,7 @@ inline size_t AdvancedProcessBlocks128_6x2_NEON(F2 func2, F6 func6,
660660
CRYPTOPP_ASSERT(outBlocks);
661661
CRYPTOPP_ASSERT(length >= 16);
662662

663-
#if defined(CRYPTOPP_LITTLE_ENDIAN)
663+
#if (CRYPTOPP_LITTLE_ENDIAN)
664664
const uint32x4_t s_one = {0, 0, 0, 1<<24};
665665
const uint32x4_t s_two = {0, 2<<24, 0, 2<<24};
666666
#else
@@ -1806,7 +1806,7 @@ inline size_t AdvancedProcessBlocks64_6x2_ALTIVEC(F2 func2, F6 func6,
18061806
CRYPTOPP_ASSERT(outBlocks);
18071807
CRYPTOPP_ASSERT(length >= 8);
18081808

1809-
#if defined(CRYPTOPP_LITTLE_ENDIAN)
1809+
#if (CRYPTOPP_LITTLE_ENDIAN)
18101810
enum {LowOffset=8, HighOffset=0};
18111811
const uint32x4_p s_one = {1,0,0,0};
18121812
const uint32x4_p s_two = {2,0,2,0};
@@ -2077,7 +2077,7 @@ inline size_t AdvancedProcessBlocks128_4x1_ALTIVEC(F1 func1, F4 func4,
20772077
CRYPTOPP_ASSERT(outBlocks);
20782078
CRYPTOPP_ASSERT(length >= 16);
20792079

2080-
#if defined(CRYPTOPP_LITTLE_ENDIAN)
2080+
#if (CRYPTOPP_LITTLE_ENDIAN)
20812081
const uint32x4_p s_one = {1,0,0,0};
20822082
#else
20832083
const uint32x4_p s_one = {0,0,0,1};
@@ -2222,7 +2222,7 @@ inline size_t AdvancedProcessBlocks128_6x1_ALTIVEC(F1 func1, F6 func6,
22222222
CRYPTOPP_ASSERT(outBlocks);
22232223
CRYPTOPP_ASSERT(length >= 16);
22242224

2225-
#if defined(CRYPTOPP_LITTLE_ENDIAN)
2225+
#if (CRYPTOPP_LITTLE_ENDIAN)
22262226
const uint32x4_p s_one = {1,0,0,0};
22272227
#else
22282228
const uint32x4_p s_one = {0,0,0,1};

aria.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ void ARIA::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, b
291291
else
292292
#endif // CRYPTOPP_ENABLE_ARIA_SSSE3_INTRINSICS
293293

294-
#ifdef CRYPTOPP_LITTLE_ENDIAN
294+
#if (CRYPTOPP_LITTLE_ENDIAN)
295295
{
296296
outBlock[ 0] = (byte)(X1[ARIA_BRF(t[0],3)] ) ^ rk[ 3];
297297
outBlock[ 1] = (byte)(X2[ARIA_BRF(t[0],2)]>>8) ^ rk[ 2];

camellia.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ NAMESPACE_BEGIN(CryptoPP)
6060
ROUND(lh, ll, rh, rl, k0, k1) \
6161
ROUND(rh, rl, lh, ll, k2, k3)
6262

63-
#ifdef CRYPTOPP_LITTLE_ENDIAN
63+
#if (CRYPTOPP_LITTLE_ENDIAN)
6464
#define EFI(i) (1-(i))
6565
#else
6666
#define EFI(i) (i)

config.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,24 @@
99
// ***************** Important Settings ********************
1010

1111
// define this if running on a big-endian CPU
12+
// big endian will be assumed if CRYPTOPP_LITTLE_ENDIAN is not non-0
1213
#if !defined(CRYPTOPP_LITTLE_ENDIAN) && !defined(CRYPTOPP_BIG_ENDIAN) && (defined(__BIG_ENDIAN__) || (defined(__s390__) || defined(__s390x__) || defined(__zarch__)) || (defined(__m68k__) || defined(__MC68K__)) || defined(__sparc) || defined(__sparc__) || defined(__hppa__) || defined(__MIPSEB__) || defined(__ARMEB__) || (defined(__MWERKS__) && !defined(__INTEL__)))
1314
# define CRYPTOPP_BIG_ENDIAN 1
1415
#endif
1516

1617
// define this if running on a little-endian CPU
17-
// big endian will be assumed if CRYPTOPP_LITTLE_ENDIAN is not defined
18+
// big endian will be assumed if CRYPTOPP_LITTLE_ENDIAN is not non-0
1819
#if !defined(CRYPTOPP_BIG_ENDIAN) && !defined(CRYPTOPP_LITTLE_ENDIAN)
1920
# define CRYPTOPP_LITTLE_ENDIAN 1
2021
#endif
2122

2223
// Sanity checks. Some processors have more than big, little and bi-endian modes. PDP mode, where order results in "4312", should
2324
// raise red flags immediately. Additionally, mis-classified machines, like (previosuly) S/390, should raise red flags immediately.
24-
#if defined(CRYPTOPP_BIG_ENDIAN) && defined(__GNUC__) && defined(__BYTE_ORDER__) && (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__)
25-
# error "CRYPTOPP_BIG_ENDIAN is set, but __BYTE_ORDER__ is not __ORDER_BIG_ENDIAN__"
25+
#if (CRYPTOPP_BIG_ENDIAN) && defined(__GNUC__) && defined(__BYTE_ORDER__) && (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__)
26+
# error "(CRYPTOPP_BIG_ENDIAN) is set, but __BYTE_ORDER__ is not __ORDER_BIG_ENDIAN__"
2627
#endif
27-
#if defined(CRYPTOPP_LITTLE_ENDIAN) && defined(__GNUC__) && defined(__BYTE_ORDER__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
28-
# error "CRYPTOPP_LITTLE_ENDIAN is set, but __BYTE_ORDER__ is not __ORDER_LITTLE_ENDIAN__"
28+
#if (CRYPTOPP_LITTLE_ENDIAN) && defined(__GNUC__) && defined(__BYTE_ORDER__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
29+
# error "(CRYPTOPP_LITTLE_ENDIAN) is set, but __BYTE_ORDER__ is not __ORDER_LITTLE_ENDIAN__"
2930
#endif
3031

3132
// Define this if you want to disable all OS-dependent features,
@@ -606,7 +607,7 @@ NAMESPACE_END
606607

607608
// We don't have an ARM big endian test rig. Disable
608609
// ARM-BE ASM and instrinsics until we can test it.
609-
#if defined(CRYPTOPP_BIG_ENDIAN)
610+
#if (CRYPTOPP_BIG_ENDIAN)
610611
# define CRYPTOPP_DISABLE_ASM 1
611612
#endif
612613

crc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extern void CRC32C_Update_SSE42(const byte *s, size_t n, word32& c);
2121

2222
/* Table of CRC-32's of all single byte values (made by makecrc.c) */
2323
const word32 CRC32::m_tab[] = {
24-
#ifdef CRYPTOPP_LITTLE_ENDIAN
24+
#if (CRYPTOPP_LITTLE_ENDIAN)
2525
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
2626
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
2727
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
@@ -189,7 +189,7 @@ void CRC32::TruncatedFinal(byte *hash, size_t size)
189189
// Castagnoli CRC32C (iSCSI)
190190

191191
const word32 CRC32C::m_tab[] = {
192-
#ifdef CRYPTOPP_LITTLE_ENDIAN
192+
#if (CRYPTOPP_LITTLE_ENDIAN)
193193
0x00000000L, 0xf26b8303L, 0xe13b70f7L, 0x1350f3f4L, 0xc79a971fL,
194194
0x35f1141cL, 0x26a1e7e8L, 0xd4ca64ebL, 0x8ad958cfL, 0x78b2dbccL,
195195
0x6be22838L, 0x9989ab3bL, 0x4d43cfd0L, 0xbf284cd3L, 0xac78bf27L,

crc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ NAMESPACE_BEGIN(CryptoPP)
1212

1313
const word32 CRC32_NEGL = 0xffffffffL;
1414

15-
#ifdef CRYPTOPP_LITTLE_ENDIAN
15+
#if (CRYPTOPP_LITTLE_ENDIAN)
1616
#define CRC32_INDEX(c) (c & 0xff)
1717
#define CRC32_SHIFTED(c) (c >> 8)
1818
#else

gcm-simd.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ using CryptoPP::VectorRotateLeft;
191191

192192
inline uint64x2_p VMULL2LE(const uint64x2_p& val)
193193
{
194-
#if CRYPTOPP_BIG_ENDIAN
194+
#if (CRYPTOPP_BIG_ENDIAN)
195195
return VectorRotateLeft<8>(val);
196196
#else
197197
return val;
@@ -776,7 +776,7 @@ inline uint64x2_p GCM_Multiply_VMULL(uint64x2_p x, uint64x2_p h, uint64x2_p r)
776776

777777
inline uint64x2_p LoadHashKey(const byte *hashKey)
778778
{
779-
#if CRYPTOPP_BIG_ENDIAN
779+
#if (CRYPTOPP_BIG_ENDIAN)
780780
const uint64x2_p key = (uint64x2_p)VectorLoad(hashKey);
781781
const uint8x16_p mask = {8,9,10,11, 12,13,14,15, 0,1,2,3, 4,5,6,7};
782782
return vec_perm(key, key, mask);
@@ -825,7 +825,7 @@ inline T SwapWords(const T& data)
825825

826826
inline uint64x2_p LoadBuffer1(const byte *dataBuffer)
827827
{
828-
#if CRYPTOPP_BIG_ENDIAN
828+
#if (CRYPTOPP_BIG_ENDIAN)
829829
return (uint64x2_p)VectorLoad(dataBuffer);
830830
#else
831831
const uint64x2_p data = (uint64x2_p)VectorLoad(dataBuffer);
@@ -836,7 +836,7 @@ inline uint64x2_p LoadBuffer1(const byte *dataBuffer)
836836

837837
inline uint64x2_p LoadBuffer2(const byte *dataBuffer)
838838
{
839-
#if CRYPTOPP_BIG_ENDIAN
839+
#if (CRYPTOPP_BIG_ENDIAN)
840840
return (uint64x2_p)SwapWords(VectorLoadBE(dataBuffer));
841841
#else
842842
return (uint64x2_p)VectorLoadBE(dataBuffer);

gcm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
438438

439439
#define READ_TABLE_WORD64_COMMON(a, b, c, d) *(word64 *)(void *)(mulTable+(a*1024)+(b*256)+c+d*8)
440440

441-
#ifdef CRYPTOPP_LITTLE_ENDIAN
441+
#if (CRYPTOPP_LITTLE_ENDIAN)
442442
#if CRYPTOPP_BOOL_SLOW_WORD64
443443
word32 z0 = (word32)x0;
444444
word32 z1 = (word32)(x0>>32);
@@ -509,7 +509,7 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
509509

510510
#define READ_TABLE_WORD64_COMMON(a, c, d) *(word64 *)(void *)(mulTable+(a)*256*16+(c)+(d)*8)
511511

512-
#ifdef CRYPTOPP_LITTLE_ENDIAN
512+
#if (CRYPTOPP_LITTLE_ENDIAN)
513513
#if CRYPTOPP_BOOL_SLOW_WORD64
514514
word32 z0 = (word32)x0;
515515
word32 z1 = (word32)(x0>>32);

integer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ class DWord
285285
#endif
286286
{
287287
#if defined(CRYPTOPP_NATIVE_DWORD_AVAILABLE)
288-
# if defined(CRYPTOPP_LITTLE_ENDIAN)
288+
# if (CRYPTOPP_LITTLE_ENDIAN)
289289
const word t[2] = {low,high};
290290
memcpy(&m_whole, t, sizeof(m_whole));
291291
# else
@@ -390,7 +390,7 @@ class DWord
390390
// Thanks to Martin Bonner at http://stackoverflow.com/a/39507183
391391
struct half_words
392392
{
393-
#ifdef CRYPTOPP_LITTLE_ENDIAN
393+
#if (CRYPTOPP_LITTLE_ENDIAN)
394394
word low;
395395
word high;
396396
#else

kalyna.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ using CryptoPP::KalynaTab::IS;
4343
template <unsigned int NB>
4444
inline void MakeOddKey(const word64 evenkey[NB], word64 oddkey[NB])
4545
{
46-
#if defined(CRYPTOPP_BIG_ENDIAN)
46+
#if (CRYPTOPP_BIG_ENDIAN)
4747
if (NB == 2)
4848
{
4949
oddkey[0] = (evenkey[1] << 8) | (evenkey[0] >> 56);

0 commit comments

Comments
 (0)