* lib/obstack.in.h (PTR_INT_TYPE): Define, for compatibility with glibc even though we don’t need the type for anything other than compatibility. Include stddef.h only if needed, like glibc obstack.h does. --- ChangeLog | 6 ++++++ lib/obstack.in.h | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog index 5c78f4dac4..7448c09ebc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2025-05-05 Paul Eggert <egg...@cs.ucla.edu> + obstack: define PTR_INT_TYPE + * lib/obstack.in.h (PTR_INT_TYPE): Define, for compatibility + with glibc even though we don’t need the type for anything + other than compatibility. Include stddef.h only if needed, + like glibc obstack.h does. + obstack: merge better with glibc When compiled for glibc, keep the fake array content size at 4, for API compatibility with older glibc. diff --git a/lib/obstack.in.h b/lib/obstack.in.h index c82f6d4a6c..6b51ebde5d 100644 --- a/lib/obstack.in.h +++ b/lib/obstack.in.h @@ -113,9 +113,20 @@ # endif #endif -#include <stddef.h> /* For size_t and ptrdiff_t. */ +/* For backward compatibility with older glibc, + define the otherwise-unused macro PTR_INT_TYPE. If __PTRDIFF_TYPE__ is + defined, as with GNU C, use that; that way we don't pollute the + namespace with <stddef.h>'s symbols. Otherwise, include <stddef.h> + and use ptrdiff_t. */ +#ifdef __PTRDIFF_TYPE__ +# define PTR_INT_TYPE __PTRDIFF_TYPE__ +#else +# include <stddef.h> +# define PTR_INT_TYPE ptrdiff_t +#endif + #include <stdint.h> /* For uintptr_t. */ -#include <string.h> /* For memcpy. */ +#include <string.h> /* For memcpy, size_t. */ /* These macros highlight the places where this implementation is different from the one in GNU libc. */ -- 2.49.0