man-pages/man2/getpagesize.2.html
2021-03-31 01:06:50 +01:00

169 lines
3.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of GETPAGESIZE</TITLE>
</HEAD><BODY>
<H1>GETPAGESIZE</H1>
Section: Linux Programmer's Manual (2)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
getpagesize - get memory page size
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>#include &lt;<A HREF="file:///usr/include/unistd.h">unistd.h</A>&gt;</B>
<P>
<B>int getpagesize(void);</B>
<P>
Feature Test Macro Requirements for glibc (see
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
<P>
<B>getpagesize</B>():
<DL COMPACT><DT id="1"><DD>
<DL COMPACT>
<DT id="2">Since glibc 2.19:<DD>
<PRE>
_DEFAULT_SOURCE || ! (_POSIX_C_SOURCE&nbsp;&gt;=&nbsp;200112L)
<DT id="3"></PRE>
<DD>
From glibc 2.12 to 2.19:
<PRE>
_BSD_SOURCE || ! (_POSIX_C_SOURCE&nbsp;&gt;=&nbsp;200112L)
<DT id="4"></PRE>
<DD>
Before glibc 2.12:
_BSD_SOURCE || _XOPEN_SOURCE&nbsp;&gt;=&nbsp;500
</DL>
</DL>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
The function
<B>getpagesize</B>()
returns the number of bytes in a memory page,
where &quot;page&quot; is a fixed-length block,
the unit for memory allocation and file mapping performed by
<B><A HREF="/cgi-bin/man/man2html?2+mmap">mmap</A></B>(2).
<A NAME="lbAE">&nbsp;</A>
<H2>CONFORMING TO</H2>
SVr4, 4.4BSD, SUSv2.
In SUSv2 the
<B>getpagesize</B>()
call is labeled LEGACY, and in POSIX.1-2001
it has been dropped;
HP-UX does not have this call.
<A NAME="lbAF">&nbsp;</A>
<H2>NOTES</H2>
Portable applications should employ
<I>sysconf(_SC_PAGESIZE)</I>
instead of
<B>getpagesize</B>():
<P>
#include &lt;<A HREF="file:///usr/include/unistd.h">unistd.h</A>&gt;
long sz = sysconf(_SC_PAGESIZE);
<P>
(Most systems allow the synonym
<B>_SC_PAGE_SIZE</B>
for
<B>_SC_PAGESIZE</B>.)
<P>
Whether
<B>getpagesize</B>()
is present as a Linux system call depends on the architecture.
If it is, it returns the kernel symbol
<B>PAGE_SIZE</B>,
whose value depends on the architecture and machine model.
Generally, one uses binaries that are dependent on the architecture but not
on the machine model, in order to have a single binary
distribution per architecture.
This means that a user program
should not find
<B>PAGE_SIZE</B>
at compile time from a header file,
but use an actual system call, at least for those architectures
(like sun4) where this dependency exists.
Here glibc 2.0 fails because its
<B>getpagesize</B>()
returns a statically derived value, and does not use a system call.
Things are OK in glibc 2.1.
<A NAME="lbAG">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?2+mmap">mmap</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?3+sysconf">sysconf</A></B>(3)
<A NAME="lbAH">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="5"><A HREF="#lbAB">NAME</A><DD>
<DT id="6"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="7"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="8"><A HREF="#lbAE">CONFORMING TO</A><DD>
<DT id="9"><A HREF="#lbAF">NOTES</A><DD>
<DT id="10"><A HREF="#lbAG">SEE ALSO</A><DD>
<DT id="11"><A HREF="#lbAH">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:32 GMT, March 31, 2021
</BODY>
</HTML>