Skip to content

Commit

Permalink
use std::endian
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb committed Jun 6, 2023
1 parent 985738a commit e68ae8a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

// + standard includes
#include <array>
#include <bit>
#include <cstdio>
#include <cstring>
#include <limits>
Expand Down Expand Up @@ -168,15 +169,11 @@ bool Image::isPrintICC(uint16_t type, Exiv2::PrintStructureOption option) {
}

bool Image::isBigEndianPlatform() {
union {
uint32_t i;
char c[4];
} e = {0x01000000};

return e.c[0] != 0;
return std::endian::native == std::endian::big;
}

bool Image::isLittleEndianPlatform() {
return !isBigEndianPlatform();
return std::endian::native == std::endian::little;
}

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

0 comments on commit e68ae8a

Please sign in to comment.