v11-0001-cpuidex-check-Support-detecting-newer-GCC-versio.patch
application/octet-stream
Filename: v11-0001-cpuidex-check-Support-detecting-newer-GCC-versio.patch
Type: application/octet-stream
Part: 2
From 86e5123425162a5bc3f6c4d85076fb2419e5d9ed Mon Sep 17 00:00:00 2001
From: Lukas Fittl <lukas@fittl.com>
Date: Sun, 27 Jul 2025 10:45:49 -0700
Subject: [PATCH v11 1/3] cpuidex check: Support detecting newer GCC versions
defining it in cpuid.h
In passing fix a typo in the ./configure check - the function is named
"__cpuidex", not "__get_cpuidex".
---
configure | 6 +++++-
meson.build | 4 ++++
src/port/pg_crc32c_sse42_choose.c | 4 ++--
src/port/pg_popcount_avx512.c | 4 ++--
4 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/configure b/configure
index 6d7c22e153f..1d5d47f44d3 100755
--- a/configure
+++ b/configure
@@ -17675,12 +17675,16 @@ if ${pgac_cv__cpuidex+:} false; then :
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
+#if defined(_MSC_VER)
#include <intrin.h>
+#else
+#include <cpuid.h>
+#endif
int
main ()
{
unsigned int exx[4] = {0, 0, 0, 0};
- __get_cpuidex(exx[0], 7, 0);
+ __cpuidex(exx, 7, 0);
;
return 0;
diff --git a/meson.build b/meson.build
index 5365aaf95e6..77702591421 100644
--- a/meson.build
+++ b/meson.build
@@ -2035,7 +2035,11 @@ if cc.links('''
args: test_c_args)
cdata.set('HAVE__GET_CPUID_COUNT', 1)
elif cc.links('''
+ #if defined(_MSC_VER)
#include <intrin.h>
+ #else
+ #include <cpuid.h>
+ #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 <cpuid.h>
#endif
-#if defined(HAVE__CPUID) || defined(HAVE__CPUIDEX)
+#if defined(HAVE__CPUID) || (defined(HAVE__CPUIDEX) && defined(_MSC_VER))
#include <intrin.h>
#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 <cpuid.h>
#endif
#include <immintrin.h>
-#if defined(HAVE__CPUID) || defined(HAVE__CPUIDEX)
+#if defined(HAVE__CPUID) || (defined(HAVE__CPUIDEX) && defined(_MSC_VER))
#include <intrin.h>
#endif
--
2.47.1