+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.
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;
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;
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;
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;