Skip to content

Commit

Permalink
Fix compilation warnings on ARM64 with old GCC versions. (google#52)
Browse files Browse the repository at this point in the history
Tested on Chrome OS M93 Linux (Debian 10.10) on kukui.
  • Loading branch information
pwnall authored Jun 22, 2021
1 parent db08d22 commit fa5ade4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/crc32c_arm64_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ inline bool CanUseArm64Crc32() {
// From 'arch/arm64/include/uapi/asm/hwcap.h' in Linux kernel source code.
constexpr unsigned long kHWCAP_PMULL = 1 << 4;
constexpr unsigned long kHWCAP_CRC32 = 1 << 7;
unsigned long hwcap = (&getauxval != nullptr) ? getauxval(AT_HWCAP) : 0;
unsigned long hwcap =
#if HAVE_STRONG_GETAUXVAL
// Some compilers warn on (&getauxval != nullptr) in the block below.
getauxval(AT_HWCAP);
#elif HAVE_WEAK_GETAUXVAL
(&getauxval != nullptr) ? getauxval(AT_HWCAP) : 0;
#else
#error This is supposed to be nested inside a check for HAVE_*_GETAUXVAL.
#endif // HAVE_STRONG_GETAUXVAL
return (hwcap & (kHWCAP_PMULL | kHWCAP_CRC32)) ==
(kHWCAP_PMULL | kHWCAP_CRC32);
#elif defined(__APPLE__)
Expand Down

0 comments on commit fa5ade4

Please sign in to comment.