summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2021-06-07 00:34:54 +0200
committerBruno Haible <bruno@clisp.org>2021-06-07 00:50:36 +0200
commita5b7194c670089046d9f22c220fea2afc3985c2a (patch)
tree7498d456ee36173cd6bea2b1ed20f7d6859b023b
parentfed6ffdbb62eb2cb1a742d22cc3233fa12d2ba58 (diff)
downloadgnulib-a5b7194c670089046d9f22c220fea2afc3985c2a.tar.gz
glob-h: Avoid conflict with preprocessor macros owned by the system.
This fixes a compilation error on DragonFly BSD 6.0. * lib/glob.in.h: Don't include <libc-config.h>. Don't define __USE_GNU. Include glob-libc.gl.h instead of glob-libc.h. * modules/glob-h (Makefile.am): Arrange to create glob-libc.gl.h from glob-libc.h. * lib/libc-config.h: Add comment.
-rw-r--r--ChangeLog10
-rw-r--r--lib/glob.in.h10
-rw-r--r--lib/libc-config.h5
-rw-r--r--modules/glob-h17
4 files changed, 32 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index a940c622d3..79fc6ff0dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2021-06-06 Bruno Haible <bruno@clisp.org>
+
+ glob-h: Avoid conflict with preprocessor macros owned by the system.
+ This fixes a compilation error on DragonFly BSD 6.0.
+ * lib/glob.in.h: Don't include <libc-config.h>. Don't define __USE_GNU.
+ Include glob-libc.gl.h instead of glob-libc.h.
+ * modules/glob-h (Makefile.am): Arrange to create glob-libc.gl.h from
+ glob-libc.h.
+ * lib/libc-config.h: Add comment.
+
2021-06-06 Dmitry V. Levin <ldv@altlinux.org>
* tests/test-regex.c (tests): Add test cases for *+ and ** regressions
diff --git a/lib/glob.in.h b/lib/glob.in.h
index 4952666407..dbc5b63ac0 100644
--- a/lib/glob.in.h
+++ b/lib/glob.in.h
@@ -70,10 +70,6 @@ typedef int (*_gl_glob_errfunc_fn) (const char *, int);
/* Preparations for including the standard GNU C Library header. */
-# ifndef __attribute_maybe_unused__
-# include <libc-config.h>
-# endif
-
# include <stddef.h>
/* On some systems, such as AIX 5.1, <sys/stat.h> does a "#define stat stat64".
@@ -81,10 +77,6 @@ typedef int (*_gl_glob_errfunc_fn) (const char *, int);
rely on 'struct stat'. */
# include <sys/stat.h>
-# ifndef __USE_GNU
-# define __USE_GNU 1
-# endif
-
# if @REPLACE_GLOB@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define glob rpl_glob
@@ -102,7 +94,7 @@ typedef int (*_gl_glob_errfunc_fn) (const char *, int);
/* Now the standard GNU C Library header should work. */
-# include "glob-libc.h"
+# include "glob-libc.gl.h"
#endif
diff --git a/lib/libc-config.h b/lib/libc-config.h
index fabca2fa3e..f68749fc74 100644
--- a/lib/libc-config.h
+++ b/lib/libc-config.h
@@ -28,7 +28,10 @@
When compiled as part of glibc this is a no-op; when compiled as
part of Gnulib this includes Gnulib's <config.h> and defines macros
- that glibc library code would normally assume. */
+ that glibc library code would normally assume.
+
+ Note: This header file MUST NOT be included by public header files
+ of Gnulib. */
#include <config.h>
diff --git a/modules/glob-h b/modules/glob-h
index 40df48f130..0b71fd2239 100644
--- a/modules/glob-h
+++ b/modules/glob-h
@@ -51,6 +51,23 @@ glob.h: $(top_builddir)/config.status
endif
MOSTLYCLEANFILES += glob.h glob.h-t
+BUILT_SOURCES += glob-libc.gl.h
+
+glob-libc.gl.h: glob-libc.h
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e '/__BEGIN_DECLS/{ s/__BEGIN_DECLS/#ifdef __cplusplus%extern "C" {%#endif/; y/%/\n/; }' \
+ -e '/__END_DECLS/{ s/__END_DECLS/#ifdef __cplusplus%}%#endif/; y/%/\n/; }' \
+ -e 's|__THROW||g' \
+ -e 's|defined __USE_MISC|1|' \
+ -e 's|ifdef __USE_GNU|if 1|' \
+ -e 's|ifdef __USE_LARGEFILE64|if 0|' \
+ < $(srcdir)/glob-libc.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += glob-libc.gl.h glob-libc.gl.h-t
+
+
Include:
<glob.h>