OSDN Git Service

(split) LDP: Update original to LDP v3.65
[linuxjm/LDP_man-pages.git] / original / man2 / getpagesize.2
1 .\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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.
12 .\"
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.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH GETPAGESIZE 2 2010-11-16 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 getpagesize \- get memory page size
28 .SH SYNOPSIS
29 .B #include <unistd.h>
30 .sp
31 .B int getpagesize(void);
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 ():
39 .ad l
40 .RS 4
41 .PD 0
42 .TP 4
43 Since glibc 2.12:
44 .nf
45 _BSD_SOURCE ||
46     !(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600)
47 .TP 4
48 .fi
49 Before glibc 2.12:
50 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
51 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
52 .PD
53 .RE
54 .ad b
55 .SH DESCRIPTION
56 The function
57 .BR getpagesize ()
58 returns the number of bytes in a memory page,
59 where "page" is a fixed-length block,
60 the unit for memory allocation and file mapping performed by
61 .BR mmap (2).
62 .\" .SH HISTORY
63 .\" This call first appeared in 4.2BSD.
64 .SH CONFORMING TO
65 SVr4, 4.4BSD, SUSv2.
66 In SUSv2 the
67 .BR getpagesize ()
68 call is labeled LEGACY, and in POSIX.1-2001
69 it has been dropped;
70 HP-UX does not have this call.
71 .SH NOTES
72 Portable applications should employ
73 .I sysconf(_SC_PAGESIZE)
74 instead of
75 .BR getpagesize ():
76 .PP
77 .in +4n
78 .nf
79 #include <unistd.h>
80 long sz = sysconf(_SC_PAGESIZE);
81 .fi
82 .in
83
84 (Most systems allow the synonym
85 .B _SC_PAGE_SIZE
86 for
87 .BR _SC_PAGESIZE .)
88
89 Whether
90 .BR getpagesize ()
91 is present as a Linux system call depends on the architecture.
92 If it is, it returns the kernel symbol
93 .BR PAGE_SIZE ,
94 whose value depends on the architecture and machine model.
95 Generally, one uses binaries that are dependent on the architecture but not
96 on the machine model, in order to have a single binary
97 distribution per architecture.
98 This means that a user program
99 should not find
100 .B PAGE_SIZE
101 at compile time from a header file,
102 but use an actual system call, at least for those architectures
103 (like sun4) where this dependency exists.
104 Here libc4, libc5, glibc 2.0 fail because their
105 .BR getpagesize ()
106 returns a statically derived value, and does not use a system call.
107 Things are OK in glibc 2.1.
108 .SH SEE ALSO
109 .BR mmap (2),
110 .BR sysconf (3)
111 .SH COLOPHON
112 This page is part of release 3.65 of the Linux
113 .I man-pages
114 project.
115 A description of the project,
116 and information about reporting bugs,
117 can be found at
118 \%http://www.kernel.org/doc/man\-pages/.