Improve OpenBSD support: Allow faster VMA determination.
[libsigsegv/ericb.git] / src / stackvma-simple.c
blob3e8003735283c073e020bf8da3a5ab878a114a36
1 /* Determine the virtual memory area of a given address.
2 Copyright (C) 2006 Bruno Haible <bruno@clisp.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 /* This file contains the proximity test function for the simple cases, where
19 the OS has an API for enumerating the mapped ranges of virtual memory. */
21 #if STACK_DIRECTION < 0
23 /* Info about the gap between this VMA and the previous one.
24 addr must be < vma->start. */
25 static int
26 simple_is_near_this (unsigned long addr, struct vma_struct *vma)
28 return (vma->start - addr <= (vma->start - vma->prev_end) / 2);
31 #endif
32 #if STACK_DIRECTION > 0
34 /* Info about the gap between this VMA and the next one.
35 addr must be > vma->end - 1. */
36 static int
37 simple_is_near_this (unsigned long addr, struct vma_struct *vma)
39 return (addr - vma->end < (vma->next_start - vma->end) / 2);
42 #endif