Mercurial > hg > octave-lojdl > gnulib-hg
changeset 16815:837ea4b31230
*alloc-gnu, eealloc: Avoid "guessing no" when cross-compiling to glibc.
* m4/malloc.m4 (_AC_FUNC_MALLOC_IF): Override in autoconf < 2.70.
* m4/realloc.m4 (_AC_FUNC_REALLOC_IF): Override in autoconf < 2.70.
* m4/calloc.m4 (_AC_FUNC_CALLOC_IF): Require AC_CANONICAL_HOST. When
cross-compiling, choose the first alternative on glibc systems.
* modules/eealloc (Files): Add m4/malloc.m4, m4/realloc.m4.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Fri, 04 May 2012 04:23:44 +0200 |
parents | 8fa37454b38b |
children | 7fd7a96c8845 |
files | ChangeLog m4/calloc.m4 m4/malloc.m4 m4/realloc.m4 modules/eealloc |
diffstat | 5 files changed, 106 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2012-05-03 Bruno Haible <bruno@clisp.org> + + *alloc-gnu, eealloc: Avoid "guessing no" when cross-compiling to glibc. + * m4/malloc.m4 (_AC_FUNC_MALLOC_IF): Override in autoconf < 2.70. + * m4/realloc.m4 (_AC_FUNC_REALLOC_IF): Override in autoconf < 2.70. + * m4/calloc.m4 (_AC_FUNC_CALLOC_IF): Require AC_CANONICAL_HOST. When + cross-compiling, choose the first alternative on glibc systems. + * modules/eealloc (Files): Add m4/malloc.m4, m4/realloc.m4. + 2012-05-03 Bruno Haible <bruno@clisp.org> getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
--- a/m4/calloc.m4 +++ b/m4/calloc.m4 @@ -1,4 +1,4 @@ -# calloc.m4 serial 14 +# calloc.m4 serial 15 # Copyright (C) 2004-2012 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -18,6 +18,7 @@ AC_DEFUN([_AC_FUNC_CALLOC_IF], [ AC_REQUIRE([AC_TYPE_SIZE_T])dnl + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CACHE_CHECK([for GNU libc compatible calloc], [ac_cv_func_calloc_0_nonnull], [AC_RUN_IFELSE( @@ -32,8 +33,21 @@ ]])], [ac_cv_func_calloc_0_nonnull=yes], [ac_cv_func_calloc_0_nonnull=no], - [ac_cv_func_calloc_0_nonnull=no])]) - AS_IF([test $ac_cv_func_calloc_0_nonnull = yes], [$1], [$2]) + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) ac_cv_func_calloc_0_nonnull="guessing yes" ;; + # If we don't know, assume the worst. + *) ac_cv_func_calloc_0_nonnull="guessing no" ;; + esac + ])]) + case "$ac_cv_func_calloc_0_nonnull" in + *yes) + $1 + ;; + *) + $2 + ;; + esac ])# AC_FUNC_CALLOC
--- a/m4/malloc.m4 +++ b/m4/malloc.m4 @@ -1,9 +1,47 @@ -# malloc.m4 serial 13 +# malloc.m4 serial 14 dnl Copyright (C) 2007, 2009-2012 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. +m4_version_prereq([2.70], [] ,[ + +# This is taken from the following Autoconf patch: +# http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9 +AC_DEFUN([_AC_FUNC_MALLOC_IF], +[ + AC_REQUIRE([AC_HEADER_STDC])dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles + AC_CHECK_HEADERS([stdlib.h]) + AC_CACHE_CHECK([for GNU libc compatible malloc], + [ac_cv_func_malloc_0_nonnull], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H + # include <stdlib.h> + #else + char *malloc (); + #endif + ]], + [[return ! malloc (0);]]) + ], + [ac_cv_func_malloc_0_nonnull=yes], + [ac_cv_func_malloc_0_nonnull=no], + [case "$host_os" in + # Guess yes on platforms where we know the result. + *-gnu* | freebsd* | netbsd* | openbsd* \ + | hpux* | solaris* | cygwin* | mingw*) + ac_cv_func_malloc_0_nonnull=yes ;; + # If we don't know, assume the worst. + *) ac_cv_func_malloc_0_nonnull=no ;; + esac + ]) + ]) + AS_IF([test $ac_cv_func_malloc_0_nonnull = yes], [$1], [$2]) +])# _AC_FUNC_MALLOC_IF + +]) + # gl_FUNC_MALLOC_GNU # ------------------ # Test whether 'malloc (0)' is handled like in GNU libc, and replace malloc if
--- a/m4/realloc.m4 +++ b/m4/realloc.m4 @@ -1,9 +1,47 @@ -# realloc.m4 serial 12 +# realloc.m4 serial 13 dnl Copyright (C) 2007, 2009-2012 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. +m4_version_prereq([2.70], [] ,[ + +# This is taken from the following Autoconf patch: +# http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9 +AC_DEFUN([_AC_FUNC_REALLOC_IF], +[ + AC_REQUIRE([AC_HEADER_STDC])dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles + AC_CHECK_HEADERS([stdlib.h]) + AC_CACHE_CHECK([for GNU libc compatible realloc], + [ac_cv_func_realloc_0_nonnull], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H + # include <stdlib.h> + #else + char *realloc (); + #endif + ]], + [[return ! realloc (0, 0);]]) + ], + [ac_cv_func_realloc_0_nonnull=yes], + [ac_cv_func_realloc_0_nonnull=no], + [case "$host_os" in + # Guess yes on platforms where we know the result. + *-gnu* | freebsd* | netbsd* | openbsd* \ + | hpux* | solaris* | cygwin* | mingw*) + ac_cv_func_realloc_0_nonnull=yes ;; + # If we don't know, assume the worst. + *) ac_cv_func_realloc_0_nonnull=no ;; + esac + ]) + ]) + AS_IF([test $ac_cv_func_realloc_0_nonnull = yes], [$1], [$2]) +])# AC_FUNC_REALLOC + +]) + # gl_FUNC_REALLOC_GNU # ------------------- # Test whether 'realloc (0, 0)' is handled like in GNU libc, and replace