Skip to content

Commit

Permalink
Use compiler macros for endianness
Browse files Browse the repository at this point in the history
  • Loading branch information
kmilos committed Jul 11, 2023
1 parent 50648dd commit 082a87d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ bool Image::isPrintICC(uint16_t type, Exiv2::PrintStructureOption option) {
}

bool Image::isBigEndianPlatform() {
#if defined(__BYTE_ORDER)
#if __BYTE_ORDER == __BIG_ENDIAN
#ifdef __LITTLE_ENDIAN__
return false;
#else
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
return true;
#else
return false;
Expand All @@ -182,9 +185,14 @@ bool Image::isBigEndianPlatform() {

return e.c[0] != 0;
#endif
#endif
}
bool Image::isLittleEndianPlatform() {
#ifdef __LITTLE_ENDIAN__
return true;
#else
return !isBigEndianPlatform();
#endif
}

uint64_t Image::byteSwap(uint64_t value, bool bSwap) {
Expand Down

0 comments on commit 082a87d

Please sign in to comment.