tzfile.5, tzselect.8: sync from tzdb upstream
[man-pages.git] / man2 / getpagesize.2
blob39af55619be47952a43d955a46b558d7b40f5d8d
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 .PP
15 .B int getpagesize(void);
16 .fi
17 .PP
18 .RS -4
19 Feature Test Macro Requirements for glibc (see
20 .BR feature_test_macros (7)):
21 .RE
22 .PP
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 HISTORY
41 .\" This call first appeared in 4.2BSD.
42 .SH STANDARDS
43 SVr4, 4.4BSD, SUSv2.
44 In SUSv2 the
45 .BR getpagesize ()
46 call is labeled LEGACY, and in POSIX.1-2001
47 it has been dropped;
48 HP-UX does not have this call.
49 .SH NOTES
50 Portable applications should employ
51 .I sysconf(_SC_PAGESIZE)
52 instead of
53 .BR getpagesize ():
54 .PP
55 .in +4n
56 .EX
57 #include <unistd.h>
58 long sz = sysconf(_SC_PAGESIZE);
59 .EE
60 .in
61 .PP
62 (Most systems allow the synonym
63 .B _SC_PAGE_SIZE
64 for
65 .BR _SC_PAGESIZE .)
66 .PP
67 Whether
68 .BR getpagesize ()
69 is present as a Linux system call depends on the architecture.
70 If it is, it returns the kernel symbol
71 .BR PAGE_SIZE ,
72 whose value depends on the architecture and machine model.
73 Generally, one uses binaries that are dependent on the architecture but not
74 on the machine model, in order to have a single binary
75 distribution per architecture.
76 This means that a user program
77 should not find
78 .B PAGE_SIZE
79 at compile time from a header file,
80 but use an actual system call, at least for those architectures
81 (like sun4) where this dependency exists.
82 Here glibc 2.0 fails because its
83 .BR getpagesize ()
84 returns a statically derived value, and does not use a system call.
85 Things are OK in glibc 2.1.
86 .SH SEE ALSO
87 .BR mmap (2),
88 .BR sysconf (3)