From 0d69a26fc1b52fb3e274176a83e7772b05bd7025 Mon Sep 17 00:00:00 2001
From: Sriram RK <sriram.rk@in.ibm.com>
Date: Tue, 13 Aug 2024 08:19:25 -0500
Subject: [PATCH] AIX support revert changes from 0b16bb8776bb. Review comments
 from Heikki

---
 configure                    | 17 ++---------------
 configure.ac                 |  5 +----
 src/include/port/aix.h       |  8 --------
 src/include/storage/s_lock.h |  6 ------
 src/template/aix             | 12 ------------
 5 files changed, 3 insertions(+), 45 deletions(-)

diff --git a/configure b/configure
index 03271f1861..f218b2e040 100755
--- a/configure
+++ b/configure
@@ -6849,12 +6849,6 @@ if test x"$pgac_cv_prog_CXX_cxxflags__fno_strict_aliasing" = x"yes"; then
   CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
 fi
 
-
-elif test "$PORTNAME" = "aix"; then
-  # AIX's xlc has to have strict aliasing turned off too
-  # Igonoring the XLC falgs -qnoansialias, -qlonglong
-{ $as_echo_n "Running AIX gcc for now... " >&6; }
-
 fi
 
 # If the compiler knows how to hide symbols, add the switch needed for that to
@@ -7009,9 +7003,6 @@ if test x"$pgac_cv_prog_CXX_cxxflags__fvisibility_inlines_hidden" = x"yes"; then
 fi
 
   have_visibility_attribute=$pgac_cv_prog_CC_cflags__fvisibility_hidden
-elif test "$PORTNAME" = "aix"; then
-  # Note that xlc accepts -fvisibility=hidden as a file.
-  { $as_echo_n "Running AIX gcc for now... " >&6; }
 fi
 
 if test "$have_visibility_attribute" = "yes"; then
@@ -14728,10 +14719,6 @@ fi
 # spelling it understands, because it conflicts with
 # __declspec(restrict). Therefore we define pg_restrict to the
 # appropriate definition, which presumably won't conflict.
-#
-# Allow platforms with buggy compilers to force restrict to not be
-# used by setting $FORCE_DISABLE_RESTRICT=yes in the relevant
-# template.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5
 $as_echo_n "checking for C/C++ restrict keyword... " >&6; }
 if ${ac_cv_c_restrict+:} false; then :
@@ -14778,7 +14765,7 @@ _ACEOF
  ;;
  esac
 
-if test "$ac_cv_c_restrict" = "no" -o "x$FORCE_DISABLE_RESTRICT" = "xyes"; then
+if test "$ac_cv_c_restrict" = "no"; then
   pg_restrict=""
 else
   pg_restrict="$ac_cv_c_restrict"
@@ -17094,7 +17081,7 @@ else
 /* end confdefs.h.  */
 
 /* This must match the corresponding code in c.h: */
-#if defined(__GNUC__) || defined(__SUNPRO_C)
+#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
 #define pg_attribute_aligned(a) __attribute__((aligned(a)))
 #elif defined(_MSC_VER)
 #define pg_attribute_aligned(a) __declspec(align(a))
diff --git a/configure.ac b/configure.ac
index 22069395a6..a059509cd9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1646,11 +1646,8 @@ PGAC_TYPE_LOCALE_T
 # __declspec(restrict). Therefore we define pg_restrict to the
 # appropriate definition, which presumably won't conflict.
 #
-# Allow platforms with buggy compilers to force restrict to not be
-# used by setting $FORCE_DISABLE_RESTRICT=yes in the relevant
-# template.
 AC_C_RESTRICT
-if test "$ac_cv_c_restrict" = "no" -o "x$FORCE_DISABLE_RESTRICT" = "xyes"; then
+if test "$ac_cv_c_restrict" = "no" ; then
   pg_restrict=""
 else
   pg_restrict="$ac_cv_c_restrict"
diff --git a/src/include/port/aix.h b/src/include/port/aix.h
index c54c95d4a5..1c2d166791 100644
--- a/src/include/port/aix.h
+++ b/src/include/port/aix.h
@@ -4,11 +4,3 @@
 #define CLASS_CONFLICT
 #define DISABLE_XOPEN_NLS
 
-/* Commenting for XLC
- * "IBM XL C/C++ for AIX, V12.1" miscompiles, for 32-bit, some inline
- * expansions of ginCompareItemPointers() "long long" arithmetic.  To take
- * advantage of inlining, build a 64-bit PostgreSQL.
-#if defined(__ILP32__) && defined(__IBMC__)
-#define PG_FORCE_DISABLE_INLINE
-#endif
- */
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 69582f4ae7..2f6eb5df2a 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -414,12 +414,6 @@ typedef unsigned int slock_t;
  * an isync is a sufficient synchronization barrier after a lwarx/stwcx loop.
  * But if the spinlock is in ordinary memory, we can use lwsync instead for
  * better performance.
- *
- * Ordinarily, we'd code the branches here using GNU-style local symbols, that
- * is "1f" referencing "1:" and so on.  But some people run gcc on AIX with
- * IBM's assembler as backend, and IBM's assembler doesn't do local symbols.
- * So hand-code the branch offsets; fortunately, all PPC instructions are
- * exactly 4 bytes each, so it's not too hard to count.
  */
 static __inline__ int
 tas(volatile slock_t *lock)
diff --git a/src/template/aix b/src/template/aix
index 903f8a8f8a..0a788676c0 100644
--- a/src/template/aix
+++ b/src/template/aix
@@ -1,17 +1,5 @@
 # src/template/aix
 
-# Commenting for XLC
-# Set default options if using xlc.  This formerly included -qsrcmsg, but that
-# option elicits internal compiler errors from xlc v16.1.0.  Note: configure
-# will add -qnoansialias if the compiler accepts it, even if user specifies a
-# non-default CFLAGS setting.
-#if test "$GCC" != yes ; then
-#  case $host_os in
-#    *)
-#      CFLAGS="-O2 -qmaxmem=16384"
-#      ;;
-#  esac
-
   # Due to a compiler bug, see 20171013023536.GA492146@rfd.leadboat.com for details,
   # force restrict not to be used when compiling with xlc.
 #  FORCE_DISABLE_RESTRICT=yes
-- 
2.41.0

