Skip to content

Commit

Permalink
add std::byteswap support
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Jul 12, 2023
1 parent 7aa28d2 commit 5f93444
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/bmffimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#endif

// + standard includes
#include <bit>
#include <cinttypes>
#include <cstdio>
#include <cstring>
Expand Down
4 changes: 4 additions & 0 deletions src/pgfimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ const unsigned char pgfBlank[] = {

namespace Exiv2 {
static uint32_t byteSwap_(uint32_t value, bool bSwap) {
#ifdef __cpp_lib_byteswap
return bSwap ? std::byteswap(value) : value;
#else
uint32_t result = 0;
result |= (value & 0x000000FF) << 24;
result |= (value & 0x0000FF00) << 8;
result |= (value & 0x00FF0000) >> 8;
result |= (value & 0xFF000000) >> 24;
return bSwap ? result : value;
#endif
}

static uint32_t byteSwap_(Exiv2::DataBuf& buf, size_t offset, bool bSwap) {
Expand Down

0 comments on commit 5f93444

Please sign in to comment.