From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24030 invoked by alias); 7 Apr 2002 17:58:11 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 24019 invoked from network); 7 Apr 2002 17:58:10 -0000 Received: from unknown (HELO localhost.redhat.com) (24.112.240.27) by sources.redhat.com with SMTP; 7 Apr 2002 17:58:10 -0000 Received: from cygnus.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 4350A3CBF; Sun, 7 Apr 2002 13:58:09 -0400 (EDT) Message-ID: <3CB088B0.1020506@cygnus.com> Date: Sun, 07 Apr 2002 10:58:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:0.9.9) Gecko/20020328 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Scott Pakin Cc: gdb-patches@sources.redhat.com Subject: Re: PATCH: Make libmmalloc work properly with /dev/zero References: <3C854268.2080508@uiuc.edu> <3C9CDD7A.1080302@cygnus.com> <3C9F64F9.6040908@uiuc.edu> Content-Type: multipart/mixed; boundary="------------050407040100050803040102" X-SW-Source: 2002-04/txt/msg00255.txt.bz2 This is a multi-part message in MIME format. --------------050407040100050803040102 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 189 FYI, I've checked in the attached. I tweaked the code and ChangeLog to comply with GNU conventions (and resisted the temptation to change the macro into a function :-). thanks! Andrew --------------050407040100050803040102 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 2371 2002-04-07 Andrew Cagney From 2002-03-05 Scott Pakin * mmap-sup.c (MAP_PRIVATE_OR_SHARED): Define. (__mmalloc_mmap_morecore): Use. (__mmalloc_remap_core): Use. Index: mmap-sup.c =================================================================== RCS file: /cvs/src/src/mmalloc/mmap-sup.c,v retrieving revision 1.3 diff -u -r1.3 mmap-sup.c --- mmap-sup.c 19 Feb 2000 00:44:46 -0000 1.3 +++ mmap-sup.c 7 Apr 2002 17:53:23 -0000 @@ -48,6 +48,15 @@ #define PAGE_ALIGN(addr) (caddr_t) (((long)(addr) + pagesize - 1) & \ ~(pagesize - 1)) + +/* Return MAP_PRIVATE if MDP represents /dev/zero. Otherwise, return + MAP_SHARED. */ + +#define MAP_PRIVATE_OR_SHARED(MDP) ((MDP -> flags & MMALLOC_DEVZERO) \ + ? MAP_PRIVATE \ + : MAP_SHARED) + + /* Get core for the memory region specified by MDP, using SIZE as the amount to either add to or subtract from the existing region. Works like sbrk(), but using mmap(). */ @@ -113,7 +122,7 @@ { /* Let mmap pick the map start address */ mapto = mmap (0, mapbytes, PROT_READ | PROT_WRITE, - MAP_SHARED, mdp -> fd, foffset); + MAP_PRIVATE_OR_SHARED (mdp), mdp -> fd, foffset); if (mapto != (caddr_t) -1) { mdp -> base = mdp -> breakval = mapto; @@ -125,7 +134,8 @@ else { mapto = mmap (mdp -> top, mapbytes, PROT_READ | PROT_WRITE, - MAP_SHARED | MAP_FIXED, mdp -> fd, foffset); + MAP_PRIVATE_OR_SHARED (mdp) | MAP_FIXED, mdp -> fd, + foffset); if (mapto == mdp -> top) { mdp -> top = moveto; @@ -152,7 +162,7 @@ /* FIXME: Quick hack, needs error checking and other attention. */ base = mmap (mdp -> base, mdp -> top - mdp -> base, - PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, + PROT_READ | PROT_WRITE, MAP_PRIVATE_OR_SHARED (mdp) | MAP_FIXED, mdp -> fd, 0); return ((PTR) base); } @@ -166,13 +176,13 @@ caddr_t base = NULL; #ifdef MAP_ANONYMOUS - flags = MAP_SHARED | MAP_ANONYMOUS; + flags = MAP_PRIVATE | MAP_ANONYMOUS; fd = -1; #else #ifdef MAP_FILE - flags = MAP_SHARED | MAP_FILE; + flags = MAP_PRIVATE | MAP_FILE; #else - flags = MAP_SHARED; + flags = MAP_PRIVATE; #endif fd = open ("/dev/zero", O_RDWR); if (fd != -1) --------------050407040100050803040102--