On 2025-06-17 07:51, Rich Felker wrote:

I'm not sure what you mean by "not having heard anyone but you bring
this up in the last 15 years". This has been a recurring issue

+1.


One thing I kinda would like to think about is if there's a way we can
signal at compile-time (without run tests that don't work for cross
compiling) that realloc is non-broken and doesn't need gnulib-style
wrapping/replacement.

That would help. Gnulib's gl_FUNC_REALLOC_0_NONNULL currently has some painful hacks (see below) that we hope work even for cross-compiling, for most platforms. But not everyone can or does use Gnulib, and it would be nice if glibc and other platforms would tell us their behavior in a standard way, to lessen our dependence on chewing gum and hope.

Even better, I'd like a simple way to tell glibc and bionic "Make realloc (p, 0) return nonnull on success" and have it just work, without all this rickety fooraw.

Here are some of the hacks Gnulib now uses for cross-compiles.

# Modules that use this macro directly or indirectly should depend # on extensions-aix, so that _LINUX_SOURCE_COMPAT gets defined # before this macro gets invoked. This helps if !(__VEC__ || __AIXVEC), # and doesn't hurt otherwise. ...> [AS_CASE([$host_os], [# Guess yes on platforms where we know the result. freebsd* | netbsd* | openbsd* | darwin* | bitrig* \
           | *-musl* | midipix* | midnightbsd* \
           | hpux* | solaris* | cygwin*],
            [gl_cv_func_realloc_0_nonnull="guessing yes"],
[# Guess as follows if we don't know. gl_cv_func_realloc_0_nonnull=$gl_cross_guess_normal])])])


Reply via email to