root/maint/gnulib/lib/vma-iter.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /* Iteration over virtual memory areas.
   2    Copyright (C) 2011-2021 Free Software Foundation, Inc.
   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
  16    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
  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.
  47    This function may open file descriptors, but does not call malloc().
  48    Return 0 if all went well, or -1 in case of error.  */
  49 extern int vma_iterate (vma_iterate_callback_fn callback, void *data);
  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.  */
  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
  56 # define VMA_ITERATE_SUPPORTED 1
  57 #endif
  58 
  59 
  60 #ifdef __cplusplus
  61 }
  62 #endif
  63 
  64 #endif /* _VMA_ITER_H */

/* [previous][next][first][last][top][bottom][index][help] */