Tom G. Christensen wrote: > On Solaris 2.6 and 7 there is the additional issue of missing MAP_ANONYMOUS: > > In file included from vma-iter.c:41:0: > /usr/include/sys/procfs.h:44:2: error: #error "Cannot use procfs in the > large file compilation environment" > vma-iter.c: In function 'vma_iterate': > vma-iter.c:545:27: error: 'MAP_ANONYMOUS' undeclared (first use in this > function) > vma-iter.c:545:27: note: each undeclared identifier is reported only > once for each function it appears in > make[4]: *** [vma-iter.o] Error 1
Fixed as follows. Thanks for the report! 2017-04-18 Bruno Haible <[email protected]> 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 <[email protected]>. diff --git a/lib/vma-iter.c b/lib/vma-iter.c index d4bae13..e81b8ea 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;
