diff options
author | cls%seawood.org <devnull@localhost> | 1999-08-20 16:01:35 +0000 |
---|---|---|
committer | cls%seawood.org <devnull@localhost> | 1999-08-20 16:01:35 +0000 |
commit | ec8003fce10c4d115b0881fc2cd94dfea0a33565 (patch) | |
tree | 83f6822312b4de2490a643be549d3cc06127e95b | |
parent | a139646d8298041dbfae5f9f2beaf7ad8ac8b068 (diff) | |
download | nss-hg-ec8003fce10c4d115b0881fc2cd94dfea0a33565.tar.gz |
Merged with HEAD from 8/18 or so.
-rw-r--r-- | dbm/include/Makefile.win | 3 | ||||
-rw-r--r-- | dbm/include/extern.h | 4 | ||||
-rw-r--r-- | dbm/include/hash.h | 6 | ||||
-rw-r--r-- | dbm/include/mcom_db.h | 10 | ||||
-rw-r--r-- | dbm/src/Makefile.in | 2 | ||||
-rw-r--r-- | dbm/src/Makefile.win | 3 | ||||
-rw-r--r-- | dbm/src/h_bigkey.c | 10 | ||||
-rw-r--r-- | dbm/src/h_page.c | 17 | ||||
-rw-r--r-- | dbm/src/hash.c | 32 | ||||
-rw-r--r-- | dbm/src/hash_buf.c | 4 | ||||
-rw-r--r-- | dbm/src/memmove.c | 3 | ||||
-rw-r--r-- | dbm/src/nsres.c | 2 | ||||
-rw-r--r-- | dbm/src/snprintf.c | 3 | ||||
-rw-r--r-- | dbm/src/strerror.c | 2 | ||||
-rw-r--r-- | dbm/tests/Makefile.in | 10 | ||||
-rw-r--r-- | dbm/tests/lots.c | 12 |
16 files changed, 68 insertions, 55 deletions
diff --git a/dbm/include/Makefile.win b/dbm/include/Makefile.win index 51e96b2c2..2370b606b 100644 --- a/dbm/include/Makefile.win +++ b/dbm/include/Makefile.win @@ -34,9 +34,6 @@ OPTIMIZER=-Os -UDEBUG -DNDEBUG #//------------------------------------------------------------------------ DEPTH= ..\.. -## Include support for MOZ_LITE/MOZ_MEDIUM -include <$(DEPTH)/config/liteness.mak> - !ifndef MAKE_OBJ_TYPE MAKE_OBJ_TYPE=EXE !endif diff --git a/dbm/include/extern.h b/dbm/include/extern.h index cfb20b940..8eabc81fe 100644 --- a/dbm/include/extern.h +++ b/dbm/include/extern.h @@ -40,10 +40,10 @@ 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 *, - int, uint32, SPLIT_RETURN *); + uint32, uint32, SPLIT_RETURN *); int __buf_free (HTAB *, int, int); void __buf_init (HTAB *, int); -uint32 __call_hash (HTAB *, char *, 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); diff --git a/dbm/include/hash.h b/dbm/include/hash.h index b898fe048..70f93e938 100644 --- a/dbm/include/hash.h +++ b/dbm/include/hash.h @@ -183,7 +183,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((B)+1)-1] : 0) + (B) + hashp->HDRPAGES + ((B) ? hashp->SPARES[__log2((uint32)((B)+1))-1] : 0) #define OADDR_TO_PAGE(B) \ BUCKET_TO_PAGE ( (1 << SPLITNUM((B))) -1 ) + OPAGENUM((B)); @@ -311,10 +311,10 @@ 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, int len); +uint32 __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,int addr,uint32 obucket, SPLIT_RETURN *ret); +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); diff --git a/dbm/include/mcom_db.h b/dbm/include/mcom_db.h index 64dabe725..6f81d7f71 100644 --- a/dbm/include/mcom_db.h +++ b/dbm/include/mcom_db.h @@ -450,4 +450,14 @@ __END_DECLS #include <machine/endian.h> #endif +#ifdef __alpha +#ifndef WIN32 +#else +/* Alpha NT */ +#define BYTE_ORDER LITTLE_ENDIAN +#define BIG_ENDIAN 4321 +#define LITTLE_ENDIAN 1234 +#endif +#endif + #endif /* !_DB_H_ */ diff --git a/dbm/src/Makefile.in b/dbm/src/Makefile.in index f44c55409..26e76b014 100644 --- a/dbm/src/Makefile.in +++ b/dbm/src/Makefile.in @@ -23,7 +23,7 @@ srcdir = @srcdir@ include $(DEPTH)/config/autoconf.mk MODULE = dbm -LIBRARY_NAME = $(MOZ_LIB_DBM_PREFIX)dbm +LIBRARY_NAME = mozdbm LIB_IS_C_ONLY = 1 diff --git a/dbm/src/Makefile.win b/dbm/src/Makefile.win index 9bec23888..247cacade 100644 --- a/dbm/src/Makefile.win +++ b/dbm/src/Makefile.win @@ -34,9 +34,6 @@ OPTIMIZER=-Os -UDEBUG -DNDEBUG #//------------------------------------------------------------------------ DEPTH= ..\.. -## Include support for MOZ_LITE/MOZ_MEDIUM -include <$(DEPTH)/config/liteness.mak> - !ifndef MAKE_OBJ_TYPE MAKE_OBJ_TYPE=EXE !endif diff --git a/dbm/src/h_bigkey.c b/dbm/src/h_bigkey.c index b482f440c..07c2f98ed 100644 --- a/dbm/src/h_bigkey.c +++ b/dbm/src/h_bigkey.c @@ -472,7 +472,7 @@ collect_data( totlen = len + mylen; if (hashp->tmp_buf) free(hashp->tmp_buf); - if ((hashp->tmp_buf = (char *)malloc(totlen)) == NULL) + if ((hashp->tmp_buf = (char *)malloc((size_t)totlen)) == NULL) return (-1); if (set) { hashp->cndx = 1; @@ -500,7 +500,7 @@ collect_data( errno = EINVAL; /* Out of buffers. */ return (-1); } - memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], mylen); + memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], (size_t)mylen); return (totlen); } @@ -547,7 +547,7 @@ collect_key( if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA) { /* End of Key. */ if (hashp->tmp_key != NULL) free(hashp->tmp_key); - if ((hashp->tmp_key = (char *)malloc(totlen)) == NULL) + if ((hashp->tmp_key = (char *)malloc((size_t)totlen)) == NULL) return (-1); if (__big_return(hashp, bufp, 1, val, set)) return (-1); @@ -561,7 +561,7 @@ collect_key( errno = EINVAL; /* MIS -- OUT OF BUFFERS */ return (-1); } - memmove(&hashp->tmp_key[len], (bufp->page) + bp[1], mylen); + memmove(&hashp->tmp_key[len], (bufp->page) + bp[1], (size_t)mylen); return (totlen); } @@ -577,7 +577,7 @@ __big_split( 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 */ + uint32 addr, /* Address of big_keyp */ uint32 obucket,/* Old Bucket */ SPLIT_RETURN *ret) { diff --git a/dbm/src/h_page.c b/dbm/src/h_page.c index fbbf6d88d..2ae72af3e 100644 --- a/dbm/src/h_page.c +++ b/dbm/src/h_page.c @@ -159,7 +159,7 @@ long new_lseek(int fd, long offset, int origin) memset(&buffer, 0, 1024); while(len > 0) { - write(fd, (char*)&buffer, (1024 > len ? len : 1024)); + write(fd, (char*)&buffer, (size_t)(1024 > len ? len : 1024)); len -= 1024; } return(lseek(fd, seek_pos, SEEK_SET)); @@ -285,7 +285,8 @@ __split_page(HTAB *hashp, uint32 obucket, uint32 nbucket) DBT key, val; uint16 n, ndx; int retval; - uint16 copyto, diff, off, moved; + uint16 copyto, diff, moved; + size_t off; char *op; copyto = (uint16)hashp->BSIZE; @@ -684,7 +685,8 @@ __get_page(HTAB *hashp, int is_disk, int is_bitmap) { - register int fd, page, size; + register int fd, page; + size_t size; int rsize; uint16 *bp; @@ -819,7 +821,8 @@ __get_page(HTAB *hashp, extern int __put_page(HTAB *hashp, char *p, uint32 bucket, int is_bucket, int is_bitmap) { - register int fd, page, size; + register int fd, page; + size_t size; int wsize; size = hashp->BSIZE; @@ -904,9 +907,9 @@ extern int __ibitmap(HTAB *hashp, int pnum, int nbits, int ndx) { uint32 *ip; - int clearbytes, clearints; + size_t clearbytes, clearints; - if ((ip = (uint32 *)malloc(hashp->BSIZE)) == NULL) + if ((ip = (uint32 *)malloc((size_t)hashp->BSIZE)) == NULL) return (1); hashp->nmaps++; clearints = ((nbits - 1) >> INT_BYTE_SHIFT) + 1; @@ -1201,7 +1204,7 @@ fetch_bitmap(HTAB *hashp, uint32 ndx) { if (ndx >= hashp->nmaps) return (NULL); - if ((hashp->mapp[ndx] = (uint32 *)malloc(hashp->BSIZE)) == NULL) + if ((hashp->mapp[ndx] = (uint32 *)malloc((size_t)hashp->BSIZE)) == NULL) return (NULL); if (__get_page(hashp, (char *)hashp->mapp[ndx], hashp->BITMAPS[ndx], 0, 1, 1)) { diff --git a/dbm/src/hash.c b/dbm/src/hash.c index 10001a39a..267ac0618 100644 --- a/dbm/src/hash.c +++ b/dbm/src/hash.c @@ -81,7 +81,7 @@ static int hash_delete __P((const DB *, const DBT *, uint)); static int hash_fd __P((const DB *)); static int hash_get __P((const DB *, const DBT *, DBT *, uint)); static int hash_put __P((const DB *, DBT *, const DBT *, uint)); -static void *hash_realloc __P((SEGMENT **, int, int)); +static void *hash_realloc __P((SEGMENT **, size_t, size_t)); static int hash_seq __P((const DB *, DBT *, DBT *, uint)); static int hash_sync __P((const DB *, uint)); static int hdestroy __P((HTAB *)); @@ -411,7 +411,7 @@ init_hash(HTAB *hashp, const char *file, HASHINFO *info) if (stat(file, &statbuf)) return (NULL); -#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) +#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) && !defined(VMS) #ifdef __QNX__ hashp->BSIZE = statbuf.st_size; #else @@ -424,7 +424,7 @@ init_hash(HTAB *hashp, const char *file, HASHINFO *info) if (hashp->BSIZE > MAX_BSIZE) hashp->BSIZE = MAX_BSIZE; #endif - hashp->BSHIFT = __log2(hashp->BSIZE); + hashp->BSHIFT = __log2((uint32)hashp->BSIZE); } if (info) { @@ -477,7 +477,7 @@ init_htab(HTAB *hashp, int nelem) */ nelem = (nelem - 1) / hashp->FFACTOR + 1; - l2 = __log2(MAX(nelem, 2)); + l2 = __log2((uint32)MAX(nelem, 2)); nbuckets = 1 << l2; hashp->SPARES[l2] = l2 + 1; @@ -486,7 +486,7 @@ init_htab(HTAB *hashp, int nelem) hashp->LAST_FREED = 2; /* First bitmap page is at: splitpoint l2 page offset 1 */ - if (__ibitmap(hashp, OADDR_OF(l2, 1), l2 + 1, 0)) + if (__ibitmap(hashp, (int)OADDR_OF(l2, 1), l2 + 1, 0)) return (-1); hashp->MAX_BUCKET = hashp->LOW_MASK = nbuckets - 1; @@ -495,7 +495,7 @@ init_htab(HTAB *hashp, int nelem) hashp->BSHIFT) + 1; nsegs = (nbuckets - 1) / hashp->SGSIZE + 1; - nsegs = 1 << __log2(nsegs); + nsegs = 1 << __log2((uint32)nsegs); if (nsegs > hashp->DSIZE) hashp->DSIZE = nsegs; @@ -763,7 +763,8 @@ hash_access( register BUFHEAD *rbufp; BUFHEAD *bufp, *save_bufp; register uint16 *bp; - register long n, ndx, off, size; + register long n, ndx, off; + register size_t size; register char *kp; uint16 pageno; uint32 ovfl_loop_count=0; @@ -822,7 +823,7 @@ hash_access( off = hashp->BSIZE; } else if (bp[1] < REAL_KEY) { if ((ndx = - __find_bigpair(hashp, rbufp, ndx, kp, size)) > 0) + __find_bigpair(hashp, rbufp, ndx, kp, (int)size)) > 0) goto found; if (ndx == -2) { bufp = rbufp; @@ -998,7 +999,8 @@ extern int __expand_table(HTAB *hashp) { uint32 old_bucket, new_bucket; - int dirsize, new_segnum, spare_ndx; + int new_segnum, spare_ndx; + size_t dirsize; #ifdef HASH_STATISTICS hash_expansions++; @@ -1019,7 +1021,7 @@ __expand_table(HTAB *hashp) hashp->DSIZE = dirsize << 1; } if ((hashp->dir[new_segnum] = - (SEGMENT)calloc(hashp->SGSIZE, sizeof(SEGMENT))) == NULL) + (SEGMENT)calloc((size_t)hashp->SGSIZE, sizeof(SEGMENT))) == NULL) return (-1); hashp->exsegs++; hashp->nsegs++; @@ -1029,7 +1031,7 @@ __expand_table(HTAB *hashp) * * increases), we need to copy the current contents of the spare * split bucket to the next bucket. */ - spare_ndx = __log2(hashp->MAX_BUCKET + 1); + spare_ndx = __log2((uint32)(hashp->MAX_BUCKET + 1)); if (spare_ndx > hashp->OVFL_POINT) { hashp->SPARES[spare_ndx] = hashp->SPARES[hashp->OVFL_POINT]; hashp->OVFL_POINT = spare_ndx; @@ -1051,7 +1053,7 @@ __expand_table(HTAB *hashp) static void * hash_realloc( SEGMENT **p_ptr, - int oldsize, int newsize) + size_t oldsize, size_t newsize) { register void *p; @@ -1065,7 +1067,7 @@ hash_realloc( } extern uint32 -__call_hash(HTAB *hashp, char *k, int len) +__call_hash(HTAB *hashp, char *k, size_t len) { uint32 n, bucket; @@ -1092,7 +1094,7 @@ alloc_segs( int save_errno; if ((hashp->dir = - (SEGMENT *)calloc(hashp->DSIZE, sizeof(SEGMENT *))) == NULL) { + (SEGMENT *)calloc((size_t)hashp->DSIZE, sizeof(SEGMENT *))) == NULL) { save_errno = errno; (void)hdestroy(hashp); errno = save_errno; @@ -1100,7 +1102,7 @@ alloc_segs( } /* Allocate segments */ if ((store = - (SEGMENT)calloc(nsegs << hashp->SSHIFT, sizeof(SEGMENT))) == NULL) { + (SEGMENT)calloc((size_t)nsegs << hashp->SSHIFT, sizeof(SEGMENT))) == NULL) { save_errno = errno; (void)hdestroy(hashp); errno = save_errno; diff --git a/dbm/src/hash_buf.c b/dbm/src/hash_buf.c index f30bee32e..35968601b 100644 --- a/dbm/src/hash_buf.c +++ b/dbm/src/hash_buf.c @@ -216,7 +216,7 @@ newbuf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp) */ memset(bp, 0xff, sizeof(BUFHEAD)); - if ((bp->page = (char *)malloc(hashp->BSIZE)) == NULL) { + if ((bp->page = (char *)malloc((size_t)hashp->BSIZE)) == NULL) { free(bp); return (NULL); } @@ -224,7 +224,7 @@ newbuf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp) /* this memset is supposedly unnecessary but lets add * it anyways. */ - memset(bp->page, 0xff, hashp->BSIZE); + memset(bp->page, 0xff, (size_t)hashp->BSIZE); if (hashp->nbufs) hashp->nbufs--; diff --git a/dbm/src/memmove.c b/dbm/src/memmove.c index 8a1942f77..c4f9ff02e 100644 --- a/dbm/src/memmove.c +++ b/dbm/src/memmove.c @@ -145,3 +145,6 @@ done: #endif } #endif /* no __sgi */ + +/* Some compilers don't like an empty source file. */ +static int dummy = 0; diff --git a/dbm/src/nsres.c b/dbm/src/nsres.c index 1751b7c08..44b448cf7 100644 --- a/dbm/src/nsres.c +++ b/dbm/src/nsres.c @@ -49,7 +49,7 @@ int GenKeyData(const char *library, int32 id, DBT *key) { char idstr[10]; static char * strdata = NULL; - int len; + size_t len; if (strdata) free (strdata); diff --git a/dbm/src/snprintf.c b/dbm/src/snprintf.c index 57ebfbfdd..5c30bd3f8 100644 --- a/dbm/src/snprintf.c +++ b/dbm/src/snprintf.c @@ -68,3 +68,6 @@ vsnprintf(str, n, fmt, ap) } #endif /* HAVE_SNPRINTF */ + +/* Some compilers don't like an empty source file. */ +static int dummy; diff --git a/dbm/src/strerror.c b/dbm/src/strerror.c index 68b0bea59..d1ae2666a 100644 --- a/dbm/src/strerror.c +++ b/dbm/src/strerror.c @@ -43,6 +43,7 @@ static char sccsid[] = "@(#)strerror.c 8.1 (Berkeley) 6/4/93"; #define sys_nerr (*_sys_nerr_dll) #endif +#ifndef HAVE_STRERROR #ifndef _AFXDLL char * strerror(num) @@ -74,3 +75,4 @@ strerror(num) } #endif +#endif /* !HAVE_STRERROR */ diff --git a/dbm/tests/Makefile.in b/dbm/tests/Makefile.in index 97849c69e..2d8b5a44a 100644 --- a/dbm/tests/Makefile.in +++ b/dbm/tests/Makefile.in @@ -1,4 +1,3 @@ -#!gmake # # The contents of this file are subject to the Netscape Public License # Version 1.0 (the "NPL"); you may not use this file except in @@ -14,6 +13,7 @@ # Communications Corporation. Portions created by Netscape are # Copyright (C) 1998 Netscape Communications Corporation. All Rights # Reserved. +# DEPTH = ../.. topsrcdir = @top_srcdir@ @@ -24,15 +24,11 @@ include $(DEPTH)/config/autoconf.mk MODULE = dbm -CSRCS = lots.c - PROGRAM = lots -#REQUIRES = $(MOZ_LIB_DBM_PREFIX)dbm +CSRCS = lots.c -LIBS = \ - $(DIST)/bin/lib$(MOZ_LIB_DBM_PREFIX)dbm.$(DLL_SUFFIX) \ - $(NULL) +LIBS = -lmozdbm include $(topsrcdir)/config/rules.mk diff --git a/dbm/tests/lots.c b/dbm/tests/lots.c index 3dccb2509..e2c9cda04 100644 --- a/dbm/tests/lots.c +++ b/dbm/tests/lots.c @@ -134,9 +134,9 @@ DBT * MakeLargeKey(int32 num) /* malloc a string low_bits wide */ size = low_bits*sizeof(char); - string_rv = (char *)malloc(size); + string_rv = (char *)malloc((size_t)size); - memset(string_rv, rep_char, size); + memset(string_rv, rep_char, (size_t)size); rv.data = string_rv; rv.size = size; @@ -151,7 +151,7 @@ DBT * MakeSmallKey(int32 num) rv.data = data_string; - sprintf(data_string, "%ld", num); + sprintf(data_string, "%ld", (long)num); rv.size = strlen(data_string); return(&rv); @@ -251,7 +251,6 @@ VerifyData(DBT *data, int32 num, key_type_enum key_type) int VerifyRange(int32 low, int32 high, int32 should_exist, key_type_enum key_type) { - char key_buf[128]; DBT *key, data; int32 num; int status; @@ -327,7 +326,7 @@ GenData(int32 num) size = sizeof(int32)*(n+1); - int32_array = (int32 *) malloc(size); + int32_array = (int32 *) malloc((size_t)size); memcpy(&int32_array[0], &n, sizeof(int32)); @@ -348,9 +347,10 @@ GenData(int32 num) int AddOrDelRange(int32 low, int32 high, int action, key_type_enum key_type) { - char key_buf[128]; DBT *key, *data; +#if 0 /* only do this if your really analy checking the puts */ DBT tmp_data; +#endif int32 num; int status; |