For the time being, refuse to build on big-endian architectures #181
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.
hictk itself can be built on both little and big-endian architectures. However, the hic library will be quite limited on big-endian archs. These are the current limitations:
The above limitations are due to the use of reinterpret_cast<> and raw std::fstream methods to serialize binary data to disk. The .hic file specification does not mandate the endianness that should be used to read and write .hic files, however virtually all .hic files are generated on little-endian machines, so the byte order of the serialized data is also little-endian, making little-endian the de-facto byte order standard.
It is my understanding that machines with big-endian architecture are not that common in desktop/HPC environments used for bioinformatics, so supporting big-endian architectures is likely not a pressing matter.
Supporting big-endian architecture can be achieved by manually converting binary types stored in BinaryBuffers to little-endian before casting them to char* for serialization.
This can be achieved with the help of libraries such as Boost.Endian.
As this conversion is only needed on big-endian machines, extra care should be taken to ensure that the implementation of this feature does not add build nor runtime costs on little-endian machines (i.e. hictk should link to boost only on big-endian platforms and the code performing endianness conversion should be wrapped in if constexpr and/or disabled with std::enable_if as appropriate).