Skip to content

Commit 3bb00e4

Browse files
committed
Reverse the order of copied bytes on big-endian
Fixes test failures on s390x.
1 parent 80bdfe5 commit 3bb00e4

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ version develop
1212
-----------------
1313
+ Use upstream ISA-L version 2.31.1 which includes patches to make
1414
installation possible.
15+
+ Fix a bug where bytes were copied in the wrong order on big endian
16+
architectures. Fixes test failures on s390x.
1517

1618
version 1.7.1
1719
-----------------

src/isal/isal_shared.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,15 @@ static int bitbuffer_copy(struct inflate_state *state, char *to, size_t n){
207207
int remainder = bits_in_buffer % 8;
208208
// Shift the 8-byte bitbuffer read_in so that the bytes are aligned.
209209
uint64_t remaining_bytes = state->read_in >> remainder;
210+
#if PY_BIG_ENDIAN
211+
char *remaining_buffer = (char *)&remaining_bytes;
212+
for (int i = 0; i < n; ++i) {
213+
to[i] = remaining_buffer[7-i];
214+
}
215+
#else
210216
// memcpy works because of little-endianness
211217
memcpy(to, &remaining_bytes, n);
218+
#endif
212219
return 0;
213220
}
214221

0 commit comments

Comments
 (0)