Bump to m4 1.4.19
[platform/upstream/m4.git] / lib / stackvma.h
1 /* Determine the virtual memory area of a given address.
2    Copyright (C) 2002-2021  Bruno Haible <bruno@clisp.org>
3    Copyright (C) 2003-2006  Paolo Bonzini <bonzini@gnu.org>
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 _STACKVMA_H
19 #define _STACKVMA_H
20
21 #include <stdint.h>
22
23 /* Describes a virtual memory area, with some info about the gap between
24    it and the next or previous virtual memory area.  */
25 struct vma_struct
26 {
27   uintptr_t start;
28   uintptr_t end;
29 #if STACK_DIRECTION < 0
30   /* Info about the gap between this VMA and the previous one.
31      addr must be < vma->start.  */
32   int (*is_near_this) (uintptr_t addr, struct vma_struct *vma);
33   /* Private field, not provided by all sigsegv_get_vma implementations.  */
34   uintptr_t prev_end;
35 #endif
36 #if STACK_DIRECTION > 0
37   /* Info about the gap between this VMA and the next one.
38      addr must be > vma->end - 1.  */
39   int (*is_near_this) (uintptr_t addr, struct vma_struct *vma);
40   /* Private field, not provided by all sigsegv_get_vma implementations.  */
41   uintptr_t next_start;
42 #endif
43 };
44
45 /* Determines the virtual memory area to which a given address belongs,
46    and returns 0.  Returns -1 if it cannot be determined.
47    This function is used to determine the stack extent when a fault occurs.  */
48 extern int sigsegv_get_vma (uintptr_t address, struct vma_struct *vma);
49
50 /* Defined if sigsegv_get_vma actually works (i.e. does not always fail).  */
51 #if defined __linux__ || defined __ANDROID__ \
52     || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __DragonFly__ \
53     || defined __NetBSD__ || defined __OpenBSD__ \
54     || (defined __APPLE__ && defined __MACH__) \
55     || defined _AIX || defined __sgi || defined __sun \
56     || defined __CYGWIN__ || defined __HAIKU__
57 # define HAVE_STACKVMA 1
58 #endif
59
60 #endif /* _STACKVMA_H */