Hi Paul, > > The patch above has the effect that libunistring.so will now export > > 'realloc'. Which is not right. > > OK, but why doesn't a similar problem happen with malloc and calloc? > lib/malloc.c has "#undef malloc", and similarly for lib/calloc.c.
It surely happens for 'malloc' and 'calloc' as well. Probably no one noticed because the non-GNU-like malloc exists only on AIX, and I'm not trying to build shared libraries on AIX very frequently. > > I doubt there are many packages that still use AC_FUNC_REALLOC the > > "old" way, without gnulib. (Maybe gawk still does?) > > No, Gawk doesn't use AC_FUNC_REALLOC or Gnulib lib/realloc.c. Similarly > for calloc and malloc. Good to hear that. > Perhaps we should simply remove the "#ifdef malloc" section from > lib/malloc.c, and similar for calloc and realloc. Yes, this is possible, since the Autoconf 2.71 documentation is clear that combining AC_FUNC_MALLOC with gnulib's lib/malloc.c is not the way to go. It says: If you don’t want to maintain a ‘malloc.c’ file in your package manually, you can instead use the Gnulib module ‘malloc-gnu’. and likewise for AC_FUNC_REALLOC. Done: 2021-04-11 Bruno Haible <br...@clisp.org> malloc, realloc, calloc: Support restricted library symbols on AIX. Suggested by Paul Eggert in <https://lists.gnu.org/archive/html/bug-gnulib/2021-04/msg00119.html>. * lib/malloc.c: Drop the code that intends to collaborate with AC_FUNC_MALLOC. * lib/realloc.c: Drop the code that intends to collaborate with AC_FUNC_REALLOC. * lib/calloc.c: Drop the code that intends to collaborate with the nonexistent macro AC_FUNC_CALLOC. diff --git a/lib/malloc.c b/lib/malloc.c index 887cdde..7b5ae95 100644 --- a/lib/malloc.c +++ b/lib/malloc.c @@ -19,12 +19,9 @@ #define _GL_USE_STDLIB_ALLOC 1 #include <config.h> -/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */ -#ifdef malloc -# define NEED_MALLOC_GNU 1 -# undef malloc -/* Whereas the gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */ -#elif GNULIB_MALLOC_GNU && !HAVE_MALLOC_GNU + +/* The gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */ +#if GNULIB_MALLOC_GNU && !HAVE_MALLOC_GNU # define NEED_MALLOC_GNU 1 #endif diff --git a/lib/realloc.c b/lib/realloc.c index ab027d7..3bf1bea 100644 --- a/lib/realloc.c +++ b/lib/realloc.c @@ -21,12 +21,8 @@ #define _GL_USE_STDLIB_ALLOC 1 #include <config.h> -/* Only the AC_FUNC_REALLOC macro defines 'realloc' already in config.h. */ -#ifdef realloc -# define NEED_REALLOC_GNU 1 -# undef realloc -/* Whereas the gnulib module 'realloc-gnu' defines HAVE_REALLOC_GNU. */ -#elif GNULIB_REALLOC_GNU && !HAVE_REALLOC_GNU +/* The gnulib module 'realloc-gnu' defines HAVE_REALLOC_GNU. */ +#if GNULIB_REALLOC_GNU && !HAVE_REALLOC_GNU # define NEED_REALLOC_GNU 1 #endif diff --git a/lib/calloc.c b/lib/calloc.c index 167fdd4..5ab1975 100644 --- a/lib/calloc.c +++ b/lib/calloc.c @@ -18,12 +18,9 @@ /* written by Jim Meyering and Bruno Haible */ #include <config.h> -/* Only the AC_FUNC_CALLOC macro defines 'calloc' already in config.h. */ -#ifdef calloc -# define NEED_CALLOC_GNU 1 -# undef calloc -/* Whereas the gnulib module 'calloc-gnu' defines HAVE_CALLOC_GNU. */ -#elif GNULIB_CALLOC_GNU && !HAVE_CALLOC_GNU + +/* The gnulib module 'calloc-gnu' defines HAVE_CALLOC_GNU. */ +#if GNULIB_CALLOC_GNU && !HAVE_CALLOC_GNU # define NEED_CALLOC_GNU 1 #endif