Assume that unaligned access is not allowed unless we know otherwise #39
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.
_SDLNet_Read16: Be const-correct in unaligned code path
We only read from areap here, we don't write to it.
Always implement exported symbols for SDLNet_Write16 etc.
It's easier to reason about the ABI if the same set of symbols is
exported on all architectures, and always exporting these avoids
breaking ABI when another architecture is found to require alignment.
Regardless of whether we are performing unaligned access or not, we can
implement the extern versions in terms of the inline versions.
Assume that unaligned access is not allowed unless we know otherwise
x86 architecturally allows unaligned access, but this is unusual:
other CPU architectures generally do not. The safe assumption is that
unaligned access on an unknown CPU architecture will either be very
slow, or not work at all.
Instead of assuming that unknown architectures are like x86, let's
assume they are like ARM. This is true for riscv64, for example[1].
x86 is the outlier here, and is the most likely to be extensively tested
by SDL_net maintainers, so specifically detect x86 (using the predefined
macros from gcc, clang and MSVC) and continue to use unaligned accesses
there.
[1] https://wiki.debian.org/ArchitectureSpecificsMemo#Alignment