From: Bruno Haible Date: Mon, 11 Nov 2024 08:02:23 +0000 (+0100) Subject: realloc-posix: Fix link error (regression 2024-11-04). X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=7368d3b7ed5a1c8446035230b747756c876a27c8;p=gnulib.git realloc-posix: Fix link error (regression 2024-11-04). * doc/extern-inline.texi (extern inline): Mention that one needs a *_INLINE macro per compilation unit. * lib/stdlib.in.h (_GL_REALLOC_INLINE): New macro. (rpl_realloc): Use it. Don't test IN_GNULIB_TESTS. * lib/realloc.c (_GL_REALLOC_INLINE): Define. --- diff --git a/ChangeLog b/ChangeLog index c3e7a2ab0e..4ba563545f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-11-11 Bruno Haible + + realloc-posix: Fix link error (regression 2024-11-04). + * doc/extern-inline.texi (extern inline): Mention that one needs a + *_INLINE macro per compilation unit. + * lib/stdlib.in.h (_GL_REALLOC_INLINE): New macro. + (rpl_realloc): Use it. Don't test IN_GNULIB_TESTS. + * lib/realloc.c (_GL_REALLOC_INLINE): Define. + 2024-11-11 Bruno Haible file-has-acl: Fix compilation errors on macOS et al. (regr. 2024-11-09). diff --git a/doc/extern-inline.texi b/doc/extern-inline.texi index 8d88d33e0d..3ebc39cdac 100644 --- a/doc/extern-inline.texi +++ b/doc/extern-inline.texi @@ -82,6 +82,15 @@ to accomplish the same ends. Other non-C99 compilers use @code{static inline} so they suffer from code bloat, but they are not mainline platforms and will die out eventually. +In this coding idiom, +you need one @code{AAA_INLINE}-like macro per compilation unit, +not one per header file. +In other words, if the header file @file{aaa.h} defines functions +defined in @file{aaa-foo.c} and @file{aaa-bar.c}, +you need different macros @code{AAA_FOO_INLINE} and @code{AAA_BAR_INLINE}. +Use @code{AAA_FOO_INLINE} for the functions defined in @file{aaa-foo.c}, +and use @code{AAA_BAR_INLINE} for the functions defined in @file{aaa-bar.c}. + @findex _GL_INLINE @code{_GL_INLINE} is a portable alternative to C99 plain @code{inline}. diff --git a/lib/realloc.c b/lib/realloc.c index e1198cf633..31487b5e18 100644 --- a/lib/realloc.c +++ b/lib/realloc.c @@ -21,6 +21,7 @@ #define _GL_USE_STDLIB_ALLOC 1 #include +#define _GL_REALLOC_INLINE _GL_EXTERN_INLINE #include #include diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 0d3e2cbf94..b4e2e723fc 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -134,6 +134,9 @@ _GL_INLINE_HEADER_BEGIN #ifndef _GL_STDLIB_INLINE # define _GL_STDLIB_INLINE _GL_INLINE #endif +#ifndef _GL_REALLOC_INLINE +# define _GL_REALLOC_INLINE _GL_INLINE +#endif /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers that can be freed by passing them as the Ith argument to the @@ -1461,9 +1464,9 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " #if @GNULIB_REALLOC_POSIX@ # if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ -# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ == 2 && !IN_GNULIB_TESTS +# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ == 2 # define _GL_INLINE_RPL_REALLOC 1 -_GL_STDLIB_INLINE void * +_GL_REALLOC_INLINE void * rpl_realloc (void *ptr, size_t size) { return realloc (ptr, size ? size : 1);