Skip to content

Commit e792e8c

Browse files
committed
Add BIGENDIAN detection logic.
1 parent 55d1db0 commit e792e8c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎lib/sha1.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@
1313
#include"sha1.h"
1414
#include"ubc_check.h"
1515

16+
17+
/*
18+
Because Little-Endian architectures are most common,
19+
we only set BIGENDIAN if one of these conditions is met.
20+
Note that all MSFT platforms are little endian,
21+
so none of these will be defined under the MSC compiler.
22+
If you are compiling on a big endian platform and your compiler does not define one of these,
23+
you will have to add whatever macros your tool chain defines to indicate Big-Endianness.
24+
*/
25+
#if (defined(__BYTE_ORDER) && (__BYTE_ORDER==__BIG_ENDIAN)) || \
26+
(defined(__BYTE_ORDER__) && (__BYTE_ORDER__==__BIG_ENDIAN__)) || \
27+
defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
28+
defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)
29+
30+
#defineBIGENDIAN (1)
31+
32+
#endif/*ENDIANNESS SELECTION*/
33+
1634
#definerotate_right(x,n) (((x)>>(n))|((x)<<(32-(n))))
1735
#definerotate_left(x,n) (((x)<<(n))|((x)>>(32-(n))))
1836

0 commit comments

Comments
(0)