aboutsummaryrefslogtreecommitdiffstats
path: root/include/mpool.h
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2009-03-28 07:31:02 +0000
committerXin LI <delphij@FreeBSD.org>2009-03-28 07:31:02 +0000
commit9fc74a871c838bb10c1ba9b01a22e9df4aa2e55f (patch)
treeed6c7564fb2f2d25581d74c48ca0074066b16e39 /include/mpool.h
parent73590c342a2d1a23322e7c64295fd91c6a6294b9 (diff)
downloadsrc-9fc74a871c838bb10c1ba9b01a22e9df4aa2e55f.tar.gz
src-9fc74a871c838bb10c1ba9b01a22e9df4aa2e55f.zip
Minor changes from Berkeley DB 1.86 and further improvements from OpenBSD.
This does not include the new hash routines since they will cause problems when reading old hash files. Since mpool(3) has been changed, provide a compatibility shim for older binaries. Obtained from: OpenBSD
Notes
Notes: svn path=/head/; revision=190498
Diffstat (limited to 'include/mpool.h')
-rw-r--r--include/mpool.h38
1 files changed, 23 insertions, 15 deletions
diff --git a/include/mpool.h b/include/mpool.h
index b5be330a0cc5..c74764d725f3 100644
--- a/include/mpool.h
+++ b/include/mpool.h
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)mpool.h 8.2 (Berkeley) 7/14/94
+ * @(#)mpool.h 8.4 (Berkeley) 11/2/95
* $FreeBSD$
*/
@@ -47,7 +47,7 @@
* pool is handed an opaque MPOOL cookie which stores all of this information.
*/
#define HASHSIZE 128
-#define HASHKEY(pgno) ((pgno - 1) % HASHSIZE)
+#define HASHKEY(pgno) ((pgno - 1 + HASHSIZE) % HASHSIZE)
/* The BKT structures are the elements of the queues. */
typedef struct _bkt {
@@ -58,6 +58,7 @@ typedef struct _bkt {
#define MPOOL_DIRTY 0x01 /* page needs to be written */
#define MPOOL_PINNED 0x02 /* page is pinned into memory */
+#define MPOOL_INUSE 0x04 /* page address is valid */
u_int8_t flags; /* flags */
} BKT;
@@ -68,7 +69,7 @@ typedef struct MPOOL {
pgno_t curcache; /* current number of cached pages */
pgno_t maxcache; /* max number of cached pages */
pgno_t npages; /* number of pages in the file */
- u_long pagesize; /* file page size */
+ unsigned long pagesize; /* file page size */
int fd; /* file descriptor */
/* page in conversion routine */
void (*pgin)(void *, pgno_t, void *);
@@ -76,25 +77,32 @@ typedef struct MPOOL {
void (*pgout)(void *, pgno_t, void *);
void *pgcookie; /* cookie for page in/out routines */
#ifdef STATISTICS
- u_long cachehit;
- u_long cachemiss;
- u_long pagealloc;
- u_long pageflush;
- u_long pageget;
- u_long pagenew;
- u_long pageput;
- u_long pageread;
- u_long pagewrite;
+ unsigned long cachehit;
+ unsigned long cachemiss;
+ unsigned long pagealloc;
+ unsigned long pageflush;
+ unsigned long pageget;
+ unsigned long pagenew;
+ unsigned long pageput;
+ unsigned long pageread;
+ unsigned long pagewrite;
#endif
} MPOOL;
+#define MPOOL_IGNOREPIN 0x01 /* Ignore if the page is pinned. */
+#define MPOOL_PAGE_REQUEST 0x01 /* Allocate a new page with a
+ specific page number. */
+#define MPOOL_PAGE_NEXT 0x02 /* Allocate a new page with the next
+ page number. */
+
__BEGIN_DECLS
MPOOL *mpool_open(void *, int, pgno_t, pgno_t);
void mpool_filter(MPOOL *, void (*)(void *, pgno_t, void *),
void (*)(void *, pgno_t, void *), void *);
-void *mpool_new(MPOOL *, pgno_t *);
-void *mpool_get(MPOOL *, pgno_t, u_int);
-int mpool_put(MPOOL *, void *, u_int);
+void *mpool_new(MPOOL *, pgno_t *, unsigned int);
+void *mpool_get(MPOOL *, pgno_t, unsigned int);
+int mpool_delete(MPOOL *, void *);
+int mpool_put(MPOOL *, void *, unsigned int);
int mpool_sync(MPOOL *);
int mpool_close(MPOOL *);
#ifdef STATISTICS