[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AC_FUNC_*ALLOC
From: |
Akim Demaille |
Subject: |
Re: AC_FUNC_*ALLOC |
Date: |
16 Jul 2002 15:24:54 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter) |
>>>>> "Akim" == Akim Demaille <address@hidden> writes:
Akim> Ok to install the does-the-replacement variation of this patch?
Akim> Or just this patch?
Here is my `replace' proposal. My previous NEWS update was wrong: it
was changing the NEWS of 2.50: we do change the meaning of
AC_FUNC_MALLOC here :(
Index: ChangeLog
from Akim Demaille <address@hidden>
* lib/autoconf/functions.m4 (AC_FUNC_REALLOC): New.
(AC_FUNC_MALLOC): Define HAVE_MALLOC to 0 if broken.
* doc/autoconf.texi (Particular Functions): Adjust.
Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.246
diff -u -u -r1.246 NEWS
--- NEWS 7 Jun 2002 09:30:24 -0000 1.246
+++ NEWS 16 Jul 2002 13:20:02 -0000
@@ -23,8 +23,13 @@
- AC_PROG_F77 default search no longer includes cf77 and cfg77.
- New macros
- AC_CONFIG_LIBOBJ_DIR, AC_GNU_SOURCE, AC_PROG_EGREP, AC_PROG_FGREP,
- AC_REPLACE_FNMATCH, AC_FUNC_FNMATCH_GNU, AC_TYPE_MBSTATE_T.
+ AC_CONFIG_LIBOBJ_DIR, AC_FUNC_REALLOC, AC_GNU_SOURCE, AC_PROG_EGREP,
+ AC_PROG_FGREP, AC_REPLACE_FNMATCH, AC_FUNC_FNMATCH_GNU,
+ AC_TYPE_MBSTATE_T.
+
+- AC_FUNC_MALLOC
+ Now defines HAVE_MALLOC to 0 if `malloc' does not work, and asks
+ for a LIBOBJ replacement.
- AC_FUNC_GETLOADAVG
looks for getloadavg.c in the CONFIG_LIBOBJ_DIR.
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.637
diff -u -u -r1.637 autoconf.texi
--- doc/autoconf.texi 9 Jul 2002 17:01:38 -0000 1.637
+++ doc/autoconf.texi 16 Jul 2002 13:20:57 -0000
@@ -3740,7 +3740,8 @@
@c @fuindex malloc
@prindex @code{malloc}
If the @code{malloc} works correctly (@samp{malloc (0)} returns a valid
-pointer), define @code{HAVE_MALLOC}.
+pointer), define @code{HAVE_MALLOC} to 1, otherwise define it to 0 and
+ask for an @code{AC_LIBOBJ} replacement for @samp{malloc}.
@end defmac
@defmac AC_FUNC_MEMCMP
@@ -3780,6 +3781,15 @@
@cindex obstack
If the obstacks are found, define @code{HAVE_OBSTACK}, else require an
@code{AC_LIBOBJ} replacement for @samp{obstack}.
address@hidden defmac
+
address@hidden AC_FUNC_REALLOC
address@hidden FUNC_REALLOC
address@hidden @fuindex realloc
address@hidden @code{realloc}
+If the @code{realloc} works correctly (@samp{realloc (0, 0)} returns a
+valid pointer), define @code{HAVE_REALLOC} to 1, otherwise define it to
+0 and ask for an @code{AC_LIBOBJ} replacement for @samp{realloc}.
@end defmac
@defmac AC_FUNC_SELECT_ARGTYPES
Index: lib/autoconf/functions.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/functions.m4,v
retrieving revision 1.66
diff -u -u -r1.66 functions.m4
--- lib/autoconf/functions.m4 12 Jun 2002 07:20:14 -0000 1.66
+++ lib/autoconf/functions.m4 16 Jul 2002 13:21:03 -0000
@@ -714,10 +714,10 @@
])
-# AC_FUNC_MALLOC
-# --------------
-# Is `malloc (0)' properly handled?
-AC_DEFUN([AC_FUNC_MALLOC],
+# _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT)
+# ------------------------------------
+# If `malloc (0)' properly handled, run IF-WORKS, otherwise, IF-NOT.
+AC_DEFUN([_AC_FUNC_MALLOC_IF],
[AC_REQUIRE([AC_HEADER_STDC])dnl
AC_CHECK_HEADERS(stdlib.h)
AC_CACHE_CHECK([for working malloc], ac_cv_func_malloc_works,
@@ -733,10 +733,23 @@
[ac_cv_func_malloc_works=yes],
[ac_cv_func_malloc_works=no],
[ac_cv_func_malloc_works=no])])
-if test $ac_cv_func_malloc_works = yes; then
- AC_DEFINE(HAVE_MALLOC, 1,
- [Define to 1 if your system has a working `malloc' function.])
-fi
+AS_IF([test $ac_cv_func_malloc_works = yes], [$1], [$2])
+])# AC_FUNC_MALLOC
+
+
+# AC_FUNC_MALLOC
+# --------------
+# Report whether `malloc (0)' properly handled, and replace malloc if
+# needed.
+AC_DEFUN([AC_FUNC_MALLOC],
+[_AC_FUNC_MALLOC_IF(
+ [AC_DEFINE([HAVE_MALLOC], 1,
+ [Define to 1 if your system has a working `malloc' function,
+ and to 0 otherwise.])],
+ [AC_DEFINE([HAVE_MALLOC], 0)
+ AC_LIBOBJ(malloc)
+ AC_DEFINE([malloc], [rpl_malloc],
+ [Define to rpl_malloc if the replacement function should be used.])])
])# AC_FUNC_MALLOC
@@ -1113,6 +1126,46 @@
# AU::AM_FUNC_OBSTACK
# -------------------
AU_ALIAS([AM_FUNC_OBSTACK], [AC_FUNC_OBSTACK])
+
+
+
+# _AC_FUNC_REALLOC_IF(IF-WORKS, IF-NOT)
+# -------------------------------------
+# If `realloc (0, 0)' properly handled, run IF-WORKS, otherwise, IF-NOT.
+AC_DEFUN([_AC_FUNC_REALLOC_IF],
+[AC_REQUIRE([AC_HEADER_STDC])dnl
+AC_CHECK_HEADERS(stdlib.h)
+AC_CACHE_CHECK([for working realloc], ac_cv_func_realloc_works,
+[AC_RUN_IFELSE(
+[AC_LANG_PROGRAM(
+[[#if STDC_HEADERS || HAVE_STDLIB_H
+# include <stdlib.h>
+#else
+char *realloc ();
+#endif
+]],
+ [exit (realloc (0, 0) ? 0 : 1);])],
+ [ac_cv_func_realloc_works=yes],
+ [ac_cv_func_realloc_works=no],
+ [ac_cv_func_realloc_works=no])])
+AS_IF([test $ac_cv_func_realloc_works = yes], [$1], [$2])
+])# AC_FUNC_REALLOC
+
+
+# AC_FUNC_REALLOC
+# ---------------
+# Report whether `realloc (0, 0)' properly handled, and replace realloc if
+# needed.
+AC_DEFUN([AC_FUNC_REALLOC],
+[_AC_FUNC_REALLOC_IF(
+ [AC_DEFINE([HAVE_REALLOC], 1,
+ [Define to 1 if your system has a working `realloc' function,
+ and to 0 otherwise.])],
+ [AC_DEFINE([HAVE_REALLOC], 0)
+ AC_LIBOBJ([realloc])
+ AC_DEFINE([realloc], [rpl_realloc],
+ [Define to rpl_realloc if the replacement function should be used.])])
+])# AC_FUNC_REALLOC
# AC_FUNC_SELECT_ARGTYPES
Index: lib/autoscan/functions
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoscan/functions,v
retrieving revision 1.17
diff -u -u -r1.17 functions
--- lib/autoscan/functions 11 Jan 2002 13:25:09 -0000 1.17
+++ lib/autoscan/functions 16 Jul 2002 13:21:03 -0000
@@ -1,5 +1,5 @@
# functions -- autoscan's mapping from functions to Autoconf macros
-# Copyright 1992, 1993, 1994, 1996, 1999, 2000, 2001, 2002
+# Copyright (C) 1992, 1993, 1994, 1996, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
@@ -51,6 +51,7 @@
mktime AC_FUNC_MKTIME
mmap AC_FUNC_MMAP
obstack_init AC_FUNC_OBSTACK
+realloc AC_FUNC_REALLOC
rindex AC_HEADER_STDC
setpgrp AC_FUNC_SETPGRP
setvbuf AC_FUNC_SETVBUF_REVERSED
- AC_FUNC_*ALLOC, Akim Demaille, 2002/07/16
- Re: AC_FUNC_*ALLOC,
Akim Demaille <=