summaryrefslogtreecommitdiffstats
path: root/lib/libc/db/hash
diff options
context:
space:
mode:
authorpst <pst@FreeBSD.org>1996-02-27 01:59:15 +0000
committerpst <pst@FreeBSD.org>1996-02-27 01:59:15 +0000
commit2fd01690e924737239e87aee0c117e3369de6c3e (patch)
tree223a02ae7b36628c291a44ca56e521009362cc01 /lib/libc/db/hash
parent584fea2f92d8bdbedf4d4b45cff7acd9602ae1ad (diff)
parentc2306789fe98946429af7462a2fd453454034a79 (diff)
downloadFreeBSD-src-2fd01690e924737239e87aee0c117e3369de6c3e.zip
FreeBSD-src-2fd01690e924737239e87aee0c117e3369de6c3e.tar.gz
This commit was generated by cvs2svn to compensate for changes in r14272,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'lib/libc/db/hash')
-rw-r--r--lib/libc/db/hash/extern.h24
-rw-r--r--lib/libc/db/hash/hash_bigkey.c76
-rw-r--r--lib/libc/db/hash/hash_buf.c28
-rw-r--r--lib/libc/db/hash/hash_log2.c12
-rw-r--r--lib/libc/db/hash/hsearch.c4
-rw-r--r--lib/libc/db/hash/page.h16
6 files changed, 85 insertions, 75 deletions
diff --git a/lib/libc/db/hash/extern.h b/lib/libc/db/hash/extern.h
index b7ef37a..3167e6d 100644
--- a/lib/libc/db/hash/extern.h
+++ b/lib/libc/db/hash/extern.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1991, 1993
+ * Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)extern.h 8.2 (Berkeley) 2/21/94
+ * @(#)extern.h 8.4 (Berkeley) 6/16/94
*/
BUFHEAD *__add_ovflpage __P((HTAB *, BUFHEAD *));
@@ -40,26 +40,26 @@ int __big_insert __P((HTAB *, BUFHEAD *, const DBT *, const DBT *));
int __big_keydata __P((HTAB *, BUFHEAD *, DBT *, DBT *, int));
int __big_return __P((HTAB *, BUFHEAD *, int, DBT *, int));
int __big_split __P((HTAB *, BUFHEAD *, BUFHEAD *, BUFHEAD *,
- int, u_int, SPLIT_RETURN *));
+ int, u_int32_t, SPLIT_RETURN *));
int __buf_free __P((HTAB *, int, int));
void __buf_init __P((HTAB *, int));
-u_int __call_hash __P((HTAB *, char *, int));
+u_int32_t __call_hash __P((HTAB *, char *, int));
int __delpair __P((HTAB *, BUFHEAD *, int));
int __expand_table __P((HTAB *));
int __find_bigpair __P((HTAB *, BUFHEAD *, int, char *, int));
-u_short __find_last_page __P((HTAB *, BUFHEAD **));
+u_int16_t __find_last_page __P((HTAB *, BUFHEAD **));
void __free_ovflpage __P((HTAB *, BUFHEAD *));
-BUFHEAD *__get_buf __P((HTAB *, u_int, BUFHEAD *, int));
-int __get_page __P((HTAB *, char *, u_int, int, int, int));
-int __init_bitmap __P((HTAB *, int, int, int));
-u_int __log2 __P((u_int));
-int __put_page __P((HTAB *, char *, u_int, int, int));
+BUFHEAD *__get_buf __P((HTAB *, u_int32_t, BUFHEAD *, int));
+int __get_page __P((HTAB *, char *, u_int32_t, int, int, int));
+int __ibitmap __P((HTAB *, int, int, int));
+u_int32_t __log2 __P((u_int32_t));
+int __put_page __P((HTAB *, char *, u_int32_t, int, int));
void __reclaim_buf __P((HTAB *, BUFHEAD *));
-int __split_page __P((HTAB *, u_int, u_int));
+int __split_page __P((HTAB *, u_int32_t, u_int32_t));
/* Default hash routine. */
extern u_int32_t (*__default_hash) __P((const void *, size_t));
#ifdef HASH_STATISTICS
-extern long hash_accesses, hash_collisions, hash_expansions, hash_overflows;
+extern int hash_accesses, hash_collisions, hash_expansions, hash_overflows;
#endif
diff --git a/lib/libc/db/hash/hash_bigkey.c b/lib/libc/db/hash/hash_bigkey.c
index b747fbc..578314a 100644
--- a/lib/libc/db/hash/hash_bigkey.c
+++ b/lib/libc/db/hash/hash_bigkey.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1990, 1993
+ * Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hash_bigkey.c 8.2 (Berkeley) 2/21/94";
+static char sccsid[] = "@(#)hash_bigkey.c 8.3 (Berkeley) 5/31/94";
#endif /* LIBC_SCCS and not lint */
/*
@@ -90,13 +90,13 @@ __big_insert(hashp, bufp, key, val)
BUFHEAD *bufp;
const DBT *key, *val;
{
- register u_short *p;
+ register u_int16_t *p;
int key_size, n, val_size;
- u_short space, move_bytes, off;
+ u_int16_t space, move_bytes, off;
char *cp, *key_data, *val_data;
cp = bufp->page; /* Character pointer of p. */
- p = (u_short *)cp;
+ p = (u_int16_t *)cp;
key_data = (char *)key->data;
key_size = key->size;
@@ -134,7 +134,7 @@ __big_insert(hashp, bufp, key, val)
OFFSET(p) = off;
} else
p[n - 2] = FULL_KEY;
- p = (u_short *)bufp->page;
+ p = (u_int16_t *)bufp->page;
cp = bufp->page;
bufp->flags |= BUF_MOD;
}
@@ -164,7 +164,7 @@ __big_insert(hashp, bufp, key, val)
if (!bufp)
return (-1);
cp = bufp->page;
- p = (u_short *)cp;
+ p = (u_int16_t *)cp;
} else
p[n] = FULL_KEY_DATA;
bufp->flags |= BUF_MOD;
@@ -189,12 +189,12 @@ __big_delete(hashp, bufp)
BUFHEAD *bufp;
{
register BUFHEAD *last_bfp, *rbufp;
- u_short *bp, pageno;
+ u_int16_t *bp, pageno;
int key_done, n;
rbufp = bufp;
last_bfp = NULL;
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
pageno = 0;
key_done = 0;
@@ -217,7 +217,7 @@ __big_delete(hashp, bufp)
last_bfp = rbufp;
if (!rbufp)
return (-1); /* Error. */
- bp = (u_short *)rbufp->page;
+ bp = (u_int16_t *)rbufp->page;
}
/*
@@ -232,7 +232,7 @@ __big_delete(hashp, bufp)
pageno = bp[n - 1];
/* Now, bp is the first page of the pair. */
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
if (n > 2) {
/* There is an overflow page. */
bp[1] = pageno;
@@ -270,13 +270,13 @@ __find_bigpair(hashp, bufp, ndx, key, size)
char *key;
int size;
{
- register u_short *bp;
+ register u_int16_t *bp;
register char *p;
int ksize;
- u_short bytes;
+ u_int16_t bytes;
char *kkey;
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
p = bufp->page;
ksize = size;
kkey = key;
@@ -292,7 +292,7 @@ __find_bigpair(hashp, bufp, ndx, key, size)
if (!bufp)
return (-3);
p = bufp->page;
- bp = (u_short *)p;
+ bp = (u_int16_t *)p;
ndx = 1;
}
@@ -314,17 +314,17 @@ __find_bigpair(hashp, bufp, ndx, key, size)
* of the pair; 0 if there isn't any (i.e. big pair is the last key in the
* bucket)
*/
-extern u_short
+extern u_int16_t
__find_last_page(hashp, bpp)
HTAB *hashp;
BUFHEAD **bpp;
{
BUFHEAD *bufp;
- u_short *bp, pageno;
+ u_int16_t *bp, pageno;
int n;
bufp = *bpp;
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
for (;;) {
n = bp[0];
@@ -341,7 +341,7 @@ __find_last_page(hashp, bpp)
bufp = __get_buf(hashp, pageno, bufp, 0);
if (!bufp)
return (0); /* Need to indicate an error! */
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
}
*bpp = bufp;
@@ -364,15 +364,15 @@ __big_return(hashp, bufp, ndx, val, set_current)
int set_current;
{
BUFHEAD *save_p;
- u_short *bp, len, off, save_addr;
+ u_int16_t *bp, len, off, save_addr;
char *tp;
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
while (bp[ndx + 1] == PARTIAL_KEY) {
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!bufp)
return (-1);
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
ndx = 1;
}
@@ -380,7 +380,7 @@ __big_return(hashp, bufp, ndx, val, set_current)
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!bufp)
return (-1);
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
save_p = bufp;
save_addr = save_p->addr;
off = bp[1];
@@ -401,7 +401,7 @@ __big_return(hashp, bufp, ndx, val, set_current)
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!bufp)
return (-1);
- bp = (u_short *)bufp->page;
+ bp = (u_int16_t *)bufp->page;
} else {
/* The data is all on one page. */
tp = (char *)bp;
@@ -420,7 +420,7 @@ __big_return(hashp, bufp, ndx, val, set_current)
if (!hashp->cpage)
return (-1);
hashp->cndx = 1;
- if (!((u_short *)
+ if (!((u_int16_t *)
hashp->cpage->page)[0]) {
hashp->cbucket++;
hashp->cpage = NULL;
@@ -452,14 +452,14 @@ collect_data(hashp, bufp, len, set)
BUFHEAD *bufp;
int len, set;
{
- register u_short *bp;
+ register u_int16_t *bp;
register char *p;
BUFHEAD *xbp;
- u_short save_addr;
+ u_int16_t save_addr;
int mylen, totlen;
p = bufp->page;
- bp = (u_short *)p;
+ bp = (u_int16_t *)p;
mylen = hashp->BSIZE - bp[1];
save_addr = bufp->addr;
@@ -479,7 +479,7 @@ collect_data(hashp, bufp, len, set)
__get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!hashp->cpage)
return (-1);
- else if (!((u_short *)hashp->cpage->page)[0]) {
+ else if (!((u_int16_t *)hashp->cpage->page)[0]) {
hashp->cbucket++;
hashp->cpage = NULL;
}
@@ -531,10 +531,10 @@ collect_key(hashp, bufp, len, val, set)
BUFHEAD *xbp;
char *p;
int mylen, totlen;
- u_short *bp, save_addr;
+ u_int16_t *bp, save_addr;
p = bufp->page;
- bp = (u_short *)p;
+ bp = (u_int16_t *)p;
mylen = hashp->BSIZE - bp[1];
save_addr = bufp->addr;
@@ -573,15 +573,15 @@ __big_split(hashp, op, np, big_keyp, addr, obucket, ret)
/* Pointer to first page containing the big key/data */
BUFHEAD *big_keyp;
int addr; /* Address of big_keyp */
- u_int obucket;/* Old Bucket */
+ u_int32_t obucket;/* Old Bucket */
SPLIT_RETURN *ret;
{
register BUFHEAD *tmpp;
- register u_short *tp;
+ register u_int16_t *tp;
BUFHEAD *bp;
DBT key, val;
- u_int change;
- u_short free_space, n, off;
+ u_int32_t change;
+ u_int16_t free_space, n, off;
bp = big_keyp;
@@ -613,14 +613,14 @@ __big_split(hashp, op, np, big_keyp, addr, obucket, ret)
(tmpp->ovfl ? tmpp->ovfl->addr : 0), (bp ? bp->addr : 0));
#endif
tmpp->ovfl = bp; /* one of op/np point to big_keyp */
- tp = (u_short *)tmpp->page;
+ tp = (u_int16_t *)tmpp->page;
#ifdef DEBUG
assert(FREESPACE(tp) >= OVFLSIZE);
#endif
n = tp[0];
off = OFFSET(tp);
free_space = FREESPACE(tp);
- tp[++n] = (u_short)addr;
+ tp[++n] = (u_int16_t)addr;
tp[++n] = OVFLPAGE;
tp[0] = n;
OFFSET(tp) = off;
@@ -636,7 +636,7 @@ __big_split(hashp, op, np, big_keyp, addr, obucket, ret)
ret->newp = np;
ret->oldp = op;
- tp = (u_short *)big_keyp->page;
+ tp = (u_int16_t *)big_keyp->page;
big_keyp->flags |= BUF_MOD;
if (tp[0] > 2) {
/*
diff --git a/lib/libc/db/hash/hash_buf.c b/lib/libc/db/hash/hash_buf.c
index 1362c83..92e1f93 100644
--- a/lib/libc/db/hash/hash_buf.c
+++ b/lib/libc/db/hash/hash_buf.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1990, 1993
+ * Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hash_buf.c 8.2 (Berkeley) 2/21/94";
+static char sccsid[] = "@(#)hash_buf.c 8.5 (Berkeley) 7/15/94";
#endif /* LIBC_SCCS and not lint */
/*
@@ -57,8 +57,10 @@ static char sccsid[] = "@(#)hash_buf.c 8.2 (Berkeley) 2/21/94";
#include <sys/param.h>
#include <errno.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
+
#ifdef DEBUG
#include <assert.h>
#endif
@@ -68,7 +70,7 @@ static char sccsid[] = "@(#)hash_buf.c 8.2 (Berkeley) 2/21/94";
#include "page.h"
#include "extern.h"
-static BUFHEAD *newbuf __P((HTAB *, u_int, BUFHEAD *));
+static BUFHEAD *newbuf __P((HTAB *, u_int32_t, BUFHEAD *));
/* Unlink B from its place in the lru */
#define BUF_REMOVE(B) { \
@@ -102,12 +104,12 @@ static BUFHEAD *newbuf __P((HTAB *, u_int, BUFHEAD *));
extern BUFHEAD *
__get_buf(hashp, addr, prev_bp, newpage)
HTAB *hashp;
- u_int addr;
+ u_int32_t addr;
BUFHEAD *prev_bp;
int newpage; /* If prev_bp set, indicates a new overflow page. */
{
register BUFHEAD *bp;
- register u_int is_disk_mask;
+ register u_int32_t is_disk_mask;
register int is_disk, segment_ndx;
SEGMENT segp;
@@ -140,7 +142,7 @@ __get_buf(hashp, addr, prev_bp, newpage)
return (NULL);
if (!prev_bp)
segp[segment_ndx] =
- (BUFHEAD *)((u_int)bp | is_disk_mask);
+ (BUFHEAD *)((ptrdiff_t)bp | is_disk_mask);
} else {
BUF_REMOVE(bp);
MRU_INSERT(bp);
@@ -157,7 +159,7 @@ __get_buf(hashp, addr, prev_bp, newpage)
static BUFHEAD *
newbuf(hashp, addr, prev_bp)
HTAB *hashp;
- u_int addr;
+ u_int32_t addr;
BUFHEAD *prev_bp;
{
register BUFHEAD *bp; /* The buffer we're going to use */
@@ -165,7 +167,7 @@ newbuf(hashp, addr, prev_bp)
register BUFHEAD *next_xbp;
SEGMENT segp;
int segment_ndx;
- u_short oaddr, *shortp;
+ u_int16_t oaddr, *shortp;
oaddr = 0;
bp = LRU;
@@ -177,10 +179,16 @@ newbuf(hashp, addr, prev_bp)
/* Allocate a new one */
if ((bp = (BUFHEAD *)malloc(sizeof(BUFHEAD))) == NULL)
return (NULL);
+#ifdef PURIFY
+ memset(bp, 0xff, sizeof(BUFHEAD));
+#endif
if ((bp->page = (char *)malloc(hashp->BSIZE)) == NULL) {
free(bp);
return (NULL);
}
+#ifdef PURIFY
+ memset(bp->page, 0xff, hashp->BSIZE);
+#endif
if (hashp->nbufs)
hashp->nbufs--;
} else {
@@ -195,7 +203,7 @@ newbuf(hashp, addr, prev_bp)
* Set oaddr before __put_page so that you get it
* before bytes are swapped.
*/
- shortp = (u_short *)bp->page;
+ shortp = (u_int16_t *)bp->page;
if (shortp[0])
oaddr = shortp[shortp[0] - 1];
if ((bp->flags & BUF_MOD) && __put_page(hashp, bp->page,
@@ -238,7 +246,7 @@ newbuf(hashp, addr, prev_bp)
(oaddr != xbp->addr))
break;
- shortp = (u_short *)xbp->page;
+ shortp = (u_int16_t *)xbp->page;
if (shortp[0])
/* set before __put_page */
oaddr = shortp[shortp[0] - 1];
diff --git a/lib/libc/db/hash/hash_log2.c b/lib/libc/db/hash/hash_log2.c
index b773707..c8c56bf 100644
--- a/lib/libc/db/hash/hash_log2.c
+++ b/lib/libc/db/hash/hash_log2.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1990, 1993
+ * Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
@@ -35,16 +35,18 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hash_log2.c 8.1 (Berkeley) 6/4/93";
+static char sccsid[] = "@(#)hash_log2.c 8.2 (Berkeley) 5/31/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
-u_int
+#include <db.h>
+
+u_int32_t
__log2(num)
- u_int num;
+ u_int32_t num;
{
- register u_int i, limit;
+ register u_int32_t i, limit;
limit = 1;
for (i = 0; limit < num; limit = limit << 1, i++);
diff --git a/lib/libc/db/hash/hsearch.c b/lib/libc/db/hash/hsearch.c
index e4914b1..cc8f7a4 100644
--- a/lib/libc/db/hash/hsearch.c
+++ b/lib/libc/db/hash/hsearch.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hsearch.c 8.3 (Berkeley) 2/21/94";
+static char sccsid[] = "@(#)hsearch.c 8.4 (Berkeley) 7/21/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -58,7 +58,7 @@ hcreate(nel)
info.nelem = nel;
info.bsize = 256;
info.ffactor = 8;
- info.cachesize = NULL;
+ info.cachesize = 0;
info.hash = NULL;
info.lorder = 0;
dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR, 0600, &info, 0);
diff --git a/lib/libc/db/hash/page.h b/lib/libc/db/hash/page.h
index dae82ae..0fc0d5a 100644
--- a/lib/libc/db/hash/page.h
+++ b/lib/libc/db/hash/page.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1990, 1993
+ * Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)page.h 8.1 (Berkeley) 6/6/93
+ * @(#)page.h 8.2 (Berkeley) 5/31/94
*/
/*
@@ -73,20 +73,20 @@
* You might as well do this up front.
*/
-#define PAIRSIZE(K,D) (2*sizeof(u_short) + (K)->size + (D)->size)
-#define BIGOVERHEAD (4*sizeof(u_short))
-#define KEYSIZE(K) (4*sizeof(u_short) + (K)->size);
-#define OVFLSIZE (2*sizeof(u_short))
+#define PAIRSIZE(K,D) (2*sizeof(u_int16_t) + (K)->size + (D)->size)
+#define BIGOVERHEAD (4*sizeof(u_int16_t))
+#define KEYSIZE(K) (4*sizeof(u_int16_t) + (K)->size);
+#define OVFLSIZE (2*sizeof(u_int16_t))
#define FREESPACE(P) ((P)[(P)[0]+1])
#define OFFSET(P) ((P)[(P)[0]+2])
#define PAIRFITS(P,K,D) \
(((P)[2] >= REAL_KEY) && \
(PAIRSIZE((K),(D)) + OVFLSIZE) <= FREESPACE((P)))
-#define PAGE_META(N) (((N)+3) * sizeof(u_short))
+#define PAGE_META(N) (((N)+3) * sizeof(u_int16_t))
typedef struct {
BUFHEAD *newp;
BUFHEAD *oldp;
BUFHEAD *nextp;
- u_short next_addr;
+ u_int16_t next_addr;
} SPLIT_RETURN;
OpenPOWER on IntegriCloud