From 9824c4e39e011a38f5d300d9d932a9b0ce61805e Mon Sep 17 00:00:00 2001 From: Gerd Moellmann Date: Sun, 10 Sep 2000 11:19:00 +0000 Subject: [PATCH] (mmap_enlarge): Don't return 0 if successful. --- src/ChangeLog | 6 +++++- src/ralloc.c | 30 ++++++++++++++---------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 3a175418f4a..3d00ebfeba2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2000-09-10 Gerd Moellmann + + * ralloc.c (mmap_enlarge): Don't return 0 if successful. + 2000-09-09 Ken Raeburn * s/netbsd.h: Use NOT_C_CODE, not NO_C_SOURCE, when deciding @@ -6,7 +10,7 @@ 2000-09-09 Gerd Moellmann * xfaces.c (CYCLE_CHECK): Don't use the Lisp_Object returned - by Fmemq in a condition. + by Fmemq as a boolean. 2000-09-08 Stefan Monnier diff --git a/src/ralloc.c b/src/ralloc.c index a90b6514799..9858e45a87e 100644 --- a/src/ralloc.c +++ b/src/ralloc.c @@ -1389,41 +1389,39 @@ mmap_enlarge (r, npages) { char *region_end = (char *) r + r->nbytes_mapped; size_t nbytes; - int success = 1; + int success = 0; if (npages < 0) { /* Unmap pages at the end of the region. */ nbytes = - npages * page_size; if (munmap (region_end - nbytes, nbytes) == -1) + fprintf (stderr, "munmap: %s\n", emacs_strerror (errno)); + else { - fprintf (stderr, "munmap: %s\n", emacs_strerror (errno)); - success = 0; + r->nbytes_mapped -= nbytes; + success = 1; } - else - r->nbytes_mapped -= nbytes; } else if (npages > 0) { + struct mmap_region *r2; + nbytes = npages * page_size; /* Try to map additional pages at the end of the region. We cannot do this if the address range is already occupied by something else because mmap deletes any previous mapping. I'm not sure this is worth doing, let's see. */ - if (mmap_find (region_end, region_end + nbytes)) - success = 0; - else + r2 = mmap_find (region_end, region_end + nbytes); + if (r2 == NULL) { POINTER_TYPE *p; p = mmap (region_end, nbytes, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, mmap_fd, 0); if (p == MAP_FAILED) - { - fprintf (stderr, "mmap: %s\n", emacs_strerror (errno)); - success = 0; - } + fprintf (stderr, "mmap: %s\n", emacs_strerror (errno)); else if (p != (POINTER_TYPE *) region_end) { /* Kernels are free to choose a different address. In @@ -1431,13 +1429,13 @@ mmap_enlarge (r, npages) no use for it. */ if (munmap (p, nbytes) == -1) fprintf (stderr, "munmap: %s\n", emacs_strerror (errno)); - success = 0; } else - r->nbytes_mapped += nbytes; + { + r->nbytes_mapped += nbytes; + success = 1; + } } - - success = 0; } return success; -- 2.39.5