.\" Copyright (C) 2001 Andries Brouwer .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya .\" all rights reserved. .\" Translated 2002-04-14, HANATAKA Shinya .\" Updated 2003-07-03, Akihiro Motoki .\" Updated 2007-01-07, Akihiro MOTOKI, catch up to LDP v2.43 .\" Updated 2012-04-30, Akihiro MOTOKI .\" .TH GETPAGESIZE 2 2014\-08\-19 Linux "Linux Programmer's Manual" .SH 名前 getpagesize \- メモリーのページサイズを取得する .SH 書式 \fB#include \fP .sp \fBint getpagesize(void);\fP .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp \fBgetpagesize\fP(): .ad l .RS 4 .PD 0 .TP 4 glibc 2.12 以降: .nf _BSD_SOURCE || !(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600) .TP 4 .fi glibc 2.12 より前: _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED .PD .RE .ad b .SH 説明 .\" .SH HISTORY .\" This call first appeared in 4.2BSD. \fBgetpagesize\fP() 関数はメモリーページの大きさをバイト数で返す。 ここでいう「ページ」は固定長のブロックであり、 \fBmmap\fP(2) で実行されるメモリー割り当てとファイルマッピングの単位である。 .SH 準拠 SVr4, 4.4BSD, SUSv2. SUSv2 では \fBgetpagesize\fP() システムコールは「過去の遺物 (LEGACY)」とされており、 POSIX.1\-2001 からは外されている。 HP\-UX にはこのシステムコールは存在しない。 .SH 注意 移植性が必要なアプリケーションでは、 \fBgetpagesize\fP() ではなく \fIsysconf(_SC_PAGESIZE)\fP を利用すべきである。 .PP .in +4n .nf #include long sz = sysconf(_SC_PAGESIZE); .fi .in (ほとんどのシステムでは \fB_SC_PAGESIZE\fP の同義語として \fB_SC_PAGE_SIZE\fP を使用することができる。) \fBgetpagesize\fP() が Linux のシステムコールとして存在するかどうかは、そのアーキテクチャーに 依存している。 システムコールとして存在する場合には、カーネルシンボルの \fBPAGE_SIZE\fP を返す。 \fBPAGE_SIZE\fP の値は、アーキテクチャーとマシンモデルに依存する。 一般に、バイナリは、アーキテクチャーごとに1つのバイナリ配布で済ませるために、 アーキテクチャーには依存しているがマシンモデルには依存していない。 つまり、ユーザープログラムはコンパイル時にヘッダーファイルから \fBPAGE_SIZE\fP を見つけて使用すべきではない。 少なくとも、マシンモデルについても依存性が存在する (sun4 のような) アーキテクチャーにおいては本物のシステムコールを使用する必要がある。 尚、 glibc 2.0 では、 \fBgetpagesize\fP() がシステムコールを使用せず、固定の値を返すために、この方法は 失敗する。glibc 2.1 では大丈夫である。 .SH 関連項目 \fBmmap\fP(2), \fBsysconf\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。