first pass at making DB use basic integral types (the Alpha port)
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 22 Feb 1994 07:12:48 +0000 (23:12 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 22 Feb 1994 07:12:48 +0000 (23:12 -0800)
SCCS-vsn: lib/libc/db/btree/bt_conv.c 8.2
SCCS-vsn: lib/libc/db/btree/bt_debug.c 8.2
SCCS-vsn: lib/libc/db/btree/bt_delete.c 8.3
SCCS-vsn: lib/libc/db/btree/bt_open.c 8.4
SCCS-vsn: lib/libc/db/btree/bt_page.c 8.2
SCCS-vsn: lib/libc/db/btree/bt_search.c 8.5
SCCS-vsn: lib/libc/db/btree/bt_split.c 8.2
SCCS-vsn: lib/libc/db/btree/bt_stack.c 8.2
SCCS-vsn: lib/libc/db/btree/bt_utils.c 8.3
SCCS-vsn: lib/libc/db/btree/btree.h 8.5
SCCS-vsn: lib/libc/db/btree/extern.h 8.3
SCCS-vsn: lib/libc/db/hash/extern.h 8.2
SCCS-vsn: lib/libc/db/hash/hash.c 8.6
SCCS-vsn: lib/libc/db/hash/hash.h 8.2
SCCS-vsn: lib/libc/db/hash/hash_func.c 8.2
SCCS-vsn: lib/libc/db/hash/hash_page.c 8.3
SCCS-vsn: lib/libc/db/hash/hsearch.c 8.3
SCCS-vsn: lib/libc/db/man/btree.3 8.3
SCCS-vsn: lib/libc/db/man/hash.3 8.5
SCCS-vsn: lib/libc/db/man/recno.3 8.3
SCCS-vsn: lib/libc/db/recno/extern.h 8.2
SCCS-vsn: lib/libc/db/recno/rec_close.c 8.3
SCCS-vsn: lib/libc/db/recno/rec_delete.c 8.4
SCCS-vsn: lib/libc/db/recno/rec_open.c 8.5
SCCS-vsn: lib/libc/db/recno/rec_search.c 8.3

25 files changed:
usr/src/lib/libc/db/btree/bt_conv.c
usr/src/lib/libc/db/btree/bt_debug.c
usr/src/lib/libc/db/btree/bt_delete.c
usr/src/lib/libc/db/btree/bt_open.c
usr/src/lib/libc/db/btree/bt_page.c
usr/src/lib/libc/db/btree/bt_search.c
usr/src/lib/libc/db/btree/bt_split.c
usr/src/lib/libc/db/btree/bt_stack.c
usr/src/lib/libc/db/btree/bt_utils.c
usr/src/lib/libc/db/btree/btree.h
usr/src/lib/libc/db/btree/extern.h
usr/src/lib/libc/db/hash/extern.h
usr/src/lib/libc/db/hash/hash.c
usr/src/lib/libc/db/hash/hash.h
usr/src/lib/libc/db/hash/hash_func.c
usr/src/lib/libc/db/hash/hash_page.c
usr/src/lib/libc/db/hash/hsearch.c
usr/src/lib/libc/db/man/btree.3
usr/src/lib/libc/db/man/hash.3
usr/src/lib/libc/db/man/recno.3
usr/src/lib/libc/db/recno/extern.h
usr/src/lib/libc/db/recno/rec_close.c
usr/src/lib/libc/db/recno/rec_delete.c
usr/src/lib/libc/db/recno/rec_open.c
usr/src/lib/libc/db/recno/rec_search.c

index f00d39c..ab11763 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_conv.c  8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)bt_conv.c  8.2 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
@@ -38,7 +38,7 @@ __bt_pgin(t, pg, pp)
        void *pp;
 {
        PAGE *h;
        void *pp;
 {
        PAGE *h;
-       int i, top;
+       indx_t i, top;
        u_char flags;
        char *p;
 
        u_char flags;
        char *p;
 
@@ -50,50 +50,50 @@ __bt_pgin(t, pg, pp)
        }
 
        h = pp;
        }
 
        h = pp;
-       BLSWAP(h->pgno);
-       BLSWAP(h->prevpg);
-       BLSWAP(h->nextpg);
-       BLSWAP(h->flags);
-       BSSWAP(h->lower);
-       BSSWAP(h->upper);
+       M_32_SWAP(h->pgno);
+       M_32_SWAP(h->prevpg);
+       M_32_SWAP(h->nextpg);
+       M_32_SWAP(h->flags);
+       M_16_SWAP(h->lower);
+       M_16_SWAP(h->upper);
 
        top = NEXTINDEX(h);
        if ((h->flags & P_TYPE) == P_BINTERNAL)
                for (i = 0; i < top; i++) {
 
        top = NEXTINDEX(h);
        if ((h->flags & P_TYPE) == P_BINTERNAL)
                for (i = 0; i < top; i++) {
-                       BSSWAP(h->linp[i]);
+                       M_16_SWAP(h->linp[i]);
                        p = (char *)GETBINTERNAL(h, i);
                        p = (char *)GETBINTERNAL(h, i);
-                       BLPSWAP(p);
+                       P_32_SWAP(p);
                        p += sizeof(size_t);
                        p += sizeof(size_t);
-                       BLPSWAP(p);
+                       P_32_SWAP(p);
                        p += sizeof(pgno_t);
                        if (*(u_char *)p & P_BIGKEY) {
                                p += sizeof(u_char);
                        p += sizeof(pgno_t);
                        if (*(u_char *)p & P_BIGKEY) {
                                p += sizeof(u_char);
-                               BLPSWAP(p);
+                               P_32_SWAP(p);
                                p += sizeof(pgno_t);
                                p += sizeof(pgno_t);
-                               BLPSWAP(p);
+                               P_32_SWAP(p);
                        }
                }
        else if ((h->flags & P_TYPE) == P_BLEAF)
                for (i = 0; i < top; i++) {
                        }
                }
        else if ((h->flags & P_TYPE) == P_BLEAF)
                for (i = 0; i < top; i++) {
-                       BSSWAP(h->linp[i]);
+                       M_16_SWAP(h->linp[i]);
                        p = (char *)GETBLEAF(h, i);
                        p = (char *)GETBLEAF(h, i);
-                       BLPSWAP(p);
+                       P_32_SWAP(p);
                        p += sizeof(size_t);
                        p += sizeof(size_t);
-                       BLPSWAP(p);
+                       P_32_SWAP(p);
                        p += sizeof(size_t);
                        flags = *(u_char *)p;
                        if (flags & (P_BIGKEY | P_BIGDATA)) {
                                p += sizeof(u_char);
                                if (flags & P_BIGKEY) {
                        p += sizeof(size_t);
                        flags = *(u_char *)p;
                        if (flags & (P_BIGKEY | P_BIGDATA)) {
                                p += sizeof(u_char);
                                if (flags & P_BIGKEY) {
-                                       BLPSWAP(p);
+                                       P_32_SWAP(p);
                                        p += sizeof(pgno_t);
                                        p += sizeof(pgno_t);
-                                       BLPSWAP(p);
+                                       P_32_SWAP(p);
                                }
                                if (flags & P_BIGDATA) {
                                        p += sizeof(size_t);
                                }
                                if (flags & P_BIGDATA) {
                                        p += sizeof(size_t);
-                                       BLPSWAP(p);
+                                       P_32_SWAP(p);
                                        p += sizeof(pgno_t);
                                        p += sizeof(pgno_t);
-                                       BLPSWAP(p);
+                                       P_32_SWAP(p);
                                }
                        }
                }
                                }
                        }
                }
@@ -106,7 +106,7 @@ __bt_pgout(t, pg, pp)
        void *pp;
 {
        PAGE *h;
        void *pp;
 {
        PAGE *h;
-       int i, top;
+       indx_t i, top;
        u_char flags;
        char *p;
 
        u_char flags;
        char *p;
 
@@ -122,49 +122,49 @@ __bt_pgout(t, pg, pp)
        if ((h->flags & P_TYPE) == P_BINTERNAL)
                for (i = 0; i < top; i++) {
                        p = (char *)GETBINTERNAL(h, i);
        if ((h->flags & P_TYPE) == P_BINTERNAL)
                for (i = 0; i < top; i++) {
                        p = (char *)GETBINTERNAL(h, i);
-                       BLPSWAP(p);
+                       P_32_SWAP(p);
                        p += sizeof(size_t);
                        p += sizeof(size_t);
-                       BLPSWAP(p);
+                       P_32_SWAP(p);
                        p += sizeof(pgno_t);
                        if (*(u_char *)p & P_BIGKEY) {
                                p += sizeof(u_char);
                        p += sizeof(pgno_t);
                        if (*(u_char *)p & P_BIGKEY) {
                                p += sizeof(u_char);
-                               BLPSWAP(p);
+                               P_32_SWAP(p);
                                p += sizeof(pgno_t);
                                p += sizeof(pgno_t);
-                               BLPSWAP(p);
+                               P_32_SWAP(p);
                        }
                        }
-                       BSSWAP(h->linp[i]);
+                       M_16_SWAP(h->linp[i]);
                }
        else if ((h->flags & P_TYPE) == P_BLEAF)
                for (i = 0; i < top; i++) {
                        p = (char *)GETBLEAF(h, i);
                }
        else if ((h->flags & P_TYPE) == P_BLEAF)
                for (i = 0; i < top; i++) {
                        p = (char *)GETBLEAF(h, i);
-                       BLPSWAP(p);
+                       P_32_SWAP(p);
                        p += sizeof(size_t);
                        p += sizeof(size_t);
-                       BLPSWAP(p);
+                       P_32_SWAP(p);
                        p += sizeof(size_t);
                        flags = *(u_char *)p;
                        if (flags & (P_BIGKEY | P_BIGDATA)) {
                                p += sizeof(u_char);
                                if (flags & P_BIGKEY) {
                        p += sizeof(size_t);
                        flags = *(u_char *)p;
                        if (flags & (P_BIGKEY | P_BIGDATA)) {
                                p += sizeof(u_char);
                                if (flags & P_BIGKEY) {
-                                       BLPSWAP(p);
+                                       P_32_SWAP(p);
                                        p += sizeof(pgno_t);
                                        p += sizeof(pgno_t);
-                                       BLPSWAP(p);
+                                       P_32_SWAP(p);
                                }
                                if (flags & P_BIGDATA) {
                                        p += sizeof(size_t);
                                }
                                if (flags & P_BIGDATA) {
                                        p += sizeof(size_t);
-                                       BLPSWAP(p);
+                                       P_32_SWAP(p);
                                        p += sizeof(pgno_t);
                                        p += sizeof(pgno_t);
-                                       BLPSWAP(p);
+                                       P_32_SWAP(p);
                                }
                        }
                                }
                        }
-                       BSSWAP(h->linp[i]);
+                       M_16_SWAP(h->linp[i]);
                }
 
                }
 
-       BLSWAP(h->pgno);
-       BLSWAP(h->prevpg);
-       BLSWAP(h->nextpg);
-       BLSWAP(h->flags);
-       BSSWAP(h->lower);
-       BSSWAP(h->upper);
+       M_32_SWAP(h->pgno);
+       M_32_SWAP(h->prevpg);
+       M_32_SWAP(h->nextpg);
+       M_32_SWAP(h->flags);
+       M_16_SWAP(h->lower);
+       M_16_SWAP(h->upper);
 }
 
 /*
 }
 
 /*
@@ -180,16 +180,16 @@ mswap(pg)
        char *p;
 
        p = (char *)pg;
        char *p;
 
        p = (char *)pg;
-       BLPSWAP(p);             /* m_magic */
-       p += sizeof(u_long);
-       BLPSWAP(p);             /* m_version */
-       p += sizeof(u_long);
-       BLPSWAP(p);             /* m_psize */
-       p += sizeof(u_long);
-       BLPSWAP(p);             /* m_free */
-       p += sizeof(u_long);
-       BLPSWAP(p);             /* m_nrecs */
-       p += sizeof(u_long);
-       BLPSWAP(p);             /* m_flags */
-       p += sizeof(u_long);
+       P_32_SWAP(p);           /* m_magic */
+       p += sizeof(u_int32_t);
+       P_32_SWAP(p);           /* m_version */
+       p += sizeof(u_int32_t);
+       P_32_SWAP(p);           /* m_psize */
+       p += sizeof(u_int32_t);
+       P_32_SWAP(p);           /* m_free */
+       p += sizeof(u_int32_t);
+       P_32_SWAP(p);           /* m_nrecs */
+       p += sizeof(u_int32_t);
+       P_32_SWAP(p);           /* m_flags */
+       p += sizeof(u_int32_t);
 }
 }
index 884ed41..6975fca 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_debug.c 8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)bt_debug.c 8.2 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
@@ -229,9 +229,8 @@ void
 __bt_stat(dbp)
        DB *dbp;
 {
 __bt_stat(dbp)
        DB *dbp;
 {
-       extern u_long bt_cache_hit, bt_cache_miss;
-       extern u_long bt_rootsplit, bt_split, bt_sortsplit;
-       extern u_long bt_pfxsaved;
+       extern u_long bt_cache_hit, bt_cache_miss, bt_pfxsaved, bt_rootsplit;
+       extern u_long bt_sortsplit, bt_split;
        BTREE *t;
        PAGE *h;
        pgno_t i, pcont, pinternal, pleaf;
        BTREE *t;
        PAGE *h;
        pgno_t i, pcont, pinternal, pleaf;
index 5f6ad2f..5bf7235 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_delete.c        8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)bt_delete.c        8.3 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -253,12 +253,11 @@ int
 __bt_dleaf(t, h, index)
        BTREE *t;
        PAGE *h;
 __bt_dleaf(t, h, index)
        BTREE *t;
        PAGE *h;
-       int index;
+       indx_t index;
 {
        register BLEAF *bl;
 {
        register BLEAF *bl;
-       register indx_t *ip, offset;
+       register indx_t cnt, *ip, offset;
        register size_t nbytes;
        register size_t nbytes;
-       register int cnt;
        char *from;
        void *to;
 
        char *from;
        void *to;
 
index 7028dd1..c77f04c 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_open.c  8.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)bt_open.c  8.4 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 /*
 #endif /* LIBC_SCCS and not lint */
 
 /*
@@ -32,7 +32,6 @@ static char sccsid[] = "@(#)bt_open.c 8.3 (Berkeley) %G%";
 #include <string.h>
 #include <unistd.h>
 
 #include <string.h>
 #include <unistd.h>
 
-#define        __DBINTERFACE_PRIVATE
 #include <db.h>
 #include "btree.h"
 
 #include <db.h>
 #include "btree.h"
 
@@ -62,13 +61,14 @@ __bt_open(fname, flags, mode, openinfo, dflags)
        int flags, mode, dflags;
        const BTREEINFO *openinfo;
 {
        int flags, mode, dflags;
        const BTREEINFO *openinfo;
 {
+       struct stat sb;
        BTMETA m;
        BTREE *t;
        BTREEINFO b;
        DB *dbp;
        pgno_t ncache;
        BTMETA m;
        BTREE *t;
        BTREEINFO b;
        DB *dbp;
        pgno_t ncache;
-       struct stat sb;
-       int machine_lorder, nr;
+       ssize_t nr;
+       int machine_lorder;
 
        t = NULL;
 
 
        t = NULL;
 
@@ -206,12 +206,12 @@ __bt_open(fname, flags, mode, openinfo, dflags)
                        CLR(t, B_NEEDSWAP);
                else {
                        SET(t, B_NEEDSWAP);
                        CLR(t, B_NEEDSWAP);
                else {
                        SET(t, B_NEEDSWAP);
-                       BLSWAP(m.m_magic);
-                       BLSWAP(m.m_version);
-                       BLSWAP(m.m_psize);
-                       BLSWAP(m.m_free);
-                       BLSWAP(m.m_nrecs);
-                       BLSWAP(m.m_flags);
+                       M_32_SWAP(m.m_magic);
+                       M_32_SWAP(m.m_version);
+                       M_32_SWAP(m.m_psize);
+                       M_32_SWAP(m.m_free);
+                       M_32_SWAP(m.m_nrecs);
+                       M_32_SWAP(m.m_flags);
                }
                if (m.m_magic != BTREEMAGIC || m.m_version != BTREEVERSION)
                        goto eftype;
                }
                if (m.m_magic != BTREEMAGIC || m.m_version != BTREEVERSION)
                        goto eftype;
@@ -376,7 +376,7 @@ tmp()
 static int
 byteorder()
 {
 static int
 byteorder()
 {
-       u_long x;                       /* XXX: 32-bit assumption. */
+       u_int32_t x;
        u_char *p;
 
        x = 0x01020304;
        u_char *p;
 
        x = 0x01020304;
index 3f9ca92..ca20726 100644 (file)
@@ -6,12 +6,11 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_page.c  8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)bt_page.c  8.2 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 
-#define        __DBINTERFACE_PRIVATE
 #include <stdio.h>
 
 #include <db.h>
 #include <stdio.h>
 
 #include <db.h>
index 09b78d2..ea07bf6 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_search.c        8.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)bt_search.c        8.5 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -42,9 +42,9 @@ __bt_search(t, key, exactp)
        int *exactp;
 {
        PAGE *h, *n;
        int *exactp;
 {
        PAGE *h, *n;
-       indx_t index;
+       indx_t base, index, lim;
        pgno_t pg;
        pgno_t pg;
-       int base, cmp, lim;
+       int cmp;
 
        BT_CLR(t);
        for (pg = P_ROOT;;) {
 
        BT_CLR(t);
        for (pg = P_ROOT;;) {
index 725e87d..95d91d1 100644 (file)
@@ -9,12 +9,11 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_split.c 8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)bt_split.c 8.2 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 
-#define        __DBINTERFACE_PRIVATE
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -25,12 +24,12 @@ static char sccsid[] = "@(#)bt_split.c      8.1 (Berkeley) %G%";
 
 static int      bt_broot __P((BTREE *, PAGE *, PAGE *, PAGE *));
 static PAGE    *bt_page
 
 static int      bt_broot __P((BTREE *, PAGE *, PAGE *, PAGE *));
 static PAGE    *bt_page
-                   __P((BTREE *, PAGE *, PAGE **, PAGE **, u_int *, size_t));
+                   __P((BTREE *, PAGE *, PAGE **, PAGE **, indx_t *, size_t));
 static int      bt_preserve __P((BTREE *, pgno_t));
 static PAGE    *bt_psplit
 static int      bt_preserve __P((BTREE *, pgno_t));
 static PAGE    *bt_psplit
-                   __P((BTREE *, PAGE *, PAGE *, PAGE *, u_int *, size_t));
+                   __P((BTREE *, PAGE *, PAGE *, PAGE *, indx_t *, size_t));
 static PAGE    *bt_root
 static PAGE    *bt_root
-                   __P((BTREE *, PAGE *, PAGE **, PAGE **, u_int *, size_t));
+                   __P((BTREE *, PAGE *, PAGE **, PAGE **, indx_t *, size_t));
 static int      bt_rroot __P((BTREE *, PAGE *, PAGE *, PAGE *));
 static recno_t  rec_total __P((PAGE *));
 
 static int      bt_rroot __P((BTREE *, PAGE *, PAGE *, PAGE *));
 static recno_t  rec_total __P((PAGE *));
 
@@ -58,9 +57,9 @@ __bt_split(t, sp, key, data, flags, ilen, skip)
        BTREE *t;
        PAGE *sp;
        const DBT *key, *data;
        BTREE *t;
        PAGE *sp;
        const DBT *key, *data;
-       u_long flags;
+       int flags;
        size_t ilen;
        size_t ilen;
-       u_int skip;
+       indx_t skip;
 {
        BINTERNAL *bi;
        BLEAF *bl, *tbl;
 {
        BINTERNAL *bi;
        BLEAF *bl, *tbl;
@@ -317,7 +316,7 @@ static PAGE *
 bt_page(t, h, lp, rp, skip, ilen)
        BTREE *t;
        PAGE *h, **lp, **rp;
 bt_page(t, h, lp, rp, skip, ilen)
        BTREE *t;
        PAGE *h, **lp, **rp;
-       u_int *skip;
+       indx_t *skip;
        size_t ilen;
 {
        PAGE *l, *r, *tp;
        size_t ilen;
 {
        PAGE *l, *r, *tp;
@@ -419,7 +418,7 @@ static PAGE *
 bt_root(t, h, lp, rp, skip, ilen)
        BTREE *t;
        PAGE *h, **lp, **rp;
 bt_root(t, h, lp, rp, skip, ilen)
        BTREE *t;
        PAGE *h, **lp, **rp;
-       u_int *skip;
+       indx_t *skip;
        size_t ilen;
 {
        PAGE *l, *r, *tp;
        size_t ilen;
 {
        PAGE *l, *r, *tp;
@@ -583,7 +582,7 @@ static PAGE *
 bt_psplit(t, h, l, r, pskip, ilen)
        BTREE *t;
        PAGE *h, *l, *r;
 bt_psplit(t, h, l, r, pskip, ilen)
        BTREE *t;
        PAGE *h, *l, *r;
-       u_int *pskip;
+       indx_t *pskip;
        size_t ilen;
 {
        BINTERNAL *bi;
        size_t ilen;
 {
        BINTERNAL *bi;
index d4c09e6..b57c02e 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_stack.c 8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)bt_stack.c 8.2 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -48,7 +48,7 @@ int
 __bt_push(t, pgno, index)
        BTREE *t;
        pgno_t pgno;
 __bt_push(t, pgno, index)
        BTREE *t;
        pgno_t pgno;
-       int index;
+       indx_t index;
 {
        if (t->bt_sp == t->bt_maxstack) {
                t->bt_maxstack += 50;
 {
        if (t->bt_sp == t->bt_maxstack) {
                t->bt_maxstack += 50;
index 8dc05fb..586a9d7 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_utils.c 8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)bt_utils.c 8.3 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
@@ -175,14 +175,20 @@ int
 __bt_defcmp(a, b)
        const DBT *a, *b;
 {
 __bt_defcmp(a, b)
        const DBT *a, *b;
 {
+       register size_t len;
        register u_char *p1, *p2;
        register u_char *p1, *p2;
-       register int diff, len;
 
 
+       /*
+        * XXX
+        * If a size_t doesn't fit in an int, this routine can lose.
+        * What we need is a integral type which is guaranteed to be
+        * larger than a size_t, and there is no such thing.
+        */
        len = MIN(a->size, b->size);
        for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2)
        len = MIN(a->size, b->size);
        for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2)
-               if (diff = *p1 - *p2)
-                       return (diff);
-       return (a->size - b->size);
+               if (*p1 != *p2)
+                       return ((int)*p1 - (int)*p2);
+       return ((int)a->size - (int)b->size);
 }
 
 /*
 }
 
 /*
@@ -195,13 +201,12 @@ __bt_defcmp(a, b)
  * Returns:
  *     Number of bytes needed to distinguish b from a.
  */
  * Returns:
  *     Number of bytes needed to distinguish b from a.
  */
-int
+size_t
 __bt_defpfx(a, b)
        const DBT *a, *b;
 {
        register u_char *p1, *p2;
 __bt_defpfx(a, b)
        const DBT *a, *b;
 {
        register u_char *p1, *p2;
-       register int len;
-       int cnt;
+       register size_t cnt, len;
 
        cnt = 1;
        len = MIN(a->size, b->size);
 
        cnt = 1;
        len = MIN(a->size, b->size);
index da3ff78..58ceaf1 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)btree.h     8.4 (Berkeley) %G%
+ *     @(#)btree.h     8.5 (Berkeley) %G%
  */
 
 #include <mpool.h>
  */
 
 #include <mpool.h>
@@ -29,7 +29,7 @@
  * There are five page layouts in the btree: btree internal pages (BINTERNAL),
  * btree leaf pages (BLEAF), recno internal pages (RINTERNAL), recno leaf pages
  * (RLEAF) and overflow pages.  All five page types have a page header (PAGE).
  * There are five page layouts in the btree: btree internal pages (BINTERNAL),
  * btree leaf pages (BLEAF), recno internal pages (RINTERNAL), recno leaf pages
  * (RLEAF) and overflow pages.  All five page types have a page header (PAGE).
- * This implementation requires that longs within structures are NOT padded.
+ * This implementation requires that values within structures NOT be padded.
  * (ANSI C permits random padding.)  If your compiler pads randomly you'll have
  * to do some work to get this package to run.
  */
  * (ANSI C permits random padding.)  If your compiler pads randomly you'll have
  * to do some work to get this package to run.
  */
@@ -44,18 +44,17 @@ typedef struct _page {
 #define        P_RINTERNAL     0x08            /* recno internal page */
 #define        P_RLEAF         0x10            /* leaf page */
 #define P_TYPE         0x1f            /* type mask */
 #define        P_RINTERNAL     0x08            /* recno internal page */
 #define        P_RLEAF         0x10            /* leaf page */
 #define P_TYPE         0x1f            /* type mask */
-
 #define        P_PRESERVE      0x20            /* never delete this chain of pages */
 #define        P_PRESERVE      0x20            /* never delete this chain of pages */
-       u_long  flags;
+       u_int32_t flags;
 
        indx_t  lower;                  /* lower bound of free space on page */
        indx_t  upper;                  /* upper bound of free space on page */
 
        indx_t  lower;                  /* lower bound of free space on page */
        indx_t  upper;                  /* upper bound of free space on page */
-       indx_t  linp[1];                /* long-aligned VARIABLE LENGTH DATA */
+       indx_t  linp[1];                /* indx_t-aligned VAR. LENGTH DATA */
 } PAGE;
 
 /* First and next index. */
 #define        BTDATAOFF       (sizeof(pgno_t) + sizeof(pgno_t) + sizeof(pgno_t) + \
 } PAGE;
 
 /* First and next index. */
 #define        BTDATAOFF       (sizeof(pgno_t) + sizeof(pgno_t) + sizeof(pgno_t) + \
-                           sizeof(u_long) + sizeof(indx_t) + sizeof(indx_t))
+                           sizeof(u_int32_t) + sizeof(indx_t) + sizeof(indx_t))
 #define        NEXTINDEX(p)    (((p)->lower - BTDATAOFF) / sizeof(indx_t))
 
 /*
 #define        NEXTINDEX(p)    (((p)->lower - BTDATAOFF) / sizeof(indx_t))
 
 /*
@@ -70,10 +69,12 @@ typedef struct _page {
  * chain with size bytes of item.  Overflow pages are simply bytes without any
  * external structure.
  *
  * chain with size bytes of item.  Overflow pages are simply bytes without any
  * external structure.
  *
- * The size and page number fields in the items are long aligned so they can be
- * manipulated without copying.
+ * The page number and size fields in the items are pgno_t-aligned so they can
+ * be manipulated without copying.  (This presumes that 32 bit items can be
+ * manipulated on this system.)
  */
  */
-#define        LALIGN(n)       (((n) + sizeof(u_long) - 1) & ~(sizeof(u_long) - 1))
+#define        LALIGN(n) \
+       (((n) + sizeof(pgno_t) - 1) & ~(sizeof(pgno_t) - 1))
 #define        NOVFLSIZE       (sizeof(pgno_t) + sizeof(size_t))
 
 /*
 #define        NOVFLSIZE       (sizeof(pgno_t) + sizeof(size_t))
 
 /*
@@ -228,14 +229,14 @@ typedef struct _epg {
  * put or delete call modify the metadata.
  */
 typedef struct _btmeta {
  * put or delete call modify the metadata.
  */
 typedef struct _btmeta {
-       u_long  m_magic;                /* magic number */
-       u_long  m_version;              /* version */
-       u_long  m_psize;                /* page size */
-       u_long  m_free;                 /* page number of first free page */
-       u_long  m_nrecs;                /* R: number of records */
+       u_int32_t       m_magic;        /* magic number */
+       u_int32_t       m_version;      /* version */
+       u_int32_t       m_psize;        /* page size */
+       u_int32_t       m_free;         /* page number of first free page */
+       u_int32_t       m_nrecs;        /* R: number of records */
 #define        SAVEMETA        (B_NODUPS | R_RECNO)
 #define        SAVEMETA        (B_NODUPS | R_RECNO)
-       u_long  m_flags;                /* bt_flags & SAVEMETA */
-       u_long  m_unused;               /* unused */
+       u_int32_t       m_flags;        /* bt_flags & SAVEMETA */
+       u_int32_t       m_unused;       /* unused */
 } BTMETA;
 
 /* The in-memory btree/recno data structure. */
 } BTMETA;
 
 /* The in-memory btree/recno data structure. */
@@ -264,7 +265,7 @@ typedef struct _btree {
        int     bt_fd;                  /* tree file descriptor */
 
        pgno_t  bt_free;                /* next free page */
        int     bt_fd;                  /* tree file descriptor */
 
        pgno_t  bt_free;                /* next free page */
-       u_long  bt_psize;               /* page size */
+       u_int32_t bt_psize;             /* page size */
        indx_t  bt_ovflsize;            /* cut-off for key/data overflow */
        int     bt_lorder;              /* byte order */
                                        /* sorted order */
        indx_t  bt_ovflsize;            /* cut-off for key/data overflow */
        int     bt_lorder;              /* byte order */
                                        /* sorted order */
@@ -274,7 +275,7 @@ typedef struct _btree {
                                        /* B: key comparison function */
        int     (*bt_cmp) __P((const DBT *, const DBT *));
                                        /* B: prefix comparison function */
                                        /* B: key comparison function */
        int     (*bt_cmp) __P((const DBT *, const DBT *));
                                        /* B: prefix comparison function */
-       int     (*bt_pfx) __P((const DBT *, const DBT *));
+       size_t  (*bt_pfx) __P((const DBT *, const DBT *));
                                        /* R: recno input function */
        int     (*bt_irec) __P((struct _btree *, recno_t));
 
                                        /* R: recno input function */
        int     (*bt_irec) __P((struct _btree *, recno_t));
 
@@ -316,7 +317,7 @@ typedef struct _btree {
 #define        B_DB_SHMEM      0x20000         /* DB_SHMEM specified. */
 #define        B_DB_TXN        0x40000         /* DB_TXN specified. */
 
 #define        B_DB_SHMEM      0x20000         /* DB_SHMEM specified. */
 #define        B_DB_TXN        0x40000         /* DB_TXN specified. */
 
-       u_long          bt_flags;       /* btree state */
+       u_int32_t       bt_flags;       /* btree state */
 } BTREE;
 
 #define        SET(t, f)       ((t)->bt_flags |= (f))
 } BTREE;
 
 #define        SET(t, f)       ((t)->bt_flags |= (f))
index db5d49f..79e52b0 100644 (file)
@@ -4,14 +4,14 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)extern.h    8.2 (Berkeley) %G%
+ *     @(#)extern.h    8.3 (Berkeley) %G%
  */
 
 int     __bt_close __P((DB *));
 int     __bt_cmp __P((BTREE *, const DBT *, EPG *));
 int     __bt_crsrdel __P((BTREE *, EPGNO *));
 int     __bt_defcmp __P((const DBT *, const DBT *));
  */
 
 int     __bt_close __P((DB *));
 int     __bt_cmp __P((BTREE *, const DBT *, EPG *));
 int     __bt_crsrdel __P((BTREE *, EPGNO *));
 int     __bt_defcmp __P((const DBT *, const DBT *));
-int     __bt_defpfx __P((const DBT *, const DBT *));
+size_t  __bt_defpfx __P((const DBT *, const DBT *));
 int     __bt_delete __P((const DB *, const DBT *, u_int));
 int     __bt_dleaf __P((BTREE *, PAGE *, int));
 int     __bt_fd __P((const DB *));
 int     __bt_delete __P((const DB *, const DBT *, u_int));
 int     __bt_dleaf __P((BTREE *, PAGE *, int));
 int     __bt_fd __P((const DB *));
@@ -27,7 +27,7 @@ int    __bt_ret __P((BTREE *, EPG *, DBT *, DBT *));
 EPG    *__bt_search __P((BTREE *, const DBT *, int *));
 int     __bt_seq __P((const DB *, DBT *, DBT *, u_int));
 int     __bt_split __P((BTREE *, PAGE *,
 EPG    *__bt_search __P((BTREE *, const DBT *, int *));
 int     __bt_seq __P((const DB *, DBT *, DBT *, u_int));
 int     __bt_split __P((BTREE *, PAGE *,
-           const DBT *, const DBT *, u_long, size_t, u_int));
+           const DBT *, const DBT *, int, size_t, indx_t));
 int     __bt_sync __P((const DB *, u_int));
 
 int     __ovfl_delete __P((BTREE *, void *));
 int     __bt_sync __P((const DB *, u_int));
 
 int     __ovfl_delete __P((BTREE *, void *));
index 47a32d6..7c9c51b 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)extern.h    8.1 (Berkeley) %G%
+ *     @(#)extern.h    8.2 (Berkeley) %G%
  */
 
 BUFHEAD        *__add_ovflpage __P((HTAB *, BUFHEAD *));
  */
 
 BUFHEAD        *__add_ovflpage __P((HTAB *, BUFHEAD *));
@@ -32,7 +32,7 @@ void   __reclaim_buf __P((HTAB *, BUFHEAD *));
 int     __split_page __P((HTAB *, u_int, u_int));
 
 /* Default hash routine. */
 int     __split_page __P((HTAB *, u_int, u_int));
 
 /* Default hash routine. */
-extern int     (*__default_hash) __P((u_char *, int));
+extern u_int32_t (*__default_hash) __P((const void *, size_t));
 
 #ifdef HASH_STATISTICS
 extern long hash_accesses, hash_collisions, hash_expansions, hash_overflows;
 
 #ifdef HASH_STATISTICS
 extern long hash_accesses, hash_collisions, hash_expansions, hash_overflows;
index 9f6220d..d3d67b8 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hash.c     8.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)hash.c     8.6 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
@@ -910,26 +910,26 @@ swap_header_copy(srcp, destp)
 {
        int i;
 
 {
        int i;
 
-       BLSWAP_COPY(srcp->magic, destp->magic);
-       BLSWAP_COPY(srcp->version, destp->version);
-       BLSWAP_COPY(srcp->lorder, destp->lorder);
-       BLSWAP_COPY(srcp->bsize, destp->bsize);
-       BLSWAP_COPY(srcp->bshift, destp->bshift);
-       BLSWAP_COPY(srcp->dsize, destp->dsize);
-       BLSWAP_COPY(srcp->ssize, destp->ssize);
-       BLSWAP_COPY(srcp->sshift, destp->sshift);
-       BLSWAP_COPY(srcp->ovfl_point, destp->ovfl_point);
-       BLSWAP_COPY(srcp->last_freed, destp->last_freed);
-       BLSWAP_COPY(srcp->max_bucket, destp->max_bucket);
-       BLSWAP_COPY(srcp->high_mask, destp->high_mask);
-       BLSWAP_COPY(srcp->low_mask, destp->low_mask);
-       BLSWAP_COPY(srcp->ffactor, destp->ffactor);
-       BLSWAP_COPY(srcp->nkeys, destp->nkeys);
-       BLSWAP_COPY(srcp->hdrpages, destp->hdrpages);
-       BLSWAP_COPY(srcp->h_charkey, destp->h_charkey);
+       P_32_COPY(srcp->magic, destp->magic);
+       P_32_COPY(srcp->version, destp->version);
+       P_32_COPY(srcp->lorder, destp->lorder);
+       P_32_COPY(srcp->bsize, destp->bsize);
+       P_32_COPY(srcp->bshift, destp->bshift);
+       P_32_COPY(srcp->dsize, destp->dsize);
+       P_32_COPY(srcp->ssize, destp->ssize);
+       P_32_COPY(srcp->sshift, destp->sshift);
+       P_32_COPY(srcp->ovfl_point, destp->ovfl_point);
+       P_32_COPY(srcp->last_freed, destp->last_freed);
+       P_32_COPY(srcp->max_bucket, destp->max_bucket);
+       P_32_COPY(srcp->high_mask, destp->high_mask);
+       P_32_COPY(srcp->low_mask, destp->low_mask);
+       P_32_COPY(srcp->ffactor, destp->ffactor);
+       P_32_COPY(srcp->nkeys, destp->nkeys);
+       P_32_COPY(srcp->hdrpages, destp->hdrpages);
+       P_32_COPY(srcp->h_charkey, destp->h_charkey);
        for (i = 0; i < NCACHED; i++) {
        for (i = 0; i < NCACHED; i++) {
-               BLSWAP_COPY(srcp->spares[i], destp->spares[i]);
-               BSSWAP_COPY(srcp->bitmaps[i], destp->bitmaps[i]);
+               P_32_COPY(srcp->spares[i], destp->spares[i]);
+               P_16_COPY(srcp->bitmaps[i], destp->bitmaps[i]);
        }
 }
 
        }
 }
 
@@ -942,26 +942,26 @@ swap_header(hashp)
 
        hdrp = &hashp->hdr;
 
 
        hdrp = &hashp->hdr;
 
-       BLSWAP(hdrp->magic);
-       BLSWAP(hdrp->version);
-       BLSWAP(hdrp->lorder);
-       BLSWAP(hdrp->bsize);
-       BLSWAP(hdrp->bshift);
-       BLSWAP(hdrp->dsize);
-       BLSWAP(hdrp->ssize);
-       BLSWAP(hdrp->sshift);
-       BLSWAP(hdrp->ovfl_point);
-       BLSWAP(hdrp->last_freed);
-       BLSWAP(hdrp->max_bucket);
-       BLSWAP(hdrp->high_mask);
-       BLSWAP(hdrp->low_mask);
-       BLSWAP(hdrp->ffactor);
-       BLSWAP(hdrp->nkeys);
-       BLSWAP(hdrp->hdrpages);
-       BLSWAP(hdrp->h_charkey);
+       M_32_SWAP(hdrp->magic);
+       M_32_SWAP(hdrp->version);
+       M_32_SWAP(hdrp->lorder);
+       M_32_SWAP(hdrp->bsize);
+       M_32_SWAP(hdrp->bshift);
+       M_32_SWAP(hdrp->dsize);
+       M_32_SWAP(hdrp->ssize);
+       M_32_SWAP(hdrp->sshift);
+       M_32_SWAP(hdrp->ovfl_point);
+       M_32_SWAP(hdrp->last_freed);
+       M_32_SWAP(hdrp->max_bucket);
+       M_32_SWAP(hdrp->high_mask);
+       M_32_SWAP(hdrp->low_mask);
+       M_32_SWAP(hdrp->ffactor);
+       M_32_SWAP(hdrp->nkeys);
+       M_32_SWAP(hdrp->hdrpages);
+       M_32_SWAP(hdrp->h_charkey);
        for (i = 0; i < NCACHED; i++) {
        for (i = 0; i < NCACHED; i++) {
-               BLSWAP(hdrp->spares[i]);
-               BSSWAP(hdrp->bitmaps[i]);
+               M_32_SWAP(hdrp->spares[i]);
+               M_16_SWAP(hdrp->bitmaps[i]);
        }
 }
 #endif
        }
 }
 #endif
index 6658966..33cce8c 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)hash.h      8.1 (Berkeley) %G%
+ *     @(#)hash.h      8.2 (Berkeley) %G%
  */
 
 /* Operations */
  */
 
 /* Operations */
@@ -63,7 +63,8 @@ typedef struct htab {         /* Memory resident data structure */
        HASHHDR hdr;            /* Header */
        int     nsegs;          /* Number of allocated segments */
        int     exsegs;         /* Number of extra allocated segments */
        HASHHDR hdr;            /* Header */
        int     nsegs;          /* Number of allocated segments */
        int     exsegs;         /* Number of extra allocated segments */
-       int     (*hash) ();     /* Hash Function */
+       u_int32_t               /* Hash function */
+           (*hash)__P((const void *, size_t));
        int     flags;          /* Flag values */
        int     fp;             /* File pointer */
        char    *tmp_buf;       /* Temporary Buffer for BIG data */
        int     flags;          /* Flag values */
        int     fp;             /* File pointer */
        char    *tmp_buf;       /* Temporary Buffer for BIG data */
index 0810613..d1493b2 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hash_func.c        8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)hash_func.c        8.2 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -19,16 +19,17 @@ static char sccsid[] = "@(#)hash_func.c     8.1 (Berkeley) %G%";
 #include "page.h"
 #include "extern.h"
 
 #include "page.h"
 #include "extern.h"
 
-static int hash1 __P((u_char *, int));
-static int hash2 __P((u_char *, int));
-static int hash3 __P((u_char *, int));
-static int hash4 __P((u_char *, int));
+static u_int32_t hash1 __P((const void *, size_t));
+static u_int32_t hash2 __P((const void *, size_t));
+static u_int32_t hash3 __P((const void *, size_t));
+static u_int32_t hash4 __P((const void *, size_t));
 
 /* Global default hash function */
 
 /* Global default hash function */
-int (*__default_hash) __P((u_char *, int)) = hash4;
+u_int32_t (*__default_hash) __P((const void *, size_t)) = hash4;
 
 
-/******************************* HASH FUNCTIONS **************************/
 /*
 /*
+ * HASH FUNCTIONS
+ *
  * Assume that we've already split the bucket to which this key hashes,
  * calculate that bucket, and check that in fact we did already split it.
  *
  * Assume that we've already split the bucket to which this key hashes,
  * calculate that bucket, and check that in fact we did already split it.
  *
@@ -38,16 +39,16 @@ int (*__default_hash) __P((u_char *, int)) = hash4;
 #define PRIME1         37
 #define PRIME2         1048583
 
 #define PRIME1         37
 #define PRIME2         1048583
 
-static int
-hash1(key, len)
-       register u_char *key;
-       register int len;
+static u_int32_t
+hash1(keyarg, len)
+       const void *keyarg;
+       register size_t len;
 {
 {
-       register int h;
+       register const u_char *key;
+       register u_int32_t h;
 
 
-       h = 0;
        /* Convert string to integer */
        /* Convert string to integer */
-       while (len--)
+       for (key = keyarg, h = 0; len--;)
                h = h * PRIME1 ^ (*key++ - ' ');
        h %= PRIME2;
        return (h);
                h = h * PRIME1 ^ (*key++ - ' ');
        h %= PRIME2;
        return (h);
@@ -58,14 +59,16 @@ hash1(key, len)
  */
 #define dcharhash(h, c)        ((h) = 0x63c63cd9*(h) + 0x9c39c33d + (c))
 
  */
 #define dcharhash(h, c)        ((h) = 0x63c63cd9*(h) + 0x9c39c33d + (c))
 
-static int
-hash2(key, len)
-       register u_char *key;
-       int len;
+static u_int32_t
+hash2(keyarg, len)
+       const void *keyarg;
+       size_t len;
 {
 {
-       register u_char *e, c;
-       register int h;
+       register const u_char *e, *key;
+       register u_int32_t h;
+       register u_char c;
 
 
+       key = keyarg;
        e = key + len;
        for (h = 0; key != e;) {
                c = *key++;
        e = key + len;
        for (h = 0; key != e;) {
                c = *key++;
@@ -85,81 +88,99 @@ hash2(key, len)
  *
  * OZ's original sdbm hash
  */
  *
  * OZ's original sdbm hash
  */
-static int
-hash3(key, len)
-       register u_char *key;
-       register int len;
+static u_int32_t
+hash3(keyarg, len)
+       const void *keyarg;
+       register size_t len;
 {
 {
-       register int n, loop;
+       register const u_char *key;
+       register size_t loop;
+       register u_int32_t h;
 
 
-#define HASHC   n = *key++ + 65599 * n
+#define HASHC   h = *key++ + 65599 * h
 
 
-       n = 0;
+       h = 0;
+       key = keyarg;
        if (len > 0) {
                loop = (len + 8 - 1) >> 3;
 
                switch (len & (8 - 1)) {
                case 0:
        if (len > 0) {
                loop = (len + 8 - 1) >> 3;
 
                switch (len & (8 - 1)) {
                case 0:
-                       do {    /* All fall throughs */
+                       do {
                                HASHC;
                                HASHC;
+                               /* FALLTHROUGH */
                case 7:
                                HASHC;
                case 7:
                                HASHC;
+                               /* FALLTHROUGH */
                case 6:
                                HASHC;
                case 6:
                                HASHC;
+                               /* FALLTHROUGH */
                case 5:
                                HASHC;
                case 5:
                                HASHC;
+                               /* FALLTHROUGH */
                case 4:
                                HASHC;
                case 4:
                                HASHC;
+                               /* FALLTHROUGH */
                case 3:
                                HASHC;
                case 3:
                                HASHC;
+                               /* FALLTHROUGH */
                case 2:
                                HASHC;
                case 2:
                                HASHC;
+                               /* FALLTHROUGH */
                case 1:
                                HASHC;
                        } while (--loop);
                }
                case 1:
                                HASHC;
                        } while (--loop);
                }
-
        }
        }
-       return (n);
+       return (h);
 }
 
 /* Hash function from Chris Torek. */
 }
 
 /* Hash function from Chris Torek. */
-static int
-hash4(key, len)
-       register u_char *key;
-       register int len;
+static u_int32_t
+hash4(keyarg, len)
+       const void *keyarg;
+       register size_t len;
 {
 {
-       register int h, loop;
+       register const u_char *key;
+       register size_t loop;
+       register u_int32_t h;
 
 #define HASH4a   h = (h << 5) - h + *key++;
 #define HASH4b   h = (h << 5) + h + *key++;
 #define HASH4 HASH4b
 
        h = 0;
 
 #define HASH4a   h = (h << 5) - h + *key++;
 #define HASH4b   h = (h << 5) + h + *key++;
 #define HASH4 HASH4b
 
        h = 0;
+       key = keyarg;
        if (len > 0) {
                loop = (len + 8 - 1) >> 3;
 
                switch (len & (8 - 1)) {
                case 0:
        if (len > 0) {
                loop = (len + 8 - 1) >> 3;
 
                switch (len & (8 - 1)) {
                case 0:
-                       do {    /* All fall throughs */
+                       do {
                                HASH4;
                                HASH4;
+                               /* FALLTHROUGH */
                case 7:
                                HASH4;
                case 7:
                                HASH4;
+                               /* FALLTHROUGH */
                case 6:
                                HASH4;
                case 6:
                                HASH4;
+                               /* FALLTHROUGH */
                case 5:
                                HASH4;
                case 5:
                                HASH4;
+                               /* FALLTHROUGH */
                case 4:
                                HASH4;
                case 4:
                                HASH4;
+                               /* FALLTHROUGH */
                case 3:
                                HASH4;
                case 3:
                                HASH4;
+                               /* FALLTHROUGH */
                case 2:
                                HASH4;
                case 2:
                                HASH4;
+                               /* FALLTHROUGH */
                case 1:
                                HASH4;
                        } while (--loop);
                }
                case 1:
                                HASH4;
                        } while (--loop);
                }
-
        }
        return (h);
 }
        }
        return (h);
 }
index 945a595..18ba7aa 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hash_page.c        8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)hash_page.c        8.3 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 /*
 #endif /* LIBC_SCCS and not lint */
 
 /*
@@ -530,12 +530,12 @@ __get_page(hashp, p, bucket, is_bucket, is_disk, is_bitmap)
                        if (is_bitmap) {
                                max = hashp->BSIZE >> 2; /* divide by 4 */
                                for (i = 0; i < max; i++)
                        if (is_bitmap) {
                                max = hashp->BSIZE >> 2; /* divide by 4 */
                                for (i = 0; i < max; i++)
-                                       BLSWAP(((long *)p)[i]);
+                                       M_32_SWAP(((long *)p)[i]);
                        } else {
                        } else {
-                               BSSWAP(bp[0]);
+                               M_16_SWAP(bp[0]);
                                max = bp[0] + 2;
                                for (i = 1; i <= max; i++)
                                max = bp[0] + 2;
                                for (i = 1; i <= max; i++)
-                                       BSSWAP(bp[i]);
+                                       M_16_SWAP(bp[i]);
                        }
                }
        return (0);
                        }
                }
        return (0);
@@ -570,11 +570,11 @@ __put_page(hashp, p, bucket, is_bucket, is_bitmap)
                if (is_bitmap) {
                        max = hashp->BSIZE >> 2;        /* divide by 4 */
                        for (i = 0; i < max; i++)
                if (is_bitmap) {
                        max = hashp->BSIZE >> 2;        /* divide by 4 */
                        for (i = 0; i < max; i++)
-                               BLSWAP(((long *)p)[i]);
+                               M_32_SWAP(((long *)p)[i]);
                } else {
                        max = ((u_short *)p)[0] + 2;
                        for (i = 0; i <= max; i++)
                } else {
                        max = ((u_short *)p)[0] + 2;
                        for (i = 0; i <= max; i++)
-                               BSSWAP(((u_short *)p)[i]);
+                               M_16_SWAP(((u_short *)p)[i]);
                }
        }
        if (is_bucket)
                }
        }
        if (is_bucket)
index 5cacd68..4d16fdc 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hsearch.c  8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)hsearch.c  8.3 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -17,7 +17,6 @@ static char sccsid[] = "@(#)hsearch.c 8.2 (Berkeley) %G%";
 #include <fcntl.h>
 #include <string.h>
 
 #include <fcntl.h>
 #include <string.h>
 
-#define        __DBINTERFACE_PRIVATE
 #include <db.h>
 #include "search.h"
 
 #include <db.h>
 #include "search.h"
 
index ac39f11..e41d3a1 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .\" %sccs.include.redist.man%
 .\"
 .\"
 .\" %sccs.include.redist.man%
 .\"
-.\"    @(#)btree.3     8.2 (Berkeley) %G%
+.\"    @(#)btree.3     8.3 (Berkeley) %G%
 .\"
 .TH BTREE 3 ""
 .\".UC 7
 .\"
 .TH BTREE 3 ""
 .\".UC 7
@@ -42,11 +42,11 @@ int maxkeypage;
 .br
 int minkeypage;
 .br
 .br
 int minkeypage;
 .br
-index_t psize;
+u_int psize;
 .br
 int (*compare)(const DBT *key1, const DBT *key2);
 .br
 .br
 int (*compare)(const DBT *key1, const DBT *key2);
 .br
-int (*prefix)(const DBT *key1, const DBT *key2);
+size_t (*prefix)(const DBT *key1, const DBT *key2);
 .br
 int lorder;
 .RE
 .br
 int lorder;
 .RE
index f9324c8..ad28d96 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .\" %sccs.include.redist.man%
 .\"
 .\"
 .\" %sccs.include.redist.man%
 .\"
-.\"    @(#)hash.3      8.4 (Berkeley) %G%
+.\"    @(#)hash.3      8.5 (Berkeley) %G%
 .\"
 .TH HASH 3 ""
 .UC 7
 .\"
 .TH HASH 3 ""
 .UC 7
@@ -33,15 +33,15 @@ is defined in the <db.h> include file as follows:
 .sp
 typedef struct {
 .RS
 .sp
 typedef struct {
 .RS
-int bsize;
+u_int bsize;
 .br
 .br
-int ffactor;
+u_int ffactor;
 .br
 .br
-int nelem;
+u_int nelem;
 .br
 .br
-int cachesize;
+u_int cachesize;
 .br
 .br
-u_long (*hash)(const void *, size_t);
+u_int32_t (*hash)(const void *, size_t);
 .br
 int lorder;
 .RE
 .br
 int lorder;
 .RE
@@ -83,7 +83,8 @@ Since no hash function performs equally well on all possible data, the
 user may find that the built-in hash function does poorly on a particular
 data set.
 User specified hash functions must take two arguments (a pointer to a byte
 user may find that the built-in hash function does poorly on a particular
 data set.
 User specified hash functions must take two arguments (a pointer to a byte
-string and a length) and return an u_long to be used as the hash value.
+string and a length) and return a 32-bit quantity to be used as the hash
+value.
 .TP
 lorder
 The byte order for integers in the stored database metadata.
 .TP
 lorder
 The byte order for integers in the stored database metadata.
index 65a6388..3a11800 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .\" %sccs.include.redist.man%
 .\"
 .\"
 .\" %sccs.include.redist.man%
 .\"
-.\"    @(#)recno.3     8.2 (Berkeley) %G%
+.\"    @(#)recno.3     8.3 (Berkeley) %G%
 .\"
 .TH RECNO 3 ""
 .UC 7
 .\"
 .TH RECNO 3 ""
 .UC 7
@@ -44,7 +44,7 @@ u_long flags;
 .br
 u_int cachesize;
 .br
 .br
 u_int cachesize;
 .br
-index_t psize;
+u_int psize;
 .br
 int lorder;
 .br
 .br
 int lorder;
 .br
index 60ec89c..ea5694d 100644 (file)
@@ -4,14 +4,14 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)extern.h    8.1 (Berkeley) %G%
+ *     @(#)extern.h    8.2 (Berkeley) %G%
  */
 
 #include "../btree/extern.h"
 
 int     __rec_close __P((DB *));
 int     __rec_delete __P((const DB *, const DBT *, u_int));
  */
 
 #include "../btree/extern.h"
 
 int     __rec_close __P((DB *));
 int     __rec_delete __P((const DB *, const DBT *, u_int));
-int     __rec_dleaf __P((BTREE *, PAGE *, int));
+int     __rec_dleaf __P((BTREE *, PAGE *, indx_t));
 int     __rec_fd __P((const DB *));
 int     __rec_fmap __P((BTREE *, recno_t));
 int     __rec_fout __P((BTREE *));
 int     __rec_fd __P((const DB *));
 int     __rec_fmap __P((BTREE *, recno_t));
 int     __rec_fout __P((BTREE *));
index 1f8da16..c64c6b9 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rec_close.c        8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)rec_close.c        8.3 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -35,7 +35,7 @@ __rec_close(dbp)
        DB *dbp;
 {
        BTREE *t;
        DB *dbp;
 {
        BTREE *t;
-       int rval;
+       int status;
 
        t = dbp->internal;
 
 
        t = dbp->internal;
 
@@ -49,22 +49,22 @@ __rec_close(dbp)
                return (RET_ERROR);
 
        /* Committed to closing. */
                return (RET_ERROR);
 
        /* Committed to closing. */
-       rval = RET_SUCCESS;
+       status = RET_SUCCESS;
        if (ISSET(t, R_MEMMAPPED) && munmap(t->bt_smap, t->bt_msize))
        if (ISSET(t, R_MEMMAPPED) && munmap(t->bt_smap, t->bt_msize))
-               rval = RET_ERROR;
+               status = RET_ERROR;
 
        if (!ISSET(t, R_INMEM))
                if (ISSET(t, R_CLOSEFP)) {
                        if (fclose(t->bt_rfp))
 
        if (!ISSET(t, R_INMEM))
                if (ISSET(t, R_CLOSEFP)) {
                        if (fclose(t->bt_rfp))
-                               rval = RET_ERROR;
+                               status = RET_ERROR;
                } else
                        if (close(t->bt_rfd))
                } else
                        if (close(t->bt_rfd))
-                               rval = RET_ERROR;
+                               status = RET_ERROR;
 
        if (__bt_close(dbp) == RET_ERROR)
 
        if (__bt_close(dbp) == RET_ERROR)
-               rval = RET_ERROR;
+               status = RET_ERROR;
 
 
-       return (rval);
+       return (status);
 }
 
 /*
 }
 
 /*
index e576964..b160cf1 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rec_delete.c       8.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)rec_delete.c       8.4 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -128,12 +128,11 @@ int
 __rec_dleaf(t, h, index)
        BTREE *t;
        PAGE *h;
 __rec_dleaf(t, h, index)
        BTREE *t;
        PAGE *h;
-       int index;
+       indx_t index;
 {
        register RLEAF *rl;
 {
        register RLEAF *rl;
-       register indx_t *ip, offset;
+       register indx_t *ip, cnt, offset;
        register size_t nbytes;
        register size_t nbytes;
-       register int cnt;
        char *from;
        void *to;
 
        char *from;
        void *to;
 
index 9fabde7..c67023c 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rec_open.c 8.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)rec_open.c 8.5 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -23,7 +23,6 @@ static char sccsid[] = "@(#)rec_open.c        8.4 (Berkeley) %G%";
 #include <stdio.h>
 #include <unistd.h>
 
 #include <stdio.h>
 #include <unistd.h>
 
-#define        __DBINTERFACE_PRIVATE
 #include <db.h>
 #include "recno.h"
 
 #include <db.h>
 #include "recno.h"
 
index b2060f0..475ecdc 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rec_search.c       8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)rec_search.c       8.3 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -47,7 +47,7 @@ __rec_search(t, recno, op)
        pgno_t pg;
        indx_t top;
        recno_t total;
        pgno_t pg;
        indx_t top;
        recno_t total;
-       int serrno;
+       int sverrno;
 
        BT_CLR(t);
        for (pg = P_ROOT, total = 0;;) {
 
        BT_CLR(t);
        for (pg = P_ROOT, total = 0;;) {
@@ -85,7 +85,7 @@ __rec_search(t, recno, op)
 
        }
        /* Try and recover the tree. */
 
        }
        /* Try and recover the tree. */
-err:   serrno = errno;
+err:   sverrno = errno;
        if (op != SEARCH)
                while  ((parent = BT_POP(t)) != NULL) {
                        if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL)
        if (op != SEARCH)
                while  ((parent = BT_POP(t)) != NULL) {
                        if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL)
@@ -96,6 +96,6 @@ err:  serrno = errno;
                                ++GETRINTERNAL(h, parent->index)->nrecs;
                         mpool_put(t->bt_mp, h, MPOOL_DIRTY);
                 }
                                ++GETRINTERNAL(h, parent->index)->nrecs;
                         mpool_put(t->bt_mp, h, MPOOL_DIRTY);
                 }
-       errno = serrno;
+       errno = sverrno;
        return (NULL);
 }
        return (NULL);
 }