diff options
| author | Gerd Moellmann | 2000-09-10 11:19:00 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-09-10 11:19:00 +0000 |
| commit | 9824c4e39e011a38f5d300d9d932a9b0ce61805e (patch) | |
| tree | 8a22185f6d263471e34d84bde834caf195037271 /src/ralloc.c | |
| parent | 6a72fdd12eb40f88442576abbc67cfcaa242b701 (diff) | |
| download | emacs-9824c4e39e011a38f5d300d9d932a9b0ce61805e.tar.gz emacs-9824c4e39e011a38f5d300d9d932a9b0ce61805e.zip | |
(mmap_enlarge): Don't return 0 if successful.
Diffstat (limited to 'src/ralloc.c')
| -rw-r--r-- | src/ralloc.c | 30 |
1 files changed, 14 insertions, 16 deletions
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) | |||
| 1389 | { | 1389 | { |
| 1390 | char *region_end = (char *) r + r->nbytes_mapped; | 1390 | char *region_end = (char *) r + r->nbytes_mapped; |
| 1391 | size_t nbytes; | 1391 | size_t nbytes; |
| 1392 | int success = 1; | 1392 | int success = 0; |
| 1393 | 1393 | ||
| 1394 | if (npages < 0) | 1394 | if (npages < 0) |
| 1395 | { | 1395 | { |
| 1396 | /* Unmap pages at the end of the region. */ | 1396 | /* Unmap pages at the end of the region. */ |
| 1397 | nbytes = - npages * page_size; | 1397 | nbytes = - npages * page_size; |
| 1398 | if (munmap (region_end - nbytes, nbytes) == -1) | 1398 | if (munmap (region_end - nbytes, nbytes) == -1) |
| 1399 | fprintf (stderr, "munmap: %s\n", emacs_strerror (errno)); | ||
| 1400 | else | ||
| 1399 | { | 1401 | { |
| 1400 | fprintf (stderr, "munmap: %s\n", emacs_strerror (errno)); | 1402 | r->nbytes_mapped -= nbytes; |
| 1401 | success = 0; | 1403 | success = 1; |
| 1402 | } | 1404 | } |
| 1403 | else | ||
| 1404 | r->nbytes_mapped -= nbytes; | ||
| 1405 | } | 1405 | } |
| 1406 | else if (npages > 0) | 1406 | else if (npages > 0) |
| 1407 | { | 1407 | { |
| 1408 | struct mmap_region *r2; | ||
| 1409 | |||
| 1408 | nbytes = npages * page_size; | 1410 | nbytes = npages * page_size; |
| 1409 | 1411 | ||
| 1410 | /* Try to map additional pages at the end of the region. We | 1412 | /* Try to map additional pages at the end of the region. We |
| 1411 | cannot do this if the address range is already occupied by | 1413 | cannot do this if the address range is already occupied by |
| 1412 | something else because mmap deletes any previous mapping. | 1414 | something else because mmap deletes any previous mapping. |
| 1413 | I'm not sure this is worth doing, let's see. */ | 1415 | I'm not sure this is worth doing, let's see. */ |
| 1414 | if (mmap_find (region_end, region_end + nbytes)) | 1416 | r2 = mmap_find (region_end, region_end + nbytes); |
| 1415 | success = 0; | 1417 | if (r2 == NULL) |
| 1416 | else | ||
| 1417 | { | 1418 | { |
| 1418 | POINTER_TYPE *p; | 1419 | POINTER_TYPE *p; |
| 1419 | 1420 | ||
| 1420 | p = mmap (region_end, nbytes, PROT_READ | PROT_WRITE, | 1421 | p = mmap (region_end, nbytes, PROT_READ | PROT_WRITE, |
| 1421 | MAP_ANON | MAP_PRIVATE | MAP_FIXED, mmap_fd, 0); | 1422 | MAP_ANON | MAP_PRIVATE | MAP_FIXED, mmap_fd, 0); |
| 1422 | if (p == MAP_FAILED) | 1423 | if (p == MAP_FAILED) |
| 1423 | { | 1424 | fprintf (stderr, "mmap: %s\n", emacs_strerror (errno)); |
| 1424 | fprintf (stderr, "mmap: %s\n", emacs_strerror (errno)); | ||
| 1425 | success = 0; | ||
| 1426 | } | ||
| 1427 | else if (p != (POINTER_TYPE *) region_end) | 1425 | else if (p != (POINTER_TYPE *) region_end) |
| 1428 | { | 1426 | { |
| 1429 | /* Kernels are free to choose a different address. In | 1427 | /* Kernels are free to choose a different address. In |
| @@ -1431,13 +1429,13 @@ mmap_enlarge (r, npages) | |||
| 1431 | no use for it. */ | 1429 | no use for it. */ |
| 1432 | if (munmap (p, nbytes) == -1) | 1430 | if (munmap (p, nbytes) == -1) |
| 1433 | fprintf (stderr, "munmap: %s\n", emacs_strerror (errno)); | 1431 | fprintf (stderr, "munmap: %s\n", emacs_strerror (errno)); |
| 1434 | success = 0; | ||
| 1435 | } | 1432 | } |
| 1436 | else | 1433 | else |
| 1437 | r->nbytes_mapped += nbytes; | 1434 | { |
| 1435 | r->nbytes_mapped += nbytes; | ||
| 1436 | success = 1; | ||
| 1437 | } | ||
| 1438 | } | 1438 | } |
| 1439 | |||
| 1440 | success = 0; | ||
| 1441 | } | 1439 | } |
| 1442 | 1440 | ||
| 1443 | return success; | 1441 | return success; |