From xemacs-m  Sun May 25 13:18:12 1997
Received: from neptune.corp.comsat.com (neptune.corp.comsat.com [134.133.161.183])
	by xemacs.org (8.8.5/8.8.5) with SMTP id NAA01990
	for <xemacs-beta@xemacs.org>; Sun, 25 May 1997 13:18:10 -0500 (CDT)
Received: from neal by neptune.corp.comsat.com with local (Exim 1.58 #2)
	id 0wVhqc-0001oD-00; Sun, 25 May 1997 14:16:50 -0400
From: <neal@ctd.comsat.com>
To: xemacs-beta@xemacs.org
Subject: MMAP test
X-Face: "$ryF/ne$oms9n}#TY|W5Ttjbp-6/u4j'7c:%-aq2IAf'&DjuvII4wvr:eU{h=GMPcVTP,p
 XgCPnk{Qu:7P=jH00Q?B(*bZ\7#x_&KD=%hU1VhP'`hy'PF01*tU9DAoK7QXTGzL%fe!lIj,0Ds,P:
 GV_YPd*4GO?ClJAPRa=iB\PuIQmM=Q>qo87lJh-N2PQL-2QaM>}LdWI<}
Mime-Version: 1.0 (generated by tm-edit 7.106)
Content-Type: multipart/mixed;
 boundary="Multipart_Sun_May_25_14:16:49_1997-1"
Content-Transfer-Encoding: 7bit
Message-Id: <E0wVhqc-0001oD-00@neptune.corp.comsat.com>
Date: Sun, 25 May 1997 14:16:50 -0400

--Multipart_Sun_May_25_14:16:49_1997-1
Content-Type: text/plain; charset=US-ASCII

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


--Multipart_Sun_May_25_14:16:49_1997-1
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="Test.c"
Content-Transfer-Encoding: 7bit

#include <sys/mman.h>

# ifdef MAP_VARIABLE
#    define MAP_ADDRCHOICE_FLAG MAP_VARIABLE
# endif

#ifndef MAP_ADDRCHOICE_FLAG
#  define MAP_ADDRCHOICE_FLAG 0
#endif /* MAP_ADDRCHOICE_FLAG */

#ifdef MAP_ANONYMOUS
#  define MAP_FLAGS (MAP_PRIVATE | MAP_ADDRCHOICE_FLAG | MAP_ANONYMOUS)
#else
#  define MAP_FLAGS (MAP_PRIVATE | MAP_ADDRCHOICE_FLAG)
#endif /* MAP_ANONYMOUS */

static int DEV_ZERO_FD = -1;

main () {
  void* new_addr;
#ifndef MAP_ANONYMOUS
  DEV_ZERO_FD = open( "/dev/zero", O_RDWR );
  if (DEV_ZERO_FD < 0)
    exit (1);
#endif
  new_addr = mmap (0, 1024, PROT_READ|PROT_WRITE,
		   MAP_FLAGS, DEV_ZERO_FD, 0);
  if (new_addr < 0)
    exit (1);
  exit (0);
}

--Multipart_Sun_May_25_14:16:49_1997-1--

