OSDN Git Service

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