/*-
* Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#endif /* LIBC_SCCS and not lint */
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "db-int.h"
#include "mpool.h"
/*
* mpool_open --
* Initialize a memory pool.
*/
MPOOL *
void *key;
int fd;
{
int entry;
/*
* Get information about the file.
*
* XXX
* We don't currently handle pipes, although we should.
*/
return (NULL);
return (NULL);
}
/* Allocate and initialize the MPOOL cookie. */
return (NULL);
return (mp);
}
/*
* mpool_filter --
*/
void
void *pgcookie;
{
}
/*
* mpool_new --
* Get a new page of memory.
*/
void *
{
abort();
}
#ifdef STATISTICS
#endif
/*
* Get a BKT from the cache. Assign a new page number, attach
* it to the head of the hash chain, the tail of the lru chain,
* and return.
*/
return (NULL);
if (flags == MPOOL_PAGE_REQUEST) {
} else
}
int
void *page;
{
#ifdef DEBUG
abort();
}
#endif
/* Remove from the hash and lru queues. */
return (RET_SUCCESS);
}
/*
* mpool_get
* Get a page.
*/
void *
{
int nr;
#ifdef STATISTICS
#endif
/* Check for a page that is cached. */
#ifdef DEBUG
abort();
}
#endif
/*
* Move the page to the head of the hash chain and the tail
* of the lru chain.
*/
/* Return a pinned page. */
}
/* Get a page from the cache. */
return (NULL);
/* Read in the contents. */
#ifdef STATISTICS
#endif
/* Run past the end of the file, or at least the part we
can address without large-file support? */
return NULL;
}
return (NULL);
if (nr > 0) {
/* A partial read is definitely bad. */
return (NULL);
} else {
/*
* A zero-length reads, means you need to create a
* new page.
*/
}
}
/* Set the page number, pin the page. */
if (!(flags & MPOOL_IGNOREPIN))
/*
* Add the page to the head of the hash chain and the tail
* of the lru chain.
*/
/* Run through the user's filter. */
}
/*
* mpool_put
* Return a page.
*/
int
void *page;
{
#ifdef STATISTICS
#endif
#ifdef DEBUG
abort();
}
#endif
if (flags & MPOOL_DIRTY)
return (RET_SUCCESS);
}
/*
* mpool_close
* Close the buffer pool.
*/
int
{
/* Free up any space allocated to the lru pages. */
}
/* Free the MPOOL cookie. */
return (RET_SUCCESS);
}
/*
* mpool_sync
* Sync the pool to disk.
*/
int
{
/* Walk the lru chain, flushing any dirty pages to disk. */
return (RET_ERROR);
/* Sync the file descriptor. */
}
/*
* mpool_bkt
* Get a page from the cache (or create one).
*/
static BKT *
{
/* If under the max cached, always create a new page. */
goto new;
/*
* If the cache is max'd out, walk the lru list for a buffer we
* can flush. If we find one, write it (if necessary) and take it
* off any lists. If we don't find anything we grow the cache anyway.
* The cache never shrinks.
*/
/* Flush if dirty. */
return (NULL);
#ifdef STATISTICS
#endif
/* Remove from the hash and lru queues. */
#if defined(DEBUG) && !defined(DEBUG_IDX0SPLIT)
{ void *spage;
}
#endif
return (bp);
}
return (NULL);
#ifdef STATISTICS
#endif
#endif
return (bp);
}
/*
* mpool_write
* Write a page to disk.
*/
static int
{
#ifdef STATISTICS
#endif
/* Run through the user's filter. */
/* Run past the end of the file, or at least the part we
can address without large-file support? */
return RET_ERROR;
}
return (RET_ERROR);
return (RET_ERROR);
return (RET_SUCCESS);
}
/*
* mpool_look
* Lookup a page in the cache.
*/
static BKT *
{
#ifdef STATISTICS
#endif
return (bp);
}
#ifdef STATISTICS
#endif
return (NULL);
}
#ifdef STATISTICS
/*
* mpool_stat
* Print out cache statistics.
*/
void
{
int cnt;
char *sep;
"page size %lu, cacheing %lu pages of %lu page max cache\n",
"%.0f%% cache hit rate (%lu hits, %lu misses)\n",
sep = "";
cnt = 0;
if (++cnt == 10) {
sep = "\n";
cnt = 0;
} else
sep = ", ";
}
}
#endif