Blame gl/tests/vma-iter.h

Packit Service 4684c1
/* Iteration over virtual memory areas.
Packit Service 4684c1
   Copyright (C) 2011-2020 Free Software Foundation, Inc.
Packit Service 4684c1
   Written by Bruno Haible <bruno@clisp.org>, 2011.
Packit Service 4684c1
Packit Service 4684c1
   This program is free software: you can redistribute it and/or modify
Packit Service 4684c1
   it under the terms of the GNU General Public License as published by
Packit Service 4684c1
   the Free Software Foundation; either version 3 of the License, or
Packit Service 4684c1
   (at your option) any later version.
Packit Service 4684c1
Packit Service 4684c1
   This program is distributed in the hope that it will be useful,
Packit Service 4684c1
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 4684c1
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 4684c1
   GNU General Public License for more details.
Packit Service 4684c1
Packit Service 4684c1
   You should have received a copy of the GNU General Public License
Packit Service 4684c1
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit Service 4684c1
Packit Service 4684c1
#ifndef _VMA_ITER_H
Packit Service 4684c1
#define _VMA_ITER_H
Packit Service 4684c1
Packit Service 4684c1
#include <stdint.h>
Packit Service 4684c1
Packit Service 4684c1
#ifdef __cplusplus
Packit Service 4684c1
extern "C" {
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* Bit mask for the FLAGS parameter of a vma_iterate callback function.  */
Packit Service 4684c1
#define VMA_PROT_READ    (1<<0)
Packit Service 4684c1
#define VMA_PROT_WRITE   (1<<1)
Packit Service 4684c1
#define VMA_PROT_EXECUTE (1<<2)
Packit Service 4684c1
Packit Service 4684c1
typedef int (*vma_iterate_callback_fn) (void *data,
Packit Service 4684c1
                                        uintptr_t start, uintptr_t end,
Packit Service 4684c1
                                        unsigned int flags);
Packit Service 4684c1
Packit Service 4684c1
/* Iterate over the virtual memory areas of the current process.
Packit Service 4684c1
   If such iteration is supported, the callback is called once for every
Packit Service 4684c1
   virtual memory area, in ascending order, with the following arguments:
Packit Service 4684c1
     - DATA is the same argument as passed to vma_iterate.
Packit Service 4684c1
     - START is the address of the first byte in the area, page-aligned.
Packit Service 4684c1
     - END is the address of the last byte in the area plus 1, page-aligned.
Packit Service 4684c1
       Note that it may be 0 for the last area in the address space.
Packit Service 4684c1
     - FLAGS is a combination of the VMA_* bits.
Packit Service 4684c1
   If the callback returns 0, the iteration continues.  If it returns 1,
Packit Service 4684c1
   the iteration terminates prematurely.
Packit Service 4684c1
   This function may open file descriptors, but does not call malloc().
Packit Service 4684c1
   Return 0 if all went well, or -1 in case of error.  */
Packit Service 4684c1
extern int vma_iterate (vma_iterate_callback_fn callback, void *data);
Packit Service 4684c1
Packit Service 4684c1
/* The macro VMA_ITERATE_SUPPORTED indicates that vma_iterate is supported on
Packit Service 4684c1
   this platform.
Packit Service 4684c1
   Note that even when this macro is defined, vma_iterate() may still fail to
Packit Service 4684c1
   find any virtual memory area, for example if /proc is not mounted.  */
Packit Service 4684c1
#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
Packit Service 4684c1
# define VMA_ITERATE_SUPPORTED 1
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
#ifdef __cplusplus
Packit Service 4684c1
}
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#endif /* _VMA_ITER_H */