Gnulib supports multiple gnulib-tool invocations in the scope of the same
configure.ac since 2021 (cf. 2021-04-11, 2021-04-17, 2021-06-13). Namely,
the module indicator variable (@GNULIB_<module>@) expand to something that
depends on the gnulib-tool invocation.
This is still not working right with some header files, however. Namely,
the _GL_ALREADY_INCLUDING_*_H macros are a problem. In a build of GNU gettext
on mingw 13, I am seeing a compilation error:
gcc -DHAVE_CONFIG_H -I. -I../../../../gettext-tools/tests/gnulib-lib -I../..
-I../../gnulib-lib -I../../../../gettext-tools/gnulib-lib
-I/usr/local/mingw64/include -Wall -Wno-cast-qual -Wno-conversion
-Wno-float-equal -Wno-sign-compare -Wno-undef -Wno-unused-function
-Wno-unused-parameter -Wno-float-conversion -Wimplicit-fallthrough
-Wno-pedantic -Wno-sign-conversion -Wno-type-limits -Wno-unused-const-variable
-Wno-unsuffixed-float-constants -g -O2 -MT libtestsgnu_a-pthread_sigmask.o -MD
-MP -MF .deps/libtestsgnu_a-pthread_sigmask.Tpo -c -o
libtestsgnu_a-pthread_sigmask.o `test -f 'pthread_sigmask.c' || echo
'../../../../gettext-tools/tests/gnulib-lib/'`pthread_sigmask.c
../../../../gettext-tools/tests/gnulib-lib/pthread_sigmask.c: In function
'rpl_pthread_sigmask':
../../../../gettext-tools/tests/gnulib-lib/pthread_sigmask.c:89:13: error:
implicit declaration of function 'sigprocmask' [-Wimplicit-function-declaration]
89 | int ret = sigprocmask (how, new_mask, old_mask);
| ^~~~~~~~~~~
make[5]: *** [Makefile:3963: libtestsgnu_a-pthread_sigmask.o] Error 1
The module 'pthread_sigmask' depends on the module 'sigprocmask', so why
is sigprocmask not declared? It ought to be declared in gnulib's signal.h
override. The reason is that there are two signal.h overrides:
1. tests/gnulib-lib/signal.h
2. gnulib-lib/signal.h
In the gnulib-tool invocation #1, @GNULIB_SIGPROCMASK@ expands to 0.
In the gnulib-tool invocation #2, @GNULIB_SIGPROCMASK@ expands to 1.
When pthread_sigmask.c does #include <signal.h>, the include_next chain
consists of
1. tests/gnulib-lib/signal.h
2. gnulib-lib/signal.h
3. the system's <signal.h>,
and since #1 defines _GL_ALREADY_INCLUDING_SIGNAL_H, #2 becomes
essentially a no-op. Thus the declaration of sigprocmask in #2 is hidden.
Here's a patch series that fixes that.
2024-12-24 Bruno Haible <[email protected]>
wchar: Support several gnulib-tool invocations better.
* lib/wchar.in.h (_GL_ALREADY_INCLUDING_WCHAR_H): Rename to a macro that
depends on GUARD_PREFIX.
(mbszero): Avoid duplicate definition.
2024-12-24 Bruno Haible <[email protected]>
threads-h: Support several gnulib-tool invocations better.
* lib/threads.in.h (_GL_ALREADY_INCLUDING_THREADS_H): Rename to a macro
that depends on GUARD_PREFIX.
(struct thrd_with_exitcode): Avoid duplicate definition.
2024-12-24 Bruno Haible <[email protected]>
sys_socket: Support several gnulib-tool invocations better.
* lib/sys_socket.in.h (_GL_ALREADY_INCLUDING_SYS_SOCKET_H): Rename to a
macro that depends on GUARD_PREFIX.
(struct msghdr): Avoid duplicate definition.
2024-12-24 Bruno Haible <[email protected]>
string: Support several gnulib-tool invocations better.
* lib/string.in.h (_GL_ALREADY_INCLUDING_STRING_H): Rename to a macro
that depends on GUARD_PREFIX.
2024-12-24 Bruno Haible <[email protected]>
stdio: Support several gnulib-tool invocations better.
* lib/stdio.in.h: Test _GL_SKIP_GNULIB_STDIO_H.
(_GL_ALREADY_INCLUDING_STDIO_H): Rename to a macro that depends on
GUARD_PREFIX.
* lib/fopen.c: Set _GL_SKIP_GNULIB_STDIO_H instead of
_GL_ALREADY_INCLUDING_STDIO_H.
* lib/freopen.c: Likewise.
2024-12-24 Bruno Haible <[email protected]>
spawn: Support several gnulib-tool invocations better.
* lib/spawn.in.h (_GL_ALREADY_INCLUDING_SPAWN_H): Rename to a macro that
depends on GUARD_PREFIX.
2024-12-24 Bruno Haible <[email protected]>
signal-h: Support several gnulib-tool invocations better.
* lib/signal.in.h (_GL_ALREADY_INCLUDING_SIGNAL_H): Rename to a macro
that depends on GUARD_PREFIX.
2024-12-24 Bruno Haible <[email protected]>
pthread-h: Support several gnulib-tool invocations better.
* lib/pthread.in.h (_GL_ALREADY_INCLUDING_PTHREAD_H): Rename to a macro
that depends on GUARD_PREFIX.
2024-12-24 Bruno Haible <[email protected]>
malloc-h: Support several gnulib-tool invocations better.
* lib/malloc.in.h (_GL_ALREADY_INCLUDING_MALLOC_H): Rename to a macro
that depends on GUARD_PREFIX.
2024-12-24 Bruno Haible <[email protected]>
locale: Support several gnulib-tool invocations better.
* lib/locale.in.h (_GL_ALREADY_INCLUDING_LOCALE_H): Rename to a macro
that depends on GUARD_PREFIX.
(struct lconv): Avoid duplicate definition.
2024-12-24 Bruno Haible <[email protected]>
limits-h: Support several gnulib-tool invocations better.
* lib/limits.in.h (_GL_ALREADY_INCLUDING_LIMITS_H): Rename to a macro
that depends on GUARD_PREFIX.
>From 31682bc14840b2e003f5ca3cc90378dabd6e256a Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Tue, 24 Dec 2024 11:13:16 +0100
Subject: [PATCH 01/11] limits-h: Support several gnulib-tool invocations
better.
* lib/limits.in.h (_GL_ALREADY_INCLUDING_LIMITS_H): Rename to a macro
that depends on GUARD_PREFIX.
---
ChangeLog | 6 ++++++
lib/limits.in.h | 6 +++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 416a05dd1c..3df9fe9997 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-12-24 Bruno Haible <[email protected]>
+
+ limits-h: Support several gnulib-tool invocations better.
+ * lib/limits.in.h (_GL_ALREADY_INCLUDING_LIMITS_H): Rename to a macro
+ that depends on GUARD_PREFIX.
+
2024-12-23 Paul Eggert <[email protected]>
stdlib: fix MB_CUR_MAX on older Android
diff --git a/lib/limits.in.h b/lib/limits.in.h
index c65eb4c1cf..3347e369fb 100644
--- a/lib/limits.in.h
+++ b/lib/limits.in.h
@@ -20,7 +20,7 @@
#endif
@PRAGMA_COLUMNS@
-#if defined _GL_ALREADY_INCLUDING_LIMITS_H
+#if defined _@GUARD_PREFIX@_ALREADY_INCLUDING_LIMITS_H
/* Special invocation convention:
On Haiku/x86_64, we have a sequence of nested includes
<limits.h> -> <syslimits.h> -> <limits.h>.
@@ -34,12 +34,12 @@
#ifndef _@GUARD_PREFIX@_LIMITS_H
-# define _GL_ALREADY_INCLUDING_LIMITS_H
+# define _@GUARD_PREFIX@_ALREADY_INCLUDING_LIMITS_H
/* The include_next requires a split double-inclusion guard. */
# @INCLUDE_NEXT@ @NEXT_LIMITS_H@
-# undef _GL_ALREADY_INCLUDING_LIMITS_H
+# undef _@GUARD_PREFIX@_ALREADY_INCLUDING_LIMITS_H
#ifndef _@GUARD_PREFIX@_LIMITS_H
#define _@GUARD_PREFIX@_LIMITS_H
--
2.43.0
>From d41d22f63df00445dac1bcb17fb8005008cef5a4 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Tue, 24 Dec 2024 11:14:20 +0100
Subject: [PATCH 02/11] locale: Support several gnulib-tool invocations better.
* lib/locale.in.h (_GL_ALREADY_INCLUDING_LOCALE_H): Rename to a macro
that depends on GUARD_PREFIX.
(struct lconv): Avoid duplicate definition.
---
ChangeLog | 7 +++++++
lib/locale.in.h | 13 ++++++++-----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3df9fe9997..d7793aab69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-12-24 Bruno Haible <[email protected]>
+
+ locale: Support several gnulib-tool invocations better.
+ * lib/locale.in.h (_GL_ALREADY_INCLUDING_LOCALE_H): Rename to a macro
+ that depends on GUARD_PREFIX.
+ (struct lconv): Avoid duplicate definition.
+
2024-12-24 Bruno Haible <[email protected]>
limits-h: Support several gnulib-tool invocations better.
diff --git a/lib/locale.in.h b/lib/locale.in.h
index c3d34085de..5c45ef4507 100644
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -20,7 +20,7 @@
@PRAGMA_COLUMNS@
#if (defined _WIN32 && !defined __CYGWIN__ && defined __need_locale_t) \
- || defined _GL_ALREADY_INCLUDING_LOCALE_H
+ || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_LOCALE_H
/* Special invocation convention:
- Inside mingw header files,
@@ -34,12 +34,12 @@
#ifndef _@GUARD_PREFIX@_LOCALE_H
-#define _GL_ALREADY_INCLUDING_LOCALE_H
+#define _@GUARD_PREFIX@_ALREADY_INCLUDING_LOCALE_H
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
-#undef _GL_ALREADY_INCLUDING_LOCALE_H
+#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_LOCALE_H
#ifndef _@GUARD_PREFIX@_LOCALE_H
#define _@GUARD_PREFIX@_LOCALE_H
@@ -83,7 +83,8 @@
/* Bionic libc's 'struct lconv' is just a dummy. */
#if @REPLACE_STRUCT_LCONV@
-# define lconv rpl_lconv
+# if !defined GNULIB_defined_struct_lconv
+# define lconv rpl_lconv
struct lconv
{
/* All 'char *' are actually 'const char *'. */
@@ -160,6 +161,8 @@ struct lconv
number. */
char int_n_sep_by_space;
};
+# define GNULIB_defined_struct_lconv 1
+# endif
#endif
#if @GNULIB_LOCALECONV@
@@ -309,4 +312,4 @@ _GL_WARN_ON_USE (freelocale, "freelocale is not portable");
#endif /* _@GUARD_PREFIX@_LOCALE_H */
#endif /* _@GUARD_PREFIX@_LOCALE_H */
-#endif /* !(__need_locale_t || _GL_ALREADY_INCLUDING_LOCALE_H) */
+#endif /* !(__need_locale_t || _@GUARD_PREFIX@_ALREADY_INCLUDING_LOCALE_H) */
--
2.43.0
>From fe929b50226665aef7d05d6d8197b650dc8ed646 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Tue, 24 Dec 2024 11:15:25 +0100
Subject: [PATCH 03/11] malloc-h: Support several gnulib-tool invocations
better.
* lib/malloc.in.h (_GL_ALREADY_INCLUDING_MALLOC_H): Rename to a macro
that depends on GUARD_PREFIX.
---
ChangeLog | 6 ++++++
lib/malloc.in.h | 6 +++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d7793aab69..c87b7366e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-12-24 Bruno Haible <[email protected]>
+
+ malloc-h: Support several gnulib-tool invocations better.
+ * lib/malloc.in.h (_GL_ALREADY_INCLUDING_MALLOC_H): Rename to a macro
+ that depends on GUARD_PREFIX.
+
2024-12-24 Bruno Haible <[email protected]>
locale: Support several gnulib-tool invocations better.
diff --git a/lib/malloc.in.h b/lib/malloc.in.h
index a22a4a8a39..ed90ea36ad 100644
--- a/lib/malloc.in.h
+++ b/lib/malloc.in.h
@@ -19,7 +19,7 @@
#endif
@PRAGMA_COLUMNS@
-#if defined _GL_ALREADY_INCLUDING_MALLOC_H
+#if defined _@GUARD_PREFIX@_ALREADY_INCLUDING_MALLOC_H
/* Special invocation convention:
- On Android we have a sequence of nested includes
<malloc.h> -> <stdio.h> -> <sys/stat.h> -> <time.h> -> <sys/time.h> ->
@@ -34,14 +34,14 @@
#ifndef _@GUARD_PREFIX@_MALLOC_H
-#define _GL_ALREADY_INCLUDING_MALLOC_H
+#define _@GUARD_PREFIX@_ALREADY_INCLUDING_MALLOC_H
/* The include_next requires a split double-inclusion guard. */
#if @HAVE_MALLOC_H@
# @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MALLOC_H@
#endif
-#undef _GL_ALREADY_INCLUDING_MALLOC_H
+#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_MALLOC_H
#ifndef _@GUARD_PREFIX@_MALLOC_H
#define _@GUARD_PREFIX@_MALLOC_H
--
2.43.0
>From 64c2831dae3c1172ce417b25b425881fe72a880a Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Tue, 24 Dec 2024 11:16:25 +0100
Subject: [PATCH 04/11] pthread-h: Support several gnulib-tool invocations
better.
* lib/pthread.in.h (_GL_ALREADY_INCLUDING_PTHREAD_H): Rename to a macro
that depends on GUARD_PREFIX.
---
ChangeLog | 6 ++++++
lib/pthread.in.h | 6 +++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c87b7366e0..574a519bac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-12-24 Bruno Haible <[email protected]>
+
+ pthread-h: Support several gnulib-tool invocations better.
+ * lib/pthread.in.h (_GL_ALREADY_INCLUDING_PTHREAD_H): Rename to a macro
+ that depends on GUARD_PREFIX.
+
2024-12-24 Bruno Haible <[email protected]>
malloc-h: Support several gnulib-tool invocations better.
diff --git a/lib/pthread.in.h b/lib/pthread.in.h
index 80081da7a7..4a193ef908 100644
--- a/lib/pthread.in.h
+++ b/lib/pthread.in.h
@@ -22,7 +22,7 @@
#endif
@PRAGMA_COLUMNS@
-#if defined _GL_ALREADY_INCLUDING_PTHREAD_H
+#if defined _@GUARD_PREFIX@_ALREADY_INCLUDING_PTHREAD_H
/* Special invocation convention:
On Android, we have a sequence of nested includes
<pthread.h> -> <time.h> -> <sys/time.h> -> <sys/select.h> ->
@@ -39,12 +39,12 @@
#if @HAVE_PTHREAD_H@
-# define _GL_ALREADY_INCLUDING_PTHREAD_H
+# define _@GUARD_PREFIX@_ALREADY_INCLUDING_PTHREAD_H
/* The include_next requires a split double-inclusion guard. */
# @INCLUDE_NEXT@ @NEXT_PTHREAD_H@
-# undef _GL_ALREADY_INCLUDING_PTHREAD_H
+# undef _@GUARD_PREFIX@_ALREADY_INCLUDING_PTHREAD_H
#endif
--
2.43.0
>From 0985d0c8079a7fdb07e8e4dd9c5dfd24e4a9cfb6 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Tue, 24 Dec 2024 11:25:01 +0100
Subject: [PATCH 05/11] signal-h: Support several gnulib-tool invocations
better.
* lib/signal.in.h (_GL_ALREADY_INCLUDING_SIGNAL_H): Rename to a macro
that depends on GUARD_PREFIX.
---
ChangeLog | 6 ++++++
lib/signal.in.h | 6 +++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 574a519bac..4bc25a006f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-12-24 Bruno Haible <[email protected]>
+
+ signal-h: Support several gnulib-tool invocations better.
+ * lib/signal.in.h (_GL_ALREADY_INCLUDING_SIGNAL_H): Rename to a macro
+ that depends on GUARD_PREFIX.
+
2024-12-24 Bruno Haible <[email protected]>
pthread-h: Support several gnulib-tool invocations better.
diff --git a/lib/signal.in.h b/lib/signal.in.h
index 6239b90adf..18c88f0c1d 100644
--- a/lib/signal.in.h
+++ b/lib/signal.in.h
@@ -20,7 +20,7 @@
#endif
@PRAGMA_COLUMNS@
-#if defined __need_sig_atomic_t || defined __need_sigset_t || defined _GL_ALREADY_INCLUDING_SIGNAL_H || (defined _SIGNAL_H && !defined __SIZEOF_PTHREAD_MUTEX_T)
+#if defined __need_sig_atomic_t || defined __need_sigset_t || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_SIGNAL_H || (defined _SIGNAL_H && !defined __SIZEOF_PTHREAD_MUTEX_T)
/* Special invocation convention:
- Inside glibc header files.
- On glibc systems we have a sequence of nested includes
@@ -39,7 +39,7 @@
#ifndef _@GUARD_PREFIX@_SIGNAL_H
-#define _GL_ALREADY_INCLUDING_SIGNAL_H
+#define _@GUARD_PREFIX@_ALREADY_INCLUDING_SIGNAL_H
/* Define pid_t, uid_t.
Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.
@@ -50,7 +50,7 @@
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_SIGNAL_H@
-#undef _GL_ALREADY_INCLUDING_SIGNAL_H
+#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_SIGNAL_H
#ifndef _@GUARD_PREFIX@_SIGNAL_H
#define _@GUARD_PREFIX@_SIGNAL_H
--
2.43.0
>From 143d6b17fa01eba73bb253b839b38dd5e6a50606 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Tue, 24 Dec 2024 11:17:31 +0100
Subject: [PATCH 06/11] spawn: Support several gnulib-tool invocations better.
* lib/spawn.in.h (_GL_ALREADY_INCLUDING_SPAWN_H): Rename to a macro that
depends on GUARD_PREFIX.
---
ChangeLog | 6 ++++++
lib/spawn.in.h | 6 +++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4bc25a006f..ba83b79725 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-12-24 Bruno Haible <[email protected]>
+
+ spawn: Support several gnulib-tool invocations better.
+ * lib/spawn.in.h (_GL_ALREADY_INCLUDING_SPAWN_H): Rename to a macro that
+ depends on GUARD_PREFIX.
+
2024-12-24 Bruno Haible <[email protected]>
signal-h: Support several gnulib-tool invocations better.
diff --git a/lib/spawn.in.h b/lib/spawn.in.h
index 5f42407d87..7bf7af60d5 100644
--- a/lib/spawn.in.h
+++ b/lib/spawn.in.h
@@ -20,7 +20,7 @@
#endif
@PRAGMA_COLUMNS@
-#if defined _GL_ALREADY_INCLUDING_SPAWN_H
+#if defined _@GUARD_PREFIX@_ALREADY_INCLUDING_SPAWN_H
/* Special invocation convention:
On OS/2 kLIBC, <spawn.h> includes <signal.h>. Then <signal.h> ->
<pthread.h> -> <sched.h> -> <spawn.h> are included by GNULIB.
@@ -36,11 +36,11 @@
/* The include_next requires a split double-inclusion guard. */
#if @HAVE_SPAWN_H@
-# define _GL_ALREADY_INCLUDING_SPAWN_H
+# define _@GUARD_PREFIX@_ALREADY_INCLUDING_SPAWN_H
# @INCLUDE_NEXT@ @NEXT_SPAWN_H@
-# define _GL_ALREADY_INCLUDING_SPAWN_H
+# define _@GUARD_PREFIX@_ALREADY_INCLUDING_SPAWN_H
#endif
--
2.43.0
>From ff96fd7cf0afff896a5a123286df8bf4340b3fd3 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Tue, 24 Dec 2024 11:19:49 +0100
Subject: [PATCH 07/11] stdio: Support several gnulib-tool invocations better.
* lib/stdio.in.h: Test _GL_SKIP_GNULIB_STDIO_H.
(_GL_ALREADY_INCLUDING_STDIO_H): Rename to a macro that depends on
GUARD_PREFIX.
* lib/fopen.c: Set _GL_SKIP_GNULIB_STDIO_H instead of
_GL_ALREADY_INCLUDING_STDIO_H.
* lib/freopen.c: Likewise.
---
ChangeLog | 10 ++++++++++
lib/fopen.c | 4 ++--
lib/freopen.c | 4 ++--
lib/stdio.in.h | 6 +++---
4 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ba83b79725..62a1149468 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-12-24 Bruno Haible <[email protected]>
+
+ stdio: Support several gnulib-tool invocations better.
+ * lib/stdio.in.h: Test _GL_SKIP_GNULIB_STDIO_H.
+ (_GL_ALREADY_INCLUDING_STDIO_H): Rename to a macro that depends on
+ GUARD_PREFIX.
+ * lib/fopen.c: Set _GL_SKIP_GNULIB_STDIO_H instead of
+ _GL_ALREADY_INCLUDING_STDIO_H.
+ * lib/freopen.c: Likewise.
+
2024-12-24 Bruno Haible <[email protected]>
spawn: Support several gnulib-tool invocations better.
diff --git a/lib/fopen.c b/lib/fopen.c
index d3b57a987a..b9e6e37374 100644
--- a/lib/fopen.c
+++ b/lib/fopen.c
@@ -19,12 +19,12 @@
/* If the user's config.h happens to include <stdio.h>, let it include only
the system's <stdio.h> here, so that orig_fopen doesn't recurse to
rpl_fopen. */
-#define _GL_ALREADY_INCLUDING_STDIO_H
+#define _GL_SKIP_GNULIB_STDIO_H
#include <config.h>
/* Get the original definition of fopen. It might be defined as a macro. */
#include <stdio.h>
-#undef _GL_ALREADY_INCLUDING_STDIO_H
+#undef _GL_SKIP_GNULIB_STDIO_H
static FILE *
orig_fopen (const char *filename, const char *mode)
diff --git a/lib/freopen.c b/lib/freopen.c
index e003c0ba7f..ab4a40dfe0 100644
--- a/lib/freopen.c
+++ b/lib/freopen.c
@@ -19,12 +19,12 @@
/* If the user's config.h happens to include <stdio.h>, let it include only
the system's <stdio.h> here, so that orig_freopen doesn't recurse to
rpl_freopen. */
-#define _GL_ALREADY_INCLUDING_STDIO_H
+#define _GL_SKIP_GNULIB_STDIO_H
#include <config.h>
/* Get the original definition of freopen. It might be defined as a macro. */
#include <stdio.h>
-#undef _GL_ALREADY_INCLUDING_STDIO_H
+#undef _GL_SKIP_GNULIB_STDIO_H
#include <errno.h>
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index e77798d9b2..ed260d308b 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -20,7 +20,7 @@
#endif
@PRAGMA_COLUMNS@
-#if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H
+#if defined __need_FILE || defined __need___FILE || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H || defined _GL_SKIP_GNULIB_STDIO_H
/* Special invocation convention:
- Inside glibc header files.
- On OSF/1 5.1 we have a sequence of nested includes
@@ -48,12 +48,12 @@
# endif
#endif
-#define _GL_ALREADY_INCLUDING_STDIO_H
+#define _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_STDIO_H@
-#undef _GL_ALREADY_INCLUDING_STDIO_H
+#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H
#ifdef _GL_DEFINED__POSIX_C_SOURCE
# undef _GL_DEFINED__POSIX_C_SOURCE
--
2.43.0
>From 7e9b92b4fc06d24b8df992c3958b82db9d75d470 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Tue, 24 Dec 2024 11:20:52 +0100
Subject: [PATCH 08/11] string: Support several gnulib-tool invocations better.
* lib/string.in.h (_GL_ALREADY_INCLUDING_STRING_H): Rename to a macro
that depends on GUARD_PREFIX.
---
ChangeLog | 6 ++++++
lib/string.in.h | 6 +++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 62a1149468..5037f1bbc5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-12-24 Bruno Haible <[email protected]>
+
+ string: Support several gnulib-tool invocations better.
+ * lib/string.in.h (_GL_ALREADY_INCLUDING_STRING_H): Rename to a macro
+ that depends on GUARD_PREFIX.
+
2024-12-24 Bruno Haible <[email protected]>
stdio: Support several gnulib-tool invocations better.
diff --git a/lib/string.in.h b/lib/string.in.h
index f5a6d8b326..72cd7566e6 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -20,7 +20,7 @@
#endif
@PRAGMA_COLUMNS@
-#if defined _GL_ALREADY_INCLUDING_STRING_H
+#if defined _@GUARD_PREFIX@_ALREADY_INCLUDING_STRING_H
/* Special invocation convention:
- On OS X/NetBSD we have a sequence of nested includes
<string.h> -> <strings.h> -> "string.h"
@@ -34,12 +34,12 @@
#ifndef _@GUARD_PREFIX@_STRING_H
-#define _GL_ALREADY_INCLUDING_STRING_H
+#define _@GUARD_PREFIX@_ALREADY_INCLUDING_STRING_H
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_STRING_H@
-#undef _GL_ALREADY_INCLUDING_STRING_H
+#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_STRING_H
#ifndef _@GUARD_PREFIX@_STRING_H
#define _@GUARD_PREFIX@_STRING_H
--
2.43.0
>From e095b4f2f55b1311ce170de5e014ba24325f0a91 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Tue, 24 Dec 2024 11:21:51 +0100
Subject: [PATCH 09/11] sys_socket: Support several gnulib-tool invocations
better.
* lib/sys_socket.in.h (_GL_ALREADY_INCLUDING_SYS_SOCKET_H): Rename to a
macro that depends on GUARD_PREFIX.
(struct msghdr): Avoid duplicate definition.
---
ChangeLog | 7 +++++++
lib/sys_socket.in.h | 9 ++++++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5037f1bbc5..bec6cc301e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-12-24 Bruno Haible <[email protected]>
+
+ sys_socket: Support several gnulib-tool invocations better.
+ * lib/sys_socket.in.h (_GL_ALREADY_INCLUDING_SYS_SOCKET_H): Rename to a
+ macro that depends on GUARD_PREFIX.
+ (struct msghdr): Avoid duplicate definition.
+
2024-12-24 Bruno Haible <[email protected]>
string: Support several gnulib-tool invocations better.
diff --git a/lib/sys_socket.in.h b/lib/sys_socket.in.h
index 2be986659f..9610a52647 100644
--- a/lib/sys_socket.in.h
+++ b/lib/sys_socket.in.h
@@ -27,7 +27,7 @@
#endif
@PRAGMA_COLUMNS@
-#if defined _GL_ALREADY_INCLUDING_SYS_SOCKET_H
+#if defined _@GUARD_PREFIX@_ALREADY_INCLUDING_SYS_SOCKET_H
/* Special invocation convention:
- On Cygwin 1.5.x we have a sequence of nested includes
<sys/socket.h> -> <cygwin/socket.h> -> <asm/socket.h> -> <cygwin/if.h>,
@@ -43,7 +43,7 @@
#if @HAVE_SYS_SOCKET_H@
-# define _GL_ALREADY_INCLUDING_SYS_SOCKET_H
+# define _@GUARD_PREFIX@_ALREADY_INCLUDING_SYS_SOCKET_H
/* On many platforms, <sys/socket.h> assumes prior inclusion of
<sys/types.h>. */
@@ -56,7 +56,7 @@
/* The include_next requires a split double-inclusion guard. */
# @INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@
-# undef _GL_ALREADY_INCLUDING_SYS_SOCKET_H
+# undef _@GUARD_PREFIX@_ALREADY_INCLUDING_SYS_SOCKET_H
#endif
@@ -202,6 +202,7 @@ struct sockaddr_storage
/* Rudimentary 'struct msghdr'; this works as long as you don't try to
access msg_control or msg_controllen. */
+# if !defined GNULIB_defined_struct_msghdr
struct msghdr {
void *msg_name;
socklen_t msg_namelen;
@@ -209,6 +210,8 @@ struct msghdr {
int msg_iovlen;
int msg_flags;
};
+# define GNULIB_defined_struct_msghdr 1
+# endif
#endif
--
2.43.0
>From 399006d7f5d3937290bb3b8de9684ac30f5f0ec7 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Tue, 24 Dec 2024 11:22:40 +0100
Subject: [PATCH 10/11] threads-h: Support several gnulib-tool invocations
better.
* lib/threads.in.h (_GL_ALREADY_INCLUDING_THREADS_H): Rename to a macro
that depends on GUARD_PREFIX.
(struct thrd_with_exitcode): Avoid duplicate definition.
---
ChangeLog | 7 +++++++
lib/threads.in.h | 11 +++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bec6cc301e..b2175edb0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-12-24 Bruno Haible <[email protected]>
+
+ threads-h: Support several gnulib-tool invocations better.
+ * lib/threads.in.h (_GL_ALREADY_INCLUDING_THREADS_H): Rename to a macro
+ that depends on GUARD_PREFIX.
+ (struct thrd_with_exitcode): Avoid duplicate definition.
+
2024-12-24 Bruno Haible <[email protected]>
sys_socket: Support several gnulib-tool invocations better.
diff --git a/lib/threads.in.h b/lib/threads.in.h
index 91834d0788..fd4a5818ad 100644
--- a/lib/threads.in.h
+++ b/lib/threads.in.h
@@ -20,7 +20,7 @@
#endif
@PRAGMA_COLUMNS@
-#if defined _GL_ALREADY_INCLUDING_THREADS_H
+#if defined _@GUARD_PREFIX@_ALREADY_INCLUDING_THREADS_H
/* Special invocation convention:
- On Android we have a sequence of nested includes
<threads.h> -> <android/legacy_threads_inlines.h>
@@ -35,14 +35,14 @@
#ifndef _@GUARD_PREFIX@_THREADS_H
-#define _GL_ALREADY_INCLUDING_THREADS_H
+#define _@GUARD_PREFIX@_ALREADY_INCLUDING_THREADS_H
/* The include_next requires a split double-inclusion guard. */
#if @HAVE_THREADS_H@
# @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_THREADS_H@
#endif
-#undef _GL_ALREADY_INCLUDING_THREADS_H
+#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_THREADS_H
#ifndef _@GUARD_PREFIX@_THREADS_H
#define _@GUARD_PREFIX@_THREADS_H
@@ -144,6 +144,7 @@ typedef pthread_t thrd_t;
#endif
#if @BROKEN_THRD_START_T@ || @BROKEN_THRD_JOIN@
/* Need to override thrd_t, to make thrd_join work. */
+# if !defined GNULIB_defined_struct_thrd_with_exitcode
struct thrd_with_exitcode
{
thrd_t volatile tid;
@@ -151,7 +152,9 @@ struct thrd_with_exitcode
int volatile exitcode;
};
typedef struct thrd_with_exitcode *rpl_thrd_t;
-# define thrd_t rpl_thrd_t
+# define thrd_t rpl_thrd_t
+# define GNULIB_defined_struct_thrd_with_exitcode 1
+# endif
#endif
/* Type of the main function of a thread. */
#if !@HAVE_THREADS_H@ || @BROKEN_THRD_START_T@
--
2.43.0
>From 2dd90a9b5fb9851d3a764129ace6a744c8562c1a Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Tue, 24 Dec 2024 11:23:45 +0100
Subject: [PATCH 11/11] wchar: Support several gnulib-tool invocations better.
* lib/wchar.in.h (_GL_ALREADY_INCLUDING_WCHAR_H): Rename to a macro that
depends on GUARD_PREFIX.
(mbszero): Avoid duplicate definition.
---
ChangeLog | 7 +++++++
lib/wchar.in.h | 15 +++++++++------
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b2175edb0b..20c4ab35c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-12-24 Bruno Haible <[email protected]>
+
+ wchar: Support several gnulib-tool invocations better.
+ * lib/wchar.in.h (_GL_ALREADY_INCLUDING_WCHAR_H): Rename to a macro that
+ depends on GUARD_PREFIX.
+ (mbszero): Avoid duplicate definition.
+
2024-12-24 Bruno Haible <[email protected]>
threads-h: Support several gnulib-tool invocations better.
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index 3c6beb0712..1eaaf363f4 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -37,7 +37,7 @@
&& !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \
|| defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
|| (defined __MINGW32__ && defined __STRING_H_SOURCED__) \
- || defined _GL_ALREADY_INCLUDING_WCHAR_H)
+ || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_WCHAR_H)
/* Special invocation convention:
- Inside glibc and uClibc header files, but not MinGW.
- On HP-UX 11.00 we have a sequence of nested includes
@@ -59,7 +59,7 @@
#ifndef _@GUARD_PREFIX@_WCHAR_H
-#define _GL_ALREADY_INCLUDING_WCHAR_H
+#define _@GUARD_PREFIX@_ALREADY_INCLUDING_WCHAR_H
#if @HAVE_FEATURES_H@
# include <features.h> /* for __GLIBC__ */
@@ -79,7 +79,7 @@
# @INCLUDE_NEXT@ @NEXT_WCHAR_H@
#endif
-#undef _GL_ALREADY_INCLUDING_WCHAR_H
+#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_WCHAR_H
#ifndef _@GUARD_PREFIX@_WCHAR_H
#define _@GUARD_PREFIX@_WCHAR_H
@@ -531,16 +531,19 @@ _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
# define _GL_MBSTATE_ZERO_SIZE sizeof (mbstate_t)
# endif
_GL_BEGIN_C_LINKAGE
-# if defined IN_MBSZERO
+# if !GNULIB_defined_mbszero
+# if defined IN_MBSZERO
_GL_EXTERN_INLINE
-# else
+# else
_GL_INLINE
-# endif
+# endif
_GL_ARG_NONNULL ((1)) void
mbszero (mbstate_t *ps)
{
memset (ps, 0, _GL_MBSTATE_ZERO_SIZE);
}
+# define GNULIB_defined_mbszero 1
+# endif
_GL_END_C_LINKAGE
_GL_CXXALIAS_SYS (mbszero, void, (mbstate_t *ps));
_GL_CXXALIASWARN (mbszero);
--
2.43.0