+2021-06-06 Bruno Haible <bruno@clisp.org>
+
+ dynarray: Avoid conflict with preprocessor macros owned by the system.
+ * lib/dynarray.h: Don't include <libc-config.h>. Define _GL_LIKELY,
+ _GL_UNLIKELY. Include malloc/dynarray.gl.h instead of malloc/dynarray.h.
+ Include malloc/dynarray-skeleton.gl.h instead of
+ malloc/dynarray-skeleton.c.
+ * modules/dynarray (Depends-on): Add builtin-expect.
+ (Makefile.am): Arrange to create malloc/dynarray.gl.h from
+ malloc/dynarray.h and malloc/dynarray-skeleton.gl.h from
+ malloc/dynarray-skeleton.c.
+
2021-06-06 Bruno Haible <bruno@clisp.org>
glob-h: Avoid conflict with preprocessor macros owned by the system.
#if defined DYNARRAY_STRUCT || defined DYNARRAY_ELEMENT || defined DYNARRAY_PREFIX
-# include <libc-config.h>
+# ifndef _GL_LIKELY
+/* Rely on __builtin_expect, as provided by the module 'builtin-expect'. */
+# define _GL_LIKELY(cond) __builtin_expect ((cond), 1)
+# define _GL_UNLIKELY(cond) __builtin_expect ((cond), 0)
+# endif
/* Define auxiliary structs and declare auxiliary functions, common to all
instantiations of dynarray. */
-# include <malloc/dynarray.h>
+# include <malloc/dynarray.gl.h>
/* Define the instantiation, specified through
DYNARRAY_STRUCT
DYNARRAY_ELEMENT
DYNARRAY_PREFIX
etc. */
-# include <malloc/dynarray-skeleton.c>
+# include <malloc/dynarray-skeleton.gl.h>
#else
Depends-on:
c99
+builtin-expect
libc-config
stdbool
stddef
configure.ac:
Makefile.am:
+BUILT_SOURCES += malloc/dynarray.gl.h malloc/dynarray-skeleton.gl.h
+
+malloc/dynarray.gl.h: malloc/dynarray.h
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e '/libc_hidden_proto/d' < $(srcdir)/malloc/dynarray.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += malloc/dynarray.gl.h malloc/dynarray.gl.h-t
+
+malloc/dynarray-skeleton.gl.h: malloc/dynarray-skeleton.c
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|<malloc/dynarray\.h>|<malloc/dynarray.gl.h>|g' \
+ -e 's|__attribute_maybe_unused__|_GL_ATTRIBUTE_MAYBE_UNUSED|g' \
+ -e 's|__attribute_nonnull__|_GL_ATTRIBUTE_NONNULL|g' \
+ -e 's|__attribute_warn_unused_result__|_GL_ATTRIBUTE_NODISCARD|g' \
+ -e 's|__glibc_likely|_GL_LIKELY|g' \
+ -e 's|__glibc_unlikely|_GL_UNLIKELY|g' \
+ < $(srcdir)/malloc/dynarray-skeleton.c; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += malloc/dynarray-skeleton.gl.h malloc/dynarray-skeleton.gl.h-t
+
lib_SOURCES += malloc/dynarray_at_failure.c \
malloc/dynarray_emplace_enlarge.c \
malloc/dynarray_finalize.c \