]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/getpagesize.2
man*/: srcfix (Use .P instead of .PP or .LP)
[thirdparty/man-pages.git] / man2 / getpagesize.2
1 .\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .TH getpagesize 2 (date) "Linux man-pages (unreleased)"
6 .SH NAME
7 getpagesize \- get memory page size
8 .SH LIBRARY
9 Standard C library
10 .RI ( libc ", " \-lc )
11 .SH SYNOPSIS
12 .nf
13 .B #include <unistd.h>
14 .P
15 .B int getpagesize(void);
16 .fi
17 .P
18 .RS -4
19 Feature Test Macro Requirements for glibc (see
20 .BR feature_test_macros (7)):
21 .RE
22 .P
23 .BR getpagesize ():
24 .nf
25 Since glibc 2.20:
26 _DEFAULT_SOURCE || ! (_POSIX_C_SOURCE >= 200112L)
27 glibc 2.12 to glibc 2.19:
28 _BSD_SOURCE || ! (_POSIX_C_SOURCE >= 200112L)
29 Before glibc 2.12:
30 _BSD_SOURCE || _XOPEN_SOURCE >= 500
31 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
32 .fi
33 .SH DESCRIPTION
34 The function
35 .BR getpagesize ()
36 returns the number of bytes in a memory page,
37 where "page" is a fixed-length block,
38 the unit for memory allocation and file mapping performed by
39 .BR mmap (2).
40 .SH STANDARDS
41 None.
42 .SH HISTORY
43 This call first appeared in 4.2BSD.
44 SVr4, 4.4BSD, SUSv2.
45 In SUSv2 the
46 .BR getpagesize ()
47 call is labeled LEGACY, and in POSIX.1-2001
48 it has been dropped;
49 HP-UX does not have this call.
50 .SH NOTES
51 Portable applications should employ
52 .I sysconf(_SC_PAGESIZE)
53 instead of
54 .BR getpagesize ():
55 .P
56 .in +4n
57 .EX
58 #include <unistd.h>
59 long sz = sysconf(_SC_PAGESIZE);
60 .EE
61 .in
62 .P
63 (Most systems allow the synonym
64 .B _SC_PAGE_SIZE
65 for
66 .BR _SC_PAGESIZE .)
67 .P
68 Whether
69 .BR getpagesize ()
70 is present as a Linux system call depends on the architecture.
71 If it is, it returns the kernel symbol
72 .BR PAGE_SIZE ,
73 whose value depends on the architecture and machine model.
74 Generally, one uses binaries that are dependent on the architecture but not
75 on the machine model, in order to have a single binary
76 distribution per architecture.
77 This means that a user program
78 should not find
79 .B PAGE_SIZE
80 at compile time from a header file,
81 but use an actual system call, at least for those architectures
82 (like sun4) where this dependency exists.
83 Here glibc 2.0 fails because its
84 .BR getpagesize ()
85 returns a statically derived value, and does not use a system call.
86 Things are OK in glibc 2.1.
87 .SH SEE ALSO
88 .BR mmap (2),
89 .BR sysconf (3)