+2021-06-06 Bruno Haible <bruno@clisp.org>
+
+ scratch_buffer: Avoid conflict with prepr. macros owned by the system.
+ * lib/scratch_buffer.h: Don't include <libc-config.h>. Define
+ _GL_LIKELY, _GL_UNLIKELY. Include malloc/scratch_buffer.gl.h instead of
+ malloc/scratch_buffer.h.
+ * modules/scratch_buffer (Depends-on): Add builtin-expect.
+ (Makefile.am): Arrange to create malloc/scratch_buffer.gl.h from
+ malloc/scratch_buffer.h.
+
2021-06-06 Bruno Haible <bruno@clisp.org>
dynarray: Avoid conflict with preprocessor macros owned by the system.
/* The implementation is imported from glibc. */
-#include <libc-config.h>
-
/* Avoid possible conflicts with symbols exported by the GNU libc. */
#define __libc_scratch_buffer_dupfree gl_scratch_buffer_dupfree
#define __libc_scratch_buffer_grow gl_scratch_buffer_grow
#define __libc_scratch_buffer_grow_preserve gl_scratch_buffer_grow_preserve
#define __libc_scratch_buffer_set_array_size gl_scratch_buffer_set_array_size
-#include <malloc/scratch_buffer.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
+
+#include <malloc/scratch_buffer.gl.h>
#endif /* _GL_SCRATCH_BUFFER_H */
Depends-on:
c99
+builtin-expect
libc-config
stdbool
stddef
configure.ac:
Makefile.am:
+BUILT_SOURCES += malloc/scratch_buffer.gl.h
+
+malloc/scratch_buffer.gl.h: malloc/scratch_buffer.h
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|__always_inline|inline _GL_ATTRIBUTE_ALWAYS_INLINE|g' \
+ -e 's|__glibc_likely|_GL_LIKELY|g' \
+ -e 's|__glibc_unlikely|_GL_UNLIKELY|g' \
+ -e '/libc_hidden_proto/d' \
+ < $(srcdir)/malloc/scratch_buffer.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += malloc/scratch_buffer.gl.h malloc/scratch_buffer.gl.h-t
+
lib_SOURCES += malloc/scratch_buffer_dupfree.c \
malloc/scratch_buffer_grow.c \
malloc/scratch_buffer_grow_preserve.c \