Commit b9dad25d authored by Martin Thomson's avatar Martin Thomson

Bug 1513913 - Rename symbols with __ names in dbm, r=jcj

These have been shown to collice.  This also renames two types: `struct __db`
and `__default_hash`.  A global, `__sigtemp` is also renamed (though removed
might be better, I don't want to do too much here).

I considered also renaming __DBINTERFACE_PRIVATE, but that is part of the
external interface.

--HG--
extra : source : dafd3408e5aa8fe1c9d127982a6d5e88bca7e00d
extra : amend_source : f282f42591ef9cf01aae8399b60534620b2f463d
parent 69203eee
......@@ -31,32 +31,32 @@
* @(#)extern.h 8.4 (Berkeley) 6/16/94
*/
BUFHEAD *__add_ovflpage(HTAB *, BUFHEAD *);
int __addel(HTAB *, BUFHEAD *, const DBT *, const DBT *);
int __big_delete(HTAB *, BUFHEAD *);
int __big_insert(HTAB *, BUFHEAD *, const DBT *, const DBT *);
int __big_keydata(HTAB *, BUFHEAD *, DBT *, DBT *, int);
int __big_return(HTAB *, BUFHEAD *, int, DBT *, int);
int __big_split(HTAB *, BUFHEAD *, BUFHEAD *, BUFHEAD *,
uint32, uint32, SPLIT_RETURN *);
int __buf_free(HTAB *, int, int);
void __buf_init(HTAB *, int);
uint32 __call_hash(HTAB *, char *, size_t);
int __delpair(HTAB *, BUFHEAD *, int);
int __expand_table(HTAB *);
int __find_bigpair(HTAB *, BUFHEAD *, int, char *, int);
uint16 __find_last_page(HTAB *, BUFHEAD **);
void __free_ovflpage(HTAB *, BUFHEAD *);
BUFHEAD *__get_buf(HTAB *, uint32, BUFHEAD *, int);
int __get_page(HTAB *, char *, uint32, int, int, int);
int __ibitmap(HTAB *, int, int, int);
uint32 __log2(uint32);
int __put_page(HTAB *, char *, uint32, int, int);
void __reclaim_buf(HTAB *, BUFHEAD *);
int __split_page(HTAB *, uint32, uint32);
BUFHEAD *dbm_add_ovflpage(HTAB *, BUFHEAD *);
int dbm_addel(HTAB *, BUFHEAD *, const DBT *, const DBT *);
int dbm_big_delete(HTAB *, BUFHEAD *);
int dbm_big_insert(HTAB *, BUFHEAD *, const DBT *, const DBT *);
int dbm_big_keydata(HTAB *, BUFHEAD *, DBT *, DBT *, int);
int dbm_big_return(HTAB *, BUFHEAD *, int, DBT *, int);
int dbm_big_split(HTAB *, BUFHEAD *, BUFHEAD *, BUFHEAD *,
uint32, uint32, SPLIT_RETURN *);
int dbm_buf_free(HTAB *, int, int);
void dbm_buf_init(HTAB *, int);
uint32 dbm_call_hash(HTAB *, char *, size_t);
int dbm_delpair(HTAB *, BUFHEAD *, int);
int dbm_expand_table(HTAB *);
int dbm_find_bigpair(HTAB *, BUFHEAD *, int, char *, int);
uint16 dbm_find_last_page(HTAB *, BUFHEAD **);
void dbm_free_ovflpage(HTAB *, BUFHEAD *);
BUFHEAD *dbm_get_buf(HTAB *, uint32, BUFHEAD *, int);
int dbm_get_page(HTAB *, char *, uint32, int, int, int);
int dbm_ibitmap(HTAB *, int, int, int);
uint32 dbm_log2(uint32);
int dbm_put_page(HTAB *, char *, uint32, int, int);
void dbm_reclaim_buf(HTAB *, BUFHEAD *);
int dbm_split_page(HTAB *, uint32, uint32);
/* Default hash routine. */
extern uint32 (*__default_hash)(const void *, size_t);
extern uint32 (*dbm_default_hash)(const void *, size_t);
#ifdef HASH_STATISTICS
extern int hash_accesses, hash_collisions, hash_expansions, hash_overflows;
......
......@@ -190,7 +190,7 @@ typedef struct htab { /* Memory resident data structure */
#define OADDR_OF(S, O) ((uint32)((uint32)(S) << SPLITSHIFT) + (O))
#define BUCKET_TO_PAGE(B) \
(B) + hashp->HDRPAGES + ((B) ? hashp->SPARES[__log2((uint32)((B) + 1)) - 1] : 0)
(B) + hashp->HDRPAGES + ((B) ? hashp->SPARES[dbm_log2((uint32)((B) + 1)) - 1] : 0)
#define OADDR_TO_PAGE(B) \
BUCKET_TO_PAGE((1 << SPLITNUM((B))) - 1) + OPAGENUM((B));
......@@ -314,28 +314,28 @@ typedef struct htab { /* Memory resident data structure */
#define NEXT_FREE hdr.next_free
#define H_CHARKEY hdr.h_charkey
extern uint32 (*__default_hash)(const void *, size_t);
void __buf_init(HTAB *hashp, int32 nbytes);
int __big_delete(HTAB *hashp, BUFHEAD *bufp);
BUFHEAD *__get_buf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp, int newpage);
uint32 __call_hash(HTAB *hashp, char *k, size_t len);
extern uint32 (*dbm_default_hash)(const void *, size_t);
void dbm_buf_init(HTAB *hashp, int32 nbytes);
int dbm_big_delete(HTAB *hashp, BUFHEAD *bufp);
BUFHEAD *dbm_get_buf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp, int newpage);
uint32 dbm_call_hash(HTAB *hashp, char *k, size_t len);
#include "page.h"
extern int __big_split(HTAB *hashp, BUFHEAD *op, BUFHEAD *np,
BUFHEAD *big_keyp, uint32 addr, uint32 obucket, SPLIT_RETURN *ret);
void __free_ovflpage(HTAB *hashp, BUFHEAD *obufp);
BUFHEAD *__add_ovflpage(HTAB *hashp, BUFHEAD *bufp);
int __big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val);
int __expand_table(HTAB *hashp);
uint32 __log2(uint32 num);
void __reclaim_buf(HTAB *hashp, BUFHEAD *bp);
int __get_page(HTAB *hashp, char *p, uint32 bucket, int is_bucket, int is_disk, int is_bitmap);
int __put_page(HTAB *hashp, char *p, uint32 bucket, int is_bucket, int is_bitmap);
int __ibitmap(HTAB *hashp, int pnum, int nbits, int ndx);
int __buf_free(HTAB *hashp, int do_free, int to_disk);
int __find_bigpair(HTAB *hashp, BUFHEAD *bufp, int ndx, char *key, int size);
uint16 __find_last_page(HTAB *hashp, BUFHEAD **bpp);
int __addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val);
int __big_return(HTAB *hashp, BUFHEAD *bufp, int ndx, DBT *val, int set_current);
int __delpair(HTAB *hashp, BUFHEAD *bufp, int ndx);
int __big_keydata(HTAB *hashp, BUFHEAD *bufp, DBT *key, DBT *val, int set);
int __split_page(HTAB *hashp, uint32 obucket, uint32 nbucket);
extern int dbm_big_split(HTAB *hashp, BUFHEAD *op, BUFHEAD *np,
BUFHEAD *big_keyp, uint32 addr, uint32 obucket, SPLIT_RETURN *ret);
void dbm_free_ovflpage(HTAB *hashp, BUFHEAD *obufp);
BUFHEAD *dbm_add_ovflpage(HTAB *hashp, BUFHEAD *bufp);
int dbm_big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val);
int dbm_expand_table(HTAB *hashp);
uint32 dbm_log2(uint32 num);
void dbm_reclaim_buf(HTAB *hashp, BUFHEAD *bp);
int dbm_get_page(HTAB *hashp, char *p, uint32 bucket, int is_bucket, int is_disk, int is_bitmap);
int dbm_put_page(HTAB *hashp, char *p, uint32 bucket, int is_bucket, int is_bitmap);
int dbm_ibitmap(HTAB *hashp, int pnum, int nbits, int ndx);
int dbm_buf_free(HTAB *hashp, int do_free, int to_disk);
int dbm_find_bigpair(HTAB *hashp, BUFHEAD *bufp, int ndx, char *key, int size);
uint16 dbm_find_last_page(HTAB *hashp, BUFHEAD **bpp);
int dbm_addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val);
int dbm_big_return(HTAB *hashp, BUFHEAD *bufp, int ndx, DBT *val, int set_current);
int dbm_delpair(HTAB *hashp, BUFHEAD *bufp, int ndx);
int dbm_big_keydata(HTAB *hashp, BUFHEAD *bufp, DBT *key, DBT *val, int set);
int dbm_split_page(HTAB *hashp, uint32 obucket, uint32 nbucket);
......@@ -287,16 +287,16 @@ typedef enum { LockOutDatabase,
#endif
/* Access method description structure. */
typedef struct __db {
typedef struct dbm_db {
DBTYPE type; /* Underlying db type. */
int (*close)(struct __db *);
int (*del)(const struct __db *, const DBT *, uint);
int (*get)(const struct __db *, const DBT *, DBT *, uint);
int (*put)(const struct __db *, DBT *, const DBT *, uint);
int (*seq)(const struct __db *, DBT *, DBT *, uint);
int (*sync)(const struct __db *, uint);
int (*close)(struct dbm_db *);
int (*del)(const struct dbm_db *, const DBT *, uint);
int (*get)(const struct dbm_db *, const DBT *, DBT *, uint);
int (*put)(const struct dbm_db *, DBT *, const DBT *, uint);
int (*seq)(const struct dbm_db *, DBT *, DBT *, uint);
int (*sync)(const struct dbm_db *, uint);
void *internal; /* Access method private. */
int (*fd)(const struct __db *);
int (*fd)(const struct dbm_db *);
} DB;
#define BTREEMAGIC 0x053162
......@@ -412,10 +412,10 @@ dbopen(const char *, int, int, DBTYPE, const void *);
void dbSetOrClearDBLock(DBLockFlagEnum type);
#ifdef __DBINTERFACE_PRIVATE
DB *__bt_open(const char *, int, int, const BTREEINFO *, int);
DB *__hash_open(const char *, int, int, const HASHINFO *, int);
DB *__rec_open(const char *, int, int, const RECNOINFO *, int);
void __dbpanic(DB *dbp);
DB *dbm_bt_open(const char *, int, int, const BTREEINFO *, int);
DB *dbm_hash_open(const char *, int, int, const HASHINFO *, int);
DB *dbm_rec_open(const char *, int, int, const RECNOINFO *, int);
void dbm_dbpanic(DB *dbp);
#endif
PR_END_EXTERN_C
......
......@@ -89,13 +89,13 @@ typedef unsigned int sigset_t;
#define SIG_UNBLOCK 2
#define SIG_SETMASK 3
static int __sigtemp; /* For the use of sigprocmask */
static int dbm_sigtemp; /* For the use of sigprocmask */
/* Repeated test of oset != NULL is to avoid "*0". */
#define sigprocmask(how, set, oset) \
((__sigtemp = \
((dbm_sigtemp = \
(((how) == SIG_BLOCK) ? sigblock(0) | *(set) : (((how) == SIG_UNBLOCK) ? sigblock(0) & ~(*(set)) : ((how) == SIG_SETMASK ? *(set) : sigblock(0))))), \
((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : sigsetmask(__sigtemp)), 0)
((oset) ? (*(oset ? oset : set) = sigsetmask(dbm_sigtemp)) : sigsetmask(dbm_sigtemp)), 0)
#endif
/*
......
......@@ -92,16 +92,16 @@ dbopen(const char *fname, int flags, int mode, DBTYPE type, const void *openinfo
/* we don't need btree and recno right now */
#if 0
case DB_BTREE:
return (__bt_open(fname, flags & USE_OPEN_FLAGS,
return (dbm_bt_open(fname, flags & USE_OPEN_FLAGS,
mode, openinfo, flags & DB_FLAGS));
case DB_RECNO:
return (__rec_open(fname, flags & USE_OPEN_FLAGS,
return (dbm_rec_open(fname, flags & USE_OPEN_FLAGS,
mode, openinfo, flags & DB_FLAGS));
#endif
case DB_HASH:
return (__hash_open(fname, flags & USE_OPEN_FLAGS,
mode, (const HASHINFO *)openinfo, flags & DB_FLAGS));
return (dbm_hash_open(fname, flags & USE_OPEN_FLAGS,
mode, (const HASHINFO *)openinfo, flags & DB_FLAGS));
default:
break;
}
......@@ -110,7 +110,7 @@ dbopen(const char *fname, int flags, int mode, DBTYPE type, const void *openinfo
}
static int
__dberr()
dbm_dberr()
{
return (RET_ERROR);
}
......@@ -122,13 +122,13 @@ __dberr()
* dbp: pointer to the DB structure.
*/
void
__dbpanic(DB *dbp)
dbm_dbpanic(DB *dbp)
{
/* The only thing that can succeed is a close. */
dbp->del = (int (*)(const struct __db *, const DBT *, uint))__dberr;
dbp->fd = (int (*)(const struct __db *))__dberr;
dbp->get = (int (*)(const struct __db *, const DBT *, DBT *, uint))__dberr;
dbp->put = (int (*)(const struct __db *, DBT *, const DBT *, uint))__dberr;
dbp->seq = (int (*)(const struct __db *, DBT *, DBT *, uint))__dberr;
dbp->sync = (int (*)(const struct __db *, uint))__dberr;
dbp->del = (int (*)(const struct dbm_db *, const DBT *, uint))dbm_dberr;
dbp->fd = (int (*)(const struct dbm_db *))dbm_dberr;
dbp->get = (int (*)(const struct dbm_db *, const DBT *, DBT *, uint))dbm_dberr;
dbp->put = (int (*)(const struct dbm_db *, DBT *, const DBT *, uint))dbm_dberr;
dbp->seq = (int (*)(const struct dbm_db *, DBT *, DBT *, uint))dbm_dberr;
dbp->sync = (int (*)(const struct dbm_db *, uint))dbm_dberr;
}
......@@ -85,7 +85,7 @@ static int collect_data(HTAB *, BUFHEAD *, int, int);
*-1 ==> ERROR
*/
extern int
__big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
dbm_big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
{
register uint16 *p;
uint key_size, n, val_size;
......@@ -114,7 +114,7 @@ __big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
FREESPACE(p) = off - PAGE_META(n);
OFFSET(p) = off;
p[n] = PARTIAL_KEY;
bufp = __add_ovflpage(hashp, bufp);
bufp = dbm_add_ovflpage(hashp, bufp);
if (!bufp)
return (-1);
n = p[0];
......@@ -158,7 +158,7 @@ __big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
OFFSET(p) = off;
if (val_size) {
p[n] = FULL_KEY;
bufp = __add_ovflpage(hashp, bufp);
bufp = dbm_add_ovflpage(hashp, bufp);
if (!bufp)
return (-1);
cp = bufp->page;
......@@ -182,7 +182,7 @@ __big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
*-1 => ERROR
*/
extern int
__big_delete(HTAB *hashp, BUFHEAD *bufp)
dbm_big_delete(HTAB *hashp, BUFHEAD *bufp)
{
register BUFHEAD *last_bfp, *rbufp;
uint16 *bp, pageno;
......@@ -207,9 +207,9 @@ __big_delete(HTAB *hashp, BUFHEAD *bufp)
break;
pageno = bp[bp[0] - 1];
rbufp->flags |= BUF_MOD;
rbufp = __get_buf(hashp, pageno, rbufp, 0);
rbufp = dbm_get_buf(hashp, pageno, rbufp, 0);
if (last_bfp)
__free_ovflpage(hashp, last_bfp);
dbm_free_ovflpage(hashp, last_bfp);
last_bfp = rbufp;
if (!rbufp)
return (-1); /* Error. */
......@@ -244,9 +244,9 @@ __big_delete(HTAB *hashp, BUFHEAD *bufp)
bufp->flags |= BUF_MOD;
if (rbufp)
__free_ovflpage(hashp, rbufp);
dbm_free_ovflpage(hashp, rbufp);
if (last_bfp != rbufp)
__free_ovflpage(hashp, last_bfp);
dbm_free_ovflpage(hashp, last_bfp);
hashp->NKEYS--;
return (0);
......@@ -259,7 +259,7 @@ __big_delete(HTAB *hashp, BUFHEAD *bufp)
* -3 error
*/
extern int
__find_bigpair(HTAB *hashp, BUFHEAD *bufp, int ndx, char *key, int size)
dbm_find_bigpair(HTAB *hashp, BUFHEAD *bufp, int ndx, char *key, int size)
{
register uint16 *bp;
register char *p;
......@@ -279,7 +279,7 @@ __find_bigpair(HTAB *hashp, BUFHEAD *bufp, int ndx, char *key, int size)
return (-2);
kkey += bytes;
ksize -= bytes;
bufp = __get_buf(hashp, bp[ndx + 2], bufp, 0);
bufp = dbm_get_buf(hashp, bp[ndx + 2], bufp, 0);
if (!bufp)
return (-3);
p = bufp->page;
......@@ -306,7 +306,7 @@ __find_bigpair(HTAB *hashp, BUFHEAD *bufp, int ndx, char *key, int size)
* bucket)
*/
extern uint16
__find_last_page(HTAB *hashp, BUFHEAD **bpp)
dbm_find_last_page(HTAB *hashp, BUFHEAD **bpp)
{
BUFHEAD *bufp;
uint16 *bp, pageno;
......@@ -332,7 +332,7 @@ __find_last_page(HTAB *hashp, BUFHEAD **bpp)
return (0);
pageno = bp[n - 1];
bufp = __get_buf(hashp, pageno, bufp, 0);
bufp = dbm_get_buf(hashp, pageno, bufp, 0);
if (!bufp)
return (0); /* Need to indicate an error! */
bp = (uint16 *)bufp->page;
......@@ -350,7 +350,7 @@ __find_last_page(HTAB *hashp, BUFHEAD **bpp)
* index (index should always be 1).
*/
extern int
__big_return(
dbm_big_return(
HTAB *hashp,
BUFHEAD *bufp,
int ndx,
......@@ -364,7 +364,7 @@ __big_return(
bp = (uint16 *)bufp->page;
while (bp[ndx + 1] == PARTIAL_KEY) {
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
bufp = dbm_get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!bufp)
return (-1);
bp = (uint16 *)bufp->page;
......@@ -372,7 +372,7 @@ __big_return(
}
if (bp[ndx + 1] == FULL_KEY) {
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
bufp = dbm_get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!bufp)
return (-1);
bp = (uint16 *)bufp->page;
......@@ -392,7 +392,7 @@ __big_return(
len = bp[1] - off;
save_p = bufp;
save_addr = bufp->addr;
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
bufp = dbm_get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!bufp)
return (-1);
bp = (uint16 *)bufp->page;
......@@ -409,8 +409,8 @@ __big_return(
hashp->cbucket++;
hashp->cndx = 1;
} else {
hashp->cpage = __get_buf(hashp,
bp[bp[0] - 1], bufp, 0);
hashp->cpage = dbm_get_buf(hashp,
bp[bp[0] - 1], bufp, 0);
if (!hashp->cpage)
return (-1);
hashp->cndx = 1;
......@@ -470,7 +470,7 @@ collect_data(
save_bufp->flags |= BUF_PIN;
/* read the length of the buffer */
for (totlen = len; bufp; bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0)) {
for (totlen = len; bufp; bufp = dbm_get_buf(hashp, bp[bp[0] - 1], bufp, 0)) {
bp = (uint16 *)bufp->page;
mylen = hashp->BSIZE - bp[1];
......@@ -502,7 +502,7 @@ collect_data(
/* copy the buffers back into temp buf */
for (bufp = save_bufp; bufp;
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0)) {
bufp = dbm_get_buf(hashp, bp[bp[0] - 1], bufp, 0)) {
bp = (uint16 *)bufp->page;
mylen = hashp->BSIZE - bp[1];
memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], (size_t)mylen);
......@@ -522,7 +522,7 @@ collect_data(
hashp->cpage = NULL;
hashp->cbucket++;
} else {
hashp->cpage = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
hashp->cpage = dbm_get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!hashp->cpage)
return (-1);
else if (!((uint16 *)hashp->cpage->page)[0]) {
......@@ -538,7 +538,7 @@ collect_data(
* Fill in the key and data for this big pair.
*/
extern int
__big_keydata(
dbm_big_keydata(
HTAB *hashp,
BUFHEAD *bufp,
DBT *key, DBT *val,
......@@ -579,10 +579,10 @@ collect_key(
free(hashp->tmp_key);
if ((hashp->tmp_key = (char *)malloc((size_t)totlen)) == NULL)
return (-1);
if (__big_return(hashp, bufp, 1, val, set))
if (dbm_big_return(hashp, bufp, 1, val, set))
return (-1);
} else {
xbp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
xbp = dbm_get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!xbp || ((totlen =
collect_key(hashp, xbp, totlen, val, set)) < 1))
return (-1);
......@@ -601,7 +601,7 @@ collect_key(
* -1 => error
*/
extern int
__big_split(
dbm_big_split(
HTAB *hashp,
BUFHEAD *op, /* Pointer to where to put keys that go in old bucket */
BUFHEAD *np, /* Pointer to new bucket page */
......@@ -621,13 +621,13 @@ __big_split(
bp = big_keyp;
/* Now figure out where the big key/data goes */
if (__big_keydata(hashp, big_keyp, &key, &val, 0))
if (dbm_big_keydata(hashp, big_keyp, &key, &val, 0))
return (-1);
change = (__call_hash(hashp, (char *)key.data, key.size) != obucket);
change = (dbm_call_hash(hashp, (char *)key.data, key.size) != obucket);
if ((ret->next_addr = __find_last_page(hashp, &big_keyp))) {
if ((ret->next_addr = dbm_find_last_page(hashp, &big_keyp))) {
if (!(ret->nextp =
__get_buf(hashp, ret->next_addr, big_keyp, 0)))
dbm_get_buf(hashp, ret->next_addr, big_keyp, 0)))
return (-1);
;
} else
......@@ -692,7 +692,7 @@ __big_split(
tp[0] -= 2;
FREESPACE(tp) = free_space + OVFLSIZE;
OFFSET(tp) = off;
tmpp = __add_ovflpage(hashp, big_keyp);
tmpp = dbm_add_ovflpage(hashp, big_keyp);
if (!tmpp)
return (-1);
tp[4] = n;
......
......@@ -52,7 +52,7 @@ static uint32 hash3(const void *, size_t);
static uint32 hash4(const void *, size_t);
/* Global default hash function */
uint32 (*__default_hash)(const void *, size_t) = hash4;
uint32 (*dbm_default_hash)(const void *, size_t) = hash4;
/*
* HASH FUNCTIONS
......
......@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)hash_log2.c 8.2 (Berkeley) 5/31/94";
#include "mcom_db.h"
uint32
__log2(uint32 num)
dbm_log2(uint32 num)
{
register uint32 i, limit;
......
......@@ -204,7 +204,7 @@ putpair(char *p, const DBT *key, DBT *val)
* -1 error
*/
extern int
__delpair(HTAB *hashp, BUFHEAD *bufp, int ndx)
dbm_delpair(HTAB *hashp, BUFHEAD *bufp, int ndx)
{
register uint16 *bp, newoff;
register int n;
......@@ -214,7 +214,7 @@ __delpair(HTAB *hashp, BUFHEAD *bufp, int ndx)
n = bp[0];
if (bp[ndx + 1] < REAL_KEY)
return (__big_delete(hashp, bufp));
return (dbm_big_delete(hashp, bufp));
if (ndx != 1)
newoff = bp[ndx - 1];
else
......@@ -277,7 +277,7 @@ __delpair(HTAB *hashp, BUFHEAD *bufp, int ndx)
* -1 ==> Error
*/
extern int
__split_page(HTAB *hashp, uint32 obucket, uint32 nbucket)
dbm_split_page(HTAB *hashp, uint32 obucket, uint32 nbucket)
{
register BUFHEAD *new_bufp, *old_bufp;
register uint16 *ino;
......@@ -292,10 +292,10 @@ __split_page(HTAB *hashp, uint32 obucket, uint32 nbucket)
copyto = (uint16)hashp->BSIZE;
off = (uint16)hashp->BSIZE;
old_bufp = __get_buf(hashp, obucket, NULL, 0);
old_bufp = dbm_get_buf(hashp, obucket, NULL, 0);
if (old_bufp == NULL)
return (-1);
new_bufp = __get_buf(hashp, nbucket, NULL, 0);
new_bufp = dbm_get_buf(hashp, nbucket, NULL, 0);
if (new_bufp == NULL)
return (-1);
......@@ -331,7 +331,7 @@ __split_page(HTAB *hashp, uint32 obucket, uint32 nbucket)
assert(((int)key.size) > -1);
#endif
if (__call_hash(hashp, (char *)key.data, key.size) == obucket) {
if (dbm_call_hash(hashp, (char *)key.data, key.size) == obucket) {
/* Don't switch page */
diff = copyto - off;
if (diff) {
......@@ -443,8 +443,8 @@ ugly_split(HTAB *hashp, uint32 obucket, BUFHEAD *old_bufp,
return DATABASE_CORRUPTED_ERROR;
if (ino[2] < REAL_KEY && ino[2] != OVFLPAGE) {
if ((status = __big_split(hashp, old_bufp,
new_bufp, bufp, bufp->addr, obucket, &ret)))
if ((status = dbm_big_split(hashp, old_bufp,
new_bufp, bufp, bufp->addr, obucket, &ret)))
return (status);
old_bufp = ret.oldp;
if (!old_bufp)
......@@ -477,7 +477,7 @@ ugly_split(HTAB *hashp, uint32 obucket, BUFHEAD *old_bufp,
scopyto - sizeof(uint16) * (ino[0] + 3);
OFFSET(ino) = scopyto;
bufp = __get_buf(hashp, ov_addr, bufp, 0);
bufp = dbm_get_buf(hashp, ov_addr, bufp, 0);
if (!bufp)
return (-1);
......@@ -487,7 +487,7 @@ ugly_split(HTAB *hashp, uint32 obucket, BUFHEAD *old_bufp,
moved = 0;
if (last_bfp)
__free_ovflpage(hashp, last_bfp);
dbm_free_ovflpage(hashp, last_bfp);
last_bfp = bufp;
}
/* Move regular sized pairs of there are any */
......@@ -506,13 +506,13 @@ ugly_split(HTAB *hashp, uint32 obucket, BUFHEAD *old_bufp,
val.size = ino[n] - ino[n + 1];
off = ino[n + 1];
if (__call_hash(hashp, (char *)key.data, key.size) == obucket) {
if (dbm_call_hash(hashp, (char *)key.data, key.size) == obucket) {
/* Keep on old page */
if (PAIRFITS(op, (&key), (&val)))
putpair((char *)op, &key, &val);
else {
old_bufp =
__add_ovflpage(hashp, old_bufp);
dbm_add_ovflpage(hashp, old_bufp);
if (!old_bufp)
return (-1);
op = (uint16 *)old_bufp->page;
......@@ -525,7 +525,7 @@ ugly_split(HTAB *hashp, uint32 obucket, BUFHEAD *old_bufp,
putpair((char *)np, &key, &val);
else {
new_bufp =
__add_ovflpage(hashp, new_bufp);
dbm_add_ovflpage(hashp, new_bufp);
if (!new_bufp)
return (-1);
np = (uint16 *)new_bufp->page;
......@@ -536,7 +536,7 @@ ugly_split(HTAB *hashp, uint32 obucket, BUFHEAD *old_bufp,
}
}
if (last_bfp)
__free_ovflpage(hashp, last_bfp);
dbm_free_ovflpage(hashp, last_bfp);
return (0);
}
......@@ -548,7 +548,7 @@ ugly_split(HTAB *hashp, uint32 obucket, BUFHEAD *old_bufp,
* 1 ==> failure
*/
extern int
__addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
dbm_addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
{
register uint16 *bp, *sop;
int do_expand;
......@@ -562,7 +562,7 @@ __addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
and we need to add another page */
break;
else if (bp[2] < REAL_KEY && bp[bp[0]] != OVFLPAGE) {
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
bufp = dbm_get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!bufp) {
#ifdef DEBUG
assert(0);
......@@ -585,7 +585,7 @@ __addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
return (0);
}
} else {
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
bufp = dbm_get_buf(hashp, bp[bp[0] - 1], bufp, 0);
if (!bufp) {
#ifdef DEBUG
assert(0);
......@@ -599,7 +599,7 @@ __addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
putpair(bufp->page, key, (DBT *)val);
else {
do_expand = 1;
bufp = __add_ovflpage(hashp, bufp);
bufp = dbm_add_ovflpage(hashp, bufp);
if (!bufp) {
#ifdef DEBUG
assert(0);
......@@ -610,7 +610,7 @@ __addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
if (PAIRFITS(sop, key, val))
putpair((char *)sop, key, (DBT *)val);
else if (__big_insert(hashp, bufp, key, val)) {
else if (dbm_big_insert(hashp, bufp, key, val)) {
#ifdef DEBUG
assert(0);
#endif
......@@ -625,7 +625,7 @@ __addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
hashp->NKEYS++;
if (do_expand ||
(hashp->NKEYS / (hashp->MAX_BUCKET + 1) > hashp->FFACTOR))
return (__expand_table(hashp));
return (dbm_expand_table(hashp));
return (0);
}
......@@ -636,7 +636,7 @@ __addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
* NULL on error
*/
extern BUFHEAD *
__add_ovflpage(HTAB *hashp, BUFHEAD *bufp)
dbm_add_ovflpage(HTAB *hashp, BUFHEAD *bufp)
{
register uint16 *sp;
uint16 ndx, ovfl_num;
......@@ -657,7 +657,7 @@ __add_ovflpage(HTAB *hashp, BUFHEAD *bufp)
tmp1 = bufp->addr;
tmp2 = bufp->ovfl ? bufp->ovfl->addr : 0;
#endif
if (!ovfl_num || !(bufp->ovfl = __get_buf(hashp, ovfl_num, bufp, 1)))
if (!ovfl_num || !(bufp->ovfl = dbm_get_buf(hashp, ovfl_num, bufp, 1)))
return (NULL);
bufp->ovfl->flags |= BUF_MOD;
#ifdef DEBUG1
......@@ -687,12 +687,12 @@ __add_ovflpage(HTAB *hashp, BUFHEAD *bufp)
* -1 indicates FAILURE
*/
extern int
__get_page(HTAB *hashp,
char *p,
uint32 bucket,
int is_bucket,
int is_disk,
int is_bitmap)
dbm_get_page(HTAB *hashp,
char *p,
uint32 bucket,
int is_bucket,
int is_disk,
int is_bitmap)
{
register int fd, page;
size_t size;
......@@ -805,7 +805,7 @@ __get_page(HTAB *hashp,
* -1 ==>failure
*/
extern int
__put_page(HTAB *hashp, char *p, uint32 bucket, int is_bucket, int is_bitmap)
dbm_put_page(HTAB *hashp, char *p, uint32 bucket, int is_bucket, int is_bitmap)
{
register int fd, page;
size_t size;
......@@ -895,7 +895,7 @@ __put_page(HTAB *hashp, char *p, uint32 bucket, int is_bucket, int is_bitmap)
* once they are read in.
*/
extern int
__ibitmap(HTAB *hashp, int pnum, int nbits, int ndx)
dbm_ibitmap(HTAB *hashp, int pnum, int nbits, int ndx)
{
uint32 *ip;
size_t clearbytes, clearints;
......@@ -1011,8 +1011,8 @@ overflow_page(HTAB *hashp)
* don't have to if we tell init_bitmap not to leave it clear
* in the first place.
*/
if (__ibitmap(hashp,
(int)OADDR_OF(splitnum, offset), 1, free_page))
if (dbm_ibitmap(hashp,
(int)OADDR_OF(splitnum, offset), 1, free_page))
return (0);
hashp->SPARES[splitnum]++;
#ifdef DEBUG2
......@@ -1084,7 +1084,7 @@ found:
* Mark this overflow page as free.
*/
extern void
__free_ovflpage(HTAB *hashp, BUFHEAD *obufp)
dbm_free_ovflpage(HTAB *hashp, BUFHEAD *obufp)
{
uint16 addr;
uint32 *freep;
......@@ -1125,7 +1125,7 @@ __free_ovflpage(HTAB *hashp, BUFHEAD *obufp)
(void)fprintf(stderr, "FREE_OVFLPAGE: ADDR: %d BIT: %d PAGE %d\n",
obufp->addr, free_bit, free_page);
#endif
__reclaim_buf(hashp, obufp);
dbm_reclaim_buf(hashp, obufp);
}
/*
......@@ -1236,8 +1236,8 @@ fetch_bitmap(HTAB *hashp, uint32 ndx)
return (NULL);
if ((hashp->mapp[ndx] = (uint32 *)malloc((size_t)hashp->BSIZE)) == NULL)
return (NULL);