Skip to content

Fix: add endian byte-swap for portable --fried import/export#226

Open
Thunder-Blaze wants to merge 2 commits into
hoytech:masterfrom
Thunder-Blaze:fix/fried-endianness
Open

Fix: add endian byte-swap for portable --fried import/export#226
Thunder-Blaze wants to merge 2 commits into
hoytech:masterfrom
Thunder-Blaze:fix/fried-endianness

Conversation

@Thunder-Blaze

Copy link
Copy Markdown
Contributor

Issue

  • Fixes: FIXME at cmd_export.cpp:34 and cmd_import.cpp:79

Description

The --fried flag on strfry export and strfry import enables a fast binary format that embeds the packed event representation directly. The packed format stores created_at, kind, and expiration as raw uint64 values in native byte order. This means fried data exported on a little-endian system can't be imported on a big-endian one - strfry currently throws a hard error on non-LE systems.

This fix defines the fried wire format as always little-endian and adds friedSwapEndian() which byte-swaps the three uint64 fields (at offsets 64, 72, 80) between native and LE. Using if constexpr, the swap is a compile-time no-op on little-endian systems - zero runtime cost for x86/ARM-LE.

Testing

  • Haven't been tested because I do not own such a system but I have properly reviewed the code properly and believe it will work
  • Can wait for this to get merged after I can somehow check this on any big-endian device

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.

1 participant