v1-0004-Remove-configure-meson-checks-for-atomics.patch

application/octet-stream

Filename: v1-0004-Remove-configure-meson-checks-for-atomics.patch
Type: application/octet-stream
Part: 3
Message: Trying out <stdatomic.h>

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v1-0004
Subject: Remove configure/meson checks for atomics.
File+
config/c-compiler.m4 0 99
configure 0 200
configure.ac 0 10
meson.build 0 63
src/backend/Makefile 1 1
src/backend/port/.gitignore 0 1
src/include/pg_config.h.in 0 20
From 60d21c1950f92ed0b0a10b2cec29b242a17fa276 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Mon, 10 Nov 2025 23:03:00 +1300
Subject: [PATCH v1 4/4] Remove configure/meson checks for atomics.

These are now unreferenced, but this was kept separate from the two
patches that did that to disentangle them.
---
 config/c-compiler.m4        |  99 ------------------
 configure                   | 200 ------------------------------------
 configure.ac                |  10 --
 meson.build                 |  63 ------------
 src/backend/Makefile        |   2 +-
 src/backend/port/.gitignore |   1 -
 src/include/pg_config.h.in  |  20 ----
 7 files changed, 1 insertion(+), 394 deletions(-)

diff --git a/config/c-compiler.m4 b/config/c-compiler.m4
index 236a59e8536..e05570255b3 100644
--- a/config/c-compiler.m4
+++ b/config/c-compiler.m4
@@ -446,105 +446,6 @@ AC_DEFUN([PGAC_PROG_CC_LDFLAGS_OPT],
 [PGAC_PROG_CC_LD_VARFLAGS_OPT(LDFLAGS, [$1], [$2])
 ])# PGAC_PROG_CC_LDFLAGS_OPT
 
-
-# PGAC_HAVE_GCC__SYNC_CHAR_TAS
-# ----------------------------
-# Check if the C compiler understands __sync_lock_test_and_set(char),
-# and define HAVE_GCC__SYNC_CHAR_TAS
-#
-# NB: There are platforms where test_and_set is available but compare_and_swap
-# is not, so test this separately.
-# NB: Some platforms only do 32bit tas, others only do 8bit tas. Test both.
-AC_DEFUN([PGAC_HAVE_GCC__SYNC_CHAR_TAS],
-[AC_CACHE_CHECK(for builtin __sync char locking functions, pgac_cv_gcc_sync_char_tas,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([],
-  [char lock = 0;
-   __sync_lock_test_and_set(&lock, 1);
-   __sync_lock_release(&lock);])],
-  [pgac_cv_gcc_sync_char_tas="yes"],
-  [pgac_cv_gcc_sync_char_tas="no"])])
-if test x"$pgac_cv_gcc_sync_char_tas" = x"yes"; then
-  AC_DEFINE(HAVE_GCC__SYNC_CHAR_TAS, 1, [Define to 1 if you have __sync_lock_test_and_set(char *) and friends.])
-fi])# PGAC_HAVE_GCC__SYNC_CHAR_TAS
-
-# PGAC_HAVE_GCC__SYNC_INT32_TAS
-# -----------------------------
-# Check if the C compiler understands __sync_lock_test_and_set(),
-# and define HAVE_GCC__SYNC_INT32_TAS
-AC_DEFUN([PGAC_HAVE_GCC__SYNC_INT32_TAS],
-[AC_CACHE_CHECK(for builtin __sync int32 locking functions, pgac_cv_gcc_sync_int32_tas,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([],
-  [int lock = 0;
-   __sync_lock_test_and_set(&lock, 1);
-   __sync_lock_release(&lock);])],
-  [pgac_cv_gcc_sync_int32_tas="yes"],
-  [pgac_cv_gcc_sync_int32_tas="no"])])
-if test x"$pgac_cv_gcc_sync_int32_tas" = x"yes"; then
-  AC_DEFINE(HAVE_GCC__SYNC_INT32_TAS, 1, [Define to 1 if you have __sync_lock_test_and_set(int *) and friends.])
-fi])# PGAC_HAVE_GCC__SYNC_INT32_TAS
-
-# PGAC_HAVE_GCC__SYNC_INT32_CAS
-# -----------------------------
-# Check if the C compiler understands __sync_compare_and_swap() for 32bit
-# types, and define HAVE_GCC__SYNC_INT32_CAS if so.
-AC_DEFUN([PGAC_HAVE_GCC__SYNC_INT32_CAS],
-[AC_CACHE_CHECK(for builtin __sync int32 atomic operations, pgac_cv_gcc_sync_int32_cas,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([],
-  [int val = 0;
-   __sync_val_compare_and_swap(&val, 0, 37);])],
-  [pgac_cv_gcc_sync_int32_cas="yes"],
-  [pgac_cv_gcc_sync_int32_cas="no"])])
-if test x"$pgac_cv_gcc_sync_int32_cas" = x"yes"; then
-  AC_DEFINE(HAVE_GCC__SYNC_INT32_CAS, 1, [Define to 1 if you have __sync_val_compare_and_swap(int *, int, int).])
-fi])# PGAC_HAVE_GCC__SYNC_INT32_CAS
-
-# PGAC_HAVE_GCC__SYNC_INT64_CAS
-# -----------------------------
-# Check if the C compiler understands __sync_compare_and_swap() for 64bit
-# types, and define HAVE_GCC__SYNC_INT64_CAS if so.
-AC_DEFUN([PGAC_HAVE_GCC__SYNC_INT64_CAS],
-[AC_CACHE_CHECK(for builtin __sync int64 atomic operations, pgac_cv_gcc_sync_int64_cas,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdint.h>],
-  [int64_t lock = 0;
-   __sync_val_compare_and_swap(&lock, 0, (int64_t) 37);])],
-  [pgac_cv_gcc_sync_int64_cas="yes"],
-  [pgac_cv_gcc_sync_int64_cas="no"])])
-if test x"$pgac_cv_gcc_sync_int64_cas" = x"yes"; then
-  AC_DEFINE(HAVE_GCC__SYNC_INT64_CAS, 1, [Define to 1 if you have __sync_val_compare_and_swap(int64_t *, int64_t, int64_t).])
-fi])# PGAC_HAVE_GCC__SYNC_INT64_CAS
-
-# PGAC_HAVE_GCC__ATOMIC_INT32_CAS
-# -------------------------------
-# Check if the C compiler understands __atomic_compare_exchange_n() for 32bit
-# types, and define HAVE_GCC__ATOMIC_INT32_CAS if so.
-AC_DEFUN([PGAC_HAVE_GCC__ATOMIC_INT32_CAS],
-[AC_CACHE_CHECK(for builtin __atomic int32 atomic operations, pgac_cv_gcc_atomic_int32_cas,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([],
-  [int val = 0;
-   int expect = 0;
-   __atomic_compare_exchange_n(&val, &expect, 37, 0, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);])],
-  [pgac_cv_gcc_atomic_int32_cas="yes"],
-  [pgac_cv_gcc_atomic_int32_cas="no"])])
-if test x"$pgac_cv_gcc_atomic_int32_cas" = x"yes"; then
-  AC_DEFINE(HAVE_GCC__ATOMIC_INT32_CAS, 1, [Define to 1 if you have __atomic_compare_exchange_n(int *, int *, int).])
-fi])# PGAC_HAVE_GCC__ATOMIC_INT32_CAS
-
-# PGAC_HAVE_GCC__ATOMIC_INT64_CAS
-# -------------------------------
-# Check if the C compiler understands __atomic_compare_exchange_n() for 64bit
-# types, and define HAVE_GCC__ATOMIC_INT64_CAS if so.
-AC_DEFUN([PGAC_HAVE_GCC__ATOMIC_INT64_CAS],
-[AC_CACHE_CHECK(for builtin __atomic int64 atomic operations, pgac_cv_gcc_atomic_int64_cas,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdint.h>],
-  [int64_t val = 0;
-   int64_t expect = 0;
-   __atomic_compare_exchange_n(&val, &expect, 37, 0, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);])],
-  [pgac_cv_gcc_atomic_int64_cas="yes"],
-  [pgac_cv_gcc_atomic_int64_cas="no"])])
-if test x"$pgac_cv_gcc_atomic_int64_cas" = x"yes"; then
-  AC_DEFINE(HAVE_GCC__ATOMIC_INT64_CAS, 1, [Define to 1 if you have __atomic_compare_exchange_n(int64 *, int64 *, int64).])
-fi])# PGAC_HAVE_GCC__ATOMIC_INT64_CAS
-
 # PGAC_SSE42_CRC32_INTRINSICS
 # ---------------------------
 # Check if the compiler supports the x86 CRC instructions added in SSE 4.2,
diff --git a/configure b/configure
index 3a0ed11fa8e..bd7dee3fdf3 100755
--- a/configure
+++ b/configure
@@ -17167,206 +17167,6 @@ _ACEOF
   fi
 fi
 
-# Check for various atomic operations now that we have checked how to declare
-# 64bit integers.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for builtin __sync char locking functions" >&5
-$as_echo_n "checking for builtin __sync char locking functions... " >&6; }
-if ${pgac_cv_gcc_sync_char_tas+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-char lock = 0;
-   __sync_lock_test_and_set(&lock, 1);
-   __sync_lock_release(&lock);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  pgac_cv_gcc_sync_char_tas="yes"
-else
-  pgac_cv_gcc_sync_char_tas="no"
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_gcc_sync_char_tas" >&5
-$as_echo "$pgac_cv_gcc_sync_char_tas" >&6; }
-if test x"$pgac_cv_gcc_sync_char_tas" = x"yes"; then
-
-$as_echo "#define HAVE_GCC__SYNC_CHAR_TAS 1" >>confdefs.h
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for builtin __sync int32 locking functions" >&5
-$as_echo_n "checking for builtin __sync int32 locking functions... " >&6; }
-if ${pgac_cv_gcc_sync_int32_tas+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-int lock = 0;
-   __sync_lock_test_and_set(&lock, 1);
-   __sync_lock_release(&lock);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  pgac_cv_gcc_sync_int32_tas="yes"
-else
-  pgac_cv_gcc_sync_int32_tas="no"
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_gcc_sync_int32_tas" >&5
-$as_echo "$pgac_cv_gcc_sync_int32_tas" >&6; }
-if test x"$pgac_cv_gcc_sync_int32_tas" = x"yes"; then
-
-$as_echo "#define HAVE_GCC__SYNC_INT32_TAS 1" >>confdefs.h
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for builtin __sync int32 atomic operations" >&5
-$as_echo_n "checking for builtin __sync int32 atomic operations... " >&6; }
-if ${pgac_cv_gcc_sync_int32_cas+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-int val = 0;
-   __sync_val_compare_and_swap(&val, 0, 37);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  pgac_cv_gcc_sync_int32_cas="yes"
-else
-  pgac_cv_gcc_sync_int32_cas="no"
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_gcc_sync_int32_cas" >&5
-$as_echo "$pgac_cv_gcc_sync_int32_cas" >&6; }
-if test x"$pgac_cv_gcc_sync_int32_cas" = x"yes"; then
-
-$as_echo "#define HAVE_GCC__SYNC_INT32_CAS 1" >>confdefs.h
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for builtin __sync int64 atomic operations" >&5
-$as_echo_n "checking for builtin __sync int64 atomic operations... " >&6; }
-if ${pgac_cv_gcc_sync_int64_cas+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdint.h>
-int
-main ()
-{
-int64_t lock = 0;
-   __sync_val_compare_and_swap(&lock, 0, (int64_t) 37);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  pgac_cv_gcc_sync_int64_cas="yes"
-else
-  pgac_cv_gcc_sync_int64_cas="no"
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_gcc_sync_int64_cas" >&5
-$as_echo "$pgac_cv_gcc_sync_int64_cas" >&6; }
-if test x"$pgac_cv_gcc_sync_int64_cas" = x"yes"; then
-
-$as_echo "#define HAVE_GCC__SYNC_INT64_CAS 1" >>confdefs.h
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for builtin __atomic int32 atomic operations" >&5
-$as_echo_n "checking for builtin __atomic int32 atomic operations... " >&6; }
-if ${pgac_cv_gcc_atomic_int32_cas+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-int val = 0;
-   int expect = 0;
-   __atomic_compare_exchange_n(&val, &expect, 37, 0, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  pgac_cv_gcc_atomic_int32_cas="yes"
-else
-  pgac_cv_gcc_atomic_int32_cas="no"
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_gcc_atomic_int32_cas" >&5
-$as_echo "$pgac_cv_gcc_atomic_int32_cas" >&6; }
-if test x"$pgac_cv_gcc_atomic_int32_cas" = x"yes"; then
-
-$as_echo "#define HAVE_GCC__ATOMIC_INT32_CAS 1" >>confdefs.h
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for builtin __atomic int64 atomic operations" >&5
-$as_echo_n "checking for builtin __atomic int64 atomic operations... " >&6; }
-if ${pgac_cv_gcc_atomic_int64_cas+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdint.h>
-int
-main ()
-{
-int64_t val = 0;
-   int64_t expect = 0;
-   __atomic_compare_exchange_n(&val, &expect, 37, 0, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  pgac_cv_gcc_atomic_int64_cas="yes"
-else
-  pgac_cv_gcc_atomic_int64_cas="no"
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_gcc_atomic_int64_cas" >&5
-$as_echo "$pgac_cv_gcc_atomic_int64_cas" >&6; }
-if test x"$pgac_cv_gcc_atomic_int64_cas" = x"yes"; then
-
-$as_echo "#define HAVE_GCC__ATOMIC_INT64_CAS 1" >>confdefs.h
-
-fi
-
-
 # Check for __get_cpuid() and __cpuid()
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __get_cpuid" >&5
 $as_echo_n "checking for __get_cpuid... " >&6; }
diff --git a/configure.ac b/configure.ac
index c2413720a18..e3b75601df7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2019,16 +2019,6 @@ AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignme
 # Some compilers offer a 128-bit integer scalar type.
 PGAC_TYPE_128BIT_INT
 
-# Check for various atomic operations now that we have checked how to declare
-# 64bit integers.
-PGAC_HAVE_GCC__SYNC_CHAR_TAS
-PGAC_HAVE_GCC__SYNC_INT32_TAS
-PGAC_HAVE_GCC__SYNC_INT32_CAS
-PGAC_HAVE_GCC__SYNC_INT64_CAS
-PGAC_HAVE_GCC__ATOMIC_INT32_CAS
-PGAC_HAVE_GCC__ATOMIC_INT64_CAS
-
-
 # Check for __get_cpuid() and __cpuid()
 AC_CACHE_CHECK([for __get_cpuid], [pgac_cv__get_cpuid],
 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <cpuid.h>],
diff --git a/meson.build b/meson.build
index 24aeffe929f..3b88f63b0df 100644
--- a/meson.build
+++ b/meson.build
@@ -2212,69 +2212,6 @@ if llvm.found()
 endif
 
 
-
-###############################################################
-# Atomics
-###############################################################
-
-atomic_checks = [
-  {'name': 'HAVE_GCC__SYNC_CHAR_TAS',
-   'desc': '__sync_lock_test_and_set(char)',
-   'test': '''
-char lock = 0;
-__sync_lock_test_and_set(&lock, 1);
-__sync_lock_release(&lock);'''},
-
-  {'name': 'HAVE_GCC__SYNC_INT32_TAS',
-   'desc': '__sync_lock_test_and_set(int32)',
-   'test': '''
-int lock = 0;
-__sync_lock_test_and_set(&lock, 1);
-__sync_lock_release(&lock);'''},
-
-  {'name': 'HAVE_GCC__SYNC_INT32_CAS',
-   'desc': '__sync_val_compare_and_swap(int32)',
-   'test': '''
-int val = 0;
-__sync_val_compare_and_swap(&val, 0, 37);'''},
-
-  {'name': 'HAVE_GCC__SYNC_INT64_CAS',
-   'desc': '__sync_val_compare_and_swap(int64)',
-   'test': '''
-int64_t val = 0;
-__sync_val_compare_and_swap(&val, 0, 37);'''},
-
-  {'name': 'HAVE_GCC__ATOMIC_INT32_CAS',
-   'desc': ' __atomic_compare_exchange_n(int32)',
-   'test': '''
-int val = 0;
-int expect = 0;
-__atomic_compare_exchange_n(&val, &expect, 37, 0, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);'''},
-
-  {'name': 'HAVE_GCC__ATOMIC_INT64_CAS',
-   'desc': ' __atomic_compare_exchange_n(int64)',
-   'test': '''
-int64_t val = 0;
-int64_t expect = 0;
-__atomic_compare_exchange_n(&val, &expect, 37, 0, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);'''},
-]
-
-foreach check : atomic_checks
-  test = '''
-#include <stdint.h>
-int main(void)
-{
-@0@
-}'''.format(check['test'])
-
-  cdata.set(check['name'],
-    cc.links(test,
-      name: check['desc'],
-      args: test_c_args) ? 1 : false
-  )
-endforeach
-
-
 ###############################################################
 # Check for the availability of XSAVE intrinsics.
 ###############################################################
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 7344c8c7f5c..b0d97dc2fa2 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -265,7 +265,7 @@ endif
 
 distclean: clean
 # generated by configure
-	rm -f port/tas.s port/pg_sema.c port/pg_shmem.c
+	rm -f port/pg_sema.c port/pg_shmem.c
 
 
 ##########################################################################
diff --git a/src/backend/port/.gitignore b/src/backend/port/.gitignore
index 4ef36b82c77..6c5067a4a9f 100644
--- a/src/backend/port/.gitignore
+++ b/src/backend/port/.gitignore
@@ -1,3 +1,2 @@
 /pg_sema.c
 /pg_shmem.c
-/tas.s
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index b0b0cfdaf79..ad5663a8915 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -149,26 +149,6 @@
 /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
 #undef HAVE_FSEEKO
 
-/* Define to 1 if you have __atomic_compare_exchange_n(int *, int *, int). */
-#undef HAVE_GCC__ATOMIC_INT32_CAS
-
-/* Define to 1 if you have __atomic_compare_exchange_n(int64 *, int64 *,
-   int64). */
-#undef HAVE_GCC__ATOMIC_INT64_CAS
-
-/* Define to 1 if you have __sync_lock_test_and_set(char *) and friends. */
-#undef HAVE_GCC__SYNC_CHAR_TAS
-
-/* Define to 1 if you have __sync_val_compare_and_swap(int *, int, int). */
-#undef HAVE_GCC__SYNC_INT32_CAS
-
-/* Define to 1 if you have __sync_lock_test_and_set(int *) and friends. */
-#undef HAVE_GCC__SYNC_INT32_TAS
-
-/* Define to 1 if you have __sync_val_compare_and_swap(int64_t *, int64_t,
-   int64_t). */
-#undef HAVE_GCC__SYNC_INT64_CAS
-
 /* Define to 1 if you have the `getauxval' function. */
 #undef HAVE_GETAUXVAL
 
-- 
2.50.1 (Apple Git-155)