From e8d30b7e89dcf789ceab75bf13f3956658a8ea09 Mon Sep 17 00:00:00 2001
From: Timur Magomedov <t.magomedov@postgrespro.ru>
Date: Fri, 30 May 2025 20:08:15 +0300
Subject: [PATCH 3/4] Removed unused OS-specific CAS functions

---
 contrib/vci/include/vci_mem.h          |  1 -
 contrib/vci/include/vci_port_linux.h   |  7 -------
 contrib/vci/include/vci_port_solaris.h |  6 ------
 contrib/vci/include/vci_port_windows.h | 26 --------------------------
 contrib/vci/include/vci_ros.h          | 13 -------------
 5 files changed, 53 deletions(-)

diff --git a/contrib/vci/include/vci_mem.h b/contrib/vci/include/vci_mem.h
index 4225682a71f..c36c21d9e2f 100644
--- a/contrib/vci/include/vci_mem.h
+++ b/contrib/vci/include/vci_mem.h
@@ -19,7 +19,6 @@
 #include "utils/palloc.h"
 
 #include "vci.h"
-#include "vci_port.h"
 #include "vci_ros.h"
 #include "vci_memory_entry.h"
 
diff --git a/contrib/vci/include/vci_port_linux.h b/contrib/vci/include/vci_port_linux.h
index a6ed0f2e3e7..edefb70ad19 100644
--- a/contrib/vci/include/vci_port_linux.h
+++ b/contrib/vci/include/vci_port_linux.h
@@ -25,13 +25,6 @@
 #define VCI_NAME_MAX			NAME_MAX
 #define VCI_PATH_MAX			PATH_MAX
 
-static inline int64
-vci_CompareAndSwap64(volatile int64 *ptr, int64 oldValue, int64 newValue)
-{
-	/* GCC build-in function */
-	return __sync_val_compare_and_swap(ptr, oldValue, newValue);
-}
-
 /**
  * values in /proc/diskstats
  * For more detail, see https://www.kernel.org/doc/Documentation/iostats.txt
diff --git a/contrib/vci/include/vci_port_solaris.h b/contrib/vci/include/vci_port_solaris.h
index a2eecf753aa..cf2878fd139 100644
--- a/contrib/vci/include/vci_port_solaris.h
+++ b/contrib/vci/include/vci_port_solaris.h
@@ -24,10 +24,4 @@
 #define VCI_FULLPATH_FMT		"%s/%s"
 #define VCI_MOUNTS_FILE			"/etc/mnttab"
 
-static inline int64
-vci_CompareAndSwap64(volatile int64 *ptr, int64 oldValue, int64 newValue)
-{
-	return atomic_cas_64(ptr, oldValue, newValue);
-}
-
 #endif							/* VCI_PORT_SOLARIS_H */
diff --git a/contrib/vci/include/vci_port_windows.h b/contrib/vci/include/vci_port_windows.h
index 40d28ea6662..241f602b49d 100644
--- a/contrib/vci/include/vci_port_windows.h
+++ b/contrib/vci/include/vci_port_windows.h
@@ -21,30 +21,4 @@
 #endif							/* #if defined(_MSC_VER) ||
 								 * defined(__BORLANDC__) */
 
-#ifdef __GCC__
-static inline int64
-vci_CompareAndSwap64(volatile int64 *ptr, int64 oldValue, int64 newValue)
-{
-	/* GCC build-in function */
-	return __sync_val_compare_and_swap(ptr, oldValue, newValue);
-}
-#endif							/* #ifdef __GCC__ */
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-static inline int64
-vci_CompareAndSwap64(volatile int64 *ptr, int64 oldValue, int64 newValue)
-{
-	/* Visual studio built-in function */
-	return _InterlockedCompareExchange64(ptr, oldValue, newValue);
-}
-#endif							/* #if defined(_MSC_VER) ||
-								 * defined(__BORLANDC__) */
-
-extern bool vci_ReserveSharedMemoryRegion(HANDLE hProcess, void **addr_p, Size size);
-
-extern pid_t vci_getpid(void);
-#ifndef getpid
-#define getpid vci_getpid
-#endif
-
 #endif							/* VCI_PORT_WINDOWS_H */
diff --git a/contrib/vci/include/vci_ros.h b/contrib/vci/include/vci_ros.h
index bfafede1af6..a92b3864559 100644
--- a/contrib/vci/include/vci_ros.h
+++ b/contrib/vci/include/vci_ros.h
@@ -1067,19 +1067,6 @@ Buffer
 										   const void *data_,
 										   Size size);
 
-static inline void
-vci_SetValueAtomically64(volatile int64 *ptr, int64 val)
-{
-	int64		oldValue;
-	int64		chkValue;
-
-	do
-	{
-		oldValue = *ptr;
-		chkValue = vci_CompareAndSwap64(ptr, oldValue, val);
-	} while (oldValue != chkValue);
-}
-
 typedef struct vci_meta_item_scanner
 {
 	bool		inited;
-- 
2.43.0

