aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2002-04-07 17:58:57 +0000
committerAndrew Cagney <cagney@redhat.com>2002-04-07 17:58:57 +0000
commitaeec20bafba923fc36ac252590362746847913a3 (patch)
treeaafa7f18e4580624f83fd357862a0d916fc4251d
parentc657a1f082d393862981e62d8e6ed377d549539d (diff)
downloadgdb-aeec20bafba923fc36ac252590362746847913a3.zip
gdb-aeec20bafba923fc36ac252590362746847913a3.tar.gz
gdb-aeec20bafba923fc36ac252590362746847913a3.tar.bz2
From 2002-03-05 Scott Pakin <pakin@uiuc.edu>
* mmap-sup.c (MAP_PRIVATE_OR_SHARED): Define. (__mmalloc_mmap_morecore): Use. (__mmalloc_remap_core): Use.
-rw-r--r--mmalloc/ChangeLog7
-rw-r--r--mmalloc/mmap-sup.c22
2 files changed, 23 insertions, 6 deletions
diff --git a/mmalloc/ChangeLog b/mmalloc/ChangeLog
index 20339a5..8b59d38 100644
--- a/mmalloc/ChangeLog
+++ b/mmalloc/ChangeLog
@@ -1,3 +1,10 @@
+2002-04-07 Andrew Cagney <ac131313@redhat.com>
+
+ From 2002-03-05 Scott Pakin <pakin@uiuc.edu>
+ * mmap-sup.c (MAP_PRIVATE_OR_SHARED): Define.
+ (__mmalloc_mmap_morecore): Use.
+ (__mmalloc_remap_core): Use.
+
2000-05-17 Eli Zaretskii <eliz@is.elta.co.il>
* Makefile.in (install-info): Make sure $(infodir) exists. Run
diff --git a/mmalloc/mmap-sup.c b/mmalloc/mmap-sup.c
index 56146e2..b12e43c 100644
--- a/mmalloc/mmap-sup.c
+++ b/mmalloc/mmap-sup.c
@@ -48,6 +48,15 @@ extern int getpagesize PARAMS ((void));
#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 @@ __mmalloc_mmap_morecore (mdp, size)
{
/* 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 @@ __mmalloc_mmap_morecore (mdp, size)
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 @@ __mmalloc_remap_core (mdp)
/* 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 @@ mmalloc_findbase (size)
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)