OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[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 2007-07-26 "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 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
38 .SH DESCRIPTION
39 The function
40 .BR getpagesize ()
41 returns the number of bytes in a page, where a "page" is the thing
42 used where it says in the description of
43 .BR mmap (2)
44 that files are mapped in page-sized units.
45
46 The size of the kind of pages that
47 .BR mmap (2)
48 uses, is found using
49
50 .in +4n
51 .nf
52 #include <unistd.h>
53 long sz = sysconf(_SC_PAGESIZE);
54 .fi
55 .in
56
57 (most systems allow the synonym
58 .B _SC_PAGE_SIZE
59 for
60 .BR _SC_PAGESIZE ),
61 or
62
63 .in +4n
64 .nf
65 #include <unistd.h>
66 int sz = getpagesize();
67 .fi
68 .in
69 .\" .SH HISTORY
70 .\" This call first appeared in 4.2BSD.
71 .SH CONFORMING TO
72 SVr4, 4.4BSD, SUSv2.
73 In SUSv2 the
74 .BR getpagesize ()
75 call is labeled LEGACY, and in POSIX.1-2001
76 it has been dropped;
77 HP-UX does not have this call.
78 Portable applications should employ
79 .I sysconf(_SC_PAGESIZE)
80 instead of this call.
81 .SH NOTES
82 Whether
83 .BR getpagesize ()
84 is present as a Linux system call depends on the architecture.
85 If it is, it returns the kernel symbol
86 .BR PAGE_SIZE ,
87 whose value depends on the architecture and machine model.
88 Generally, one uses binaries that are dependent on the architecture but not
89 on the machine model, in order to have a single binary
90 distribution per architecture.
91 This means that a user program
92 should not find
93 .B PAGE_SIZE
94 at compile time from a header file,
95 but use an actual system call, at least for those architectures
96 (like sun4) where this dependency exists.
97 Here libc4, libc5, glibc 2.0 fail because their
98 .BR getpagesize ()
99 returns a statically derived value, and does not use a system call.
100 Things are OK in glibc 2.1.
101 .SH "SEE ALSO"
102 .BR mmap (2),
103 .BR sysconf (3)