summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2012-05-04 04:23:44 +0200
committerBruno Haible <bruno@clisp.org>2012-05-04 04:23:58 +0200
commit98f7f8fde92f6f3f583cabc1168305a9ce542bbe (patch)
treed6e7eadc1785a1182131e947fabc702828d19bd6
parent158873b079eb6b325742b502a0dd5b55308d3185 (diff)
downloadgnulib-98f7f8fde92f6f3f583cabc1168305a9ce542bbe.tar.gz
*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.
-rw-r--r--ChangeLog9
-rw-r--r--m4/calloc.m420
-rw-r--r--m4/malloc.m440
-rw-r--r--m4/realloc.m440
-rw-r--r--modules/eealloc2
5 files changed, 106 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 2729eef884..c1c5ac29fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
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.
* m4/getgroups.m4 (AC_FUNC_GETGROUPS): Override in autoconf < 2.70.
(gl_FUNC_GETGROUPS): Adapt to change of ac_cv_func_getgroups_works.
diff --git a/m4/calloc.m4 b/m4/calloc.m4
index bc61168c37..00c5fe43cf 100644
--- 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_DEFUN([_AC_FUNC_CALLOC_IF],
]])],
[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
diff --git a/m4/malloc.m4 b/m4/malloc.m4
index d3c39f5d96..8fa48e93bc 100644
--- 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
diff --git a/m4/realloc.m4 b/m4/realloc.m4
index 039ed192a6..954c2f0e58 100644
--- 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
diff --git a/modules/eealloc b/modules/eealloc
index 437cb4ddf5..7e18d45a99 100644
--- a/modules/eealloc
+++ b/modules/eealloc
@@ -4,6 +4,8 @@ Memory allocation with expensive empty allocations (glibc compatible).
Files:
lib/eealloc.h
m4/eealloc.m4
+m4/malloc.m4
+m4/realloc.m4
Depends-on: