From 3844daeee1f8eac0263f1421929812b4b04fad38 Mon Sep 17 00:00:00 2001 From: Lukas Fittl Date: Sun, 27 Jul 2025 10:45:49 -0700 Subject: [PATCH v12 1/3] cpuidex check: Support detecting newer GCC versions defining it in cpuid.h Author: Lukas Fittl Discussion: https://postgr.es/m/CAP53Pky-BN0Ui+A9no3TsU=GoMTFpxYSWYtp_LVaDH=y69BxNg@mail.gmail.com --- meson.build | 4 ++++ src/port/pg_crc32c_sse42_choose.c | 4 ++-- src/port/pg_popcount_avx512.c | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 395416a6060..007ec30800f 100644 --- a/meson.build +++ b/meson.build @@ -2015,7 +2015,11 @@ if cc.links(''' args: test_c_args) cdata.set('HAVE__GET_CPUID_COUNT', 1) elif cc.links(''' + #if defined(_MSC_VER) #include + #else + #include + #endif int main(int arg, char **argv) { unsigned int exx[4] = {0, 0, 0, 0}; diff --git a/src/port/pg_crc32c_sse42_choose.c b/src/port/pg_crc32c_sse42_choose.c index 74d2421ba2b..750f390bfdf 100644 --- a/src/port/pg_crc32c_sse42_choose.c +++ b/src/port/pg_crc32c_sse42_choose.c @@ -20,11 +20,11 @@ #include "c.h" -#if defined(HAVE__GET_CPUID) || defined(HAVE__GET_CPUID_COUNT) +#if defined(HAVE__GET_CPUID) || defined(HAVE__GET_CPUID_COUNT) || (defined(HAVE__CPUIDEX) && !defined(_MSC_VER)) #include #endif -#if defined(HAVE__CPUID) || defined(HAVE__CPUIDEX) +#if defined(HAVE__CPUID) || (defined(HAVE__CPUIDEX) && defined(_MSC_VER)) #include #endif diff --git a/src/port/pg_popcount_avx512.c b/src/port/pg_popcount_avx512.c index 80c0aee3e73..80d9a372dd7 100644 --- a/src/port/pg_popcount_avx512.c +++ b/src/port/pg_popcount_avx512.c @@ -14,13 +14,13 @@ #ifdef USE_AVX512_POPCNT_WITH_RUNTIME_CHECK -#if defined(HAVE__GET_CPUID) || defined(HAVE__GET_CPUID_COUNT) +#if defined(HAVE__GET_CPUID) || defined(HAVE__GET_CPUID_COUNT) || (defined(HAVE__CPUIDEX) && !defined(_MSC_VER)) #include #endif #include -#if defined(HAVE__CPUID) || defined(HAVE__CPUIDEX) +#if defined(HAVE__CPUID) || (defined(HAVE__CPUIDEX) && defined(_MSC_VER)) #include #endif -- 2.47.3