diff options
author | Bruno Haible <bruno@clisp.org> | 2017-04-19 01:27:17 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2017-04-19 01:27:17 +0200 |
commit | 959b2dff5af5e6ea63773bdf2f516d9c1af586e4 (patch) | |
tree | fb1b214f00ac7a818a6db974b32d64bf121c8fca | |
parent | 3a82bb79c68b1bf814ad1f5e7c5e34bbe6697a26 (diff) | |
download | gnulib-959b2dff5af5e6ea63773bdf2f516d9c1af586e4.tar.gz |
vma-iter: Fix compilation error on Solaris 7.
* lib/vma-iter.c (vma_iterate): Treat missing MAP_ANONYMOUS on Solaris
like on IRIX, OSF/1.
Reported by Tom G. Christensen <tgc@jupiterrise.com>.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | lib/vma-iter.c | 34 |
2 files changed, 39 insertions, 2 deletions
@@ -1,5 +1,12 @@ 2017-04-18 Bruno Haible <bruno@clisp.org> + vma-iter: Fix compilation error on Solaris 7. + * lib/vma-iter.c (vma_iterate): Treat missing MAP_ANONYMOUS on Solaris + like on IRIX, OSF/1. + Reported by Tom G. Christensen <tgc@jupiterrise.com>. + +2017-04-18 Bruno Haible <bruno@clisp.org> + vma-iter: Fix conflict with module 'largefile' on 32-bit Solaris 9. * modules/vma-iter (configure.ac): Test whether <sys/procfs.h> can be included. diff --git a/lib/vma-iter.c b/lib/vma-iter.c index d4bae13183..e81b8ea1ce 100644 --- a/lib/vma-iter.c +++ b/lib/vma-iter.c @@ -399,6 +399,13 @@ vma_iterate (vma_iterate_callback_fn callback, void *data) int fd; int nmaps; size_t memneed; +# if HAVE_MAP_ANONYMOUS +# define zero_fd -1 +# define map_flags MAP_ANONYMOUS +# else /* Solaris <= 7 */ + int zero_fd; +# define map_flags 0 +# endif void *auxmap; unsigned long auxmap_start; unsigned long auxmap_end; @@ -433,8 +440,16 @@ vma_iterate (vma_iterate_callback_fn callback, void *data) and thus pre-allocate available memory. So use mmap(), and ignore the resulting VMA. */ memneed = ((memneed - 1) / pagesize + 1) * pagesize; +# if !HAVE_MAP_ANONYMOUS + zero_fd = open ("/dev/zero", O_RDONLY, 0644); + if (zero_fd < 0) + goto fail2; +# endif auxmap = (void *) mmap ((void *) 0, memneed, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + map_flags | MAP_PRIVATE, zero_fd, 0); +# if !HAVE_MAP_ANONYMOUS + close (zero_fd); +# endif if (auxmap == (void *) -1) goto fail2; auxmap_start = (unsigned long) auxmap; @@ -502,6 +517,13 @@ vma_iterate (vma_iterate_callback_fn callback, void *data) int fd; int nmaps; size_t memneed; +# if HAVE_MAP_ANONYMOUS +# define zero_fd -1 +# define map_flags MAP_ANONYMOUS +# else /* Solaris <= 7 */ + int zero_fd; +# define map_flags 0 +# endif void *auxmap; unsigned long auxmap_start; unsigned long auxmap_end; @@ -541,8 +563,16 @@ vma_iterate (vma_iterate_callback_fn callback, void *data) and thus pre-allocate available memory. So use mmap(), and ignore the resulting VMA. */ memneed = ((memneed - 1) / pagesize + 1) * pagesize; +# if !HAVE_MAP_ANONYMOUS + zero_fd = open ("/dev/zero", O_RDONLY, 0644); + if (zero_fd < 0) + goto fail2; +# endif auxmap = (void *) mmap ((void *) 0, memneed, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + map_flags | MAP_PRIVATE, zero_fd, 0); +# if !HAVE_MAP_ANONYMOUS + close (zero_fd); +# endif if (auxmap == (void *) -1) goto fail2; auxmap_start = (unsigned long) auxmap; |