1 .\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>
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.
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.
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
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
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
30 .\"WORD: legacy ²áµî¤Î°äʪ
32 .TH GETPAGESIZE 2 2007-07-26 "Linux" "Linux Programmer's Manual"
35 .\"O getpagesize \- get memory page size
36 getpagesize \- ¥á¥â¥ê¤Î¥Ú¡¼¥¸¡¦¥µ¥¤¥º¤ò¼èÆÀ¤¹¤ë
38 .B #include <unistd.h>
40 .B int getpagesize(void);
43 .\"O Feature Test Macro Requirements for glibc (see
44 .\"O .BR feature_test_macros (7)):
45 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
46 .RB ( feature_test_macros (7)
51 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
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
59 .\"O that files are mapped in page-sized units.
61 ´Ø¿ô¤Ï¥Ú¡¼¥¸¤ÎÂ礤µ¤ò¥Ð¥¤¥È¿ô¤ÇÊÖ¤¹¡£¤³¤³¤Ç¤Î¡Ö¥Ú¡¼¥¸¡×¤Ï
63 ¤ÎÀâÌÀ¤ÎÃæ¤Ç»ÈÍѤµ¤ì¤Æ¤¤¤ë¤â¤Î¤Ç¡¢
65 ¤Ï¤³¤Î¥Ú¡¼¥¸¥µ¥¤¥º¤Îñ°Ì¤Ç¥Õ¥¡¥¤¥ë¤ò¥Þ¥Ã¥×¤¹¤ë¡£
67 .\"O The size of the kind of pages that
69 .\"O uses, is found using
71 ¤¬»ÈÍѤ¹¤ë¥Ú¡¼¥¸¥µ¥¤¥º¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤·¤ÆÃΤ뤳¤È¤¬¤Ç¤¤ë¡£
76 long sz = sysconf(_SC_PAGESIZE);
80 .\"O (most systems allow the synonym
83 .\"O .BR _SC_PAGESIZE ),
85 (¤Û¤È¤ó¤É¤Î¥·¥¹¥Æ¥à¤Ç¤Ï
89 ¤ò»ÈÍѤ¹¤ë¤³¤È¤¬¤Ç¤¤ë)¡¢¤â¤·¤¯¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤¹¤ë:
94 int sz = getpagesize();
99 .\"O .\" This call first appeared in 4.2BSD.
100 .\" ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï 4.2BSD ¤Ç½é¤á¤ÆÅо줷¤¿¡£
101 .\"O .SH CONFORMING TO
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.
114 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¡Ö²áµî¤Î°äʪ (LEGACY)¡×¤È¤µ¤ì¤Æ¤ª¤ê¡¢
115 POSIX.1-2001 ¤«¤é¤Ï³°¤µ¤ì¤Æ¤¤¤ë¡£
116 HP-UX ¤Ë¤Ï¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¸ºß¤·¤Ê¤¤¡£
117 °Ü¿¢À¤¬É¬Íפʥ¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¡¢¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÎÂå¤ï¤ê¤Ë
118 .I sysconf(_SC_PAGESIZE)
123 .\"O .BR getpagesize ()
124 .\"O is present as a Linux system call depends on the architecture.
126 ¤¬ Linux ¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤È¤·¤Æ¸ºß¤¹¤ë¤«¤É¤¦¤«¤Ï¡¢¤½¤Î¥¢¡¼¥¥Æ¥¯¥Á¥ã¤Ë
128 .\"O If it is, it returns the kernel symbol
130 .\"O whose value depends on the architecture and machine model.
131 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤È¤·¤Æ¸ºß¤¹¤ë¾ì¹ç¤Ë¤Ï¡¢¥«¡¼¥Í¥ë¥·¥ó¥Ü¥ë¤Î
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
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 ¤Ä¤Þ¤ê¡¢¥æ¡¼¥¶¥×¥í¥°¥é¥à¤Ï¥³¥ó¥Ñ¥¤¥ë»þ¤Ë¥Ø¥Ã¥À¡¼¥Õ¥¡¥¤¥ë¤«¤é
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 ¤Ç¤Ï¡¢
158 ¤¬¥·¥¹¥Æ¥à¡¦¥³¡¼¥ë¤ò»ÈÍѤ»¤º¡¢¸ÇÄê¤ÎÃͤòÊÖ¤¹¤¿¤á¤Ë¡¢¤³¤ÎÊýË¡¤Ï
159 ¼ºÇÔ¤¹¤ë¡£glibc 2.1 ¤Ç¤ÏÂç¾æÉפǤ¢¤ë¡£