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