From: Bruno Haible <bruno@clisp.org>
Date: Thu, 1 Aug 2024 11:24:10 +0000 (+0200)
Subject: strerror_r: Fix for AIX (regression yesterday).
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=cee2cccd0249103b246678699dd608b61e63ee02;p=gnulib.git

strerror_r: Fix for AIX (regression yesterday).

* lib/strerror_r.c: Ignore the value of STRERROR_R_CHAR_P on AIX.
* m4/strerror_r.m4 (gl_FUNC_STRERROR_R): Don't define
_LINUX_SOURCE_COMPAT, since it provides no advantage for strerror_r.
---

diff --git a/ChangeLog b/ChangeLog
index 78e4bd2f09..9acef580e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-08-01  Bruno Haible  <bruno@clisp.org>
+
+	strerror_r: Fix for AIX (regression yesterday).
+	* lib/strerror_r.c: Ignore the value of STRERROR_R_CHAR_P on AIX.
+	* m4/strerror_r.m4 (gl_FUNC_STRERROR_R): Don't define
+	_LINUX_SOURCE_COMPAT, since it provides no advantage for strerror_r.
+
 2024-07-31  Paul Eggert  <eggert@cs.ucla.edu>
 
 	errno: make EEXIST != ENOTEMPTY on AIX
diff --git a/lib/strerror_r.c b/lib/strerror_r.c
index 0cd28ade6e..87fc114262 100644
--- a/lib/strerror_r.c
+++ b/lib/strerror_r.c
@@ -34,7 +34,7 @@
 
 #include "strerror-override.h"
 
-#if STRERROR_R_CHAR_P
+#if STRERROR_R_CHAR_P && !defined _AIX
 
 # if HAVE___XPG_STRERROR_R
 _GL_EXTERN_C int __xpg_strerror_r (int errnum, char *buf, size_t buflen);
@@ -159,7 +159,10 @@ strerror_r (int errnum, char *buf, size_t buflen)
     int ret;
     int saved_errno = errno;
 
-#if STRERROR_R_CHAR_P
+    /* Due to the '#undef strerror_r' above, on AIX, we're always using
+       the POSIX-compatible strerror_r function, regardless whether
+       _LINUX_SOURCE_COMPAT is defined or not.  */
+#if STRERROR_R_CHAR_P && !defined _AIX
 
     {
       ret = 0;
diff --git a/m4/strerror_r.m4 b/m4/strerror_r.m4
index eae9f1c419..5353972172 100644
--- a/m4/strerror_r.m4
+++ b/m4/strerror_r.m4
@@ -1,5 +1,5 @@
 # strerror_r.m4
-# serial 27
+# serial 28
 dnl Copyright (C) 2002, 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,13 +10,6 @@ AC_DEFUN([gl_FUNC_STRERROR_R],
   AC_REQUIRE([gl_STRING_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS])
 
-  dnl On AIX, ask for the GNU/Linux API.  Other modules might ask for
-  dnl that API for other reasons, so we will will need override it because
-  dnl we cannot easily ask AIX for the GNU/Linux API for everything
-  dnl but strerror_r.
-  AC_DEFINE([_LINUX_SOURCE_COMPAT], [1],
-    [Define so that AIX headers are more compatible with GNU/Linux.])
-
   dnl Some systems don't declare strerror_r() if _THREAD_SAFE and _REENTRANT
   dnl are not defined.
   AC_CHECK_DECLS_ONCE([strerror_r])