summaryrefslogtreecommitdiffstats
path: root/man/man2/getpagesize.2
blob: 1bfcad3c26d2aa1ef122a362c9ad8cd74fac9350 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
.\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.TH getpagesize 2 2024-05-02 "Linux man-pages (unreleased)"
.SH NAME
getpagesize \- get memory page size
.SH LIBRARY
Standard C library
.RI ( libc ", " \-lc )
.SH SYNOPSIS
.nf
.B #include <unistd.h>
.P
.B int getpagesize(void);
.fi
.P
.RS -4
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.RE
.P
.BR getpagesize ():
.nf
    Since glibc 2.20:
        _DEFAULT_SOURCE || ! (_POSIX_C_SOURCE >= 200112L)
    glibc 2.12 to glibc 2.19:
        _BSD_SOURCE || ! (_POSIX_C_SOURCE >= 200112L)
    Before glibc 2.12:
        _BSD_SOURCE || _XOPEN_SOURCE >= 500
.\"        || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
.fi
.SH DESCRIPTION
The function
.BR getpagesize ()
returns the number of bytes in a memory page,
where "page" is a fixed-length block,
the unit for memory allocation and file mapping performed by
.BR mmap (2).
.SH VERSIONS
A user program should not hard-code a page size,
neither as a literal nor using the
.B PAGE_SIZE
macro,
because some architectures support multiple page sizes.
.P
This manual page is in section 2 because
Alpha, SPARC, and SPARC64
all have a Linux system call
.BR getpagesize ()
though other architectures do not,
and use the ELF auxiliary vector instead.
.SH STANDARDS
None.
.SH HISTORY
This call first appeared in 4.2BSD.
SVr4, 4.4BSD, SUSv2.
In SUSv2 the
.BR getpagesize ()
call was labeled LEGACY,
and it was removed in POSIX.1-2001.
.P
glibc 2.0 returned a constant
even on architectures with multiple page sizes.
.SH SEE ALSO
.BR mmap (2),
.BR sysconf (3)