Mercurial > gnulib
annotate lib/vma-iter.h @ 40149:e1f68c6256cf
vma-iter: Add support for Android.
* lib/vma-iter.h (VMA_ITERATE_SUPPORTED): Define on Android as well.
* lib/vma-iter.c: Treat Android like Linux.
* lib/get-rusage-data.c (get_rusage_data): Likewise.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 27 Jan 2019 04:57:29 +0100 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
14220 | 1 /* Iteration over virtual memory areas. |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19595
diff
changeset
|
2 Copyright (C) 2011-2019 Free Software Foundation, Inc. |
14220 | 3 Written by Bruno Haible <bruno@clisp.org>, 2011. |
4 | |
5 This program is free software: you can redistribute it and/or modify | |
6 it under the terms of the GNU General Public License as published by | |
7 the Free Software Foundation; either version 3 of the License, or | |
8 (at your option) any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
19190 | 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
14220 | 17 |
18 #ifndef _VMA_ITER_H | |
19 #define _VMA_ITER_H | |
20 | |
21 #include <stdint.h> | |
22 | |
23 #ifdef __cplusplus | |
24 extern "C" { | |
25 #endif | |
26 | |
27 | |
28 /* Bit mask for the FLAGS parameter of a vma_iterate callback function. */ | |
29 #define VMA_PROT_READ (1<<0) | |
30 #define VMA_PROT_WRITE (1<<1) | |
31 #define VMA_PROT_EXECUTE (1<<2) | |
32 | |
33 typedef int (*vma_iterate_callback_fn) (void *data, | |
34 uintptr_t start, uintptr_t end, | |
35 unsigned int flags); | |
36 | |
37 /* Iterate over the virtual memory areas of the current process. | |
38 If such iteration is supported, the callback is called once for every | |
39 virtual memory area, in ascending order, with the following arguments: | |
40 - DATA is the same argument as passed to vma_iterate. | |
41 - START is the address of the first byte in the area, page-aligned. | |
42 - END is the address of the last byte in the area plus 1, page-aligned. | |
43 Note that it may be 0 for the last area in the address space. | |
44 - FLAGS is a combination of the VMA_* bits. | |
45 If the callback returns 0, the iteration continues. If it returns 1, | |
46 the iteration terminates prematurely. | |
18727
6e02cce8c632
vma-iter: Let callers know about error.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
47 This function may open file descriptors, but does not call malloc(). |
6e02cce8c632
vma-iter: Let callers know about error.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
48 Return 0 if all went well, or -1 in case of error. */ |
6e02cce8c632
vma-iter: Let callers know about error.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
49 extern int vma_iterate (vma_iterate_callback_fn callback, void *data); |
14220 | 50 |
51 /* The macro VMA_ITERATE_SUPPORTED indicates that vma_iterate is supported on | |
52 this platform. | |
53 Note that even when this macro is defined, vma_iterate() may still fail to | |
54 find any virtual memory area, for example if /proc is not mounted. */ | |
40149
e1f68c6256cf
vma-iter: Add support for Android.
Bruno Haible <bruno@clisp.org>
parents:
40057
diff
changeset
|
55 #if defined __linux__ || defined __ANDROID__ || defined __GNU__ || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ || defined __sgi || defined __osf__ || defined __sun || HAVE_PSTAT_GETPROCVM || (defined __APPLE__ && defined __MACH__) || defined _WIN32 || defined __CYGWIN__ || defined __BEOS__ || defined __HAIKU__ || defined __minix || HAVE_MQUERY |
14220 | 56 # define VMA_ITERATE_SUPPORTED 1 |
57 #endif | |
58 | |
59 | |
60 #ifdef __cplusplus | |
61 } | |
62 #endif | |
63 | |
64 #endif /* _VMA_ITER_H */ |