There's no macro to check for musl, so check host_os like for malloc. The same could be done for OpenBSD and Solaris to save a compilation. --- m4/free.m4 | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/m4/free.m4 b/m4/free.m4 index c7a134bab8..81a8ccd9b9 100644 --- a/m4/free.m4 +++ b/m4/free.m4 @@ -20,25 +20,31 @@ AC_DEFUN([gl_FUNC_FREE], dnl <https://sourceware.org/PR17924> dnl * OpenBSD >= 4.5, thanks to this commit: dnl <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdlib/malloc.c.diff?r1=1.100&r2=1.101&f=h> + dnl * musl >= 1.2.3, thanks to these commits: + dnl <https://git.musl-libc.org/cgit/musl/commit/?id=9b77aaca86b53c367f23505c24dd3c02e240efad> + dnl <https://git.musl-libc.org/cgit/musl/commit/?id=2010df0d64570db4ce29cc7df0e31f81aa26ae4a> dnl * Solaris, because its malloc() implementation is based on brk(), dnl not mmap(); hence its free() implementation makes no system calls. dnl For other platforms, you can only be sure if they state it in their dnl documentation, or by code inspection of the free() implementation in libc. AC_CACHE_CHECK([whether free is known to preserve errno], [gl_cv_func_free_preserves_errno], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include <stdlib.h> - ]], - [[#if 2 < __GLIBC__ + (33 <= __GLIBC_MINOR__) - #elif defined __OpenBSD__ - #elif defined __sun - #else - #error "'free' is not known to preserve errno" - #endif - ]])], - [gl_cv_func_free_preserves_errno=yes], - [gl_cv_func_free_preserves_errno=no]) + [AS_CASE([$host_os], + [*-musl*], [gl_cv_func_free_preserves_errno=yes], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <stdlib.h> + ]], + [[#if 2 < __GLIBC__ + (33 <= __GLIBC_MINOR__) + #elif defined __OpenBSD__ + #elif defined __sun + #else + #error "'free' is not known to preserve errno" + #endif + ]])], + [gl_cv_func_free_preserves_errno=yes], + [gl_cv_func_free_preserves_errno=no]) + ]) ]) case $gl_cv_func_free_preserves_errno in base-commit: 4a127339b2446c4b0cec5b67cf29938a74c0acc8 -- 2.53.0
