+2017-03-10 Bruno Haible <bruno@clisp.org>
+
+ vma-iter: Let callers know about error.
+ * lib/vma-iter.h (vma_iterate): Return 'int', not 'void'.
+ * lib/vma-iter.c (vma_iterate): Return -1 in case of error.
+
2017-03-05 Bruno Haible <bruno@clisp.org>
Fix value of LD for 64-bit compilers on AIX.
#endif
-void
+int
vma_iterate (vma_iterate_callback_fn callback, void *data)
{
#if defined __linux__ /* || defined __CYGWIN__ */
/* Open the current process' maps file. It describes one VMA per line. */
if (rof_open (&rof, "/proc/self/maps") < 0)
- return;
+ return -1;
for (;;)
{
break;
}
rof_close (&rof);
+ return 0;
#elif defined __FreeBSD__ || defined __NetBSD__
/* Open the current process' maps file. It describes one VMA per line. */
if (rof_open (&rof, "/proc/curproc/map") < 0)
- return;
+ return -1;
for (;;)
{
break;
}
rof_close (&rof);
+ return 0;
#elif defined __sgi || defined __osf__ /* IRIX, OSF/1 */
fd = open (fname, O_RDONLY);
if (fd < 0)
- return;
+ return -1;
if (ioctl (fd, PIOCNMAP, &nmaps) < 0)
goto fail2;
}
munmap (auxmap, memneed);
close (fd);
- return;
+ return 0;
fail1:
munmap (auxmap, memneed);
fail2:
close (fd);
- return;
+ return -1;
#elif defined __APPLE__ && defined __MACH__ /* Mac OS X */
if (callback (data, address, address + size, flags))
break;
}
+ return 0;
#elif (defined _WIN32 || defined __WIN32__) || defined __CYGWIN__
/* Windows platform. Use the native Windows API. */
}
address = (uintptr_t)info.BaseAddress + info.RegionSize;
}
+ return 0;
#elif defined __BEOS__ || defined __HAIKU__
/* Use the BeOS specific API. */
if (callback (data, start, end, flags))
break;
}
+ return 0;
#elif HAVE_MQUERY /* OpenBSD */
if (address + pagesize - 1 < pagesize) /* wrap around? */
break;
}
+ return 0;
+
+#else
+
+ /* Not implemented. */
+ return -1;
#endif
}
- FLAGS is a combination of the VMA_* bits.
If the callback returns 0, the iteration continues. If it returns 1,
the iteration terminates prematurely.
- This function may open file descriptors, but does not call malloc(). */
-extern void vma_iterate (vma_iterate_callback_fn callback, void *data);
+ This function may open file descriptors, but does not call malloc().
+ Return 0 if all went well, or -1 in case of error. */
+extern int vma_iterate (vma_iterate_callback_fn callback, void *data);
/* The macro VMA_ITERATE_SUPPORTED indicates that vma_iterate is supported on
this platform.