]> Savannah Git Hosting - gnulib.git/commitdiff
realloc-posix: Fix link error (regression 2024-11-04).
authorBruno Haible <bruno@clisp.org>
Mon, 11 Nov 2024 08:02:23 +0000 (09:02 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 11 Nov 2024 08:05:54 +0000 (09:05 +0100)
* 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.

ChangeLog
doc/extern-inline.texi
lib/realloc.c
lib/stdlib.in.h

index c3e7a2ab0e60804e33f5280759d2c9cbb6749a7d..4ba563545fc576171e3e01a5fb321ba1e70af990 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-11-11  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        file-has-acl: Fix compilation errors on macOS et al. (regr. 2024-11-09).
index 8d88d33e0d1873382d5c78ff79e034739a302585..3ebc39cdac67e97894e1bfce32a19c279bd6ebee 100644 (file)
@@ -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}.
 
index e1198cf633114447461934310a4634443cd1126d..31487b5e181a3a35be1a8813a9d4c1b887ce5456 100644 (file)
@@ -21,6 +21,7 @@
 #define _GL_USE_STDLIB_ALLOC 1
 #include <config.h>
 
+#define _GL_REALLOC_INLINE _GL_EXTERN_INLINE
 #include <stdlib.h>
 
 #include <errno.h>
index 0d3e2cbf94fd71481873e3ced000c434200ffa2a..b4e2e723fcb4c0252de529d72e2b27e87e4e4324 100644 (file)
@@ -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);