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
32 .TH GETPAGESIZE 2 2010-09-20 "Linux" "Linux Programmer's Manual"
34 getpagesize \- メモリのページ・サイズを取得する
36 .B #include <unistd.h>
38 .B int getpagesize(void);
42 .RB ( feature_test_macros (7)
54 !(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600)
58 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
59 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
65 関数はページの大きさをバイト数で返す。ここでの「ページ」は
69 はこのページサイズの単位でファイルをマップする。
72 が使用するページサイズは以下のようにして知ることができる。
77 long sz = sysconf(_SC_PAGESIZE);
85 を使用することができる)、もしくは以下のようにする:
90 int sz = getpagesize();
94 .\" このシステムコールは 4.2BSD で初めて登場した。
99 システムコールは「過去の遺物 (LEGACY)」とされており、
100 POSIX.1-2001 からは外されている。
101 HP-UX にはこのシステムコールは存在しない。
102 移植性が必要なアプリケーションでは、このシステムコールの代わりに
103 .I sysconf(_SC_PAGESIZE)
107 が Linux のシステムコールとして存在するかどうかは、そのアーキテクチャに
109 システムコールとして存在する場合には、カーネルシンボルの
113 の値は、アーキテクチャとマシンモデルに依存する。
114 一般に、バイナリは、アーキテクチャごとに1つのバイナリ配布で済ませるために、
115 アーキテクチャには依存しているがマシンモデルには依存していない。
116 つまり、ユーザプログラムはコンパイル時にヘッダーファイルから
119 少なくとも、マシンモデルについても依存性が存在する (sun4 のような)
120 アーキテクチャにおいては本物のシステムコールを使用する必要がある。
121 尚、 libc4, libc5, glibc 2.0 では、
123 がシステム・コールを使用せず、固定の値を返すために、この方法は
124 失敗する。glibc 2.1 では大丈夫である。