summary refs log tree commit diff
path: root/db2/include
diff options
context:
space:
mode:
Diffstat (limited to 'db2/include')
-rw-r--r--db2/include/btree.h62
-rw-r--r--db2/include/btree_ext.h22
-rw-r--r--db2/include/clib_ext.h3
-rw-r--r--db2/include/common_ext.h47
-rw-r--r--db2/include/cxx_int.h4
-rw-r--r--db2/include/db.h.src245
-rw-r--r--db2/include/db_185.h.src28
-rw-r--r--db2/include/db_am.h4
-rw-r--r--db2/include/db_auto.h3
-rw-r--r--db2/include/db_cxx.h84
-rw-r--r--db2/include/db_dispatch.h24
-rw-r--r--db2/include/db_ext.h14
-rw-r--r--db2/include/db_int.h.src132
-rw-r--r--db2/include/db_page.h12
-rw-r--r--db2/include/db_shash.h4
-rw-r--r--db2/include/db_swap.h6
-rw-r--r--db2/include/hash.h4
-rw-r--r--db2/include/hash_ext.h18
-rw-r--r--db2/include/lock.h52
-rw-r--r--db2/include/lock_ext.h9
-rw-r--r--db2/include/log.h27
-rw-r--r--db2/include/log_ext.h4
-rw-r--r--db2/include/mp.h45
-rw-r--r--db2/include/mp_ext.h10
-rw-r--r--db2/include/mutex_ext.h2
-rw-r--r--db2/include/os_ext.h18
-rw-r--r--db2/include/os_func.h79
-rw-r--r--db2/include/queue.h2
-rw-r--r--db2/include/shqueue.h4
-rw-r--r--db2/include/txn.h20
30 files changed, 567 insertions, 421 deletions
diff --git a/db2/include/btree.h b/db2/include/btree.h
index 878096b7b2..1660d331e7 100644
--- a/db2/include/btree.h
+++ b/db2/include/btree.h
@@ -1,7 +1,7 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 /*
@@ -43,7 +43,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)btree.h	10.17 (Sleepycat) 9/23/97
+ *	@(#)btree.h	10.21 (Sleepycat) 5/23/98
  */
 
 /* Forward structure declarations. */
@@ -103,28 +103,39 @@ struct __recno;		typedef struct __recno RECNO;
  * to return deleted entries.  To simplify both the mnemonic representation
  * and the code that checks for various cases, we construct a set of bitmasks.
  */
-#define	S_READ		0x0001		/* Read locks. */
-#define	S_WRITE		0x0002		/* Write locks. */
-
-#define	S_APPEND	0x0040		/* Append to the tree. */
-#define	S_DELNO		0x0080		/* Don't return deleted items. */
-#define	S_DUPFIRST	0x0100		/* Return first duplicate. */
-#define	S_DUPLAST	0x0200		/* Return last duplicate. */
-#define	S_EXACT		0x0400		/* Exact items only. */
-#define	S_PARENT	0x0800		/* Lock page pair. */
-
-#define	S_DELETE	(S_WRITE | S_DUPFIRST | S_DELNO | S_EXACT)
+#define	S_READ		0x00001		/* Read locks. */
+#define	S_WRITE		0x00002		/* Write locks. */
+
+#define	S_APPEND	0x00040		/* Append to the tree. */
+#define	S_DELNO		0x00080		/* Don't return deleted items. */
+#define	S_DUPFIRST	0x00100		/* Return first duplicate. */
+#define	S_DUPLAST	0x00200		/* Return last duplicate. */
+#define	S_EXACT		0x00400		/* Exact items only. */
+#define	S_PARENT	0x00800		/* Lock page pair. */
+#define	S_STACK		0x01000		/* Need a complete stack. */
+
+#define	S_DELETE	(S_WRITE | S_DUPFIRST | S_DELNO | S_EXACT | S_STACK)
 #define	S_FIND		(S_READ | S_DUPFIRST | S_DELNO)
-#define	S_INSERT	(S_WRITE | S_DUPLAST)
-#define	S_KEYFIRST	(S_WRITE | S_DUPFIRST)
-#define	S_KEYLAST	(S_WRITE | S_DUPLAST)
+#define	S_INSERT	(S_WRITE | S_DUPLAST | S_STACK)
+#define	S_KEYFIRST	(S_WRITE | S_DUPFIRST | S_STACK)
+#define	S_KEYLAST	(S_WRITE | S_DUPLAST | S_STACK)
 #define	S_WRPAIR	(S_WRITE | S_DUPLAST | S_PARENT)
 
 /*
+ * If doing insert search (including keyfirst or keylast operations) or a
+ * split search on behalf of an insert, it's okay to return the entry one
+ * past the end of the page.
+ */
+#define	PAST_END_OK(f)							\
+	((f) == S_INSERT ||						\
+	(f) == S_KEYFIRST || (f) == S_KEYLAST || (f) == S_WRPAIR)
+
+/*
  * Flags to __bam_iitem().
  */
-#define	BI_NEWKEY	0x01		/* New key. */
-#define	BI_DELETED	0x02		/* Key/data pair only placeholder. */
+#define	BI_DELETED	0x01		/* Key/data pair only placeholder. */
+#define	BI_DOINCR	0x02		/* Increment the record count. */
+#define	BI_NEWKEY	0x04		/* New key. */
 
 /*
  * Various routines pass around page references.  A page reference can be a
@@ -138,6 +149,21 @@ struct __epg {
 };
 
 /*
+ * All cursors are queued from the master DB structure.  Convert the user's
+ * DB reference to the master DB reference.  We lock the master DB mutex
+ * so that we can walk the cursor queue.  There's no race in accessing the
+ * cursors, because if we're modifying a page, we have a write lock on it,
+ * and therefore no other thread than the current one can have a cursor that
+ * references the page.
+ */
+#define	CURSOR_SETUP(dbp) {						\
+	(dbp) = (dbp)->master;						\
+	DB_THREAD_LOCK(dbp);						\
+}
+#define	CURSOR_TEARDOWN(dbp)						\
+	DB_THREAD_UNLOCK(dbp);
+
+/*
  * Btree cursor.
  *
  * Arguments passed to __bam_ca_replace().
diff --git a/db2/include/btree_ext.h b/db2/include/btree_ext.h
index 9c34c8c6bf..b8a137364c 100644
--- a/db2/include/btree_ext.h
+++ b/db2/include/btree_ext.h
@@ -2,7 +2,7 @@
 #ifndef _btree_ext_h_
 #define _btree_ext_h_
 int __bam_close __P((DB *));
-int __bam_sync __P((DB *, int));
+int __bam_sync __P((DB *, u_int32_t));
 int __bam_cmp __P((DB *, const DBT *, EPG *));
 int __bam_defcmp __P((const DBT *, const DBT *));
 size_t __bam_defpfx __P((const DBT *, const DBT *));
@@ -11,7 +11,7 @@ int __bam_pgout __P((db_pgno_t, void *, DBT *));
 int __bam_mswap __P((PAGE *));
 int __bam_cursor __P((DB *, DB_TXN *, DBC **));
 int __bam_c_iclose __P((DB *, DBC *));
-int __bam_get __P((DB *, DB_TXN *, DBT *, DBT *, int));
+int __bam_get __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
 int __bam_ovfl_chk __P((DB *, CURSOR *, u_int32_t, int));
 int __bam_cprint __P((DB *));
 int __bam_ca_delete __P((DB *, db_pgno_t, u_int32_t, CURSOR *, int));
@@ -23,8 +23,8 @@ void __bam_ca_replace
    __P((DB *, db_pgno_t, u_int32_t, ca_replace_arg));
 void __bam_ca_split __P((DB *,
    db_pgno_t, db_pgno_t, db_pgno_t, u_int32_t, int));
-int __bam_delete __P((DB *, DB_TXN *, DBT *, int));
-int __ram_delete __P((DB *, DB_TXN *, DBT *, int));
+int __bam_delete __P((DB *, DB_TXN *, DBT *, u_int32_t));
+int __ram_delete __P((DB *, DB_TXN *, DBT *, u_int32_t));
 int __bam_ditem __P((DB *, PAGE *, u_int32_t));
 int __bam_adjindx __P((DB *, PAGE *, u_int32_t, u_int32_t, int));
 int __bam_dpage __P((DB *, const DBT *));
@@ -35,10 +35,10 @@ int __bam_free __P((DB *, PAGE *));
 int __bam_lt __P((DB *));
 int __bam_lget __P((DB *, int, db_pgno_t, db_lockmode_t, DB_LOCK *));
 int __bam_lput __P((DB *, DB_LOCK));
-int __bam_pget __P((DB *, PAGE **, db_pgno_t *, int));
-int __bam_put __P((DB *, DB_TXN *, DBT *, DBT *, int));
+int __bam_pget __P((DB *, PAGE **, db_pgno_t *, u_int32_t));
+int __bam_put __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
 int __bam_iitem __P((DB *,
-   PAGE **, db_indx_t *, DBT *, DBT *, int, int));
+   PAGE **, db_indx_t *, DBT *, DBT *, u_int32_t, u_int32_t));
 int __bam_ritem __P((DB *, PAGE *, u_int32_t, DBT *));
 int __bam_pg_alloc_recover
   __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
@@ -64,19 +64,19 @@ void __ram_ca __P((DB *, db_recno_t, ca_recno_arg));
 int __ram_cprint __P((DB *));
 int __ram_getno __P((DB *, const DBT *, db_recno_t *, int));
 int __ram_snapshot __P((DB *));
-int __bam_rsearch __P((DB *, db_recno_t *, u_int, int, int *));
-int __bam_adjust __P((DB *, BTREE *, int));
+int __bam_rsearch __P((DB *, db_recno_t *, u_int32_t, int, int *));
+int __bam_adjust __P((DB *, BTREE *, int32_t));
 int __bam_nrecs __P((DB *, db_recno_t *));
 db_recno_t __bam_total __P((PAGE *));
 int __bam_search __P((DB *,
-    const DBT *, u_int, int, db_recno_t *, int *));
+    const DBT *, u_int32_t, int, db_recno_t *, int *));
 int __bam_stkrel __P((DB *));
 int __bam_stkgrow __P((BTREE *));
 int __bam_split __P((DB *, void *));
 int __bam_broot __P((DB *, PAGE *, PAGE *, PAGE *));
 int __ram_root __P((DB *, PAGE *, PAGE *, PAGE *));
 int __bam_copy __P((DB *, PAGE *, PAGE *, u_int32_t, u_int32_t));
-int __bam_stat __P((DB *, void *, void *(*)(size_t), int));
+int __bam_stat __P((DB *, void *, void *(*)(size_t), u_int32_t));
 void __bam_add_mstat __P((DB_BTREE_LSTAT *, DB_BTREE_LSTAT *));
 int __bam_pg_alloc_log
     __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
diff --git a/db2/include/clib_ext.h b/db2/include/clib_ext.h
index eb982bf85f..f5510a1629 100644
--- a/db2/include/clib_ext.h
+++ b/db2/include/clib_ext.h
@@ -53,9 +53,6 @@ int snprintf __P((char *, size_t, const char *, ...));
 int snprintf();
 #endif
 #endif
-#ifndef HAVE_STRDUP
-char *strdup __P((const char *));
-#endif
 #ifndef HAVE_STRERROR
 char *strerror __P((int));
 #endif
diff --git a/db2/include/common_ext.h b/db2/include/common_ext.h
index b362c9c32e..4674f9ce01 100644
--- a/db2/include/common_ext.h
+++ b/db2/include/common_ext.h
@@ -2,8 +2,8 @@
 #ifndef _common_ext_h_
 #define _common_ext_h_
 int __db_appname __P((DB_ENV *,
-   APPNAME, const char *, const char *, int *, char **));
-int __db_apprec __P((DB_ENV *, int));
+   APPNAME, const char *, const char *, u_int32_t, int *, char **));
+int __db_apprec __P((DB_ENV *, u_int32_t));
 int __db_byteorder __P((DB_ENV *, int));
 #ifdef __STDC__
 void __db_err __P((const DB_ENV *dbenv, const char *fmt, ...));
@@ -11,35 +11,32 @@ void __db_err __P((const DB_ENV *dbenv, const char *fmt, ...));
 void __db_err();
 #endif
 int __db_panic __P((DB *));
-int __db_fchk __P((DB_ENV *, const char *, int, int));
-int __db_fcchk __P((DB_ENV *, const char *, int, int, int));
-int __db_cdelchk __P((const DB *, int, int, int));
-int __db_cgetchk __P((const DB *, DBT *, DBT *, int, int));
+int __db_fchk __P((DB_ENV *, const char *, u_int32_t, u_int32_t));
+int __db_fcchk
+   __P((DB_ENV *, const char *, u_int32_t, u_int32_t, u_int32_t));
+int __db_cdelchk __P((const DB *, u_int32_t, int, int));
+int __db_cgetchk __P((const DB *, DBT *, DBT *, u_int32_t, int));
 int __db_cputchk __P((const DB *,
-   const DBT *, DBT *, int, int, int));
-int __db_delchk __P((const DB *, int, int));
-int __db_getchk __P((const DB *, const DBT *, DBT *, int));
-int __db_putchk __P((const DB *, DBT *, const DBT *, int, int, int));
-int __db_statchk __P((const DB *, int));
-int __db_syncchk __P((const DB *, int));
+   const DBT *, DBT *, u_int32_t, int, int));
+int __db_delchk __P((const DB *, DBT *, u_int32_t, int));
+int __db_getchk __P((const DB *, const DBT *, DBT *, u_int32_t));
+int __db_putchk
+   __P((const DB *, DBT *, const DBT *, u_int32_t, int, int));
+int __db_statchk __P((const DB *, u_int32_t));
+int __db_syncchk __P((const DB *, u_int32_t));
 int __db_ferr __P((const DB_ENV *, const char *, int));
 u_int32_t __db_log2 __P((u_int32_t));
-int __db_rcreate __P((DB_ENV *, APPNAME,
-   const char *, const char *, int, size_t, int, int *, void *));
-int __db_rinit __P((DB_ENV *, RLAYOUT *, int, size_t, int));
-int __db_ropen __P((DB_ENV *,
-   APPNAME, const char *, const char *, int, int *, void *));
-int __db_rclose __P((DB_ENV *, int, void *));
-int __db_runlink __P((DB_ENV *,
-   APPNAME, const char *, const char *, int));
-int __db_rgrow __P((DB_ENV *, int, size_t));
-int __db_rremap __P((DB_ENV *, void *, size_t, size_t, int, void *));
+int __db_rattach __P((REGINFO *));
+int __db_rdetach __P((REGINFO *));
+int __db_runlink __P((REGINFO *, int));
+int __db_rgrow __P((REGINFO *, size_t));
+int __db_rreattach __P((REGINFO *, size_t));
 void __db_shalloc_init __P((void *, size_t));
 int __db_shalloc __P((void *, size_t, size_t, void *));
 void __db_shalloc_free __P((void *, void *));
 size_t __db_shalloc_count __P((void *));
 size_t __db_shsizeof __P((void *));
-void __db_shalloc_dump __P((FILE *, void *));
-int __db_tablesize __P((u_int));
-void __db_hashinit __P((void *, int));
+void __db_shalloc_dump __P((void *, FILE *));
+int __db_tablesize __P((u_int32_t));
+void __db_hashinit __P((void *, u_int32_t));
 #endif /* _common_ext_h_ */
diff --git a/db2/include/cxx_int.h b/db2/include/cxx_int.h
index bf7a09602d..0a59de4391 100644
--- a/db2/include/cxx_int.h
+++ b/db2/include/cxx_int.h
@@ -1,10 +1,10 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1997
+ * Copyright (c) 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  *
- *	@(#)cxx_int.h	10.4 (Sleepycat) 8/22/97
+ *	@(#)cxx_int.h	10.5 (Sleepycat) 4/10/98
  */
 
 #ifndef _CXX_INT_H_
diff --git a/db2/include/db.h.src b/db2/include/db.h.src
index ebdaa27470..97ad55693f 100644
--- a/db2/include/db.h.src
+++ b/db2/include/db.h.src
@@ -1,10 +1,10 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  *
- *	@(#)db.h.src	10.102 (Sleepycat) 1/18/98
+ *	@(#)db.h.src	10.131 (Sleepycat) 6/2/98
  */
 
 #ifndef _DB_H_
@@ -54,8 +54,7 @@
  *
  * !!!
  * We also provide the standard u_int, u_long etc., if they're not provided
- * by the system.  This isn't completely necessary, but the example programs
- * need them.
+ * by the system.
  */
 #ifndef	__BIT_TYPES_DEFINED__
 #define	__BIT_TYPES_DEFINED__
@@ -72,9 +71,9 @@
 @u_long_decl@
 
 #define	DB_VERSION_MAJOR	2
-#define	DB_VERSION_MINOR	3
-#define	DB_VERSION_PATCH	16
-#define	DB_VERSION_STRING	"Sleepycat Software: DB 2.3.16: (1/19/98)"
+#define	DB_VERSION_MINOR	4
+#define	DB_VERSION_PATCH	14
+#define	DB_VERSION_STRING	"Sleepycat Software: DB 2.4.14: (6/2/98)"
 
 typedef	u_int32_t	db_pgno_t;	/* Page number type. */
 typedef	u_int16_t	db_indx_t;	/* Page offset type. */
@@ -95,6 +94,7 @@ struct __db_bt_stat;	typedef struct __db_bt_stat DB_BTREE_STAT;
 struct __db_dbt;	typedef struct __db_dbt DBT;
 struct __db_env;	typedef struct __db_env DB_ENV;
 struct __db_info;	typedef struct __db_info DB_INFO;
+struct __db_lock_stat;	typedef struct __db_lock_stat DB_LOCK_STAT;
 struct __db_lockregion;	typedef struct __db_lockregion DB_LOCKREGION;
 struct __db_lockreq;	typedef struct __db_lockreq DB_LOCKREQ;
 struct __db_locktab;	typedef struct __db_locktab DB_LOCKTAB;
@@ -102,6 +102,7 @@ struct __db_log;	typedef struct __db_log DB_LOG;
 struct __db_log_stat;	typedef struct __db_log_stat DB_LOG_STAT;
 struct __db_lsn;	typedef struct __db_lsn DB_LSN;
 struct __db_mpool;	typedef struct __db_mpool DB_MPOOL;
+struct __db_mpool_finfo;typedef struct __db_mpool_finfo DB_MPOOL_FINFO;
 struct __db_mpool_fstat;typedef struct __db_mpool_fstat DB_MPOOL_FSTAT;
 struct __db_mpool_stat;	typedef struct __db_mpool_stat DB_MPOOL_STAT;
 struct __db_mpoolfile;	typedef struct __db_mpoolfile DB_MPOOLFILE;
@@ -134,7 +135,7 @@ struct __db_dbt {
  * There are a set of functions that the application can replace with its
  * own versions, and some other knobs which can be turned at run-time.
  */
-#define	DB_FUNC_CALLOC	 1		/* ANSI C calloc. */
+#define	DB_FUNC_CALLOC	 1	/* DELETED: ANSI C calloc. */
 #define	DB_FUNC_CLOSE	 2		/* POSIX 1003.1 close. */
 #define	DB_FUNC_DIRFREE	 3		/* DB: free directory list. */
 #define	DB_FUNC_DIRLIST	 4		/* DB: create directory list. */
@@ -149,12 +150,18 @@ struct __db_dbt {
 #define	DB_FUNC_REALLOC	13		/* ANSI C realloc. */
 #define	DB_FUNC_SEEK	14		/* POSIX 1003.1 lseek. */
 #define	DB_FUNC_SLEEP	15		/* DB: sleep secs/usecs. */
-#define	DB_FUNC_STRDUP	16		/* DB: strdup(3). */
+#define	DB_FUNC_STRDUP	16	/* DELETED: DB: strdup(3). */
 #define	DB_FUNC_UNLINK	17		/* POSIX 1003.1 unlink. */
 #define	DB_FUNC_UNMAP	18		/* DB: unmap shared memory file. */
 #define	DB_FUNC_WRITE	19		/* POSIX 1003.1 write. */
 #define	DB_FUNC_YIELD	20		/* DB: yield thread to scheduler. */
 #define	DB_TSL_SPINS	21		/* DB: initialize spin count. */
+#define	DB_FUNC_RUNLINK	22		/* DB: remove a shared region. */
+#define	DB_REGION_ANON	23		/* DB: anonymous, unnamed regions. */
+#define	DB_REGION_INIT	24		/* DB: page-fault regions in create. */
+#define	DB_REGION_NAME	25		/* DB: anonymous, named regions. */
+#define	DB_MUTEXLOCKS	26		/* DB: turn off all mutex locks. */
+#define	DB_PAGEYIELD	27		/* DB: yield the CPU on pool get. */
 
 /*
  * Database configuration and initialization.
@@ -162,52 +169,51 @@ struct __db_dbt {
  /*
   * Flags understood by both db_open(3) and db_appinit(3).
   */
-#define	DB_CREATE		0x00001	/* O_CREAT: create file as necessary. */
-#define	DB_NOMMAP		0x00002	/* Don't mmap underlying file. */
-#define	DB_THREAD		0x00004	/* Free-thread DB package handles. */
+#define	DB_CREATE	      0x000001	/* O_CREAT: create file as necessary. */
+#define	DB_NOMMAP	      0x000002	/* Don't mmap underlying file. */
+#define	DB_THREAD	      0x000004	/* Free-thread DB package handles. */
 
 /*
  * Flags understood by db_appinit(3).
- *
- * DB_MUTEXDEBUG is internal only, and not documented.
  */
-/*				0x00007	   COMMON MASK. */
-#define	DB_INIT_LOCK		0x00008	/* Initialize locking. */
-#define	DB_INIT_LOG		0x00010	/* Initialize logging. */
-#define	DB_INIT_MPOOL		0x00020	/* Initialize mpool. */
-#define	DB_INIT_TXN		0x00040	/* Initialize transactions. */
-#define	DB_MPOOL_PRIVATE	0x00080	/* Mpool: private memory pool. */
-#define	DB_MUTEXDEBUG		0x00100	/* Do not get/set mutexes in regions. */
-#define	DB_RECOVER		0x00200	/* Run normal recovery. */
-#define	DB_RECOVER_FATAL	0x00400 /* Run catastrophic recovery. */
-#define	DB_TXN_NOSYNC		0x00800	/* Do not sync log on commit. */
-#define	DB_USE_ENVIRON		0x01000	/* Use the environment. */
-#define	DB_USE_ENVIRON_ROOT	0x02000	/* Use the environment if root. */
+/*			      0x000007	   COMMON MASK. */
+#define	DB_INIT_LOCK	      0x000008	/* Initialize locking. */
+#define	DB_INIT_LOG	      0x000010	/* Initialize logging. */
+#define	DB_INIT_MPOOL	      0x000020	/* Initialize mpool. */
+#define	DB_INIT_TXN	      0x000040	/* Initialize transactions. */
+#define	DB_MPOOL_PRIVATE      0x000080	/* Mpool: private memory pool. */
+#define	__UNUSED_100	      0x000100
+#define	DB_RECOVER	      0x000200	/* Run normal recovery. */
+#define	DB_RECOVER_FATAL      0x000400	/* Run catastrophic recovery. */
+#define	DB_TXN_NOSYNC	      0x000800	/* Do not sync log on commit. */
+#define	DB_USE_ENVIRON	      0x001000	/* Use the environment. */
+#define	DB_USE_ENVIRON_ROOT   0x002000	/* Use the environment if root. */
 
 /* CURRENTLY UNUSED LOCK FLAGS. */
-#define	DB_TXN_LOCK_2PL		0x00000	/* Two-phase locking. */
-#define	DB_TXN_LOCK_OPTIMISTIC	0x00000	/* Optimistic locking. */
-#define	DB_TXN_LOCK_MASK	0x00000	/* Lock flags mask. */
+#define	DB_TXN_LOCK_2PL	      0x000000	/* Two-phase locking. */
+#define	DB_TXN_LOCK_OPTIMIST  0x000000	/* Optimistic locking. */
+#define	DB_TXN_LOCK_MASK      0x000000	/* Lock flags mask. */
 
 /* CURRENTLY UNUSED LOG FLAGS. */
-#define	DB_TXN_LOG_REDO		0x00000	/* Redo-only logging. */
-#define	DB_TXN_LOG_UNDO		0x00000	/* Undo-only logging. */
-#define	DB_TXN_LOG_UNDOREDO	0x00000	/* Undo/redo write-ahead logging. */
-#define	DB_TXN_LOG_MASK		0x00000	/* Log flags mask. */
+#define	DB_TXN_LOG_REDO	      0x000000	/* Redo-only logging. */
+#define	DB_TXN_LOG_UNDO	      0x000000	/* Undo-only logging. */
+#define	DB_TXN_LOG_UNDOREDO   0x000000	/* Undo/redo write-ahead logging. */
+#define	DB_TXN_LOG_MASK	      0x000000	/* Log flags mask. */
 
 /*
  * Flags understood by db_open(3).
  *
- * DB_EXCL and DB_TEMPORARY are internal only, and not documented.
- * DB_SEQUENTIAL is currently internal, but likely to be exported some day.
+ * DB_EXCL and DB_TEMPORARY are internal only, and are not documented.
+ * DB_SEQUENTIAL is currently internal, but may be exported some day.
  */
-/*				0x00007	   COMMON MASK. */
-/*				0x07fff	   ALREADY USED. */
-#define	DB_EXCL			0x08000	/* O_EXCL: exclusive open. */
-#define	DB_RDONLY		0x10000	/* O_RDONLY: read-only. */
-#define	DB_SEQUENTIAL		0x20000	/* Indicate sequential access. */
-#define	DB_TEMPORARY		0x40000	/* Remove on last close. */
-#define	DB_TRUNCATE		0x80000	/* O_TRUNCATE: replace existing DB. */
+/*			      0x000007	   COMMON MASK. */
+/*			      0x003fff	   ALREADY USED. */
+#define	__UNUSED_4000	      0x004000
+#define	DB_EXCL		      0x008000	/* O_EXCL: exclusive open. */
+#define	DB_RDONLY	      0x010000	/* O_RDONLY: read-only. */
+#define	DB_SEQUENTIAL	      0x020000	/* Indicate sequential access. */
+#define	DB_TEMPORARY	      0x040000	/* Remove on last close. */
+#define	DB_TRUNCATE	      0x080000	/* O_TRUNCATE: replace existing DB. */
 
 /*
  * Deadlock detector modes; used in the DBENV structure to configure the
@@ -240,9 +246,9 @@ struct __db_env {
 	/* Locking. */
 	DB_LOCKTAB	*lk_info;	/* Return from lock_open(). */
 	u_int8_t	*lk_conflicts;	/* Two dimensional conflict matrix. */
-	int		 lk_modes;	/* Number of lock modes in table. */
-	u_int		 lk_max;	/* Maximum number of locks. */
-	u_int32_t	 lk_detect;	/* Deadlock detect on every conflict. */
+	u_int32_t	 lk_modes;	/* Number of lock modes in table. */
+	u_int32_t	 lk_max;	/* Maximum number of locks. */
+	u_int32_t	 lk_detect;	/* Deadlock detect on all conflicts. */
 
 	/* Logging. */
 	DB_LOG		*lg_info;	/* Return from log_open(). */
@@ -255,7 +261,7 @@ struct __db_env {
 
 	/* Transactions. */
 	DB_TXNMGR	*tx_info;	/* Return from txn_open(). */
-	unsigned int	 tx_max;	/* Maximum number of transactions. */
+	u_int32_t	 tx_max;	/* Maximum number of transactions. */
 	int (*tx_recover)		/* Dispatch function for recovery. */
 	    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
 
@@ -300,17 +306,17 @@ struct __db_info {
 	void *(*db_malloc) __P((size_t));
 
 	/* Btree access method. */
-	int		 bt_maxkey;	/* Maximum keys per page. */
-	int		 bt_minkey;	/* Minimum keys per page. */
+	u_int32_t	 bt_maxkey;	/* Maximum keys per page. */
+	u_int32_t	 bt_minkey;	/* Minimum keys per page. */
 	int (*bt_compare)		/* Comparison function. */
 	    __P((const DBT *, const DBT *));
 	size_t (*bt_prefix)		/* Prefix function. */
 	    __P((const DBT *, const DBT *));
 
 	/* Hash access method. */
-	unsigned int	 h_ffactor;	/* Fill factor. */
-	unsigned int	 h_nelem;	/* Number of elements. */
-	u_int32_t	(*h_hash)	/* Hash function. */
+	u_int32_t 	 h_ffactor;	/* Fill factor. */
+	u_int32_t	 h_nelem;	/* Number of elements. */
+	u_int32_t      (*h_hash)	/* Hash function. */
 	    __P((const void *, u_int32_t));
 
 	/* Recno access method. */
@@ -353,6 +359,7 @@ struct __db_info {
 #define	DB_SET		0x010000	/* c_get(), log_get() */
 #define	DB_SET_RANGE	0x020000	/* c_get() */
 #define	DB_SET_RECNO	0x040000	/* c_get() */
+#define	DB_CURLSN	0x080000	/* log_put() */
 
 /*
  * DB (user visible) error return codes.
@@ -435,14 +442,14 @@ struct __db {
 	void *(*db_malloc) __P((size_t));
 
 					/* Functions. */
-	int (*close)	__P((DB *, int));
+	int (*close)	__P((DB *, u_int32_t));
 	int (*cursor)	__P((DB *, DB_TXN *, DBC **));
-	int (*del)	__P((DB *, DB_TXN *, DBT *, int));
+	int (*del)	__P((DB *, DB_TXN *, DBT *, u_int32_t));
 	int (*fd)	__P((DB *, int *));
-	int (*get)	__P((DB *, DB_TXN *, DBT *, DBT *, int));
-	int (*put)	__P((DB *, DB_TXN *, DBT *, DBT *, int));
-	int (*stat)	__P((DB *, void *, void *(*)(size_t), int));
-	int (*sync)	__P((DB *, int));
+	int (*get)	__P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
+	int (*put)	__P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
+	int (*stat)	__P((DB *, void *, void *(*)(size_t), u_int32_t));
+	int (*sync)	__P((DB *, u_int32_t));
 
 #define	DB_AM_DUP	0x000001	/* DB_DUP (internal). */
 #define	DB_AM_INMEM	0x000002	/* In-memory; no sync on close. */
@@ -483,9 +490,9 @@ struct __dbc {
 	void	 *internal;		/* Access method private. */
 
 	int (*c_close)	__P((DBC *));
-	int (*c_del)	__P((DBC *, int));
-	int (*c_get)	__P((DBC *, DBT *, DBT *, int));
-	int (*c_put)	__P((DBC *, DBT *, DBT *, int));
+	int (*c_del)	__P((DBC *, u_int32_t));
+	int (*c_get)	__P((DBC *, DBT *, DBT *, u_int32_t));
+	int (*c_put)	__P((DBC *, DBT *, DBT *, u_int32_t));
 };
 
 /* Btree/recno statistics structure. */
@@ -524,10 +531,11 @@ struct __db_bt_stat {
 #if defined(__cplusplus)
 extern "C" {
 #endif
-int   db_appinit __P((const char *, char * const *, DB_ENV *, int));
+int   db_appinit __P((const char *, char * const *, DB_ENV *, u_int32_t));
 int   db_appexit __P((DB_ENV *));
 int   db_jump_set __P((void *, int));
-int   db_open __P((const char *, DBTYPE, int, int, DB_ENV *, DB_INFO *, DB **));
+int   db_open __P((const char *,
+	  DBTYPE, u_int32_t, int, DB_ENV *, DB_INFO *, DB **));
 int   db_value_set __P((int, int));
 char *db_version __P((int *, int *, int *));
 #if defined(__cplusplus)
@@ -575,6 +583,21 @@ typedef enum {
 	DB_LOCK_IWR			/* Intent to read and write. */
 } db_lockmode_t;
 
+/*
+ * Status of a lock.
+ */
+typedef enum {
+	DB_LSTAT_ABORTED,		/* Lock belongs to an aborted txn. */
+	DB_LSTAT_ERR,			/* Lock is bad. */
+	DB_LSTAT_FREE,			/* Lock is unallocated. */
+	DB_LSTAT_HELD,			/* Lock is currently held. */
+	DB_LSTAT_NOGRANT,		/* Lock was not granted. */
+	DB_LSTAT_PENDING,		/* Lock was waiting and has been
+					 * promoted; waiting for the owner
+					 * to run and upgrade it to held. */
+	DB_LSTAT_WAITING		/* Lock is on the wait queue. */
+} db_status_t;
+
 /* Lock request structure. */
 struct __db_lockreq {
 	db_lockop_t	 op;		/* Operation. */
@@ -596,19 +619,38 @@ extern const u_int8_t db_rw_conflicts[];
 #define	DB_LOCK_RIW_N	6
 extern const u_int8_t db_riw_conflicts[];
 
+struct __db_lock_stat {
+	u_int32_t st_magic;		/* Lock file magic number. */
+	u_int32_t st_version;		/* Lock file version number. */
+	u_int32_t st_maxlocks;		/* Maximum number of locks in table. */
+	u_int32_t st_nmodes;		/* Number of lock modes. */
+	u_int32_t st_numobjs;		/* Number of objects. */
+	u_int32_t st_nlockers;		/* Number of lockers. */
+	u_int32_t st_nconflicts;	/* Number of lock conflicts. */
+	u_int32_t st_nrequests;		/* Number of lock gets. */
+	u_int32_t st_nreleases;		/* Number of lock puts. */
+	u_int32_t st_ndeadlocks;	/* Number of lock deadlocks. */
+	u_int32_t st_region_wait;	/* Region lock granted after wait. */
+	u_int32_t st_region_nowait;	/* Region lock granted without wait. */
+	u_int32_t st_refcnt;		/* Region reference count. */
+	u_int32_t st_regsize;		/* Region size. */
+};
+
 #if defined(__cplusplus)
 extern "C" {
 #endif
 int	  lock_close __P((DB_LOCKTAB *));
-int	  lock_detect __P((DB_LOCKTAB *, int, int));
+int	  lock_detect __P((DB_LOCKTAB *, u_int32_t, u_int32_t));
 int	  lock_get __P((DB_LOCKTAB *,
-	    u_int32_t, int, const DBT *, db_lockmode_t, DB_LOCK *));
+	    u_int32_t, u_int32_t, const DBT *, db_lockmode_t, DB_LOCK *));
 int	  lock_id __P((DB_LOCKTAB *, u_int32_t *));
-int	  lock_open __P((const char *, int, int, DB_ENV *, DB_LOCKTAB **));
+int	  lock_open __P((const char *,
+	    u_int32_t, int, DB_ENV *, DB_LOCKTAB **));
 int	  lock_put __P((DB_LOCKTAB *, DB_LOCK));
+int	  lock_stat __P((DB_LOCKTAB *, DB_LOCK_STAT **, void *(*)(size_t)));
 int	  lock_unlink __P((const char *, int, DB_ENV *));
 int	  lock_vec __P((DB_LOCKTAB *,
-	    u_int32_t, int, DB_LOCKREQ *, int, DB_LOCKREQ **));
+	    u_int32_t, u_int32_t, DB_LOCKREQ *, int, DB_LOCKREQ **));
 #if defined(__cplusplus)
 }
 #endif
@@ -651,19 +693,21 @@ struct __db_log_stat {
 	u_int32_t st_region_nowait;	/* Region lock granted without wait. */
 	u_int32_t st_cur_file;		/* Current log file number. */
 	u_int32_t st_cur_offset;	/* Current log file offset. */
+	u_int32_t st_refcnt;		/* Region reference count. */
+	u_int32_t st_regsize;		/* Region size. */
 };
 
 #if defined(__cplusplus)
 extern "C" {
 #endif
-int	 log_archive __P((DB_LOG *, char **[], int, void *(*)(size_t)));
+int	 log_archive __P((DB_LOG *, char **[], u_int32_t, void *(*)(size_t)));
 int	 log_close __P((DB_LOG *));
 int	 log_compare __P((const DB_LSN *, const DB_LSN *));
 int	 log_file __P((DB_LOG *, const DB_LSN *, char *, size_t));
 int	 log_flush __P((DB_LOG *, const DB_LSN *));
-int	 log_get __P((DB_LOG *, DB_LSN *, DBT *, int));
-int	 log_open __P((const char *, int, int, DB_ENV *, DB_LOG **));
-int	 log_put __P((DB_LOG *, DB_LSN *, const DBT *, int));
+int	 log_get __P((DB_LOG *, DB_LSN *, DBT *, u_int32_t));
+int	 log_open __P((const char *, u_int32_t, int, DB_ENV *, DB_LOG **));
+int	 log_put __P((DB_LOG *, DB_LSN *, const DBT *, u_int32_t));
 int	 log_register __P((DB_LOG *, DB *, const char *, DBTYPE, u_int32_t *));
 int	 log_stat __P((DB_LOG *, DB_LOG_STAT **, void *(*)(size_t)));
 int	 log_unlink __P((const char *, int, DB_ENV *));
@@ -705,6 +749,17 @@ struct __db_mpool_stat {
 	u_int32_t st_page_trickle;	/* Pages written by memp_trickle. */
 	u_int32_t st_region_wait;	/* Region lock granted after wait. */
 	u_int32_t st_region_nowait;	/* Region lock granted without wait. */
+	u_int32_t st_refcnt;		/* Region reference count. */
+	u_int32_t st_regsize;		/* Region size. */
+};
+
+/* Mpool file open information structure. */
+struct __db_mpool_finfo {
+	int	   ftype;		/* File type. */
+	DBT	  *pgcookie;		/* Byte-string passed to pgin/pgout. */
+	u_int8_t  *fileid;		/* Unique file ID. */
+	int32_t	   lsn_offset;		/* LSN offset in page. */
+	u_int32_t  clear_len;		/* Cleared length on created pages. */
 };
 
 /* Mpool file statistics structure. */
@@ -724,13 +779,13 @@ extern "C" {
 #endif
 int	memp_close __P((DB_MPOOL *));
 int	memp_fclose __P((DB_MPOOLFILE *));
-int	memp_fget __P((DB_MPOOLFILE *, db_pgno_t *, int, void *));
+int	memp_fget __P((DB_MPOOLFILE *, db_pgno_t *, u_int32_t, void *));
 int	memp_fopen __P((DB_MPOOL *, const char *,
-	    int, int, int, size_t, int, DBT *, u_int8_t *, DB_MPOOLFILE **));
-int	memp_fput __P((DB_MPOOLFILE *, void *, int));
-int	memp_fset __P((DB_MPOOLFILE *, void *, int));
+	    u_int32_t, int, size_t, DB_MPOOL_FINFO *, DB_MPOOLFILE **));
+int	memp_fput __P((DB_MPOOLFILE *, void *, u_int32_t));
+int	memp_fset __P((DB_MPOOLFILE *, void *, u_int32_t));
 int	memp_fsync __P((DB_MPOOLFILE *));
-int	memp_open __P((const char *, int, int, DB_ENV *, DB_MPOOL **));
+int	memp_open __P((const char *, u_int32_t, int, DB_ENV *, DB_MPOOL **));
 int	memp_register __P((DB_MPOOL *, int,
 	    int (*)(db_pgno_t, void *, DBT *),
 	    int (*)(db_pgno_t, void *, DBT *)));
@@ -765,16 +820,21 @@ struct __db_txn_active {
 };
 
 struct __db_txn_stat {
-	DB_LSN		st_last_ckp;	/* lsn of the last checkpoint */
-	DB_LSN		st_pending_ckp;	/* last checkpoint did not finish */
-	time_t		st_time_ckp;	/* time of last checkpoint */
-	u_int32_t	st_last_txnid;	/* last transaction id given out */
-	u_int32_t	st_maxtxns;	/* maximum number of active txns */
-	u_int32_t	st_naborts;	/* number of aborted transactions */
-	u_int32_t	st_nbegins;	/* number of begun transactions */
-	u_int32_t	st_ncommits;	/* number of committed transactions */
-	u_int32_t	st_nactive;	/* number of active transactions */
-	DB_TXN_ACTIVE	*st_txnarray;	/* array of active transactions */
+	DB_LSN	  st_last_ckp;		/* lsn of the last checkpoint */
+	DB_LSN	  st_pending_ckp;	/* last checkpoint did not finish */
+	time_t	  st_time_ckp;		/* time of last checkpoint */
+	u_int32_t st_last_txnid;	/* last transaction id given out */
+	u_int32_t st_maxtxns;	/* maximum number of active txns */
+	u_int32_t st_naborts;	/* number of aborted transactions */
+	u_int32_t st_nbegins;	/* number of begun transactions */
+	u_int32_t st_ncommits;	/* number of committed transactions */
+	u_int32_t st_nactive;	/* number of active transactions */
+	DB_TXN_ACTIVE
+		 *st_txnarray;	/* array of active transactions */
+	u_int32_t st_region_wait;	/* Region lock granted after wait. */
+	u_int32_t st_region_nowait;	/* Region lock granted without wait. */
+	u_int32_t st_refcnt;		/* Region reference count. */
+	u_int32_t st_regsize;		/* Region size. */
 };
 
 #if defined(__cplusplus)
@@ -782,11 +842,11 @@ extern "C" {
 #endif
 int	  txn_abort __P((DB_TXN *));
 int	  txn_begin __P((DB_TXNMGR *, DB_TXN *, DB_TXN **));
-int	  txn_checkpoint __P((const DB_TXNMGR *, int, int));
+int	  txn_checkpoint __P((const DB_TXNMGR *, u_int32_t, u_int32_t));
 int	  txn_commit __P((DB_TXN *));
 int	  txn_close __P((DB_TXNMGR *));
 u_int32_t txn_id __P((DB_TXN *));
-int	  txn_open __P((const char *, int, int, DB_ENV *, DB_TXNMGR **));
+int	  txn_open __P((const char *, u_int32_t, int, DB_ENV *, DB_TXNMGR **));
 int	  txn_prepare __P((DB_TXN *));
 int	  txn_stat __P((DB_TXNMGR *, DB_TXN_STAT **, void *(*)(size_t)));
 int	  txn_unlink __P((const char *, int, DB_ENV *));
@@ -810,10 +870,17 @@ int	  txn_unlink __P((const char *, int, DB_ENV *));
  */
 #define	DBM_SUFFIX	".db"
 
+#if defined(_XPG4_2)
+typedef struct {
+	char *dptr;
+	size_t dsize;
+} datum;
+#else
 typedef struct {
 	char *dptr;
 	int dsize;
 } datum;
+#endif
 
 /*
  * Translate DBM calls into DB calls so that DB doesn't step on the
@@ -894,7 +961,7 @@ typedef enum {
 
 typedef struct entry {
 	char *key;
-	void *data;
+	char *data;
 } ENTRY;
 
 /*
@@ -909,7 +976,7 @@ typedef struct entry {
 #if defined(__cplusplus)
 extern "C" {
 #endif
-int	 __db_hcreate __P((unsigned int));
+int	 __db_hcreate __P((size_t));
 void	 __db_hdestroy __P((void));
 ENTRY	*__db_hsearch __P((ENTRY, ACTION));
 #if defined(__cplusplus)
diff --git a/db2/include/db_185.h.src b/db2/include/db_185.h.src
index a88eb4e525..a928ca8fd5 100644
--- a/db2/include/db_185.h.src
+++ b/db2/include/db_185.h.src
@@ -1,7 +1,7 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 /*
@@ -36,7 +36,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)db_185.h.src	8.5 (Sleepycat) 1/15/98
+ *	@(#)db_185.h.src	8.7 (Sleepycat) 4/10/98
  */
 
 #ifndef _DB_185_H_
@@ -127,11 +127,11 @@ typedef struct __db {
 /* Structure used to pass parameters to the btree routines. */
 typedef struct {
 #define	R_DUP		0x01	/* duplicate keys */
-	u_long	flags;
-	u_int	cachesize;	/* bytes to cache */
-	int	maxkeypage;	/* maximum keys per page */
-	int	minkeypage;	/* minimum keys per page */
-	u_int	psize;		/* page size */
+	u_int32_t flags;
+	u_int32_t cachesize;	/* bytes to cache */
+	u_int32_t maxkeypage;	/* maximum keys per page */
+	u_int32_t minkeypage;	/* minimum keys per page */
+	u_int32_t psize;	/* page size */
 	int	(*compare)	/* comparison function */
 	    __P((const DBT *, const DBT *));
 	size_t	(*prefix)	/* prefix function */
@@ -144,10 +144,10 @@ typedef struct {
 
 /* Structure used to pass parameters to the hashing routines. */
 typedef struct {
-	u_int	bsize;		/* bucket size */
-	u_int	ffactor;	/* fill factor */
-	u_int	nelem;		/* number of elements */
-	u_int	cachesize;	/* bytes to cache */
+	u_int32_t bsize;	/* bucket size */
+	u_int32_t ffactor;	/* fill factor */
+	u_int32_t nelem;	/* number of elements */
+	u_int32_t cachesize;	/* bytes to cache */
 	u_int32_t		/* hash function */
 		(*hash) __P((const void *, size_t));
 	int	lorder;		/* byte order */
@@ -158,9 +158,9 @@ typedef struct {
 #define	R_FIXEDLEN	0x01	/* fixed-length records */
 #define	R_NOKEY		0x02	/* key not required */
 #define	R_SNAPSHOT	0x04	/* snapshot the input */
-	u_long	flags;
-	u_int	cachesize;	/* bytes to cache */
-	u_int	psize;		/* page size */
+	u_int32_t flags;
+	u_int32_t cachesize;	/* bytes to cache */
+	u_int32_t psize;	/* page size */
 	int	lorder;		/* byte order */
 	size_t	reclen;		/* record length (fixed-length records) */
 	u_char	bval;		/* delimiting byte (variable-length records */
diff --git a/db2/include/db_am.h b/db2/include/db_am.h
index 304e3fd959..0c189244a2 100644
--- a/db2/include/db_am.h
+++ b/db2/include/db_am.h
@@ -1,10 +1,10 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  *
- *	@(#)db_am.h	10.8 (Sleepycat) 1/8/98
+ *	@(#)db_am.h	10.9 (Sleepycat) 4/10/98
  */
 #ifndef _DB_AM_H
 #define _DB_AM_H
diff --git a/db2/include/db_auto.h b/db2/include/db_auto.h
index 4c7b4da970..1b07c748e8 100644
--- a/db2/include/db_auto.h
+++ b/db2/include/db_auto.h
@@ -114,6 +114,9 @@ typedef struct _db_noop_args {
 	u_int32_t type;
 	DB_TXN *txnid;
 	DB_LSN prev_lsn;
+	u_int32_t	fileid;
+	db_pgno_t	pgno;
+	DB_LSN 	prevlsn;
 } __db_noop_args;
 
 #endif
diff --git a/db2/include/db_cxx.h b/db2/include/db_cxx.h
index 83523c5559..fc04d5d66b 100644
--- a/db2/include/db_cxx.h
+++ b/db2/include/db_cxx.h
@@ -1,10 +1,10 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1997
+ * Copyright (c) 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  *
- *	@(#)db_cxx.h	10.13 (Sleepycat) 11/25/97
+ *	@(#)db_cxx.h	10.17 (Sleepycat) 5/2/98
  */
 
 #ifndef _DB_CXX_H_
@@ -178,11 +178,11 @@ class _exported DbLock
     friend DbLockTab;
 
 public:
-    DbLock(unsigned int);
+    DbLock(u_int);
     DbLock();
 
-    unsigned int get_lock_id();
-    void set_lock_id(unsigned int);
+    u_int get_lock_id();
+    void set_lock_id(u_int);
 
     int put(DbLockTab *locktab);
 
@@ -202,16 +202,16 @@ class _exported DbLockTab
 friend DbEnv;
 public:
     int close();
-    int detect(int flags, int atype);
-    int get(u_int32_t locker, int flags, const Dbt *obj,
+    int detect(u_int32_t flags, int atype);
+    int get(u_int32_t locker, u_int32_t flags, const Dbt *obj,
             db_lockmode_t lock_mode, DbLock *lock);
     int id(u_int32_t *idp);
-    int vec(u_int32_t locker, int flags, DB_LOCKREQ list[],
+    int vec(u_int32_t locker, u_int32_t flags, DB_LOCKREQ list[],
 	    int nlist, DB_LOCKREQ **elistp);
 
     // Create or remove new locktab files
     //
-    static int open(const char *dir, int flags, int mode,
+    static int open(const char *dir, u_int32_t flags, int mode,
                     DbEnv* dbenv, DbLockTab **regionp);
     static int unlink(const char *dir, int force, DbEnv* dbenv);
 
@@ -252,13 +252,13 @@ class _exported DbLog
 {
 friend DbEnv;
 public:
-    int archive(char **list[], int flags, void *(*db_malloc)(size_t));
+    int archive(char **list[], u_int32_t flags, void *(*db_malloc)(size_t));
     int close();
     static int compare(const DbLsn *lsn0, const DbLsn *lsn1);
     int file(DbLsn *lsn, char *namep, int len);
     int flush(const DbLsn *lsn);
-    int get(DbLsn *lsn, Dbt *data, int flags);
-    int put(DbLsn *lsn, const Dbt *data, int flags);
+    int get(DbLsn *lsn, Dbt *data, u_int32_t flags);
+    int put(DbLsn *lsn, const Dbt *data, u_int32_t flags);
 
     // Normally these would be called register and unregister to
     // parallel the C interface, but "register" is a reserved word.
@@ -268,7 +268,7 @@ public:
 
     // Create or remove new log files
     //
-    static int open(const char *dir, int flags, int mode,
+    static int open(const char *dir, u_int32_t flags, int mode,
                     DbEnv* dbenv, DbLog **regionp);
     static int unlink(const char *dir, int force, DbEnv* dbenv);
 
@@ -300,17 +300,17 @@ private:
 
 class _exported DbMpoolFile
 {
+friend DbEnv;
 public:
     int close();
-    int get(db_pgno_t *pgnoaddr, int flags, void *pagep);
-    int put(void *pgaddr, int flags);
-    int set(void *pgaddr, int flags);
+    int get(db_pgno_t *pgnoaddr, u_int32_t flags, void *pagep);
+    int put(void *pgaddr, u_int32_t flags);
+    int set(void *pgaddr, u_int32_t flags);
     int sync();
 
     static int open(DbMpool *mp, const char *file,
-                    int ftype, int flags, int mode,
-                    size_t pagesize, int lsn_offset,
-                    Dbt *pgcookie, u_int8_t *uid, DbMpoolFile **mpf);
+                    u_int32_t flags, int mode, size_t pagesize,
+                    DB_MPOOL_FINFO *finfop, DbMpoolFile **mpf);
 
 private:
     // We can add data to this class if needed
@@ -356,7 +356,7 @@ public:
 
     // Create or remove new mpool files
     //
-    static int open(const char *dir, int flags, int mode,
+    static int open(const char *dir, u_int32_t flags, int mode,
                     DbEnv* dbenv, DbMpool **regionp);
     static int unlink(const char *dir, int force, DbEnv* dbenv);
 
@@ -391,13 +391,13 @@ class _exported DbTxnMgr
 friend DbEnv;
 public:
     int begin(DbTxn *pid, DbTxn **tid);
-    int checkpoint(int kbyte, int min) const;
+    int checkpoint(u_int32_t kbyte, u_int32_t min) const;
     int close();
     int stat(DB_TXN_STAT **statp, void *(*db_malloc)(size_t));
 
     // Create or remove new txnmgr files
     //
-    static int open(const char *dir, int flags, int mode,
+    static int open(const char *dir, u_int32_t flags, int mode,
                     DbEnv* dbenv, DbTxnMgr **regionp);
     static int unlink(const char *dir, int force, DbEnv* dbenv);
 
@@ -510,12 +510,12 @@ public:
     // Hash access method.
 
     // Fill factor.
-    unsigned int get_h_ffactor() const;
-    void set_h_ffactor(unsigned int);
+    u_int32_t get_h_ffactor() const;
+    void set_h_ffactor(u_int32_t);
 
     // Number of elements.
-    unsigned int get_h_nelem() const;
-    void set_h_nelem(unsigned int);
+    u_int32_t get_h_nelem() const;
+    void set_h_nelem(u_int32_t);
 
     // Hash function.
     typedef u_int32_t (*h_hash_fcn)(const void *, u_int32_t);
@@ -584,7 +584,7 @@ public:
     // application with these arguments.  Do not use it if you
     // need to set other parameters via the access methods.
     //
-    DbEnv(const char *homeDir, char *const *db_config, int flags);
+    DbEnv(const char *homeDir, char *const *db_config, u_int32_t flags);
 
     // Use this constructor if you wish to *delay* the initialization
     // of the db library.  This is useful if you need to set
@@ -596,7 +596,7 @@ public:
     // Used in conjunction with the default constructor to
     // complete the initialization of the db library.
     //
-    int appinit(const char *homeDir, char *const *db_config, int flags);
+    int appinit(const char *homeDir, char *const *db_config, u_int32_t flags);
 
     // Called automatically when DbEnv is destroyed, or can be
     // called at any time to shut down Db.
@@ -673,8 +673,8 @@ public:
     void set_lk_modes(int);
 
     // Maximum number of locks.
-    unsigned int get_lk_max() const;
-    void set_lk_max(unsigned int);
+    u_int32_t get_lk_max() const;
+    void set_lk_max(u_int32_t);
 
     // Deadlock detect on every conflict.
     u_int32_t get_lk_detect() const;
@@ -714,8 +714,8 @@ public:
     DbTxnMgr *get_tx_info() const;
 
     // Maximum number of transactions.
-    unsigned int get_tx_max() const;
-    void set_tx_max(unsigned int);
+    u_int32_t get_tx_max() const;
+    void set_tx_max(u_int32_t);
 
     // Dispatch function for recovery.
     typedef int (*tx_recover_fcn)(DB_LOG *, DBT *, DB_LSN *, int, void *);
@@ -781,18 +781,18 @@ class _exported Db
     friend DbEnv;
 
 public:
-    int close(int flags);
+    int close(u_int32_t flags);
     int cursor(DbTxn *txnid, Dbc **cursorp);
-    int del(DbTxn *txnid, Dbt *key, int flags);
+    int del(DbTxn *txnid, Dbt *key, u_int32_t flags);
     int fd(int *fdp);
-    int get(DbTxn *txnid, Dbt *key, Dbt *data, int flags);
-    int put(DbTxn *txnid, Dbt *key, Dbt *data, int flags);
-    int stat(void *sp, void *(*db_malloc)(size_t), int flags);
-    int sync(int flags);
+    int get(DbTxn *txnid, Dbt *key, Dbt *data, u_int32_t flags);
+    int put(DbTxn *txnid, Dbt *key, Dbt *data, u_int32_t flags);
+    int stat(void *sp, void *(*db_malloc)(size_t), u_int32_t flags);
+    int sync(u_int32_t flags);
 
     DBTYPE get_type() const;
 
-    static int open(const char *fname, DBTYPE type, int flags,
+    static int open(const char *fname, DBTYPE type, u_int32_t flags,
                     int mode, DbEnv *dbenv, DbInfo *info, Db **dbpp);
 
 private:
@@ -867,9 +867,9 @@ class _exported Dbc : protected DBC
 
 public:
     int close();
-    int del(int flags);
-    int get(Dbt* key, Dbt *data, int flags);
-    int put(Dbt* key, Dbt *data, int flags);
+    int del(u_int32_t flags);
+    int get(Dbt* key, Dbt *data, u_int32_t flags);
+    int put(Dbt* key, Dbt *data, u_int32_t flags);
 
 private:
     // No data is permitted in this class (see comment at top)
diff --git a/db2/include/db_dispatch.h b/db2/include/db_dispatch.h
index b93ec39b54..8f5e217402 100644
--- a/db2/include/db_dispatch.h
+++ b/db2/include/db_dispatch.h
@@ -1,7 +1,7 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 /*
@@ -36,26 +36,30 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)db_dispatch.h	10.1 (Sleepycat) 4/12/97
+ *	@(#)db_dispatch.h	10.4 (Sleepycat) 5/3/98
  */
 
 #ifndef _DB_DISPATCH_H
 #define _DB_DISPATCH_H
 
+struct __db_txnhead;	typedef struct __db_txnhead DB_TXNHEAD;
+struct __db_txnlist;	typedef struct __db_txnlist DB_TXNLIST;
+
 /*
  * Declarations and typedefs for the list of transaction IDs used during
  * recovery.
  */
-
-typedef struct __db_txnhead {
-	LIST_HEAD(__db_headlink, _db_txnlist) head;
+struct __db_txnhead {
+	LIST_HEAD(__db_headlink, __db_txnlist) head;
 	u_int32_t maxid;
-} __db_txnhead;
+	int32_t generation;
+};
 
-typedef struct _db_txnlist {
-	LIST_ENTRY(_db_txnlist) links;
-	u_int32_t	txnid;
-} __db_txnlist;
+struct __db_txnlist {
+	LIST_ENTRY(__db_txnlist) links;
+	u_int32_t txnid;
+	int32_t	generation;
+};
 
 #define	DB_log_BEGIN		  0
 #define	DB_txn_BEGIN		  5
diff --git a/db2/include/db_ext.h b/db2/include/db_ext.h
index 122d8f13c1..8a03db9f64 100644
--- a/db2/include/db_ext.h
+++ b/db2/include/db_ext.h
@@ -53,7 +53,8 @@ int __db_debug_print
    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
 int __db_debug_read __P((void *, __db_debug_args **));
 int __db_noop_log
-    __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t));
+    __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
+    u_int32_t, db_pgno_t, DB_LSN *));
 int __db_noop_print
    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
 int __db_noop_read __P((void *, __db_noop_args **));
@@ -67,8 +68,9 @@ int __db_add_recovery __P((DB_ENV *,
 int __db_txnlist_init __P((void *));
 int __db_txnlist_add __P((void *, u_int32_t));
 int __db_txnlist_find __P((void *, u_int32_t));
-void __db_txnlist_print __P((void *));
 void __db_txnlist_end __P((void *));
+void __db_txnlist_gen __P((void *, int));
+void __db_txnlist_print __P((void *));
 int __db_dput __P((DB *,
    DBT *, PAGE **, db_indx_t *, int (*)(DB *, u_int32_t, PAGE **)));
 int __db_drem __P((DB *,
@@ -83,7 +85,7 @@ int __db_goff __P((DB *, DBT *,
     u_int32_t, db_pgno_t, void **, u_int32_t *));
 int __db_poff __P((DB *, const DBT *, db_pgno_t *,
     int (*)(DB *, u_int32_t, PAGE **)));
-int __db_ovref __P((DB *, db_pgno_t, int));
+int __db_ovref __P((DB *, db_pgno_t, int32_t));
 int __db_doff __P((DB *, db_pgno_t, int (*)(DB *, PAGE *)));
 int __db_moff __P((DB *, const DBT *, db_pgno_t));
 void __db_loadme __P((void));
@@ -97,7 +99,8 @@ int __db_prnpage __P((DB_MPOOLFILE *, db_pgno_t));
 int __db_prpage __P((PAGE *, int));
 int __db_isbad __P((PAGE *, int));
 void __db_pr __P((u_int8_t *, u_int32_t));
-void __db_prflags __P((u_int32_t, const FN *));
+int __db_prdbt __P((DBT *, int, FILE *));
+void __db_prflags __P((u_int32_t, const FN *, FILE *));
 int __db_addrem_recover
    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
 int __db_split_recover __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
@@ -108,8 +111,7 @@ int __db_relink_recover
 int __db_addpage_recover
    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
 int __db_debug_recover __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
-int __db_noop_recover
-  __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
+int __db_noop_recover __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
 int __db_ret __P((DB *,
    PAGE *, u_int32_t, DBT *, void **, u_int32_t *));
 int __db_retcopy __P((DBT *,
diff --git a/db2/include/db_int.h.src b/db2/include/db_int.h.src
index 48790d6c9a..d67e2c428c 100644
--- a/db2/include/db_int.h.src
+++ b/db2/include/db_int.h.src
@@ -1,10 +1,10 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  *
- *	@(#)db_int.h.src	10.41 (Sleepycat) 1/8/98
+ *	@(#)db_int.h.src	10.62 (Sleepycat) 5/23/98
  */
 
 #ifndef _DB_INTERNAL_H_
@@ -12,8 +12,6 @@
 
 #include "db.h"				/* Standard DB include file. */
 #include "queue.h"
-#include "os_func.h"
-#include "os_ext.h"
 
 /*******************************************************
  * General purpose constants and macros.
@@ -77,8 +75,8 @@
 #define	R_ADDR(base, offset)	((void *)((u_int8_t *)((base)->addr) + offset))
 #define	R_OFFSET(base, p)	((u_int8_t *)(p) - (u_int8_t *)(base)->addr)
 
-/* Free and free-string macros that overwrite memory during debugging. */
-#ifdef DEBUG
+/* Free and free-string macros that overwrite memory. */
+#ifdef DIAGNOSTIC
 #undef	FREE
 #define	FREE(p, len) {							\
 	memset(p, 0xff, len);						\
@@ -117,36 +115,41 @@ typedef struct __fn {
 #undef	DB_LINE
 #define	DB_LINE "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
 
+/* Global variables. */
+typedef struct __db_globals {
+	int db_mutexlocks;		/* DB_MUTEXLOCKS */
+	int db_region_anon;		/* DB_REGION_ANON, DB_REGION_NAME */
+	int db_region_init;		/* DB_REGION_INIT */
+	int db_tsl_spins;		/* DB_TSL_SPINS */
+	int db_pageyield;		/* DB_PAGEYIELD */
+} DB_GLOBALS;
+extern	DB_GLOBALS	__db_global_values;
+#define	DB_GLOBAL(v)	__db_global_values.v
+
 /* Unused, or not-used-yet variable.  "Shut that bloody compiler up!" */
 #define	COMPQUIET(n, v)	(n) = (v)
 
+/*
+ * Win16 needs specific syntax on callback functions.  Nobody else cares.
+ */
+#ifndef	DB_CALLBACK
+#define	DB_CALLBACK	/* Nothing. */
+#endif
+
 /*******************************************************
  * Files.
  *******************************************************/
-#ifndef MAXPATHLEN		/* Maximum path length. */
-#ifdef PATH_MAX
-#define	MAXPATHLEN	PATH_MAX
-#else
+ /*
+  * We use 1024 as the maximum path length.  It's too hard to figure out what
+  * the real path length is, as it was traditionally stored in <sys/param.h>,
+  * and that file isn't always available.
+  */
+#undef	MAXPATHLEN
 #define	MAXPATHLEN	1024
-#endif
-#endif
 
 #define	PATH_DOT	"."	/* Current working directory. */
 #define	PATH_SEPARATOR	"/"	/* Path separator character. */
 
-#ifndef S_IRUSR			/* UNIX specific file permissions. */
-#define	S_IRUSR	0000400		/* R for owner */
-#define	S_IWUSR	0000200		/* W for owner */
-#define	S_IRGRP	0000040		/* R for group */
-#define	S_IWGRP	0000020		/* W for group */
-#define	S_IROTH	0000004		/* R for other */
-#define	S_IWOTH	0000002		/* W for other */
-#endif
-
-#ifndef S_ISDIR			/* UNIX specific: directory test. */
-#define	S_ISDIR(m)	((m & 0170000) == 0040000)
-#endif
-
 /*******************************************************
  * Mutex support.
  *******************************************************/
@@ -176,12 +179,12 @@ typedef struct __fn {
 typedef struct _db_mutex_t {
 #ifdef HAVE_SPINLOCKS
 	tsl_t	  tsl_resource;		/* Resource test and set. */
-#ifdef DEBUG
-	u_long	  pid;			/* Lock holder: 0 or process pid. */
+#ifdef DIAGNOSTIC
+	u_int32_t pid;			/* Lock holder: 0 or process pid. */
 #endif
 #else
 	u_int32_t off;			/* Backing file offset. */
-	u_long	  pid;			/* Lock holder: 0 or process pid. */
+	u_int32_t pid;			/* Lock holder: 0 or process pid. */
 #endif
 	u_int32_t spins;		/* Spins before block. */
 	u_int32_t mutex_set_wait;	/* Granted after wait. */
@@ -195,11 +198,11 @@ typedef struct _db_mutex_t {
  *******************************************************/
 /* Lock/unlock a DB thread. */
 #define	DB_THREAD_LOCK(dbp)						\
-	(F_ISSET(dbp, DB_AM_THREAD) ?					\
-	    __db_mutex_lock((db_mutex_t *)(dbp)->mutexp, -1) : 0)
+	if (F_ISSET(dbp, DB_AM_THREAD))					\
+	    (void)__db_mutex_lock((db_mutex_t *)(dbp)->mutexp, -1);
 #define	DB_THREAD_UNLOCK(dbp)						\
-	(F_ISSET(dbp, DB_AM_THREAD) ?					\
-	    __db_mutex_unlock((db_mutex_t *)(dbp)->mutexp, -1) : 0)
+	if (F_ISSET(dbp, DB_AM_THREAD))					\
+	    (void)__db_mutex_unlock((db_mutex_t *)(dbp)->mutexp, -1);
 
 /* Btree/recno local statistics structure. */
 struct __db_bt_lstat;	typedef struct __db_bt_lstat DB_BTREE_LSTAT;
@@ -228,7 +231,7 @@ typedef enum {
 } APPNAME;
 
 /*******************************************************
- * Regions.
+ * Shared memory regions.
  *******************************************************/
 /*
  * The shared memory regions share an initial structure so that the general
@@ -240,16 +243,69 @@ typedef enum {
  */
 typedef struct _rlayout {
 	db_mutex_t lock;		/* Region mutex. */
+#define	DB_REGIONMAGIC	0x120897
+	u_int32_t  valid;		/* Valid magic number. */
 	u_int32_t  refcnt;		/* Region reference count. */
 	size_t	   size;		/* Region length. */
 	int	   majver;		/* Major version number. */
 	int	   minver;		/* Minor version number. */
 	int	   patch;		/* Patch version number. */
+#define	INVALID_SEGID	-1
+	int	   segid;		/* shmget(2) ID, or Win16 segment ID. */
 
-#define	DB_R_DELETED	0x01		/* Region was deleted. */
+#define	REGION_ANONYMOUS	0x01	/* Region is/should be in anon mem. */
 	u_int32_t  flags;
 } RLAYOUT;
 
+/*
+ * DB creates all regions on 4K boundaries out of sheer paranoia, so that
+ * we don't make the underlying VM unhappy.
+ */
+#define	DB_VMPAGESIZE	(4 * 1024)
+#define	DB_ROUNDOFF(i) {						\
+	(i) += DB_VMPAGESIZE - 1;					\
+	(i) -= (i) % DB_VMPAGESIZE;					\
+}
+
+/*
+ * The interface to region attach is nasty, there is a lot of complex stuff
+ * going on, which has to be retained between create/attach and detach.  The
+ * REGINFO structure keeps track of it.
+ */
+struct __db_reginfo;	typedef struct __db_reginfo REGINFO;
+struct __db_reginfo {
+					/* Arguments. */
+	DB_ENV	   *dbenv;		/* Region naming info. */
+	APPNAME	    appname;		/* Region naming info. */
+	char	   *path;		/* Region naming info. */
+	const char *file;		/* Region naming info. */
+	int	    mode;		/* Region mode, if a file. */
+	size_t	    size;		/* Region size. */
+	u_int32_t   dbflags;		/* Region file open flags, if a file. */
+
+					/* Results. */
+	char	   *name;		/* Region name. */
+	void	   *addr;		/* Region address. */
+	int	    fd;			/* Fcntl(2) locking file descriptor.
+					   NB: this is only valid if a regular
+					   file is backing the shared region,
+					   and mmap(2) is being used to map it
+					   into our address space. */
+	int	    segid;		/* shmget(2) ID, or Win16 segment ID. */
+
+					/* Shared flags. */
+/*				0x0001	COMMON MASK with RLAYOUT structure. */
+#define	REGION_CANGROW		0x0002	/* Can grow. */
+#define	REGION_CREATED		0x0004	/* Created. */
+#define	REGION_HOLDINGSYS	0x0008	/* Holding system resources. */
+#define	REGION_LASTDETACH	0x0010	/* Delete on last detach. */
+#define	REGION_MALLOC		0x0020	/* Created in malloc'd memory. */
+#define	REGION_PRIVATE		0x0040	/* Private to thread/process. */
+#define	REGION_REMOVED		0x0080	/* Already deleted. */
+#define	REGION_SIZEDEF		0x0100	/* Use default region size if exists. */
+	u_int32_t   flags;
+};
+
 /*******************************************************
  * Mpool.
  *******************************************************/
@@ -281,7 +337,7 @@ typedef struct __dbpginfo {
 #define	DB_LOGGING(dbp)							\
 	(F_ISSET(dbp, DB_AM_LOGGING) && !F_ISSET(dbp, DB_AM_RECOVER))
 
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 /*
  * Debugging macro to log operations.
  *	If DEBUG_WOP is defined, log operations that modify the database.
@@ -318,7 +374,7 @@ typedef struct __dbpginfo {
 #else
 #define	DEBUG_LREAD(D, T, O, K, A, F)
 #define	DEBUG_LWRITE(D, T, O, K, A, F)
-#endif /* DEBUG */
+#endif /* DIAGNOSTIC */
 
 /*******************************************************
  * Transactions and recovery.
@@ -339,4 +395,8 @@ struct __db_txn {
 	size_t		off;		/* Detail structure within region. */
 	TAILQ_ENTRY(__db_txn) links;
 };
+
+#include "os_func.h"
+#include "os_ext.h"
+
 #endif /* !_DB_INTERNAL_H_ */
diff --git a/db2/include/db_page.h b/db2/include/db_page.h
index 30f6072fc3..e1846cbbbd 100644
--- a/db2/include/db_page.h
+++ b/db2/include/db_page.h
@@ -1,10 +1,10 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  *
- *	@(#)db_page.h	10.13 (Sleepycat) 9/24/97
+ *	@(#)db_page.h	10.15 (Sleepycat) 5/1/98
  */
 
 #ifndef _DB_PAGE_H_
@@ -29,6 +29,14 @@
 #define	PGNO_INVALID	0	/* Metadata page number, therefore illegal. */
 #define	PGNO_ROOT	1	/* Root is page #1. */
 
+/*
+ * When we create pages in mpool, we ask mpool to clear some number of bytes
+ * in the header.  This number must be at least as big as the regular page
+ * headers and cover enough of the btree and hash meta-data pages to obliterate
+ * the magic and version numbers.
+ */
+#define	DB_PAGE_CLEAR_LEN	32
+
 /************************************************************************
  BTREE METADATA PAGE LAYOUT
  ************************************************************************/
diff --git a/db2/include/db_shash.h b/db2/include/db_shash.h
index b94e0f1d41..35ade395fc 100644
--- a/db2/include/db_shash.h
+++ b/db2/include/db_shash.h
@@ -1,10 +1,10 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  *
- *	@(#)db_shash.h	10.2 (Sleepycat) 9/16/97
+ *	@(#)db_shash.h	10.3 (Sleepycat) 4/10/98
  */
 
 /* Hash Headers */
diff --git a/db2/include/db_swap.h b/db2/include/db_swap.h
index 278282f5e4..9f94ed721b 100644
--- a/db2/include/db_swap.h
+++ b/db2/include/db_swap.h
@@ -1,7 +1,7 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 /*
@@ -36,7 +36,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)db_swap.h	10.3 (Sleepycat) 6/10/97
+ *	@(#)db_swap.h	10.5 (Sleepycat) 4/10/98
  */
 
 #ifndef _DB_SWAP_H_
@@ -74,7 +74,7 @@
 /*
  * Little endian <==> big endian 16-bit swap macros.
  *	M_16_SWAP	swap a memory location
- *	P_16_COPY	copy potentially unaligned  from one location to another
+ *	P_16_COPY	copy potentially unaligned 2 byte quantities
  *	P_16_SWAP	swap a referenced memory location
  */
 #define	M_16_SWAP(a) {							\
diff --git a/db2/include/hash.h b/db2/include/hash.h
index ae6d3843c6..e55c2102cb 100644
--- a/db2/include/hash.h
+++ b/db2/include/hash.h
@@ -1,7 +1,7 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 /*
@@ -43,7 +43,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)hash.h	10.7 (Sleepycat) 11/1/97
+ *	@(#)hash.h	10.8 (Sleepycat) 4/10/98
  */
 
 /* Cursor structure definitions. */
diff --git a/db2/include/hash_ext.h b/db2/include/hash_ext.h
index 9b97d35a42..7086adcc44 100644
--- a/db2/include/hash_ext.h
+++ b/db2/include/hash_ext.h
@@ -2,7 +2,7 @@
 #ifndef _hash_ext_h_
 #define _hash_ext_h_
 int __ham_open __P((DB *, DB_INFO *));
-int  __ham_close __P((DB *));
+int __ham_close __P((DB *));
 int __ham_c_iclose __P((DB *, DBC *));
 int __ham_expand_table __P((HTAB *));
 u_int32_t __ham_call_hash __P((HTAB *, u_int8_t *, int32_t));
@@ -75,7 +75,7 @@ int __ham_mswap __P((void *));
 #ifdef DEBUG
 void __ham_dump_bucket __P((HTAB *, u_int32_t));
 #endif
-int __ham_add_dup __P((HTAB *, HASH_CURSOR *, DBT *, int));
+int __ham_add_dup __P((HTAB *, HASH_CURSOR *, DBT *, u_int32_t));
 void __ham_move_offpage __P((HTAB *, PAGE *, u_int32_t, db_pgno_t));
 u_int32_t __ham_func2 __P((const void *, u_int32_t));
 u_int32_t __ham_func3 __P((const void *, u_int32_t));
@@ -90,14 +90,16 @@ int __ham_item_first __P((HTAB *, HASH_CURSOR *, db_lockmode_t));
 int __ham_item_prev __P((HTAB *, HASH_CURSOR *, db_lockmode_t));
 int __ham_item_next __P((HTAB *, HASH_CURSOR *, db_lockmode_t));
 void __ham_putitem __P((PAGE *p, const DBT *, int));
+void __ham_reputpair
+   __P((PAGE *p, u_int32_t, u_int32_t, const DBT *, const DBT *));
 int __ham_del_pair __P((HTAB *, HASH_CURSOR *, int));
 int __ham_replpair __P((HTAB *, HASH_CURSOR *, DBT *, u_int32_t));
 void __ham_onpage_replace __P((PAGE *, size_t, u_int32_t, int32_t,
     int32_t,  DBT *));
 int __ham_split_page __P((HTAB *, u_int32_t, u_int32_t));
-int __ham_add_el __P((HTAB *, HASH_CURSOR *, const DBT *, const DBT *,
-    int));
-void __ham_copy_item __P((HTAB *, PAGE *, int, PAGE *));
+int __ham_add_el
+   __P((HTAB *, HASH_CURSOR *, const DBT *, const DBT *, int));
+void __ham_copy_item __P((HTAB *, PAGE *, u_int32_t, PAGE *));
 int __ham_add_ovflpage __P((HTAB *, PAGE *, int, PAGE **));
 int __ham_new_page __P((HTAB *, u_int32_t, u_int32_t, PAGE **));
 int __ham_del_page __P((DB *, PAGE *));
@@ -106,12 +108,12 @@ int __ham_dirty_page __P((HTAB *, PAGE *));
 int __ham_get_page __P((DB *, db_pgno_t, PAGE **));
 int __ham_overflow_page __P((DB *, u_int32_t, PAGE **));
 #ifdef DEBUG
-int __bucket_to_page __P((HTAB *, int));
+db_pgno_t __bucket_to_page __P((HTAB *, db_pgno_t));
 #endif
 void __ham_init_ovflpages __P((HTAB *));
 int __ham_get_cpage __P((HTAB *, HASH_CURSOR *, db_lockmode_t));
-int __ham_next_cpage __P((HTAB *, HASH_CURSOR *, db_pgno_t,
-    int, int));
+int __ham_next_cpage
+   __P((HTAB *, HASH_CURSOR *, db_pgno_t, int, u_int32_t));
 void __ham_dpair __P((DB *, PAGE *, u_int32_t));
 int __ham_insdel_recover
     __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
diff --git a/db2/include/lock.h b/db2/include/lock.h
index 5031b65d06..47a38b8783 100644
--- a/db2/include/lock.h
+++ b/db2/include/lock.h
@@ -1,16 +1,19 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  *
- *	@(#)lock.h	10.10 (Sleepycat) 11/13/97
+ *	@(#)lock.h	10.15 (Sleepycat) 5/10/98
  */
 
 typedef struct __db_lockobj	DB_LOCKOBJ;
 
 #define DB_DEFAULT_LOCK_FILE	"__db_lock.share"
-#define DB_LOCK_DEFAULT_N	5000
+
+#ifndef DB_LOCK_DEFAULT_N
+#define DB_LOCK_DEFAULT_N	5000	/* Default # of locks in region. */
+#endif
 
 /*
  * The locker id space is divided between the transaction manager and the lock
@@ -54,9 +57,9 @@ struct __db_lockregion {
 
 /* Macros to lock/unlock the region. */
 #define	LOCK_LOCKREGION(lt)						\
-	(void)__db_mutex_lock(&(lt)->region->hdr.lock, (lt)->fd)
+	(void)__db_mutex_lock(&(lt)->region->hdr.lock, (lt)->reginfo.fd)
 #define	UNLOCK_LOCKREGION(lt)						\
-	(void)__db_mutex_unlock(&(lt)->region->hdr.lock, (lt)->fd)
+	(void)__db_mutex_unlock(&(lt)->region->hdr.lock, (lt)->reginfo.fd)
 
 /*
  * Since we will be keeping DBTs in shared memory, we need the equivalent
@@ -69,9 +72,6 @@ typedef struct __sh_dbt {
 
 #define SH_DBT_PTR(p)	((void *)(((u_int8_t *)(p)) + (p)->off))
 
-/*
- * The lock table is the per-process cookie returned from a lock_open call.
- */
 struct __db_lockobj {
 	SH_DBT	lockobj;		/* Identifies object locked. */
 	SH_TAILQ_ENTRY links;		/* Links for free list. */
@@ -98,12 +98,14 @@ struct __db_lockobj {
 #define	holders	dlinks._holders
 #define	heldby	dlinks._heldby
 
+/*
+ * The lock table is the per-process cookie returned from a lock_open call.
+ */
 struct __db_locktab {
 	DB_ENV		*dbenv;		/* Environment. */
-	int		 fd;		/* mapped file descriptor */
-	DB_LOCKREGION	*region;	/* address of shared memory region */
+	REGINFO		 reginfo;	/* Region information. */
+	DB_LOCKREGION	*region;	/* Address of shared memory region. */
 	DB_HASHTAB 	*hashtab; 	/* Beginning of hash table. */
-	size_t		reg_size;	/* last known size of lock region */
 	void		*mem;		/* Beginning of string space. */
 	u_int8_t 	*conflicts;	/* Pointer to conflict matrix. */
 };
@@ -113,21 +115,6 @@ struct __db_locktab {
 	T->conflicts[HELD * T->region->nmodes + WANTED]
 
 /*
- * Status of a lock.
- */
-typedef enum {
-	DB_LSTAT_ABORTED,		/* Lock belongs to an aborted txn. */
-	DB_LSTAT_ERR,			/* Lock is bad. */
-	DB_LSTAT_FREE,			/* Lock is unallocated. */
-	DB_LSTAT_HELD,			/* Lock is currently held. */
-	DB_LSTAT_NOGRANT,		/* Lock was not granted. */
-	DB_LSTAT_PENDING,		/* Lock was waiting and has been
-					 * promoted; waiting for the owner
-					 * to run and upgrade it to held. */
-	DB_LSTAT_WAITING		/* Lock is on the wait queue. */
-} db_status_t;
-
-/*
  * Resources in the lock region.  Used to indicate which resource
  * is running low when we need to grow the region.
  */
@@ -187,17 +174,4 @@ struct __db_lock {
 	ALIGN((N) * sizeof(DB_LOCKOBJ), sizeof(size_t)) +		\
 	ALIGN(STRING_SIZE(N), sizeof(size_t)))
 
-#ifdef DEBUG
-#define	LOCK_DEBUG_LOCKERS	0x0001
-#define	LOCK_DEBUG_LOCK	 	0x0002
-#define	LOCK_DEBUG_OBJ	 	0x0004
-#define	LOCK_DEBUG_CONF	 	0x0008
-#define	LOCK_DEBUG_MEM	 	0x0010
-#define	LOCK_DEBUG_BUCKET	0x0020
-#define LOCK_DEBUG_OBJECTS	0x0040
-#define	LOCK_DEBUG_ALL	 	0xFFFF
-
-#define	LOCK_DEBUG_NOMUTEX	0x0100
-#endif
-
 #include "lock_ext.h"
diff --git a/db2/include/lock_ext.h b/db2/include/lock_ext.h
index d983b29069..1e0522c6b5 100644
--- a/db2/include/lock_ext.h
+++ b/db2/include/lock_ext.h
@@ -1,14 +1,17 @@
 /* DO NOT EDIT: automatically built by dist/distrib. */
 #ifndef _lock_ext_h_
 #define _lock_ext_h_
-void __lock_dump_region __P((DB_LOCKTAB *, u_int));
 int __lock_is_locked
    __P((DB_LOCKTAB *, u_int32_t, DBT *, db_lockmode_t));
+void __lock_printlock __P((DB_LOCKTAB *, struct __db_lock *, int));
 int __lock_getobj  __P((DB_LOCKTAB *,
     u_int32_t, const DBT *, u_int32_t type, DB_LOCKOBJ **));
+int __lock_validate_region __P((DB_LOCKTAB *));
+int __lock_grow_region __P((DB_LOCKTAB *, int, size_t));
+void __lock_dump_region __P((DB_LOCKTAB *, char *, FILE *));
 int __lock_cmp __P((const DBT *, DB_LOCKOBJ *));
 int __lock_locker_cmp __P((u_int32_t, DB_LOCKOBJ *));
-int __lock_ohash __P((const DBT *));
-u_int32_t __lock_locker_hash __P((u_int32_t));
+u_int32_t __lock_ohash __P((const DBT *));
 u_int32_t __lock_lhash __P((DB_LOCKOBJ *));
+u_int32_t __lock_locker_hash __P((u_int32_t));
 #endif /* _lock_ext_h_ */
diff --git a/db2/include/log.h b/db2/include/log.h
index 4e27b038d3..7d5161cc9d 100644
--- a/db2/include/log.h
+++ b/db2/include/log.h
@@ -1,10 +1,10 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  *
- *	@(#)log.h	10.19 (Sleepycat) 1/17/98
+ *	@(#)log.h	10.25 (Sleepycat) 4/10/98
  */
 
 #ifndef _LOG_H_
@@ -15,9 +15,10 @@ struct __hdr;		typedef struct __hdr HDR;
 struct __log;		typedef struct __log LOG;
 struct __log_persist;	typedef struct __log_persist LOGP;
 
+#ifndef MAXLFNAME
 #define	MAXLFNAME	99999		/* Maximum log file name. */
 #define	LFNAME		"log.%05d"	/* Log file name template. */
-
+#endif
 					/* Default log name. */
 #define DB_DEFAULT_LOG_FILE	"__db_log.share"
 
@@ -31,17 +32,19 @@ struct __log_persist;	typedef struct __log_persist LOGP;
 	if (F_ISSET(dblp, DB_AM_THREAD))				\
 		(void)__db_mutex_unlock((dblp)->mutexp, -1);
 #define	LOCK_LOGREGION(dblp)						\
-	(void)__db_mutex_lock(&((RLAYOUT *)(dblp)->lp)->lock, (dblp)->fd)
+	(void)__db_mutex_lock(&((RLAYOUT *)(dblp)->lp)->lock,		\
+	    (dblp)->reginfo.fd)
 #define	UNLOCK_LOGREGION(dblp)						\
-	(void)__db_mutex_unlock(&((RLAYOUT *)(dblp)->lp)->lock, (dblp)->fd)
+	(void)__db_mutex_unlock(&((RLAYOUT *)(dblp)->lp)->lock,		\
+	    (dblp)->reginfo.fd)
 
 /*
  * The per-process table that maps log file-id's to DB structures.
  */
 typedef	struct __db_entry {
-	DB	*dbp;			/* Associated DB structure. */
-	int	refcount;		/* Reference counted. */
-	int	deleted;		/* File was not found during open. */
+	DB	 *dbp;			/* Associated DB structure. */
+	u_int32_t refcount;		/* Reference counted. */
+	int	  deleted;		/* File was not found during open. */
 } DB_ENTRY;
 
 /*
@@ -75,10 +78,9 @@ struct __db_log {
 	LOG	 *lp;			/* Address of the shared LOG. */
 
 	DB_ENV	 *dbenv;		/* Reference to error information. */
+	REGINFO	  reginfo;		/* Region information. */
 
-	void     *maddr;		/* Address of mmap'd region. */
 	void     *addr;			/* Address of shalloc() region. */
-	int	  fd;			/* Region file descriptor. */
 
 	char	 *dir;			/* Directory argument. */
 
@@ -131,7 +133,7 @@ struct __log {
 
 	u_int32_t w_off;		/* Current write offset in the file. */
 
-	DB_LSN	  c_lsn;		/* LSN of the last checkpoint. */
+	DB_LSN	  chkpt_lsn;		/* LSN of the last checkpoint. */
 	time_t	  chkpt;		/* Time of the last checkpoint. */
 
 	DB_LOG_STAT stat;		/* Log statistics. */
@@ -159,9 +161,8 @@ struct __fname {
 	u_int32_t id;			/* Logging file id. */
 	DBTYPE	  s_type;		/* Saved DB type. */
 
-	u_int32_t fileid_off;		/* Unique file id offset. */
-
 	size_t	  name_off;		/* Name offset. */
+	u_int8_t  ufid[DB_FILE_ID_LEN];	/* Unique file id. */
 };
 
 /* File open/close register log record opcodes. */
diff --git a/db2/include/log_ext.h b/db2/include/log_ext.h
index 8640b134cd..bf3bcb02ce 100644
--- a/db2/include/log_ext.h
+++ b/db2/include/log_ext.h
@@ -13,8 +13,8 @@ int __log_register_read __P((void *, __log_register_args **));
 int __log_init_print __P((DB_ENV *));
 int __log_init_recover __P((DB_ENV *));
 int __log_findckp __P((DB_LOG *, DB_LSN *));
-int __log_get __P((DB_LOG *, DB_LSN *, DBT *, int, int));
-int __log_put __P((DB_LOG *, DB_LSN *, const DBT *, int));
+int __log_get __P((DB_LOG *, DB_LSN *, DBT *, u_int32_t, int));
+int __log_put __P((DB_LOG *, DB_LSN *, const DBT *, u_int32_t));
 int __log_name __P((DB_LOG *, int, char **));
 int __log_register_recover
     __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
diff --git a/db2/include/mp.h b/db2/include/mp.h
index 4efbf9b95e..8635efa722 100644
--- a/db2/include/mp.h
+++ b/db2/include/mp.h
@@ -1,10 +1,10 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  *
- *	@(#)mp.h	10.25 (Sleepycat) 1/8/98
+ *	@(#)mp.h	10.33 (Sleepycat) 5/4/98
  */
 
 struct __bh;		typedef struct __bh BH;
@@ -16,10 +16,12 @@ struct __mpoolfile;	typedef struct __mpoolfile MPOOLFILE;
 #define	DB_DEFAULT_MPOOL_FILE	"__db_mpool.share"
 
 /*
- *  We default to 128K (16 8K pages) if the user doesn't specify, and
+ * We default to 128K (16 8K pages) if the user doesn't specify, and
  * require a minimum of 20K.
  */
+#ifndef	DB_CACHESIZE_DEF
 #define	DB_CACHESIZE_DEF	(128 * 1024)
+#endif
 #define	DB_CACHESIZE_MIN	( 20 * 1024)
 
 #define	INVALID		0		/* Invalid shared memory offset. */
@@ -79,30 +81,30 @@ struct __mpoolfile;	typedef struct __mpoolfile MPOOLFILE;
 #define	LOCKINIT(dbmp, mutexp)						\
 	if (F_ISSET(dbmp, MP_LOCKHANDLE | MP_LOCKREGION))		\
 		(void)__db_mutex_init(mutexp,				\
-		    MUTEX_LOCK_OFFSET((dbmp)->maddr, mutexp))
+		    MUTEX_LOCK_OFFSET((dbmp)->reginfo.addr, mutexp))
 
 #define	LOCKHANDLE(dbmp, mutexp)					\
 	if (F_ISSET(dbmp, MP_LOCKHANDLE))				\
-		(void)__db_mutex_lock(mutexp, (dbmp)->fd)
+		(void)__db_mutex_lock(mutexp, (dbmp)->reginfo.fd)
 #define	UNLOCKHANDLE(dbmp, mutexp)					\
 	if (F_ISSET(dbmp, MP_LOCKHANDLE))				\
-		(void)__db_mutex_unlock(mutexp, (dbmp)->fd)
+		(void)__db_mutex_unlock(mutexp, (dbmp)->reginfo.fd)
 
 #define	LOCKREGION(dbmp)						\
 	if (F_ISSET(dbmp, MP_LOCKREGION))				\
 		(void)__db_mutex_lock(&((RLAYOUT *)(dbmp)->mp)->lock,	\
-		    (dbmp)->fd)
+		    (dbmp)->reginfo.fd)
 #define	UNLOCKREGION(dbmp)						\
 	if (F_ISSET(dbmp, MP_LOCKREGION))				\
 		(void)__db_mutex_unlock(&((RLAYOUT *)(dbmp)->mp)->lock,	\
-		(dbmp)->fd)
+		(dbmp)->reginfo.fd)
 
 #define	LOCKBUFFER(dbmp, bhp)						\
 	if (F_ISSET(dbmp, MP_LOCKREGION))				\
-		(void)__db_mutex_lock(&(bhp)->mutex, (dbmp)->fd)
+		(void)__db_mutex_lock(&(bhp)->mutex, (dbmp)->reginfo.fd)
 #define	UNLOCKBUFFER(dbmp, bhp)						\
 	if (F_ISSET(dbmp, MP_LOCKREGION))				\
-		(void)__db_mutex_unlock(&(bhp)->mutex, (dbmp)->fd)
+		(void)__db_mutex_unlock(&(bhp)->mutex, (dbmp)->reginfo.fd)
 
 /*
  * DB_MPOOL --
@@ -120,20 +122,16 @@ struct __db_mpool {
 
 /* These fields are not protected. */
 	DB_ENV     *dbenv;		/* Reference to error information. */
+	REGINFO	    reginfo;		/* Region information. */
 
 	MPOOL	   *mp;			/* Address of the shared MPOOL. */
 
-	void	   *maddr;		/* Address of mmap'd region. */
 	void	   *addr;		/* Address of shalloc() region. */
 
 	DB_HASHTAB *htab;		/* Hash table of bucket headers. */
 
-	int	    fd;			/* Underlying mmap'd fd. */
-
-#define	MP_ISPRIVATE	0x01		/* Private, so local memory. */
-#define	MP_LOCKHANDLE	0x02		/* Threaded, lock handles and region. */
-#define	MP_LOCKREGION	0x04		/* Concurrent access, lock region. */
-#define	MP_MALLOC	0x08		/* If region in allocated memory. */
+#define	MP_LOCKHANDLE	0x01		/* Threaded, lock handles and region. */
+#define	MP_LOCKREGION	0x02		/* Concurrent access, lock region. */
 	u_int32_t  flags;
 };
 
@@ -146,8 +144,8 @@ struct __db_mpreg {
 
 	int ftype;			/* File type. */
 					/* Pgin, pgout routines. */
-	int (*pgin) __P((db_pgno_t, void *, DBT *));
-	int (*pgout) __P((db_pgno_t, void *, DBT *));
+	int (DB_CALLBACK *pgin) __P((db_pgno_t, void *, DBT *));
+	int (DB_CALLBACK *pgout) __P((db_pgno_t, void *, DBT *));
 };
 
 /*
@@ -207,7 +205,7 @@ struct __mpool {
 	size_t	    htab_buckets;	/* Number of hash table entries. */
 
 	DB_LSN	    lsn;		/* Maximum checkpoint LSN. */
-	int	    lsn_cnt;		/* Checkpoint buffers left to write. */
+	u_int32_t   lsn_cnt;		/* Checkpoint buffers left to write. */
 
 	DB_MPOOL_STAT stat;		/* Global mpool statistics. */
 
@@ -225,7 +223,9 @@ struct __mpoolfile {
 	u_int32_t ref;			/* Reference count. */
 
 	int	  ftype;		/* File type. */
-	int	  lsn_off;		/* Page's LSN offset. */
+
+	int32_t	  lsn_off;		/* Page's LSN offset. */
+	u_int32_t clear_len;		/* Bytes to clear on page create. */
 
 	size_t	  path_off;		/* File name location. */
 	size_t	  fileid_off;		/* File identification location. */
@@ -233,9 +233,10 @@ struct __mpoolfile {
 	size_t	  pgcookie_len;		/* Pgin/pgout cookie length. */
 	size_t	  pgcookie_off;		/* Pgin/pgout cookie location. */
 
-	int	  lsn_cnt;		/* Checkpoint buffers left to write. */
+	u_int32_t lsn_cnt;		/* Checkpoint buffers left to write. */
 
 	db_pgno_t last_pgno;		/* Last page in the file. */
+	db_pgno_t orig_last_pgno;	/* Original last page in the file. */
 
 #define	MP_CAN_MMAP	0x01		/* If the file can be mmap'd. */
 #define	MP_TEMP		0x02		/* Backing file is a temporary. */
diff --git a/db2/include/mp_ext.h b/db2/include/mp_ext.h
index 1928820637..3650839475 100644
--- a/db2/include/mp_ext.h
+++ b/db2/include/mp_ext.h
@@ -7,13 +7,13 @@ int __memp_pgread __P((DB_MPOOLFILE *, BH *, int));
 int __memp_pgwrite __P((DB_MPOOLFILE *, BH *, int *, int *));
 int __memp_pg __P((DB_MPOOLFILE *, BH *, int));
 void __memp_bhfree __P((DB_MPOOL *, MPOOLFILE *, BH *, int));
-int __memp_fopen __P((DB_MPOOL *, MPOOLFILE *, const char *, int,
-   int, int, size_t, int, DBT *, u_int8_t *, int, DB_MPOOLFILE **));
+int __memp_fopen __P((DB_MPOOL *, MPOOLFILE *, const char *,
+   u_int32_t, int, size_t, int, DB_MPOOL_FINFO *, DB_MPOOLFILE **));
 char * __memp_fn __P((DB_MPOOLFILE *));
 char * __memp_fns __P((DB_MPOOL *, MPOOLFILE *));
-void __memp_debug __P((DB_MPOOL *, FILE *, int));
+void __memp_dump_region __P((DB_MPOOL *, char *, FILE *));
 int __memp_ralloc __P((DB_MPOOL *, size_t, size_t *, void *));
 int __memp_ropen
-   __P((DB_MPOOL *, const char *, size_t, int, int));
-int __memp_rclose __P((DB_MPOOL *));
+   __P((DB_MPOOL *, const char *, size_t, int, int, u_int32_t));
+int __mp_xxx_fd __P((DB_MPOOLFILE *, int *));
 #endif /* _mp_ext_h_ */
diff --git a/db2/include/mutex_ext.h b/db2/include/mutex_ext.h
index f0e68f3659..b48da5d2f4 100644
--- a/db2/include/mutex_ext.h
+++ b/db2/include/mutex_ext.h
@@ -1,7 +1,7 @@
 /* DO NOT EDIT: automatically built by dist/distrib. */
 #ifndef _mutex_ext_h_
 #define _mutex_ext_h_
-void __db_mutex_init __P((db_mutex_t *, u_int32_t));
+int __db_mutex_init __P((db_mutex_t *, u_int32_t));
 int __db_mutex_lock __P((db_mutex_t *, int));
 int __db_mutex_unlock __P((db_mutex_t *, int));
 #endif /* _mutex_ext_h_ */
diff --git a/db2/include/os_ext.h b/db2/include/os_ext.h
index 9c66a248c8..889a45a44e 100644
--- a/db2/include/os_ext.h
+++ b/db2/include/os_ext.h
@@ -2,23 +2,29 @@
 #ifndef _os_ext_h_
 #define _os_ext_h_
 int __db_abspath __P((const char *));
+char *__db_strdup __P((const char *));
 void *__db_calloc __P((size_t, size_t));
 void *__db_malloc __P((size_t));
 void *__db_realloc __P((void *, size_t));
-int __os_oldwin __P((void));
 int __os_dirlist __P((const char *, char ***, int *));
 void __os_dirfree __P((char **, int));
 int __db_fileid __P((DB_ENV *, const char *, int, u_int8_t *));
 int __db_fsync __P((int));
-int __os_map __P((int, size_t, int, int, void **));
-int __os_unmap __P((void *, size_t));
-int __db_oflags __P((int));
-int __db_open __P((const char *, int, int, int, int *));
+int __db_mapanon_ok __P((int));
+int __db_mapinit __P((void));
+int __db_mapregion __P((char *, REGINFO *));
+int __db_unmapregion __P((REGINFO *));
+int __db_unlinkregion __P((char *, REGINFO *));
+int __db_mapfile __P((char *, int, size_t, int, void **));
+int __db_unmapfile __P((void *, size_t));
+u_int32_t __db_oflags __P((int));
+int __db_omode __P((const char *));
+int __db_open __P((const char *, u_int32_t, u_int32_t, int, int *));
 int __db_close __P((int));
 char *__db_rpath __P((const char *));
 int __db_read __P((int, void *, size_t, ssize_t *));
 int __db_write __P((int, void *, size_t, ssize_t *));
-int __os_seek __P((int, size_t, db_pgno_t, u_long, int));
+int __os_seek __P((int, size_t, db_pgno_t, u_int32_t, int, int));
 int __os_sleep __P((u_long, u_long));
 int __os_spin __P((void));
 int __os_exists __P((const char *, int *));
diff --git a/db2/include/os_func.h b/db2/include/os_func.h
index b825fed5db..12794d550d 100644
--- a/db2/include/os_func.h
+++ b/db2/include/os_func.h
@@ -1,40 +1,40 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1997
+ * Copyright (c) 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  *
- *	@(#)os_func.h	10.5 (Sleepycat) 12/4/97
+ *	@(#)os_func.h	10.8 (Sleepycat) 4/19/98
  */
 
 /* Calls which can be replaced by the application. */
 struct __db_jumptab {
-	int	(*db_close) __P((int));			/* DB_FUNC_CLOSE */
-	void	(*db_dirfree) __P((char **, int));	/* DB_FUNC_DIRFREE */
-	int	(*db_dirlist)				/* DB_FUNC_DIRLIST */
+	int	(*j_close) __P((int));			/* DB_FUNC_CLOSE */
+	void	(*j_dirfree) __P((char **, int));	/* DB_FUNC_DIRFREE */
+	int	(*j_dirlist)				/* DB_FUNC_DIRLIST */
 		    __P((const char *, char ***, int *));
-	int	(*db_exists)				/* DB_FUNC_EXISTS */
+	int	(*j_exists)				/* DB_FUNC_EXISTS */
 		    __P((const char *, int *));
-	void	(*db_free) __P((void *));		/* DB_FUNC_FREE */
-	int	(*db_fsync) __P((int));			/* DB_FUNC_FSYNC */
-	int	(*db_ioinfo) __P((const char *,		/* DB_FUNC_IOINFO */
+	void	(*j_free) __P((void *));		/* DB_FUNC_FREE */
+	int	(*j_fsync) __P((int));			/* DB_FUNC_FSYNC */
+	int	(*j_ioinfo) __P((const char *,		/* DB_FUNC_IOINFO */
 		    int, u_int32_t *, u_int32_t *, u_int32_t *));
-	void   *(*db_malloc) __P((size_t));		/* DB_FUNC_MALLOC */
-	int	(*db_map)				/* DB_FUNC_MAP */
-		    __P((int, size_t, int, int, void **));
-	int	(*db_open)				/* DB_FUNC_OPEN */
+	void   *(*j_malloc) __P((size_t));		/* DB_FUNC_MALLOC */
+	int	(*j_map)				/* DB_FUNC_MAP */
+		    __P((char *, int, size_t, int, int, int, void **));
+	int	(*j_open)				/* DB_FUNC_OPEN */
 		    __P((const char *, int, ...));
-	ssize_t	(*db_read) __P((int, void *, size_t));	/* DB_FUNC_READ */
-	void   *(*db_realloc) __P((void *, size_t));	/* DB_FUNC_REALLOC */
-	int	(*db_seek)				/* DB_FUNC_SEEK */
-		    __P((int, size_t, db_pgno_t, u_long, int));
-	int	(*db_sleep) __P((u_long, u_long));	/* DB_FUNC_SLEEP */
-	char   *(*db_strdup) __P((const char *));	/* DB_FUNC_STRDUP */
-	int	(*db_unlink) __P((const char *));	/* DB_FUNC_UNLINK */
-	int	(*db_unmap) __P((void *, size_t));	/* DB_FUNC_UNMAP */
-	ssize_t	(*db_write)				/* DB_FUNC_WRITE */
+	ssize_t	(*j_read) __P((int, void *, size_t));	/* DB_FUNC_READ */
+	void   *(*j_realloc) __P((void *, size_t));	/* DB_FUNC_REALLOC */
+	int	(*j_runlink) __P((char *));		/* DB_FUNC_RUNLINK */
+	int	(*j_seek)				/* DB_FUNC_SEEK */
+		    __P((int, size_t, db_pgno_t, u_int32_t, int, int));
+	int	(*j_sleep) __P((u_long, u_long));	/* DB_FUNC_SLEEP */
+	int	(*j_unlink) __P((const char *));	/* DB_FUNC_UNLINK */
+	int	(*j_unmap) __P((void *, size_t));	/* DB_FUNC_UNMAP */
+	ssize_t	(*j_write)				/* DB_FUNC_WRITE */
 		    __P((int, const void *, size_t));
-	int	(*db_yield) __P((void));		/* DB_FUNC_YIELD */
+	int	(*j_yield) __P((void));			/* DB_FUNC_YIELD */
 };
 
 extern struct __db_jumptab __db_jump;
@@ -43,7 +43,7 @@ extern struct __db_jumptab __db_jump;
  * Names used by DB to call through the jump table.
  *
  * The naming scheme goes like this: if the functionality the application can
- * replace is the same as the DB functionality, e.g., calloc, or dirlist, then
+ * replace is the same as the DB functionality, e.g., malloc, or dirlist, then
  * we use the name __db_XXX, and the application is expected to replace the
  * complete functionality, which may or may not map directly to an ANSI C or
  * POSIX 1003.1 interface.  If the functionality that the aplication replaces
@@ -53,20 +53,17 @@ extern struct __db_jumptab __db_jump;
  * part of DB is the only code that should use the __os_XXX names, all other
  * parts of DB should be calling __db_XXX functions.
  */
-#define	__os_close	__db_jump.db_close	/* __db_close is a wrapper. */
-#define	__db_dirfree	__db_jump.db_dirfree
-#define	__db_dirlist	__db_jump.db_dirlist
-#define	__db_exists	__db_jump.db_exists
-#define	__db_free	__db_jump.db_free
-#define	__os_fsync	__db_jump.db_fsync	/* __db_fsync is a wrapper. */
-#define	__db_ioinfo	__db_jump.db_ioinfo
-#define	__db_map	__db_jump.db_map
-#define	__os_open	__db_jump.db_open	/* __db_open is a wrapper. */
-#define	__os_read	__db_jump.db_read	/* __db_read is a wrapper. */
-#define	__db_seek	__db_jump.db_seek
-#define	__db_sleep	__db_jump.db_sleep
-#define	__db_strdup	__db_jump.db_strdup
-#define	__os_unlink	__db_jump.db_unlink	/* __db_unlink is a wrapper. */
-#define	__db_unmap	__db_jump.db_unmap
-#define	__os_write	__db_jump.db_write	/* __db_write is a wrapper. */
-#define	__db_yield	__db_jump.db_yield
+#define	__os_close	__db_jump.j_close	/* __db_close is a wrapper. */
+#define	__db_dirfree	__db_jump.j_dirfree
+#define	__db_dirlist	__db_jump.j_dirlist
+#define	__db_exists	__db_jump.j_exists
+#define	__db_free	__db_jump.j_free
+#define	__os_fsync	__db_jump.j_fsync	/* __db_fsync is a wrapper. */
+#define	__db_ioinfo	__db_jump.j_ioinfo
+#define	__os_open	__db_jump.j_open	/* __db_open is a wrapper. */
+#define	__os_read	__db_jump.j_read	/* __db_read is a wrapper. */
+#define	__db_seek	__db_jump.j_seek
+#define	__db_sleep	__db_jump.j_sleep
+#define	__os_unlink	__db_jump.j_unlink	/* __db_unlink is a wrapper. */
+#define	__os_write	__db_jump.j_write	/* __db_write is a wrapper. */
+#define	__db_yield	__db_jump.j_yield
diff --git a/db2/include/queue.h b/db2/include/queue.h
index 0909c86c60..f606eb0497 100644
--- a/db2/include/queue.h
+++ b/db2/include/queue.h
@@ -1,6 +1,6 @@
 /*	BSDI $Id$	*/
 
-/* 
+/*
  * Copyright (c) 1991, 1993
  *	The Regents of the University of California.  All rights reserved.
  *
diff --git a/db2/include/shqueue.h b/db2/include/shqueue.h
index c596d33e92..00e5d76251 100644
--- a/db2/include/shqueue.h
+++ b/db2/include/shqueue.h
@@ -1,10 +1,10 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  *
- *	@(#)shqueue.h	8.12 (Sleepycat) 9/10/97
+ *	@(#)shqueue.h	8.13 (Sleepycat) 4/10/98
  */
 #ifndef	_SYS_SHQUEUE_H_
 #define	_SYS_SHQUEUE_H_
diff --git a/db2/include/txn.h b/db2/include/txn.h
index c64ac3fc52..a2512ed152 100644
--- a/db2/include/txn.h
+++ b/db2/include/txn.h
@@ -1,10 +1,10 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  *
- *	@(#)txn.h	10.11 (Sleepycat) 10/25/97
+ *	@(#)txn.h	10.15 (Sleepycat) 4/21/98
  */
 #ifndef	_TXN_H_
 #define	_TXN_H_
@@ -52,12 +52,11 @@ struct __db_txnmgr {
 	TAILQ_HEAD(_chain, __db_txn)	txn_chain;
 
 /* These fields are not protected. */
+	REGINFO		reginfo;	/* Region information. */
 	DB_ENV		*dbenv;		/* Environment. */
 	int (*recover)			/* Recovery dispatch routine */
 	    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
-	int		 fd;		/* mapped file descriptor */
-	u_int		 flags;		/* DB_TXN_NOSYNC, DB_THREAD */
-	size_t		 reg_size;	/* how large we think the region is */
+	u_int32_t	 flags;		/* DB_TXN_NOSYNC, DB_THREAD */
 	DB_TXNREGION	*region;	/* address of shared memory region */
 	void		*mem;		/* address of the shalloc space */
 };
@@ -102,17 +101,16 @@ struct __db_txnregion {
 		(void)__db_mutex_unlock((tmgrp)->mutexp, -1)
 
 #define	LOCK_TXNREGION(tmgrp)						\
-	(void)__db_mutex_lock(&(tmgrp)->region->hdr.lock, (tmgrp)->fd)
+	(void)__db_mutex_lock(&(tmgrp)->region->hdr.lock, (tmgrp)->reginfo.fd)
 #define	UNLOCK_TXNREGION(tmgrp)						\
-	(void)__db_mutex_unlock(&(tmgrp)->region->hdr.lock, (tmgrp)->fd)
+	(void)__db_mutex_unlock(&(tmgrp)->region->hdr.lock, (tmgrp)->reginfo.fd)
 
 /*
  * Log record types.
  */
-#define	TXN_BEGIN	1
-#define	TXN_COMMIT	2
-#define	TXN_PREPARE	3
-#define	TXN_CHECKPOINT	4
+#define	TXN_COMMIT	1
+#define	TXN_PREPARE	2
+#define	TXN_CHECKPOINT	3
 
 #include "txn_auto.h"
 #include "txn_ext.h"