Skip to content

Commit fd734f7

Browse files
authored
Merge pull request libgit2#5107 from pks-t/pks/sha1dc-update
sha1dc: update to fix endianess issues on AIX/HP-UX
2 parents 110b589 + 230a451 commit fd734f7

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/hash/sha1dc/sha1.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,23 @@
9393
#define SHA1DC_BIGENDIAN
9494

9595
/* Not under GCC-alike or glibc or *BSD or newlib or <processor whitelist> */
96+
#elif (defined(_AIX) || defined(__hpux))
97+
98+
/*
99+
* Defines Big Endian on a whitelist of OSs that are known to be Big
100+
* Endian-only. See
101+
* https://public-inbox.org/git/93056823-2740-d072-1ebd-46b440b33d7e@felt.demon.nl/
102+
*/
103+
#define SHA1DC_BIGENDIAN
104+
105+
/* Not under GCC-alike or glibc or *BSD or newlib or <processor whitelist> or <os whitelist> */
96106
#elif defined(SHA1DC_ON_INTEL_LIKE_PROCESSOR)
97107
/*
98108
* As a last resort before we do anything else we're not 100% sure
99109
* about below, we blacklist specific processors here. We could add
100110
* more, see e.g. https://wiki.debian.org/ArchitectureSpecificsMemo
101111
*/
102-
#else /* Not under GCC-alike or glibc or *BSD or newlib or <processor whitelist> or <processor blacklist> */
112+
#else /* Not under GCC-alike or glibc or *BSD or newlib or <processor whitelist> or <os whitelist> or <processor blacklist> */
103113

104114
/* We do nothing more here for now */
105115
/*#error "Uncomment this to see if you fall through all the detection"*/
@@ -114,10 +124,11 @@
114124
#endif
115125
/*ENDIANNESS SELECTION*/
116126

127+
#ifndef SHA1DC_FORCE_ALIGNED_ACCESS
117128
#if defined(SHA1DC_FORCE_UNALIGNED_ACCESS) || defined(SHA1DC_ON_INTEL_LIKE_PROCESSOR)
118129
#define SHA1DC_ALLOW_UNALIGNED_ACCESS
119-
#endif /*UNALIGNMENT DETECTION*/
120-
130+
#endif /*UNALIGNED ACCESS DETECTION*/
131+
#endif /*FORCE ALIGNED ACCESS*/
121132

122133
#define rotate_right(x,n) (((x)>>(n))|((x)<<(32-(n))))
123134
#define rotate_left(x,n) (((x)<<(n))|((x)>>(32-(n))))

0 commit comments

Comments
 (0)