1getpagesize(2)                System Calls Manual               getpagesize(2)
2
3
4

NAME

6       getpagesize - get memory page size
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <unistd.h>
13
14       int getpagesize(void);
15
16   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
17
18       getpagesize():
19           Since glibc 2.20:
20               _DEFAULT_SOURCE || ! (_POSIX_C_SOURCE >= 200112L)
21           glibc 2.12 to glibc 2.19:
22               _BSD_SOURCE || ! (_POSIX_C_SOURCE >= 200112L)
23           Before glibc 2.12:
24               _BSD_SOURCE || _XOPEN_SOURCE >= 500
25

DESCRIPTION

27       The  function  getpagesize()  returns  the  number of bytes in a memory
28       page, where "page" is a fixed-length block, the unit for memory alloca‐
29       tion and file mapping performed by mmap(2).
30

STANDARDS

32       None.
33

HISTORY

35       This call first appeared in 4.2BSD.  SVr4, 4.4BSD, SUSv2.  In SUSv2 the
36       getpagesize() call is labeled LEGACY, and in POSIX.1-2001 it  has  been
37       dropped; HP-UX does not have this call.
38

NOTES

40       Portable  applications  should  employ sysconf(_SC_PAGESIZE) instead of
41       getpagesize():
42
43           #include <unistd.h>
44           long sz = sysconf(_SC_PAGESIZE);
45
46       (Most systems allow the synonym _SC_PAGE_SIZE for _SC_PAGESIZE.)
47
48       Whether getpagesize() is present as a Linux system call depends on  the
49       architecture.   If it is, it returns the kernel symbol PAGE_SIZE, whose
50       value depends on the architecture and machine  model.   Generally,  one
51       uses binaries that are dependent on the architecture but not on the ma‐
52       chine model, in order to have a single binary distribution  per  archi‐
53       tecture.   This  means that a user program should not find PAGE_SIZE at
54       compile time from a header file, but use  an  actual  system  call,  at
55       least for those architectures (like sun4) where this dependency exists.
56       Here glibc 2.0 fails because its getpagesize() returns a statically de‐
57       rived  value,  and  does not use a system call.  Things are OK in glibc
58       2.1.
59

SEE ALSO

61       mmap(2), sysconf(3)
62
63
64
65Linux man-pages 6.04              2023-03-30                    getpagesize(2)
Impressum