0002-Remove-checks-for-no-longer-supported-GCC-versions.patch

text/plain

Filename: 0002-Remove-checks-for-no-longer-supported-GCC-versions.patch
Type: text/plain
Part: 1
Message: Re: Solaris compiler status

Patch

Format: format-patch
Series: patch 0002
Subject: Remove checks for no longer supported GCC versions
File+
src/include/c.h 4 4
src/include/port/atomics/generic-gcc.h 2 2
From 58c151b7bd062dee6744f5c1d3fe2ee0863e5349 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Thu, 4 Sep 2025 11:38:04 +0200
Subject: [PATCH 2/3] Remove checks for no longer supported GCC versions

Since commit f5e0186f865 (Raise C requirement to C11), we effectively
require at least GCC version 4.7, so checks for older versions can be
removed.

Discussion: https://www.postgresql.org/message-id/flat/a0f817ee-fb86-483a-8a14-b6f7f5991b6e%40eisentraut.org
---
 src/include/c.h                        | 8 ++++----
 src/include/port/atomics/generic-gcc.h | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/include/c.h b/src/include/c.h
index 39022f8a9dd..b580cfa7d31 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -259,8 +259,8 @@
  * choose not to.  But, if possible, don't force inlining in unoptimized
  * debug builds.
  */
-#if (defined(__GNUC__) && __GNUC__ > 3 && defined(__OPTIMIZE__)) || defined(__SUNPRO_C)
-/* GCC > 3 and Sunpro support always_inline via __attribute__ */
+#if (defined(__GNUC__) && defined(__OPTIMIZE__)) || defined(__SUNPRO_C)
+/* GCC and Sunpro support always_inline via __attribute__ */
 #define pg_attribute_always_inline __attribute__((always_inline)) inline
 #elif defined(_MSC_VER)
 /* MSVC has a special keyword for this */
@@ -277,7 +277,7 @@
  * above, this should be placed before the function's return type and name.
  */
 /* GCC and Sunpro support noinline via __attribute__ */
-#if (defined(__GNUC__) && __GNUC__ > 2) || defined(__SUNPRO_C)
+#if defined(__GNUC__) || defined(__SUNPRO_C)
 #define pg_noinline __attribute__((noinline))
 /* msvc via declspec */
 #elif defined(_MSC_VER)
@@ -369,7 +369,7 @@
  * These should only be used sparingly, in very hot code paths. It's very easy
  * to mis-estimate likelihoods.
  */
-#if __GNUC__ >= 3
+#ifdef __GNUC__
 #define likely(x)	__builtin_expect((x) != 0, 1)
 #define unlikely(x) __builtin_expect((x) != 0, 0)
 #else
diff --git a/src/include/port/atomics/generic-gcc.h b/src/include/port/atomics/generic-gcc.h
index d8f04c89cca..e7dfad4f0d5 100644
--- a/src/include/port/atomics/generic-gcc.h
+++ b/src/include/port/atomics/generic-gcc.h
@@ -30,14 +30,14 @@
 #define pg_compiler_barrier_impl()	__asm__ __volatile__("" ::: "memory")
 
 /*
- * If we're on GCC 4.1.0 or higher, we should be able to get a memory barrier
+ * If we're on GCC, we should be able to get a memory barrier
  * out of this compiler built-in.  But we prefer to rely on platform specific
  * definitions where possible, and use this only as a fallback.
  */
 #if !defined(pg_memory_barrier_impl)
 #	if defined(HAVE_GCC__ATOMIC_INT32_CAS)
 #		define pg_memory_barrier_impl()		__atomic_thread_fence(__ATOMIC_SEQ_CST)
-#	elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
+#	elif defined(__GNUC__)
 #		define pg_memory_barrier_impl()		__sync_synchronize()
 #	endif
 #endif /* !defined(pg_memory_barrier_impl) */
-- 
2.51.0