From 8194c4a9dd38f7373166ea3fd9243a6e51c0869f Mon Sep 17 00:00:00 2001 From: John Naylor Date: Mon, 6 Apr 2026 09:30:01 +0700 Subject: [PATCH] Fix unportable use of __builtin_constant_p On MSVC Arm, USE_ARMV8_CRC32C is defined, but __builtin_constant_p is not available. Use pg_integer_constant_p and add appropriate guards. There is a similar potential hazard for the x86 path, but for now let's get the buildfarm green. Oversight in commit fbc57f2bc, per buildfarm member hoatzin. --- src/include/port/pg_crc32c.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/include/port/pg_crc32c.h b/src/include/port/pg_crc32c.h index 10518614664..e6085ca50d1 100644 --- a/src/include/port/pg_crc32c.h +++ b/src/include/port/pg_crc32c.h @@ -113,13 +113,21 @@ extern pg_crc32c pg_comp_crc32c_avx512(pg_crc32c crc, const void *data, size_t l #elif defined(USE_ARMV8_CRC32C) /* * Use either ARMv8 CRC Extension or CRYPTO Extension (PMULL) instructions. + */ +#ifdef HAVE_PG_INTEGER_CONSTANT_P +/* * We don't need a runtime check for CRC, so for constant inputs, where * we assume the input is small, we can avoid an indirect function call. */ #define COMP_CRC32C(crc, data, len) \ - ((crc) = __builtin_constant_p(len) ? \ + ((crc) = pg_integer_constant_p(len) ? \ pg_comp_crc32c_armv8((crc), (data), (len)) : \ pg_comp_crc32c((crc), (data), (len))) +#else +#define COMP_CRC32C(crc, data, len) \ + ((crc) = pg_comp_crc32c((crc), (data), (len))) +#endif /* HAVE_PG_INTEGER_CONSTANT_P */ + #define FIN_CRC32C(crc) ((crc) ^= 0xFFFFFFFF) extern pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len);