Home | History | Annotate | only in /src/lib/libc/db/hash
History log of /src/lib/libc/db/hash
RevisionDateAuthorComments
 1.9 13-Sep-2005  christos compat core reorg.
 1.8 28-Apr-2004  kleink XPG4.2: Change member `dsize' of struct datum from int to size_t.
Version dbm_{delete,fetch,firstkey,nextkey,store}() accordingly.
Fixes PRs standards/21402 from Ben Harris and standards/25343 from
Murray Armfield.
 1.7 14-Feb-2001  cgd build new hsearch() code
 1.6 03-May-1996  cgd branches: 1.6.18;
merge DB 1.85 changes
 1.5 27-Feb-1995  cgd add unintrusive Ids
 1.4 18-Aug-1994  cgd branches: 1.4.2;
clean up import
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 14-Jun-1993  cgd update db code to v1.6 from vangogh, and put it in "db" rather than "DB"
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd update to db 1.79
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.2.2 18-Aug-1994  cgd clean up import
 1.4.2.1 18-Aug-1994  cgd file Makefile.inc was added on branch netbsd-1-0 on 1994-08-18 00:40:40 +0000
 1.6.18.1 13-Mar-2001  he Pull up revision 1.7 (requested by cgd):
Replace hcreate() / hsearch() / hdestroy() implementation with
one that actually works as it's supposed to.
 1.6 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.5 16-Feb-1999  kleink Dispose the private search.h header and use <search.h>, which is a superset,
instead.
 1.4 03-May-1996  cgd merge DB 1.85 changes
 1.3 27-Feb-1995  cgd add unintrusive Ids
 1.2 14-Jun-1993  cgd update db code to v1.6 from vangogh, and put it in "db" rather than "DB"
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd update to db 1.79
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3 13-Sep-2005  christos compat core reorg.
 1.2 29-Apr-2004  kleink XPG4.2: when it is attempted to open a database write-only, silently
"upgrade" to use read/write access on the database file.
 1.1 28-Apr-2004  kleink XPG4.2: Change member `dsize' of struct datum from int to size_t.
Version dbm_{delete,fetch,firstkey,nextkey,store}() accordingly.
Fixes PRs standards/21402 from Ben Harris and standards/25343 from
Murray Armfield.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 14-Jun-1993  mycroft Clean up deleted files.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 14-Jun-1993  mycroft Clean up deleted files.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 14-Jun-1993  mycroft Clean up deleted files.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9 26-Aug-2008  joerg branches: 1.9.6;
Convert db from UCB types to POSIX types. Prefer uint8_t for u_char as
it is mostly about the wire format.

Patched libc.so is bit-identical.

OK matt@
 1.8 03-Feb-2007  christos branches: 1.8.12;
cleanup:
- remove __P
- remove unneeded casts
- add _DIAGASSERT
- add more diagnostics for integer overflow
- fix size_t/int confusion
- make debugging and statistics code compile
 1.7 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.6 09-Dec-1998  christos delint
 1.5 03-May-1996  cgd merge DB 1.85 changes
 1.4 27-Feb-1995  cgd add unintrusive Ids
 1.3 18-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 14-Jun-1993  cgd branches: 1.1.1;
update db code to v1.6 from vangogh, and put it in "db" rather than "DB"
 1.1.1.1 17-Aug-1994  cgd update to db 1.79
 1.3.2.2 18-Aug-1994  cgd clean up import
 1.3.2.1 18-Aug-1994  cgd file extern.h was added on branch netbsd-1-0 on 1994-08-18 00:40:44 +0000
 1.8.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.9.6.2 26-Aug-2008  joerg Convert db from UCB types to POSIX types. Prefer uint8_t for u_char as
it is mostly about the wire format.

Patched libc.so is bit-identical.

OK matt@
 1.9.6.1 26-Aug-2008  joerg file extern.h was added on branch christos-time_t on 2008-08-26 21:18:39 +0000
 1.38 18-Nov-2015  christos Introduce a HASH_BSIZE macro to return the blocksize; in the 64K case this
returns 0xffff to avoid overflow. This is used where sizes are stored.
 1.37 18-Nov-2015  christos Account for the -1 hack to fit 0x10000 in a short in hash_page.c
 1.36 17-Nov-2015  christos PR/50441: Manuel Bouyer: hash seq enumeration skips keys on big data.
XXX: pullup-7
 1.35 22-Jun-2015  christos Fix hash iteration that deletes the current element under the cursor by
adjusting the position of the iterator appropriately.
XXX: pullup 7
 1.34 22-Jun-2015  christos Delay moving to the next key until the next iteration. This avoids returning
invalid data to the user if the user deletes the current key, but it also
fails to iterate over some keys as will be shown by a unit test. From FreeBSD.
 1.33 01-Dec-2013  christos branches: 1.33.4;
- centralize opening of regular and temp files to avoid code duplication
- don't cast malloc
- use malloc sizeof(*var) instead of sizeof(type)
 1.32 13-Mar-2012  christos branches: 1.32.2;
PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.31 12-Feb-2009  lukem branches: 1.31.6;
fix -Wsign-compare issues
 1.30 11-Sep-2008  joerg branches: 1.30.6; 1.30.8;
Consistently include "nbtool_config.h" when cross-compiling.
 1.29 10-Sep-2008  joerg In preparation for providing a db fallback in libnbcompat, remove
sccsid and conditionals around __RCSID. lint understands __RCSID enough
to ignore it, undefining LIBC_SCCS is superseded by MKSTRIPIDENT.
No functional changes.
 1.28 26-Aug-2008  joerg Convert db from UCB types to POSIX types. Prefer uint8_t for u_char as
it is mostly about the wire format.

Patched libc.so is bit-identical.

OK matt@
 1.27 03-Feb-2007  christos branches: 1.27.12;
cleanup:
- remove __P
- remove unneeded casts
- add _DIAGASSERT
- add more diagnostics for integer overflow
- fix size_t/int confusion
- make debugging and statistics code compile
 1.26 19-Mar-2006  rtr retrun -> return
 1.25 19-Mar-2006  christos Coverity CID 518: Avoid NULL pointer deref.
 1.24 19-Mar-2006  christos Coverity CID 508: Avoid memory leak.
 1.23 29-Nov-2005  christos WARNS=4
 1.22 16-Oct-2005  christos Initialize a variable that might confuse gcc as uninitialized.
 1.21 29-Mar-2005  christos Don't refuse to create a hash database on 0 length files. Treat
them as new files the same way that the btree code does. Note that
we do the fstat() after the open() instead of re-using the previous
result of the stat() to avoid races (we open with O_EXLOCK when we care).
 1.20 06-Mar-2005  christos branches: 1.20.2;
Revert previous commit at 1.17. a maximum BSIZE of 65536 ends up stored
as a 0 in the page, but it is supported and it does work.
 1.19 19-Jan-2005  mycroft hash already uses FD_CLOEXEC -- pay attention to the return value and make it
a hard failure.

Also make btree and recno uses FD_CLOEXEC.
 1.18 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.17 11-Dec-2002  christos Only allow BSIZE to 1^16 - 1:
- fix off by one error
- limit the default from the filesystem
 1.16 12-Jan-2002  aymeric use %p instead of %x when displaying a pointer
 1.15 09-Dec-1998  christos branches: 1.15.12;
delint
 1.14 14-Oct-1998  kleink Need "namespace.h".
 1.13 30-Jun-1998  thorpej Use pread(2) and pwrite(2) where appropriate.
 1.12 07-May-1998  kleink Change the file mode argument to dbopen() and the db backends from int to
mode_t.
 1.11 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings.
 1.10 07-Nov-1996  jtc Rename the errno field in struct htab to err, as the former name
conflicts with a macro implementation of errno.h's errno.
 1.9 03-May-1996  cgd merge DB 1.85 changes
 1.8 27-Feb-1995  cgd add unintrusive Ids
 1.7 18-Aug-1994  cgd branches: 1.7.2; 1.7.4;
clean up import
 1.6 13-Jan-1994  cgd fix sall memory leak. from Christopher Jon Kane <kane@kidd.vet.purdue.edu>
 1.5 20-Oct-1993  cgd update to v1.72 of new DB code
 1.4 09-Sep-1993  cgd upgrade new DB code to version 1.7
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 14-Jun-1993  cgd branches: 1.1.1;
update db code to v1.6 from vangogh, and put it in "db" rather than "DB"
 1.1.1.1 17-Aug-1994  cgd update to db 1.79
 1.7.4.1 02-May-1995  jtc #include "namespace.h"
 1.7.2.2 18-Aug-1994  cgd clean up import
 1.7.2.1 18-Aug-1994  cgd file hash.c was added on branch netbsd-1-0 on 1994-08-18 00:40:50 +0000
 1.15.12.2 19-Dec-2002  thorpej Sync with HEAD.
 1.15.12.1 28-Jan-2002  nathanw Catch up to -current.
 1.20.2.1 30-Mar-2005  tron Pull up revision 1.21 (requested by christos in ticket #78):
Don't refuse to create a hash database on 0 length files. Treat
them as new files the same way that the btree code does. Note that
we do the fstat() after the open() instead of re-using the previous
result of the stat() to avoid races (we open with O_EXLOCK when we care).
 1.27.12.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.27.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.30.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.30.6.2 11-Sep-2008  joerg Consistently include "nbtool_config.h" when cross-compiling.
 1.30.6.1 11-Sep-2008  joerg file hash.c was added on branch christos-time_t on 2008-09-11 12:58:01 +0000
 1.31.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.31.6.1 17-Apr-2012  yamt sync with head
 1.32.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.33.4.2 22-Nov-2015  bouyer Pull up following revision(s) (requested by christos in ticket #1046):
lib/libc/db/hash/hash_page.c: revision 1.27
lib/libc/db/hash/hash_page.c: revision 1.28
lib/libc/db/hash/hash.h: revision 1.16
lib/libc/db/hash/hash.c: revision 1.36
lib/libc/db/hash/hash.c: revision 1.37
lib/libc/db/hash/hash.c: revision 1.38
lib/libc/db/hash/hash_bigkey.c: revision 1.25
Account for the -1 hack to fit 0x10000 in a short in hash_page.c
Introduce a HASH_BSIZE macro to return the blocksize; in the 64K case this
returns 0xffff to avoid overflow. This is used where sizes are stored.
If MAX_BSIZE == hashp->BSIZE (65536) then it does not fit in a short, and
we end up storing 0... This means that every entry needs a page. We store
MAX_BSIZE - 1 here, but it would be better to always store (avail - 1) here
so that we don't waste a byte and be consistent.
PR/50441: Manuel Bouyer: hash seq enumeration skips keys on big data.
XXX: pullup-7
 1.33.4.1 06-Aug-2015  snj Pull up following revision(s) (requested by christos in ticket #921):
lib/libc/db/hash/hash.c: revision 1.34
lib/libc/db/hash/hash.c: revision 1.35
Delay moving to the next key until the next iteration. This avoids returning
invalid data to the user if the user deletes the current key, but it also
fails to iterate over some keys as will be shown by a unit test. From FreeBSD.
--
Fix hash iteration that deletes the current element under the cursor by
adjusting the position of the iterator appropriately.
 1.17 21-Feb-2020  kamil Avoid undefined behavior in *BIT macros

hash_page.c:792:2, left shift of 1 by 31 places cannot be represented in type 'int'
hash_page.c:855:2, left shift of 1 by 31 places cannot be represented in type 'int'
hash_page.c:779:3, left shift of 1 by 31 places cannot be represented in type 'int'
 1.16 18-Nov-2015  christos branches: 1.16.16;
Introduce a HASH_BSIZE macro to return the blocksize; in the 64K case this
returns 0xffff to avoid overflow. This is used where sizes are stored.
 1.15 26-Aug-2008  joerg branches: 1.15.6; 1.15.40;
Convert db from UCB types to POSIX types. Prefer uint8_t for u_char as
it is mostly about the wire format.

Patched libc.so is bit-identical.

OK matt@
 1.14 03-Feb-2007  christos branches: 1.14.12;
cleanup:
- remove __P
- remove unneeded casts
- add _DIAGASSERT
- add more diagnostics for integer overflow
- fix size_t/int confusion
- make debugging and statistics code compile
 1.13 27-Oct-2003  lukem Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 30-May-2002  itojun use int32_t, instead of int, for on-disk data.
(so that we are safe in the future)
 1.10 21-Jan-2002  tv Add hooks for reachover builds from src/tools/compat.
 1.9 11-Jun-2001  wiz Fix various misspellings of compatible/compatibility.
 1.8 09-Dec-1998  christos branches: 1.8.12;
delint
 1.7 07-Nov-1996  jtc Rename the errno field in struct htab to err, as the former name
conflicts with a macro implementation of errno.h's errno.
 1.6 03-May-1996  cgd merge DB 1.85 changes
 1.5 27-Feb-1995  cgd add unintrusive Ids
 1.4 18-Aug-1994  cgd branches: 1.4.2;
clean up import
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 14-Jun-1993  cgd update db code to v1.6 from vangogh, and put it in "db" rather than "DB"
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd update to db 1.79
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.2.2 18-Aug-1994  cgd clean up import
 1.4.2.1 18-Aug-1994  cgd file hash.h was added on branch netbsd-1-0 on 1994-08-18 00:40:53 +0000
 1.8.12.3 21-Jun-2002  nathanw Catch up to -current.
 1.8.12.2 28-Jan-2002  nathanw Catch up to -current.
 1.8.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.14.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.15.40.1 22-Nov-2015  bouyer Pull up following revision(s) (requested by christos in ticket #1046):
lib/libc/db/hash/hash_page.c: revision 1.27
lib/libc/db/hash/hash_page.c: revision 1.28
lib/libc/db/hash/hash.h: revision 1.16
lib/libc/db/hash/hash.c: revision 1.36
lib/libc/db/hash/hash.c: revision 1.37
lib/libc/db/hash/hash.c: revision 1.38
lib/libc/db/hash/hash_bigkey.c: revision 1.25
Account for the -1 hack to fit 0x10000 in a short in hash_page.c
Introduce a HASH_BSIZE macro to return the blocksize; in the 64K case this
returns 0xffff to avoid overflow. This is used where sizes are stored.
If MAX_BSIZE == hashp->BSIZE (65536) then it does not fit in a short, and
we end up storing 0... This means that every entry needs a page. We store
MAX_BSIZE - 1 here, but it would be better to always store (avail - 1) here
so that we don't waste a byte and be consistent.
PR/50441: Manuel Bouyer: hash seq enumeration skips keys on big data.
XXX: pullup-7
 1.15.6.2 26-Aug-2008  joerg Convert db from UCB types to POSIX types. Prefer uint8_t for u_char as
it is mostly about the wire format.

Patched libc.so is bit-identical.

OK matt@
 1.15.6.1 26-Aug-2008  joerg file hash.h was added on branch christos-time_t on 2008-08-26 21:18:39 +0000
 1.16.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 14-Jun-1993  mycroft Clean up deleted files.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.25 18-Nov-2015  christos Introduce a HASH_BSIZE macro to return the blocksize; in the 64K case this
returns 0xffff to avoid overflow. This is used where sizes are stored.
 1.24 13-Mar-2012  christos branches: 1.24.10;
PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.23 12-Feb-2009  lukem branches: 1.23.6;
fix sign-compare issues
 1.22 10-Sep-2008  joerg branches: 1.22.6; 1.22.8;
In preparation for providing a db fallback in libnbcompat, remove
sccsid and conditionals around __RCSID. lint understands __RCSID enough
to ignore it, undefining LIBC_SCCS is superseded by MKSTRIPIDENT.
No functional changes.
 1.21 26-Aug-2008  joerg Convert db from UCB types to POSIX types. Prefer uint8_t for u_char as
it is mostly about the wire format.

Patched libc.so is bit-identical.

OK matt@
 1.20 03-Feb-2007  christos branches: 1.20.12;
cleanup:
- remove __P
- remove unneeded casts
- add _DIAGASSERT
- add more diagnostics for integer overflow
- fix size_t/int confusion
- make debugging and statistics code compile
 1.19 27-Apr-2005  christos Don't attempt to delete a NULL key. Can happen if we were the only key
in a 64K page. Thanks to Juergen Hannken-Illjes for the test.
 1.18 20-Jun-2004  jmc branches: 1.18.2;
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.17 07-Aug-2003  agc branches: 1.17.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.16 20-Apr-2003  christos PR/5996: ITOH Yasufumi: lib/libc/db/hash/* writes memory garbage to db file
Fixed by changing malloc's to calloc's where needed.
 1.15 20-Jan-2003  simonb The Double-Semi-Colon Police.
 1.14 29-Jul-1999  mycroft branches: 1.14.12;
When deleting a big key, the offset of an empty page should be bsize, not
bsize-1; otherwise an insertion into the empty page will cause the new key to
be elongated by 1 byte.
 1.13 29-Jul-1999  mycroft Previous bug fix was slightly wrong. In this case, the data must start on a
new page, or we will mistakenly think the first page is the end of the data.
 1.12 28-Jul-1999  mycroft Make the packing more dense in a couple of cases.
 1.11 28-Jul-1999  mycroft If (keysize+datasize)%(bsize=14)==0, insertion of a `big key' would cause an
invariant (actually, an ugly hack) to fail, and all Hell would break loose.
 1.10 10-Jul-1999  christos don't compare non-pointer values against NULL.
 1.9 09-Dec-1998  christos delint
 1.8 18-Aug-1998  thorpej Add some braces to make egcs happy.
 1.7 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings.
 1.6 03-May-1996  cgd merge DB 1.85 changes
 1.5 27-Feb-1995  cgd add unintrusive Ids
 1.4 18-Aug-1994  cgd branches: 1.4.2;
clean up import
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 14-Jun-1993  cgd branches: 1.1.1;
update db code to v1.6 from vangogh, and put it in "db" rather than "DB"
 1.1.1.1 17-Aug-1994  cgd update to db 1.79
 1.4.2.2 18-Aug-1994  cgd clean up import
 1.4.2.1 18-Aug-1994  cgd file hash_bigkey.c was added on branch netbsd-1-0 on 1994-08-18 00:40:56 +0000
 1.14.12.1 06-Apr-2004  jmc Pullup rev 1.16 (requested by bouyer in ticket #1651)

lib/libc/db/hash/* writes memory garbage to db file.
Fixed by changing malloc's to calloc's where needed. PR#5996
 1.17.2.1 22-Jun-2004  tron Pull up revision 1.18 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.18.2.1 28-Apr-2005  tron Pull up revision 1.19 (requested by christos in ticket #212):
Don't attempt to delete a NULL key. Can happen if we were the only key
in a 64K page. Thanks to Juergen Hannken-Illjes for the test.
 1.20.12.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.20.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.22.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.22.6.2 10-Sep-2008  joerg In preparation for providing a db fallback in libnbcompat, remove
sccsid and conditionals around __RCSID. lint understands __RCSID enough
to ignore it, undefining LIBC_SCCS is superseded by MKSTRIPIDENT.
No functional changes.
 1.22.6.1 10-Sep-2008  joerg file hash_bigkey.c was added on branch christos-time_t on 2008-09-10 17:52:36 +0000
 1.23.6.1 17-Apr-2012  yamt sync with head
 1.24.10.1 22-Nov-2015  bouyer Pull up following revision(s) (requested by christos in ticket #1046):
lib/libc/db/hash/hash_page.c: revision 1.27
lib/libc/db/hash/hash_page.c: revision 1.28
lib/libc/db/hash/hash.h: revision 1.16
lib/libc/db/hash/hash.c: revision 1.36
lib/libc/db/hash/hash.c: revision 1.37
lib/libc/db/hash/hash.c: revision 1.38
lib/libc/db/hash/hash_bigkey.c: revision 1.25
Account for the -1 hack to fit 0x10000 in a short in hash_page.c
Introduce a HASH_BSIZE macro to return the blocksize; in the 64K case this
returns 0xffff to avoid overflow. This is used where sizes are stored.
If MAX_BSIZE == hashp->BSIZE (65536) then it does not fit in a short, and
we end up storing 0... This means that every entry needs a page. We store
MAX_BSIZE - 1 here, but it would be better to always store (avail - 1) here
so that we don't waste a byte and be consistent.
PR/50441: Manuel Bouyer: hash seq enumeration skips keys on big data.
XXX: pullup-7
 1.18 23-Apr-2009  christos correct cast to size_t.
 1.17 23-Apr-2009  agc Cast the arg to an unsigned value to let this compile
 1.16 22-Apr-2009  njoly Include string.h for memset prototype.
 1.15 22-Apr-2009  christos Avoid information leaks by zeroing memory, from FreeBSD (we had done some
already)
 1.14 10-Sep-2008  joerg branches: 1.14.4; 1.14.6; 1.14.8;
In preparation for providing a db fallback in libnbcompat, remove
sccsid and conditionals around __RCSID. lint understands __RCSID enough
to ignore it, undefining LIBC_SCCS is superseded by MKSTRIPIDENT.
No functional changes.
 1.13 26-Aug-2008  joerg Convert db from UCB types to POSIX types. Prefer uint8_t for u_char as
it is mostly about the wire format.

Patched libc.so is bit-identical.

OK matt@
 1.12 03-Feb-2007  christos branches: 1.12.12;
cleanup:
- remove __P
- remove unneeded casts
- add _DIAGASSERT
- add more diagnostics for integer overflow
- fix size_t/int confusion
- make debugging and statistics code compile
 1.11 20-Jun-2004  jmc branches: 1.11.10; 1.11.14;
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.10 07-Aug-2003  agc branches: 1.10.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 20-Apr-2003  christos PR/5996: ITOH Yasufumi: lib/libc/db/hash/* writes memory garbage to db file
Fixed by changing malloc's to calloc's where needed.
 1.8 09-Dec-1998  christos branches: 1.8.14;
delint
 1.7 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings.
 1.6 03-May-1996  cgd merge DB 1.85 changes
 1.5 27-Feb-1995  cgd add unintrusive Ids
 1.4 18-Aug-1994  cgd branches: 1.4.2;
clean up import
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 14-Jun-1993  cgd branches: 1.1.1;
update db code to v1.6 from vangogh, and put it in "db" rather than "DB"
 1.1.1.2 03-May-1996  cgd Import of Berkeley DB version 1.85
 1.1.1.1 17-Aug-1994  cgd update to db 1.79
 1.4.2.2 18-Aug-1994  cgd clean up import
 1.4.2.1 18-Aug-1994  cgd file hash_buf.c was added on branch netbsd-1-0 on 1994-08-18 00:41:00 +0000
 1.8.14.1 06-Apr-2004  jmc Pullup rev 1.9 (requested by bouyer in ticket #1651)

lib/libc/db/hash/* writes memory garbage to db file.
Fixed by changing malloc's to calloc's where needed. PR#5996
 1.10.2.1 22-Jun-2004  tron Pull up revision 1.11 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.11.14.3 30-Apr-2009  bouyer Pull up following revision(s) (requested by hauke in ticket #1311):
lib/libc/db/hash/hash_buf.c: revision 1.17, 1.18
lib/libc/db/hash/hash_buf.c: revision 1.18
Fix build fallout from ticket 1310
 1.11.14.2 23-Apr-2009  snj Pull up following revision(s) (requested by christos in ticket #1310):
lib/libc/db/hash/hash_buf.c: revision 1.16 via patch
Include string.h for memset prototype.
 1.11.14.1 23-Apr-2009  snj Pull up following revision(s) (requested by christos in ticket #1310):
lib/libc/db/btree/bt_split.c: revision 1.19
lib/libc/db/hash/hash_buf.c: revision 1.15
lib/libc/db/mpool/mpool.c: revision 1.19
Avoid information leaks by zeroing memory, from FreeBSD (we had done some
already)
 1.11.10.3 30-Apr-2009  bouyer Pull up following revision(s) (requested by hauke in ticket #1311):
lib/libc/db/hash/hash_buf.c: revision 1.17, 1.18
lib/libc/db/hash/hash_buf.c: revision 1.18
Fix build fallout from ticket 1310
 1.11.10.2 23-Apr-2009  snj Pull up following revision(s) (requested by christos in ticket #1310):
lib/libc/db/hash/hash_buf.c: revision 1.16 via patch
Include string.h for memset prototype.
 1.11.10.1 23-Apr-2009  snj Pull up following revision(s) (requested by christos in ticket #1310):
lib/libc/db/mpool/mpool.c: revision 1.19
lib/libc/db/hash/hash_buf.c: revision 1.15
lib/libc/db/btree/bt_split.c: revision 1.19
Avoid information leaks by zeroing memory, from FreeBSD (we had done some
already)
 1.12.12.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.12.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.14.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.14.6.2 10-Sep-2008  joerg In preparation for providing a db fallback in libnbcompat, remove
sccsid and conditionals around __RCSID. lint understands __RCSID enough
to ignore it, undefining LIBC_SCCS is superseded by MKSTRIPIDENT.
No functional changes.
 1.14.6.1 10-Sep-2008  joerg file hash_buf.c was added on branch christos-time_t on 2008-09-10 17:52:36 +0000
 1.14.4.4 23-Apr-2009  snj Pull up following revision(s) (requested by agc in ticket #723):
lib/libc/db/hash/hash_buf.c: revision 1.18
correct cast to size_t.
 1.14.4.3 23-Apr-2009  snj Pull up following revision(s) (requested by agc in ticket #723):
lib/libc/db/hash/hash_buf.c: revision 1.17
Cast the arg to an unsigned value to let this compile
 1.14.4.2 23-Apr-2009  snj Pull up following revision(s) (requested by christos in ticket #719):
lib/libc/db/hash/hash_buf.c: revision 1.16
Include string.h for memset prototype.
 1.14.4.1 23-Apr-2009  snj Pull up following revision(s) (requested by christos in ticket #719):
lib/libc/db/btree/bt_split.c: revision 1.19
lib/libc/db/hash/hash_buf.c: revision 1.15
lib/libc/db/mpool/mpool.c: revision 1.19
Avoid information leaks by zeroing memory, from FreeBSD (we had done some
already)
 1.13 10-Sep-2008  joerg branches: 1.13.6;
In preparation for providing a db fallback in libnbcompat, remove
sccsid and conditionals around __RCSID. lint understands __RCSID enough
to ignore it, undefining LIBC_SCCS is superseded by MKSTRIPIDENT.
No functional changes.
 1.12 26-Aug-2008  joerg Convert db from UCB types to POSIX types. Prefer uint8_t for u_char as
it is mostly about the wire format.

Patched libc.so is bit-identical.

OK matt@
 1.11 03-Feb-2007  christos branches: 1.11.12;
cleanup:
- remove __P
- remove unneeded casts
- add _DIAGASSERT
- add more diagnostics for integer overflow
- fix size_t/int confusion
- make debugging and statistics code compile
 1.10 20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.9 07-Aug-2003  agc branches: 1.9.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.8 09-Dec-1998  christos delint
 1.7 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings.
 1.6 03-May-1996  cgd merge DB 1.85 changes
 1.5 27-Feb-1995  cgd add unintrusive Ids
 1.4 18-Aug-1994  cgd branches: 1.4.2;
clean up import
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 14-Jun-1993  cgd branches: 1.1.1;
update db code to v1.6 from vangogh, and put it in "db" rather than "DB"
 1.1.1.1 17-Aug-1994  cgd update to db 1.79
 1.4.2.2 18-Aug-1994  cgd clean up import
 1.4.2.1 18-Aug-1994  cgd file hash_func.c was added on branch netbsd-1-0 on 1994-08-18 00:41:03 +0000
 1.9.2.1 22-Jun-2004  tron Pull up revision 1.10 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.11.12.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.11.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.13.6.2 10-Sep-2008  joerg In preparation for providing a db fallback in libnbcompat, remove
sccsid and conditionals around __RCSID. lint understands __RCSID enough
to ignore it, undefining LIBC_SCCS is superseded by MKSTRIPIDENT.
No functional changes.
 1.13.6.1 10-Sep-2008  joerg file hash_func.c was added on branch christos-time_t on 2008-09-10 17:52:36 +0000
 1.13 11-Sep-2008  joerg branches: 1.13.6;
Remove one remaining sccsid.
 1.12 28-Aug-2008  joerg Fix __log2 to not loop for 0x80000000 and higher.
 1.11 26-Aug-2008  joerg Convert db from UCB types to POSIX types. Prefer uint8_t for u_char as
it is mostly about the wire format.

Patched libc.so is bit-identical.

OK matt@
 1.10 03-Feb-2007  christos branches: 1.10.12;
cleanup:
- remove __P
- remove unneeded casts
- add _DIAGASSERT
- add more diagnostics for integer overflow
- fix size_t/int confusion
- make debugging and statistics code compile
 1.9 20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.8 07-Aug-2003  agc branches: 1.8.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings.
 1.6 03-May-1996  cgd merge DB 1.85 changes
 1.5 27-Feb-1995  cgd add unintrusive Ids
 1.4 18-Aug-1994  cgd branches: 1.4.2;
clean up import
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 14-Jun-1993  cgd branches: 1.1.1;
update db code to v1.6 from vangogh, and put it in "db" rather than "DB"
 1.1.1.1 17-Aug-1994  cgd update to db 1.79
 1.4.2.2 18-Aug-1994  cgd clean up import
 1.4.2.1 18-Aug-1994  cgd file hash_log2.c was added on branch netbsd-1-0 on 1994-08-18 00:41:05 +0000
 1.8.2.1 22-Jun-2004  tron Pull up revision 1.9 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.10.12.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.10.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.13.6.2 11-Sep-2008  joerg Remove one remaining sccsid.
 1.13.6.1 11-Sep-2008  joerg file hash_log2.c was added on branch christos-time_t on 2008-09-11 12:33:56 +0000
 1.29 24-Sep-2016  christos When writing out pages in the "other endian" format, make a copy instead of
trashing the in-memory one.
 1.28 18-Nov-2015  christos branches: 1.28.2;
Introduce a HASH_BSIZE macro to return the blocksize; in the 64K case this
returns 0xffff to avoid overflow. This is used where sizes are stored.
 1.27 18-Nov-2015  christos If MAX_BSIZE == hashp->BSIZE (65536) then it does not fit in a short, and
we end up storing 0... This means that every entry needs a page. We store
MAX_BSIZE - 1 here, but it would be better to always store (avail - 1) here
so that we don't waste a byte and be consistent.
 1.26 01-Dec-2013  christos branches: 1.26.4;
- centralize opening of regular and temp files to avoid code duplication
- don't cast malloc
- use malloc sizeof(*var) instead of sizeof(type)
 1.25 13-Mar-2012  christos branches: 1.25.2;
PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.24 17-Apr-2011  christos branches: 1.24.4;
Correct check for snprintf() overflow via Maksymilian Arciemowicz from FreeBSD.
(the bt one was ok, but set errno and make it the same for consistency).
[to be pulled up]
 1.23 11-Sep-2008  joerg branches: 1.23.4; 1.23.6; 1.23.10; 1.23.14;
Consistently include "nbtool_config.h" when cross-compiling.
 1.22 10-Sep-2008  joerg In preparation for providing a db fallback in libnbcompat, remove
sccsid and conditionals around __RCSID. lint understands __RCSID enough
to ignore it, undefining LIBC_SCCS is superseded by MKSTRIPIDENT.
No functional changes.
 1.21 26-Aug-2008  joerg Convert db from UCB types to POSIX types. Prefer uint8_t for u_char as
it is mostly about the wire format.

Patched libc.so is bit-identical.

OK matt@
 1.20 03-Feb-2007  christos branches: 1.20.12;
cleanup:
- remove __P
- remove unneeded casts
- add _DIAGASSERT
- add more diagnostics for integer overflow
- fix size_t/int confusion
- make debugging and statistics code compile
 1.19 03-Nov-2006  christos branches: 1.19.2;
use FD_CLOEXEC instead of 1.
 1.18 26-Mar-2006  rtr make __hash_open obey TMPDIR

resolves pr32565 and pr32454
 1.17 24-Jan-2006  christos simplify assertion.
 1.16 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.15 29-Jul-1999  mycroft Only squeeze a short key/value pair onto a page with other complete key/value
pairs, not onto a page containing the end of a big pair.
 1.14 29-Jul-1999  mycroft Return a useful errno value in the overflow case.
Also, print a message to stderr in one more case.
 1.13 09-Dec-1998  christos delint
 1.12 14-Oct-1998  kleink Need "namespace.h".
 1.11 26-Jul-1998  mycroft Reinitialize the mkstemp() template each time it's used.
 1.10 30-Jun-1998  thorpej Use pread(2) and pwrite(2) where appropriate.
 1.9 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings.
 1.8 03-May-1996  cgd merge DB 1.85 changes
 1.7 27-Feb-1995  cgd add unintrusive Ids
 1.6 18-Aug-1994  cgd branches: 1.6.2; 1.6.4;
clean up import
 1.5 17-Sep-1993  cgd get rid of extraneous include of machine/endian.h now that it's
included by sys/types.h
 1.4 09-Sep-1993  cgd upgrade new DB code to version 1.7
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 14-Jun-1993  cgd branches: 1.1.1;
update db code to v1.6 from vangogh, and put it in "db" rather than "DB"
 1.1.1.2 03-May-1996  cgd Import of Berkeley DB version 1.85
 1.1.1.1 17-Aug-1994  cgd update to db 1.79
 1.6.4.1 02-May-1995  jtc #include "namespace.h"
 1.6.2.2 18-Aug-1994  cgd clean up import
 1.6.2.1 18-Aug-1994  cgd file hash_page.c was added on branch netbsd-1-0 on 1994-08-18 00:41:09 +0000
 1.19.2.1 08-May-2011  bouyer Pull up following revision(s) (requested by christos in ticket #1428):
lib/libc/db/hash/hash_page.c: revision 1.24
lib/libc/db/btree/bt_open.c: revision 1.25
Correct check for snprintf() overflow via Maksymilian Arciemowicz from FreeBSD.
(the bt one was ok, but set errno and make it the same for consistency).
[to be pulled up]
 1.20.12.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.20.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.23.14.1 19-May-2011  bouyer Pull up following revision(s) (requested by christos in ticket #1602):
lib/libc/db/hash/hash_page.c: revision 1.24
lib/libc/db/btree/bt_open.c: revision 1.25
Correct check for snprintf() overflow via Maksymilian Arciemowicz from FreeBSD.
(the bt one was ok, but set errno and make it the same for consistency).
[to be pulled up]
 1.23.10.1 19-May-2011  bouyer Pull up following revision(s) (requested by christos in ticket #1602):
lib/libc/db/hash/hash_page.c: revision 1.24
lib/libc/db/btree/bt_open.c: revision 1.25
Correct check for snprintf() overflow via Maksymilian Arciemowicz from FreeBSD.
(the bt one was ok, but set errno and make it the same for consistency).
[to be pulled up]
 1.23.6.2 11-Sep-2008  joerg Consistently include "nbtool_config.h" when cross-compiling.
 1.23.6.1 11-Sep-2008  joerg file hash_page.c was added on branch christos-time_t on 2008-09-11 12:58:01 +0000
 1.23.4.1 19-May-2011  bouyer Pull up following revision(s) (requested by christos in ticket #1602):
lib/libc/db/hash/hash_page.c: revision 1.24
lib/libc/db/btree/bt_open.c: revision 1.25
Correct check for snprintf() overflow via Maksymilian Arciemowicz from FreeBSD.
(the bt one was ok, but set errno and make it the same for consistency).
[to be pulled up]
 1.24.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.24.4.1 17-Apr-2012  yamt sync with head
 1.25.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.4.1 22-Nov-2015  bouyer Pull up following revision(s) (requested by christos in ticket #1046):
lib/libc/db/hash/hash_page.c: revision 1.27
lib/libc/db/hash/hash_page.c: revision 1.28
lib/libc/db/hash/hash.h: revision 1.16
lib/libc/db/hash/hash.c: revision 1.36
lib/libc/db/hash/hash.c: revision 1.37
lib/libc/db/hash/hash.c: revision 1.38
lib/libc/db/hash/hash_bigkey.c: revision 1.25
Account for the -1 hack to fit 0x10000 in a short in hash_page.c
Introduce a HASH_BSIZE macro to return the blocksize; in the 64K case this
returns 0xffff to avoid overflow. This is used where sizes are stored.
If MAX_BSIZE == hashp->BSIZE (65536) then it does not fit in a short, and
we end up storing 0... This means that every entry needs a page. We store
MAX_BSIZE - 1 here, but it would be better to always store (avail - 1) here
so that we don't waste a byte and be consistent.
PR/50441: Manuel Bouyer: hash seq enumeration skips keys on big data.
XXX: pullup-7
 1.28.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 01-Mar-1995  mycroft Clean up deleted files.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.15 14-Feb-2001  cgd nuke old, unredeemably broken DB-based version of hsearch() et al.
 1.14 16-Feb-1999  kleink branches: 1.14.10;
Per XSI5, make ENTRY.data a typeless pointer.
 1.13 16-Feb-1999  kleink Per XSI5, let hcreate() take a size_t argument.
 1.12 16-Feb-1999  kleink Dispose the private search.h header and use <search.h>, which is a superset,
instead.
 1.11 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings.
 1.10 03-May-1996  cgd branches: 1.10.2;
reapply diff from rev. 1.7. can't cast pointers to ints; what's really wanted
here is foo != NULL.
 1.9 03-May-1996  cgd merge DB 1.85 changes
 1.8 27-Feb-1995  cgd add unintrusive Ids
 1.7 19-Oct-1994  cgd be a bit nicer with the return value
 1.6 18-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 09-Sep-1993  cgd upgrade new DB code to version 1.7
 1.4 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 14-Jun-1993  cgd update db code to v1.6 from vangogh, and put it in "db" rather than "DB"
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 03-May-1996  cgd Import of Berkeley DB version 1.85
 1.1.1.2 17-Aug-1994  cgd update to db 1.79
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 18-Aug-1994  cgd clean up import
 1.6.2.1 18-Aug-1994  cgd file hsearch.c was added on branch netbsd-1-0 on 1994-08-18 00:41:12 +0000
 1.10.2.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.14.10.1 13-Mar-2001  he Pull up file removal (requested by cgd):
Replace hcreate() / hsearch() / hdestroy() implementation with
one that actually works as it's supposed to.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 01-Mar-1995  mycroft Clean up deleted files.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.23 11-Sep-2008  joerg branches: 1.23.6;
Consistently include "nbtool_config.h" when cross-compiling.
 1.22 10-Sep-2008  joerg In preparation for providing a db fallback in libnbcompat, remove
sccsid and conditionals around __RCSID. lint understands __RCSID enough
to ignore it, undefining LIBC_SCCS is superseded by MKSTRIPIDENT.
No functional changes.
 1.21 03-Feb-2007  christos branches: 1.21.12;
cleanup:
- remove __P
- remove unneeded casts
- add _DIAGASSERT
- add more diagnostics for integer overflow
- fix size_t/int confusion
- make debugging and statistics code compile
 1.20 13-Sep-2005  christos compat core reorg.
 1.19 28-Apr-2004  kleink XPG4.2: Change member `dsize' of struct datum from int to size_t.
Version dbm_{delete,fetch,firstkey,nextkey,store}() accordingly.
Fixes PRs standards/21402 from Ben Harris and standards/25343 from
Murray Armfield.
 1.18 27-Apr-2004  kleink Remove internal names for dbm_*(3); these are not required at this time.
 1.17 07-Aug-2003  agc branches: 1.17.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.16 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.15 09-Dec-1998  christos delint
 1.14 07-May-1998  kleink Change the file mode argument to dbm_open() from int to mode_t.
 1.13 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.12 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings.
 1.11 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.10 07-Nov-1996  jtc Rename the errno field in struct htab to err, as the former name
conflicts with a macro implementation of errno.h's errno.
 1.9 04-May-1996  cgd branches: 1.9.2;
fix a bug that shows up only on alphas: ndbm "datum" variables can't be
cast to DBTs, because the 'size' fields are int and size_t,
respectively, and that means that the DBT size field would be
partially filled with garbage on the Alpha. Bug fix sent to bostic.
 1.8 03-May-1996  cgd merge DB 1.85 changes
 1.7 27-Feb-1995  cgd add unintrusive Ids
 1.6 18-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 17-Sep-1993  cgd version 1.71 of new db code
 1.4 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 14-Jun-1993  cgd update db code to v1.6 from vangogh, and put it in "db" rather than "DB"
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 03-May-1996  cgd Import of Berkeley DB version 1.85
 1.1.1.2 17-Aug-1994  cgd update to db 1.79
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 18-Aug-1994  cgd clean up import
 1.6.2.1 18-Aug-1994  cgd file ndbm.c was added on branch netbsd-1-0 on 1994-08-18 00:41:16 +0000
 1.9.2.1 16-Sep-1996  jtc snapshot namespace cleanup
 1.17.2.1 30-Apr-2004  jmc Pullup patch (requested by kleink in ticket #240)

XPG4.2: when it is attempted to open a database write-only, silently
"upgrade" to use read/write access on the database file.
 1.21.12.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.23.6.2 11-Sep-2008  joerg Consistently include "nbtool_config.h" when cross-compiling.
 1.23.6.1 11-Sep-2008  joerg file ndbm.c was added on branch christos-time_t on 2008-09-11 12:58:01 +0000
 1.5 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.4 11-Sep-2008  joerg branches: 1.4.2; 1.4.6;
Consistently include "nbtool_config.h" when cross-compiling.
 1.3 10-Sep-2008  joerg In preparation for providing a db fallback in libnbcompat, remove
sccsid and conditionals around __RCSID. lint understands __RCSID enough
to ignore it, undefining LIBC_SCCS is superseded by MKSTRIPIDENT.
No functional changes.
 1.2 03-Feb-2007  christos branches: 1.2.12;
cleanup:
- remove __P
- remove unneeded casts
- add _DIAGASSERT
- add more diagnostics for integer overflow
- fix size_t/int confusion
- make debugging and statistics code compile
 1.1 13-Sep-2005  christos compat core reorg.
 1.2.12.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.4.6.2 11-Sep-2008  joerg Consistently include "nbtool_config.h" when cross-compiling.
 1.4.6.1 11-Sep-2008  joerg file ndbmdatum.c was added on branch christos-time_t on 2008-09-11 12:58:01 +0000
 1.4.2.1 17-Apr-2012  yamt sync with head
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 01-Mar-1995  mycroft Clean up deleted files.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8 26-Aug-2008  joerg branches: 1.8.6;
Convert db from UCB types to POSIX types. Prefer uint8_t for u_char as
it is mostly about the wire format.

Patched libc.so is bit-identical.

OK matt@
 1.7 07-Aug-2003  agc branches: 1.7.32;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.6 03-May-1996  cgd merge DB 1.85 changes
 1.5 27-Feb-1995  cgd add unintrusive Ids
 1.4 18-Aug-1994  cgd branches: 1.4.2;
clean up import
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 14-Jun-1993  cgd update db code to v1.6 from vangogh, and put it in "db" rather than "DB"
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd update to db 1.79
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.2.2 18-Aug-1994  cgd clean up import
 1.4.2.1 18-Aug-1994  cgd file page.h was added on branch netbsd-1-0 on 1994-08-18 00:41:20 +0000
 1.7.32.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.8.6.2 26-Aug-2008  joerg Convert db from UCB types to POSIX types. Prefer uint8_t for u_char as
it is mostly about the wire format.

Patched libc.so is bit-identical.

OK matt@
 1.8.6.1 26-Aug-2008  joerg file page.h was added on branch christos-time_t on 2008-08-26 21:18:39 +0000
 1.7 16-Feb-1999  kleink Dispose the private search.h header and use <search.h>, which is a superset,
instead.
 1.6 03-May-1996  cgd merge DB 1.85 changes
 1.5 27-Feb-1995  cgd add unintrusive Ids
 1.4 18-Aug-1994  cgd branches: 1.4.2;
clean up import
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 14-Jun-1993  cgd update db code to v1.6 from vangogh, and put it in "db" rather than "DB"
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd update to db 1.79
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.2.2 18-Aug-1994  cgd clean up import
 1.4.2.1 18-Aug-1994  cgd file search.h was added on branch netbsd-1-0 on 1994-08-18 00:41:23 +0000

RSS XML Feed