X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=m4%2Frealloc.m4;h=3e97b1da967ca600e04ed946c9ab65f909035576;hb=5a9eb938fe7692fef0c13fb6bccda9c2a80db224;hp=9f746f1902cd79dc72dc184ab29c011f77eefe08;hpb=e059c2358aad79ce8dfd9581dd6f12ce8503dc63;p=gnulib.git diff --git a/m4/realloc.m4 b/m4/realloc.m4 index 9f746f190..3e97b1da9 100644 --- a/m4/realloc.m4 +++ b/m4/realloc.m4 @@ -1,25 +1,44 @@ -# realloc.m4 serial 7 -dnl Copyright (C) 2002 Free Software Foundation, Inc. -dnl This file is free software, distributed under the terms of the GNU -dnl General Public License. As a special exception to the GNU General -dnl Public License, this file may be distributed as part of a program -dnl that contains a configuration script generated by Autoconf, under -dnl the same distribution terms as the rest of that program. +# realloc.m4 serial 10 +dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. -dnl From Jim Meyering. -dnl Determine whether realloc works when both arguments are 0. -dnl If it doesn't, arrange to use the replacement function. +# gl_FUNC_REALLOC_GNU +# ------------------- +# Test whether 'realloc (0, 0)' is handled like in GNU libc, and replace +# realloc if it is not. +AC_DEFUN([gl_FUNC_REALLOC_GNU], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + dnl _AC_FUNC_REALLOC_IF is defined in Autoconf. + _AC_FUNC_REALLOC_IF( + [AC_DEFINE([HAVE_REALLOC], [1], + [Define to 1 if your system has a GNU libc compatible 'realloc' + function, and to 0 otherwise.])], + [AC_DEFINE([HAVE_REALLOC], [0]) + gl_REPLACE_REALLOC + ]) +])# gl_FUNC_REALLOC_GNU -AC_DEFUN([jm_FUNC_REALLOC], +# gl_FUNC_REALLOC_POSIX +# --------------------- +# Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it +# fails), and replace realloc if it is not. +AC_DEFUN([gl_FUNC_REALLOC_POSIX], [ - AC_REQUIRE([AC_FUNC_REALLOC]) - dnl autoconf < 2.57 used the symbol ac_cv_func_realloc_works. - if test X"$ac_cv_func_realloc_0_nonnull" = Xno || test X"$ac_cv_func_realloc_works" = Xno; then - gl_PREREQ_REALLOC + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) + if test $gl_cv_func_malloc_posix = yes; then + AC_DEFINE([HAVE_REALLOC_POSIX], [1], + [Define if the 'realloc' function is POSIX compliant.]) + else + gl_REPLACE_REALLOC fi ]) -# Prerequisites of lib/realloc.c. -AC_DEFUN([gl_PREREQ_REALLOC], [ - : +AC_DEFUN([gl_REPLACE_REALLOC], +[ + AC_LIBOBJ([realloc]) + REPLACE_REALLOC=1 ])