]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
obstack: define PTR_INT_TYPE
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 5 May 2025 21:02:13 +0000 (14:02 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 5 May 2025 21:16:19 +0000 (14:16 -0700)
* 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
lib/obstack.in.h

index 5c78f4dac4b854f1f2a22db158a5758b9754377b..7448c09ebca51353e6140f0e34a8b41730c4954f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2025-05-05  Paul Eggert  <eggert@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.
index c82f6d4a6c25218669422c824c97b48f702f9811..6b51ebde5d8126047c141a6b6ebe1a74813725e6 100644 (file)
 # 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.  */