Skip to content

Commit

Permalink
fix predefines for bswap for old compilers (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyMusatkin authored Nov 12, 2024
1 parent b23b2e2 commit 3e4101b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions include/aws/checksums/private/crc_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ static inline uint32_t aws_bswap32_if_be(uint32_t x) {

#if _MSC_VER
return _byteswap_ulong(x);
#elif defined(__GNUC__) || defined(__clang__)
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
return __builtin_bswap32(x);
#elif defined(__clang__) && __clang_major__ >= 3
return __builtin_bswap32(x);
#else
return (
Expand All @@ -47,7 +49,10 @@ static inline uint64_t aws_bswap64_if_be(uint64_t x) {

#if _MSC_VER
return _byteswap_uint64(x);
#elif defined(__GNUC__) || defined(__clang__)
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
/* Note: gcc supports it starting with 4.2. here its just picking the lowest version we run test on. */
return __builtin_bswap64(x);
#elif defined(__clang__) && __clang_major__ >= 3
return __builtin_bswap64(x);
#else
return ((x << 56) & 0xff00000000000000ULL) | ((x << 40) & 0x00ff000000000000ULL) |
Expand Down

0 comments on commit 3e4101b

Please sign in to comment.