diff options
author | Bruno Haible <bruno@clisp.org> | 2017-03-15 22:07:56 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2017-03-15 22:08:43 +0100 |
commit | c1a21de2148bbc6cb3401e82ae1b75f0be077200 (patch) | |
tree | 3f942514272a515c63944ed3ed3b4ababfdcac1c /lib/vma-iter.c | |
parent | 4029e27f231b01e97064f3f5d4e9c90a727e4de0 (diff) | |
download | gnulib-c1a21de2148bbc6cb3401e82ae1b75f0be077200.tar.gz |
vma-iter: Add support for HP-UX.
* modules/vma-iter (configure.ac): Check for 'pstat_getprocvm'.
* lib/vma-iter.c (vma_iterate): On HP-UX, use pstat_getprocvm().
* lib/vma-iter.h (VMA_ITERATE_SUPPORTED): Define also on HP-UX.
* lib/get-rusage-as.c: Update comment about HP-UX.
* lib/get-rusage-data.c: Likewise.
(get_rusage_data): Use get_rusage_data_via_setrlimit.
Diffstat (limited to 'lib/vma-iter.c')
-rw-r--r-- | lib/vma-iter.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/vma-iter.c b/lib/vma-iter.c index 07244d3ff5..b9036ae4e6 100644 --- a/lib/vma-iter.c +++ b/lib/vma-iter.c @@ -49,6 +49,10 @@ # include <sys/mman.h> /* mquery */ #endif +#if HAVE_PSTAT_GETPROCVM /* HP-UX */ +# include <sys/pstat.h> /* pstat_getprocvm */ +#endif + /* Note: On AIX, there is a /proc/$pic/map file, that contains records of type prmap_t, defined in <sys/procfs.h>. But it lists only the virtual memory areas that are connected to a file, not the anonymous ones. */ @@ -598,6 +602,35 @@ vma_iterate (vma_iterate_callback_fn callback, void *data) } return 0; +#elif HAVE_PSTAT_GETPROCVM /* HP-UX */ + + unsigned long pagesize = getpagesize (); + int i; + + for (i = 0; ; i++) + { + struct pst_vm_status info; + int ret = pstat_getprocvm (&info, sizeof (info), 0, i); + if (ret < 0) + return -1; + if (ret == 0) + break; + { + unsigned long start = info.pst_vaddr; + unsigned long end = start + info.pst_length * pagesize; + unsigned int flags = 0; + if (info.pst_permission & PS_PROT_READ) + flags |= VMA_PROT_READ; + if (info.pst_permission & PS_PROT_WRITE) + flags |= VMA_PROT_WRITE; + if (info.pst_permission & PS_PROT_EXECUTE) + flags |= VMA_PROT_EXECUTE; + + if (callback (data, start, end, flags)) + break; + } + } + #else /* Not implemented. */ |