xref: /dflybsd-src/contrib/cvs-1.12/lib/getpagesize.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1*86d7f5d3SJohn Marino /* Emulate getpagesize on systems that lack it.
2*86d7f5d3SJohn Marino    Copyright (C) 1999, 2000, 2004 Free Software Foundation, Inc.
3*86d7f5d3SJohn Marino 
4*86d7f5d3SJohn Marino    This program is free software; you can redistribute it and/or modify
5*86d7f5d3SJohn Marino    it under the terms of the GNU General Public License as published by
6*86d7f5d3SJohn Marino    the Free Software Foundation; either version 2, or (at your option)
7*86d7f5d3SJohn Marino    any later version.
8*86d7f5d3SJohn Marino 
9*86d7f5d3SJohn Marino    This program is distributed in the hope that it will be useful,
10*86d7f5d3SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
11*86d7f5d3SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12*86d7f5d3SJohn Marino    GNU General Public License for more details.
13*86d7f5d3SJohn Marino 
14*86d7f5d3SJohn Marino    You should have received a copy of the GNU General Public License
15*86d7f5d3SJohn Marino    along with this program; if not, write to the Free Software
16*86d7f5d3SJohn Marino    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17*86d7f5d3SJohn Marino    USA.  */
18*86d7f5d3SJohn Marino 
19*86d7f5d3SJohn Marino #ifndef HAVE_GETPAGESIZE
20*86d7f5d3SJohn Marino 
21*86d7f5d3SJohn Marino #ifdef HAVE_UNISTD_H
22*86d7f5d3SJohn Marino # include <unistd.h>
23*86d7f5d3SJohn Marino #endif
24*86d7f5d3SJohn Marino 
25*86d7f5d3SJohn Marino #if !defined getpagesize && defined _SC_PAGESIZE
26*86d7f5d3SJohn Marino # if !(defined VMS && __VMS_VER < 70000000)
27*86d7f5d3SJohn Marino #  define getpagesize() sysconf (_SC_PAGESIZE)
28*86d7f5d3SJohn Marino # endif
29*86d7f5d3SJohn Marino #endif
30*86d7f5d3SJohn Marino 
31*86d7f5d3SJohn Marino #if !defined getpagesize && defined VMS
32*86d7f5d3SJohn Marino # ifdef __ALPHA
33*86d7f5d3SJohn Marino #  define getpagesize() 8192
34*86d7f5d3SJohn Marino # else
35*86d7f5d3SJohn Marino #  define getpagesize() 512
36*86d7f5d3SJohn Marino # endif
37*86d7f5d3SJohn Marino #endif
38*86d7f5d3SJohn Marino 
39*86d7f5d3SJohn Marino /* This is for BeOS.  */
40*86d7f5d3SJohn Marino #if !defined getpagesize && HAVE_OS_H
41*86d7f5d3SJohn Marino # include <OS.h>
42*86d7f5d3SJohn Marino # if defined B_PAGE_SIZE
43*86d7f5d3SJohn Marino #  define getpagesize() B_PAGE_SIZE
44*86d7f5d3SJohn Marino # endif
45*86d7f5d3SJohn Marino #endif
46*86d7f5d3SJohn Marino 
47*86d7f5d3SJohn Marino #if !defined getpagesize && HAVE_SYS_PARAM_H
48*86d7f5d3SJohn Marino # include <sys/param.h>
49*86d7f5d3SJohn Marino # ifdef EXEC_PAGESIZE
50*86d7f5d3SJohn Marino #  define getpagesize() EXEC_PAGESIZE
51*86d7f5d3SJohn Marino # else
52*86d7f5d3SJohn Marino #  ifdef NBPG
53*86d7f5d3SJohn Marino #   ifndef CLSIZE
54*86d7f5d3SJohn Marino #    define CLSIZE 1
55*86d7f5d3SJohn Marino #   endif
56*86d7f5d3SJohn Marino #   define getpagesize() (NBPG * CLSIZE)
57*86d7f5d3SJohn Marino #  else
58*86d7f5d3SJohn Marino #   ifdef NBPC
59*86d7f5d3SJohn Marino #    define getpagesize() NBPC
60*86d7f5d3SJohn Marino #   endif
61*86d7f5d3SJohn Marino #  endif
62*86d7f5d3SJohn Marino # endif
63*86d7f5d3SJohn Marino #endif
64*86d7f5d3SJohn Marino 
65*86d7f5d3SJohn Marino #endif /* not HAVE_GETPAGESIZE */
66