From: Akim Demaille Date: Wed, 8 Mar 2000 16:44:55 +0000 (+0000) Subject: * acspecific.m4 (AC_FUNC_MMAP, AC_FUNC_ALLOCA): Make them C++ X-Git-Tag: autoconf-2.50~1074 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f206e89cb30f656580e6f78932d3af0bc47f4345;p=thirdparty%2Fautoconf.git * acspecific.m4 (AC_FUNC_MMAP, AC_FUNC_ALLOCA): Make them C++ safe: include the right headers, cast the allocations etc. --- diff --git a/ChangeLog b/ChangeLog index 324d30a96..814bb5cfd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2000-03-08 Franz Sirl + + * acspecific.m4 (AC_FUNC_MMAP, AC_FUNC_ALLOCA): Make them C++ + safe: include the right headers, cast the allocations etc. + 2000-03-08 Akim Demaille The argument of AC_COPYRIGHT should be plain text, not an sh diff --git a/acspecific.m4 b/acspecific.m4 index e6fe11a42..de2e1f9b6 100644 --- a/acspecific.m4 +++ b/acspecific.m4 @@ -1265,7 +1265,8 @@ AC_DEFUN(AC_FUNC_ALLOCA, # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! AC_CACHE_CHECK([for working alloca.h], ac_cv_working_alloca_h, -[AC_TRY_LINK([#include ], [char *p = alloca(2 * sizeof(int));], +[AC_TRY_LINK([#include ], + [char *p = (char *) alloca (2 * sizeof (int));], ac_cv_working_alloca_h=yes, ac_cv_working_alloca_h=no)]) if test $ac_cv_working_alloca_h = yes; then AC_DEFINE(HAVE_ALLOCA_H, 1, @@ -1768,7 +1769,7 @@ fi # AC_FUNC_MMAP # ------------ AC_DEFUN(AC_FUNC_MMAP, -[AC_CHECK_HEADERS(unistd.h) +[AC_CHECK_HEADERS(stdlib.h unistd.h sys/stat.h) AC_CHECK_FUNCS(getpagesize) AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped, [AC_TRY_RUN( @@ -1797,12 +1798,20 @@ AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped, #include #include +#if HAVE_STDLIB_H +# include +#else +char *malloc (); +#endif +#if HAVE_UNISTD_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif + /* This mess was copied from the GNU getpagesize.h. */ #if !HAVE_GETPAGESIZE -# if HAVE_UNISTD_H -# include -# endif - /* Assume that all systems that can run configure have sys/param.h. */ # if !HAVE_SYS_PARAM_H # define HAVE_SYS_PARAM_H 1 @@ -1838,12 +1847,6 @@ AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped, #endif /* no HAVE_GETPAGESIZE */ -#ifdef __cplusplus -extern "C" { void *malloc(unsigned); } -#else -char *malloc(); -#endif - int main () { @@ -1854,7 +1857,7 @@ main () pagesize = getpagesize (); /* First, make a file with some known garbage in it. */ - data = malloc (pagesize); + data = (char *) malloc (pagesize); if (!data) exit (1); for (i = 0; i < pagesize; ++i) @@ -1873,7 +1876,7 @@ main () fd = open ("conftestmmap", O_RDWR); if (fd < 0) exit (1); - data2 = malloc (2 * pagesize); + data2 = (char *) malloc (2 * pagesize); if (!data2) exit (1); data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1); @@ -1889,7 +1892,7 @@ main () some variants of i386 svr4.0.) */ for (i = 0; i < pagesize; ++i) *(data2 + i) = *(data2 + i) + 1; - data3 = malloc (pagesize); + data3 = (char *) malloc (pagesize); if (!data3) exit (1); if (read (fd, data3, pagesize) != pagesize) diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4 index e6fe11a42..de2e1f9b6 100644 --- a/lib/autoconf/specific.m4 +++ b/lib/autoconf/specific.m4 @@ -1265,7 +1265,8 @@ AC_DEFUN(AC_FUNC_ALLOCA, # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! AC_CACHE_CHECK([for working alloca.h], ac_cv_working_alloca_h, -[AC_TRY_LINK([#include ], [char *p = alloca(2 * sizeof(int));], +[AC_TRY_LINK([#include ], + [char *p = (char *) alloca (2 * sizeof (int));], ac_cv_working_alloca_h=yes, ac_cv_working_alloca_h=no)]) if test $ac_cv_working_alloca_h = yes; then AC_DEFINE(HAVE_ALLOCA_H, 1, @@ -1768,7 +1769,7 @@ fi # AC_FUNC_MMAP # ------------ AC_DEFUN(AC_FUNC_MMAP, -[AC_CHECK_HEADERS(unistd.h) +[AC_CHECK_HEADERS(stdlib.h unistd.h sys/stat.h) AC_CHECK_FUNCS(getpagesize) AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped, [AC_TRY_RUN( @@ -1797,12 +1798,20 @@ AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped, #include #include +#if HAVE_STDLIB_H +# include +#else +char *malloc (); +#endif +#if HAVE_UNISTD_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif + /* This mess was copied from the GNU getpagesize.h. */ #if !HAVE_GETPAGESIZE -# if HAVE_UNISTD_H -# include -# endif - /* Assume that all systems that can run configure have sys/param.h. */ # if !HAVE_SYS_PARAM_H # define HAVE_SYS_PARAM_H 1 @@ -1838,12 +1847,6 @@ AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped, #endif /* no HAVE_GETPAGESIZE */ -#ifdef __cplusplus -extern "C" { void *malloc(unsigned); } -#else -char *malloc(); -#endif - int main () { @@ -1854,7 +1857,7 @@ main () pagesize = getpagesize (); /* First, make a file with some known garbage in it. */ - data = malloc (pagesize); + data = (char *) malloc (pagesize); if (!data) exit (1); for (i = 0; i < pagesize; ++i) @@ -1873,7 +1876,7 @@ main () fd = open ("conftestmmap", O_RDWR); if (fd < 0) exit (1); - data2 = malloc (2 * pagesize); + data2 = (char *) malloc (2 * pagesize); if (!data2) exit (1); data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1); @@ -1889,7 +1892,7 @@ main () some variants of i386 svr4.0.) */ for (i = 0; i < pagesize; ++i) *(data2 + i) = *(data2 + i) + 1; - data3 = malloc (pagesize); + data3 = (char *) malloc (pagesize); if (!data3) exit (1); if (read (fd, data3, pagesize) != pagesize)