diff options
author | Xin LI <delphij@FreeBSD.org> | 2009-03-02 23:47:18 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2009-03-02 23:47:18 +0000 |
commit | 0ac22237f12015101ffe02a37786a092603c1f03 (patch) | |
tree | 5a67c3be623d7be485fac882eb4ef91bd1e65262 /lib/libc/db/hash | |
parent | f86bce5ed03f2a4c30a04c29b51624e69c30d8c7 (diff) | |
download | src-0ac22237f12015101ffe02a37786a092603c1f03.tar.gz src-0ac22237f12015101ffe02a37786a092603c1f03.zip |
Diff reduction against OpenBSD: ANSI'fy prototypes.
(This is part of a larger changeset which is intended to reduce diff only,
thus some prototypes were left intact since they will be changed in the
future).
Verified with: md5(1)
Notes
Notes:
svn path=/head/; revision=189291
Diffstat (limited to 'lib/libc/db/hash')
-rw-r--r-- | lib/libc/db/hash/hash.c | 89 | ||||
-rw-r--r-- | lib/libc/db/hash/hash_bigkey.c | 75 | ||||
-rw-r--r-- | lib/libc/db/hash/hash_buf.c | 33 | ||||
-rw-r--r-- | lib/libc/db/hash/hash_log2.c | 3 | ||||
-rw-r--r-- | lib/libc/db/hash/hash_page.c | 114 |
5 files changed, 101 insertions, 213 deletions
diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index 6b71d4a7c30f..3013f680b5e0 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -92,11 +92,11 @@ int hash_accesses, hash_collisions, hash_expansions, hash_overflows; /************************** INTERFACE ROUTINES ***************************/ /* OPEN/CLOSE */ -extern DB * -__hash_open(file, flags, mode, info, dflags) - const char *file; - int flags, mode, dflags; - const HASHINFO *info; /* Special directives for create */ +/* ARGSUSED */ +DB * +__hash_open(const char *file, int flags, int mode, + const HASHINFO *info, /* Special directives for create */ + int dflags) { HTAB *hashp; struct stat statbuf; @@ -249,8 +249,7 @@ error0: } static int -hash_close(dbp) - DB *dbp; +hash_close(DB *dbp) { HTAB *hashp; int retval; @@ -265,8 +264,7 @@ hash_close(dbp) } static int -hash_fd(dbp) - const DB *dbp; +hash_fd(const DB *dbp) { HTAB *hashp; @@ -283,10 +281,7 @@ hash_fd(dbp) /************************** LOCAL CREATION ROUTINES **********************/ static HTAB * -init_hash(hashp, file, info) - HTAB *hashp; - const char *file; - const HASHINFO *info; +init_hash(HTAB *hashp, const char *file, const HASHINFO *info) { struct stat statbuf; int nelem; @@ -350,9 +345,7 @@ init_hash(hashp, file, info) * Returns 0 on No Error */ static int -init_htab(hashp, nelem) - HTAB *hashp; - int nelem; +init_htab(HTAB *hashp, int nelem) { int nbuckets, nsegs; int l2; @@ -396,8 +389,7 @@ init_htab(hashp, nelem) * structure, freeing all allocated space. */ static int -hdestroy(hashp) - HTAB *hashp; +hdestroy(HTAB *hashp) { int i, save_errno; @@ -456,9 +448,7 @@ hdestroy(hashp) * -1 ERROR */ static int -hash_sync(dbp, flags) - const DB *dbp; - u_int32_t flags; +hash_sync(const DB *dbp, u_int32_t flags) { HTAB *hashp; @@ -485,8 +475,7 @@ hash_sync(dbp, flags) * -1 indicates that errno should be set */ static int -flush_meta(hashp) - HTAB *hashp; +flush_meta(HTAB *hashp) { HASHHDR *whdrp; #if BYTE_ORDER == LITTLE_ENDIAN @@ -533,11 +522,7 @@ flush_meta(hashp) * -1 to indicate an internal ERROR (i.e. out of memory, etc) */ static int -hash_get(dbp, key, data, flag) - const DB *dbp; - const DBT *key; - DBT *data; - u_int32_t flag; +hash_get(const DB *dbp, const DBT *key, DBT *data, u_int32_t flag) { HTAB *hashp; @@ -550,11 +535,7 @@ hash_get(dbp, key, data, flag) } static int -hash_put(dbp, key, data, flag) - const DB *dbp; - DBT *key; - const DBT *data; - u_int32_t flag; +hash_put(const DB *dbp, DBT *key, const DBT *data, u_int32_t flag) { HTAB *hashp; @@ -573,10 +554,8 @@ hash_put(dbp, key, data, flag) } static int -hash_delete(dbp, key, flag) - const DB *dbp; - const DBT *key; - u_int32_t flag; /* Ignored */ +hash_delete(const DB *dbp, const DBT *key, + u_int32_t flag) /* Ignored */ { HTAB *hashp; @@ -596,10 +575,7 @@ hash_delete(dbp, key, flag) * Assume that hashp has been set in wrapper routine. */ static int -hash_access(hashp, action, key, val) - HTAB *hashp; - ACTION action; - DBT *key, *val; +hash_access(HTAB *hashp, ACTION action, DBT *key, DBT *val) { BUFHEAD *rbufp; BUFHEAD *bufp, *save_bufp; @@ -725,10 +701,7 @@ found: } static int -hash_seq(dbp, key, data, flag) - const DB *dbp; - DBT *key, *data; - u_int32_t flag; +hash_seq(const DB *dbp, DBT *key, DBT *data, u_int32_t flag) { u_int32_t bucket; BUFHEAD *bufp; @@ -814,9 +787,8 @@ hash_seq(dbp, key, data, flag) * 0 ==> OK * -1 ==> Error */ -extern int -__expand_table(hashp) - HTAB *hashp; +int +__expand_table(HTAB *hashp) { u_int32_t old_bucket, new_bucket; int dirsize, new_segnum, spare_ndx; @@ -870,9 +842,7 @@ __expand_table(hashp) * fails, then this routine can go away. */ static void * -hash_realloc(p_ptr, oldsize, newsize) - SEGMENT **p_ptr; - int oldsize, newsize; +hash_realloc(SEGMENT **p_ptr, int oldsize, int newsize) { void *p; @@ -885,11 +855,8 @@ hash_realloc(p_ptr, oldsize, newsize) return (p); } -extern u_int32_t -__call_hash(hashp, k, len) - HTAB *hashp; - char *k; - int len; +u_int32_t +__call_hash(HTAB *hashp, char *k, int len) { int n, bucket; @@ -906,9 +873,7 @@ __call_hash(hashp, k, len) * Returns 0 on success */ static int -alloc_segs(hashp, nsegs) - HTAB *hashp; - int nsegs; +alloc_segs(HTAB *hashp, int nsegs) { int i; SEGMENT store; @@ -940,8 +905,7 @@ alloc_segs(hashp, nsegs) * Hashp->hdr needs to be byteswapped. */ static void -swap_header_copy(srcp, destp) - HASHHDR *srcp, *destp; +swap_header_copy(HASHHDR *srcp, HASHHDR *destp) { int i; @@ -969,8 +933,7 @@ swap_header_copy(srcp, destp) } static void -swap_header(hashp) - HTAB *hashp; +swap_header(HTAB *hashp) { HASHHDR *hdrp; int i; diff --git a/lib/libc/db/hash/hash_bigkey.c b/lib/libc/db/hash/hash_bigkey.c index 3a28ae5abd56..d6464ae97cca 100644 --- a/lib/libc/db/hash/hash_bigkey.c +++ b/lib/libc/db/hash/hash_bigkey.c @@ -82,11 +82,8 @@ static int collect_data(HTAB *, BUFHEAD *, int, int); * 0 ==> OK *-1 ==> ERROR */ -extern int -__big_insert(hashp, bufp, key, val) - HTAB *hashp; - BUFHEAD *bufp; - const DBT *key, *val; +int +__big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val) { u_int16_t *p; int key_size, n, val_size; @@ -182,10 +179,8 @@ __big_insert(hashp, bufp, key, val) * 0 => OK *-1 => ERROR */ -extern int -__big_delete(hashp, bufp) - HTAB *hashp; - BUFHEAD *bufp; +int +__big_delete(HTAB *hashp, BUFHEAD *bufp) { BUFHEAD *last_bfp, *rbufp; u_int16_t *bp, pageno; @@ -261,13 +256,8 @@ __big_delete(hashp, bufp) * -2 means key not found and this is big key/data * -3 error */ -extern int -__find_bigpair(hashp, bufp, ndx, key, size) - HTAB *hashp; - BUFHEAD *bufp; - int ndx; - char *key; - int size; +int +__find_bigpair(HTAB *hashp, BUFHEAD *bufp, int ndx, char *key, int size) { u_int16_t *bp; char *p; @@ -313,10 +303,8 @@ __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_int16_t -__find_last_page(hashp, bpp) - HTAB *hashp; - BUFHEAD **bpp; +u_int16_t +__find_last_page(HTAB *hashp, BUFHEAD **bpp) { BUFHEAD *bufp; u_int16_t *bp, pageno; @@ -354,13 +342,8 @@ __find_last_page(hashp, bpp) * Return the data for the key/data pair that begins on this page at this * index (index should always be 1). */ -extern int -__big_return(hashp, bufp, ndx, val, set_current) - HTAB *hashp; - BUFHEAD *bufp; - int ndx; - DBT *val; - int set_current; +int +__big_return(HTAB *hashp, BUFHEAD *bufp, int ndx, DBT *val, int set_current) { BUFHEAD *save_p; u_int16_t *bp, len, off, save_addr; @@ -446,10 +429,7 @@ __big_return(hashp, bufp, ndx, val, set_current) * allocate a buffer and copy the data as you recurse up. */ static int -collect_data(hashp, bufp, len, set) - HTAB *hashp; - BUFHEAD *bufp; - int len, set; +collect_data(HTAB *hashp, BUFHEAD *bufp, int len, int set) { u_int16_t *bp; char *p; @@ -501,12 +481,8 @@ collect_data(hashp, bufp, len, set) /* * Fill in the key and data for this big pair. */ -extern int -__big_keydata(hashp, bufp, key, val, set) - HTAB *hashp; - BUFHEAD *bufp; - DBT *key, *val; - int set; +int +__big_keydata(HTAB *hashp, BUFHEAD *bufp, DBT *key, DBT *val, int set) { key->size = collect_key(hashp, bufp, 0, val, set); if (key->size == -1) @@ -520,12 +496,7 @@ __big_keydata(hashp, bufp, key, val, set) * collect the data, allocate a buffer and copy the key as you recurse up. */ static int -collect_key(hashp, bufp, len, val, set) - HTAB *hashp; - BUFHEAD *bufp; - int len; - DBT *val; - int set; +collect_key(HTAB *hashp, BUFHEAD *bufp, int len, DBT *val, int set) { BUFHEAD *xbp; char *p; @@ -564,16 +535,14 @@ collect_key(hashp, bufp, len, val, set) * 0 => OK * -1 => error */ -extern int -__big_split(hashp, op, np, big_keyp, addr, obucket, ret) - HTAB *hashp; - BUFHEAD *op; /* Pointer to where to put keys that go in old bucket */ - BUFHEAD *np; /* Pointer to new bucket page */ - /* Pointer to first page containing the big key/data */ - BUFHEAD *big_keyp; - int addr; /* Address of big_keyp */ - u_int32_t obucket;/* Old Bucket */ - SPLIT_RETURN *ret; +int +__big_split(HTAB *hashp, + BUFHEAD *op, /* Pointer to where to put keys that go in old bucket */ + BUFHEAD *np, /* Pointer to new bucket page */ + BUFHEAD *big_keyp, /* Pointer to first page containing the big key/data */ + int addr, /* Address of big_keyp */ + u_int32_t obucket, /* Old Bucket */ + SPLIT_RETURN *ret) { BUFHEAD *tmpp; u_int16_t *tp; diff --git a/lib/libc/db/hash/hash_buf.c b/lib/libc/db/hash/hash_buf.c index db8ad1a3db24..7eadbb90c26b 100644 --- a/lib/libc/db/hash/hash_buf.c +++ b/lib/libc/db/hash/hash_buf.c @@ -98,12 +98,10 @@ static BUFHEAD *newbuf(HTAB *, u_int32_t, BUFHEAD *); * be valid. Therefore, you must always verify that its address matches the * address you are seeking. */ -extern BUFHEAD * -__get_buf(hashp, addr, prev_bp, newpage) - HTAB *hashp; - u_int32_t addr; - BUFHEAD *prev_bp; - int newpage; /* If prev_bp set, indicates a new overflow page. */ +BUFHEAD * +__get_buf(HTAB *hashp, u_int32_t addr, + BUFHEAD *prev_bp, /* If prev_bp set, indicates a new overflow page. */ + int newpage) { BUFHEAD *bp; u_int32_t is_disk_mask; @@ -154,10 +152,7 @@ __get_buf(hashp, addr, prev_bp, newpage) * If newbuf finds an error (returning NULL), it also sets errno. */ static BUFHEAD * -newbuf(hashp, addr, prev_bp) - HTAB *hashp; - u_int32_t addr; - BUFHEAD *prev_bp; +newbuf(HTAB *hashp, u_int32_t addr, BUFHEAD *prev_bp) { BUFHEAD *bp; /* The buffer we're going to use */ BUFHEAD *xbp; /* Temp pointer */ @@ -283,10 +278,8 @@ newbuf(hashp, addr, prev_bp) return (bp); } -extern void -__buf_init(hashp, nbytes) - HTAB *hashp; - int nbytes; +void +__buf_init(HTAB *hashp, int nbytes) { BUFHEAD *bfp; int npages; @@ -308,10 +301,8 @@ __buf_init(hashp, nbytes) */ } -extern int -__buf_free(hashp, do_free, to_disk) - HTAB *hashp; - int do_free, to_disk; +int +__buf_free(HTAB *hashp, int do_free, int to_disk) { BUFHEAD *bp; @@ -339,10 +330,8 @@ __buf_free(hashp, do_free, to_disk) return (0); } -extern void -__reclaim_buf(hashp, bp) - HTAB *hashp; - BUFHEAD *bp; +void +__reclaim_buf(HTAB *hashp, BUFHEAD *bp) { bp->ovfl = 0; bp->addr = 0; diff --git a/lib/libc/db/hash/hash_log2.c b/lib/libc/db/hash/hash_log2.c index cbbfdc8419b4..33e0515e0b7e 100644 --- a/lib/libc/db/hash/hash_log2.c +++ b/lib/libc/db/hash/hash_log2.c @@ -41,8 +41,7 @@ __FBSDID("$FreeBSD$"); #include <db.h> u_int32_t -__log2(num) - u_int32_t num; +__log2(u_int32_t num) { u_int32_t i, limit; diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c index daeb18ed0c4e..0c0146846554 100644 --- a/lib/libc/db/hash/hash_page.c +++ b/lib/libc/db/hash/hash_page.c @@ -72,14 +72,13 @@ __FBSDID("$FreeBSD$"); #include "page.h" #include "extern.h" -static u_int32_t *fetch_bitmap(HTAB *, int); -static u_int32_t first_free(u_int32_t); -static int open_temp(HTAB *); -static u_int16_t overflow_page(HTAB *); -static void putpair(char *, const DBT *, const DBT *); -static void squeeze_key(u_int16_t *, const DBT *, const DBT *); -static int ugly_split -(HTAB *, u_int32_t, BUFHEAD *, BUFHEAD *, int, int); +static u_int32_t *fetch_bitmap(HTAB *, int); +static u_int32_t first_free(u_int32_t); +static int open_temp(HTAB *); +static u_int16_t overflow_page(HTAB *); +static void putpair(char *, const DBT *, const DBT *); +static void squeeze_key(u_int16_t *, const DBT *, const DBT *); +static int ugly_split(HTAB *, u_int32_t, BUFHEAD *, BUFHEAD *, int, int); #define PAGE_INIT(P) { \ ((u_int16_t *)(P))[0] = 0; \ @@ -93,9 +92,7 @@ static int ugly_split * stuff on. */ static void -putpair(p, key, val) - char *p; - const DBT *key, *val; +putpair(char *p, const DBT *key, const DBT *val) { u_int16_t *bp, n, off; @@ -124,11 +121,8 @@ putpair(p, key, val) * 0 OK * -1 error */ -extern int -__delpair(hashp, bufp, ndx) - HTAB *hashp; - BUFHEAD *bufp; - int ndx; +int +__delpair(HTAB *hashp, BUFHEAD *bufp, int ndx) { u_int16_t *bp, newoff; int n; @@ -177,10 +171,8 @@ __delpair(hashp, bufp, ndx) * 0 ==> OK * -1 ==> Error */ -extern int -__split_page(hashp, obucket, nbucket) - HTAB *hashp; - u_int32_t obucket, nbucket; +int +__split_page(HTAB *hashp, u_int32_t obucket, u_int32_t nbucket) { BUFHEAD *new_bufp, *old_bufp; u_int16_t *ino; @@ -274,17 +266,17 @@ __split_page(hashp, obucket, nbucket) * -1 ==> failure */ static int -ugly_split(hashp, obucket, old_bufp, new_bufp, copyto, moved) - HTAB *hashp; - u_int32_t obucket; /* Same as __split_page. */ - BUFHEAD *old_bufp, *new_bufp; - int copyto; /* First byte on page which contains key/data values. */ - int moved; /* Number of pairs moved to new page. */ +ugly_split(HTAB *hashp, + u_int32_t obucket, /* Same as __split_page. */ + BUFHEAD *old_bufp, + BUFHEAD *new_bufp, + int copyto, /* First byte on page which contains key/data values. */ + int moved) /* Number of pairs moved to new page. */ { - BUFHEAD *bufp; /* Buffer header for ino */ - u_int16_t *ino; /* Page keys come off of */ - u_int16_t *np; /* New page */ - u_int16_t *op; /* Page keys go on to if they aren't moving */ + BUFHEAD *bufp; /* Buffer header for ino */ + u_int16_t *ino; /* Page keys come off of */ + u_int16_t *np; /* New page */ + u_int16_t *op; /* Page keys go on to if they aren't moving */ BUFHEAD *last_bfp; /* Last buf header OVFL needing to be freed */ DBT key, val; @@ -394,11 +386,8 @@ ugly_split(hashp, obucket, old_bufp, new_bufp, copyto, moved) * 0 ==> OK * 1 ==> failure */ -extern int -__addel(hashp, bufp, key, val) - HTAB *hashp; - BUFHEAD *bufp; - const DBT *key, *val; +int +__addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val) { u_int16_t *bp, *sop; int do_expand; @@ -461,10 +450,8 @@ __addel(hashp, bufp, key, val) * pointer on success * NULL on error */ -extern BUFHEAD * -__add_ovflpage(hashp, bufp) - HTAB *hashp; - BUFHEAD *bufp; +BUFHEAD * +__add_ovflpage(HTAB *hashp, BUFHEAD *bufp) { u_int16_t *sp; u_int16_t ndx, ovfl_num; @@ -514,12 +501,9 @@ __add_ovflpage(hashp, bufp) * 0 indicates SUCCESS * -1 indicates FAILURE */ -extern int -__get_page(hashp, p, bucket, is_bucket, is_disk, is_bitmap) - HTAB *hashp; - char *p; - u_int32_t bucket; - int is_bucket, is_disk, is_bitmap; +int +__get_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_disk, + int is_bitmap) { int fd, page, size; int rsize; @@ -574,12 +558,8 @@ __get_page(hashp, p, bucket, is_bucket, is_disk, is_bitmap) * 0 ==> OK * -1 ==>failure */ -extern int -__put_page(hashp, p, bucket, is_bucket, is_bitmap) - HTAB *hashp; - char *p; - u_int32_t bucket; - int is_bucket, is_bitmap; +int +__put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap) { int fd, page, size; int wsize; @@ -623,10 +603,8 @@ __put_page(hashp, p, bucket, is_bucket, is_bitmap) * Initialize a new bitmap page. Bitmap pages are left in memory * once they are read in. */ -extern int -__ibitmap(hashp, pnum, nbits, ndx) - HTAB *hashp; - int pnum, nbits, ndx; +int +__ibitmap(HTAB *hashp, int pnum, int nbits, int ndx) { u_int32_t *ip; int clearbytes, clearints; @@ -647,8 +625,7 @@ __ibitmap(hashp, pnum, nbits, ndx) } static u_int32_t -first_free(map) - u_int32_t map; +first_free(u_int32_t map) { u_int32_t i, mask; @@ -662,8 +639,7 @@ first_free(map) } static u_int16_t -overflow_page(hashp) - HTAB *hashp; +overflow_page(HTAB *hashp) { u_int32_t *freep; int max_free, offset, splitnum; @@ -809,10 +785,8 @@ found: /* * Mark this overflow page as free. */ -extern void -__free_ovflpage(hashp, obufp) - HTAB *hashp; - BUFHEAD *obufp; +void +__free_ovflpage(HTAB *hashp, BUFHEAD *obufp) { u_int16_t addr; u_int32_t *freep; @@ -856,8 +830,7 @@ __free_ovflpage(hashp, obufp) * -1 failure */ static int -open_temp(hashp) - HTAB *hashp; +open_temp(HTAB *hashp) { sigset_t set, oset; static char namestr[] = "_hashXXXXXX"; @@ -878,9 +851,7 @@ open_temp(hashp) * an overflow pair, so we need to shift things. */ static void -squeeze_key(sp, key, val) - u_int16_t *sp; - const DBT *key, *val; +squeeze_key(u_int16_t *sp, const DBT *key, const DBT *val) { char *p; u_int16_t free_space, n, off, pageno; @@ -905,9 +876,7 @@ squeeze_key(sp, key, val) } static u_int32_t * -fetch_bitmap(hashp, ndx) - HTAB *hashp; - int ndx; +fetch_bitmap(HTAB *hashp, int ndx) { if (ndx >= hashp->nmaps) return (NULL); @@ -923,8 +892,7 @@ fetch_bitmap(hashp, ndx) #ifdef DEBUG4 int -print_chain(addr) - int addr; +print_chain(int addr) { BUFHEAD *bufp; short *bp, oaddr; |