Remove checks for no longer supported GCC versions
authorPeter Eisentraut <peter@eisentraut.org>
Thu, 11 Sep 2025 09:55:29 +0000 (11:55 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Thu, 11 Sep 2025 10:05:59 +0000 (12:05 +0200)
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.

Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/a0f817ee-fb86-483a-8a14-b6f7f5991b6e%40eisentraut.org

src/include/c.h
src/include/port/atomics/generic-gcc.h

index 39022f8a9dd75adcf58d28c3f7ba43a7cd046d1f..b580cfa7d3178e839a069064a80809ee425984bd 100644 (file)
  * 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 */
  * 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)
  * 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
index d8f04c89ccac28bd24a7da2d097f57a9b454d1da..e7dfad4f0d5ebe7f627d3e58e0f94606a3cccda1 100644 (file)
 #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) */