OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libc/] [search/] [hash_buf.c] - Diff between revs 207 and 345

Only display areas with differences | Details | Blame | View Log

Rev 207 Rev 345
/*-
/*-
 * Copyright (c) 1990, 1993, 1994
 * Copyright (c) 1990, 1993, 1994
 *      The Regents of the University of California.  All rights reserved.
 *      The Regents of the University of California.  All rights reserved.
 *
 *
 * This code is derived from software contributed to Berkeley by
 * This code is derived from software contributed to Berkeley by
 * Margo Seltzer.
 * Margo Seltzer.
 *
 *
 * Redistribution and use in source and binary forms, with or without
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * modification, are permitted provided that the following conditions
 * are met:
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    must display the following acknowledgement:
 *      This product includes software developed by the University of
 *      This product includes software developed by the University of
 *      California, Berkeley and its contributors.
 *      California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of 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
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *    without specific prior written permission.
 *
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * 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
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * SUCH DAMAGE.
 */
 */
 
 
#include <sys/param.h>
#include <sys/param.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)hash_buf.c  8.5 (Berkeley) 7/15/94";
static char sccsid[] = "@(#)hash_buf.c  8.5 (Berkeley) 7/15/94";
#endif /* LIBC_SCCS and not lint */
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
#include <sys/cdefs.h>
 
 
/*
/*
 * PACKAGE: hash
 * PACKAGE: hash
 *
 *
 * DESCRIPTION:
 * DESCRIPTION:
 *      Contains buffer management
 *      Contains buffer management
 *
 *
 * ROUTINES:
 * ROUTINES:
 * External
 * External
 *      __buf_init
 *      __buf_init
 *      __get_buf
 *      __get_buf
 *      __buf_free
 *      __buf_free
 *      __reclaim_buf
 *      __reclaim_buf
 * Internal
 * Internal
 *      newbuf
 *      newbuf
 */
 */
 
 
#include <sys/param.h>
#include <sys/param.h>
 
 
#include <stddef.h>
#include <stddef.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
 
 
#ifdef DEBUG
#ifdef DEBUG
#include <assert.h>
#include <assert.h>
#endif
#endif
 
 
#include "db_local.h"
#include "db_local.h"
#include "hash.h"
#include "hash.h"
#include "page.h"
#include "page.h"
#include "extern.h"
#include "extern.h"
 
 
static BUFHEAD *newbuf(HTAB *, __uint32_t, BUFHEAD *);
static BUFHEAD *newbuf(HTAB *, __uint32_t, BUFHEAD *);
 
 
/* Unlink B from its place in the lru */
/* Unlink B from its place in the lru */
#define BUF_REMOVE(B) { \
#define BUF_REMOVE(B) { \
        (B)->prev->next = (B)->next; \
        (B)->prev->next = (B)->next; \
        (B)->next->prev = (B)->prev; \
        (B)->next->prev = (B)->prev; \
}
}
 
 
/* Insert B after P */
/* Insert B after P */
#define BUF_INSERT(B, P) { \
#define BUF_INSERT(B, P) { \
        (B)->next = (P)->next; \
        (B)->next = (P)->next; \
        (B)->prev = (P); \
        (B)->prev = (P); \
        (P)->next = (B); \
        (P)->next = (B); \
        (B)->next->prev = (B); \
        (B)->next->prev = (B); \
}
}
 
 
#define MRU     hashp->bufhead.next
#define MRU     hashp->bufhead.next
#define LRU     hashp->bufhead.prev
#define LRU     hashp->bufhead.prev
 
 
#define MRU_INSERT(B)   BUF_INSERT((B), &hashp->bufhead)
#define MRU_INSERT(B)   BUF_INSERT((B), &hashp->bufhead)
#define LRU_INSERT(B)   BUF_INSERT((B), LRU)
#define LRU_INSERT(B)   BUF_INSERT((B), LRU)
 
 
/* Macros for min/max.  */
/* Macros for min/max.  */
#ifndef MIN
#ifndef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
#endif
#ifndef MAX
#ifndef MAX
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif
#endif
 
 
/*
/*
 * We are looking for a buffer with address "addr".  If prev_bp is NULL, then
 * We are looking for a buffer with address "addr".  If prev_bp is NULL, then
 * address is a bucket index.  If prev_bp is not NULL, then it points to the
 * address is a bucket index.  If prev_bp is not NULL, then it points to the
 * page previous to an overflow page that we are trying to find.
 * page previous to an overflow page that we are trying to find.
 *
 *
 * CAVEAT:  The buffer header accessed via prev_bp's ovfl field may no longer
 * CAVEAT:  The buffer header accessed via prev_bp's ovfl field may no longer
 * be valid.  Therefore, you must always verify that its address matches the
 * be valid.  Therefore, you must always verify that its address matches the
 * address you are seeking.
 * address you are seeking.
 */
 */
extern BUFHEAD *
extern BUFHEAD *
__get_buf(hashp, addr, prev_bp, newpage)
__get_buf(hashp, addr, prev_bp, newpage)
        HTAB *hashp;
        HTAB *hashp;
        __uint32_t addr;
        __uint32_t addr;
        BUFHEAD *prev_bp;
        BUFHEAD *prev_bp;
        int newpage;    /* If prev_bp set, indicates a new overflow page. */
        int newpage;    /* If prev_bp set, indicates a new overflow page. */
{
{
        BUFHEAD *bp;
        BUFHEAD *bp;
        __uint32_t is_disk_mask;
        __uint32_t is_disk_mask;
        int is_disk, segment_ndx;
        int is_disk, segment_ndx;
        SEGMENT segp;
        SEGMENT segp;
 
 
        is_disk = 0;
        is_disk = 0;
        is_disk_mask = 0;
        is_disk_mask = 0;
        if (prev_bp) {
        if (prev_bp) {
                bp = prev_bp->ovfl;
                bp = prev_bp->ovfl;
                if (!bp || (bp->addr != addr))
                if (!bp || (bp->addr != addr))
                        bp = NULL;
                        bp = NULL;
                if (!newpage)
                if (!newpage)
                        is_disk = BUF_DISK;
                        is_disk = BUF_DISK;
        } else {
        } else {
                /* Grab buffer out of directory */
                /* Grab buffer out of directory */
                segment_ndx = addr & (hashp->SGSIZE - 1);
                segment_ndx = addr & (hashp->SGSIZE - 1);
 
 
                /* valid segment ensured by __call_hash() */
                /* valid segment ensured by __call_hash() */
                segp = hashp->dir[addr >> hashp->SSHIFT];
                segp = hashp->dir[addr >> hashp->SSHIFT];
#ifdef DEBUG
#ifdef DEBUG
                assert(segp != NULL);
                assert(segp != NULL);
#endif
#endif
                bp = PTROF(segp[segment_ndx]);
                bp = PTROF(segp[segment_ndx]);
                is_disk_mask = ISDISK(segp[segment_ndx]);
                is_disk_mask = ISDISK(segp[segment_ndx]);
                is_disk = is_disk_mask || !hashp->new_file;
                is_disk = is_disk_mask || !hashp->new_file;
        }
        }
 
 
        if (!bp) {
        if (!bp) {
                bp = newbuf(hashp, addr, prev_bp);
                bp = newbuf(hashp, addr, prev_bp);
                if (!bp ||
                if (!bp ||
                    __get_page(hashp, bp->page, addr, !prev_bp, is_disk, 0))
                    __get_page(hashp, bp->page, addr, !prev_bp, is_disk, 0))
                        return (NULL);
                        return (NULL);
                if (!prev_bp)
                if (!prev_bp)
                        segp[segment_ndx] =
                        segp[segment_ndx] =
                            (BUFHEAD *)((ptrdiff_t)bp | is_disk_mask);
                            (BUFHEAD *)((ptrdiff_t)bp | is_disk_mask);
        } else {
        } else {
                BUF_REMOVE(bp);
                BUF_REMOVE(bp);
                MRU_INSERT(bp);
                MRU_INSERT(bp);
        }
        }
        return (bp);
        return (bp);
}
}
 
 
/*
/*
 * We need a buffer for this page. Either allocate one, or evict a resident
 * We need a buffer for this page. Either allocate one, or evict a resident
 * one (if we have as many buffers as we're allowed) and put this one in.
 * one (if we have as many buffers as we're allowed) and put this one in.
 *
 *
 * If newbuf finds an error (returning NULL), it also sets errno.
 * If newbuf finds an error (returning NULL), it also sets errno.
 */
 */
static BUFHEAD *
static BUFHEAD *
newbuf(hashp, addr, prev_bp)
newbuf(hashp, addr, prev_bp)
        HTAB *hashp;
        HTAB *hashp;
        __uint32_t addr;
        __uint32_t addr;
        BUFHEAD *prev_bp;
        BUFHEAD *prev_bp;
{
{
        BUFHEAD *bp;            /* The buffer we're going to use */
        BUFHEAD *bp;            /* The buffer we're going to use */
        BUFHEAD *xbp;           /* Temp pointer */
        BUFHEAD *xbp;           /* Temp pointer */
        BUFHEAD *next_xbp;
        BUFHEAD *next_xbp;
        SEGMENT segp;
        SEGMENT segp;
        int segment_ndx;
        int segment_ndx;
        __uint16_t oaddr, *shortp;
        __uint16_t oaddr, *shortp;
 
 
        oaddr = 0;
        oaddr = 0;
        bp = LRU;
        bp = LRU;
        /*
        /*
         * If LRU buffer is pinned, the buffer pool is too small. We need to
         * If LRU buffer is pinned, the buffer pool is too small. We need to
         * allocate more buffers.
         * allocate more buffers.
         */
         */
        if (hashp->nbufs || (bp->flags & BUF_PIN)) {
        if (hashp->nbufs || (bp->flags & BUF_PIN)) {
                /* Allocate a new one */
                /* Allocate a new one */
                if ((bp = (BUFHEAD *)malloc(sizeof(BUFHEAD))) == NULL)
                if ((bp = (BUFHEAD *)malloc(sizeof(BUFHEAD))) == NULL)
                        return (NULL);
                        return (NULL);
#ifdef PURIFY
#ifdef PURIFY
                memset(bp, 0xff, sizeof(BUFHEAD));
                memset(bp, 0xff, sizeof(BUFHEAD));
#endif
#endif
                if ((bp->page = (char *)malloc(hashp->BSIZE)) == NULL) {
                if ((bp->page = (char *)malloc(hashp->BSIZE)) == NULL) {
                        free(bp);
                        free(bp);
                        return (NULL);
                        return (NULL);
                }
                }
#ifdef PURIFY
#ifdef PURIFY
                memset(bp->page, 0xff, hashp->BSIZE);
                memset(bp->page, 0xff, hashp->BSIZE);
#endif
#endif
                if (hashp->nbufs)
                if (hashp->nbufs)
                        hashp->nbufs--;
                        hashp->nbufs--;
        } else {
        } else {
                /* Kick someone out */
                /* Kick someone out */
                BUF_REMOVE(bp);
                BUF_REMOVE(bp);
                /*
                /*
                 * If this is an overflow page with addr 0, it's already been
                 * If this is an overflow page with addr 0, it's already been
                 * flushed back in an overflow chain and initialized.
                 * flushed back in an overflow chain and initialized.
                 */
                 */
                if ((bp->addr != 0) || (bp->flags & BUF_BUCKET)) {
                if ((bp->addr != 0) || (bp->flags & BUF_BUCKET)) {
                        /*
                        /*
                         * Set oaddr before __put_page so that you get it
                         * Set oaddr before __put_page so that you get it
                         * before bytes are swapped.
                         * before bytes are swapped.
                         */
                         */
                        shortp = (__uint16_t *)bp->page;
                        shortp = (__uint16_t *)bp->page;
                        if (shortp[0])
                        if (shortp[0])
                                oaddr = shortp[shortp[0] - 1];
                                oaddr = shortp[shortp[0] - 1];
                        if ((bp->flags & BUF_MOD) && __put_page(hashp, bp->page,
                        if ((bp->flags & BUF_MOD) && __put_page(hashp, bp->page,
                            bp->addr, (int)IS_BUCKET(bp->flags), 0))
                            bp->addr, (int)IS_BUCKET(bp->flags), 0))
                                return (NULL);
                                return (NULL);
                        /*
                        /*
                         * Update the pointer to this page (i.e. invalidate it).
                         * Update the pointer to this page (i.e. invalidate it).
                         *
                         *
                         * If this is a new file (i.e. we created it at open
                         * If this is a new file (i.e. we created it at open
                         * time), make sure that we mark pages which have been
                         * time), make sure that we mark pages which have been
                         * written to disk so we retrieve them from disk later,
                         * written to disk so we retrieve them from disk later,
                         * rather than allocating new pages.
                         * rather than allocating new pages.
                         */
                         */
                        if (IS_BUCKET(bp->flags)) {
                        if (IS_BUCKET(bp->flags)) {
                                segment_ndx = bp->addr & (hashp->SGSIZE - 1);
                                segment_ndx = bp->addr & (hashp->SGSIZE - 1);
                                segp = hashp->dir[bp->addr >> hashp->SSHIFT];
                                segp = hashp->dir[bp->addr >> hashp->SSHIFT];
#ifdef DEBUG
#ifdef DEBUG
                                assert(segp != NULL);
                                assert(segp != NULL);
#endif
#endif
 
 
                                if (hashp->new_file &&
                                if (hashp->new_file &&
                                    ((bp->flags & BUF_MOD) ||
                                    ((bp->flags & BUF_MOD) ||
                                    ISDISK(segp[segment_ndx])))
                                    ISDISK(segp[segment_ndx])))
                                        segp[segment_ndx] = (BUFHEAD *)BUF_DISK;
                                        segp[segment_ndx] = (BUFHEAD *)BUF_DISK;
                                else
                                else
                                        segp[segment_ndx] = NULL;
                                        segp[segment_ndx] = NULL;
                        }
                        }
                        /*
                        /*
                         * Since overflow pages can only be access by means of
                         * Since overflow pages can only be access by means of
                         * their bucket, free overflow pages associated with
                         * their bucket, free overflow pages associated with
                         * this bucket.
                         * this bucket.
                         */
                         */
                        for (xbp = bp; xbp->ovfl;) {
                        for (xbp = bp; xbp->ovfl;) {
                                next_xbp = xbp->ovfl;
                                next_xbp = xbp->ovfl;
                                xbp->ovfl = 0;
                                xbp->ovfl = 0;
                                xbp = next_xbp;
                                xbp = next_xbp;
 
 
                                /* Check that ovfl pointer is up date. */
                                /* Check that ovfl pointer is up date. */
                                if (IS_BUCKET(xbp->flags) ||
                                if (IS_BUCKET(xbp->flags) ||
                                    (oaddr != xbp->addr))
                                    (oaddr != xbp->addr))
                                        break;
                                        break;
 
 
                                shortp = (__uint16_t *)xbp->page;
                                shortp = (__uint16_t *)xbp->page;
                                if (shortp[0])
                                if (shortp[0])
                                        /* set before __put_page */
                                        /* set before __put_page */
                                        oaddr = shortp[shortp[0] - 1];
                                        oaddr = shortp[shortp[0] - 1];
                                if ((xbp->flags & BUF_MOD) && __put_page(hashp,
                                if ((xbp->flags & BUF_MOD) && __put_page(hashp,
                                    xbp->page, xbp->addr, 0, 0))
                                    xbp->page, xbp->addr, 0, 0))
                                        return (NULL);
                                        return (NULL);
                                xbp->addr = 0;
                                xbp->addr = 0;
                                xbp->flags = 0;
                                xbp->flags = 0;
                                BUF_REMOVE(xbp);
                                BUF_REMOVE(xbp);
                                LRU_INSERT(xbp);
                                LRU_INSERT(xbp);
                        }
                        }
                }
                }
        }
        }
 
 
        /* Now assign this buffer */
        /* Now assign this buffer */
        bp->addr = addr;
        bp->addr = addr;
#ifdef DEBUG1
#ifdef DEBUG1
        (void)fprintf(stderr, "NEWBUF1: %d->ovfl was %d is now %d\n",
        (void)fprintf(stderr, "NEWBUF1: %d->ovfl was %d is now %d\n",
            bp->addr, (bp->ovfl ? bp->ovfl->addr : 0), 0);
            bp->addr, (bp->ovfl ? bp->ovfl->addr : 0), 0);
#endif
#endif
        bp->ovfl = NULL;
        bp->ovfl = NULL;
        if (prev_bp) {
        if (prev_bp) {
                /*
                /*
                 * If prev_bp is set, this is an overflow page, hook it in to
                 * If prev_bp is set, this is an overflow page, hook it in to
                 * the buffer overflow links.
                 * the buffer overflow links.
                 */
                 */
#ifdef DEBUG1
#ifdef DEBUG1
                (void)fprintf(stderr, "NEWBUF2: %d->ovfl was %d is now %d\n",
                (void)fprintf(stderr, "NEWBUF2: %d->ovfl was %d is now %d\n",
                    prev_bp->addr, (prev_bp->ovfl ? bp->ovfl->addr : 0),
                    prev_bp->addr, (prev_bp->ovfl ? bp->ovfl->addr : 0),
                    (bp ? bp->addr : 0));
                    (bp ? bp->addr : 0));
#endif
#endif
                prev_bp->ovfl = bp;
                prev_bp->ovfl = bp;
                bp->flags = 0;
                bp->flags = 0;
        } else
        } else
                bp->flags = BUF_BUCKET;
                bp->flags = BUF_BUCKET;
        MRU_INSERT(bp);
        MRU_INSERT(bp);
        return (bp);
        return (bp);
}
}
 
 
extern void
extern void
__buf_init(hashp, nbytes)
__buf_init(hashp, nbytes)
        HTAB *hashp;
        HTAB *hashp;
        int nbytes;
        int nbytes;
{
{
        BUFHEAD *bfp;
        BUFHEAD *bfp;
        int npages;
        int npages;
 
 
        bfp = &(hashp->bufhead);
        bfp = &(hashp->bufhead);
        npages = (nbytes + hashp->BSIZE - 1) >> hashp->BSHIFT;
        npages = (nbytes + hashp->BSIZE - 1) >> hashp->BSHIFT;
        npages = MAX(npages, MIN_BUFFERS);
        npages = MAX(npages, MIN_BUFFERS);
 
 
        hashp->nbufs = npages;
        hashp->nbufs = npages;
        bfp->next = bfp;
        bfp->next = bfp;
        bfp->prev = bfp;
        bfp->prev = bfp;
        /*
        /*
         * This space is calloc'd so these are already null.
         * This space is calloc'd so these are already null.
         *
         *
         * bfp->ovfl = NULL;
         * bfp->ovfl = NULL;
         * bfp->flags = 0;
         * bfp->flags = 0;
         * bfp->page = NULL;
         * bfp->page = NULL;
         * bfp->addr = 0;
         * bfp->addr = 0;
         */
         */
}
}
 
 
extern int
extern int
__buf_free(hashp, do_free, to_disk)
__buf_free(hashp, do_free, to_disk)
        HTAB *hashp;
        HTAB *hashp;
        int do_free, to_disk;
        int do_free, to_disk;
{
{
        BUFHEAD *bp;
        BUFHEAD *bp;
 
 
        /* Need to make sure that buffer manager has been initialized */
        /* Need to make sure that buffer manager has been initialized */
        if (!LRU)
        if (!LRU)
                return (0);
                return (0);
        for (bp = LRU; bp != &hashp->bufhead;) {
        for (bp = LRU; bp != &hashp->bufhead;) {
                /* Check that the buffer is valid */
                /* Check that the buffer is valid */
                if (bp->addr || IS_BUCKET(bp->flags)) {
                if (bp->addr || IS_BUCKET(bp->flags)) {
                        if (to_disk && (bp->flags & BUF_MOD) &&
                        if (to_disk && (bp->flags & BUF_MOD) &&
                            __put_page(hashp, bp->page,
                            __put_page(hashp, bp->page,
                            bp->addr, IS_BUCKET(bp->flags), 0))
                            bp->addr, IS_BUCKET(bp->flags), 0))
                                return (-1);
                                return (-1);
                }
                }
                /* Check if we are freeing stuff */
                /* Check if we are freeing stuff */
                if (do_free) {
                if (do_free) {
                        if (bp->page)
                        if (bp->page)
                                free(bp->page);
                                free(bp->page);
                        BUF_REMOVE(bp);
                        BUF_REMOVE(bp);
                        free(bp);
                        free(bp);
                        bp = LRU;
                        bp = LRU;
                } else
                } else
                        bp = bp->prev;
                        bp = bp->prev;
        }
        }
        return (0);
        return (0);
}
}
 
 
extern void
extern void
__reclaim_buf(hashp, bp)
__reclaim_buf(hashp, bp)
        HTAB *hashp;
        HTAB *hashp;
        BUFHEAD *bp;
        BUFHEAD *bp;
{
{
        bp->ovfl = 0;
        bp->ovfl = 0;
        bp->addr = 0;
        bp->addr = 0;
        bp->flags = 0;
        bp->flags = 0;
        BUF_REMOVE(bp);
        BUF_REMOVE(bp);
        LRU_INSERT(bp);
        LRU_INSERT(bp);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.