1GETPAGESIZE(2) Linux Programmer's Manual GETPAGESIZE(2)
2
3
4
6 getpagesize - get memory page size
7
9 #include <unistd.h>
10
11 int getpagesize(void);
12
14 The function getpagesize() returns the number of bytes in a page, where
15 a "page" is the thing used where it says in the description of mmap(2)
16 that files are mapped in page-sized units.
17
18 The size of the kind of pages that mmap() uses, is found using
19
20 #include <unistd.h>
21 long sz = sysconf(_SC_PAGESIZE);
22
23 (most systems allow the synonym _SC_PAGE_SIZE for _SC_PAGESIZE), or
24
25 #include <unistd.h>
26 int sz = getpagesize();
27
29 This call first appeared in 4.2BSD.
30
32 SVr4, 4.4BSD, SUSv2. In SUSv2 the getpagesize() call is labeled
33 LEGACY, and in POSIX.1-2001 it has been dropped; HP-UX does not have
34 this call. Portable applications should employ sysconf(_SC_PAGESIZE)
35 instead of this call.
36
38 Whether getpagesize() is present as a Linux system call depends on the
39 architecture. If it is, it returns the kernel symbol PAGE_SIZE, which
40 is architecture and machine model dependent. Generally, one uses bina‐
41 ries that are architecture but not machine model dependent, in order to
42 have a single binary distribution per architecture. This means that a
43 user program should not find PAGE_SIZE at compile time from a header
44 file, but use an actual system call, at least for those architectures
45 (like sun4) where this dependency exists. Here libc4, libc5, glibc 2.0
46 fail because their getpagesize() returns a statically derived value,
47 and does not use a system call. Things are OK in glibc 2.1.
48
50 mmap(2), sysconf(3)
51
52
53
54Linux 2.5.0 2001-12-21 GETPAGESIZE(2)