From 56bc1edad9f2a3d868f2365f134462b7888108ea Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 24 Jul 2024 23:35:53 +0200
Subject: [PATCH] Avoid false error
 close_used_without_requesting_gnulib_module_close.
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

Reported by Frédéric at <https://savannah.gnu.org/bugs/?65958>.

* modules/close (configure.ac): Invoke gl_MODULE_INDICATOR.
* lib/unistd.in.h (close): Don't define to
close_used_without_requesting_gnulib_module_close if the gnulib module
'close' is in use under the same configure.ac.
---
 ChangeLog       | 9 +++++++++
 lib/unistd.in.h | 6 ++++--
 modules/close   | 1 +
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a96c219d7e..e874cdc003 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-07-24  Bruno Haible  <bruno@clisp.org>
+
+	Avoid false error close_used_without_requesting_gnulib_module_close.
+	Reported by Frédéric at <https://savannah.gnu.org/bugs/?65958>.
+	* modules/close (configure.ac): Invoke gl_MODULE_INDICATOR.
+	* lib/unistd.in.h (close): Don't define to
+	close_used_without_requesting_gnulib_module_close if the gnulib module
+	'close' is in use under the same configure.ac.
+
 2024-07-24  Bruno Haible  <bruno@clisp.org>
 
 	xstrtod, xstrtold: Don't treat gradual underflow as an error.
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index e01629af25..688988e9e2 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -412,8 +412,10 @@ _GL_CXXALIAS_SYS (close, int, (int fd));
 # endif
 _GL_CXXALIASWARN (close);
 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
-# undef close
-# define close close_used_without_requesting_gnulib_module_close
+# if !GNULIB_CLOSE
+#  undef close
+#  define close close_used_without_requesting_gnulib_module_close
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef close
 /* Assume close is always declared.  */
diff --git a/modules/close b/modules/close
index 926ea85501..fbb54063c6 100644
--- a/modules/close
+++ b/modules/close
@@ -14,6 +14,7 @@ configure.ac:
 gl_FUNC_CLOSE
 gl_CONDITIONAL([GL_COND_OBJ_CLOSE], [test $REPLACE_CLOSE = 1])
 gl_UNISTD_MODULE_INDICATOR([close])
+gl_MODULE_INDICATOR([close])
 
 Makefile.am:
 if GL_COND_OBJ_CLOSE
-- 
2.39.5