]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/mincore.2
Added/updated glibc feature test macro requirements
[thirdparty/man-pages.git] / man2 / mincore.2
CommitLineData
fea681da
MK
1.\" Hey Emacs! This file is -*- nroff -*- source.
2.\"
3.\" Copyright (C) 2001 Bert Hubert <ahu@ds9a.nl>
182d6622 4.\" and Copyright (C) 2007 Michael Kerrisk <mtk-manpages@gmx.net>
fea681da
MK
5.\"
6.\" Permission is granted to make and distribute verbatim copies of this
7.\" manual provided the copyright notice and this permission notice are
8.\" preserved on all copies.
9.\"
10.\" Permission is granted to copy and distribute modified versions of this
11.\" manual under the conditions for verbatim copying, provided that the
12.\" entire resulting derived work is distributed under the terms of a
13.\" permission notice identical to this one.
c13182ef 14.\"
fea681da
MK
15.\" Since the Linux kernel and libraries are constantly changing, this
16.\" manual page may be incorrect or out-of-date. The author(s) assume no
17.\" responsibility for errors or omissions, or for damages resulting from
18.\" the use of the information contained herein. The author(s) may not
19.\" have taken the same level of care in the production of this manual,
20.\" which is licensed free of charge, as they might when working
21.\" professionally.
c13182ef 22.\"
fea681da
MK
23.\" Formatted or processed versions of this manual, if unaccompanied by
24.\" the source, must acknowledge the copyright and authors of this work.
25.\"
26.\" Created Sun Jun 3 17:23:32 2001 by bert hubert <ahu@ds9a.nl>
27.\" Slightly adapted, following comments by Hugh Dickins, aeb, 2001-06-04.
305a0578
MK
28.\" Modified, 20 May 2003, Michael Kerrisk <mtk-manpages@gmx.net>
29.\" Modified, 30 Apr 2004, Michael Kerrisk <mtk-manpages@gmx.net>
2a447060 30.\" 2005-04-05 mtk, Fixed error descriptions
6e01dc7e 31.\" after message from <gordon.jin@intel.com>
182d6622 32.\" 2007-01-08 mtk, rewrote various parts
fea681da 33.\"
cc4615cc 34.TH MINCORE 2 2007-07-26 "Linux" "Linux Programmer's Manual"
fea681da 35.SH NAME
182d6622 36mincore \- determine whether pages are resident in memory
fea681da
MK
37.SH SYNOPSIS
38.B #include <unistd.h>
39.br
40.B #include <sys/mman.h>
41.sp
42.BI "int mincore(void *" start ", size_t " length ", unsigned char *" vec );
cc4615cc
MK
43.sp
44.in -4n
45Feature Test Macro Requirements for glibc (see
46.BR feature_test_macros (7)):
47.in
48.sp
49.BR mincore ():
50_BSD_SOURCE || _SVID_SOURCE
fea681da 51.SH DESCRIPTION
e511ffb6 52.BR mincore ()
c13182ef
MK
53returns a vector that indicates whether pages
54of the calling process's virtual memory are resident in core (RAM),
182d6622
MK
55and so will not cause a disk access (page fault) if referenced.
56The kernel returns residency information about the pages
57starting at the address
58.IR start ,
c13182ef 59and continuing for
fea681da 60.I length
182d6622 61bytes.
fea681da 62
182d6622 63The
fea681da 64.I start
182d6622
MK
65argument must be a multiple of the system page size.
66The
fea681da 67.I length
c13182ef 68argument need not be a multiple of the page size,
182d6622
MK
69but since residency information is returned for whole pages,
70.I length
71is effectively rounded up to the next multiple of the page size.
72One may obtain the page size (PAGE_SIZE) using
73.IR sysconf(_SC_PAGESIZE) .
fea681da 74
182d6622
MK
75The
76.I vec
77argument must point to an array containing at least
78(length+PAGE_SIZE-1) / PAGE_SIZE bytes.
c13182ef
MK
79On return,
80the least significant bit of each byte will be set if
81the corresponding page is currently resident in memory,
182d6622
MK
82and be clear otherwise.
83(The settings of the other bits in each byte are undefined;
84these bits are reserved for possible later use.)
85Of course the information returned in
86.I vec
87is only a snapshot: pages that are not
88locked in memory can come and go at any moment, and the contents of
89.I vec
90may already be stale by the time this call returns.
fea681da
MK
91.SH "RETURN VALUE"
92On success,
e511ffb6 93.BR mincore ()
fea681da
MK
94returns zero.
95On error, \-1 is returned, and
96.I errno
97is set appropriately.
98.SH ERRORS
99.B EAGAIN
182d6622 100kernel is temporarily out of resources.
fea681da
MK
101.TP
102.B EFAULT
103.I vec
182d6622 104points to an invalid address.
fea681da
MK
105.TP
106.B EINVAL
107.I start
2a447060
MK
108is not a multiple of the page size.
109.TP
110.B ENOMEM
8a784deb 111.I length
6e01dc7e 112is greater than
e9496f74 113.RI ( TASK_SIZE " \- " start ).
2a447060 114(This could occur if a negative value is specified for
8a784deb 115.IR length ,
2a447060
MK
116since that value will be interpreted as a large
117unsigned integer.)
118In Linux 2.6.11 and earlier, the error
119.B EINVAL
120was returned for this condition.
fea681da
MK
121.TP
122.B ENOMEM
8a784deb 123.I start
fea681da 124to
8a784deb 125.I start
fea681da
MK
126+
127.I length
24825f27 128contained unmapped memory.
a1d5f77c
MK
129.SH VERSIONS
130Available since Linux 2.3.99pre1 and glibc 2.2.
131.SH "CONFORMING TO"
132.BR mincore ()
133is not specified in POSIX.1-2001,
134and it is not available on all Unix implementations.
135.\" It is on at least NetBSD, FreeBSD, OpenBSD, Solaris 8,
136.\" AIX 5.1, SunOS 4.1
137.\" .SH HISTORY
138.\" The
139.\" .BR mincore ()
140.\" function first appeared in 4.4BSD.
fea681da 141.SH BUGS
24825f27 142Before kernel 2.6.21,
e511ffb6 143.BR mincore ()
c13182ef
MK
144did not return correct information for
145.B MAP_PRIVATE
24825f27
MK
146mappings, or for non-linear mappings (established using
147.BR remap_file_pages (2)).
fea681da
MK
148.\" Linux (up to now, 2.6.5),
149.\" .B mincore
150.\" does not return correct information for MAP_PRIVATE mappings:
151.\" for a MAP_PRIVATE file mapping,
152.\" .B mincore
153.\" returns the residency of the file pages, rather than any
154.\" modified process-private pages that have been copied on write;
155.\" for a MAP_PRIVATE mapping of
156.\" .IR /dev/zero ,
157.\" .B mincore
158.\" always reports pages as non-resident;
159.\" and for a MAP_PRIVATE, MAP_ANONYMOUS mapping,
160.\" .B mincore
161.\" always fails with the error
162.\" .BR ENOMEM .
fea681da 163.SH "SEE ALSO"
fea681da
MK
164.BR mlock (2),
165.BR mmap (2)