getpagesize(2)

getpagesize2

Get memory page size

Usage

#include <unistd.h>

int getpagesize(void);

Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

getpagesize():

    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

Library

Standard C library (libc, -lc)

Overview

The function 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 mmap(2).

Versions

A user program should not hard-code a page size, neither as a literal nor using the PAGE_SIZE macro, because some architectures support multiple page sizes.

This manual page is in section 2 because Alpha, SPARC, and SPARC64 all have a Linux system call getpagesize() though other architectures do not, and use the ELF auxiliary vector instead.

Releases

19 releases since Debian 1.1 (Buzz); the text changed 15 times.

  1. 1.1–1.2
  2. 1.3–2.1
  3. 2.2
  4. 3.0
  5. 3.1
  6. 4.0
  7. 5.0
  8. 6.0
  9. 7
  10. 8
  11. 9
  12. 10
  13. 11
  14. 12
  15. 13
  16. Arch

Standards

None.

History

4.2BSD, SVr4, SUSv1. In SUSv2 the getpagesize() call was labeled LEGACY, and it was removed in POSIX.1-2001.

glibc 2.0 returned a constant even on architectures with multiple page sizes.

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.