getpagesize(2)
๐ getpagesize โ bestie, what even IS a page ๐
okay so this is getpagesize(2) from the System Calls Manual, section 2, and honestly? it's a tiny little function with a lot of lore. let's get into it ๐ซถ
โจ NAME โจ
getpagesize โ get memory page size
basically: it tells you how big a memory page is. that's it. that's the whole job. queen behavior honestly ๐
๐ LIBRARY ๐
Standard C library (libc, -lc)
so you're linking against the classic. nothing exotic. ๐
๐ธ SYNOPSIS ๐ธ
#include <unistd.h>
int getpagesize(void);
no arguments, returns an int. she takes nothing and gives everything ๐
๐ Feature Test Macro Requirements for glibc ๐
(see feature_test_macros(7) for the full tea โ)
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
likeโฆ the macros changed over the years, that's just how glibc girlies are ๐ don't @ me, check which version you're on.
๐ฆ DESCRIPTION ๐ฆ
so getpagesize() returns the number of bytes in a memory page. and what's a "page", you ask? it's a fixed-length block โ the unit used for memory allocation and for file mapping done by mmap(2). ๐บ๏ธ
that's the whole vibe. pages are the little bricks, and this function tells you how big the bricks are.
๐ VERSIONS ๐
okay this part is important, bestie, pay attention:
a user program should not hard-code a page size. not as a literal, and not using the PAGE_SIZE macro. why? because some architectures support multiple page sizes. ๐จ
like imagine hardcoding a number and then running on a machine where that's just wrong. embarrassing. don't do it. ๐
and here's a fun fact about why this page lives in section 2 instead of section 3: Alpha, SPARC, and SPARC64 all have an actual Linux system call getpagesize(). the other architectures do not โ they use the ELF auxiliary vector instead. so it counts as a system call page. iykyk โจ
๐ STANDARDS ๐
None.
that's it. no standards. nothing. she's free. she's ungoverned. iconic ๐ฅ
๐ HISTORY ๐
4.2BSD,SVr4,SUSv1.- in
SUSv2thegetpagesize()call was labeled LEGACY, and then it got removed in POSIX.1-2001. rip bestie ๐ญ glibc 2.0returned a constant even on architectures with multiple page sizes. (which, as we discussed above, is a whole problem. not great. ๐)
๐ SEE ALSO ๐
go read those if you wanna know more about pages and how to ask the system things politely ๐
and that's the page, bestie!! this one came from Linux man-pages 6.20, dated 2026-02-08 โ go off, documentation queens ๐โจ mwah ๐ ๐ฆ๐ธ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 2001, Andries Brouwer <aeb@cwi.nl>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms