Am Mit, 01 Mär 2000 schrieb Akim Demaille:
>| Hi,
>
>Hi!
>
>CCed to Autoconf because there is an issue which we'll need to discuss
>(again).
>
>| the appended patch fixes some tests to produce correct results even 
>| if compiled with the stricter checking of g++ >= 2.95.
>
>OK, you do speak of a C++ compiler and C tests :)  Are you using
>CC=g++?  Under what conditions do you meet this problems?

Yeah, C tests compiled with g++ :-). But it's not me creating these, I just
want to fix the most annoying bugs with a simple autoconf rerun. The only
noticeable misdetection stuff I encountered with all the RH61 packages were:

inline: already fixed in CVS
const: Likewise.
mmap: my patch addresses this one...
alloca: ...and this one.

I think I addressed all your concerns with the appended patch. I didn't fiddle
with any includes, cause I simply don't know enough about the implications on
non-glibc platforms. With glibc including sys/stat.h and stdlib.h for the mmap
test should be enough.


>OK, now we come the ``it''.  We've already had a long thread on this
>very issue, and it has been decided *not* to do that, because it is
>perfect C not to initial a const var.  Hence, no reason to weaken the
>test.  The only problem was with CC=g++, for which it is indeed
>invalid, but this piece of the test is conditioned out for C++.

Heh, you are right, the test is already c++ safe, I just didn't notice the test
changing around my change :-), I carry around this stuff for quite a while
now and got reminded just recently to finally post it.

Franz.

        * acspecific.m4 (AC_FUNC_MMAP): Make it c++ safe.
        (AC_FUNC_ALLOCA): Likewise.


? diff
? diff2
Index: acspecific.m4
===================================================================
RCS file: /cvs/autoconf/acspecific.m4,v
retrieving revision 1.230
diff -u -p -r1.230 acspecific.m4
--- acspecific.m4	2000/03/02 17:03:30	1.230
+++ acspecific.m4	2000/03/02 20:46:40
@@ -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 <alloca.h>], [char *p = alloca(2 * sizeof(int));],
+[AC_TRY_LINK([#include <alloca.h>],
+  [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,
@@ -1839,9 +1840,17 @@ AC_CACHE_CHECK(for working mmap, ac_cv_f
 #endif /* no HAVE_GETPAGESIZE */
 
 #ifdef __cplusplus
-extern "C" { void *malloc(unsigned); }
+extern "C"
+{
+  void *malloc (unsigned);
+  int rand (void);
+  int umask (int);
+}
+# ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+# endif
 #else
-char *malloc();
+char *malloc ();
 #endif
 
 int
@@ -1854,7 +1863,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 +1882,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 +1898,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)

Reply via email to