From: Bruno Haible Date: Fri, 18 Dec 2020 22:58:37 +0000 (+0100) Subject: free: Remove support for obsolete platforms. X-Git-Tag: v1.0~3352 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=e7d4443c5bb365ed0a0688aab312913483c74577;p=gnulib.git free: Remove support for obsolete platforms. * m4/free.m4 (gl_FUNC_FREE): Assume free(NULL) works. Don't define CANNOT_FREE_NULL. * lib/free.c (rpl_free): Don't test CANNOT_FREE_NULL. * modules/free (Description): Update. * doc/posix-functions/free.texi: Don't mention SunOS 4 any more. --- diff --git a/ChangeLog b/ChangeLog index c723356c11..14db75ab28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2020-12-18 Bruno Haible + + free: Remove support for obsolete platforms. + * m4/free.m4 (gl_FUNC_FREE): Assume free(NULL) works. Don't define + CANNOT_FREE_NULL. + * lib/free.c (rpl_free): Don't test CANNOT_FREE_NULL. + * modules/free (Description): Update. + * doc/posix-functions/free.texi: Don't mention SunOS 4 any more. + 2020-12-18 Paul Eggert intprops: port to ICC 2021.1 Beta 20201112 diff --git a/doc/posix-functions/free.texi b/doc/posix-functions/free.texi index ba3484c270..1c397d14ee 100644 --- a/doc/posix-functions/free.texi +++ b/doc/posix-functions/free.texi @@ -8,11 +8,6 @@ Gnulib module: free Portability problems fixed by Gnulib: @itemize -@item -On old platforms such as SunOS4, @code{free (NULL)} fails. -However, since all such systems are so old as to no longer -be considered ``reasonable portability targets,'' -this module is no longer useful. @end itemize Portability problems not fixed by Gnulib: diff --git a/lib/free.c b/lib/free.c index 843ce4816b..2f689a7ea3 100644 --- a/lib/free.c +++ b/lib/free.c @@ -1,4 +1,4 @@ -/* Work around incompatibility on older systems where free (NULL) fails. +/* Make free() preserve errno. Copyright (C) 2003, 2006, 2009-2020 Free Software Foundation, Inc. @@ -18,7 +18,6 @@ /* written by Paul Eggert */ #include -#undef free #include @@ -26,12 +25,8 @@ void rpl_free (void *p) +#undef free { -#ifdef CANNOT_FREE_NULL - if (!p) - return; -#endif - int err = errno; free (p); errno = err; diff --git a/m4/free.m4 b/m4/free.m4 index 9f108c184d..fb191df1e4 100644 --- a/m4/free.m4 +++ b/m4/free.m4 @@ -1,4 +1,4 @@ -# free.m4 serial 1 +# free.m4 serial 2 # Copyright (C) 2003-2005, 2009-2020 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -6,34 +6,10 @@ # Written by Paul Eggert. -# We can't test for free (NULL) even at runtime, since it might -# happen to "work" for our test program, but not in general. So, be -# conservative and use feature tests for relatively modern hosts, -# where free (NULL) is known to work. This costs a bit of -# performance on some older hosts, but we can fix that later if -# needed. - AC_DEFUN([gl_FUNC_FREE], [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) - AC_CACHE_CHECK([whether free (NULL) is known to work], - [gl_cv_func_free], - [case "$host_os" in - mingw*) gl_cv_func_free=yes ;; - *) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[#if _POSIX_VERSION < 199009L && \ - (defined unix || defined _unix || defined _unix_ \ - || defined __unix || defined __unix__) - #error "'free (NULL)' is not known to work" - #endif]])], - [gl_cv_func_free=yes], - [gl_cv_func_free=no]) - esac - ]) dnl In the next release of POSIX, free must preserve errno. dnl https://www.austingroupbugs.net/view.php?id=385 @@ -60,13 +36,8 @@ AC_DEFUN([gl_FUNC_FREE], esac ]) - if test $gl_cv_func_free = no; then - AC_DEFINE([CANNOT_FREE_NULL], [1], - [Define to 1 if free (NULL) does not work.]) - fi - - case $gl_cv_func_free,$gl_cv_func_free_preserves_errno in - *yes,*yes) ;; + case $gl_cv_func_free_preserves_errno in + *yes) ;; *) REPLACE_FREE=1 ;; esac ]) diff --git a/modules/free b/modules/free index dc5cb56c47..29ec637bd7 100644 --- a/modules/free +++ b/modules/free @@ -1,5 +1,5 @@ Description: -Work around systems where free sets errno or free (NULL) fails. +Work around systems where free clobbers errno. Files: lib/free.c