]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/getpagesize.2
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man2 / getpagesize.2
CommitLineData
fea681da
MK
1.\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>
2.\"
5fbde956 3.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da 4.\"
45186a5d 5.TH GETPAGESIZE 2 2021-03-22 "Linux man-pages (unreleased)"
fea681da
MK
6.SH NAME
7getpagesize \- get memory page size
c18bf8b2
AC
8.SH LIBRARY
9Standard C library
8fc3b2cf 10.RI ( libc ", " \-lc )
fea681da 11.SH SYNOPSIS
4653ec6e 12.nf
fea681da 13.B #include <unistd.h>
68e4db0a 14.PP
fea681da 15.B int getpagesize(void);
4653ec6e 16.fi
68e4db0a 17.PP
d39ad78f 18.RS -4
cc4615cc
MK
19Feature Test Macro Requirements for glibc (see
20.BR feature_test_macros (7)):
d39ad78f 21.RE
68e4db0a 22.PP
cc4615cc 23.BR getpagesize ():
c8fab0f0 24.nf
3754620f 25 Since glibc 2.20:
9e8a25d7 26 _DEFAULT_SOURCE || ! (_POSIX_C_SOURCE >= 200112L)
3754620f 27 Glibc 2.12 to 2.19:
9e8a25d7
MK
28 _BSD_SOURCE || ! (_POSIX_C_SOURCE >= 200112L)
29 Before glibc 2.12:
5c10d2c5
MK
30 _BSD_SOURCE || _XOPEN_SOURCE >= 500
31.\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
c8fab0f0 32.fi
fea681da
MK
33.SH DESCRIPTION
34The function
63aa9df0 35.BR getpagesize ()
e13cd31c
MK
36returns the number of bytes in a memory page,
37where "page" is a fixed-length block,
38the unit for memory allocation and file mapping performed by
39.BR mmap (2).
889829be
MK
40.\" .SH HISTORY
41.\" This call first appeared in 4.2BSD.
3113c7f3 42.SH STANDARDS
fea681da
MK
43SVr4, 4.4BSD, SUSv2.
44In SUSv2 the
63aa9df0 45.BR getpagesize ()
97c1eac8 46call is labeled LEGACY, and in POSIX.1-2001
9ec86f29 47it has been dropped;
97c1eac8 48HP-UX does not have this call.
e13cd31c 49.SH NOTES
c13182ef 50Portable applications should employ
9ec86f29 51.I sysconf(_SC_PAGESIZE)
e13cd31c
MK
52instead of
53.BR getpagesize ():
54.PP
55.in +4n
04fd9d70 56.EX
e13cd31c
MK
57#include <unistd.h>
58long sz = sysconf(_SC_PAGESIZE);
04fd9d70 59.EE
e13cd31c 60.in
efeece04 61.PP
e13cd31c
MK
62(Most systems allow the synonym
63.B _SC_PAGE_SIZE
64for
65.BR _SC_PAGESIZE .)
efeece04 66.PP
fea681da 67Whether
63aa9df0 68.BR getpagesize ()
fea681da 69is present as a Linux system call depends on the architecture.
4bd8c614
MK
70If it is, it returns the kernel symbol
71.BR PAGE_SIZE ,
0b4deed8
MK
72whose value depends on the architecture and machine model.
73Generally, one uses binaries that are dependent on the architecture but not
74on the machine model, in order to have a single binary
c13182ef
MK
75distribution per architecture.
76This means that a user program
4bd8c614
MK
77should not find
78.B PAGE_SIZE
79at compile time from a header file,
fea681da
MK
80but use an actual system call, at least for those architectures
81(like sun4) where this dependency exists.
ed86e39a 82Here glibc 2.0 fails because its
63aa9df0 83.BR getpagesize ()
fea681da
MK
84returns a statically derived value, and does not use a system call.
85Things are OK in glibc 2.1.
47297adb 86.SH SEE ALSO
fea681da
MK
87.BR mmap (2),
88.BR sysconf (3)