Add Windows endian conversions - #87
Open
kungfubeaner wants to merge 1 commit into
Open
Conversation
fmang
reviewed
Aug 24, 2026
fmang
left a comment
Owner
There was a problem hiding this comment.
Thank you for the splitting! The code looks reasonable, but the documentation is a bit off the point (like an LLM’s rambling, to be frank).
I’ll look at the rest later this week.
| // Windows has no <endian.h>. It's always little-endian in practice, so the | ||
| // LE conversions are no-ops; for BE, use the compiler's byte-swap builtin | ||
| // rather than hand-rolled masking/shifting. Both MinGW-w64 (GCC/Clang) and | ||
| // MSVC provide one. |
Owner
There was a problem hiding this comment.
The assumption that Windows is always little-endian is worth stating, but that we use the compiler’s function instead of performing the bit operations ourselves is clear by reading the code. Unless you explain why, that mention is useless. If you wish to say that MSVC provides _byteswap_ulong, you should put the comment below, in the #else block. Just saying it provides one without giving the name of the provided function is vague.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the Windows-specific endian conversion support needed for the Windows port.
Provides htobe32() / be32toh() using compiler byte-swap intrinsics.
Provides htole32() / le32toh() for Windows.
Keeps the existing platform-specific implementations unchanged on Linux/macOS.
This is the first part of the Windows port and is intended to be followed by separate PRs for file handling and other Windows compatibility work.