From aefacfeaae17b353e82b54df5a5565e0e9cc6a2c Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Thu, 19 Feb 2026 15:38:39 -0500
Subject: [PATCH v7 6/8] Add some definitions needed for a clean compile.

AIX has getpeereid() and wcstombs_l() in libc, so configure finds them
and tries to use them.  But they aren't declared in system headers
(as of 7.3, anyway) so we get implicit-function-declaration warnings.

We could probe for the existence of these declarations, but given
that they're not in POSIX it's not completely clear which headers
to check.  Let's just supply hard-wired externs in aix.h, instead.

Like old Solaris, AIX never added "const" to the second argument
of PAM conversation procs.  We can leverage what e6dfd068e did
about that to silence the "incompatible pointer" compiler warning
(which'll be an error with GCC 14 and later, so fixing it is
important).
---
 src/include/port/aix.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/include/port/aix.h b/src/include/port/aix.h
index c86983a4452..211b048cfbf 100644
--- a/src/include/port/aix.h
+++ b/src/include/port/aix.h
@@ -1,3 +1,22 @@
 /*
  * src/include/port/aix.h
  */
+#include <stddef.h>				/* for size_t */
+#include <sys/types.h>			/* for uid_t and gid_t */
+#include <wchar.h>				/* for wchar_t and locale_t */
+
+/* AIX has getpeereid(), but fails to declare it as of 7.3 */
+extern int	getpeereid(int socket, uid_t *euid, gid_t *egid);
+
+/* AIX has wcstombs_l(), but fails to declare it as of 7.3 */
+extern size_t wcstombs_l(char *dest, const wchar_t *src, size_t n,
+						 locale_t loc);
+
+/*
+ * AIX doesn't seem to have ever modernized pam_appl.h to include
+ * "const" in the declaration of PAM conversation procs.  We can avoid
+ * a compile error by setting _PAM_LEGACY_NONCONST; that doesn't do
+ * anything in AIX's system headers, but it makes us omit the "const"
+ * in our own code.  (Compare solaris.h.)
+ */
+#define _PAM_LEGACY_NONCONST 1
-- 
2.43.7

