]> Savannah Git Hosting - gnulib.git/commitdiff
obstack: Make it easier to sync back with glibc.
authorBruno Haible <bruno@clisp.org>
Wed, 30 Apr 2025 09:57:34 +0000 (11:57 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 30 Apr 2025 09:57:34 +0000 (11:57 +0200)
* 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@.

ChangeLog
lib/obstack.in.h
modules/obstack

index 2d0f93e33d2d60399f92b62b9bea7ea37d2f0485..fc772d1f95e204d82c2c62442012ca5a1b852f57 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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.
index b5791ee294000e037dac88c01e7fac1d202b3eb3..39eb3a030f35b363888291ea854dfad9a14acd9e 100644 (file)
 #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
@@ -210,7 +214,7 @@ struct obstack          /* control current object in current chunk */
 
 /* 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
index 77b81f9e442dfaf517ee3af97a81cf5a37673600..5065a693cc2ab395af2f6231888879f7631327c4 100644 (file)
@@ -31,8 +31,9 @@ if GL_GENERATE_OBSTACK_H
 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