summaryrefslogtreecommitdiff
path: root/m4/malloc.m4
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-10-26 03:52:27 +0000
committerJim Meyering <jim@meyering.net>1997-10-26 03:52:27 +0000
commit504453762cd7e2ab14930c42c02585e2674c14a4 (patch)
tree57fc25b3555527b714221e791d4580240abc7883 /m4/malloc.m4
parent71a0d20bf5a752cf6221a5e64c1eec492c4aab62 (diff)
downloadcoreutils-504453762cd7e2ab14930c42c02585e2674c14a4.tar.xz
.
Diffstat (limited to 'm4/malloc.m4')
-rw-r--r--m4/malloc.m433
1 files changed, 33 insertions, 0 deletions
diff --git a/m4/malloc.m4 b/m4/malloc.m4
new file mode 100644
index 000000000..ec5939768
--- /dev/null
+++ b/m4/malloc.m4
@@ -0,0 +1,33 @@
+#serial 1
+
+dnl From Jim Meyering.
+dnl Determine whether malloc accepts 0 as its argument.
+dnl If it doesn't, arrange to use the replacement function.
+dnl
+dnl If you use this macro in a package, you should
+dnl add the following two lines to acconfig.h:
+dnl /* Define to rpl_malloc if the replacement function should be used. */
+dnl #undef malloc
+dnl
+
+AC_DEFUN(jm_FUNC_MALLOC,
+[
+ AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
+ [AC_TRY_RUN([
+ char *malloc ();
+ int
+ main ()
+ {
+ exit (malloc (0) ? 0 : 1);
+ }
+ ],
+ jm_cv_func_working_malloc=yes,
+ jm_cv_func_working_malloc=no,
+ dnl When crosscompiling, assume malloc is broken.
+ jm_cv_func_working_malloc=no)
+ ])
+ if test $jm_cv_func_working_malloc = no; then
+ LIBOBJS="$LIBOBJS malloc.o"
+ AC_DEFINE_UNQUOTED(malloc, rpl_malloc)
+ fi
+])