getpagesize(2) — Linux manual page

NAME | LIBRARY | SYNOPSIS | DESCRIPTION | VERSIONS | STANDARDS | HISTORY | SEE ALSO | COLOPHON

getpagesize(2)             System Calls Manual            getpagesize(2)

NAME         top

       getpagesize - get memory page size

LIBRARY         top

       Standard C library (libc, -lc)

SYNOPSIS         top

       #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

DESCRIPTION         top

       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         top

       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.

STANDARDS         top

       None.

HISTORY         top

       This call first appeared in 4.2BSD.  SVr4, 4.4BSD, SUSv2.  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.

SEE ALSO         top

       mmap(2), sysconf(3)

COLOPHON         top

       This page is part of the man-pages (Linux kernel and C library
       user-space interface documentation) project.  Information about
       the project can be found at 
       ⟨https://www.kernel.org/doc/man-pages/⟩.  If you have a bug report
       for this manual page, see
       ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩.
       This page was obtained from the tarball man-pages-6.9.1.tar.gz
       fetched from
       ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on
       2024-06-26.  If you discover any rendering problems in this HTML
       version of the page, or you believe there is a better or more up-
       to-date source for the page, or you have corrections or
       improvements to the information in this COLOPHON (which is not
       part of the original manual page), send a mail to
       [email protected]

Linux man-pages 6.9.1          2024-05-02                 getpagesize(2)

Pages that refer to this page: fincore(1)strace(1)mmap2(2)mmap(2)mremap(2)remap_file_pages(2)syscalls(2)numa(3)posix_memalign(3)