[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AC_FUNC_*ALLOC
From: |
Akim Demaille |
Subject: |
AC_FUNC_*ALLOC |
Date: |
16 Jul 2002 15:10:16 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter) |
This should make it easier to check whether these macros were run, as
Jim needs in lib/malloc.c for instance. It is still not a REPLACE
variation, but frankly, these new macros, IMO, should perform the
REPLACE task. Then, m4/malloc.m4 and its realloc sister would no
longer be needed.
Ok to install the does-the-replacement variation of this patch? Or
just this patch?
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:08:07 -0000
@@ -455,7 +455,8 @@
** Specific Macros
- AC_FUNC_CHOWN, AC_FUNC_MALLOC, AC_FUNC_STRERROR_R,
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK, AC_FUNC_STAT, AC_FUNC_LSTAT,
- AC_FUNC_ERROR_AT_LINE, AC_FUNC_OBSTACK, AC_FUNC_STRTOD, AC_FUNC_FSEEKO.
+ AC_FUNC_ERROR_AT_LINE, AC_FUNC_OBSTACK, AC_FUNC_REALLOC,
+ AC_FUNC_STRTOD, AC_FUNC_FSEEKO.
New.
- AC_FUNC_GETGROUPS
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:09:19 -0000
@@ -3740,7 +3740,7 @@
@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 to 0.
@end defmac
@defmac AC_FUNC_MEMCMP
@@ -3780,6 +3780,14 @@
@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 to 0.
@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:09:26 -0000
@@ -734,8 +734,11 @@
[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.])
+ AC_DEFINE([HAVE_MALLOC], 1,
+ [Define to 1 if your system has a working `malloc' function,
+ and to 0 otherwise.])
+else
+ AC_DEFINE([HAVE_MALLOC], 0)
fi
])# AC_FUNC_MALLOC
@@ -1113,6 +1116,35 @@
# AU::AM_FUNC_OBSTACK
# -------------------
AU_ALIAS([AM_FUNC_OBSTACK], [AC_FUNC_OBSTACK])
+
+
+# AC_FUNC_REALLOC
+# ---------------
+# Is `realloc (0, 0)' properly handled?
+AC_DEFUN([AC_FUNC_REALLOC],
+[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])])
+if test $ac_cv_func_realloc_works = yes; then
+ AC_DEFINE([HAVE_REALLOC], 1,
+ [Define to 1 if your system has a working `realloc' function,
+ and to 0 otherwise.])
+else
+ AC_DEFINE([HAVE_REALLOC], 0)
+fi
+])# AC_FUNC_REALLOC
# AC_FUNC_SELECT_ARGTYPES
- AC_FUNC_*ALLOC,
Akim Demaille <=