OSDN Git Service

(split) LDP: Update original to LDP v3.40.
[linuxjm/LDP_man-pages.git] / original / man3 / mpool.3
1 .\" Copyright (c) 1990, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)mpool.3     8.1 (Berkeley) 6/4/93
33 .\"
34 .TH MPOOL 3 2012-04-26 "" "Linux Programmer's Manual"
35 .UC 7
36 .SH NAME
37 mpool \- shared memory buffer pool
38 .SH SYNOPSIS
39 .nf
40 .B #include <db.h>
41 .B #include <mpool.h>
42 .sp
43 .BI "MPOOL *mpool_open(DBT *" key ", int " fd ", pgno_t " pagesize \
44 ", pgno_t " maxcache );
45 .sp
46 .BI "void mpool_filter(MPOOL *" mp ", void (*pgin)(void *, pgno_t, void *),"
47 .BI "                  void (*" pgout ")(void *, pgno_t, void *),"
48 .BI "                  void *" pgcookie );
49 .sp
50 .BI "void *mpool_new(MPOOL *" mp ", pgno_t *" pgnoaddr );
51 .sp
52 .BI "void *mpool_get(MPOOL *" mp ", pgno_t " pgno ", unsigned int " flags );
53 .sp
54 .BI "int mpool_put(MPOOL *" mp ", void *" pgaddr ", unsigned int " flags );
55 .sp
56 .BI "int mpool_sync(MPOOL *" mp );
57 .sp
58 .BI "int mpool_close(MPOOL *" mp );
59 .fi
60 .SH DESCRIPTION
61 .IR "Note well" :
62 This page documents interfaces provided in glibc up until version 2.1.
63 Since version 2.2, glibc no longer provides these interfaces.
64 Probably, you are looking for the APIs provided by the
65 .I libdb
66 library instead.
67
68 .I Mpool
69 is the library interface intended to provide page oriented buffer management
70 of files.
71 The buffers may be shared between processes.
72 .PP
73 The function
74 .BR mpool_open ()
75 initializes a memory pool.
76 The
77 .I key
78 argument is the byte string used to negotiate between multiple
79 processes wishing to share buffers.
80 If the file buffers are mapped in shared memory, all processes using
81 the same key will share the buffers.
82 If
83 .I key
84 is NULL, the buffers are mapped into private memory.
85 The
86 .I fd
87 argument is a file descriptor for the underlying file, which must be seekable.
88 If
89 .I key
90 is non-NULL and matches a file already being mapped, the
91 .I fd
92 argument is ignored.
93 .PP
94 The
95 .I pagesize
96 argument is the size, in bytes, of the pages into which the file is broken up.
97 The
98 .I maxcache
99 argument is the maximum number of pages from the underlying file to cache
100 at any one time.
101 This value is not relative to the number of processes which share a file's
102 buffers, but will be the largest value specified by any of the processes
103 sharing the file.
104 .PP
105 The
106 .BR mpool_filter ()
107 function is intended to make transparent input and output processing of the
108 pages possible.
109 If the
110 .I pgin
111 function is specified, it is called each time a buffer is read into the memory
112 pool from the backing file.
113 If the
114 .I pgout
115 function is specified, it is called each time a buffer is written into the
116 backing file.
117 Both functions are called with the
118 .I pgcookie
119 pointer, the page number and a pointer to the page to being read or written.
120 .PP
121 The function
122 .BR mpool_new ()
123 takes an
124 .I MPOOL
125 pointer and an address as arguments.
126 If a new page can be allocated, a pointer to the page is returned and
127 the page number is stored into the
128 .I pgnoaddr
129 address.
130 Otherwise, NULL is returned and
131 .I errno
132 is set.
133 .PP
134 The function
135 .BR mpool_get ()
136 takes an
137 .I MPOOL
138 pointer and a page number as arguments.
139 If the page exists, a pointer to the page is returned.
140 Otherwise, NULL is returned and
141 .I errno
142 is set.
143 The
144 .I flags
145 argument is not currently used.
146 .PP
147 The function
148 .BR mpool_put ()
149 unpins the page referenced by
150 .IR pgaddr .
151 .I pgaddr
152 must be an address previously returned by
153 .BR mpool_get ()
154 or
155 .BR mpool_new ().
156 The flag value is specified by ORing
157 any of the following values:
158 .TP
159 .B MPOOL_DIRTY
160 The page has been modified and needs to be written to the backing file.
161 .PP
162 .BR mpool_put ()
163 returns 0 on success and \-1 if an error occurs.
164 .PP
165 The function
166 .BR mpool_sync ()
167 writes all modified pages associated with the
168 .I MPOOL
169 pointer to the
170 backing file.
171 .BR mpool_sync ()
172 returns 0 on success and \-1 if an error occurs.
173 .PP
174 The
175 .BR mpool_close ()
176 function free's up any allocated memory associated with the memory pool
177 cookie.
178 Modified pages are
179 .B not
180 written to the backing file.
181 .BR mpool_close ()
182 returns 0 on success and \-1 if an error occurs.
183 .SH ERRORS
184 The
185 .BR mpool_open ()
186 function may fail and set
187 .I errno
188 for any of the errors specified for the library routine
189 .BR malloc (3).
190 .PP
191 The
192 .BR mpool_get ()
193 function may fail and set
194 .I errno
195 for the following:
196 .TP 15
197 .B EINVAL
198 The requested record doesn't exist.
199 .PP
200 The
201 .BR mpool_new ()
202 and
203 .BR mpool_get ()
204 functions may fail and set
205 .I errno
206 for any of the errors specified for the library routines
207 .BR read (2),
208 .BR write (2),
209 and
210 .BR malloc (3).
211 .PP
212 The
213 .BR mpool_sync ()
214 function may fail and set
215 .I errno
216 for any of the errors specified for the library routine
217 .BR write (2).
218 .PP
219 The
220 .BR mpool_close ()
221 function may fail and set
222 .I errno
223 for any of the errors specified for the library routine
224 .BR free (3).
225 .SH "CONFORMING TO"
226 Not in POSIX.1-2001.
227 Present on the BSDs.
228 .SH "SEE ALSO"
229 .BR btree (3),
230 .BR dbopen (3),
231 .BR hash (3),
232 .BR recno (3)