Improve NetBSD support: Allow VMA determination with fewer system calls.
[libsigsegv/ericb.git] / m4 / getpagesize.m4
blob3dcf7ebbf2ec64fa0021a0d5b3c71927a98e594e
1 # getpagesize.m4 serial 3 (libsigsegv-2.9)
2 dnl Copyright (C) 2002-2003, 2010 Bruno Haible <bruno@clisp.org>
3 dnl This file is free software, distributed under the terms of the GNU
4 dnl General Public License.  As a special exception to the GNU General
5 dnl Public License, this file may be distributed as part of a program
6 dnl that contains a configuration script generated by Autoconf, under
7 dnl the same distribution terms as the rest of that program.
9 # How to determine the memory page size.
10 AC_DEFUN([SV_GETPAGESIZE],
12   AC_REQUIRE([AC_PROG_CC])
14   AC_CHECK_HEADERS([unistd.h])
16   dnl 1) getpagesize().
18   AC_CACHE_CHECK([for getpagesize], [sv_cv_func_getpagesize], [
19     AC_LINK_IFELSE([
20       AC_LANG_PROGRAM([[
21 #if HAVE_UNISTD_H
22 #include <sys/types.h>
23 #include <unistd.h>
24 #endif
25 ]],
26         [[int pgsz = getpagesize();]])],
27       [sv_cv_func_getpagesize=yes],
28       [sv_cv_func_getpagesize=no])])
29   if test $sv_cv_func_getpagesize = yes; then
30     AC_DEFINE([HAVE_GETPAGESIZE], [1],
31       [Define if getpagesize() is available as a function or a macro.])
32   fi
34   dnl 2) sysconf(_SC_PAGESIZE).
36   AC_CACHE_CHECK([for sysconf(_SC_PAGESIZE)], [sv_cv_func_sysconf_pagesize], [
37     AC_LINK_IFELSE([
38       AC_LANG_PROGRAM([[
39 #if HAVE_UNISTD_H
40 #include <sys/types.h>
41 #include <unistd.h>
42 #endif
43 ]],
44         [[int pgsz = sysconf (_SC_PAGESIZE);]])],
45       [sv_cv_func_sysconf_pagesize=yes],
46       [sv_cv_func_sysconf_pagesize=no])])
47   if test $sv_cv_func_sysconf_pagesize = yes; then
48     AC_DEFINE([HAVE_SYSCONF_PAGESIZE], [1],
49       [Define if sysconf(_SC_PAGESIZE) is available as a function or a macro.])
50   fi
52   dnl 3) PAGESIZE.
54   AC_CACHE_CHECK([for PAGESIZE in limits.h], [sv_cv_macro_pagesize], [
55     AC_LINK_IFELSE([
56       AC_LANG_PROGRAM([[#include <limits.h>]],
57         [[int pgsz = PAGESIZE;]])],
58       [sv_cv_macro_pagesize=yes],
59       [sv_cv_macro_pagesize=no])])
60   if test $sv_cv_macro_pagesize = yes; then
61     AC_DEFINE([HAVE_PAGESIZE], [1],
62       [Define if PAGESIZE is available as a macro.])
63   fi
65   dnl 4) On BeOS, you need to include <OS.h> and use B_PAGE_SIZE.