Skip to content

Commit 62dc8b5

Browse files
committed
Merge branch 'jk/sha1dc'
sha1dc/sha1.c wanted to check the endianness of the target platform at compilation time and used a CPP macro with a rather overly generic name, "BIGENDIAN", to pass the result of the check around in the file. It wasn't prepared for the same macro set to 0 (false) by the platform to signal that the target is _not_ a big endian box, and assumed that the endianness detection logic it has alone would be the one that is setting the macro, resulting in a breakage on Windows. This has been fixed by using a bit less generic name for the same purpose. * jk/sha1dc: sha1dc: avoid CPP macro collisions
2 parents 0330344 + 7e71542 commit 62dc8b5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sha1dc/sha1.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
/*
1414
Because Little-Endian architectures are most common,
15-
we only set BIGENDIAN if one of these conditions is met.
15+
we only set SHA1DC_BIGENDIAN if one of these conditions is met.
1616
Note that all MSFT platforms are little endian,
1717
so none of these will be defined under the MSC compiler.
1818
If you are compiling on a big endian platform and your compiler does not define one of these,
@@ -23,8 +23,9 @@
2323
defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
2424
defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)
2525

26-
#define BIGENDIAN (1)
27-
26+
#define SHA1DC_BIGENDIAN 1
27+
#else
28+
#undef SHA1DC_BIGENDIAN
2829
#endif /*ENDIANNESS SELECTION*/
2930

3031
#define rotate_right(x,n) (((x)>>(n))|((x)<<(32-(n))))
@@ -35,11 +36,11 @@
3536

3637
#define sha1_mix(W, t) (rotate_left(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1))
3738

38-
#if defined(BIGENDIAN)
39+
#if defined(SHA1DC_BIGENDIAN)
3940
#define sha1_load(m, t, temp) { temp = m[t]; }
4041
#else
4142
#define sha1_load(m, t, temp) { temp = m[t]; sha1_bswap32(temp); }
42-
#endif /*define(BIGENDIAN)*/
43+
#endif /* !defined(SHA1DC_BIGENDIAN) */
4344

4445
#define sha1_store(W, t, x) *(volatile uint32_t *)&W[t] = x
4546

0 commit comments

Comments
 (0)