exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / stackvma.h
blob3b92a2d235b54b9f3aa004d55d7931a21b4b3f98
1 /* Determine the virtual memory area of a given address.
2 Copyright (C) 2002-2024 Free Software Foundation, Inc.
3 Copyright (C) 2003-2006 Paolo Bonzini <bonzini@gnu.org>
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 2 of the License, or
8 (at your option) any later version.
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.
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/>. */
18 /* Written by Bruno Haible and Paolo Bonzini. */
20 #ifndef _STACKVMA_H
21 #define _STACKVMA_H
23 #include <stdint.h>
25 /* Describes a virtual memory area, with some info about the gap between
26 it and the next or previous virtual memory area. */
27 struct vma_struct
29 uintptr_t start;
30 uintptr_t end;
31 #if STACK_DIRECTION < 0
32 /* Info about the gap between this VMA and the previous one.
33 addr must be < vma->start. */
34 int (*is_near_this) (uintptr_t addr, struct vma_struct *vma);
35 /* Private field, not provided by all sigsegv_get_vma implementations. */
36 uintptr_t prev_end;
37 #endif
38 #if STACK_DIRECTION > 0
39 /* Info about the gap between this VMA and the next one.
40 addr must be > vma->end - 1. */
41 int (*is_near_this) (uintptr_t addr, struct vma_struct *vma);
42 /* Private field, not provided by all sigsegv_get_vma implementations. */
43 uintptr_t next_start;
44 #endif
47 /* Determines the virtual memory area to which a given address belongs,
48 and returns 0. Returns -1 if it cannot be determined.
49 This function is used to determine the stack extent when a fault occurs. */
50 extern int sigsegv_get_vma (uintptr_t address, struct vma_struct *vma);
52 /* Defined if sigsegv_get_vma actually works (i.e. does not always fail). */
53 #if defined __linux__ || defined __ANDROID__ \
54 || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ \
55 || defined __NetBSD__ || defined __OpenBSD__ \
56 || (defined __APPLE__ && defined __MACH__) \
57 || defined _AIX || defined __sgi || defined __sun \
58 || defined __CYGWIN__ || defined __HAIKU__
59 # define HAVE_STACKVMA 1
60 #endif
62 #endif /* _STACKVMA_H */