From xemacs-m  Wed May 28 21:02:05 1997
Received: from mercury.Sun.COM (mercury.Sun.COM [192.9.25.1])
	by xemacs.org (8.8.5/8.8.5) with SMTP id VAA21666
	for <xemacs-beta@xemacs.org>; Wed, 28 May 1997 21:02:05 -0500 (CDT)
Received: from Eng.Sun.COM ([129.146.1.25]) by mercury.Sun.COM (SMI-8.6/mail.byaddr) with SMTP id TAA28892; Wed, 28 May 1997 19:18:30 -0700
Received: from kindra.eng.sun.com by Eng.Sun.COM (SMI-8.6/SMI-5.3)
	id TAA04566; Wed, 28 May 1997 19:01:04 -0700
Received: from xemacs.eng.sun.com by kindra.eng.sun.com (SMI-8.6/SMI-SVR4)
	id TAA22211; Wed, 28 May 1997 19:01:02 -0700
Received: by xemacs.eng.sun.com (SMI-8.6/SMI-SVR4)
	id TAA17330; Wed, 28 May 1997 19:01:07 -0700
Date: Wed, 28 May 1997 19:01:07 -0700
Message-Id: <199705290201.TAA17330@xemacs.eng.sun.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
From: Martin Buchholz <mrb@Eng.Sun.COM>
To: Neal Becker <neal@ctd.comsat.com>
Cc: xemacs-beta@xemacs.org
Subject: MMAP test
In-Reply-To: <E0wVhqc-0001oD-00@neptune.corp.comsat.com>
References: <E0wVhqc-0001oD-00@neptune.corp.comsat.com>
X-Mailer: VM 6.31 under 20.3 XEmacs Lucid (beta2)
Reply-To: Martin Buchholz <mrb@Eng.Sun.COM>

>>>>> "neal" == neal  <neal@ctd.comsat.com> writes:

neal> Here is a test for mmap.  This test looks just for the support that is 
neal> needed by xemacs, which I believe is used only for ralloc.c.

I've modified your mmap program a little, and the configure fragment
now looks like this (please check my work):


dnl We used to call AC_FUNC_MMAP here
dnl Instead we now use following, suggested by Neal Becker
AC_MSG_CHECKING(for working mmap)
AC_TRY_RUN([#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>

#ifndef MAP_VARIABLE
#define MAP_VARIABLE 0
#endif

#ifndef MAP_FAILED
#define MAP_FAILED -1
#endif

int main (int argc, char *argv[])
{
  int fd = -1;
  caddr_t p;
#ifndef MAP_ANONYMOUS
  fd = open ("/dev/zero", O_RDWR);
  if (fd < 0)
    return 1;
#define MAP_ANONYMOUS 0
#endif
  if (mmap(0, 1024, PROT_READ | PROT_WRITE,
	   MAP_PRIVATE | MAP_VARIABLE | MAP_ANONYMOUS,
	   fd, 0) != (void *) MAP_FAILED)
    return 0;
  perror ("conftest: mmap failed");
  return 1;
}], have_mmap=yes, have_mmap=no)
AC_MSG_RESULT($have_mmap)
test "$have_mmap" = "yes" && AC_DEFINE(HAVE_MMAP)

dnl rel_alloc requires either GNU malloc or system malloc with mmap
dnl We only turn rel_alloc on by default if mmap is available.
test "$GNU_MALLOC" != "yes"   -a "$have_mmap" != "yes" && rel_alloc=no
test "$rel_alloc" = "default" -a "$have_mmap"  = "yes" && rel_alloc=yes
test "$rel_alloc" = "yes" && AC_DEFINE(REL_ALLOC)

