Skip to content

Support big-endian platforms (s390x) in the scalar codecs - #85

Merged
lemire merged 2 commits into
masterfrom
big_endian_scalar
Oct 14, 2026
Merged

lemire merged 2 commits into
masterfrom
big_endian_scalar

Conversation

@lemire

@lemire lemire commented Oct 14, 2026

Copy link
Copy Markdown
Member

Fixes #83.

The scalar encode/decode paths used memcpy to move 2/3/4-byte values to and from the stream, which assumes a little-endian host. On big-endian systems (e.g. s390x, as reported for vbz_compression in Debian) this corrupts the data and unit fails.

This PR:

  • adds an internal src/streamvbyte_endian.h with svb_load_le / svb_store_le: plain memcpy on little-endian hosts (so generated code is unchanged there) and explicit byte shifts when __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__;
  • uses them in the scalar paths of the standard, delta and 0124 codecs (streamvbyte_{encode,decode}.c, streamvbytedelta_{encode,decode}.c, streamvbyte_0124_{encode,decode}.c). The patch in the issue edited streamvbytedelta.c, which isn't built; the delta codec actually lives in streamvbytedelta_{encode,decode}.c;
  • adds an s390x CI job (Debian under QEMU).

Verified locally under s390x emulation: unit fails on master and passes with this change (-Wall -Werror). Encoded bytes for the standard, 0124 and delta formats are identical on s390x and on little-endian hosts, so streams can be moved between platforms. Thanks to @pranavkaruvally for the report and the initial patch.

The scalar encode/decode paths copied integers to and from the byte
stream with memcpy, which silently assumes a little-endian host. On
big-endian systems such as s390x this produced corrupted streams.

Add small svb_load_le/svb_store_le helpers that keep using memcpy on
little-endian hosts (no codegen change) and fall back to explicit byte
shifts on big-endian hosts. Add an s390x CI job running under QEMU.
- windows-2025 no longer ships Visual Studio 2022; let CMake pick the
  installed Visual Studio instead of hardcoding the generator.
- Replace leftover SIMDJSON_* options (ignored by this project) with a
  BUILD_SHARED_LIBS axis so the static/shared matrix tests something.
- Bump actions/checkout to v7 and docker/setup-qemu-action to v4
  (Node 20 deprecation).
@lemire
lemire merged commit 25417e3 into master Oct 14, 2026
32 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vbz_compression test-suite fails on s390x

1 participant