+2025-04-30 Bruno Haible <bruno@clisp.org>
+
+ obstack: Make it easier to sync back with glibc.
+ * lib/obstack.in.h: Use __GL_GNULIB_HEADER to delimit sections that are
+ for Gnulib usage.
+ Test __GL_SMALL_PTRDIFF_T__ instead of @SMALL_PTRDIFF_T@.
+ Test __GL_REPLACE_OBSTACK__ instead of @REPLACE_OBSTACK@.
+ * modules/obstack (Makefile.am): Substitute __GL_GNULIB_HEADER.
+ Substitute __GL_SMALL_PTRDIFF_T__ instead of @SMALL_PTRDIFF_T@.
+ Substitute __GL_REPLACE_OBSTACK__ instead of @REPLACE_OBSTACK@.
+
2025-04-29 Bruno Haible <bruno@clisp.org>
hash: Rename an internal function.
#ifndef _OBSTACK_H
#define _OBSTACK_H 1
-/* This file uses _Noreturn, _GL_ATTRIBUTE_PURE. */
-#if !_GL_CONFIG_H_INCLUDED
- #error "Please include config.h first."
+#if defined __GL_GNULIB_HEADER
+/* Gnulib usage. */
+/* This file uses _GL_ATTRIBUTE_PURE. */
+# if !_GL_CONFIG_H_INCLUDED
+ #error "Please include config.h first."
+# endif
#endif
#include <stddef.h> /* For size_t and ptrdiff_t. */
/* These macros highlight the places where this implementation
is different from the one in GNU libc. */
-#ifdef _LIBC
-# define _OBSTACK_SIZE_T unsigned int
-# define _CHUNK_SIZE_T unsigned long
-# define _OBSTACK_CAST(type, expr) ((type) (expr))
-#else
+#if defined __GL_GNULIB_HEADER
/* In Gnulib, we use sane types, especially for 64-bit hosts. */
# define _OBSTACK_SIZE_T size_t
# define _CHUNK_SIZE_T size_t
# define _OBSTACK_CAST(type, expr) (expr)
+#else
+/* glibc usage. */
+# define _OBSTACK_SIZE_T unsigned int
+# define _CHUNK_SIZE_T unsigned long
+# define _OBSTACK_CAST(type, expr) ((type) (expr))
#endif
/* __PTR_ALIGN(B, P, A) returns the result of aligning P to the next multiple
If ptrdiff_t is narrower than a pointer (e.g., the AS/400), play it
safe and compute the alignment relative to B. Otherwise, use the
faster strategy of computing the alignment through uintptr_t. */
-#if @SMALL_PTRDIFF_T@
+#if defined __GL_SMALL_PTRDIFF_T__
# define __PTR_ALIGN(B, P, A) \
((B) + (((P) - (B) + (A)) & ~(A)))
#else
/* Declare the external functions we use; they are in obstack.c. */
-#if @REPLACE_OBSTACK@
+#if defined __GL_REPLACE_OBSTACK__
# define _obstack_newchunk rpl_obstack_newchunk
# define _obstack_free rpl_obstack_free
# define _obstack_begin rpl_obstack_begin
obstack.h: obstack.in.h $(top_builddir)/config.status
@NMD@ $(AM_V_GEN)$(MKDIR_P) '%reldir%'
$(gl_V_at)$(SED_HEADER_STDOUT) \
- -e 's|@''REPLACE_OBSTACK''@|$(REPLACE_OBSTACK)|g' \
- -e 's|@''SMALL_PTRDIFF_T''@|$(SMALL_PTRDIFF_T)|g' \
+ -e 's/defined __GL_GNULIB_HEADER/1/g' \
+ -e 's|defined __GL_REPLACE_OBSTACK__|$(REPLACE_OBSTACK)|g' \
+ -e 's|defined __GL_SMALL_PTRDIFF_T__|$(SMALL_PTRDIFF_T)|g' \
$(srcdir)/obstack.in.h > $@-t
$(AM_V_at)mv $@-t $@
else