]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl> |
2 | .\" | |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da | 24 | .\" |
97986708 | 25 | .TH GETPAGESIZE 2 2016-03-15 "Linux" "Linux Programmer's Manual" |
fea681da MK |
26 | .SH NAME |
27 | getpagesize \- get memory page size | |
28 | .SH SYNOPSIS | |
29 | .B #include <unistd.h> | |
30 | .sp | |
31 | .B int getpagesize(void); | |
cc4615cc MK |
32 | .sp |
33 | .in -4n | |
34 | Feature Test Macro Requirements for glibc (see | |
35 | .BR feature_test_macros (7)): | |
36 | .in | |
37 | .sp | |
38 | .BR getpagesize (): | |
2df50e3d MK |
39 | .ad l |
40 | .RS 4 | |
41 | .PD 0 | |
42 | .TP 4 | |
c8fab0f0 MK |
43 | Since glibc 2.19: |
44 | .nf | |
45 | _DEFAULT_SOURCE || ! (_POSIX_C_SOURCE\ >=\ 200112L) | |
46 | .TP 4 | |
47 | .fi | |
48 | From glibc 2.12 to 2.19: | |
2df50e3d | 49 | .nf |
a446ac0c | 50 | _BSD_SOURCE || ! (_POSIX_C_SOURCE\ >=\ 200112L) |
2df50e3d MK |
51 | .TP 4 |
52 | .fi | |
53 | Before glibc 2.12: | |
cf7fa0a1 MK |
54 | _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 |
55 | .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED | |
2df50e3d MK |
56 | .PD |
57 | .RE | |
58 | .ad b | |
fea681da MK |
59 | .SH DESCRIPTION |
60 | The function | |
63aa9df0 | 61 | .BR getpagesize () |
e13cd31c MK |
62 | returns the number of bytes in a memory page, |
63 | where "page" is a fixed-length block, | |
64 | the unit for memory allocation and file mapping performed by | |
65 | .BR mmap (2). | |
889829be MK |
66 | .\" .SH HISTORY |
67 | .\" This call first appeared in 4.2BSD. | |
fea681da MK |
68 | .SH CONFORMING TO |
69 | SVr4, 4.4BSD, SUSv2. | |
70 | In SUSv2 the | |
63aa9df0 | 71 | .BR getpagesize () |
97c1eac8 | 72 | call is labeled LEGACY, and in POSIX.1-2001 |
9ec86f29 | 73 | it has been dropped; |
97c1eac8 | 74 | HP-UX does not have this call. |
e13cd31c | 75 | .SH NOTES |
c13182ef | 76 | Portable applications should employ |
9ec86f29 | 77 | .I sysconf(_SC_PAGESIZE) |
e13cd31c MK |
78 | instead of |
79 | .BR getpagesize (): | |
80 | .PP | |
81 | .in +4n | |
82 | .nf | |
83 | #include <unistd.h> | |
84 | long sz = sysconf(_SC_PAGESIZE); | |
85 | .fi | |
86 | .in | |
87 | ||
88 | (Most systems allow the synonym | |
89 | .B _SC_PAGE_SIZE | |
90 | for | |
91 | .BR _SC_PAGESIZE .) | |
92 | ||
fea681da | 93 | Whether |
63aa9df0 | 94 | .BR getpagesize () |
fea681da | 95 | is present as a Linux system call depends on the architecture. |
4bd8c614 MK |
96 | If it is, it returns the kernel symbol |
97 | .BR PAGE_SIZE , | |
0b4deed8 MK |
98 | whose value depends on the architecture and machine model. |
99 | Generally, one uses binaries that are dependent on the architecture but not | |
100 | on the machine model, in order to have a single binary | |
c13182ef MK |
101 | distribution per architecture. |
102 | This means that a user program | |
4bd8c614 MK |
103 | should not find |
104 | .B PAGE_SIZE | |
105 | at compile time from a header file, | |
fea681da MK |
106 | but use an actual system call, at least for those architectures |
107 | (like sun4) where this dependency exists. | |
ed86e39a | 108 | Here glibc 2.0 fails because its |
63aa9df0 | 109 | .BR getpagesize () |
fea681da MK |
110 | returns a statically derived value, and does not use a system call. |
111 | Things are OK in glibc 2.1. | |
47297adb | 112 | .SH SEE ALSO |
fea681da MK |
113 | .BR mmap (2), |
114 | .BR sysconf (3) |