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 7930039
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,12 @@ 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;
#elif defined(__BIG_ENDIAN__)
return true;
#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
return true;
#else
return false;
Expand All @@ -184,7 +188,11 @@ bool Image::isBigEndianPlatform() {
#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 7930039

Please sign in to comment.