OSDN Git Service

e2db542471cc497dc52bbd212ed8836248d45a22
[linuxjm/LDP_man-pages.git] / draft / 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 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
24 .\"         all rights reserved.
25 .\" Translated 2002-04-14, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
26 .\" Updated 2003-07-03, Akihiro Motoki <amotoki@dd.iij4u.or.jp>
27 .\" Updated 2007-01-07, Akihiro MOTOKI, catch up to LDP v2.43
28 .\"
29 .\"WORD:        page                    ¥Ú¡¼¥¸
30 .\"WORD:        legacy                  ²áµî¤Î°äʪ
31 .\"
32 .TH GETPAGESIZE 2 2007-07-26 "Linux" "Linux Programmer's Manual"
33 .\"O .SH NAME
34 .SH Ì¾Á°
35 .\"O getpagesize \- get memory page size
36 getpagesize \- ¥á¥â¥ê¤Î¥Ú¡¼¥¸¡¦¥µ¥¤¥º¤ò¼èÆÀ¤¹¤ë
37 .SH ½ñ¼°
38 .B #include <unistd.h>
39 .sp
40 .B int getpagesize(void);
41 .sp
42 .in -4n
43 .\"O Feature Test Macro Requirements for glibc (see
44 .\"O .BR feature_test_macros (7)):
45 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
46 .RB ( feature_test_macros (7)
47 »²¾È):
48 .in
49 .sp
50 .BR getpagesize ():
51 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
52 .\"O .SH DESCRIPTION
53 .SH ÀâÌÀ
54 .\"O The function
55 .\"O .BR getpagesize ()
56 .\"O returns the number of bytes in a page, where a "page" is the thing
57 .\"O used where it says in the description of
58 .\"O .BR mmap (2)
59 .\"O that files are mapped in page-sized units.
60 .BR getpagesize ()
61 ´Ø¿ô¤Ï¥Ú¡¼¥¸¤ÎÂ礭¤µ¤ò¥Ð¥¤¥È¿ô¤ÇÊÖ¤¹¡£¤³¤³¤Ç¤Î¡Ö¥Ú¡¼¥¸¡×¤Ï
62 .BR mmap (2)
63 ¤ÎÀâÌÀ¤ÎÃæ¤Ç»ÈÍѤµ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¡¢
64 .BR mmap ()
65 ¤Ï¤³¤Î¥Ú¡¼¥¸¥µ¥¤¥º¤Îñ°Ì¤Ç¥Õ¥¡¥¤¥ë¤ò¥Þ¥Ã¥×¤¹¤ë¡£
66
67 .\"O The size of the kind of pages that
68 .\"O .BR mmap (2)
69 .\"O uses, is found using
70 .BR mmap (2)
71 ¤¬»ÈÍѤ¹¤ë¥Ú¡¼¥¸¥µ¥¤¥º¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤·¤ÆÃΤ뤳¤È¤¬¤Ç¤­¤ë¡£
72
73 .in +4n
74 .nf
75 #include <unistd.h>
76 long sz = sysconf(_SC_PAGESIZE);
77 .fi
78 .in
79
80 .\"O (most systems allow the synonym
81 .\"O .B _SC_PAGE_SIZE
82 .\"O for
83 .\"O .BR _SC_PAGESIZE ),
84 .\"O or
85 (¤Û¤È¤ó¤É¤Î¥·¥¹¥Æ¥à¤Ç¤Ï
86 .B _SC_PAGESIZE
87 ¤ÎƱµÁ¸ì¤È¤·¤Æ
88 .B _SC_PAGE_SIZE
89 ¤ò»ÈÍѤ¹¤ë¤³¤È¤¬¤Ç¤­¤ë)¡¢¤â¤·¤¯¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤¹¤ë:
90
91 .in +4n
92 .nf
93 #include <unistd.h>
94 int sz = getpagesize();
95 .fi
96 .in
97 .\"O .\" .SH HISTORY
98 .\" .SH Îò»Ë
99 .\"O .\" This call first appeared in 4.2BSD.
100 .\" ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï 4.2BSD ¤Ç½é¤á¤ÆÅо줷¤¿¡£
101 .\"O .SH CONFORMING TO
102 .SH ½àµò
103 SVr4, 4.4BSD, SUSv2.
104 .\"O In SUSv2 the
105 .\"O .BR getpagesize ()
106 .\"O call is labeled LEGACY, and in POSIX.1-2001
107 .\"O it has been dropped;
108 .\"O HP-UX does not have this call.
109 .\"O Portable applications should employ
110 .\"O .I sysconf(_SC_PAGESIZE)
111 .\"O instead of this call.
112 SUSv2 ¤Ç¤Ï
113 .BR getpagesize ()
114 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡Ö²áµî¤Î°äʪ (LEGACY)¡×¤È¤µ¤ì¤Æ¤ª¤ê¡¢
115 POSIX.1-2001 ¤«¤é¤Ï³°¤µ¤ì¤Æ¤¤¤ë¡£
116 HP-UX ¤Ë¤Ï¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¸ºß¤·¤Ê¤¤¡£
117 °Ü¿¢À­¤¬É¬Íפʥ¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¡¢¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÎÂå¤ï¤ê¤Ë
118 .I sysconf(_SC_PAGESIZE)
119 ¤òÍøÍѤ¹¤Ù¤­¤Ç¤¢¤ë¡£
120 .\"O .SH NOTES
121 .SH Ãí°Õ
122 .\"O Whether
123 .\"O .BR getpagesize ()
124 .\"O is present as a Linux system call depends on the architecture.
125 .BR getpagesize ()
126 ¤¬ Linux ¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤È¤·¤Æ¸ºß¤¹¤ë¤«¤É¤¦¤«¤Ï¡¢¤½¤Î¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤Ë
127 °Í¸¤·¤Æ¤¤¤ë¡£
128 .\"O If it is, it returns the kernel symbol
129 .\"O .BR PAGE_SIZE ,
130 .\"O whose value depends on the architecture and machine model.
131 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤È¤·¤Æ¸ºß¤¹¤ë¾ì¹ç¤Ë¤Ï¡¢¥«¡¼¥Í¥ë¥·¥ó¥Ü¥ë¤Î
132 .B PAGE_SIZE
133 ¤òÊÖ¤¹¡£
134 .B PAGE_SIZE
135 ¤ÎÃͤϡ¢¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤È¥Þ¥·¥ó¥â¥Ç¥ë¤Ë°Í¸¤¹¤ë¡£
136 .\"O Generally, one uses binaries that are dependent on the architecture but not
137 .\"O on the machine model, in order to have a single binary
138 .\"O distribution per architecture.
139 .\"O This means that a user program
140 .\"O should not find
141 .\"O .B PAGE_SIZE
142 .\"O at compile time from a header file,
143 .\"O but use an actual system call, at least for those architectures
144 .\"O (like sun4) where this dependency exists.
145 °ìÈ̤ˡ¢¥Ð¥¤¥Ê¥ê¤Ï¡¢¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤´¤È¤Ë1¤Ä¤Î¥Ð¥¤¥Ê¥êÇÛÉۤǺѤޤ»¤ë¤¿¤á¤Ë¡¢
146 ¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤Ë¤Ï°Í¸¤·¤Æ¤¤¤ë¤¬¥Þ¥·¥ó¥â¥Ç¥ë¤Ë¤Ï°Í¸¤·¤Æ¤¤¤Ê¤¤¡£
147 ¤Ä¤Þ¤ê¡¢¥æ¡¼¥¶¥×¥í¥°¥é¥à¤Ï¥³¥ó¥Ñ¥¤¥ë»þ¤Ë¥Ø¥Ã¥À¡¼¥Õ¥¡¥¤¥ë¤«¤é
148 .B PAGE_SIZE
149 ¤ò¸«¤Ä¤±¤Æ»ÈÍѤ¹¤Ù¤­¤Ç¤Ï¤Ê¤¤¡£
150 ¾¯¤Ê¤¯¤È¤â¡¢¥Þ¥·¥ó¥â¥Ç¥ë¤Ë¤Ä¤¤¤Æ¤â°Í¸À­¤¬Â¸ºß¤¹¤ë (sun4 ¤Î¤è¤¦¤Ê)
151 ¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤Ë¤ª¤¤¤Æ¤ÏËÜʪ¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò»ÈÍѤ¹¤ëɬÍפ¬¤¢¤ë¡£
152 .\"O Here libc4, libc5, glibc 2.0 fail because their
153 .\"O .BR getpagesize ()
154 .\"O returns a statically derived value, and does not use a system call.
155 .\"O Things are OK in glibc 2.1.
156 ¾°¡¢ libc4, libc5, glibc 2.0 ¤Ç¤Ï¡¢
157 .BR getpagesize ()
158 ¤¬¥·¥¹¥Æ¥à¡¦¥³¡¼¥ë¤ò»ÈÍѤ»¤º¡¢¸ÇÄê¤ÎÃͤòÊÖ¤¹¤¿¤á¤Ë¡¢¤³¤ÎÊýË¡¤Ï
159 ¼ºÇÔ¤¹¤ë¡£glibc 2.1 ¤Ç¤ÏÂç¾æÉפǤ¢¤ë¡£
160 .\"O .SH "SEE ALSO"
161 .SH ´ØÏ¢¹àÌÜ
162 .BR mmap (2),
163 .BR sysconf (3)