#line 1 "./bdb.c"
/*
 * CLISP: Berkeley-DB <http://www.sleepycat.com/docs/api_c/>
 * Copyright (C) 2003-2010 by Sam Steingold
 */

#include "clisp.h"

#ifndef FOREIGN
# error Berkeley-DB requires CLISP FOREIGN CPP macro
#endif

#include "config.h"

#if defined(__CYGWIN__)
# define UNIX_CYGWIN32
#endif

#if defined(_WIN32) || defined(UNIX_CYGWIN32)
# define WIN32_LEAN_AND_MEAN  /* avoid including junk */
# if defined(UNIX_CYGWIN32) || defined(__MINGW32__)
#  define ULONGLONG OS_ULONGLONG
#  define ULONG OS_ULONG
#  include <windows.h>
#  undef ULONG
#  undef ULONGLONG
# else
#  include <windows.h>
# endif
#endif

#if defined(HAVE_SYS_TIME_H)
# include <sys/time.h>
#endif
#if defined(HAVE_TIME_H)
# include <time.h>
#endif

#include <string.h>             /* for memset() */
#include <stdio.h>              /* fopen/fclose for db->verify */

/* #define DEBUG */
#if defined(DEBUG)
# include <dmalloc.h>
# define clisp_malloc malloc
extern object nobject_out (FILE* stream, object obj);
#line 48
# define XOUT(obj,label)                                                   (printf("[%s:%d] %s: %s:\n",__FILE__,__LINE__,STRING(obj),label),         obj=nobject_out(stdout,obj), printf("\n"))
#line 51
# define VECOUT(v,l)                               (printf("[%s:%d] %d: ",__FILE__,__LINE__,l),      vecout(v,l), printf("\n"))
static void vecout (unsigned char* v, int l) {
  int i; for (i=0; i<l; i++) printf(" %x",v[i]);
}
#else
# undef OBJECT_OUT
# define OBJECT_OUT(o,l)
# define XOUT(o,l)
# define VECOUT(v,l)
#endif

/* convert C string to Lisp string; NULL --> NIL
   first argument is evaluated twice - must be a variable
   this is a macro and not a function for NO_UNICODE */
#define asciz_to_string0(a,e) (a ? asciz_to_string(a,e) : NIL)

#include <db.h>

/* http://www.oracle.com/technology/products/berkeley-db/db/update/4.4.20/if.4.4.20.html
 * DIRTY -> DB_READ_UNCOMMITTED; DEGREE_2 -> DB_READ_COMMITTED */
#if !HAVE_DECL_DB_LOCK_READ_UNCOMMITTED
# define DB_LOCK_READ_UNCOMMITTED DB_LOCK_DIRTY
#endif
#if !defined(DB_READ_UNCOMMITTED)
# define DB_READ_UNCOMMITTED DB_DIRTY_READ
#endif
#if !defined(DB_READ_COMMITTED)
# define DB_READ_COMMITTED DB_DEGREE_2
#endif

/* this has to be before DEFCHECKERs */
typedef enum { DBT_RAW, DBT_STRING, DBT_INTEGER } dbt_o_t;

DEFMODULE(bdb,"BDB")

#define O(varname) module__bdb__object_tab._##varname
#define F(varname) subr_tab_ptr_as_object(&(module__bdb__subr_tab._##varname))

struct module__bdb__object_tab_t {
  gcv_object_t _object_bdb__bdb_error;
  gcv_object_t _object_bdb__db;
  gcv_object_t _object_bdb__dbc;
  gcv_object_t _object_bdb__dbe;
  gcv_object_t _object_bdb__dblock;
  gcv_object_t _object_bdb__kill_handle;
  gcv_object_t _object_bdb__lock_put;
  gcv_object_t _object_bdb__logc;
  gcv_object_t _object_bdb__lsn;
  gcv_object_t _object_bdb__mkdb;
  gcv_object_t _object_bdb__mkdbc;
  gcv_object_t _object_bdb__mkdbe;
  gcv_object_t _object_bdb__mkdblock;
  gcv_object_t _object_bdb__mkdbstat_btree;
  gcv_object_t _object_bdb__mkdbstat_hash;
  gcv_object_t _object_bdb__mkdbstat_queue;
  gcv_object_t _object_bdb__mkhandle;
  gcv_object_t _object_bdb__mklockstat;
  gcv_object_t _object_bdb__mklogc;
  gcv_object_t _object_bdb__mklogstat;
  gcv_object_t _object_bdb__mklsn;
  gcv_object_t _object_bdb__mktxn;
  gcv_object_t _object_bdb__mktxnactive;
  gcv_object_t _object_bdb__mktxnstat;
  gcv_object_t _object_bdb__txn;
#if defined(TXN_ABORTED)
  gcv_object_t _object_Kaborted;
#endif
  gcv_object_t _object_Kaction;
#if defined(DB_ENCRYPT_AES)
  gcv_object_t _object_Kaes;
#endif
#if defined(DB_AFTER)
  gcv_object_t _object_Kafter;
#endif
  gcv_object_t _object_Kaggressive;
#if defined(DB_ALREADY_ABORTED)
  gcv_object_t _object_Kalready_aborted;
#endif
#if defined(DB_APPEND)
  gcv_object_t _object_Kappend;
#endif
  gcv_object_t _object_Karch_abs;
  gcv_object_t _object_Karch_data;
  gcv_object_t _object_Karch_log;
  gcv_object_t _object_Karch_remove;
  gcv_object_t _object_Kauto_commit;
#if defined(DB_BEFORE)
  gcv_object_t _object_Kbefore;
#endif
  gcv_object_t _object_Kbtree;
  gcv_object_t _object_Kbt_minkey;
#if defined(DB_BUFFER_SMALL)
  gcv_object_t _object_Kbuffer_small;
#endif
  gcv_object_t _object_Kcache;
  gcv_object_t _object_Kcachesize;
  gcv_object_t _object_Kcdb_alldb;
  gcv_object_t _object_Kchksum;
  gcv_object_t _object_Kclient_timeout;
#if defined(TXN_COMMITTED)
  gcv_object_t _object_Kcommitted;
#endif
  gcv_object_t _object_Kconsume;
#if defined(DB_CONSUME_WAIT)
  gcv_object_t _object_Kconsume_wait;
#endif
  gcv_object_t _object_Kcreate;
#if defined(DB_CURRENT)
  gcv_object_t _object_Kcurrent;
#endif
  gcv_object_t _object_Kdatabase;
  gcv_object_t _object_Kdata_dir;
  gcv_object_t _object_Kdbname;
  gcv_object_t _object_Kdb_gid_size;
#if defined(DB_LOCK_DEFAULT)
  gcv_object_t _object_Kdefault;
#endif
#if defined(DB_DELETED)
  gcv_object_t _object_Kdeleted;
#endif
  gcv_object_t _object_Kdirect_db;
#if defined(DB_DONOTINDEX)
  gcv_object_t _object_Kdonotindex;
#endif
  gcv_object_t _object_Kdup;
  gcv_object_t _object_Kdupsort;
  gcv_object_t _object_Kencrypt;
  gcv_object_t _object_Kencryption;
  gcv_object_t _object_Kencrypt_aes;
  gcv_object_t _object_Kerrfile;
  gcv_object_t _object_Kerror;
  gcv_object_t _object_Kerrpfx;
  gcv_object_t _object_Kexcl;
#if defined(DB_LOCK_EXPIRE)
  gcv_object_t _object_Kexpire;
#endif
  gcv_object_t _object_Kfast_stat;
  gcv_object_t _object_Kfirst;
  gcv_object_t _object_Kflags;
  gcv_object_t _object_Kflush;
  gcv_object_t _object_Kforce;
#if defined(DB_GET_BOTH)
  gcv_object_t _object_Kget_both;
#endif
#if defined(DB_GET_BOTH_RANGE)
  gcv_object_t _object_Kget_both_range;
#endif
#if defined(DB_GET_RECNO)
  gcv_object_t _object_Kget_recno;
#endif
  gcv_object_t _object_Khash;
  gcv_object_t _object_Khome;
  gcv_object_t _object_Khomedir;
  gcv_object_t _object_Khost;
  gcv_object_t _object_Kh_ffactor;
  gcv_object_t _object_Kh_nelem;
  gcv_object_t _object_Kinit_cdb;
  gcv_object_t _object_Kinit_lock;
  gcv_object_t _object_Kinit_log;
  gcv_object_t _object_Kinit_mpool;
  gcv_object_t _object_Kinit_txn;
  gcv_object_t _object_Kinorder;
  gcv_object_t _object_Kinteger;
  gcv_object_t _object_Kintermediate_dir_mode;
  gcv_object_t _object_Kiread;
  gcv_object_t _object_Kiwr;
  gcv_object_t _object_Kiwrite;
  gcv_object_t _object_Kjoinenv;
#if defined(DB_JOIN_ITEM)
  gcv_object_t _object_Kjoin_item;
#endif
  gcv_object_t _object_Kjoin_nosort;
  gcv_object_t _object_Kkbyte;
  gcv_object_t _object_Kkeyempty;
  gcv_object_t _object_Kkeyexist;
#if defined(DB_KEYFIRST)
  gcv_object_t _object_Kkeyfirst;
#endif
#if defined(DB_KEYLAST)
  gcv_object_t _object_Kkeylast;
#endif
  gcv_object_t _object_Kkey_type;
#if defined(DB_LAST)
  gcv_object_t _object_Klast;
#endif
  gcv_object_t _object_Klg_bsize;
  gcv_object_t _object_Klg_dir;
  gcv_object_t _object_Klg_max;
  gcv_object_t _object_Klg_regionmax;
  gcv_object_t _object_Klk_conflicts;
  gcv_object_t _object_Klk_detect;
  gcv_object_t _object_Klk_max_lockers;
  gcv_object_t _object_Klk_max_locks;
  gcv_object_t _object_Klk_max_objects;
#if defined(DB_LOCKVERSION)
  gcv_object_t _object_Klock;
#endif
  gcv_object_t _object_Klockdown;
#if defined(DB_LOCK_DEADLOCK)
  gcv_object_t _object_Klock_deadlock;
#endif
#if defined(DB_LOCK_NOTEXIST)
  gcv_object_t _object_Klock_notexist;
#endif
#if defined(DB_LOCK_NOTGRANTED)
  gcv_object_t _object_Klock_notgranted;
#endif
  gcv_object_t _object_Klock_timeout;
#if defined(DB_LOGVERSION)
  gcv_object_t _object_Klog;
#endif
  gcv_object_t _object_Klog_auto_remove;
#if defined(DB_LOG_BUFFER_FULL)
  gcv_object_t _object_Klog_buffer_full;
#endif
  gcv_object_t _object_Klog_direct;
  gcv_object_t _object_Klog_dsync;
  gcv_object_t _object_Klog_in_memory;
  gcv_object_t _object_Klog_zero;
  gcv_object_t _object_Klorder;
#if defined(DB_LOCK_MAXLOCKS)
  gcv_object_t _object_Kmaxlocks;
#endif
  gcv_object_t _object_Kmin;
#if defined(DB_LOCK_MINLOCKS)
  gcv_object_t _object_Kminlocks;
#endif
#if defined(DB_LOCK_MINWRITE)
  gcv_object_t _object_Kminwrite;
#endif
  gcv_object_t _object_Kmode;
  gcv_object_t _object_Kmsgfile;
  gcv_object_t _object_Kmultiple;
  gcv_object_t _object_Kmultiple_key;
  gcv_object_t _object_Kncache;
#if defined(DB_NEEDSPLIT)
  gcv_object_t _object_Kneedsplit;
#endif
  gcv_object_t _object_Knext;
#if defined(DB_NEXT_DUP)
  gcv_object_t _object_Knext_dup;
#endif
#if defined(DB_NEXT_NODUP)
  gcv_object_t _object_Knext_nodup;
#endif
  gcv_object_t _object_Kng;
#if defined(DB_NODUPDATA)
  gcv_object_t _object_Knodupdata;
#endif
  gcv_object_t _object_Knolocking;
  gcv_object_t _object_Knommap;
  gcv_object_t _object_Knoorderchk;
#if defined(DB_NOOVERWRITE)
  gcv_object_t _object_Knooverwrite;
#endif
  gcv_object_t _object_Knopanic;
#if defined(DB_LOCK_NORUN)
  gcv_object_t _object_Knorun;
#endif
#if defined(DB_NOSERVER)
  gcv_object_t _object_Knoserver;
#endif
#if defined(DB_NOSERVER_HOME)
  gcv_object_t _object_Knoserver_home;
#endif
#if defined(DB_NOSERVER_ID)
  gcv_object_t _object_Knoserver_id;
#endif
  gcv_object_t _object_Knosync;
  gcv_object_t _object_Knotfound;
  gcv_object_t _object_Knowait;
#if defined(DB_LOCK_OLDEST)
  gcv_object_t _object_Koldest;
#endif
#if defined(DB_OLD_VERSION)
  gcv_object_t _object_Kold_version;
#endif
  gcv_object_t _object_Kopen;
  gcv_object_t _object_Koverwrite;
#if defined(DB_OVERWRITE_DUP)
  gcv_object_t _object_Koverwrite_dup;
#endif
  gcv_object_t _object_Kpagesize;
#if defined(DB_PAGE_NOTFOUND)
  gcv_object_t _object_Kpage_notfound;
#endif
  gcv_object_t _object_Kpanic_environment;
  gcv_object_t _object_Kparent;
  gcv_object_t _object_Kpassword;
  gcv_object_t _object_Kposition;
#if defined(TXN_PREPARED)
  gcv_object_t _object_Kprepared;
#endif
#if defined(DB_PREV)
  gcv_object_t _object_Kprev;
#endif
#if defined(DB_PREV_NODUP)
  gcv_object_t _object_Kprev_nodup;
#endif
  gcv_object_t _object_Kprintable;
  gcv_object_t _object_Kprivate;
#if defined(DB_QAMVERSION)
  gcv_object_t _object_Kqam;
#endif
  gcv_object_t _object_Kqueue;
  gcv_object_t _object_Kq_extentsize;
#if defined(DB_LOCK_RANDOM)
  gcv_object_t _object_Krandom;
#endif
  gcv_object_t _object_Kraw;
  gcv_object_t _object_Krdonly;
  gcv_object_t _object_Kread;
  gcv_object_t _object_Kread_committed;
  gcv_object_t _object_Kread_uncommitted;
  gcv_object_t _object_Krecno;
  gcv_object_t _object_Krecnum;
  gcv_object_t _object_Krecover;
  gcv_object_t _object_Krecover_fatal;
  gcv_object_t _object_Kregion_init;
  gcv_object_t _object_Krenumber;
#if defined(DB_REP_DUPMASTER)
  gcv_object_t _object_Krep_dupmaster;
#endif
#if defined(DB_REP_EGENCHG)
  gcv_object_t _object_Krep_egenchg;
#endif
#if defined(DB_REP_HANDLE_DEAD)
  gcv_object_t _object_Krep_handle_dead;
#endif
#if defined(DB_REP_HOLDELECTION)
  gcv_object_t _object_Krep_holdelection;
#endif
#if defined(DB_REP_ISPERM)
  gcv_object_t _object_Krep_isperm;
#endif
#if defined(DB_REP_LOGREADY)
  gcv_object_t _object_Krep_logready;
#endif
#if defined(DB_REP_NEWMASTER)
  gcv_object_t _object_Krep_newmaster;
#endif
#if defined(DB_REP_NEWSITE)
  gcv_object_t _object_Krep_newsite;
#endif
#if defined(DB_REP_NOTPERM)
  gcv_object_t _object_Krep_notperm;
#endif
#if defined(DB_REP_PAGEDONE)
  gcv_object_t _object_Krep_pagedone;
#endif
#if defined(DB_REP_STARTUPDONE)
  gcv_object_t _object_Krep_startupdone;
#endif
#if defined(DB_REP_UNAVAIL)
  gcv_object_t _object_Krep_unavail;
#endif
  gcv_object_t _object_Krevsplitoff;
  gcv_object_t _object_Kre_delim;
  gcv_object_t _object_Kre_len;
  gcv_object_t _object_Kre_pad;
  gcv_object_t _object_Kre_source;
  gcv_object_t _object_Krmw;
#if defined(TXN_RUNNING)
  gcv_object_t _object_Krunning;
#endif
#if defined(DB_RUNRECOVERY)
  gcv_object_t _object_Krunrecovery;
#endif
  gcv_object_t _object_Ksalvage;
#if defined(DB_SECONDARY_BAD)
  gcv_object_t _object_Ksecondary_bad;
#endif
#if defined(DB_SEQUENCE_VERSION)
  gcv_object_t _object_Ksequence;
#endif
  gcv_object_t _object_Kserver_timeout;
#if defined(DB_SET)
  gcv_object_t _object_Kset;
#endif
#if defined(DB_SET_RANGE)
  gcv_object_t _object_Kset_range;
#endif
#if defined(DB_SET_RECNO)
  gcv_object_t _object_Kset_recno;
#endif
  gcv_object_t _object_Kshm_key;
  gcv_object_t _object_Ksnapshot;
  gcv_object_t _object_Kstat_clear;
  gcv_object_t _object_Kstring;
#if defined(DB_SURPRISE_KID)
  gcv_object_t _object_Ksurprise_kid;
#endif
#if defined(DB_SWAPBYTES)
  gcv_object_t _object_Kswapbytes;
#endif
  gcv_object_t _object_Ksync;
  gcv_object_t _object_Ksystem_mem;
  gcv_object_t _object_Ktas_spins;
  gcv_object_t _object_Kthread;
  gcv_object_t _object_Ktimeout;
  gcv_object_t _object_Ktimestamp;
  gcv_object_t _object_Ktmp_dir;
  gcv_object_t _object_Ktransaction;
  gcv_object_t _object_Ktransactional;
  gcv_object_t _object_Ktruncate;
#if defined(DB_TXNVERSION)
  gcv_object_t _object_Ktxn;
#endif
#if defined(DB_TXN_CKP)
  gcv_object_t _object_Ktxn_ckp;
#endif
  gcv_object_t _object_Ktxn_nosync;
  gcv_object_t _object_Ktxn_not_durable;
  gcv_object_t _object_Ktxn_timeout;
  gcv_object_t _object_Ktxn_write_nosync;
  gcv_object_t _object_Ktx_max;
  gcv_object_t _object_Ktx_timestamp;
  gcv_object_t _object_Ktype;
  gcv_object_t _object_Kunknown;
  gcv_object_t _object_Kuse_environ;
  gcv_object_t _object_Kuse_environ_root;
  gcv_object_t _object_Kverbose;
  gcv_object_t _object_Kverb_chkpoint;
  gcv_object_t _object_Kverb_deadlock;
  gcv_object_t _object_Kverb_recovery;
  gcv_object_t _object_Kverb_replication;
  gcv_object_t _object_Kverb_waitsfor;
#if defined(DB_VERIFY_BAD)
  gcv_object_t _object_Kverify_bad;
#endif
#if defined(DB_VERIFY_FATAL)
  gcv_object_t _object_Kverify_fatal;
#endif
#if defined(DB_VERSION_MISMATCH)
  gcv_object_t _object_Kversion_mismatch;
#endif
  gcv_object_t _object_Kwait;
  gcv_object_t _object_Kwrite;
  gcv_object_t _object_Kwritecursor;
  gcv_object_t _object_Kwwrite;
  gcv_object_t _object_Kyieldcpu;
#if defined(DB_LOCK_YOUNGEST)
  gcv_object_t _object_Kyoungest;
#endif
  gcv_object_t _object__22_7Es_20_28_7Es_29__20_7Es_22;
  gcv_object_t _object__22_7Es_20_28_7Es_29__20_7Es__20_7Es_22;
  gcv_object_t _object__22_7Es__20bad_20logical_20record_20number_20size__20_7Es_20should_20be_20_7Es_22;
  gcv_object_t _object__23_2E_28byte_2030_200_29;
  gcv_object_t _object__28array_20_28unsigned_byte_208_29_20_28_2A_20_2A_29_29;
  gcv_object_t _object__28or_20integer_20_28member_20_ng_20_read_20_write_20_wait_20_iwrite_20_iread_20_iwr_20_read_uncommitted_20_wwrite_29_29;
  gcv_object_t _object__28or_20null_20integer_20_28member_20_raw_20_string_20_integer_29_29;
  gcv_object_t _object__28or_20null_20integer_20_28member_20_unknown_20_btree_20_hash_20_queue_20_recno_29_29;
  gcv_object_t _object__28or_20string_20bdb__dbe_29;
  gcv_object_t _object__28or_20string_20_28integer_200_29_20_28vector_20_28unsigned_byte_29_29_29;
  gcv_object_t _object___28or_20integer_20_28member_defined_28db_buffer_small_29_Kbuffer_small_defined_28db_donotindex_29_Kdonotindex_defined_28db_keyempty_29_Kkeyempty_defined_28db_keyexist_29_Kkeyexist_defined_28db_lock_deadlock_29_Klock_deadlock_defined_28db_lock_notgranted_29_Klock_notgranted_defined_28db_log_buffer_full_29_Klog_buffer_full_defined_28db_noserver_29_Knoserver_defined_28db_noserver_home_29_Knoserver_home_defined_28db_noserver_id_29_Knoserver_id_defined_28db_notfound_29_Knotfound_defined_28db_old_version_29_Kold_version_defined_28db_page_notfound_29_Kpage_notfound_defined_28db_rep_dupmaster_29_Krep_dupmaster_defined_28db_rep_handle_dead_29_Krep_handle_dead_defined_28db_rep_holdelection_29_Krep_holdelection_defined_28db_rep_isperm_29_Krep_isperm_defined_28db_rep_newmaster_29_Krep_newmaster_defined_28db_rep_newsite_29_Krep_newsite_defined_28db_rep_notperm_29_Krep_notperm_defined_28db_rep_startupdone_29_Krep_startupdone_defined_28db_rep_unavail_29_Krep_unavail_defined_28db_runrecovery_29_Krunrecovery_defined_28db_secondary_bad_29_Ksecondary_bad_defined_28db_verify_bad_29_Kverify_bad_defined_28db_version_mismatch_29_Kversion_mismatch_defined_28db_already_aborted_29_Kalready_aborted_defined_28db_deleted_29_Kdeleted_defined_28db_lock_notexist_29_Klock_notexist_defined_28db_needsplit_29_Kneedsplit_defined_28db_rep_egenchg_29_Krep_egenchg_defined_28db_rep_logready_29_Krep_logready_defined_28db_rep_pagedone_29_Krep_pagedone_defined_28db_surprise_kid_29_Ksurprise_kid_defined_28db_swapbytes_29_Kswapbytes_defined_28db_timeout_29_Ktimeout_defined_28db_txn_ckp_29_Ktxn_ckp_defined_28db_verify_fatal_29_Kverify_fatal__29_29;
  gcv_object_t _object___28or_20integer_20_28member_defined_28db_set_lock_timeout_29_Klock_timeout_defined_28db_set_txn_timeout_29_Ktxn_timeout__29_29;
  gcv_object_t _object___28or_20integer_20_28member_defined_28txn_aborted_29_Kaborted_defined_28txn_committed_29_Kcommitted_defined_28txn_prepared_29_Kprepared_defined_28txn_running_29_Krunning__29_29;
  gcv_object_t _object___28or_20null_20integer_20_28member_defined_28db_append_29_Kappend_defined_28db_nodupdata_29_Knodupdata_defined_28db_nooverwrite_29_Knooverwrite__29_29;
  gcv_object_t _object___28or_20null_20integer_20_28member_defined_28db_consume_29_Kconsume_defined_28db_consume_wait_29_Kconsume_wait_defined_28db_get_both_29_Kget_both_defined_28db_set_recno_29_Kset_recno__29_29;
  gcv_object_t _object___28or_20null_20integer_20_28member_defined_28db_create_29_Kcreate_defined_28db_read_uncommitted_29_Kread_uncommitted_defined_28db_excl_29_Kexcl_defined_28db_nommap_29_Knommap_defined_28db_rdonly_29_Krdonly_defined_28db_thread_29_Kthread_defined_28db_truncate_29_Ktruncate_defined_28db_auto_commit_29_Kauto_commit__29_29;
  gcv_object_t _object___28or_20null_20integer_20_28member_defined_28db_current_29_Kcurrent_defined_28db_after_29_Kafter_defined_28db_before_29_Kbefore_defined_28db_keyfirst_29_Kkeyfirst_defined_28db_keylast_29_Kkeylast_defined_28db_nodupdata_29_Knodupdata_defined_28db_overwrite_dup_29_Koverwrite_dup__29_29;
  gcv_object_t _object___28or_20null_20integer_20_28member_defined_28db_current_29_Kcurrent_defined_28db_first_29_Kfirst_defined_28db_get_both_29_Kget_both_defined_28db_get_both_range_29_Kget_both_range_defined_28db_get_recno_29_Kget_recno_defined_28db_join_item_29_Kjoin_item_defined_28db_last_29_Klast_defined_28db_next_29_Knext_defined_28db_next_dup_29_Knext_dup_defined_28db_next_nodup_29_Knext_nodup_defined_28db_prev_29_Kprev_defined_28db_prev_nodup_29_Kprev_nodup_defined_28db_set_29_Kset_defined_28db_set_range_29_Kset_range_defined_28db_set_recno_29_Kset_recno__29_29;
  gcv_object_t _object___28or_20null_20integer_20_28member_defined_28db_current_29_Kcurrent_defined_28db_first_29_Kfirst_defined_28db_last_29_Klast_defined_28db_next_29_Knext_defined_28db_prev_29_Kprev__29_29;
  gcv_object_t _object___28or_20null_20integer_20_28member_defined_28db_encrypt_aes_29_Kaes__29_29;
  gcv_object_t _object___28or_20null_20integer_20_28member_defined_28db_joinenv_29_Kjoinenv_defined_28db_init_cdb_29_Kinit_cdb_defined_28db_init_lock_29_Kinit_lock_defined_28db_init_log_29_Kinit_log_defined_28db_init_mpool_29_Kinit_mpool_defined_28db_init_txn_29_Kinit_txn_defined_28db_recover_29_Krecover_defined_28db_recover_fatal_29_Krecover_fatal_defined_28db_use_environ_29_Kuse_environ_defined_28db_use_environ_root_29_Kuse_environ_root_defined_28db_create_29_Kcreate_defined_28db_lockdown_29_Klockdown_defined_28db_private_29_Kprivate_defined_28db_system_mem_29_Ksystem_mem_defined_28db_thread_29_Kthread__29_29;
  gcv_object_t _object___28or_20null_20integer_20_28member_defined_28db_lock_norun_29_Knorun_defined_28db_lock_default_29_Kdefault_defined_28db_lock_expire_29_Kexpire_defined_28db_lock_maxlocks_29_Kmaxlocks_defined_28db_lock_minlocks_29_Kminlocks_defined_28db_lock_minwrite_29_Kminwrite_defined_28db_lock_oldest_29_Koldest_defined_28db_lock_random_29_Krandom_defined_28db_lock_youngest_29_Kyoungest__29_29;
  gcv_object_t _object___28or_20null_20integer_20_28member_defined_28db_txn_nosync_29_Knosync_defined_28db_txn_sync_29_Ksync__29_29;
  gcv_object_t _giga_byte;
} module__bdb__object_tab;
uintC module__bdb__object_tab_size = sizeof(module__bdb__object_tab)/sizeof(gcv_object_t);

struct module__bdb__object_tab_initdata_t {
  object_initdata_t _object_bdb__bdb_error;
  object_initdata_t _object_bdb__db;
  object_initdata_t _object_bdb__dbc;
  object_initdata_t _object_bdb__dbe;
  object_initdata_t _object_bdb__dblock;
  object_initdata_t _object_bdb__kill_handle;
  object_initdata_t _object_bdb__lock_put;
  object_initdata_t _object_bdb__logc;
  object_initdata_t _object_bdb__lsn;
  object_initdata_t _object_bdb__mkdb;
  object_initdata_t _object_bdb__mkdbc;
  object_initdata_t _object_bdb__mkdbe;
  object_initdata_t _object_bdb__mkdblock;
  object_initdata_t _object_bdb__mkdbstat_btree;
  object_initdata_t _object_bdb__mkdbstat_hash;
  object_initdata_t _object_bdb__mkdbstat_queue;
  object_initdata_t _object_bdb__mkhandle;
  object_initdata_t _object_bdb__mklockstat;
  object_initdata_t _object_bdb__mklogc;
  object_initdata_t _object_bdb__mklogstat;
  object_initdata_t _object_bdb__mklsn;
  object_initdata_t _object_bdb__mktxn;
  object_initdata_t _object_bdb__mktxnactive;
  object_initdata_t _object_bdb__mktxnstat;
  object_initdata_t _object_bdb__txn;
#if defined(TXN_ABORTED)
  object_initdata_t _object_Kaborted;
#endif
  object_initdata_t _object_Kaction;
#if defined(DB_ENCRYPT_AES)
  object_initdata_t _object_Kaes;
#endif
#if defined(DB_AFTER)
  object_initdata_t _object_Kafter;
#endif
  object_initdata_t _object_Kaggressive;
#if defined(DB_ALREADY_ABORTED)
  object_initdata_t _object_Kalready_aborted;
#endif
#if defined(DB_APPEND)
  object_initdata_t _object_Kappend;
#endif
  object_initdata_t _object_Karch_abs;
  object_initdata_t _object_Karch_data;
  object_initdata_t _object_Karch_log;
  object_initdata_t _object_Karch_remove;
  object_initdata_t _object_Kauto_commit;
#if defined(DB_BEFORE)
  object_initdata_t _object_Kbefore;
#endif
  object_initdata_t _object_Kbtree;
  object_initdata_t _object_Kbt_minkey;
#if defined(DB_BUFFER_SMALL)
  object_initdata_t _object_Kbuffer_small;
#endif
  object_initdata_t _object_Kcache;
  object_initdata_t _object_Kcachesize;
  object_initdata_t _object_Kcdb_alldb;
  object_initdata_t _object_Kchksum;
  object_initdata_t _object_Kclient_timeout;
#if defined(TXN_COMMITTED)
  object_initdata_t _object_Kcommitted;
#endif
  object_initdata_t _object_Kconsume;
#if defined(DB_CONSUME_WAIT)
  object_initdata_t _object_Kconsume_wait;
#endif
  object_initdata_t _object_Kcreate;
#if defined(DB_CURRENT)
  object_initdata_t _object_Kcurrent;
#endif
  object_initdata_t _object_Kdatabase;
  object_initdata_t _object_Kdata_dir;
  object_initdata_t _object_Kdbname;
  object_initdata_t _object_Kdb_gid_size;
#if defined(DB_LOCK_DEFAULT)
  object_initdata_t _object_Kdefault;
#endif
#if defined(DB_DELETED)
  object_initdata_t _object_Kdeleted;
#endif
  object_initdata_t _object_Kdirect_db;
#if defined(DB_DONOTINDEX)
  object_initdata_t _object_Kdonotindex;
#endif
  object_initdata_t _object_Kdup;
  object_initdata_t _object_Kdupsort;
  object_initdata_t _object_Kencrypt;
  object_initdata_t _object_Kencryption;
  object_initdata_t _object_Kencrypt_aes;
  object_initdata_t _object_Kerrfile;
  object_initdata_t _object_Kerror;
  object_initdata_t _object_Kerrpfx;
  object_initdata_t _object_Kexcl;
#if defined(DB_LOCK_EXPIRE)
  object_initdata_t _object_Kexpire;
#endif
  object_initdata_t _object_Kfast_stat;
  object_initdata_t _object_Kfirst;
  object_initdata_t _object_Kflags;
  object_initdata_t _object_Kflush;
  object_initdata_t _object_Kforce;
#if defined(DB_GET_BOTH)
  object_initdata_t _object_Kget_both;
#endif
#if defined(DB_GET_BOTH_RANGE)
  object_initdata_t _object_Kget_both_range;
#endif
#if defined(DB_GET_RECNO)
  object_initdata_t _object_Kget_recno;
#endif
  object_initdata_t _object_Khash;
  object_initdata_t _object_Khome;
  object_initdata_t _object_Khomedir;
  object_initdata_t _object_Khost;
  object_initdata_t _object_Kh_ffactor;
  object_initdata_t _object_Kh_nelem;
  object_initdata_t _object_Kinit_cdb;
  object_initdata_t _object_Kinit_lock;
  object_initdata_t _object_Kinit_log;
  object_initdata_t _object_Kinit_mpool;
  object_initdata_t _object_Kinit_txn;
  object_initdata_t _object_Kinorder;
  object_initdata_t _object_Kinteger;
  object_initdata_t _object_Kintermediate_dir_mode;
  object_initdata_t _object_Kiread;
  object_initdata_t _object_Kiwr;
  object_initdata_t _object_Kiwrite;
  object_initdata_t _object_Kjoinenv;
#if defined(DB_JOIN_ITEM)
  object_initdata_t _object_Kjoin_item;
#endif
  object_initdata_t _object_Kjoin_nosort;
  object_initdata_t _object_Kkbyte;
  object_initdata_t _object_Kkeyempty;
  object_initdata_t _object_Kkeyexist;
#if defined(DB_KEYFIRST)
  object_initdata_t _object_Kkeyfirst;
#endif
#if defined(DB_KEYLAST)
  object_initdata_t _object_Kkeylast;
#endif
  object_initdata_t _object_Kkey_type;
#if defined(DB_LAST)
  object_initdata_t _object_Klast;
#endif
  object_initdata_t _object_Klg_bsize;
  object_initdata_t _object_Klg_dir;
  object_initdata_t _object_Klg_max;
  object_initdata_t _object_Klg_regionmax;
  object_initdata_t _object_Klk_conflicts;
  object_initdata_t _object_Klk_detect;
  object_initdata_t _object_Klk_max_lockers;
  object_initdata_t _object_Klk_max_locks;
  object_initdata_t _object_Klk_max_objects;
#if defined(DB_LOCKVERSION)
  object_initdata_t _object_Klock;
#endif
  object_initdata_t _object_Klockdown;
#if defined(DB_LOCK_DEADLOCK)
  object_initdata_t _object_Klock_deadlock;
#endif
#if defined(DB_LOCK_NOTEXIST)
  object_initdata_t _object_Klock_notexist;
#endif
#if defined(DB_LOCK_NOTGRANTED)
  object_initdata_t _object_Klock_notgranted;
#endif
  object_initdata_t _object_Klock_timeout;
#if defined(DB_LOGVERSION)
  object_initdata_t _object_Klog;
#endif
  object_initdata_t _object_Klog_auto_remove;
#if defined(DB_LOG_BUFFER_FULL)
  object_initdata_t _object_Klog_buffer_full;
#endif
  object_initdata_t _object_Klog_direct;
  object_initdata_t _object_Klog_dsync;
  object_initdata_t _object_Klog_in_memory;
  object_initdata_t _object_Klog_zero;
  object_initdata_t _object_Klorder;
#if defined(DB_LOCK_MAXLOCKS)
  object_initdata_t _object_Kmaxlocks;
#endif
  object_initdata_t _object_Kmin;
#if defined(DB_LOCK_MINLOCKS)
  object_initdata_t _object_Kminlocks;
#endif
#if defined(DB_LOCK_MINWRITE)
  object_initdata_t _object_Kminwrite;
#endif
  object_initdata_t _object_Kmode;
  object_initdata_t _object_Kmsgfile;
  object_initdata_t _object_Kmultiple;
  object_initdata_t _object_Kmultiple_key;
  object_initdata_t _object_Kncache;
#if defined(DB_NEEDSPLIT)
  object_initdata_t _object_Kneedsplit;
#endif
  object_initdata_t _object_Knext;
#if defined(DB_NEXT_DUP)
  object_initdata_t _object_Knext_dup;
#endif
#if defined(DB_NEXT_NODUP)
  object_initdata_t _object_Knext_nodup;
#endif
  object_initdata_t _object_Kng;
#if defined(DB_NODUPDATA)
  object_initdata_t _object_Knodupdata;
#endif
  object_initdata_t _object_Knolocking;
  object_initdata_t _object_Knommap;
  object_initdata_t _object_Knoorderchk;
#if defined(DB_NOOVERWRITE)
  object_initdata_t _object_Knooverwrite;
#endif
  object_initdata_t _object_Knopanic;
#if defined(DB_LOCK_NORUN)
  object_initdata_t _object_Knorun;
#endif
#if defined(DB_NOSERVER)
  object_initdata_t _object_Knoserver;
#endif
#if defined(DB_NOSERVER_HOME)
  object_initdata_t _object_Knoserver_home;
#endif
#if defined(DB_NOSERVER_ID)
  object_initdata_t _object_Knoserver_id;
#endif
  object_initdata_t _object_Knosync;
  object_initdata_t _object_Knotfound;
  object_initdata_t _object_Knowait;
#if defined(DB_LOCK_OLDEST)
  object_initdata_t _object_Koldest;
#endif
#if defined(DB_OLD_VERSION)
  object_initdata_t _object_Kold_version;
#endif
  object_initdata_t _object_Kopen;
  object_initdata_t _object_Koverwrite;
#if defined(DB_OVERWRITE_DUP)
  object_initdata_t _object_Koverwrite_dup;
#endif
  object_initdata_t _object_Kpagesize;
#if defined(DB_PAGE_NOTFOUND)
  object_initdata_t _object_Kpage_notfound;
#endif
  object_initdata_t _object_Kpanic_environment;
  object_initdata_t _object_Kparent;
  object_initdata_t _object_Kpassword;
  object_initdata_t _object_Kposition;
#if defined(TXN_PREPARED)
  object_initdata_t _object_Kprepared;
#endif
#if defined(DB_PREV)
  object_initdata_t _object_Kprev;
#endif
#if defined(DB_PREV_NODUP)
  object_initdata_t _object_Kprev_nodup;
#endif
  object_initdata_t _object_Kprintable;
  object_initdata_t _object_Kprivate;
#if defined(DB_QAMVERSION)
  object_initdata_t _object_Kqam;
#endif
  object_initdata_t _object_Kqueue;
  object_initdata_t _object_Kq_extentsize;
#if defined(DB_LOCK_RANDOM)
  object_initdata_t _object_Krandom;
#endif
  object_initdata_t _object_Kraw;
  object_initdata_t _object_Krdonly;
  object_initdata_t _object_Kread;
  object_initdata_t _object_Kread_committed;
  object_initdata_t _object_Kread_uncommitted;
  object_initdata_t _object_Krecno;
  object_initdata_t _object_Krecnum;
  object_initdata_t _object_Krecover;
  object_initdata_t _object_Krecover_fatal;
  object_initdata_t _object_Kregion_init;
  object_initdata_t _object_Krenumber;
#if defined(DB_REP_DUPMASTER)
  object_initdata_t _object_Krep_dupmaster;
#endif
#if defined(DB_REP_EGENCHG)
  object_initdata_t _object_Krep_egenchg;
#endif
#if defined(DB_REP_HANDLE_DEAD)
  object_initdata_t _object_Krep_handle_dead;
#endif
#if defined(DB_REP_HOLDELECTION)
  object_initdata_t _object_Krep_holdelection;
#endif
#if defined(DB_REP_ISPERM)
  object_initdata_t _object_Krep_isperm;
#endif
#if defined(DB_REP_LOGREADY)
  object_initdata_t _object_Krep_logready;
#endif
#if defined(DB_REP_NEWMASTER)
  object_initdata_t _object_Krep_newmaster;
#endif
#if defined(DB_REP_NEWSITE)
  object_initdata_t _object_Krep_newsite;
#endif
#if defined(DB_REP_NOTPERM)
  object_initdata_t _object_Krep_notperm;
#endif
#if defined(DB_REP_PAGEDONE)
  object_initdata_t _object_Krep_pagedone;
#endif
#if defined(DB_REP_STARTUPDONE)
  object_initdata_t _object_Krep_startupdone;
#endif
#if defined(DB_REP_UNAVAIL)
  object_initdata_t _object_Krep_unavail;
#endif
  object_initdata_t _object_Krevsplitoff;
  object_initdata_t _object_Kre_delim;
  object_initdata_t _object_Kre_len;
  object_initdata_t _object_Kre_pad;
  object_initdata_t _object_Kre_source;
  object_initdata_t _object_Krmw;
#if defined(TXN_RUNNING)
  object_initdata_t _object_Krunning;
#endif
#if defined(DB_RUNRECOVERY)
  object_initdata_t _object_Krunrecovery;
#endif
  object_initdata_t _object_Ksalvage;
#if defined(DB_SECONDARY_BAD)
  object_initdata_t _object_Ksecondary_bad;
#endif
#if defined(DB_SEQUENCE_VERSION)
  object_initdata_t _object_Ksequence;
#endif
  object_initdata_t _object_Kserver_timeout;
#if defined(DB_SET)
  object_initdata_t _object_Kset;
#endif
#if defined(DB_SET_RANGE)
  object_initdata_t _object_Kset_range;
#endif
#if defined(DB_SET_RECNO)
  object_initdata_t _object_Kset_recno;
#endif
  object_initdata_t _object_Kshm_key;
  object_initdata_t _object_Ksnapshot;
  object_initdata_t _object_Kstat_clear;
  object_initdata_t _object_Kstring;
#if defined(DB_SURPRISE_KID)
  object_initdata_t _object_Ksurprise_kid;
#endif
#if defined(DB_SWAPBYTES)
  object_initdata_t _object_Kswapbytes;
#endif
  object_initdata_t _object_Ksync;
  object_initdata_t _object_Ksystem_mem;
  object_initdata_t _object_Ktas_spins;
  object_initdata_t _object_Kthread;
  object_initdata_t _object_Ktimeout;
  object_initdata_t _object_Ktimestamp;
  object_initdata_t _object_Ktmp_dir;
  object_initdata_t _object_Ktransaction;
  object_initdata_t _object_Ktransactional;
  object_initdata_t _object_Ktruncate;
#if defined(DB_TXNVERSION)
  object_initdata_t _object_Ktxn;
#endif
#if defined(DB_TXN_CKP)
  object_initdata_t _object_Ktxn_ckp;
#endif
  object_initdata_t _object_Ktxn_nosync;
  object_initdata_t _object_Ktxn_not_durable;
  object_initdata_t _object_Ktxn_timeout;
  object_initdata_t _object_Ktxn_write_nosync;
  object_initdata_t _object_Ktx_max;
  object_initdata_t _object_Ktx_timestamp;
  object_initdata_t _object_Ktype;
  object_initdata_t _object_Kunknown;
  object_initdata_t _object_Kuse_environ;
  object_initdata_t _object_Kuse_environ_root;
  object_initdata_t _object_Kverbose;
  object_initdata_t _object_Kverb_chkpoint;
  object_initdata_t _object_Kverb_deadlock;
  object_initdata_t _object_Kverb_recovery;
  object_initdata_t _object_Kverb_replication;
  object_initdata_t _object_Kverb_waitsfor;
#if defined(DB_VERIFY_BAD)
  object_initdata_t _object_Kverify_bad;
#endif
#if defined(DB_VERIFY_FATAL)
  object_initdata_t _object_Kverify_fatal;
#endif
#if defined(DB_VERSION_MISMATCH)
  object_initdata_t _object_Kversion_mismatch;
#endif
  object_initdata_t _object_Kwait;
  object_initdata_t _object_Kwrite;
  object_initdata_t _object_Kwritecursor;
  object_initdata_t _object_Kwwrite;
  object_initdata_t _object_Kyieldcpu;
#if defined(DB_LOCK_YOUNGEST)
  object_initdata_t _object_Kyoungest;
#endif
  object_initdata_t _object__22_7Es_20_28_7Es_29__20_7Es_22;
  object_initdata_t _object__22_7Es_20_28_7Es_29__20_7Es__20_7Es_22;
  object_initdata_t _object__22_7Es__20bad_20logical_20record_20number_20size__20_7Es_20should_20be_20_7Es_22;
  object_initdata_t _object__23_2E_28byte_2030_200_29;
  object_initdata_t _object__28array_20_28unsigned_byte_208_29_20_28_2A_20_2A_29_29;
  object_initdata_t _object__28or_20integer_20_28member_20_ng_20_read_20_write_20_wait_20_iwrite_20_iread_20_iwr_20_read_uncommitted_20_wwrite_29_29;
  object_initdata_t _object__28or_20null_20integer_20_28member_20_raw_20_string_20_integer_29_29;
  object_initdata_t _object__28or_20null_20integer_20_28member_20_unknown_20_btree_20_hash_20_queue_20_recno_29_29;
  object_initdata_t _object__28or_20string_20bdb__dbe_29;
  object_initdata_t _object__28or_20string_20_28integer_200_29_20_28vector_20_28unsigned_byte_29_29_29;
  object_initdata_t _object___28or_20integer_20_28member_defined_28db_buffer_small_29_Kbuffer_small_defined_28db_donotindex_29_Kdonotindex_defined_28db_keyempty_29_Kkeyempty_defined_28db_keyexist_29_Kkeyexist_defined_28db_lock_deadlock_29_Klock_deadlock_defined_28db_lock_notgranted_29_Klock_notgranted_defined_28db_log_buffer_full_29_Klog_buffer_full_defined_28db_noserver_29_Knoserver_defined_28db_noserver_home_29_Knoserver_home_defined_28db_noserver_id_29_Knoserver_id_defined_28db_notfound_29_Knotfound_defined_28db_old_version_29_Kold_version_defined_28db_page_notfound_29_Kpage_notfound_defined_28db_rep_dupmaster_29_Krep_dupmaster_defined_28db_rep_handle_dead_29_Krep_handle_dead_defined_28db_rep_holdelection_29_Krep_holdelection_defined_28db_rep_isperm_29_Krep_isperm_defined_28db_rep_newmaster_29_Krep_newmaster_defined_28db_rep_newsite_29_Krep_newsite_defined_28db_rep_notperm_29_Krep_notperm_defined_28db_rep_startupdone_29_Krep_startupdone_defined_28db_rep_unavail_29_Krep_unavail_defined_28db_runrecovery_29_Krunrecovery_defined_28db_secondary_bad_29_Ksecondary_bad_defined_28db_verify_bad_29_Kverify_bad_defined_28db_version_mismatch_29_Kversion_mismatch_defined_28db_already_aborted_29_Kalready_aborted_defined_28db_deleted_29_Kdeleted_defined_28db_lock_notexist_29_Klock_notexist_defined_28db_needsplit_29_Kneedsplit_defined_28db_rep_egenchg_29_Krep_egenchg_defined_28db_rep_logready_29_Krep_logready_defined_28db_rep_pagedone_29_Krep_pagedone_defined_28db_surprise_kid_29_Ksurprise_kid_defined_28db_swapbytes_29_Kswapbytes_defined_28db_timeout_29_Ktimeout_defined_28db_txn_ckp_29_Ktxn_ckp_defined_28db_verify_fatal_29_Kverify_fatal__29_29;
  object_initdata_t _object___28or_20integer_20_28member_defined_28db_set_lock_timeout_29_Klock_timeout_defined_28db_set_txn_timeout_29_Ktxn_timeout__29_29;
  object_initdata_t _object___28or_20integer_20_28member_defined_28txn_aborted_29_Kaborted_defined_28txn_committed_29_Kcommitted_defined_28txn_prepared_29_Kprepared_defined_28txn_running_29_Krunning__29_29;
  object_initdata_t _object___28or_20null_20integer_20_28member_defined_28db_append_29_Kappend_defined_28db_nodupdata_29_Knodupdata_defined_28db_nooverwrite_29_Knooverwrite__29_29;
  object_initdata_t _object___28or_20null_20integer_20_28member_defined_28db_consume_29_Kconsume_defined_28db_consume_wait_29_Kconsume_wait_defined_28db_get_both_29_Kget_both_defined_28db_set_recno_29_Kset_recno__29_29;
  object_initdata_t _object___28or_20null_20integer_20_28member_defined_28db_create_29_Kcreate_defined_28db_read_uncommitted_29_Kread_uncommitted_defined_28db_excl_29_Kexcl_defined_28db_nommap_29_Knommap_defined_28db_rdonly_29_Krdonly_defined_28db_thread_29_Kthread_defined_28db_truncate_29_Ktruncate_defined_28db_auto_commit_29_Kauto_commit__29_29;
  object_initdata_t _object___28or_20null_20integer_20_28member_defined_28db_current_29_Kcurrent_defined_28db_after_29_Kafter_defined_28db_before_29_Kbefore_defined_28db_keyfirst_29_Kkeyfirst_defined_28db_keylast_29_Kkeylast_defined_28db_nodupdata_29_Knodupdata_defined_28db_overwrite_dup_29_Koverwrite_dup__29_29;
  object_initdata_t _object___28or_20null_20integer_20_28member_defined_28db_current_29_Kcurrent_defined_28db_first_29_Kfirst_defined_28db_get_both_29_Kget_both_defined_28db_get_both_range_29_Kget_both_range_defined_28db_get_recno_29_Kget_recno_defined_28db_join_item_29_Kjoin_item_defined_28db_last_29_Klast_defined_28db_next_29_Knext_defined_28db_next_dup_29_Knext_dup_defined_28db_next_nodup_29_Knext_nodup_defined_28db_prev_29_Kprev_defined_28db_prev_nodup_29_Kprev_nodup_defined_28db_set_29_Kset_defined_28db_set_range_29_Kset_range_defined_28db_set_recno_29_Kset_recno__29_29;
  object_initdata_t _object___28or_20null_20integer_20_28member_defined_28db_current_29_Kcurrent_defined_28db_first_29_Kfirst_defined_28db_last_29_Klast_defined_28db_next_29_Knext_defined_28db_prev_29_Kprev__29_29;
  object_initdata_t _object___28or_20null_20integer_20_28member_defined_28db_encrypt_aes_29_Kaes__29_29;
  object_initdata_t _object___28or_20null_20integer_20_28member_defined_28db_joinenv_29_Kjoinenv_defined_28db_init_cdb_29_Kinit_cdb_defined_28db_init_lock_29_Kinit_lock_defined_28db_init_log_29_Kinit_log_defined_28db_init_mpool_29_Kinit_mpool_defined_28db_init_txn_29_Kinit_txn_defined_28db_recover_29_Krecover_defined_28db_recover_fatal_29_Krecover_fatal_defined_28db_use_environ_29_Kuse_environ_defined_28db_use_environ_root_29_Kuse_environ_root_defined_28db_create_29_Kcreate_defined_28db_lockdown_29_Klockdown_defined_28db_private_29_Kprivate_defined_28db_system_mem_29_Ksystem_mem_defined_28db_thread_29_Kthread__29_29;
  object_initdata_t _object___28or_20null_20integer_20_28member_defined_28db_lock_norun_29_Knorun_defined_28db_lock_default_29_Kdefault_defined_28db_lock_expire_29_Kexpire_defined_28db_lock_maxlocks_29_Kmaxlocks_defined_28db_lock_minlocks_29_Kminlocks_defined_28db_lock_minwrite_29_Kminwrite_defined_28db_lock_oldest_29_Koldest_defined_28db_lock_random_29_Krandom_defined_28db_lock_youngest_29_Kyoungest__29_29;
  object_initdata_t _object___28or_20null_20integer_20_28member_defined_28db_txn_nosync_29_Knosync_defined_28db_txn_sync_29_Ksync__29_29;
  object_initdata_t _giga_byte;
  int _dummy_to_avoid_trailing_comma_in_initializer;
} module__bdb__object_tab_initdata = {
  { "BDB::BDB-ERROR" },
  { "BDB::DB" },
  { "BDB::DBC" },
  { "BDB::DBE" },
  { "BDB::DBLOCK" },
  { "BDB::KILL-HANDLE" },
  { "BDB::LOCK-PUT" },
  { "BDB::LOGC" },
  { "BDB::LSN" },
  { "BDB::MKDB" },
  { "BDB::MKDBC" },
  { "BDB::MKDBE" },
  { "BDB::MKDBLOCK" },
  { "BDB::MKDBSTAT-BTREE" },
  { "BDB::MKDBSTAT-HASH" },
  { "BDB::MKDBSTAT-QUEUE" },
  { "BDB::MKHANDLE" },
  { "BDB::MKLOCKSTAT" },
  { "BDB::MKLOGC" },
  { "BDB::MKLOGSTAT" },
  { "BDB::MKLSN" },
  { "BDB::MKTXN" },
  { "BDB::MKTXNACTIVE" },
  { "BDB::MKTXNSTAT" },
  { "BDB::TXN" },
#if defined(TXN_ABORTED)
  { ":ABORTED" },
#endif
  { ":ACTION" },
#if defined(DB_ENCRYPT_AES)
  { ":AES" },
#endif
#if defined(DB_AFTER)
  { ":AFTER" },
#endif
  { ":AGGRESSIVE" },
#if defined(DB_ALREADY_ABORTED)
  { ":ALREADY-ABORTED" },
#endif
#if defined(DB_APPEND)
  { ":APPEND" },
#endif
  { ":ARCH-ABS" },
  { ":ARCH-DATA" },
  { ":ARCH-LOG" },
  { ":ARCH-REMOVE" },
  { ":AUTO-COMMIT" },
#if defined(DB_BEFORE)
  { ":BEFORE" },
#endif
  { ":BTREE" },
  { ":BT-MINKEY" },
#if defined(DB_BUFFER_SMALL)
  { ":BUFFER-SMALL" },
#endif
  { ":CACHE" },
  { ":CACHESIZE" },
  { ":CDB-ALLDB" },
  { ":CHKSUM" },
  { ":CLIENT-TIMEOUT" },
#if defined(TXN_COMMITTED)
  { ":COMMITTED" },
#endif
  { ":CONSUME" },
#if defined(DB_CONSUME_WAIT)
  { ":CONSUME-WAIT" },
#endif
  { ":CREATE" },
#if defined(DB_CURRENT)
  { ":CURRENT" },
#endif
  { ":DATABASE" },
  { ":DATA-DIR" },
  { ":DBNAME" },
  { ":DB-GID-SIZE" },
#if defined(DB_LOCK_DEFAULT)
  { ":DEFAULT" },
#endif
#if defined(DB_DELETED)
  { ":DELETED" },
#endif
  { ":DIRECT-DB" },
#if defined(DB_DONOTINDEX)
  { ":DONOTINDEX" },
#endif
  { ":DUP" },
  { ":DUPSORT" },
  { ":ENCRYPT" },
  { ":ENCRYPTION" },
  { ":ENCRYPT-AES" },
  { ":ERRFILE" },
  { ":ERROR" },
  { ":ERRPFX" },
  { ":EXCL" },
#if defined(DB_LOCK_EXPIRE)
  { ":EXPIRE" },
#endif
  { ":FAST-STAT" },
  { ":FIRST" },
  { ":FLAGS" },
  { ":FLUSH" },
  { ":FORCE" },
#if defined(DB_GET_BOTH)
  { ":GET-BOTH" },
#endif
#if defined(DB_GET_BOTH_RANGE)
  { ":GET-BOTH-RANGE" },
#endif
#if defined(DB_GET_RECNO)
  { ":GET-RECNO" },
#endif
  { ":HASH" },
  { ":HOME" },
  { ":HOMEDIR" },
  { ":HOST" },
  { ":H-FFACTOR" },
  { ":H-NELEM" },
  { ":INIT-CDB" },
  { ":INIT-LOCK" },
  { ":INIT-LOG" },
  { ":INIT-MPOOL" },
  { ":INIT-TXN" },
  { ":INORDER" },
  { ":INTEGER" },
  { ":INTERMEDIATE-DIR-MODE" },
  { ":IREAD" },
  { ":IWR" },
  { ":IWRITE" },
  { ":JOINENV" },
#if defined(DB_JOIN_ITEM)
  { ":JOIN-ITEM" },
#endif
  { ":JOIN-NOSORT" },
  { ":KBYTE" },
  { ":KEYEMPTY" },
  { ":KEYEXIST" },
#if defined(DB_KEYFIRST)
  { ":KEYFIRST" },
#endif
#if defined(DB_KEYLAST)
  { ":KEYLAST" },
#endif
  { ":KEY-TYPE" },
#if defined(DB_LAST)
  { ":LAST" },
#endif
  { ":LG-BSIZE" },
  { ":LG-DIR" },
  { ":LG-MAX" },
  { ":LG-REGIONMAX" },
  { ":LK-CONFLICTS" },
  { ":LK-DETECT" },
  { ":LK-MAX-LOCKERS" },
  { ":LK-MAX-LOCKS" },
  { ":LK-MAX-OBJECTS" },
#if defined(DB_LOCKVERSION)
  { ":LOCK" },
#endif
  { ":LOCKDOWN" },
#if defined(DB_LOCK_DEADLOCK)
  { ":LOCK-DEADLOCK" },
#endif
#if defined(DB_LOCK_NOTEXIST)
  { ":LOCK-NOTEXIST" },
#endif
#if defined(DB_LOCK_NOTGRANTED)
  { ":LOCK-NOTGRANTED" },
#endif
  { ":LOCK-TIMEOUT" },
#if defined(DB_LOGVERSION)
  { ":LOG" },
#endif
  { ":LOG-AUTO-REMOVE" },
#if defined(DB_LOG_BUFFER_FULL)
  { ":LOG-BUFFER-FULL" },
#endif
  { ":LOG-DIRECT" },
  { ":LOG-DSYNC" },
  { ":LOG-IN-MEMORY" },
  { ":LOG-ZERO" },
  { ":LORDER" },
#if defined(DB_LOCK_MAXLOCKS)
  { ":MAXLOCKS" },
#endif
  { ":MIN" },
#if defined(DB_LOCK_MINLOCKS)
  { ":MINLOCKS" },
#endif
#if defined(DB_LOCK_MINWRITE)
  { ":MINWRITE" },
#endif
  { ":MODE" },
  { ":MSGFILE" },
  { ":MULTIPLE" },
  { ":MULTIPLE-KEY" },
  { ":NCACHE" },
#if defined(DB_NEEDSPLIT)
  { ":NEEDSPLIT" },
#endif
  { ":NEXT" },
#if defined(DB_NEXT_DUP)
  { ":NEXT-DUP" },
#endif
#if defined(DB_NEXT_NODUP)
  { ":NEXT-NODUP" },
#endif
  { ":NG" },
#if defined(DB_NODUPDATA)
  { ":NODUPDATA" },
#endif
  { ":NOLOCKING" },
  { ":NOMMAP" },
  { ":NOORDERCHK" },
#if defined(DB_NOOVERWRITE)
  { ":NOOVERWRITE" },
#endif
  { ":NOPANIC" },
#if defined(DB_LOCK_NORUN)
  { ":NORUN" },
#endif
#if defined(DB_NOSERVER)
  { ":NOSERVER" },
#endif
#if defined(DB_NOSERVER_HOME)
  { ":NOSERVER-HOME" },
#endif
#if defined(DB_NOSERVER_ID)
  { ":NOSERVER-ID" },
#endif
  { ":NOSYNC" },
  { ":NOTFOUND" },
  { ":NOWAIT" },
#if defined(DB_LOCK_OLDEST)
  { ":OLDEST" },
#endif
#if defined(DB_OLD_VERSION)
  { ":OLD-VERSION" },
#endif
  { ":OPEN" },
  { ":OVERWRITE" },
#if defined(DB_OVERWRITE_DUP)
  { ":OVERWRITE-DUP" },
#endif
  { ":PAGESIZE" },
#if defined(DB_PAGE_NOTFOUND)
  { ":PAGE-NOTFOUND" },
#endif
  { ":PANIC-ENVIRONMENT" },
  { ":PARENT" },
  { ":PASSWORD" },
  { ":POSITION" },
#if defined(TXN_PREPARED)
  { ":PREPARED" },
#endif
#if defined(DB_PREV)
  { ":PREV" },
#endif
#if defined(DB_PREV_NODUP)
  { ":PREV-NODUP" },
#endif
  { ":PRINTABLE" },
  { ":PRIVATE" },
#if defined(DB_QAMVERSION)
  { ":QAM" },
#endif
  { ":QUEUE" },
  { ":Q-EXTENTSIZE" },
#if defined(DB_LOCK_RANDOM)
  { ":RANDOM" },
#endif
  { ":RAW" },
  { ":RDONLY" },
  { ":READ" },
  { ":READ-COMMITTED" },
  { ":READ-UNCOMMITTED" },
  { ":RECNO" },
  { ":RECNUM" },
  { ":RECOVER" },
  { ":RECOVER-FATAL" },
  { ":REGION-INIT" },
  { ":RENUMBER" },
#if defined(DB_REP_DUPMASTER)
  { ":REP-DUPMASTER" },
#endif
#if defined(DB_REP_EGENCHG)
  { ":REP-EGENCHG" },
#endif
#if defined(DB_REP_HANDLE_DEAD)
  { ":REP-HANDLE-DEAD" },
#endif
#if defined(DB_REP_HOLDELECTION)
  { ":REP-HOLDELECTION" },
#endif
#if defined(DB_REP_ISPERM)
  { ":REP-ISPERM" },
#endif
#if defined(DB_REP_LOGREADY)
  { ":REP-LOGREADY" },
#endif
#if defined(DB_REP_NEWMASTER)
  { ":REP-NEWMASTER" },
#endif
#if defined(DB_REP_NEWSITE)
  { ":REP-NEWSITE" },
#endif
#if defined(DB_REP_NOTPERM)
  { ":REP-NOTPERM" },
#endif
#if defined(DB_REP_PAGEDONE)
  { ":REP-PAGEDONE" },
#endif
#if defined(DB_REP_STARTUPDONE)
  { ":REP-STARTUPDONE" },
#endif
#if defined(DB_REP_UNAVAIL)
  { ":REP-UNAVAIL" },
#endif
  { ":REVSPLITOFF" },
  { ":RE-DELIM" },
  { ":RE-LEN" },
  { ":RE-PAD" },
  { ":RE-SOURCE" },
  { ":RMW" },
#if defined(TXN_RUNNING)
  { ":RUNNING" },
#endif
#if defined(DB_RUNRECOVERY)
  { ":RUNRECOVERY" },
#endif
  { ":SALVAGE" },
#if defined(DB_SECONDARY_BAD)
  { ":SECONDARY-BAD" },
#endif
#if defined(DB_SEQUENCE_VERSION)
  { ":SEQUENCE" },
#endif
  { ":SERVER-TIMEOUT" },
#if defined(DB_SET)
  { ":SET" },
#endif
#if defined(DB_SET_RANGE)
  { ":SET-RANGE" },
#endif
#if defined(DB_SET_RECNO)
  { ":SET-RECNO" },
#endif
  { ":SHM-KEY" },
  { ":SNAPSHOT" },
  { ":STAT-CLEAR" },
  { ":STRING" },
#if defined(DB_SURPRISE_KID)
  { ":SURPRISE-KID" },
#endif
#if defined(DB_SWAPBYTES)
  { ":SWAPBYTES" },
#endif
  { ":SYNC" },
  { ":SYSTEM-MEM" },
  { ":TAS-SPINS" },
  { ":THREAD" },
  { ":TIMEOUT" },
  { ":TIMESTAMP" },
  { ":TMP-DIR" },
  { ":TRANSACTION" },
  { ":TRANSACTIONAL" },
  { ":TRUNCATE" },
#if defined(DB_TXNVERSION)
  { ":TXN" },
#endif
#if defined(DB_TXN_CKP)
  { ":TXN-CKP" },
#endif
  { ":TXN-NOSYNC" },
  { ":TXN-NOT-DURABLE" },
  { ":TXN-TIMEOUT" },
  { ":TXN-WRITE-NOSYNC" },
  { ":TX-MAX" },
  { ":TX-TIMESTAMP" },
  { ":TYPE" },
  { ":UNKNOWN" },
  { ":USE-ENVIRON" },
  { ":USE-ENVIRON-ROOT" },
  { ":VERBOSE" },
  { ":VERB-CHKPOINT" },
  { ":VERB-DEADLOCK" },
  { ":VERB-RECOVERY" },
  { ":VERB-REPLICATION" },
  { ":VERB-WAITSFOR" },
#if defined(DB_VERIFY_BAD)
  { ":VERIFY-BAD" },
#endif
#if defined(DB_VERIFY_FATAL)
  { ":VERIFY-FATAL" },
#endif
#if defined(DB_VERSION_MISMATCH)
  { ":VERSION-MISMATCH" },
#endif
  { ":WAIT" },
  { ":WRITE" },
  { ":WRITECURSOR" },
  { ":WWRITE" },
  { ":YIELDCPU" },
#if defined(DB_LOCK_YOUNGEST)
  { ":YOUNGEST" },
#endif
  { "\"~S (~S): ~S\"" },
  { "\"~S (~S): ~S: ~S\"" },
  { "\"~S: bad logical record number size: ~S should be ~S\"" },
  { "#.(BYTE 30 0)" },
  { "(ARRAY (UNSIGNED-BYTE 8) (* *))" },
  { "(OR INTEGER (MEMBER :NG :READ :WRITE :WAIT :IWRITE :IREAD :IWR :READ-UNCOMMITTED :WWRITE))" },
  { "(OR NULL INTEGER (MEMBER :RAW :STRING :INTEGER))" },
  { "(OR NULL INTEGER (MEMBER :UNKNOWN :BTREE :HASH :QUEUE :RECNO))" },
  { "(OR STRING BDB::DBE)" },
  { "(OR STRING (INTEGER 0) (VECTOR (UNSIGNED-BYTE)))" },
  {
    " " "(OR INTEGER (MEMBER"
#  if defined(DB_BUFFER_SMALL)
    " " ":BUFFER-SMALL"
#  endif
#  if defined(DB_DONOTINDEX)
    " " ":DONOTINDEX"
#  endif
#  if defined(DB_KEYEMPTY)
    " " ":KEYEMPTY"
#  endif
#  if defined(DB_KEYEXIST)
    " " ":KEYEXIST"
#  endif
#  if defined(DB_LOCK_DEADLOCK)
    " " ":LOCK-DEADLOCK"
#  endif
#  if defined(DB_LOCK_NOTGRANTED)
    " " ":LOCK-NOTGRANTED"
#  endif
#  if defined(DB_LOG_BUFFER_FULL)
    " " ":LOG-BUFFER-FULL"
#  endif
#  if defined(DB_NOSERVER)
    " " ":NOSERVER"
#  endif
#  if defined(DB_NOSERVER_HOME)
    " " ":NOSERVER-HOME"
#  endif
#  if defined(DB_NOSERVER_ID)
    " " ":NOSERVER-ID"
#  endif
#  if defined(DB_NOTFOUND)
    " " ":NOTFOUND"
#  endif
#  if defined(DB_OLD_VERSION)
    " " ":OLD-VERSION"
#  endif
#  if defined(DB_PAGE_NOTFOUND)
    " " ":PAGE-NOTFOUND"
#  endif
#  if defined(DB_REP_DUPMASTER)
    " " ":REP-DUPMASTER"
#  endif
#  if defined(DB_REP_HANDLE_DEAD)
    " " ":REP-HANDLE-DEAD"
#  endif
#  if defined(DB_REP_HOLDELECTION)
    " " ":REP-HOLDELECTION"
#  endif
#  if defined(DB_REP_ISPERM)
    " " ":REP-ISPERM"
#  endif
#  if defined(DB_REP_NEWMASTER)
    " " ":REP-NEWMASTER"
#  endif
#  if defined(DB_REP_NEWSITE)
    " " ":REP-NEWSITE"
#  endif
#  if defined(DB_REP_NOTPERM)
    " " ":REP-NOTPERM"
#  endif
#  if defined(DB_REP_STARTUPDONE)
    " " ":REP-STARTUPDONE"
#  endif
#  if defined(DB_REP_UNAVAIL)
    " " ":REP-UNAVAIL"
#  endif
#  if defined(DB_RUNRECOVERY)
    " " ":RUNRECOVERY"
#  endif
#  if defined(DB_SECONDARY_BAD)
    " " ":SECONDARY-BAD"
#  endif
#  if defined(DB_VERIFY_BAD)
    " " ":VERIFY-BAD"
#  endif
#  if defined(DB_VERSION_MISMATCH)
    " " ":VERSION-MISMATCH"
#  endif
#  if defined(DB_ALREADY_ABORTED)
    " " ":ALREADY-ABORTED"
#  endif
#  if defined(DB_DELETED)
    " " ":DELETED"
#  endif
#  if defined(DB_LOCK_NOTEXIST)
    " " ":LOCK-NOTEXIST"
#  endif
#  if defined(DB_NEEDSPLIT)
    " " ":NEEDSPLIT"
#  endif
#  if defined(DB_REP_EGENCHG)
    " " ":REP-EGENCHG"
#  endif
#  if defined(DB_REP_LOGREADY)
    " " ":REP-LOGREADY"
#  endif
#  if defined(DB_REP_PAGEDONE)
    " " ":REP-PAGEDONE"
#  endif
#  if defined(DB_SURPRISE_KID)
    " " ":SURPRISE-KID"
#  endif
#  if defined(DB_SWAPBYTES)
    " " ":SWAPBYTES"
#  endif
#  if defined(DB_TIMEOUT)
    " " ":TIMEOUT"
#  endif
#  if defined(DB_TXN_CKP)
    " " ":TXN-CKP"
#  endif
#  if defined(DB_VERIFY_FATAL)
    " " ":VERIFY-FATAL"
#  endif
    " " "))"
  },
  {
    " " "(OR INTEGER (MEMBER"
#  if defined(DB_SET_LOCK_TIMEOUT)
    " " ":LOCK-TIMEOUT"
#  endif
#  if defined(DB_SET_TXN_TIMEOUT)
    " " ":TXN-TIMEOUT"
#  endif
    " " "))"
  },
  {
    " " "(OR INTEGER (MEMBER"
#  if defined(TXN_ABORTED)
    " " ":ABORTED"
#  endif
#  if defined(TXN_COMMITTED)
    " " ":COMMITTED"
#  endif
#  if defined(TXN_PREPARED)
    " " ":PREPARED"
#  endif
#  if defined(TXN_RUNNING)
    " " ":RUNNING"
#  endif
    " " "))"
  },
  {
    " " "(OR NULL INTEGER (MEMBER"
#  if defined(DB_APPEND)
    " " ":APPEND"
#  endif
#  if defined(DB_NODUPDATA)
    " " ":NODUPDATA"
#  endif
#  if defined(DB_NOOVERWRITE)
    " " ":NOOVERWRITE"
#  endif
    " " "))"
  },
  {
    " " "(OR NULL INTEGER (MEMBER"
#  if defined(DB_CONSUME)
    " " ":CONSUME"
#  endif
#  if defined(DB_CONSUME_WAIT)
    " " ":CONSUME-WAIT"
#  endif
#  if defined(DB_GET_BOTH)
    " " ":GET-BOTH"
#  endif
#  if defined(DB_SET_RECNO)
    " " ":SET-RECNO"
#  endif
    " " "))"
  },
  {
    " " "(OR NULL INTEGER (MEMBER"
#  if defined(DB_CREATE)
    " " ":CREATE"
#  endif
#  if defined(DB_READ_UNCOMMITTED)
    " " ":READ-UNCOMMITTED"
#  endif
#  if defined(DB_EXCL)
    " " ":EXCL"
#  endif
#  if defined(DB_NOMMAP)
    " " ":NOMMAP"
#  endif
#  if defined(DB_RDONLY)
    " " ":RDONLY"
#  endif
#  if defined(DB_THREAD)
    " " ":THREAD"
#  endif
#  if defined(DB_TRUNCATE)
    " " ":TRUNCATE"
#  endif
#  if defined(DB_AUTO_COMMIT)
    " " ":AUTO-COMMIT"
#  endif
    " " "))"
  },
  {
    " " "(OR NULL INTEGER (MEMBER"
#  if defined(DB_CURRENT)
    " " ":CURRENT"
#  endif
#  if defined(DB_AFTER)
    " " ":AFTER"
#  endif
#  if defined(DB_BEFORE)
    " " ":BEFORE"
#  endif
#  if defined(DB_KEYFIRST)
    " " ":KEYFIRST"
#  endif
#  if defined(DB_KEYLAST)
    " " ":KEYLAST"
#  endif
#  if defined(DB_NODUPDATA)
    " " ":NODUPDATA"
#  endif
#  if defined(DB_OVERWRITE_DUP)
    " " ":OVERWRITE-DUP"
#  endif
    " " "))"
  },
  {
    " " "(OR NULL INTEGER (MEMBER"
#  if defined(DB_CURRENT)
    " " ":CURRENT"
#  endif
#  if defined(DB_FIRST)
    " " ":FIRST"
#  endif
#  if defined(DB_GET_BOTH)
    " " ":GET-BOTH"
#  endif
#  if defined(DB_GET_BOTH_RANGE)
    " " ":GET-BOTH-RANGE"
#  endif
#  if defined(DB_GET_RECNO)
    " " ":GET-RECNO"
#  endif
#  if defined(DB_JOIN_ITEM)
    " " ":JOIN-ITEM"
#  endif
#  if defined(DB_LAST)
    " " ":LAST"
#  endif
#  if defined(DB_NEXT)
    " " ":NEXT"
#  endif
#  if defined(DB_NEXT_DUP)
    " " ":NEXT-DUP"
#  endif
#  if defined(DB_NEXT_NODUP)
    " " ":NEXT-NODUP"
#  endif
#  if defined(DB_PREV)
    " " ":PREV"
#  endif
#  if defined(DB_PREV_NODUP)
    " " ":PREV-NODUP"
#  endif
#  if defined(DB_SET)
    " " ":SET"
#  endif
#  if defined(DB_SET_RANGE)
    " " ":SET-RANGE"
#  endif
#  if defined(DB_SET_RECNO)
    " " ":SET-RECNO"
#  endif
    " " "))"
  },
  {
    " " "(OR NULL INTEGER (MEMBER"
#  if defined(DB_CURRENT)
    " " ":CURRENT"
#  endif
#  if defined(DB_FIRST)
    " " ":FIRST"
#  endif
#  if defined(DB_LAST)
    " " ":LAST"
#  endif
#  if defined(DB_NEXT)
    " " ":NEXT"
#  endif
#  if defined(DB_PREV)
    " " ":PREV"
#  endif
    " " "))"
  },
  {
    " " "(OR NULL INTEGER (MEMBER"
#  if defined(DB_ENCRYPT_AES)
    " " ":AES"
#  endif
    " " "))"
  },
  {
    " " "(OR NULL INTEGER (MEMBER"
#  if defined(DB_JOINENV)
    " " ":JOINENV"
#  endif
#  if defined(DB_INIT_CDB)
    " " ":INIT-CDB"
#  endif
#  if defined(DB_INIT_LOCK)
    " " ":INIT-LOCK"
#  endif
#  if defined(DB_INIT_LOG)
    " " ":INIT-LOG"
#  endif
#  if defined(DB_INIT_MPOOL)
    " " ":INIT-MPOOL"
#  endif
#  if defined(DB_INIT_TXN)
    " " ":INIT-TXN"
#  endif
#  if defined(DB_RECOVER)
    " " ":RECOVER"
#  endif
#  if defined(DB_RECOVER_FATAL)
    " " ":RECOVER-FATAL"
#  endif
#  if defined(DB_USE_ENVIRON)
    " " ":USE-ENVIRON"
#  endif
#  if defined(DB_USE_ENVIRON_ROOT)
    " " ":USE-ENVIRON-ROOT"
#  endif
#  if defined(DB_CREATE)
    " " ":CREATE"
#  endif
#  if defined(DB_LOCKDOWN)
    " " ":LOCKDOWN"
#  endif
#  if defined(DB_PRIVATE)
    " " ":PRIVATE"
#  endif
#  if defined(DB_SYSTEM_MEM)
    " " ":SYSTEM-MEM"
#  endif
#  if defined(DB_THREAD)
    " " ":THREAD"
#  endif
    " " "))"
  },
  {
    " " "(OR NULL INTEGER (MEMBER"
#  if defined(DB_LOCK_NORUN)
    " " ":NORUN"
#  endif
#  if defined(DB_LOCK_DEFAULT)
    " " ":DEFAULT"
#  endif
#  if defined(DB_LOCK_EXPIRE)
    " " ":EXPIRE"
#  endif
#  if defined(DB_LOCK_MAXLOCKS)
    " " ":MAXLOCKS"
#  endif
#  if defined(DB_LOCK_MINLOCKS)
    " " ":MINLOCKS"
#  endif
#  if defined(DB_LOCK_MINWRITE)
    " " ":MINWRITE"
#  endif
#  if defined(DB_LOCK_OLDEST)
    " " ":OLDEST"
#  endif
#  if defined(DB_LOCK_RANDOM)
    " " ":RANDOM"
#  endif
#  if defined(DB_LOCK_YOUNGEST)
    " " ":YOUNGEST"
#  endif
    " " "))"
  },
  {
    " " "(OR NULL INTEGER (MEMBER"
#  if defined(DB_TXN_NOSYNC)
    " " ":NOSYNC"
#  endif
#  if defined(DB_TXN_SYNC)
    " " ":SYNC"
#  endif
    " " "))"
  },
  { "NIL" },
  0
};

struct module__bdb__subr_tab_t {
  VAROBJECTS_ALIGNMENT_DUMMY_DECL
  subr_t _subr_bdb_dbc_close;
  subr_t _subr_bdb_dbc_count;
  subr_t _subr_bdb_dbc_del;
  subr_t _subr_bdb_dbc_dup;
  subr_t _subr_bdb_dbc_get;
  subr_t _subr_bdb_dbc_put;
  subr_t _subr_bdb_dbe_close;
  subr_t _subr_bdb_dbe_create;
  subr_t _subr_bdb_dbe_dbremove;
  subr_t _subr_bdb_dbe_dbrename;
  subr_t _subr_bdb_dbe_get_options;
#if defined(HAVE_DB_ENV_SET_MSGCALL)
  subr_t _subr_bdb_dbe_messages;
#endif
  subr_t _subr_bdb_dbe_open;
  subr_t _subr_bdb_dbe_remove;
  subr_t _subr_bdb_dbe_set_options;
  subr_t _subr_bdb_db_close;
  subr_t _subr_bdb_db_create;
  subr_t _subr_bdb_db_del;
  subr_t _subr_bdb_db_fd;
  subr_t _subr_bdb_db_get;
  subr_t _subr_bdb_db_get_options;
  subr_t _subr_bdb_db_join;
  subr_t _subr_bdb_db_key_range;
  subr_t _subr_bdb_db_open;
  subr_t _subr_bdb_db_put;
  subr_t _subr_bdb_db_remove;
  subr_t _subr_bdb_db_rename;
  subr_t _subr_bdb_db_set_options;
  subr_t _subr_bdb_db_stat;
  subr_t _subr_bdb_db_sync;
  subr_t _subr_bdb_db_truncate;
  subr_t _subr_bdb_db_upgrade;
  subr_t _subr_bdb_db_verify;
  subr_t _subr_bdb_db_version;
  subr_t _subr_bdb_lock_close;
  subr_t _subr_bdb_lock_detect;
  subr_t _subr_bdb_lock_get;
  subr_t _subr_bdb_lock_id;
  subr_t _subr_bdb_lock_id_free;
  subr_t _subr_bdb_lock_put;
  subr_t _subr_bdb_lock_stat;
  subr_t _subr_bdb_logc_close;
  subr_t _subr_bdb_logc_get;
  subr_t _subr_bdb_log_archive;
  subr_t _subr_bdb_log_compare;
  subr_t _subr_bdb_log_cursor;
  subr_t _subr_bdb_log_file;
  subr_t _subr_bdb_log_flush;
  subr_t _subr_bdb_log_put;
  subr_t _subr_bdb_log_stat;
  subr_t _subr_bdb_make_dbc;
  subr_t _subr_bdb_txn_abort;
  subr_t _subr_bdb_txn_begin;
  subr_t _subr_bdb_txn_checkpoint;
  subr_t _subr_bdb_txn_commit;
  subr_t _subr_bdb_txn_discard;
  subr_t _subr_bdb_txn_id;
  subr_t _subr_bdb_txn_prepare;
  subr_t _subr_bdb_txn_recover;
  subr_t _subr_bdb_txn_set_timeout;
  subr_t _subr_bdb_txn_stat;
  int _dummy_to_avoid_trailing_comma_in_initializer;
};
extern struct module__bdb__subr_tab_t module__bdb__subr_tab;

static uintL bdb_ac_flags (void) {
  uintL flags = 0
#  ifdef DB_AUTO_COMMIT
    | (missingp(STACK_(0)) ? 0 : DB_AUTO_COMMIT)
#  endif
   ;
  skipSTACK(1);
  return flags;
}

static uintL dbe_open_flags (void) {
  uintL flags = 0
#  ifdef DB_THREAD
    | (missingp(STACK_(0)) ? 0 : DB_THREAD)
#  endif
#  ifdef DB_SYSTEM_MEM
    | (missingp(STACK_(1)) ? 0 : DB_SYSTEM_MEM)
#  endif
#  ifdef DB_PRIVATE
    | (missingp(STACK_(2)) ? 0 : DB_PRIVATE)
#  endif
#  ifdef DB_LOCKDOWN
    | (missingp(STACK_(3)) ? 0 : DB_LOCKDOWN)
#  endif
#  ifdef DB_CREATE
    | (missingp(STACK_(4)) ? 0 : DB_CREATE)
#  endif
#  ifdef DB_USE_ENVIRON_ROOT
    | (missingp(STACK_(5)) ? 0 : DB_USE_ENVIRON_ROOT)
#  endif
#  ifdef DB_USE_ENVIRON
    | (missingp(STACK_(6)) ? 0 : DB_USE_ENVIRON)
#  endif
#  ifdef DB_RECOVER_FATAL
    | (missingp(STACK_(7)) ? 0 : DB_RECOVER_FATAL)
#  endif
#  ifdef DB_RECOVER
    | (missingp(STACK_(8)) ? 0 : DB_RECOVER)
#  endif
#  ifdef DB_INIT_TXN
    | (missingp(STACK_(9)) ? 0 : DB_INIT_TXN)
#  endif
#  ifdef DB_INIT_MPOOL
    | (missingp(STACK_(10)) ? 0 : DB_INIT_MPOOL)
#  endif
#  ifdef DB_INIT_LOG
    | (missingp(STACK_(11)) ? 0 : DB_INIT_LOG)
#  endif
#  ifdef DB_INIT_LOCK
    | (missingp(STACK_(12)) ? 0 : DB_INIT_LOCK)
#  endif
#  ifdef DB_INIT_CDB
    | (missingp(STACK_(13)) ? 0 : DB_INIT_CDB)
#  endif
#  ifdef DB_JOINENV
    | (missingp(STACK_(14)) ? 0 : DB_JOINENV)
#  endif
   ;
  skipSTACK(15);
  return flags;
}

static uintL dbe_remove_flags (void) {
  uintL flags = 0
#  ifdef DB_USE_ENVIRON_ROOT
    | (missingp(STACK_(0)) ? 0 : DB_USE_ENVIRON_ROOT)
#  endif
#  ifdef DB_USE_ENVIRON
    | (missingp(STACK_(1)) ? 0 : DB_USE_ENVIRON)
#  endif
#  ifdef DB_FORCE
    | (missingp(STACK_(2)) ? 0 : DB_FORCE)
#  endif
   ;
  skipSTACK(3);
  return flags;
}

static uintL db_get_options (void) {
  uintL flags = 0
#  ifdef DB_RMW
    | (missingp(STACK_(0)) ? 0 : DB_RMW)
#  endif
#  ifdef DB_MULTIPLE
    | (missingp(STACK_(1)) ? 0 : DB_MULTIPLE)
#  endif
#  ifdef DB_READ_UNCOMMITTED
    | (missingp(STACK_(2)) ? 0 : DB_READ_UNCOMMITTED)
#  endif
#  ifdef DB_READ_COMMITTED
    | (missingp(STACK_(3)) ? 0 : DB_READ_COMMITTED)
#  endif
#  ifdef DB_AUTO_COMMIT
    | (missingp(STACK_(4)) ? 0 : DB_AUTO_COMMIT)
#  endif
   ;
  skipSTACK(5);
  return flags;
}

static uintL db_open_flags (void) {
  uintL flags = 0
#  ifdef DB_AUTO_COMMIT
    | (missingp(STACK_(0)) ? 0 : DB_AUTO_COMMIT)
#  endif
#  ifdef DB_TRUNCATE
    | (missingp(STACK_(1)) ? 0 : DB_TRUNCATE)
#  endif
#  ifdef DB_THREAD
    | (missingp(STACK_(2)) ? 0 : DB_THREAD)
#  endif
#  ifdef DB_RDONLY
    | (missingp(STACK_(3)) ? 0 : DB_RDONLY)
#  endif
#  ifdef DB_NOMMAP
    | (missingp(STACK_(4)) ? 0 : DB_NOMMAP)
#  endif
#  ifdef DB_EXCL
    | (missingp(STACK_(5)) ? 0 : DB_EXCL)
#  endif
#  ifdef DB_READ_UNCOMMITTED
    | (missingp(STACK_(6)) ? 0 : DB_READ_UNCOMMITTED)
#  endif
#  ifdef DB_CREATE
    | (missingp(STACK_(7)) ? 0 : DB_CREATE)
#  endif
   ;
  skipSTACK(8);
  return flags;
}

static uintL db_join_flags (void) {
  uintL flags = 0
#  ifdef DB_JOIN_NOSORT
    | (missingp(STACK_(0)) ? 0 : DB_JOIN_NOSORT)
#  endif
   ;
  skipSTACK(1);
  return flags;
}

static uintL db_verify_flags (void) {
  uintL flags = 0
#  ifdef DB_NOORDERCHK
    | (missingp(STACK_(0)) ? 0 : DB_NOORDERCHK)
#  endif
#  ifdef DB_PRINTABLE
    | (missingp(STACK_(1)) ? 0 : DB_PRINTABLE)
#  endif
#  ifdef DB_AGGRESSIVE
    | (missingp(STACK_(2)) ? 0 : DB_AGGRESSIVE)
#  endif
   ;
  skipSTACK(3);
  return flags;
}

static uintL make_dbc_flags (void) {
  uintL flags = 0
#  ifdef DB_WRITECURSOR
    | (missingp(STACK_(0)) ? 0 : DB_WRITECURSOR)
#  endif
#  ifdef DB_READ_UNCOMMITTED
    | (missingp(STACK_(1)) ? 0 : DB_READ_UNCOMMITTED)
#  endif
#  ifdef DB_READ_COMMITTED
    | (missingp(STACK_(2)) ? 0 : DB_READ_COMMITTED)
#  endif
   ;
  skipSTACK(3);
  return flags;
}

static uintL dbc_del_flags (void) {
  uintL flags = 0
#  ifdef DB_CONSUME
    | (missingp(STACK_(0)) ? 0 : DB_CONSUME)
#  endif
   ;
  skipSTACK(1);
  return flags;
}

static uintL dbc_dup_flags (void) {
  uintL flags = 0
#  ifdef DB_POSITION
    | (missingp(STACK_(0)) ? 0 : DB_POSITION)
#  endif
   ;
  skipSTACK(1);
  return flags;
}

static uintL dbc_get_options (void) {
  uintL flags = 0
#  ifdef DB_RMW
    | (missingp(STACK_(0)) ? 0 : DB_RMW)
#  endif
#  ifdef DB_MULTIPLE_KEY
    | (missingp(STACK_(1)) ? 0 : DB_MULTIPLE_KEY)
#  endif
#  ifdef DB_MULTIPLE
    | (missingp(STACK_(2)) ? 0 : DB_MULTIPLE)
#  endif
#  ifdef DB_READ_UNCOMMITTED
    | (missingp(STACK_(3)) ? 0 : DB_READ_UNCOMMITTED)
#  endif
#  ifdef DB_READ_COMMITTED
    | (missingp(STACK_(4)) ? 0 : DB_READ_COMMITTED)
#  endif
   ;
  skipSTACK(5);
  return flags;
}

static uintL lock_get_flags (void) {
  uintL flags = 0
#  ifdef DB_LOCK_NOWAIT
    | (missingp(STACK_(0)) ? 0 : DB_LOCK_NOWAIT)
#  endif
   ;
  skipSTACK(1);
  return flags;
}

static uintL stat_flags (void) {
  uintL flags = 0
#  ifdef DB_STAT_CLEAR
    | (missingp(STACK_(0)) ? 0 : DB_STAT_CLEAR)
#  endif
   ;
  skipSTACK(1);
  return flags;
}

static uintL log_archive_flags (void) {
  uintL flags = 0
#  ifdef DB_ARCH_REMOVE
    | (missingp(STACK_(0)) ? 0 : DB_ARCH_REMOVE)
#  endif
#  ifdef DB_ARCH_LOG
    | (missingp(STACK_(1)) ? 0 : DB_ARCH_LOG)
#  endif
#  ifdef DB_ARCH_DATA
    | (missingp(STACK_(2)) ? 0 : DB_ARCH_DATA)
#  endif
#  ifdef DB_ARCH_ABS
    | (missingp(STACK_(3)) ? 0 : DB_ARCH_ABS)
#  endif
   ;
  skipSTACK(4);
  return flags;
}

static uintL log_put_flags (void) {
  uintL flags = 0
#  ifdef DB_FLUSH
    | (missingp(STACK_(0)) ? 0 : DB_FLUSH)
#  endif
   ;
  skipSTACK(1);
  return flags;
}

static uintL txn_begin_flags (void) {
  uintL flags = 0
#  ifdef DB_TXN_SYNC
    | (missingp(STACK_(0)) ? 0 : DB_TXN_SYNC)
#  endif
#  ifdef DB_TXN_NOWAIT
    | (missingp(STACK_(1)) ? 0 : DB_TXN_NOWAIT)
#  endif
#  ifdef DB_TXN_NOSYNC
    | (missingp(STACK_(2)) ? 0 : DB_TXN_NOSYNC)
#  endif
#  ifdef DB_READ_UNCOMMITTED
    | (missingp(STACK_(3)) ? 0 : DB_READ_UNCOMMITTED)
#  endif
#  ifdef DB_READ_COMMITTED
    | (missingp(STACK_(4)) ? 0 : DB_READ_COMMITTED)
#  endif
   ;
  skipSTACK(5);
  return flags;
}

static uintL txn_checkpoint_flags (void) {
  uintL flags = 0
#  ifdef DB_FORCE
    | (missingp(STACK_(0)) ? 0 : DB_FORCE)
#  endif
   ;
  skipSTACK(1);
  return flags;
}

static uintL txn_recover_flags (void) {
  uintL flags = 0
#  ifdef DB_NEXT
    | (missingp(STACK_(0)) ? 0 : DB_NEXT)
#  endif
#  ifdef DB_FIRST
    | (missingp(STACK_(1)) ? 0 : DB_FIRST)
#  endif
   ;
  skipSTACK(2);
  return flags;
}


static const c_lisp_pair_t bdb_errno_table[] = {
 #ifdef DB_BUFFER_SMALL
  { DB_BUFFER_SMALL, &(O(object_Kbuffer_small)) },
 #endif
 #ifdef DB_DONOTINDEX
  { DB_DONOTINDEX, &(O(object_Kdonotindex)) },
 #endif
 #ifdef DB_KEYEMPTY
  { DB_KEYEMPTY, &(O(object_Kkeyempty)) },
 #endif
 #ifdef DB_KEYEXIST
  { DB_KEYEXIST, &(O(object_Kkeyexist)) },
 #endif
 #ifdef DB_LOCK_DEADLOCK
  { DB_LOCK_DEADLOCK, &(O(object_Klock_deadlock)) },
 #endif
 #ifdef DB_LOCK_NOTGRANTED
  { DB_LOCK_NOTGRANTED, &(O(object_Klock_notgranted)) },
 #endif
 #ifdef DB_LOG_BUFFER_FULL
  { DB_LOG_BUFFER_FULL, &(O(object_Klog_buffer_full)) },
 #endif
 #ifdef DB_NOSERVER
  { DB_NOSERVER, &(O(object_Knoserver)) },
 #endif
 #ifdef DB_NOSERVER_HOME
  { DB_NOSERVER_HOME, &(O(object_Knoserver_home)) },
 #endif
 #ifdef DB_NOSERVER_ID
  { DB_NOSERVER_ID, &(O(object_Knoserver_id)) },
 #endif
 #ifdef DB_NOTFOUND
  { DB_NOTFOUND, &(O(object_Knotfound)) },
 #endif
 #ifdef DB_OLD_VERSION
  { DB_OLD_VERSION, &(O(object_Kold_version)) },
 #endif
 #ifdef DB_PAGE_NOTFOUND
  { DB_PAGE_NOTFOUND, &(O(object_Kpage_notfound)) },
 #endif
 #ifdef DB_REP_DUPMASTER
  { DB_REP_DUPMASTER, &(O(object_Krep_dupmaster)) },
 #endif
 #ifdef DB_REP_HANDLE_DEAD
  { DB_REP_HANDLE_DEAD, &(O(object_Krep_handle_dead)) },
 #endif
 #ifdef DB_REP_HOLDELECTION
  { DB_REP_HOLDELECTION, &(O(object_Krep_holdelection)) },
 #endif
 #ifdef DB_REP_ISPERM
  { DB_REP_ISPERM, &(O(object_Krep_isperm)) },
 #endif
 #ifdef DB_REP_NEWMASTER
  { DB_REP_NEWMASTER, &(O(object_Krep_newmaster)) },
 #endif
 #ifdef DB_REP_NEWSITE
  { DB_REP_NEWSITE, &(O(object_Krep_newsite)) },
 #endif
 #ifdef DB_REP_NOTPERM
  { DB_REP_NOTPERM, &(O(object_Krep_notperm)) },
 #endif
 #ifdef DB_REP_STARTUPDONE
  { DB_REP_STARTUPDONE, &(O(object_Krep_startupdone)) },
 #endif
 #ifdef DB_REP_UNAVAIL
  { DB_REP_UNAVAIL, &(O(object_Krep_unavail)) },
 #endif
 #ifdef DB_RUNRECOVERY
  { DB_RUNRECOVERY, &(O(object_Krunrecovery)) },
 #endif
 #ifdef DB_SECONDARY_BAD
  { DB_SECONDARY_BAD, &(O(object_Ksecondary_bad)) },
 #endif
 #ifdef DB_VERIFY_BAD
  { DB_VERIFY_BAD, &(O(object_Kverify_bad)) },
 #endif
 #ifdef DB_VERSION_MISMATCH
  { DB_VERSION_MISMATCH, &(O(object_Kversion_mismatch)) },
 #endif
 #ifdef DB_ALREADY_ABORTED
  { DB_ALREADY_ABORTED, &(O(object_Kalready_aborted)) },
 #endif
 #ifdef DB_DELETED
  { DB_DELETED, &(O(object_Kdeleted)) },
 #endif
 #ifdef DB_LOCK_NOTEXIST
  { DB_LOCK_NOTEXIST, &(O(object_Klock_notexist)) },
 #endif
 #ifdef DB_NEEDSPLIT
  { DB_NEEDSPLIT, &(O(object_Kneedsplit)) },
 #endif
 #ifdef DB_REP_EGENCHG
  { DB_REP_EGENCHG, &(O(object_Krep_egenchg)) },
 #endif
 #ifdef DB_REP_LOGREADY
  { DB_REP_LOGREADY, &(O(object_Krep_logready)) },
 #endif
 #ifdef DB_REP_PAGEDONE
  { DB_REP_PAGEDONE, &(O(object_Krep_pagedone)) },
 #endif
 #ifdef DB_SURPRISE_KID
  { DB_SURPRISE_KID, &(O(object_Ksurprise_kid)) },
 #endif
 #ifdef DB_SWAPBYTES
  { DB_SWAPBYTES, &(O(object_Kswapbytes)) },
 #endif
 #ifdef DB_TIMEOUT
  { DB_TIMEOUT, &(O(object_Ktimeout)) },
 #endif
 #ifdef DB_TXN_CKP
  { DB_TXN_CKP, &(O(object_Ktxn_ckp)) },
 #endif
 #ifdef DB_VERIFY_FATAL
  { DB_VERIFY_FATAL, &(O(object_Kverify_fatal)) },
 #endif
  { 0, NULL }
};
static const c_lisp_map_t bdb_errno_map = {
  bdb_errno_table,
  (sizeof(bdb_errno_table)/sizeof(c_lisp_pair_t))-1,
  0,true,
  true,
  "bdb_errno"
};
#define bdb_errno(a) (int)map_lisp_to_c(a,&bdb_errno_map)
#define bdb_errno_reverse(a) map_c_to_lisp(a,&bdb_errno_map)

static const c_lisp_pair_t dbe_encryption_check_table[] = {
 #ifdef DB_ENCRYPT_AES
  { DB_ENCRYPT_AES, &(O(object_Kaes)) },
 #endif
  { 0, NULL }
};
static const c_lisp_map_t dbe_encryption_check_map = {
  dbe_encryption_check_table,
  (sizeof(dbe_encryption_check_table)/sizeof(c_lisp_pair_t))-1,
  0,true,
  true,
  "dbe_encryption_check"
};
#define dbe_encryption_check(a) (int)map_lisp_to_c(a,&dbe_encryption_check_map)
#define dbe_encryption_check_reverse(a) map_c_to_lisp(a,&dbe_encryption_check_map)

static const c_lisp_pair_t check_dbe_open_flags_table[] = {
 #ifdef DB_JOINENV
  { DB_JOINENV, &(O(object_Kjoinenv)) },
 #endif
 #ifdef DB_INIT_CDB
  { DB_INIT_CDB, &(O(object_Kinit_cdb)) },
 #endif
 #ifdef DB_INIT_LOCK
  { DB_INIT_LOCK, &(O(object_Kinit_lock)) },
 #endif
 #ifdef DB_INIT_LOG
  { DB_INIT_LOG, &(O(object_Kinit_log)) },
 #endif
 #ifdef DB_INIT_MPOOL
  { DB_INIT_MPOOL, &(O(object_Kinit_mpool)) },
 #endif
 #ifdef DB_INIT_TXN
  { DB_INIT_TXN, &(O(object_Kinit_txn)) },
 #endif
 #ifdef DB_RECOVER
  { DB_RECOVER, &(O(object_Krecover)) },
 #endif
 #ifdef DB_RECOVER_FATAL
  { DB_RECOVER_FATAL, &(O(object_Krecover_fatal)) },
 #endif
 #ifdef DB_USE_ENVIRON
  { DB_USE_ENVIRON, &(O(object_Kuse_environ)) },
 #endif
 #ifdef DB_USE_ENVIRON_ROOT
  { DB_USE_ENVIRON_ROOT, &(O(object_Kuse_environ_root)) },
 #endif
 #ifdef DB_CREATE
  { DB_CREATE, &(O(object_Kcreate)) },
 #endif
 #ifdef DB_LOCKDOWN
  { DB_LOCKDOWN, &(O(object_Klockdown)) },
 #endif
 #ifdef DB_PRIVATE
  { DB_PRIVATE, &(O(object_Kprivate)) },
 #endif
 #ifdef DB_SYSTEM_MEM
  { DB_SYSTEM_MEM, &(O(object_Ksystem_mem)) },
 #endif
 #ifdef DB_THREAD
  { DB_THREAD, &(O(object_Kthread)) },
 #endif
  { 0, NULL }
};
static const c_lisp_map_t check_dbe_open_flags_map = {
  check_dbe_open_flags_table,
  (sizeof(check_dbe_open_flags_table)/sizeof(c_lisp_pair_t))-1,
  0,true,
  true,
  "check_dbe_open_flags"
};
#define check_dbe_open_flags(a) (uint32_t)map_lisp_to_c(a,&check_dbe_open_flags_map)
#define check_dbe_open_flags_reverse(a) map_c_to_lisp(a,&check_dbe_open_flags_map)
#define check_dbe_open_flags_to_list(a) map_c_to_list(a,&check_dbe_open_flags_map)
#define check_dbe_open_flags_of_list(a) map_list_to_c(a,&check_dbe_open_flags_map)

static const c_lisp_pair_t check_lk_detect_table[] = {
 #ifdef DB_LOCK_NORUN
  { DB_LOCK_NORUN, &(O(object_Knorun)) },
 #endif
 #ifdef DB_LOCK_DEFAULT
  { DB_LOCK_DEFAULT, &(O(object_Kdefault)) },
 #endif
 #ifdef DB_LOCK_EXPIRE
  { DB_LOCK_EXPIRE, &(O(object_Kexpire)) },
 #endif
 #ifdef DB_LOCK_MAXLOCKS
  { DB_LOCK_MAXLOCKS, &(O(object_Kmaxlocks)) },
 #endif
 #ifdef DB_LOCK_MINLOCKS
  { DB_LOCK_MINLOCKS, &(O(object_Kminlocks)) },
 #endif
 #ifdef DB_LOCK_MINWRITE
  { DB_LOCK_MINWRITE, &(O(object_Kminwrite)) },
 #endif
 #ifdef DB_LOCK_OLDEST
  { DB_LOCK_OLDEST, &(O(object_Koldest)) },
 #endif
 #ifdef DB_LOCK_RANDOM
  { DB_LOCK_RANDOM, &(O(object_Krandom)) },
 #endif
 #ifdef DB_LOCK_YOUNGEST
  { DB_LOCK_YOUNGEST, &(O(object_Kyoungest)) },
 #endif
  { 0, NULL }
};
static const c_lisp_map_t check_lk_detect_map = {
  check_lk_detect_table,
  (sizeof(check_lk_detect_table)/sizeof(c_lisp_pair_t))-1,
# if defined(DB_LOCK_DEFAULT)
  DB_LOCK_DEFAULT,true,
# else
  0,false,
# endif
  true,
  "check_lk_detect"
};
#define check_lk_detect(a) (int)map_lisp_to_c(a,&check_lk_detect_map)
#define check_lk_detect_reverse(a) map_c_to_lisp(a,&check_lk_detect_map)

static const c_lisp_pair_t check_dbt_type_table[] = {
  { DBT_RAW, &(O(object_Kraw)) },
  { DBT_STRING, &(O(object_Kstring)) },
  { DBT_INTEGER, &(O(object_Kinteger)) },
  { 0, NULL }
};
static const c_lisp_map_t check_dbt_type_map = {
  check_dbt_type_table,
  (sizeof(check_dbt_type_table)/sizeof(c_lisp_pair_t))-1,
  DBT_RAW,true,
  true,
  "check_dbt_type"
};
#define check_dbt_type(a) (dbt_o_t)map_lisp_to_c(a,&check_dbt_type_map)
#define check_dbt_type_reverse(a) map_c_to_lisp(a,&check_dbt_type_map)

static const c_lisp_pair_t db_get_action_table[] = {
 #ifdef DB_CONSUME
  { DB_CONSUME, &(O(object_Kconsume)) },
 #endif
 #ifdef DB_CONSUME_WAIT
  { DB_CONSUME_WAIT, &(O(object_Kconsume_wait)) },
 #endif
 #ifdef DB_GET_BOTH
  { DB_GET_BOTH, &(O(object_Kget_both)) },
 #endif
 #ifdef DB_SET_RECNO
  { DB_SET_RECNO, &(O(object_Kset_recno)) },
 #endif
  { 0, NULL }
};
static const c_lisp_map_t db_get_action_map = {
  db_get_action_table,
  (sizeof(db_get_action_table)/sizeof(c_lisp_pair_t))-1,
  0,true,
  true,
  "db_get_action"
};
#define db_get_action(a) (int)map_lisp_to_c(a,&db_get_action_map)
#define db_get_action_reverse(a) map_c_to_lisp(a,&db_get_action_map)

static const c_lisp_pair_t check_dbtype_table[] = {
  { DB_UNKNOWN, &(O(object_Kunknown)) },
  { DB_BTREE, &(O(object_Kbtree)) },
  { DB_HASH, &(O(object_Khash)) },
  { DB_QUEUE, &(O(object_Kqueue)) },
  { DB_RECNO, &(O(object_Krecno)) },
  { 0, NULL }
};
static const c_lisp_map_t check_dbtype_map = {
  check_dbtype_table,
  (sizeof(check_dbtype_table)/sizeof(c_lisp_pair_t))-1,
  DB_UNKNOWN,true,
  true,
  "check_dbtype"
};
#define check_dbtype(a) (DBTYPE)map_lisp_to_c(a,&check_dbtype_map)
#define check_dbtype_reverse(a) map_c_to_lisp(a,&check_dbtype_map)

static const c_lisp_pair_t check_db_open_flags_table[] = {
 #ifdef DB_CREATE
  { DB_CREATE, &(O(object_Kcreate)) },
 #endif
 #ifdef DB_READ_UNCOMMITTED
  { DB_READ_UNCOMMITTED, &(O(object_Kread_uncommitted)) },
 #endif
 #ifdef DB_EXCL
  { DB_EXCL, &(O(object_Kexcl)) },
 #endif
 #ifdef DB_NOMMAP
  { DB_NOMMAP, &(O(object_Knommap)) },
 #endif
 #ifdef DB_RDONLY
  { DB_RDONLY, &(O(object_Krdonly)) },
 #endif
 #ifdef DB_THREAD
  { DB_THREAD, &(O(object_Kthread)) },
 #endif
 #ifdef DB_TRUNCATE
  { DB_TRUNCATE, &(O(object_Ktruncate)) },
 #endif
 #ifdef DB_AUTO_COMMIT
  { DB_AUTO_COMMIT, &(O(object_Kauto_commit)) },
 #endif
  { 0, NULL }
};
static const c_lisp_map_t check_db_open_flags_map = {
  check_db_open_flags_table,
  (sizeof(check_db_open_flags_table)/sizeof(c_lisp_pair_t))-1,
  0,true,
  true,
  "check_db_open_flags"
};
#define check_db_open_flags(a) (uint32_t)map_lisp_to_c(a,&check_db_open_flags_map)
#define check_db_open_flags_reverse(a) map_c_to_lisp(a,&check_db_open_flags_map)
#define check_db_open_flags_to_list(a) map_c_to_list(a,&check_db_open_flags_map)
#define check_db_open_flags_of_list(a) map_list_to_c(a,&check_db_open_flags_map)

static const c_lisp_pair_t db_put_action_table[] = {
 #ifdef DB_APPEND
  { DB_APPEND, &(O(object_Kappend)) },
 #endif
 #ifdef DB_NODUPDATA
  { DB_NODUPDATA, &(O(object_Knodupdata)) },
 #endif
 #ifdef DB_NOOVERWRITE
  { DB_NOOVERWRITE, &(O(object_Knooverwrite)) },
 #endif
  { 0, NULL }
};
static const c_lisp_map_t db_put_action_map = {
  db_put_action_table,
  (sizeof(db_put_action_table)/sizeof(c_lisp_pair_t))-1,
  0,true,
  true,
  "db_put_action"
};
#define db_put_action(a) (int)map_lisp_to_c(a,&db_put_action_map)
#define db_put_action_reverse(a) map_c_to_lisp(a,&db_put_action_map)

static const c_lisp_pair_t dbc_get_action_table[] = {
 #ifdef DB_CURRENT
  { DB_CURRENT, &(O(object_Kcurrent)) },
 #endif
 #ifdef DB_FIRST
  { DB_FIRST, &(O(object_Kfirst)) },
 #endif
 #ifdef DB_GET_BOTH
  { DB_GET_BOTH, &(O(object_Kget_both)) },
 #endif
 #ifdef DB_GET_BOTH_RANGE
  { DB_GET_BOTH_RANGE, &(O(object_Kget_both_range)) },
 #endif
 #ifdef DB_GET_RECNO
  { DB_GET_RECNO, &(O(object_Kget_recno)) },
 #endif
 #ifdef DB_JOIN_ITEM
  { DB_JOIN_ITEM, &(O(object_Kjoin_item)) },
 #endif
 #ifdef DB_LAST
  { DB_LAST, &(O(object_Klast)) },
 #endif
 #ifdef DB_NEXT
  { DB_NEXT, &(O(object_Knext)) },
 #endif
 #ifdef DB_NEXT_DUP
  { DB_NEXT_DUP, &(O(object_Knext_dup)) },
 #endif
 #ifdef DB_NEXT_NODUP
  { DB_NEXT_NODUP, &(O(object_Knext_nodup)) },
 #endif
 #ifdef DB_PREV
  { DB_PREV, &(O(object_Kprev)) },
 #endif
 #ifdef DB_PREV_NODUP
  { DB_PREV_NODUP, &(O(object_Kprev_nodup)) },
 #endif
 #ifdef DB_SET
  { DB_SET, &(O(object_Kset)) },
 #endif
 #ifdef DB_SET_RANGE
  { DB_SET_RANGE, &(O(object_Kset_range)) },
 #endif
 #ifdef DB_SET_RECNO
  { DB_SET_RECNO, &(O(object_Kset_recno)) },
 #endif
  { 0, NULL }
};
static const c_lisp_map_t dbc_get_action_map = {
  dbc_get_action_table,
  (sizeof(dbc_get_action_table)/sizeof(c_lisp_pair_t))-1,
# if defined(DB_CURRENT)
  DB_CURRENT,true,
# else
  0,false,
# endif
  true,
  "dbc_get_action"
};
#define dbc_get_action(a) (int)map_lisp_to_c(a,&dbc_get_action_map)
#define dbc_get_action_reverse(a) map_c_to_lisp(a,&dbc_get_action_map)

static const c_lisp_pair_t dbc_put_flag_table[] = {
 #ifdef DB_CURRENT
  { DB_CURRENT, &(O(object_Kcurrent)) },
 #endif
 #ifdef DB_AFTER
  { DB_AFTER, &(O(object_Kafter)) },
 #endif
 #ifdef DB_BEFORE
  { DB_BEFORE, &(O(object_Kbefore)) },
 #endif
 #ifdef DB_KEYFIRST
  { DB_KEYFIRST, &(O(object_Kkeyfirst)) },
 #endif
 #ifdef DB_KEYLAST
  { DB_KEYLAST, &(O(object_Kkeylast)) },
 #endif
 #ifdef DB_NODUPDATA
  { DB_NODUPDATA, &(O(object_Knodupdata)) },
 #endif
 #ifdef DB_OVERWRITE_DUP
  { DB_OVERWRITE_DUP, &(O(object_Koverwrite_dup)) },
 #endif
  { 0, NULL }
};
static const c_lisp_map_t dbc_put_flag_map = {
  dbc_put_flag_table,
  (sizeof(dbc_put_flag_table)/sizeof(c_lisp_pair_t))-1,
# if defined(DB_CURRENT)
  DB_CURRENT,true,
# else
  0,false,
# endif
  true,
  "dbc_put_flag"
};
#define dbc_put_flag(a) (int)map_lisp_to_c(a,&dbc_put_flag_map)
#define dbc_put_flag_reverse(a) map_c_to_lisp(a,&dbc_put_flag_map)

static const c_lisp_pair_t check_lockmode_table[] = {
  { DB_LOCK_NG, &(O(object_Kng)) },
  { DB_LOCK_READ, &(O(object_Kread)) },
  { DB_LOCK_WRITE, &(O(object_Kwrite)) },
  { DB_LOCK_WAIT, &(O(object_Kwait)) },
  { DB_LOCK_IWRITE, &(O(object_Kiwrite)) },
  { DB_LOCK_IREAD, &(O(object_Kiread)) },
  { DB_LOCK_IWR, &(O(object_Kiwr)) },
  { DB_LOCK_READ_UNCOMMITTED, &(O(object_Kread_uncommitted)) },
  { DB_LOCK_WWRITE, &(O(object_Kwwrite)) },
  { 0, NULL }
};
static const c_lisp_map_t check_lockmode_map = {
  check_lockmode_table,
  (sizeof(check_lockmode_table)/sizeof(c_lisp_pair_t))-1,
  0,true,
  true,
  "check_lockmode"
};
#define check_lockmode(a) (db_lockmode_t)map_lisp_to_c(a,&check_lockmode_map)
#define check_lockmode_reverse(a) map_c_to_lisp(a,&check_lockmode_map)

static const c_lisp_pair_t logc_get_action_table[] = {
 #ifdef DB_CURRENT
  { DB_CURRENT, &(O(object_Kcurrent)) },
 #endif
 #ifdef DB_FIRST
  { DB_FIRST, &(O(object_Kfirst)) },
 #endif
 #ifdef DB_LAST
  { DB_LAST, &(O(object_Klast)) },
 #endif
 #ifdef DB_NEXT
  { DB_NEXT, &(O(object_Knext)) },
 #endif
 #ifdef DB_PREV
  { DB_PREV, &(O(object_Kprev)) },
 #endif
  { 0, NULL }
};
static const c_lisp_map_t logc_get_action_map = {
  logc_get_action_table,
  (sizeof(logc_get_action_table)/sizeof(c_lisp_pair_t))-1,
# if defined(DB_CURRENT)
  DB_CURRENT,true,
# else
  0,false,
# endif
  true,
  "logc_get_action"
};
#define logc_get_action(a) (int)map_lisp_to_c(a,&logc_get_action_map)
#define logc_get_action_reverse(a) map_c_to_lisp(a,&logc_get_action_map)

static const c_lisp_pair_t txn_check_sync_table[] = {
 #ifdef DB_TXN_NOSYNC
  { DB_TXN_NOSYNC, &(O(object_Knosync)) },
 #endif
 #ifdef DB_TXN_SYNC
  { DB_TXN_SYNC, &(O(object_Ksync)) },
 #endif
  { 0, NULL }
};
static const c_lisp_map_t txn_check_sync_map = {
  txn_check_sync_table,
  (sizeof(txn_check_sync_table)/sizeof(c_lisp_pair_t))-1,
  0,true,
  true,
  "txn_check_sync"
};
#define txn_check_sync(a) (int)map_lisp_to_c(a,&txn_check_sync_map)
#define txn_check_sync_reverse(a) map_c_to_lisp(a,&txn_check_sync_map)

static const c_lisp_pair_t txn_timeout_check_table[] = {
 #ifdef DB_SET_LOCK_TIMEOUT
  { DB_SET_LOCK_TIMEOUT, &(O(object_Klock_timeout)) },
 #endif
 #ifdef DB_SET_TXN_TIMEOUT
  { DB_SET_TXN_TIMEOUT, &(O(object_Ktxn_timeout)) },
 #endif
  { 0, NULL }
};
static const c_lisp_map_t txn_timeout_check_map = {
  txn_timeout_check_table,
  (sizeof(txn_timeout_check_table)/sizeof(c_lisp_pair_t))-1,
  0,true,
  true,
  "txn_timeout_check"
};
#define txn_timeout_check(a) (int)map_lisp_to_c(a,&txn_timeout_check_map)
#define txn_timeout_check_reverse(a) map_c_to_lisp(a,&txn_timeout_check_map)

static const c_lisp_pair_t txn_status_check_table[] = {
 #ifdef TXN_ABORTED
  { TXN_ABORTED, &(O(object_Kaborted)) },
 #endif
 #ifdef TXN_COMMITTED
  { TXN_COMMITTED, &(O(object_Kcommitted)) },
 #endif
 #ifdef TXN_PREPARED
  { TXN_PREPARED, &(O(object_Kprepared)) },
 #endif
 #ifdef TXN_RUNNING
  { TXN_RUNNING, &(O(object_Krunning)) },
 #endif
  { 0, NULL }
};
static const c_lisp_map_t txn_status_check_map = {
  txn_status_check_table,
  (sizeof(txn_status_check_table)/sizeof(c_lisp_pair_t))-1,
  0,true,
  true,
  "txn_status_check"
};
#define txn_status_check(a) (int)map_lisp_to_c(a,&txn_status_check_map)
#define txn_status_check_reverse(a) map_c_to_lisp(a,&txn_status_check_map)


#line 85

DEFUN(BDB:DB-VERSION,&optional subsystems-p,(subr_bdb_db_version,seclass_default,0,1,norest,nokey,0,NIL))
{ /* Berkeley-DB version */
  int major, minor, patch;
  char * version;
  begin_system_call();
  version = db_version(&major,&minor,&patch);
  end_system_call();
  if (major != DB_VERSION_MAJOR || minor != DB_VERSION_MINOR) {
    pushSTACK(fixnum(DB_VERSION_MINOR)); pushSTACK(fixnum(DB_VERSION_MAJOR));
    pushSTACK(fixnum(minor)); pushSTACK(fixnum(major));
    error(serious_condition,GETTEXT("Version mismatch: compile=~S.~S link=~S~S"));
  }
  if (patch != DB_VERSION_PATCH) {
    /* is this warning warranted? */
    pushSTACK(fixnum(DB_VERSION_PATCH)); pushSTACK(fixnum(patch));
    error(warning,GETTEXT("Patch level mismatch: compile=~S link=~S"));
  }
  value1 = asciz_to_string(version,GLO(misc_encoding));
  value2 = fixnum(major);
  value3 = fixnum(minor);
  value4 = fixnum(patch);
  if (missingp(STACK_0)) {
    mv_count = 4;
  } else {                      /* return subsystem versions too */
    int subsystem_count = 0;
    pushSTACK(value1);          /*  save */
#  if defined(DB_LOCKVERSION)
    pushSTACK(O(object_Klock)); pushSTACK(fixnum(DB_LOCKVERSION)); subsystem_count++;
#  endif
#  if defined(DB_LOGVERSION)
    pushSTACK(O(object_Klog)); pushSTACK(fixnum(DB_LOGVERSION)); subsystem_count++;
#  endif
#  if defined(DB_TXNVERSION)
    pushSTACK(O(object_Ktxn)); pushSTACK(fixnum(DB_TXNVERSION)); subsystem_count++;
#  endif
#  if defined(DB_BTREEVERSION)
    pushSTACK(O(object_Kbtree)); pushSTACK(fixnum(DB_BTREEVERSION)); subsystem_count++;
#  endif
#  if defined(DB_HASHVERSION)
    pushSTACK(O(object_Khash)); pushSTACK(fixnum(DB_HASHVERSION)); subsystem_count++;
#  endif
#  if defined(DB_QAMVERSION)
    pushSTACK(O(object_Kqam)); pushSTACK(fixnum(DB_QAMVERSION)); subsystem_count++;
#  endif
#  if defined(DB_SEQUENCE_VERSION)
    pushSTACK(O(object_Ksequence)); pushSTACK(fixnum(DB_SEQUENCE_VERSION));
    subsystem_count++;
#  endif
    value5 = listof(2*subsystem_count);
    value1 = popSTACK();        /* restore */
    mv_count = 5;
  }
  skipSTACK(1);
}

static char *error_message = NULL;
#if defined(HAVE_DBE_SET_ERRCALL_ACCEPT_DBE)
static void error_callback (const DB_ENV* dbe,
                            const char *errpfx, const char *msg)
#else
static void error_callback (const char *errpfx, char *msg)
#endif
{
  char *data;
  if (error_message) { /* append the new message to the previous ones */
    int len = strlen(error_message);
    error_message = (char*)clisp_realloc(error_message,3 + strlen(msg) + len);
    error_message[len++] = ';';
    error_message[len++] = ' ';
    data = error_message + len;
  } else {
    int offset = errpfx ? strlen(errpfx)+4 : 0;
    data = error_message = (char*)clisp_malloc(1 + offset + strlen(msg));
    if (errpfx) {
      data[0] = '[';
      strcpy(data+1,errpfx);
      data[offset-3] = ']';
      data[offset-2] = ':';
      data[offset-1] = ' ';
    }
    data += offset;
  }
  strcpy(data,msg);
}
#define FREE_RESET(x) if (x) { free(x); x = NULL; }
static void error_message_reset (void) { FREE_RESET(error_message) }
#line 180

nonreturning_function(static, error_bdb, (int status, const char *caller)) {
  pushSTACK(O(object_bdb__bdb_error));  /* error type */
  pushSTACK(S(Kcode)); pushSTACK(bdb_errno_reverse(status));
  if (error_message)
    pushSTACK(O(object__22_7Es_20_28_7Es_29__20_7Es__20_7Es_22));
  else pushSTACK(O(object__22_7Es_20_28_7Es_29__20_7Es_22));
  pushSTACK(TheSubr(subr_self)->name);
  pushSTACK(safe_to_string(caller));
  pushSTACK(safe_to_string(db_strerror(status)));
  if (error_message) {
    pushSTACK(asciz_to_string(error_message,GLO(misc_encoding)));
    free(error_message); error_message = NULL;
    funcall(L(error_of_type),8);
  } else funcall(L(error_of_type),7);
  NOTREACHED;
}

#if defined(HAVE_DB_ENV_SET_MSGCALL)
/* a collection of messages */
struct messages { int max; int len; char* msgs[unspecified]; };

/* allocate the struct+space for max pointers */
static struct messages * make_messages (int max) {
  struct messages * data = (struct messages*)
    clisp_malloc(sizeof(struct messages) + (max-unspecified)*sizeof(char*));
  if (max<1) abort();
  data->len = 0;
  data->max = max;
  while (max) data->msgs[--max] = NULL;
  return data;
}

/* release all messages and the structure itself */
static void free_messages (struct messages* data) {
  if (data) {
    while (data->len) free(data->msgs[--data->len]);
    free(data);
  }
}
#line 221
#define close_messages(data)    do{ free_messages((struct messages*)data); data=NULL; }while(0)

/* convert all messages to a list of strings
 can trigger GC */
static object extract_messages (struct messages* data) {
  if (data && data->len) {
    int ii;
    for (ii=0; ii < data->len; ii++) {
      pushSTACK(asciz_to_string(data->msgs[ii],GLO(misc_encoding)));
      free(data->msgs[ii]);
    }
    data->len = 0;
    return listof(ii);
  } else return NIL;
}

/* add an extra message
 since we may need to reallocate, DATA is passed by reference */
static void add_message (struct messages* *data_, const char* msg) {
  if ((*data_) == NULL) (*data_) = make_messages(5);
  if ((*data_)->max = (*data_)->len) {  /* double the space */
    int new_max = 2*(*data_)->max;
    (*data_) = (struct messages*)
      clisp_realloc((*data_), (sizeof(struct messages) +
                               (new_max-unspecified)*sizeof(char*)));
    (*data_)->max = new_max;
  }
  { /* now max>len */
    int len = strlen(msg);
    (*data_)->msgs[++(*data_)->len] = (char*)clisp_malloc(len+1);
    strcpy((*data_)->msgs[(*data_)->len],msg);
  }
}

/* dbe is a const pointer, so we cannot change its slots explicitly
   (e.g., by assigning to app_private),
   so we have to pass an address to add_message() */
static void message_callback (const DB_ENV* dbe, const char *msg) {
  add_message((struct messages**)&(dbe->app_private),msg);
}
#else
#define close_messages(data)  data=NULL
#endif

#line 271
#define SYSCALL1(caller,args,cleanup)     do {                       int db_error_code;                                               begin_blocking_system_call();                                    db_error_code = caller args; cleanup                             end_blocking_system_call();                                      if (db_error_code) error_bdb(db_error_code,#caller);           } while(0)
#define SYSCALL(caller,args)     SYSCALL1(caller,args,)

/* check whether the OBJ has type TYPE and return its handle
 can trigger GC */
typedef enum {
  BH_VALID,           /* return a valid handle */
  BH_INVALIDATE,      /* invalidate and return handle, NULL for invalid FP */
  BH_NIL_IS_NULL,     /* return either NULL for NIL or a valid handle */
  BH_INVALID_IS_NULL  /* return either NULL for invalid or a valid handle */
} bdb_handle_t;
static void* bdb_handle (object obj, object type, bdb_handle_t oh) {
 bdb_handle_restart:
  while (!typep_classname(obj,type)) {
    if (missingp(obj) && oh == BH_NIL_IS_NULL) return NULL;
    pushSTACK(type);            /* save */
    pushSTACK(NIL);             /* no PLACE */
    pushSTACK(obj);             /* TYPE-ERROR slot DATUM */
    pushSTACK(type);            /* TYPE-ERROR slot EXPECTED-TYPE */
    pushSTACK(type); pushSTACK(obj); pushSTACK(TheSubr(subr_self)->name);
    check_value(type_error,GETTEXT("~S: ~S is not a ~S"));
    obj = value1; type = popSTACK(); /* restore */
  }
  { Fpointer fp = TheFpointer(TheStructure(obj)->recdata[1]);
    if (!fp_validp(fp)) {
      switch (oh) {
        case BH_INVALIDATE: case BH_INVALID_IS_NULL:
          return NULL;
        default:
          pushSTACK(type);            /* save */
          pushSTACK(NIL);             /* no PLACE */
          pushSTACK(obj); pushSTACK(TheSubr(subr_self)->name);
          check_value(type_error,GETTEXT("~S: ~S has been closed or comes from a previous Lisp session"));
          obj = value1; type = popSTACK(); /* restore */
          goto bdb_handle_restart;
      }
    }
    if (oh == BH_INVALIDATE) mark_fp_invalid(fp);
    return fp->fp_pointer;
  }
}
/* access the parents & dependents fields in a bdb-handle structure */
#define Parents(x)     TheStructure(x)->recdata[2]
#define Dependents(x)  TheStructure(x)->recdata[3]
/* allocate a wrapper for the pointer and add a finalizer to it
 parent can be a bdb-object of a list thereof
 can trigger GC */
static void wrap_finalize (void* pointer, object parents,
                           object maker, object closer) {
  pushSTACK(maker); pushSTACK(parents); pushSTACK(closer);
  pushSTACK(allocate_fpointer(pointer)); funcall(O(object_bdb__mkhandle),4);
}

/* convert a Lisp integer to a pair of (Giga-bytes bytes)
 can trigger GC */
DEFVAR(giga_byte)
static void size_to_giga_bytes (object size, u_int32_t *gb, u_int32_t *by) {
  pushSTACK(size); pushSTACK(negfixnum(-30));
  pushSTACK(O(giga_byte)); pushSTACK(size);
  funcall(L(ldb),2); *by = I_to_uint32(value1);
  funcall(L(ash),2); *gb = I_to_uint32(value1);
}

/* ===== Database Environment ===== */
/* not exported:
 DB_ENV->err	Error message with error string
 DB_ENV->errx	Error message
*/


/* set the password to perform encryption and decryption.
 can trigger GC */
static void dbe_set_encryption (DB_ENV *dbe, gcv_object_t *o_flags_,
                                gcv_object_t *o_password_) {
  u_int32_t flags = dbe_encryption_check(*o_flags_);
  *o_password_ = check_string(*o_password_);
  with_string_0(*o_password_,GLO(misc_encoding),password,
                { SYSCALL(dbe->set_encrypt,(dbe,password,flags)); });
}

DEFUN(BDB:DBE-CREATE,&key PASSWORD ENCRYPT :HOST CLIENT-TIMEOUT SERVER-TIMEOUT,(subr_bdb_dbe_create,seclass_default,0,0,norest,key,5,NIL))
{ /* Create an environment handle */
  DB_ENV *dbe, *dbe_cl;
  bool remote_p = boundp(STACK_2); /* host ==> remote */
  int cl_timeout = 0, sv_timeout = 0;
# if defined(DB_RPCCLIENT)      /* 4.2 and later */
  SYSCALL(db_env_create,(&dbe,remote_p ? DB_RPCCLIENT : 0));
# elif defined(DB_CLIENT)       /* 4.1 and before */
  SYSCALL(db_env_create,(&dbe,remote_p ? DB_CLIENT : 0));
# else
#  error how does your Berkeley DB create a remote client?
# endif
  if (remote_p) {
    if (uint_p(STACK_0)) sv_timeout = I_to_uint(STACK_0);
    if (uint_p(STACK_1)) cl_timeout = I_to_uint(STACK_1);
   host_restart:
    if (stringp(STACK_2)) {     /* string host */
      with_string_0(STACK_2,GLO(misc_encoding),hostz, {
          SYSCALL(dbe->set_rpc_server,(dbe,NULL,hostz,cl_timeout,sv_timeout,0));
        });
    } else if ((dbe_cl = (DB_ENV*)bdb_handle(STACK_2,O(object_bdb__dbe),
                                             BH_NIL_IS_NULL))) {
      /* reuse client */
      SYSCALL(dbe->set_rpc_server,(dbe,dbe_cl->cl_handle,NULL,
                                   cl_timeout,sv_timeout,0));
    } else {                    /* bad host */
      pushSTACK(NIL);           /* no PLACE */
      pushSTACK(STACK_(2+1));   /* TYPE-ERROR slot DATUM */
      pushSTACK(O(object__28or_20string_20bdb__dbe_29)); /* TYPE-ERROR slot EXPECTED-TYPE */
      pushSTACK(STACK_2);                /* host */
      pushSTACK(O(object_bdb__dbe)); pushSTACK(S(string)); pushSTACK(S(Khost));
      pushSTACK(TheSubr(subr_self)->name);
      check_value(type_error,GETTEXT("~S: ~S should be a ~S or a ~S, not ~S"));
      STACK_2 = value1;
      goto host_restart;
    }
  }
  if (!missingp(STACK_4))       /* :PASSWD */
    dbe_set_encryption(dbe,&STACK_3,&STACK_4);
  skipSTACK(5);
  /* set error & message callbacks */
  begin_system_call(); dbe->set_errcall(dbe,&error_callback);
#if defined(HAVE_DB_ENV_SET_MSGCALL)
  dbe->set_msgcall(dbe,&message_callback);
#endif
  end_system_call();
  wrap_finalize(dbe,NIL,O(object_bdb__mkdbe),F(subr_bdb_dbe_close));
}

static void time_stamp (FILE* out, char* prefix) {
  fputs(prefix,out);
#if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_LOCALTIME) && defined(HAVE_STRFTIME)
  { char str[80]; struct timeval tv; gettimeofday(&tv,NULL);
    strftime(str,80," [%Y-%m-%d %a %H:%M:%S %Z]",localtime(&tv.tv_sec));
    fputs(str,out);
  }
#else
  fprintf(out," [%s:%d: FIXME time_stamp()]",__FILE__,__LINE__);
#endif
  fputs("\n",out);
}

/* open the C file and return it
 can trigger GC */
static FILE* my_fopen (object path) {
  FILE *ret;
  with_string_0(path=physical_namestring(path),GLO(pathname_encoding),pathz,{
      begin_blocking_system_call();
      ret = fopen(pathz,"w");
      if (ret == NULL) { end_blocking_system_call(); OS_file_error(path); }
      time_stamp(ret,"opened");
      end_blocking_system_call();
    });
  return ret;
}

/* some DB parameters (errfile, errpfx) are actually kept in DB.dbenv field.
 http://groups.google.com/groups?&selm=adecb6f.0408050624.5ed0a11e@posting.google.com
 therefore, instead of calling db->get_errfile(db,...) we call
 db->dbenv(get_errfile(db->dbenv,...)).
 note that DB-CLOSE should close these parameters
 only if it is a standalone DB! */
#line 443
#define CLOSE_FILE(which)                                  static void close_##which##file (DB_ENV *dbe) {            FILE *file;                                              begin_blocking_system_call();                            dbe->get_##which##file(dbe,&file);                       if (file && (file != stdout) && (file != stderr)) {        time_stamp(file,"closed");                               fclose(file);                                          }                                                        end_blocking_system_call();                            }
CLOSE_FILE(err)
/* set :ERRFILE to STACK_0
 can trigger GC */
#line 458
#define RESET_FILE(which)                                                  static void reset_##which##file (DB_ENV *dbe) {                            close_##which##file(dbe);                                                if (nullp(STACK_0)) {                                                      begin_system_call(); dbe->set_##which##file(dbe,NULL);                   end_system_call();                                                     } else {                                                                   FILE *file = my_fopen(STACK_0);                                          begin_system_call(); dbe->set_##which##file(dbe,file);                   end_system_call();                                                     }                                                                      }
RESET_FILE(err)
/* extract errfile */
#line 470
#define EXTRACT_FILE(which)                                static object dbe_get_##which##file (DB_ENV *dbe) {        FILE* file;                                              int fd = -1;                                             begin_system_call();                                     dbe->get_##which##file(dbe,&file);                       if (file) fd = fileno(file);                             end_system_call();                                       return fd >= 0 ? fixnum(fd) : NIL;                     }
EXTRACT_FILE(err)
#if defined(HAVE_DB_ENV_SET_MSGCALL)
CLOSE_FILE(msg)
RESET_FILE(msg)
EXTRACT_FILE(msg)
#else
# define close_msgfile(dbe)   do{}while(0)
# define reset_msgfile(dbe)   do{}while(0)
# define dbe_get_msgfile(dbe) NIL
#endif
static void close_errpfx (DB_ENV *dbe) {
  const char *errpfx;
  begin_system_call();
  dbe->get_errpfx(dbe,&errpfx);
  if (errpfx) free((void*)errpfx);
  end_system_call();
}
DEFUN(BDB:DBE-CLOSE, dbe,(subr_bdb_dbe_close,seclass_default,1,0,norest,nokey,0,NIL))
{ /* close DB environment */
  DB_ENV *dbe = (DB_ENV*)bdb_handle(STACK_0,O(object_bdb__dbe),BH_INVALIDATE);
  if (dbe) {
    funcall(O(object_bdb__kill_handle),1);
    close_errfile(dbe);
    close_errpfx(dbe);
    close_msgfile(dbe);
    close_messages(dbe->app_private);
    SYSCALL(dbe->close,(dbe,0));
    VALUES1(T);
  } else { skipSTACK(1); VALUES1(NIL); }
}

#if defined(HAVE_DB_ENV_SET_MSGCALL)
DEFUN(BDB:DBE-MESSAGES, dbe,(subr_bdb_dbe_messages,seclass_default,1,0,norest,nokey,0,NIL))
{ /* close DB environment */
  DB_ENV *dbe = (DB_ENV*)bdb_handle(popSTACK(),O(object_bdb__dbe),BH_VALID);
  VALUES1(extract_messages((struct messages*)dbe->app_private));
}
#endif


DEFUN(BDB:DBE-DBREMOVE, dbe file database &key TRANSACTION AUTO-COMMIT,(subr_bdb_dbe_dbremove,seclass_default,3,0,norest,key,2,NIL))
{ /* remove DATABASE from FILE or the whole FILE */
  u_int32_t flags = bdb_ac_flags();
  DB_TXN *txn = (DB_TXN*)bdb_handle(popSTACK(),O(object_bdb__txn),BH_NIL_IS_NULL);
  DB_ENV *dbe = (DB_ENV*)bdb_handle(STACK_2,O(object_bdb__dbe),BH_VALID);
  if (!nullp(STACK_2)) STACK_2 = check_string(STACK_0); /* DATABASE */
  STACK_1 = physical_namestring(STACK_1);               /* FILE */
  with_string_0(STACK_1,GLO(pathname_encoding),file, {
      if (stringp(STACK_0)) {
        with_string_0(STACK_0,GLO(misc_encoding),database, {
            SYSCALL(dbe->dbremove,(dbe,txn,file,database,flags));
          });
      } else SYSCALL(dbe->dbremove,(dbe,txn,file,NULL,flags));
    });
  VALUES0; skipSTACK(3);
}

DEFUN(BDB:DBE-DBRENAME, dbe file database newname &key TRANSACTION AUTO-COMMIT,(subr_bdb_dbe_dbrename,seclass_default,4,0,norest,key,2,NIL))
{ /* rename DATABASE to NEWNAME in FILE */
  u_int32_t flags = bdb_ac_flags();
  DB_TXN *txn = (DB_TXN*)bdb_handle(popSTACK(),O(object_bdb__txn),BH_NIL_IS_NULL);
  DB_ENV *dbe = (DB_ENV*)bdb_handle(STACK_3,O(object_bdb__dbe),BH_VALID);
  with_string_0(physical_namestring(STACK_2),GLO(pathname_encoding),file, {
      with_string_0(check_string(STACK_1),GLO(misc_encoding),database, {
          with_string_0(check_string(STACK_0),GLO(misc_encoding),newname, {
              SYSCALL(dbe->dbrename,(dbe,txn,file,database,newname,flags));
            });
        });
    });
  VALUES0; skipSTACK(4);
}

#line 546

#line 550

#line 553
DEFUN(BDB:DBE-OPEN, dbe &key HOME FLAGS JOINENV INIT-CDB INIT-LOCK           INIT-LOG INIT-MPOOL INIT-TXN RECOVER RECOVER-FATAL USE-ENVIRON        USE-ENVIRON-ROOT :CREATE LOCKDOWN PRIVATE SYSTEM-MEM THREAD MODE,(subr_bdb_dbe_open,seclass_default,1,0,norest,key,18,NIL))
{ /* open DB environment */
  int mode = check_uint_default0(popSTACK());
  u_int32_t flags = dbe_open_flags()
    | check_dbe_open_flags_of_list(popSTACK());
  DB_ENV *dbe = (DB_ENV*)bdb_handle(STACK_1,O(object_bdb__dbe),BH_VALID);
  if (!missingp(STACK_0)) {
    with_string_0(physical_namestring(STACK_0),GLO(pathname_encoding),home,
                  { SYSCALL(dbe->open,(dbe,home,flags,mode)); });
  } else SYSCALL(dbe->open,(dbe,NULL,flags,mode));
  VALUES0; skipSTACK(2);
}


DEFUN(BDB:DBE-REMOVE, dbe &key HOME FORCE USE-ENVIRON USE-ENVIRON-ROOT,(subr_bdb_dbe_remove,seclass_default,1,0,norest,key,4,NIL))
{ /* destroy an environment */
  u_int32_t flags = dbe_remove_flags();
  DB_ENV *dbe = (DB_ENV*)bdb_handle(STACK_1,O(object_bdb__dbe),BH_INVALIDATE);
  if (!missingp(STACK_0)) {
    with_string_0(physical_namestring(STACK_0),GLO(pathname_encoding),home,
                  { SYSCALL(dbe->remove,(dbe,home,flags)); });
  } else SYSCALL(dbe->remove,(dbe,NULL,flags));
  VALUES0; skipSTACK(2);
}

/* ===== Environment Configuration ===== */

/* not exported:
 DB_ENV->set_app_dispatch	Configure application recovery interface
 DB_ENV->set_alloc	Set local space allocation functions
 DB_ENV->set_errcall	Set error message callback
 DB_ENV->set_feedback	Set feedback callback
 DB_ENV->set_paniccall	Set panic callback
*/

/* set :ERRPFX to STACK_0
 can trigger GC */
static void reset_errpfx (DB_ENV *dbe) {
  close_errpfx(dbe);
  if (nullp(STACK_0)) {
    begin_system_call(); dbe->set_errpfx(dbe,NULL); end_system_call();
  } else
    with_string_0(check_string(STACK_0),GLO(misc_encoding), prefix, {
        char *errpfx = (char*)clisp_malloc(prefix_bytelen+1);
        begin_system_call();
        strcpy(errpfx,prefix);
        dbe->set_errpfx(dbe,errpfx);
        end_system_call();
      });
}
/* extract errpfx
 can trigger GC */
static object dbe_get_errpfx (DB_ENV *dbe) {
  const char* errpfx;
  begin_system_call();
  dbe->get_errpfx(dbe,&errpfx);
  end_system_call();
  return safe_to_string(errpfx);
}
/* define a flag checker */
#line 618
#define FLAG_EXTRACTOR(name,type)                          static int name (type z) {                                 u_int32_t flags;                                         SYSCALL(z->get_flags,(z,&flags));                        return flags;                                          }

/* at 4.2, http://www.sleepycat.com/docs/ref/upgrade.4.4/mutex.html
   get_tas_spins was renamed to mutex_get_tas_spins: */
#if defined(HAVE_DB_ENV_MUTEX_GET_TAS_SPINS)
# define get_tas_spins mutex_get_tas_spins
# define dbe_get_tas_spins dbe_mutex_get_tas_spins
#endif
#if defined(HAVE_DB_ENV_MUTEX_SET_TAS_SPINS)
# define set_tas_spins mutex_set_tas_spins
# define dbe_set_tas_spins dbe_mutex_set_tas_spins
#endif
/* todo: support mutexes properly */

static void set_flags (object arg, u_int32_t *flag_on, u_int32_t *flag_off,
                       u_int32_t values) {
  if (boundp(arg))
    *(nullp(arg) ? flag_off : flag_on) |= values;
}
static void my_set_verbose (DB_ENV *dbe, object arg, u_int32_t flag) {
  if (boundp(arg)) SYSCALL(dbe->set_verbose,(dbe,flag,!nullp(arg)));
}
#line 641

#line 653
DEFUN(BDB:DBE-SET-OPTIONS, dbe &key                                            ERRFILE ERRPFX PASSWORD ENCRYPT LOCK-TIMEOUT TXN-TIMEOUT TIMEOUT        SHM-KEY TAS-SPINS TX-TIMESTAMP TX-MAX DATA-DIR TMP-DIR        INTERMEDIATE-DIR-MODE                                             LG-BSIZE LG-DIR LG-MAX LG-REGIONMAX NCACHE CACHESIZE CACHE        LK-CONFLICTS LK-DETECT LK-MAX-LOCKERS LK-MAX-LOCKS LK-MAX-OBJECTS        LOG-DIRECT LOG-DSYNC LOG-AUTO-REMOVE LOG-IN-MEMORY LOG-ZERO        AUTO-COMMIT CDB-ALLDB DIRECT-DB NOLOCKING                             NOMMAP NOPANIC :OVERWRITE PANIC-ENVIRONMENT REGION-INIT               TXN-NOSYNC TXN-WRITE-NOSYNC YIELDCPU                                  VERB-CHKPOINT VERB-DEADLOCK VERB-RECOVERY VERB-REPLICATION           VERB-WAITSFOR :VERBOSE MSGFILE,(subr_bdb_dbe_set_options,seclass_default,1,0,norest,key,50,NIL))
{ /* set many options */
  DB_ENV *dbe = (DB_ENV*)bdb_handle(STACK_(50),O(object_bdb__dbe),BH_VALID);
  if (!missingp(STACK_0)) reset_msgfile(dbe);
  skipSTACK(1);                 /* drop :MSGFILE */
  { object arg = popSTACK();
    my_set_verbose(dbe,arg,DB_VERB_WAITSFOR);
    my_set_verbose(dbe,arg,DB_VERB_REPLICATION);
#  if defined(DB_VERB_CHKPOINT)
    my_set_verbose(dbe,arg,DB_VERB_CHKPOINT);
#  endif
    my_set_verbose(dbe,arg,DB_VERB_RECOVERY);
    my_set_verbose(dbe,arg,DB_VERB_DEADLOCK);
  }
  my_set_verbose(dbe,popSTACK(),DB_VERB_WAITSFOR);
  my_set_verbose(dbe,popSTACK(),DB_VERB_REPLICATION);
  my_set_verbose(dbe,popSTACK(),DB_VERB_RECOVERY);
  my_set_verbose(dbe,popSTACK(),DB_VERB_DEADLOCK);
#if defined(DB_VERB_CHKPOINT)
  my_set_verbose(dbe,popSTACK(),DB_VERB_CHKPOINT);
#else
  skipSTACK(1);               /* drop :VERB-CHKPOINT */
#endif
  { /* flags */
    u_int32_t flags_on = 0, flags_off = 0;
    set_flags(popSTACK(),&flags_on,&flags_off,DB_YIELDCPU);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_TXN_WRITE_NOSYNC);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_TXN_NOSYNC);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_REGION_INIT);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_PANIC_ENVIRONMENT);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_OVERWRITE);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_NOPANIC);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_NOMMAP);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_NOLOCKING);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_DIRECT_DB);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_CDB_ALLDB);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_AUTO_COMMIT);
# if defined(HAVE_DB_ENV_LOG_SET_CONFIG)
    if (flags_off) SYSCALL(dbe->set_flags,(dbe,flags_off,0));
    if (flags_on)  SYSCALL(dbe->set_flags,(dbe,flags_on,1));
    flags_on = 0; flags_off = 0;
    set_flags(popSTACK(),&flags_on,&flags_off,DB_LOG_ZERO);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_LOG_IN_MEMORY);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_LOG_AUTO_REMOVE);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_LOG_DSYNC);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_LOG_DIRECT);
    if (flags_off) SYSCALL(dbe->log_set_config,(dbe,flags_off,0));
    if (flags_on)  SYSCALL(dbe->log_set_config,(dbe,flags_on,1));
# else
    skipSTACK(1);               /* skip :LOG-ZERO */
#  if defined(DB_LOG_INMEMORY)
    set_flags(popSTACK(),&flags_on,&flags_off,DB_LOG_INMEMORY);
#  else
    skipSTACK(1);               /* skip :LOG-INMEMORY */
#  endif
    set_flags(popSTACK(),&flags_on,&flags_off,DB_LOG_AUTOREMOVE);
#  if defined(DB_DSYNC_LOG)
    set_flags(popSTACK(),&flags_on,&flags_off,DB_DSYNC_LOG);
#  else
    skipSTACK(1);               /* skip :LOG-DSYNC */
#  endif
    set_flags(popSTACK(),&flags_on,&flags_off,DB_DIRECT_LOG);
    if (flags_off) SYSCALL(dbe->set_flags,(dbe,flags_off,0));
    if (flags_on)  SYSCALL(dbe->set_flags,(dbe,flags_on,1));
# endif  /* HAVE_DB_ENV_LOG_SET_CONFIG */
  }
#line 725
#define DBE_SET1(what,type,get,how)    do {             if (!missingp(STACK_0)) {                             type what = get;                                    SYSCALL(dbe->set_##what,how);                     }                                                   skipSTACK(1);                                     } while(0)
#define DBE_SET(what,type,get)   DBE_SET1(what,type,get,(dbe,what))
  DBE_SET(lk_max_objects,u_int32_t,I_to_uint32(check_uint32(STACK_0)));
  DBE_SET(lk_max_locks,u_int32_t,I_to_uint32(check_uint32(STACK_0)));
  DBE_SET(lk_max_lockers,u_int32_t,I_to_uint32(check_uint32(STACK_0)));
  DBE_SET(lk_detect,u_int32_t,check_lk_detect(STACK_0));
  if (!missingp(STACK_0)) {     /* LK_CONFLICTS */
    uintL dims[2];
   restart_LK_CONFLICTS:        /* check arguments */
    STACK_0 = check_array(STACK_0);
    if (2 != array_rank(STACK_0)
        || (get_array_dimensions(STACK_0,2,dims), dims[0] != dims[1])
        || (array_atype(STACK_0) != Atype_8Bit)) {
      pushSTACK(NIL);           /* no PLACE */
      pushSTACK(STACK_1);       /* TYPE-ERROR slot DATUM */
      pushSTACK(O(object__28array_20_28unsigned_byte_208_29_20_28_2A_20_2A_29_29)); /* EXPECTED-TYPE */
      pushSTACK(STACK_1); pushSTACK(O(object_Klk_conflicts));
      pushSTACK(TheSubr(subr_self)->name);
      check_value(type_error,
                  GETTEXT("~S: ~S must be a square matrix of bytes, not ~S"));
      STACK_0 = value1;
      goto restart_LK_CONFLICTS;
    }
    { /* set the conflict matrix */
      int db_error_code;
      uintL offset = 0;
      object data = array_displace_check(STACK_0,dims[0]*dims[1],&offset);
      /* the matrix is just copied and the call is not really "blocking" one.
         if we use SYSCALL we should also pin the object */
      begin_system_call();
      db_error_code =
        dbe->set_lk_conflicts(dbe,TheSbvector(data)->data + offset,dims[0]);
      end_system_call();
      if (db_error_code) error_bdb(db_error_code,"dbe->set_lk_conflicts");
    }
  }
  skipSTACK(1);
  if (!missingp(STACK_0)) {     /* CACHE = (ncache cachesize) */
    STACK_0 = check_list(STACK_0);
    if (consp(STACK_0)) {
      int ncache = I_to_uint(check_uint(Car(STACK_0)));
      u_int32_t gbytes=0, bytes=0;
      STACK_0 = check_list(Cdr(STACK_0));
      if (consp(STACK_0))
        size_to_giga_bytes(Car(STACK_0),&gbytes,&bytes);
      SYSCALL(dbe->set_cachesize,(dbe,gbytes,bytes,ncache));
    }
  }
  skipSTACK(1);
  if (!missingp(STACK_0)) {     /* CACHESIZE & NCACHE */
    int ncache = check_uint_default0(STACK_1);
    u_int32_t gbytes, bytes;
    size_to_giga_bytes(STACK_0,&gbytes,&bytes);
    SYSCALL(dbe->set_cachesize,(dbe,gbytes,bytes,ncache));
  }
  skipSTACK(2);
  DBE_SET(lg_regionmax,u_int32_t,I_to_uint32(check_uint32(STACK_0)));
  DBE_SET(lg_max,u_int32_t,I_to_uint32(check_uint32(STACK_0)));
  if (!missingp(STACK_0)) {     /* LG_DIR */
    with_string_0(physical_namestring(popSTACK()),GLO(pathname_encoding),dirz,
                  { SYSCALL(dbe->set_lg_dir,(dbe,dirz)); });
  } else skipSTACK(1);
  DBE_SET(lg_bsize,u_int32_t,I_to_uint32(check_uint32(STACK_0)));
#if defined(HAVE_DB_ENV_GET_INTERMEDIATE_DIR_MODE)
  if (!missingp(STACK_0)) {     /* DB_ENV.get_intermediate_dir_mode */
    with_string_0(physical_namestring(popSTACK()),GLO(pathname_encoding),idm,
                  { SYSCALL(dbe->set_intermediate_dir_mode,(dbe,idm)); });
  } else
#endif
    skipSTACK(1);                 /* drop intermediate_dir_mode */
  if (!missingp(STACK_0)) {     /* TMP_DIR */
    with_string_0(physical_namestring(popSTACK()),GLO(pathname_encoding),tmpz,
                  { SYSCALL(dbe->set_tmp_dir,(dbe,tmpz)); });
  } else skipSTACK(1);
  if (!missingp(STACK_0)) {     /* DATA_DIR */
    if (consp(STACK_0)) {
      do {
        with_string_0(physical_namestring(Car(STACK_0)),GLO(pathname_encoding),
                      dataz, { SYSCALL(dbe->set_data_dir,(dbe,dataz)); });
        STACK_0 = Cdr(STACK_0);
      } while (consp(STACK_0));
      skipSTACK(1);
    } else
      with_string_0(physical_namestring(popSTACK()),GLO(pathname_encoding),
                    dataz, { SYSCALL(dbe->set_data_dir,(dbe,dataz)); });
  } else skipSTACK(1);
  DBE_SET(tx_max,u_int32_t,I_to_uint32(check_uint32(STACK_0)));
  if (!missingp(STACK_0)) {     /* TX_TIMESTAMP */
    time_t timestamp;
    convert_time_from_universal(STACK_0,&timestamp);
    SYSCALL(dbe->set_tx_timestamp,(dbe,&timestamp));
  }
  skipSTACK(1);
  DBE_SET(tas_spins,u_int32_t,I_to_uint32(check_uint32(STACK_0)));
  DBE_SET(shm_key,long,I_to_sint32(check_sint32(STACK_0)));
  if (!missingp(STACK_0)) {     /* TIMEOUT = TXN_TIMEOUT & LOCK_TIMEOUT */
    STACK_0 = check_list(STACK_0);
    if (consp(STACK_0)) {
      db_timeout_t txn_timeout = I_to_uint(check_uint(Car(STACK_0)));
      SYSCALL(dbe->set_timeout,(dbe,txn_timeout,DB_SET_TXN_TIMEOUT));
      STACK_0 = check_list(Cdr(STACK_0));
      if (consp(STACK_0)) {
        db_timeout_t lock_timeout = I_to_uint(check_uint(Car(STACK_0)));
        SYSCALL(dbe->set_timeout,(dbe,lock_timeout,DB_SET_LOCK_TIMEOUT));
      }
    }
  }
  skipSTACK(1);
  DBE_SET1(timeout,db_timeout_t,I_to_uint(check_uint(STACK_0)),
           (dbe,timeout,DB_SET_TXN_TIMEOUT));
  DBE_SET1(timeout,db_timeout_t,I_to_uint(check_uint(STACK_0)),
           (dbe,timeout,DB_SET_LOCK_TIMEOUT));
  if (!missingp(STACK_1))       /* PASSWORD */
    dbe_set_encryption(dbe,&STACK_0,&STACK_1);
  skipSTACK(2);
  if (!missingp(STACK_0)) reset_errpfx(dbe);
  skipSTACK(1);
  if (!missingp(STACK_0)) reset_errfile(dbe);
  skipSTACK(1);
  VALUES0; skipSTACK(1);        /* skip dbe */
#undef DBE_SET
#undef DBE_SET1
}

/* value1 == cachesize, value2 = ncache
 can trigger GC */
static void cache2lisp (u_int32_t gbytes, u_int32_t bytes, int ncache) {
  pushSTACK(UL_to_I(gbytes)); pushSTACK(fixnum(30)); funcall(L(ash),2);
  pushSTACK(value1); pushSTACK(UL_to_I(bytes)); funcall(L(plus),2);
  value2 = fixnum(ncache);
}

/* get cache size and number of caches
   value1 == cachesize, value2 = ncache
 can trigger GC */
static void dbe_get_cache (DB_ENV* dbe, int errorp) {
  u_int32_t gbytes, bytes;
  int ncache, status;
  begin_system_call();
  status = dbe->get_cachesize(dbe,&gbytes,&bytes,&ncache);
  end_system_call();
  if (status) {
    if (errorp) error_bdb(status,"dbe->get_cachesize");
    error_message_reset();
    value1 = value2 = NIL;
  } else cache2lisp (gbytes, bytes, ncache);
}

/* get the list of verbosity options
 can trigger GC */
static object dbe_get_verbose (DB_ENV *dbe) {
  int count = 0, onoffp;
  SYSCALL(dbe->get_verbose,(dbe,DB_VERB_WAITSFOR,&onoffp));
  if (onoffp) { pushSTACK(O(object_Kverb_waitsfor)); count++; }
  SYSCALL(dbe->get_verbose,(dbe,DB_VERB_REPLICATION,&onoffp));
  if (onoffp) { pushSTACK(O(object_Kverb_replication)); count++;}
  SYSCALL(dbe->get_verbose,(dbe,DB_VERB_RECOVERY,&onoffp));
  if (onoffp) { pushSTACK(O(object_Kverb_recovery)); count++; }
  SYSCALL(dbe->get_verbose,(dbe,DB_VERB_DEADLOCK,&onoffp));
  if (onoffp) { pushSTACK(O(object_Kverb_deadlock)); count++; }
#if defined(DB_VERB_CHKPOINT)
  SYSCALL(dbe->get_verbose,(dbe,DB_VERB_CHKPOINT,&onoffp));
  if (onoffp) { pushSTACK(O(object_Kverb_chkpoint)); count++; }
#endif
  return listof(count);
}
/* get the data directory list
 can trigger GC */
static object dbe_get_data_dirs (DB_ENV *dbe) {
  const char **dirs;
  SYSCALL(dbe->get_data_dirs,(dbe,&dirs));
  if (dirs) {
    int ii=0;
    for (; *dirs; dirs++, ii++)
      pushSTACK(asciz_to_string(*dirs,GLO(pathname_encoding)));
    return listof(ii);
  } else return NIL;
}
/* get the home directory
   return T when DBE is not yet open and a list otherwise
 can trigger GC */
static object dbe_get_home_dir (DB_ENV *dbe, int errorp) {
  const char *home;
  int status;
  begin_system_call();
  status = dbe->get_home(dbe,&home);
  end_system_call();
  if (status) {
    if (errorp) error_bdb(status,"dbe->get_home");
    error_message_reset(); return T;
  }
  if (home == NULL) return NIL;
  return asciz_to_string(home,GLO(pathname_encoding));
}
/* get the DBE open flags
   return T when DBE is not yet open and a list otherwise
 can trigger GC */
static object dbe_get_open_flags (DB_ENV *dbe, int errorp) {
  u_int32_t flags, status;
  begin_system_call();
  status = dbe->get_open_flags(dbe,&flags);
  end_system_call();
  if (status) {
    if (errorp) error_bdb(status,"dbe->get_open_flags");
    error_message_reset(); return T;
  }
  return check_dbe_open_flags_to_list(flags);
}
/* get the flags
 can trigger GC */
static object dbe_get_flags_list (DB_ENV *dbe) {
  u_int32_t count = 0, flags;
  SYSCALL(dbe->get_flags,(dbe,&flags));
  if (flags & DB_YIELDCPU) { pushSTACK(O(object_Kyieldcpu)); count++; }
  if (flags & DB_TXN_WRITE_NOSYNC) { pushSTACK(O(object_Ktxn_write_nosync));count++; }
  if (flags & DB_TXN_NOSYNC) { pushSTACK(O(object_Ktxn_nosync)); count++; }
  if (flags & DB_REGION_INIT) { pushSTACK(O(object_Kregion_init)); count++; }
  if (flags & DB_PANIC_ENVIRONMENT) {pushSTACK(O(object_Kpanic_environment));count++;}
  if (flags & DB_OVERWRITE) { pushSTACK(S(Koverwrite)); count++; }
  if (flags & DB_NOPANIC) { pushSTACK(O(object_Knopanic)); count++; }
  if (flags & DB_NOMMAP) { pushSTACK(O(object_Knommap)); count++; }
  if (flags & DB_NOLOCKING) { pushSTACK(O(object_Knolocking)); count++; }
  if (flags & DB_CDB_ALLDB) { pushSTACK(O(object_Kcdb_alldb)); count++; }
  if (flags & DB_AUTO_COMMIT) { pushSTACK(O(object_Kauto_commit)); count++; }
  SYSCALL(dbe->get_encrypt_flags,(dbe,&flags));
  switch (flags) {
    case DB_ENCRYPT_AES: pushSTACK(O(object_Kencrypt_aes)); count++; break;
    case 0: break;
    default: NOTREACHED;
  }
#if defined(HAVE_DB_ENV_LOG_SET_CONFIG)
#line 959
 #define LGC(c,l) do {                                               int onoff; SYSCALL(dbe->log_get_config,(dbe,c,&onoff));          if (onoff) { pushSTACK(l); count++; }                          } while(0)
  LGC(DB_LOG_DIRECT,O(object_Klog_direct));
  LGC(DB_LOG_DSYNC,O(object_Klog_dsync));
  LGC(DB_LOG_AUTO_REMOVE,O(object_Klog_auto_remove));
  LGC(DB_LOG_IN_MEMORY,O(object_Klog_in_memory));
  LGC(DB_LOG_ZERO,O(object_Klog_zero));
 #undef LGC
#else
# if defined(DB_LOG_INMEMORY)
  if (flags & DB_LOG_INMEMORY) { pushSTACK(O(object_Klog_in_memory)); count++; }
# endif
  if (flags & DB_LOG_AUTOREMOVE) { pushSTACK(O(object_Klog_auto_remove)); count++; }
# if defined(DB_DSYNC_LOG)
  if (flags & DB_DSYNC_LOG) { pushSTACK(O(object_Klog_dsync)); count++; }
# endif
  if (flags & DB_DIRECT_LOG) { pushSTACK(O(object_Klog_direct)); count++; }
#endif  /* HAVE_DB_ENV_LOG_SET_CONFIG */
  return listof(count);
}
#line 983
#define DEFINE_GETTER1(handle,handle_type,getter,type,finish)      static object handle##_##getter (handle_type* handle) {            type value;                                                      SYSCALL(handle->getter,(handle,&value));                         return finish;                                                 }
#define DEFINE_DBE_GETTER1(g,t,f)   DEFINE_GETTER1(dbe,DB_ENV,g,t,f)

DEFINE_DBE_GETTER1(get_tas_spins,u_int32_t,UL_to_I(value))
DEFINE_DBE_GETTER1(get_shm_key,long,value >= 0 ? fixnum(value) : NIL)
DEFINE_DBE_GETTER1(get_lk_detect,u_int32_t,check_lk_detect_reverse(value))
DEFINE_DBE_GETTER1(get_lk_max_lockers,u_int32_t,UL_to_I(value))
DEFINE_DBE_GETTER1(get_lk_max_locks,u_int32_t,UL_to_I(value))
DEFINE_DBE_GETTER1(get_lk_max_objects,u_int32_t,UL_to_I(value))
DEFINE_DBE_GETTER1(get_lg_bsize,u_int32_t,UL_to_I(value))
DEFINE_DBE_GETTER1(get_lg_dir,const char *,
                   asciz_to_string0(value,GLO(pathname_encoding)))
DEFINE_DBE_GETTER1(get_lg_max,u_int32_t,UL_to_I(value))
DEFINE_DBE_GETTER1(get_lg_regionmax,u_int32_t,UL_to_I(value))
DEFINE_DBE_GETTER1(get_tmp_dir,const char *,
                   asciz_to_string0(value,GLO(pathname_encoding)))
#if defined(HAVE_DB_ENV_GET_INTERMEDIATE_DIR_MODE)
DEFINE_DBE_GETTER1(get_intermediate_dir_mode,const char *,safe_to_string(value))
#endif
DEFINE_DBE_GETTER1(get_tx_max,u_int32_t,UL_to_I(value))
DEFINE_DBE_GETTER1(get_tx_timestamp,time_t,convert_time_to_universal(&value))

/* get timeout values for locks or transactions in the database environment */
static object dbe_get_timeout (DB_ENV *dbe, u_int32_t which) {
  db_timeout_t timeout;
  SYSCALL(dbe->get_timeout,(dbe,&timeout,which));
  return UL_to_I(timeout);
}
/* both timeouts as a list
 can trigger GC */
static object dbe_get_timeouts (DB_ENV *dbe) {
  pushSTACK(dbe_get_timeout(dbe,DB_SET_LOCK_TIMEOUT));
  pushSTACK(dbe_get_timeout(dbe,DB_SET_TXN_TIMEOUT));
  return listof(2);
}
/* conflicts table as a bit matrix
 can trigger GC */
static object dbe_get_lk_conflicts (DB_ENV *dbe) {
  int nmodes;
  const u_int8_t *conflicts;
  SYSCALL(dbe->get_lk_conflicts,(dbe,&conflicts,&nmodes));
  pushSTACK(fixnum(nmodes)); pushSTACK(fixnum(nmodes));
  value1 = listof(2); pushSTACK(value1);
  pushSTACK(S(Kelement_type)); pushSTACK(GLO(strmtype_ubyte8));
  funcall(L(make_array),3);
  {
    uintL size = nmodes*nmodes, index = 0;
    object data = array_displace_check(value1,size,&index);
    begin_system_call();
    memcpy(TheSbvector(data)->data+index,conflicts,size);
    end_system_call();
  }
  return value1;
}
#if !defined(DB_GID_SIZE)
# define DB_GID_SIZE DB_XIDDATASIZE
#endif
FLAG_EXTRACTOR(dbe_get_flags_num,DB_ENV*)
DEFUNR(BDB:DBE-GET-OPTIONS, dbe &optional what,(subr_bdb_dbe_get_options,seclass_default,1,1,norest,nokey,0,NIL)) {
  object what = STACK_0;
  /* dbe may be NULL only for DB_GID_SIZE */
  DB_ENV *dbe = (DB_ENV*)bdb_handle(STACK_1,O(object_bdb__dbe),
                                    eq(what,O(object_Kdb_gid_size))
                                    ? BH_NIL_IS_NULL : BH_VALID);
  what = STACK_0; skipSTACK(2);
 restart_DBE_GET_OPTIONS:
  if (missingp(what)) {         /* get everything */
    uintL count = 0;
    pushSTACK(S(Kverbose)); value1 = dbe_get_verbose(dbe);
    pushSTACK(value1); count++;
    pushSTACK(O(object_Kcache)); dbe_get_cache(dbe,false);
    pushSTACK(value1); pushSTACK(value2); value1 = listof(2);
    pushSTACK(value1); count++;
    pushSTACK(O(object_Kflags)); value1 = dbe_get_flags_list(dbe);
    pushSTACK(value1); count++;
    pushSTACK(O(object_Ktimestamp)); pushSTACK(dbe_get_tx_timestamp(dbe)); count++;
    pushSTACK(O(object_Ktx_max)); pushSTACK(dbe_get_tx_max(dbe)); count++;
#  if defined(HAVE_DB_ENV_GET_INTERMEDIATE_DIR_MODE)
    pushSTACK(O(object_Kintermediate_dir_mode)); pushSTACK(dbe_get_intermediate_dir_mode(dbe)); count++;
#  endif
    pushSTACK(O(object_Ktmp_dir)); pushSTACK(dbe_get_tmp_dir(dbe)); count++;
    pushSTACK(O(object_Kdata_dir)); value1 = dbe_get_data_dirs(dbe);
    pushSTACK(value1); count++;
    pushSTACK(O(object_Ktas_spins)); pushSTACK(dbe_get_tas_spins(dbe)); count++;
    pushSTACK(O(object_Kshm_key)); pushSTACK(dbe_get_shm_key(dbe)); count++;
    pushSTACK(O(object_Kerrpfx)); pushSTACK(dbe_get_errpfx(dbe)); count++;
    pushSTACK(O(object_Kerrfile)); pushSTACK(dbe_get_errfile(dbe)); count++;
    pushSTACK(O(object_Kmsgfile)); pushSTACK(dbe_get_msgfile(dbe)); count++;
    pushSTACK(O(object_Ktimeout)); value1 = dbe_get_timeouts(dbe);
    pushSTACK(value1); count++;
    pushSTACK(O(object_Klg_bsize)); pushSTACK(dbe_get_lg_bsize(dbe)); count++;
    pushSTACK(O(object_Klg_dir)); pushSTACK(dbe_get_lg_dir(dbe)); count++;
    pushSTACK(O(object_Klg_max)); pushSTACK(dbe_get_lg_max(dbe)); count++;
    pushSTACK(O(object_Klg_regionmax)); pushSTACK(dbe_get_lg_regionmax(dbe)); count++;
    pushSTACK(O(object_Klk_conflicts)); pushSTACK(dbe_get_lk_conflicts(dbe)); count++;
    pushSTACK(O(object_Klk_detect)); pushSTACK(dbe_get_lk_detect(dbe)); count++;
    pushSTACK(O(object_Klk_max_lockers));pushSTACK(dbe_get_lk_max_lockers(dbe));count++;
    pushSTACK(O(object_Klk_max_locks)); pushSTACK(dbe_get_lk_max_locks(dbe)); count++;
    pushSTACK(O(object_Klk_max_objects));pushSTACK(dbe_get_lk_max_objects(dbe));count++;
    pushSTACK(O(object_Khomedir)); pushSTACK(dbe_get_home_dir(dbe,false)); count++;
    pushSTACK(O(object_Kopen)); value1 = dbe_get_open_flags(dbe,false);
    pushSTACK(value1); count++;
    VALUES1(listof(count*2));
  } else if (eq(what,S(Kverbose))) {
    VALUES1(dbe_get_verbose(dbe));
  } else if (eq(what,O(object_Kcache))) {
    dbe_get_cache(dbe,true); mv_count = 2;
  } else if (eq(what,O(object_Kflags))) {
    VALUES1(dbe_get_flags_list(dbe));
  } else if (eq(what,O(object_Kverb_waitsfor))) {
    int onoffp;
    SYSCALL(dbe->get_verbose,(dbe,DB_VERB_WAITSFOR,&onoffp));
    VALUES_IF(onoffp);
  } else if (eq(what,O(object_Kverb_replication))) {
    int onoffp;
    SYSCALL(dbe->get_verbose,(dbe,DB_VERB_REPLICATION,&onoffp));
    VALUES_IF(onoffp);
  } else if (eq(what,O(object_Kverb_recovery))) {
    int onoffp;
    SYSCALL(dbe->get_verbose,(dbe,DB_VERB_RECOVERY,&onoffp));
    VALUES_IF(onoffp);
  } else if (eq(what,O(object_Kverb_deadlock))) {
    int onoffp;
    SYSCALL(dbe->get_verbose,(dbe,DB_VERB_DEADLOCK,&onoffp));
    VALUES_IF(onoffp);
#if defined(DB_VERB_CHKPOINT)
  } else if (eq(what,O(object_Kverb_chkpoint))) {
    int onoffp;
    SYSCALL(dbe->get_verbose,(dbe,DB_VERB_CHKPOINT,&onoffp));
    VALUES_IF(onoffp);
#endif
  } else if (eq(what,O(object_Kyieldcpu))) {
    VALUES_IF(dbe_get_flags_num(dbe) & DB_YIELDCPU);
  } else if (eq(what,O(object_Ktxn_write_nosync))) {
    VALUES_IF(dbe_get_flags_num(dbe) & DB_TXN_WRITE_NOSYNC);
  } else if (eq(what,O(object_Ktxn_nosync))) {
    VALUES_IF(dbe_get_flags_num(dbe) & DB_TXN_NOSYNC);
  } else if (eq(what,O(object_Kregion_init))) {
    VALUES_IF(dbe_get_flags_num(dbe) & DB_REGION_INIT);
  } else if (eq(what,O(object_Kpanic_environment))) {
    VALUES_IF(dbe_get_flags_num(dbe) & DB_PANIC_ENVIRONMENT);
  } else if (eq(what,S(Koverwrite))) {
    VALUES_IF(dbe_get_flags_num(dbe) & DB_OVERWRITE);
  } else if (eq(what,O(object_Knopanic))) {
    VALUES_IF(dbe_get_flags_num(dbe) & DB_NOPANIC);
  } else if (eq(what,O(object_Knommap))) {
    VALUES_IF(dbe_get_flags_num(dbe) & DB_NOMMAP);
  } else if (eq(what,O(object_Knolocking))) {
    VALUES_IF(dbe_get_flags_num(dbe) & DB_NOLOCKING);
#if defined(DB_LOG_INMEMORY)
  } else if (eq(what,O(object_Klog_in_memory))) {
    VALUES_IF(dbe_get_flags_num(dbe) & DB_LOG_INMEMORY);
#endif
  } else if (eq(what,O(object_Klog_auto_remove))) {
#if defined(DB_LOG_AUTO_REMOVE)
    VALUES_IF(dbe_get_flags_num(dbe) & DB_LOG_AUTO_REMOVE);
#else
    VALUES_IF(dbe_get_flags_num(dbe) & DB_LOG_AUTOREMOVE);
#endif
  } else if (eq(what,O(object_Klog_dsync))) {
#  if defined(DB_DSYNC_LOG)
    VALUES_IF(dbe_get_flags_num(dbe) & DB_DSYNC_LOG);
#  elif defined(DB_LOG_DSYNC)
    VALUES_IF(dbe_get_flags_num(dbe) & DB_LOG_DSYNC);
#  else
    VALUES1(NIL);
#  endif
  } else if (eq(what,O(object_Klog_direct))) {
#  if defined(DB_LOG_DIRECT)
    VALUES_IF(dbe_get_flags_num(dbe) & DB_LOG_DIRECT);
#  else
    VALUES_IF(dbe_get_flags_num(dbe) & DB_DIRECT_LOG);
#  endif
  } else if (eq(what,O(object_Kcdb_alldb))) {
    VALUES_IF(dbe_get_flags_num(dbe) & DB_CDB_ALLDB);
  } else if (eq(what,O(object_Kauto_commit))) {
    VALUES_IF(dbe_get_flags_num(dbe) & DB_AUTO_COMMIT);
  } else if (eq(what,O(object_Klg_bsize))) {
    VALUES1(dbe_get_lg_bsize(dbe));
  } else if (eq(what,O(object_Klg_dir))) {
    VALUES1(dbe_get_lg_dir(dbe));
  } else if (eq(what,O(object_Klg_max))) {
    VALUES1(dbe_get_lg_max(dbe));
  } else if (eq(what,O(object_Klg_regionmax))) {
    VALUES1(dbe_get_lg_regionmax(dbe));
  } else if (eq(what,O(object_Klk_conflicts))) {
    VALUES1(dbe_get_lk_conflicts(dbe));
  } else if (eq(what,O(object_Klk_detect))) {
    VALUES1(dbe_get_lk_detect(dbe));
  } else if (eq(what,O(object_Klk_max_lockers))) {
    VALUES1(dbe_get_lk_max_lockers(dbe));
  } else if (eq(what,O(object_Klk_max_locks))) {
    VALUES1(dbe_get_lk_max_locks(dbe));
  } else if (eq(what,O(object_Klk_max_objects))) {
    VALUES1(dbe_get_lk_max_objects(dbe));
  } else if (eq(what,O(object_Ktx_timestamp))) {
    VALUES1(dbe_get_tx_timestamp(dbe));
  } else if (eq(what,O(object_Ktx_max))) {
    VALUES1(dbe_get_tx_max(dbe));
  } else if (eq(what,O(object_Kdata_dir))) {
    VALUES1(dbe_get_data_dirs(dbe));
  } else if (eq(what,O(object_Ktmp_dir))) {
    VALUES1(dbe_get_tmp_dir(dbe));
#if defined(HAVE_DB_ENV_GET_INTERMEDIATE_DIR_MODE)
  } else if (eq(what,O(object_Kintermediate_dir_mode))) {
    VALUES1(dbe_get_intermediate_dir_mode(dbe));
#endif
  } else if (eq(what,O(object_Ktas_spins))) {
    VALUES1(dbe_get_tas_spins(dbe));
  } else if (eq(what,O(object_Kshm_key))) {
    VALUES1(dbe_get_shm_key(dbe));
  } else if (eq(what,O(object_Klock_timeout))) {
    VALUES1(dbe_get_timeout(dbe,DB_SET_LOCK_TIMEOUT));
  } else if (eq(what,O(object_Ktxn_timeout))) {
    VALUES1(dbe_get_timeout(dbe,DB_SET_TXN_TIMEOUT));
  } else if (eq(what,O(object_Ktimeout))) {
    VALUES1(dbe_get_timeouts(dbe));
  } else if (eq(what,O(object_Kencrypt))) {
    u_int32_t flags;
    SYSCALL(dbe->get_encrypt_flags,(dbe,&flags));
    switch (flags) {
      case DB_ENCRYPT_AES: VALUES1(O(object_Kencrypt_aes));
      case 0: VALUES1(NIL);
      default: NOTREACHED;
    }
  } else if (eq(what,O(object_Kerrpfx))) {
    VALUES1(dbe_get_errpfx(dbe));
  } else if (eq(what,O(object_Kerrfile))) {
    VALUES1(dbe_get_errfile(dbe));
  } else if (eq(what,O(object_Kmsgfile))) {
    VALUES1(dbe_get_msgfile(dbe));
  } else if (eq(what,O(object_Kdb_gid_size))) {
    VALUES1(fixnum(DB_GID_SIZE));
  } else if (eq(what,O(object_Khome))) {
    VALUES1(dbe_get_home_dir(dbe,true));
  } else if (eq(what,O(object_Kopen))) {
    VALUES1(dbe_get_open_flags(dbe,true));
  } else {
    pushSTACK(NIL);             /* no PLACE */
    pushSTACK(what); pushSTACK(TheSubr(subr_self)->name);
    check_value(error_condition,GETTEXT("~S: invalid argument ~S"));
    what = value1;
    goto restart_DBE_GET_OPTIONS;
  }
}

/* ===== Database Operations ===== */

/* not exported:
 DB->associate	Associate a secondary index
 DB->err	Error message with error string
 DB->errx	Error message
*/

DEFUN(BDB:DB-CREATE, dbe,(subr_bdb_db_create,seclass_default,1,0,norest,nokey,0,NIL))
{ /* create database */
  DB_ENV *dbe = (DB_ENV*)bdb_handle(STACK_0,O(object_bdb__dbe),BH_NIL_IS_NULL);
  DB *db;
  SYSCALL(db_create,(&db,dbe,0));
  if (!dbe) {                   /* set error callback */
    begin_system_call();
    db->set_errcall(db,&error_callback);
    end_system_call();
  }
  wrap_finalize(db,STACK_0,O(object_bdb__mkdb),F(subr_bdb_db_close));
  skipSTACK(1);
}

DEFUN(BDB:DB-CLOSE, db &key NOSYNC,(subr_bdb_db_close,seclass_default,1,0,norest,key,1,NIL))
{ /* Close a database */
  u_int32_t flags = missingp(STACK_0) ? 0 : DB_NOSYNC;
  DB *db = (DB*)bdb_handle(STACK_1,O(object_bdb__db),BH_INVALIDATE);
  if (db) {
    bool orphan_p = nullp(Parents(STACK_1));
    pushSTACK(STACK_1); funcall(O(object_bdb__kill_handle),1);
    if (orphan_p) {
      DB_ENV *dbe = db->get_env(db);
      close_errfile(dbe);
      close_errpfx(dbe);
      close_msgfile(dbe);
    }
    SYSCALL(db->close,(db,flags));
    VALUES1(T);
  } else VALUES1(NIL);
  skipSTACK(2);
}

/* zero-out DBT and set allocation */
static void init_dbt (DBT* p_dbt , u_int32_t flags) {
  begin_system_call(); memset(p_dbt,0,sizeof(DBT)); end_system_call();
  p_dbt->flags = flags;
}

/* ensure that the return value is a byte vector of specified length
 can trigger GC */
static object check_byte_vector_len (object obj, int length) {
 check_byte_vector_len_restart:
  obj = check_byte_vector(obj);
  if (length > 0 &&  length!=vector_length(obj)) {
    pushSTACK(NIL);             /* no PLACE */
    pushSTACK(fixnum(length)); pushSTACK(obj);
    pushSTACK(TheSubr(subr_self)->name);
    check_value(error_condition,GETTEXT("~S: byte vector ~S should have length ~S"));
    obj = value1;
    goto check_byte_vector_len_restart;
  }
  return obj;
}

#line 1293

/* check that the argument can be converted to a DBT
 can trigger GC */
static object check_dbt_object (object obj) {
  while (!bit_vector_p(Atype_8Bit,obj) && !stringp(obj)
         && !(integerp(obj) && positivep(obj))) {
    pushSTACK(NIL);             /* no PLACE */
    pushSTACK(obj);             /* TYPE-ERROR slot DATUM */
    pushSTACK(O(object__28or_20string_20_28integer_200_29_20_28vector_20_28unsigned_byte_29_29_29));/*EXPECTED-TYPE*/
    pushSTACK(obj); pushSTACK(TheSubr(subr_self)->name);
    check_value(type_error,GETTEXT("~S: ~S is neither string, nonnegative integer nor byte vector"));
    obj = value1;
  }
  return obj;
}

#if SIZEOF_DB_RECNO_T == 8
# define db_recno_p(i)     uint64_p(i)
# define db_recno_to_I(r)  uint64_to_I(r)
# define I_to_db_recno(i)  I_to_uint64(check_uint64(i))
#elif SIZEOF_DB_RECNO_T == 4
# define db_recno_p(i)     uint32_p(i)
# define db_recno_to_I(r)  uint32_to_I(r)
# define I_to_db_recno(i)  I_to_uint32(check_uint32(i))
#else
# error db_recno_t size if unknown!
#endif
/* fill a DBT with contents of obj (a byte vector, string, or positive integer)
 dbt_type, when non-NULL, will contain the argument type
 when re_len is > 0, the database has fixed-record-length,
  so the integer will be padded on the left
  if re_len = -1, this is a key and it will be required to be a db_recno_t
   <http://www.sleepycat.com/docs/ref/am_conf/logrec.html>:
     In all cases for the Queue and Recno access methods, and when
     calling the Btree access method using the DB->get and
     DBcursor->c_get methods with the DB_SET_RECNO flag specified, the
     data field of the key DBT must be a pointer to a memory location of
     type db_recno_t <...>. The size field of the key DBT should be the
     size of that type (for example, "sizeof(db_recno_t)" in the C
     programming language). The db_recno_t type is a 32-bit unsigned
     type, which limits the number of logical records in a Queue or
     Recno database, and the maximum logical record which may be
     directly retrieved from a Btree database, to 4,294,967,295.
 can trigger GC */
static dbt_o_t fill_dbt (object obj, DBT* key, int re_len)
{
 restart_fill_dbt:
  obj = check_dbt_object(obj);
  init_dbt(key,DB_DBT_MALLOC);
  if (re_len==-1) {
    db_recno_t value = I_to_db_recno(obj);
    key->data = clisp_malloc(key->ulen = key->size = sizeof(db_recno_t));
    *(db_recno_t*)key->data = value;
    return DBT_INTEGER;
  } else if (stringp(obj)) {
    with_string_0(obj,GLO(misc_encoding),linez, {
        key->ulen = key->size = linez_bytelen;
        key->data = clisp_malloc(linez_bytelen);
        begin_system_call();
        memcpy(key->data,linez,linez_bytelen);
        end_system_call();
      });
    return DBT_STRING;
  } else if (bit_vector_p(Atype_8Bit,obj)) {
    uintL idx = 0;
    void *data_start;
    key->ulen = key->size = vector_length(obj);
    obj = array_displace_check(obj,key->size,&idx);
    data_start = TheSbvector(obj)->data + idx;
    /* no need to pin obj because memcpy does not block */
    handle_fault_range(PROT_READ,(aint)data_start,(aint)data_start + key->size);
    key->data = clisp_malloc(key->size);
    begin_system_call();
    memcpy(key->data,data_start,key->size);
    end_system_call();
    return DBT_RAW;
  } else if (integerp(obj)) { /* known to be positive from check_dbt_object() */
    unsigned long bitsize = 1+I_integer_length(obj); /* an extra sign bit */
    unsigned long bytesize = ceiling(bitsize,8);
    if (re_len) {
      if (bytesize > re_len) {
        pushSTACK(fixnum(bytesize)); pushSTACK(fixnum(re_len));
        pushSTACK(obj); pushSTACK(TheSubr(subr_self)->name);
        check_value(error_condition,GETTEXT("~S: ~S does not fit into ~S bytes (it requires at least ~S bytes)"));
        obj = value1;
        goto restart_fill_dbt;
      } else bytesize = re_len;
    }
    key->ulen = key->size = bytesize;
    key->data = clisp_malloc(bytesize);
    if (I_to_LEbytes(obj,8*bytesize,(uintB*)key->data))
      NOTREACHED;               /* there must not be an overflow! */
#  if defined(DEBUG)
    ASSERT(eql(LEbytes_to_I(bytesize,(uintB*)key->data),obj));
#  endif
    return DBT_INTEGER;
  } else NOTREACHED;
}
static void free_dbt(DBT* dbt) {
  begin_system_call(); FREE_RESET(dbt->data); end_system_call();
}

/* convert a DBT to an object of the specified type
 p_dbt->data is free()d and set to NULL
 can trigger GC */
static object dbt_to_object (DBT *p_dbt, dbt_o_t type, int key_type) {
  if (p_dbt->data == NULL) return NIL;
  switch (type) {
    case DBT_RAW: {
      object vec = allocate_bit_vector(Atype_8Bit,p_dbt->size);
      void* data = TheSbvector(vec)->data;
      /* no need to pin vec because memcpy does not block */
      handle_fault_range(PROT_READ_WRITE,(aint)data,(aint)data + p_dbt->size);
      begin_system_call();
      memcpy(data,p_dbt->data,p_dbt->size);
      free(p_dbt->data); p_dbt->data = NULL;
      end_system_call();
      return vec;
    }
    case DBT_STRING: {
      object s = n_char_to_string((char*)p_dbt->data,p_dbt->size,
                                  GLO(misc_encoding));
      free_dbt(p_dbt);
      return s;
    }
    case DBT_INTEGER:
      if (key_type == -1) {
        if (p_dbt->size == sizeof(db_recno_t)) {
          db_recno_t res = *(db_recno_t*)p_dbt->data;
          free_dbt(p_dbt);
          return db_recno_to_I(res);
        } else {
          pushSTACK(O(object_bdb__bdb_error));  /* error type */
          pushSTACK(S(Kcode)); pushSTACK(NIL);
          pushSTACK(O(object__22_7Es__20bad_20logical_20record_20number_20size__20_7Es_20should_20be_20_7Es_22));
          pushSTACK(TheSubr(subr_self)->name);
          pushSTACK(uint32_to_I(p_dbt->size));
          pushSTACK(uint32_to_I(sizeof(db_recno_t)));
          funcall(L(error_of_type),7);
        }
      } else {
        object ret = LEbytes_to_I(p_dbt->size,(uintB*)p_dbt->data);
#      if defined(DEBUG)
        uintB *tmp = (uintB*)alloca(p_dbt->size);
        memset(tmp,0,p_dbt->size);
        I_to_LEbytes(ret,1+I_integer_length(ret),tmp);
        ASSERT(!strncmp(tmp,p_dbt->data,p_dbt->size));
#      endif
        free_dbt(p_dbt);
        return ret;
      }
    default: NOTREACHED;
  }
}

/* get the type of the DB */
static inline DBTYPE db_get_type (DB *db) {
  DBTYPE db_type;
  SYSCALL(db->get_type,(db,&db_type));
  return db_type;
}

/* extract record length, not errors */
static u_int32_t record_length (DB *db) {
  switch (db_get_type(db)) {
    case DB_RECNO: case DB_QUEUE: {
      u_int32_t ret;
      int status;
      begin_system_call();
      status = db->get_re_len(db,&ret);
      end_system_call();
      if (status) {
        error_message_reset();
        return 0;
      } else return ret;
    }
    default: return 0;
  }
}
/* check whether the DB uses logical record numbers, see
 <http://www.sleepycat.com/docs/ref/am_conf/logrec.html> */
static inline int db_key_type (DB *db, u_int32_t action) {
  switch (db_get_type(db)) {
    case DB_QUEUE: case DB_RECNO: return -1;
    case DB_BTREE: switch (action) {
      case DB_GET_RECNO: case DB_SET_RECNO: return -1;
      default: return 0;
    }
    default: return 0;
  }
}

DEFUN(BDB:DB-DEL, dbe key &key TRANSACTION AUTO-COMMIT,(subr_bdb_db_del,seclass_default,2,0,norest,key,2,NIL))
{ /* Delete items from a database */
  u_int32_t flags = bdb_ac_flags();
  DB_TXN *txn = (DB_TXN*)bdb_handle(popSTACK(),O(object_bdb__txn),BH_NIL_IS_NULL);
  DB *db = (DB*)bdb_handle(STACK_1,O(object_bdb__db),BH_VALID);
  DBT key;
  fill_dbt(STACK_0,&key,db_key_type(db,0));
  SYSCALL1(db->del,(db,txn,&key,flags),{free(key.data);});
  skipSTACK(2);
  VALUES0;
}

DEFUN(BDB:DB-FD, db,(subr_bdb_db_fd,seclass_default,1,0,norest,nokey,0,NIL))
{ /* Return a file descriptor from a database */
  DB *db = (DB*)bdb_handle(popSTACK(),O(object_bdb__db),BH_VALID);
  int fd;
  SYSCALL(db->fd,(db,&fd));
  VALUES1(fixnum(fd));
}

#line 1506

#line 1508

#line 1510
DEFUN(BDB:DB-GET, db key &key ACTION AUTO-COMMIT READ-COMMITTED        READ-UNCOMMITTED MULTIPLE RMW TRANSACTION :ERROR :TYPE :KEY-TYPE,(subr_bdb_db_get,seclass_default,2,0,norest,key,10,NIL))
{ /* Get items from a database */
  dbt_o_t key_type = check_dbt_type(popSTACK());
  dbt_o_t out_type = check_dbt_type(popSTACK());
  int no_error = nullp(popSTACK());
  DB_TXN *txn = (DB_TXN*)bdb_handle(popSTACK(),O(object_bdb__txn),BH_NIL_IS_NULL);
  u_int32_t flags = db_get_options();
  u_int32_t action = db_get_action(popSTACK());
  DB *db = (DB*)bdb_handle(STACK_1,O(object_bdb__db),BH_VALID);
  DBT key, val;
  int status;
  fill_dbt(STACK_0,&key,db_key_type(db,action));
  init_dbt(&val,DB_DBT_MALLOC);
  skipSTACK(2);
  begin_blocking_system_call();
  status = db->get(db,txn,&key,&val,flags | action);
  end_blocking_system_call();
  if (status) {
    free_dbt(&key);
    if (no_error) {
      switch (status) {
        case DB_NOTFOUND: VALUES1(O(object_Knotfound)); error_message_reset(); return;
        case DB_KEYEMPTY: VALUES1(O(object_Kkeyempty)); error_message_reset(); return;
      }
    }
    error_bdb(status,"db->get");
  }
  if (action == DB_SET_RECNO) {
    pushSTACK(dbt_to_object(&key,key_type,0));
    value2 = dbt_to_object(&val,out_type,0);
    value1 = popSTACK();
    mv_count = 2;
  } else
    VALUES1(dbt_to_object(&val,out_type,0));
}

#line 1547

DEFUN(BDB:DB-STAT, db &key FAST-STAT TRANSACTION,(subr_bdb_db_stat,seclass_default,1,0,norest,key,2,NIL))
{ /* Return database statistics */
  DB_TXN *txn = (DB_TXN*)bdb_handle(popSTACK(),O(object_bdb__txn),BH_NIL_IS_NULL);
#if defined(HAVE_DB_STAT_ACCEPT_TXN)
# define DB_STAT(s)   SYSCALL(db->stat,(db,txn,&s,flags));
#else
# define DB_STAT(s)   SYSCALL(db->stat,(db,&s,flags));
#endif
  u_int32_t flags = missingp(STACK_0) ? 0 : DB_FAST_STAT;
  DB *db = (DB*)bdb_handle(STACK_1,O(object_bdb__db),BH_VALID);
  int swapped_p;
  DBTYPE db_type = db_get_type(db);
  unsigned int count = 0;
  pushSTACK(check_dbtype_reverse(db_type)); count++;
  SYSCALL(db->get_byteswapped,(db,&swapped_p));
  pushSTACK(swapped_p ? T : NIL); count++;
  switch (db_type) {
#define STAT_SLOT(slot)        pushSTACK(UL_to_I(slot)); count++
#define STAT_SLOT_FAST(slot)   pushSTACK(flags ? NIL : UL_to_I(slot)); count++
    case DB_HASH: {
      DB_HASH_STAT *hash_stat;
      DB_STAT(hash_stat);
      STAT_SLOT(hash_stat->hash_magic);
      STAT_SLOT(hash_stat->hash_version);
      STAT_SLOT(hash_stat->hash_nkeys);
      STAT_SLOT(hash_stat->hash_ndata);
      STAT_SLOT(hash_stat->hash_pagesize);
      STAT_SLOT(hash_stat->hash_ffactor);
      STAT_SLOT(hash_stat->hash_buckets);
      STAT_SLOT_FAST(hash_stat->hash_free);
      STAT_SLOT_FAST(hash_stat->hash_bfree);
      STAT_SLOT_FAST(hash_stat->hash_bigpages);
      STAT_SLOT_FAST(hash_stat->hash_big_bfree);
      STAT_SLOT_FAST(hash_stat->hash_overflows);
      STAT_SLOT_FAST(hash_stat->hash_ovfl_free);
      STAT_SLOT_FAST(hash_stat->hash_dup);
      STAT_SLOT_FAST(hash_stat->hash_dup_free);
      funcall(O(object_bdb__mkdbstat_hash),count);
      begin_system_call(); free(hash_stat); end_system_call();
    } break;
    case DB_BTREE: case DB_RECNO: {
      DB_BTREE_STAT *btree_stat;
      DB_STAT(btree_stat);
      STAT_SLOT(btree_stat->bt_magic);
      STAT_SLOT(btree_stat->bt_version);
      STAT_SLOT(btree_stat->bt_nkeys);
      STAT_SLOT(btree_stat->bt_ndata);
      STAT_SLOT(btree_stat->bt_pagesize);
      STAT_SLOT(btree_stat->bt_minkey);
      STAT_SLOT(btree_stat->bt_re_len);
      STAT_SLOT(btree_stat->bt_re_pad);
      STAT_SLOT_FAST(btree_stat->bt_levels);
      STAT_SLOT_FAST(btree_stat->bt_int_pg);
      STAT_SLOT_FAST(btree_stat->bt_leaf_pg);
      STAT_SLOT_FAST(btree_stat->bt_dup_pg);
      STAT_SLOT_FAST(btree_stat->bt_over_pg);
      STAT_SLOT_FAST(btree_stat->bt_free);
      STAT_SLOT_FAST(btree_stat->bt_int_pgfree);
      STAT_SLOT_FAST(btree_stat->bt_leaf_pgfree);
      STAT_SLOT_FAST(btree_stat->bt_dup_pgfree);
      STAT_SLOT_FAST(btree_stat->bt_over_pgfree);
      funcall(O(object_bdb__mkdbstat_btree),count);
      begin_system_call(); free(btree_stat); end_system_call();
    } break;
    case DB_QUEUE: {
      DB_QUEUE_STAT *queue_stat;
      DB_STAT(queue_stat);
      STAT_SLOT(queue_stat->qs_magic);
      STAT_SLOT(queue_stat->qs_version);
      STAT_SLOT(queue_stat->qs_nkeys);
      STAT_SLOT(queue_stat->qs_ndata);
      STAT_SLOT(queue_stat->qs_pagesize);
      STAT_SLOT(queue_stat->qs_extentsize);
      STAT_SLOT_FAST(queue_stat->qs_pages);
      STAT_SLOT(queue_stat->qs_re_len);
      STAT_SLOT(queue_stat->qs_re_pad);
      STAT_SLOT_FAST(queue_stat->qs_pgfree);
      STAT_SLOT(queue_stat->qs_first_recno);
      STAT_SLOT(queue_stat->qs_cur_recno);
      funcall(O(object_bdb__mkdbstat_queue),count);
      begin_system_call(); free(queue_stat); end_system_call();
    } break;
    default: NOTREACHED;
#undef STAT_SLOT
#undef STAT_SLOT_FAST
#undef DB_STAT
  }
  skipSTACK(2);
}

#line 1639

#line 1642

#line 1645
DEFUN(BDB:DB-OPEN, db file &key DATABASE :TYPE MODE FLAGS                   :CREATE READ-UNCOMMITTED EXCL NOMMAP RDONLY THREAD TRUNCATE           AUTO-COMMIT TRANSACTION,(subr_bdb_db_open,seclass_default,2,0,norest,key,13,NIL))
{ /* Open a database */
  DB_TXN *txn = (DB_TXN*)bdb_handle(popSTACK(),O(object_bdb__txn),BH_NIL_IS_NULL);
  u_int32_t flags = db_open_flags() | check_db_open_flags_of_list(popSTACK());
  int mode = check_uint_defaulted(popSTACK(),0644);
  DBTYPE db_type = check_dbtype(popSTACK());
  DB *db = (DB*)bdb_handle(STACK_2,O(object_bdb__db),BH_VALID);
  /* string is resolved by Berkeley-DB relative to data_dirs */
  with_string_0((stringp(STACK_1) ? (object)STACK_1
                 : physical_namestring(STACK_1)),
                GLO(pathname_encoding),file, {
      if (missingp(STACK_0)) {  /* no :DATABASE */
        SYSCALL(db->open,(db,txn,file,NULL,db_type,flags,mode));
      } else                    /* multiple databases in one file */
        with_string_0(check_string(STACK_0),GLO(misc_encoding),databse, {
            SYSCALL(db->open,(db,txn,file,databse,db_type,flags,mode));
          });
    });
  VALUES0;
  skipSTACK(3);
}

DEFUN(BDB:DB-SYNC, db,(subr_bdb_db_sync,seclass_default,1,0,norest,nokey,0,NIL))
{ /* Flush a database to stable storage */
  DB *db = (DB*)bdb_handle(popSTACK(),O(object_bdb__db),BH_VALID);
  SYSCALL(db->sync,(db,0));
  VALUES0;
}

DEFUN(BDB:DB-TRUNCATE, db &key TRANSACTION AUTO-COMMIT,(subr_bdb_db_truncate,seclass_default,1,0,norest,key,2,NIL))
{ /* Empty a database */
  u_int32_t flags = bdb_ac_flags();
  DB_TXN *txn = (DB_TXN*)bdb_handle(popSTACK(),O(object_bdb__txn),BH_NIL_IS_NULL);
  DB *db = (DB*)bdb_handle(popSTACK(),O(object_bdb__db),BH_VALID);
  u_int32_t count;
  SYSCALL(db->truncate,(db,txn,&count,flags));
  VALUES1(UL_to_I(count));
}

DEFUN(BDB:DB-UPGRADE, db file &key DUPSORT,(subr_bdb_db_upgrade,seclass_default,2,0,norest,key,1,NIL))
{ /* Upgrade a database */
  u_int32_t flags = (missingp(STACK_0) ? 0 : DB_DUPSORT);
  DB *db = (DB*)bdb_handle(STACK_2,O(object_bdb__db),BH_VALID);
  with_string_0(physical_namestring(STACK_1),GLO(pathname_encoding),file, {
      SYSCALL(db->upgrade,(db,file,flags));
    });
  VALUES0; skipSTACK(3);
}

DEFUN(BDB:DB-RENAME, db file database newname,(subr_bdb_db_rename,seclass_default,4,0,norest,nokey,0,NIL))
{ /* Rename a database */
  DB *db = (DB*)bdb_handle(STACK_3,O(object_bdb__db),BH_VALID);
  with_string_0(physical_namestring(STACK_2),GLO(pathname_encoding),file, {
      with_string_0(check_string(STACK_0),GLO(misc_encoding),newname, {
          if (nullp(STACK_1))   /* database=NIL */
            SYSCALL(db->rename,(db,file,NULL,newname,0));
          else
            with_string_0(check_string(STACK_1),GLO(misc_encoding),database, {
                SYSCALL(db->rename,(db,file,database,newname,0));
              });
        });
    });
  VALUES0; skipSTACK(4);
}

DEFUN(BDB:DB-REMOVE, db file database,(subr_bdb_db_remove,seclass_default,3,0,norest,nokey,0,NIL))
{ /* Remove a database */
  DB *db = (DB*)bdb_handle(STACK_2,O(object_bdb__db),BH_VALID);
  with_string_0(physical_namestring(STACK_1),GLO(pathname_encoding),file, {
      with_string_0(check_string(STACK_0),GLO(misc_encoding),database, {
          SYSCALL(db->remove,(db,file,database,0));
        });
    });
  VALUES0; skipSTACK(3);
}


DEFUN(BDB:DB-PUT, db key val &key AUTO-COMMIT ACTION TRANSACTION,(subr_bdb_db_put,seclass_default,3,0,norest,key,3,NIL))
{ /* Store items into a database */
  DB_TXN *txn = (DB_TXN*)bdb_handle(popSTACK(),O(object_bdb__txn),BH_NIL_IS_NULL);
  u_int32_t action = db_put_action(popSTACK());
  u_int32_t flags = bdb_ac_flags();
  DB *db = (DB*)bdb_handle(STACK_2,O(object_bdb__db),BH_VALID);
  DBT key, val;
  fill_dbt(STACK_0,&val,record_length(db));
  if (action == DB_APPEND) {     /* DB is :QUEUE or :RECNO */
    init_dbt(&key,DB_DBT_MALLOC); /* key is ignored - it will be returned */
    SYSCALL1(db->put,(db,txn,&key,&val,action | flags),{free(val.data);});
    VALUES1(dbt_to_object(&key,DBT_INTEGER,db_key_type(db,0)));
  } else {
    fill_dbt(STACK_1,&key,db_key_type(db,0));
    switch (action) {
      case DB_NODUPDATA: case DB_NOOVERWRITE: {
        int status;
        begin_blocking_system_call();
        status = db->put(db,txn,&key,&val,action | flags);
        free(val.data); free(key.data);
        end_blocking_system_call();
        switch (status) {
          case 0: VALUES0; break;
          case DB_KEYEXIST: VALUES1(O(object_Kkeyexist)); error_message_reset(); break;
          default: error_bdb(status,"db->put");
        }
        break;
      }
      default:
        SYSCALL1(db->put,(db,txn,&key,&val,action | flags),
                 {free(val.data);free(key.data);});
        VALUES0;
    }
  }
  skipSTACK(3);                 /* drop db key val */
}


DEFUN(BDB:DB-JOIN, db cursors &key JOIN-NOSORT,(subr_bdb_db_join,seclass_default,2,0,norest,key,1,NIL))
{ /* create a specialized join cursor */
  u_int32_t flags = db_join_flags(), length, pos;
  DB *db = (DB*)bdb_handle(STACK_1,O(object_bdb__db),BH_VALID);
  DBC **curslist, *dbc;
  pushSTACK(STACK_0); funcall(L(length),1); length = posfixnum_to_V(value1);
  curslist = (DBC**)alloca((1+length)*sizeof(DBC*));
  if (curslist == NULL) {
    pushSTACK(TheSubr(subr_self)->name);
    error(storage_condition,GETTEXT("~S: alloca() failed"));
  }
  curslist[length] = 0;
  if (listp(STACK_0)) {         /* list */
    for (pos=0; pos<length; pos++, STACK_0 = Cdr(STACK_0))
      curslist[pos] = (DBC*)bdb_handle(Car(STACK_0),O(object_bdb__dbc),BH_VALID);
  } else {                      /* vector */
    for (pos=0; pos<length; pos++) {
      pushSTACK(STACK_0); pushSTACK(fixnum(pos)); funcall(L(aref),2);
      curslist[pos] = (DBC*)bdb_handle(value1,O(object_bdb__dbc),BH_VALID);
    }
  }
  SYSCALL(db->join,(db,curslist,&dbc,flags));
  { /* make parents */
    object parent_list = allocate_cons();
    Car(parent_list) = STACK_1;
    STACK_1 = parent_list;
    if (listp(STACK_0)) {       /*  list */
      Cdr(STACK_1) = copy_list(STACK_0);
    } else {                    /* vector */
      pushSTACK(STACK_0); pushSTACK(S(list)); funcall(L(coerce),2);
      Cdr(STACK_1) = value1;
    }
  }
  wrap_finalize(dbc,STACK_1,O(object_bdb__mkdbc),F(subr_bdb_dbc_close));
  skipSTACK(2);
}

DEFUN(BDB:DB-KEY-RANGE, db key &key TRANSACTION,(subr_bdb_db_key_range,seclass_default,2,0,norest,key,1,NIL))
{ /* return an estimate of the proportion of keys that are less than,
     equal to, and greater than the specified key. The underlying
     database must be of type Btree. */
  DB_TXN *txn = (DB_TXN*)bdb_handle(popSTACK(),O(object_bdb__txn),BH_NIL_IS_NULL);
  DBT key;
  DB_KEY_RANGE key_range;
  DB *db = (DB*)bdb_handle(STACK_1,O(object_bdb__db),BH_VALID);
  fill_dbt(STACK_0,&key,db_key_type(db,0));
  SYSCALL1(db->key_range,(db,txn,&key,&key_range,0),{free(key.data);});
  pushSTACK(c_double_to_DF((dfloatjanus*)&(key_range.less)));
  pushSTACK(c_double_to_DF((dfloatjanus*)&(key_range.equal)));
  pushSTACK(c_double_to_DF((dfloatjanus*)&(key_range.greater)));
  VALUES3(STACK_0,STACK_1,STACK_2); skipSTACK(5);
}


#line 1815
DEFUN(BDB:DB-VERIFY, db file &key DATABASE SALVAGE AGGRESSIVE PRINTABLE        NOORDERCHK,(subr_bdb_db_verify,seclass_default,2,0,norest,key,5,NIL))
{ /* Verify/salvage a database */
  u_int32_t flags = db_verify_flags();
  DB *db = (DB*)bdb_handle(STACK_3,O(object_bdb__db),BH_VALID);
  FILE *outfile = NULL;
  if (!missingp(STACK_0)) {     /* SALVAGE */
    outfile = my_fopen(STACK_0);
    flags |= DB_SALVAGE;
  }
  STACK_2 = physical_namestring(STACK_2); /* FILE */
  if (!missingp(STACK_1)) {               /* DATABASE */
    STACK_1 = check_string(STACK_1);
    flags |= DB_ORDERCHKONLY;
  }
  with_string_0(STACK_2,GLO(pathname_encoding),file,{
      if (!missingp(STACK_1))
        with_string_0(STACK_1,GLO(misc_encoding),database,{
            SYSCALL1(db->verify,(db,file,database,outfile,flags),
                     { if (outfile) fclose(outfile); });
          });
      else
        SYSCALL1(db->verify,(db,file,NULL,outfile,flags),
                 { if (outfile) fclose(outfile); });
    });
  VALUES0; skipSTACK(3);
}

/* ===== Database Configuration ===== */
/* not exported:
 DB->set_alloc		Set local space allocation functions
 DB->set_dup_compare	Set a duplicate comparison function
 DB->set_errcall	Set error message callback
 DB->set_errpfx		Set error message prefix
 DB->set_feedback	Set feedback callback
 DB->set_paniccall	Set panic callback
Btree/Recno Configuration
 DB->set_append_recno	Set record append callback
 DB->set_bt_compare	Set a Btree comparison function
 DB->set_bt_prefix	Set a Btree prefix comparison function
Hash Configuration
 DB->set_h_hash	Set a hashing function
*/

/* set the password to perform encryption and decryption.
 can trigger GC */
static void db_set_encryption (DB *db, gcv_object_t *o_flags_,
                               gcv_object_t *o_password_) {
  u_int32_t flags = dbe_encryption_check(*o_flags_);
  *o_password_ = check_string(*o_password_);
  with_string_0(*o_password_,GLO(misc_encoding),password,
                { SYSCALL(db->set_encrypt,(db,password,flags)); });
}
/* get all flags as a list
 can trigger GC */
static object db_get_flags_list (DB *db) {
  u_int32_t flags;
  int count = 0;
  SYSCALL(db->get_flags,(db,&flags));
  if (flags & DB_CHKSUM) { pushSTACK(O(object_Kchksum)); count++; }
  if (flags & DB_DUP) { pushSTACK(O(object_Kdup)); count++; }
  if (flags & DB_DUPSORT) { pushSTACK(O(object_Kdupsort)); count++; }
  if (flags & DB_ENCRYPT) { pushSTACK(O(object_Kencrypt)); count++; }
#if defined(DB_INORDER)
  if (flags & DB_INORDER) { pushSTACK(O(object_Kinorder)); count++; }
#endif
  if (flags & DB_RECNUM) { pushSTACK(O(object_Krecnum)); count++; }
  if (flags & DB_RENUMBER) { pushSTACK(O(object_Krenumber)); count++; }
  if (flags & DB_REVSPLITOFF) { pushSTACK(O(object_Krevsplitoff)); count++; }
  if (flags & DB_SNAPSHOT) { pushSTACK(O(object_Ksnapshot)); count++; }
  if (flags & DB_TXN_NOT_DURABLE) { pushSTACK(O(object_Ktxn_not_durable)); count++; }
  return listof(count);
}
/* get the DB open flags
   return T when DB is not yet open and a list otherwise
 can trigger GC */
static object db_get_open_flags (DB *db, int errorp) {
  u_int32_t flags, status;
  begin_system_call();
  status = db->get_open_flags(db,&flags);
  end_system_call();
  if (status) {
    if (errorp) error_bdb(status,"db->get_open_flags");
    error_message_reset(); return T;
  }
  return check_db_open_flags_to_list(flags);
}

#line 1906
DEFUN(BDB:DB-SET-OPTIONS, db &key MSGFILE ERRFILE ERRPFX PASSWORD        ENCRYPTION NCACHE CACHESIZE CACHE LORDER PAGESIZE BT-MINKEY        H-FFACTOR H-NELEM Q-EXTENTSIZE RE-DELIM RE-LEN RE-PAD RE-SOURCE        CHKSUM DUP DUPSORT ENCRYPT INORDER RECNUM RENUMBER                REVSPLITOFF SNAPSHOT TXN-NOT-DURABLE,(subr_bdb_db_set_options,seclass_default,1,0,norest,key,28,NIL))
{ /* set database options */
  DB *db = (DB*)bdb_handle(STACK_(28),O(object_bdb__db),BH_VALID);
  DB_ENV *dbe = db->get_env(db);
  { /* flags */
    u_int32_t flags_on = 0, flags_off = 0;
    set_flags(popSTACK(),&flags_on,&flags_off,DB_TXN_NOT_DURABLE);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_SNAPSHOT);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_REVSPLITOFF);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_RENUMBER);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_RECNUM);
#  if defined(DB_INORDER)
    set_flags(popSTACK(),&flags_on,&flags_off,DB_INORDER);
#  else
    skipSTACK(1);               /*  drop :INORDER */
#  endif
    set_flags(popSTACK(),&flags_on,&flags_off,DB_ENCRYPT);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_DUPSORT);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_DUP);
    set_flags(popSTACK(),&flags_on,&flags_off,DB_CHKSUM);
    if (flags_off || flags_on) {
      u_int32_t flags;
      SYSCALL(db->get_flags,(db,&flags));
      flags |= flags_on;
      flags &= ~flags_off;
      SYSCALL(db->set_flags,(db,flags));
    }
  }
  if (boundp(STACK_0)) {        /* RE_SOURCE */
    if (nullp(STACK_0))
      SYSCALL(db->set_re_source,(db,NULL));
    else
      with_string_0(check_string(STACK_0),GLO(pathname_encoding), re_source, {
          SYSCALL(db->set_re_source,(db,re_source));
        });
  }
  skipSTACK(1);
  if (!missingp(STACK_0)) {     /* RE_PAD */
    int re_pad = I_to_uint8(check_uint8(STACK_0));
    SYSCALL(db->set_re_pad,(db,re_pad));
  }
  skipSTACK(1);
  if (!missingp(STACK_0)) {     /* RE_LEN */
    u_int32_t re_len = I_to_uint32(check_uint32(STACK_0));
    SYSCALL(db->set_re_len,(db,re_len));
  }
  skipSTACK(1);
  if (!missingp(STACK_0)) {     /* RE_DELIM */
    int re_delim = I_to_uint8(check_uint8(STACK_0));
    SYSCALL(db->set_re_delim,(db,re_delim));
  }
  skipSTACK(1);
  if (!missingp(STACK_0)) {     /* Q_EXTENTSIZE */
    u_int32_t q_extentsize = I_to_uint32(check_uint32(STACK_0));
    SYSCALL(db->set_q_extentsize,(db,q_extentsize));
  }
  skipSTACK(1);
  if (!missingp(STACK_0)) {     /* H_NELEM */
    u_int32_t h_nelem = I_to_uint32(check_uint32(STACK_0));
    SYSCALL(db->set_h_nelem,(db,h_nelem));
  }
  skipSTACK(1);
  if (!missingp(STACK_0)) {     /* H_FFACTOR */
    u_int32_t h_ffactor = I_to_uint32(check_uint32(STACK_0));
    SYSCALL(db->set_h_ffactor,(db,h_ffactor));
  }
  skipSTACK(1);
  if (!missingp(STACK_0)) {     /* BT_MINKEY */
    u_int32_t bt_minkey = I_to_uint32(check_uint32(STACK_0));
    SYSCALL(db->set_bt_minkey,(db,bt_minkey));
  }
  skipSTACK(1);
  if (!missingp(STACK_0)) {     /* PAGESIZE */
    u_int32_t pagesize = I_to_uint32(check_uint32(STACK_0));
    SYSCALL(db->set_pagesize,(db,pagesize));
  }
  skipSTACK(1);
  if (!missingp(STACK_0)) {     /* LORDER */
    int lorder = I_to_uint(check_uint(STACK_0));
    SYSCALL(db->set_lorder,(db,lorder));
  }
  skipSTACK(1);
  if (!missingp(STACK_0)) {     /* CACHE = (ncache cachesize) */
    STACK_0 = check_list(STACK_0);
    if (consp(STACK_0)) {
      int ncache = I_to_uint(check_uint(Car(STACK_0)));
      u_int32_t gbytes=0, bytes=0;
      STACK_0 = check_list(Cdr(STACK_0));
      if (consp(STACK_0))
        size_to_giga_bytes(Car(STACK_0),&gbytes,&bytes);
      SYSCALL(db->set_cachesize,(db,gbytes,bytes,ncache));
    }
  }
  skipSTACK(1);
  if (!missingp(STACK_0)) {     /* CACHESIZE & NCACHE */
    int ncache = check_uint_default0(STACK_1);
    u_int32_t gbytes, bytes;
    size_to_giga_bytes(STACK_0,&gbytes,&bytes);
    SYSCALL(db->set_cachesize,(db,gbytes,bytes,ncache));
  }
  skipSTACK(2);
  if (!missingp(STACK_1))       /* PASSWORD */
    db_set_encryption(db,&STACK_0,&STACK_1);
  skipSTACK(2);
  if (!missingp(STACK_0)) reset_errpfx(dbe);
  skipSTACK(1);
  if (!missingp(STACK_0)) reset_errfile(dbe);
  skipSTACK(1);
  if (!missingp(STACK_0)) reset_msgfile(dbe);
  skipSTACK(1);
  VALUES0; skipSTACK(1);        /* skip db */
}

/* get cache size and number of caches
   value1 == cachesize, value2 = ncache
 can trigger GC */
static void db_get_cache (DB* db, int errorp) {
  DB_ENV *dbe = db->get_env(db);
  if (dbe) dbe_get_cache(dbe,errorp);
  else {
    u_int32_t gbytes, bytes;
    int ncache, status;
    begin_system_call();
    status = db->get_cachesize(db,&gbytes,&bytes,&ncache);
    end_system_call();
    if (status) {
      if (errorp) error_bdb(status,"db->get_cachesize");
      error_message_reset();
      value1 = value2 = NIL;
    } else cache2lisp (gbytes, bytes, ncache);
  }
}
/* get file name and database name
   value1 == file name, value2 = database name
 can trigger GC */
static void db_get_dbname (DB* db, int errorp) {
  const char *fname, *dbname;
  int status;
  begin_system_call();
  status = db->get_dbname(db,&fname,&dbname);
  end_system_call();
  if (status) {
    if (errorp) error_bdb(status,"db->get_dbname");
    error_message_reset();
    value1 = value2 = NIL;
  } else {
    pushSTACK(asciz_to_string0(fname,GLO(pathname_encoding)));
    value2 = safe_to_string(dbname);
    value1 = popSTACK();
  }
}

#define DEFINE_DB_GETTER1(g,t,f)   DEFINE_GETTER1(db,DB,g,t,f)
DEFINE_DB_GETTER1(get_lorder,int,L_to_I(value))
DEFINE_DB_GETTER1(get_pagesize,u_int32_t,UL_to_I(value))
#if defined(HAVE_DB_GET_TRANSACTIONAL_1ARG)
static object db_get_transactional (DB* db) {
  int val;
  begin_system_call(); val = db->get_transactional(db); end_system_call();
  return val ? T : NIL;
}
#else
DEFINE_DB_GETTER1(get_transactional,int,(value?T:NIL))
#endif
#line 2083
#define DEFINE_DB_GETTER2(getter,type,finish)              static object db_##getter (DB* db,int errorp) {            type value;                                              int status;                                              begin_system_call();                                     status = db->getter(db,&value);                          end_system_call();                                       if (status) {                                              if (errorp) error_bdb(status,"db->" #getter);            error_message_reset();                                   return NIL;                                            } else                                                     return finish;                                       }
DEFINE_DB_GETTER2(get_bt_minkey,u_int32_t,UL_to_I(value))
DEFINE_DB_GETTER2(get_h_ffactor,u_int32_t,UL_to_I(value))
DEFINE_DB_GETTER2(get_h_nelem,u_int32_t,UL_to_I(value))
DEFINE_DB_GETTER2(get_q_extentsize,u_int32_t,UL_to_I(value))
DEFINE_DB_GETTER2(get_re_delim,int,L_to_I(value))
DEFINE_DB_GETTER2(get_re_len,u_int32_t,UL_to_I(value))
DEFINE_DB_GETTER2(get_re_pad,int,L_to_I(value))
DEFINE_DB_GETTER2(get_re_source,const char*,
                  asciz_to_string0(value,GLO(pathname_encoding)))
FLAG_EXTRACTOR(db_get_flags_num,DB*)
DEFUNR(BDB:DB-GET-OPTIONS, db &optional what,(subr_bdb_db_get_options,seclass_default,1,1,norest,nokey,0,NIL))
{ /* retrieve database options */
  DB *db = (DB*)bdb_handle(STACK_1,O(object_bdb__db),BH_VALID);
  DB_ENV *dbe = db->get_env(db);
  object what = STACK_0; skipSTACK(2);
 restart_DB_GET_OPTIONS:
  if (missingp(what)) {         /* get everything */
    uintL count = 0;
    DBTYPE db_type = db_get_type(db);
    pushSTACK(O(object_Kcache)); db_get_cache(db,false);
    pushSTACK(value1); pushSTACK(value2); value1 = listof(2);
    pushSTACK(value1); count++;
    pushSTACK(O(object_Kerrpfx)); pushSTACK(dbe_get_errpfx(dbe)); count++;
    pushSTACK(O(object_Kerrfile)); pushSTACK(dbe_get_errfile(dbe)); count++;
    pushSTACK(O(object_Kmsgfile)); pushSTACK(dbe_get_msgfile(dbe)); count++;
    pushSTACK(O(object_Kflags)); value1 = db_get_flags_list(db);
    pushSTACK(value1); count++;
    pushSTACK(O(object_Klorder)); pushSTACK(db_get_lorder(db)); count++;
    pushSTACK(O(object_Kpagesize)); pushSTACK(db_get_pagesize(db)); count++;
    if (db_type == DB_BTREE) {
      pushSTACK(O(object_Kbt_minkey)); pushSTACK(db_get_bt_minkey(db,false)); count++;
    }
    if (db_type == DB_HASH) {
      pushSTACK(O(object_Kh_ffactor)); pushSTACK(db_get_h_ffactor(db,false)); count++;
      pushSTACK(O(object_Kh_nelem)); pushSTACK(db_get_h_nelem(db,false)); count++;
    }
    if (db_type == DB_QUEUE) {
      pushSTACK(O(object_Kq_extentsize)); pushSTACK(db_get_q_extentsize(db,false));
      count++;
    }
    if (db_type == DB_RECNO || db_type == DB_QUEUE) {
        pushSTACK(O(object_Kre_len)); pushSTACK(db_get_re_len(db,false)); count++;
        pushSTACK(O(object_Kre_pad)); pushSTACK(db_get_re_pad(db,false)); count++;
    }
    if (db_type == DB_RECNO) {
      pushSTACK(O(object_Kre_delim)); pushSTACK(db_get_re_delim(db,false)); count++;
      pushSTACK(O(object_Kre_source)); pushSTACK(db_get_re_source(db,false)); count++;
    }
    pushSTACK(O(object_Ktransactional)); pushSTACK(db_get_transactional(db)); count++;
    pushSTACK(O(object_Kdbname)); db_get_dbname(db,false);
    pushSTACK(value1); pushSTACK(value2); value1 = listof(2);
    pushSTACK(value1); count++;
    pushSTACK(O(object_Kopen)); value1 = db_get_open_flags(db,false);
    pushSTACK(value1); count++;
    VALUES1(listof(2*count));
  } else if (eq(what,O(object_Kcache))) {
    db_get_cache(db,true); mv_count = 2;
  } else if (eq(what,O(object_Kdbname))) {
    db_get_dbname(db,true); mv_count = 2;
  } else if (eq(what,O(object_Kopen))) {
    VALUES1(db_get_open_flags(db,true));
  } else if (eq(what,O(object_Kencryption))) {
    u_int32_t flags;
    SYSCALL(db->get_encrypt_flags,(db,&flags));
    switch (flags) {
      case DB_ENCRYPT_AES: VALUES1(O(object_Kencrypt_aes));
      case 0: VALUES1(NIL);
      default: NOTREACHED;
    }
  } else if (eq(what,O(object_Kerrfile))) {
    VALUES1(dbe_get_errfile(dbe));
  } else if (eq(what,O(object_Kmsgfile))) {
    VALUES1(dbe_get_msgfile(dbe));
  } else if (eq(what,O(object_Kerrpfx))) {
    VALUES1(dbe_get_errpfx(dbe));
  } else if (eq(what,O(object_Kpagesize))) {
    VALUES1(db_get_pagesize(db));
  } else if (eq(what,O(object_Ktransactional))) {
    VALUES1(db_get_transactional(db));
  } else if (eq(what,O(object_Kbt_minkey))) {
    VALUES1(db_get_bt_minkey(db,true));
  } else if (eq(what,O(object_Kh_ffactor))) {
    VALUES1(db_get_h_ffactor(db,true));
  } else if (eq(what,O(object_Kh_nelem))) {
    VALUES1(db_get_h_nelem(db,true));
  } else if (eq(what,O(object_Kq_extentsize))) {
    VALUES1(db_get_q_extentsize(db,true));
  } else if (eq(what,O(object_Kre_delim))) {
    VALUES1(db_get_re_delim(db,true));
  } else if (eq(what,O(object_Kre_len))) {
    VALUES1(db_get_re_len(db,true));
  } else if (eq(what,O(object_Kre_pad))) {
    VALUES1(db_get_re_pad(db,true));
  } else if (eq(what,O(object_Kre_source))) {
    VALUES1(db_get_re_source(db,true));
  } else if (eq(what,O(object_Klorder))) {
    VALUES1(db_get_lorder(db));
  } else if (eq(what,O(object_Kflags))) {
    VALUES1(db_get_flags_list(db));
  } else if (eq(what,O(object_Ktxn_not_durable))) {
    VALUES_IF(db_get_flags_num(db) & DB_TXN_NOT_DURABLE);
  } else if (eq(what,O(object_Kchksum))) {
    VALUES_IF(db_get_flags_num(db) & DB_CHKSUM);
  } else if (eq(what,O(object_Kdup))) {
    VALUES_IF(db_get_flags_num(db) & DB_DUP);
  } else if (eq(what,O(object_Kdupsort))) {
    VALUES_IF(db_get_flags_num(db) & DB_DUPSORT);
  } else if (eq(what,O(object_Kencrypt))) {
    VALUES_IF(db_get_flags_num(db) & DB_ENCRYPT);
#if defined(DB_INORDER)
  } else if (eq(what,O(object_Kinorder))) {
    VALUES_IF(db_get_flags_num(db) & DB_INORDER);
#endif
  } else if (eq(what,O(object_Krecnum))) {
    VALUES_IF(db_get_flags_num(db) & DB_RECNUM);
  } else if (eq(what,O(object_Krenumber))) {
    VALUES_IF(db_get_flags_num(db) & DB_RENUMBER);
  } else if (eq(what,O(object_Krevsplitoff))) {
    VALUES_IF(db_get_flags_num(db) & DB_REVSPLITOFF);
  } else if (eq(what,O(object_Ksnapshot))) {
    VALUES_IF(db_get_flags_num(db) & DB_SNAPSHOT);
  } else {
    pushSTACK(NIL);             /* no PLACE */
    pushSTACK(what); pushSTACK(TheSubr(subr_self)->name);
    check_value(error_condition,GETTEXT("~S: invalid argument ~S"));
    what = value1;
    goto restart_DB_GET_OPTIONS;
  }
}

/* ===== cursors ===== */

#line 2217
DEFUN(BDB:MAKE-DBC,db &key TRANSACTION READ-COMMITTED        READ-UNCOMMITTED WRITECURSOR,(subr_bdb_make_dbc,seclass_default,1,0,norest,key,4,NIL))
{ /* create a cursor */
  u_int32_t flags = make_dbc_flags();
  DB_TXN *txn = (DB_TXN*)bdb_handle(STACK_0,O(object_bdb__txn),BH_NIL_IS_NULL);
  DB *db = (DB*)bdb_handle(STACK_1,O(object_bdb__db),BH_VALID);
  DBC *cursor;
  SYSCALL(db->cursor,(db,txn,&cursor,flags));
  if (txn) {
    object parents = listof(2);
    pushSTACK(parents);
  } else skipSTACK(1);          /* drop TXN=NIL */
  wrap_finalize(cursor,popSTACK(),O(object_bdb__mkdbc),F(subr_bdb_dbc_close));
}

DEFUN(BDB:DBC-CLOSE, cursor,(subr_bdb_dbc_close,seclass_default,1,0,norest,nokey,0,NIL))
{ /* close a cursor */
  DBC *cursor = (DBC*)bdb_handle(STACK_0,O(object_bdb__dbc),BH_INVALIDATE);
  if (cursor) {
    funcall(O(object_bdb__kill_handle),1);
    SYSCALL(cursor->c_close,(cursor));
    VALUES1(T);
  } else { skipSTACK(1); VALUES1(NIL); }
}

DEFUN(BDB:DBC-COUNT, cursor,(subr_bdb_dbc_count,seclass_default,1,0,norest,nokey,0,NIL))
{ /* return a count of the number of data items for the key to which
     the cursor refers */
  DBC *cursor = (DBC*)bdb_handle(popSTACK(),O(object_bdb__dbc),BH_VALID);
  db_recno_t count;
  SYSCALL(cursor->c_count,(cursor,&count,0));
  VALUES1(UL_to_I(count));
}


DEFUN(BDB:DBC-DEL, cursor &key CONSUME,(subr_bdb_dbc_del,seclass_default,1,0,norest,key,1,NIL))
{ /* delete the key/data pair to which the cursor refers */
  u_int32_t flags = dbc_del_flags();
  DBC *cursor = (DBC*)bdb_handle(popSTACK(),O(object_bdb__dbc),BH_VALID);
  SYSCALL(cursor->c_del,(cursor,flags));
  VALUES0;
}


DEFUN(BDB:DBC-DUP, cursor &key POSITION,(subr_bdb_dbc_dup,seclass_default,1,0,norest,key,1,NIL))
{ /* create a new cursor that uses the same transaction and locker ID as
     the original cursor */
  u_int32_t flags = dbc_dup_flags();
  DBC *cursor = (DBC*)bdb_handle(STACK_0,O(object_bdb__dbc),BH_VALID);
  DBC *new_cursor;
  SYSCALL(cursor->c_dup,(cursor,&new_cursor,flags));
  wrap_finalize(cursor,Parents(STACK_0),O(object_bdb__mkdbc),F(subr_bdb_dbc_close));
  skipSTACK(1);
}

static dbt_o_t fill_or_init (object datum, DBT *pdbt, int re_len) {
  if (symbolp(datum)) {       /* type spec for the return value */
    init_dbt(pdbt,DB_DBT_MALLOC);
    return check_dbt_type(datum);
  } else return fill_dbt(datum,pdbt,re_len); /* datum */
}
#line 2279

#line 2281

#line 2283
DEFUN(BDB:DBC-GET, cursor key data action &key READ-COMMITTED        READ-UNCOMMITTED MULTIPLE MULTIPLE-KEY RMW :ERROR,(subr_bdb_dbc_get,seclass_default,4,0,norest,key,6,NIL))
{ /* retrieve key/data pairs from the database */
  int no_error = nullp(popSTACK());
  u_int32_t flag = dbc_get_options();
  u_int32_t action = dbc_get_action(popSTACK());
  DBC *cursor = (DBC*)bdb_handle(STACK_2,O(object_bdb__dbc),BH_VALID);
  DBT key, val;
  int db_log_key = db_key_type(cursor->dbp,action);
  dbt_o_t val_type = fill_or_init(popSTACK(),&val,
                                  (action==DB_GET_RECNO ? sizeof(db_recno_t)
                                   : record_length(cursor->dbp)));
  dbt_o_t key_type = fill_or_init(popSTACK(),&key,db_log_key);
  int status;
  skipSTACK(1);                 /* drop cursor */
  begin_blocking_system_call();
  status = cursor->c_get(cursor,&key,&val,flag | action);
  end_blocking_system_call();
  if (status) {
    free_dbt(&key); free_dbt(&val);
    if (no_error) {
      switch (status) {
        case DB_NOTFOUND: VALUES1(O(object_Knotfound)); error_message_reset(); return;
        case DB_KEYEMPTY: VALUES1(O(object_Kkeyempty)); error_message_reset(); return;
      }
    }
    error_bdb(status,"dbc->c_get");
  }
  if (action == DB_GET_RECNO) { /* the only value is RECNO */
    VALUES1(dbt_to_object(&val,val_type,-1));
    free_dbt(&key);
  } else {                      /* two values: key & value */
    /* :SET-RECNO means that both key and value are returned as is */
    pushSTACK(dbt_to_object(&key,key_type,
                            action==DB_SET_RECNO ? 0 : db_log_key));
    value2 = dbt_to_object(&val,val_type,0);
    value1 = popSTACK();
    mv_count = 2;
  }
}

#line 2324

DEFUN(BDB:DBC-PUT, cursor key data flag,(subr_bdb_dbc_put,seclass_default,4,0,norest,nokey,0,NIL))
{ /* retrieve key/data pairs from the database */
  u_int32_t flag = dbc_put_flag(popSTACK());
  DBC *cursor = (DBC*)bdb_handle(STACK_2,O(object_bdb__dbc),BH_VALID);
  DBT key, val;
  fill_dbt(STACK_1,&key,db_key_type(cursor->dbp,0));
  fill_dbt(STACK_0,&val,record_length(cursor->dbp));
  SYSCALL1(cursor->c_put,(cursor,&key,&val,flag),
           {free(val.data);free(key.data);});
  skipSTACK(3);
  VALUES0;
}

/* ===== locks ===== */
/* not exported
 DB_ENV->lock_vec	Acquire/release locks
*/

DEFUN(BDB:LOCK-DETECT, dbe action,(subr_bdb_lock_detect,seclass_default,2,0,norest,nokey,0,NIL))
{ /* Perform deadlock detection */
  u_int32_t flags = 0;
  u_int32_t action = check_lk_detect(popSTACK());
  DB_ENV *dbe = (DB_ENV*)bdb_handle(popSTACK(),O(object_bdb__dbe),BH_VALID);
  int aborted = false;
  SYSCALL(dbe->lock_detect,(dbe,flags,action,&aborted));
  VALUES_IF(aborted);
}

#line 2354


DEFUN(BDB:LOCK-GET, dbe object locker mode &key NOWAIT,(subr_bdb_lock_get,seclass_default,4,0,norest,key,1,NIL))
{ /* Acquire a lock */
  u_int32_t flags = lock_get_flags();
  db_lockmode_t mode = check_lockmode(popSTACK());
  u_int32_t locker = I_to_uint32(check_uint32(popSTACK()));
  DB_ENV *dbe = (DB_ENV*)bdb_handle(STACK_1,O(object_bdb__dbe),BH_VALID);
  DBT obj;
  DB_LOCK *dblock;
  int status;
  /* fill_dbt() might not return,
     so clisp_malloc() must be called after it to avoid a memory leak */
  fill_dbt(STACK_0,&obj,0);
  dblock = (DB_LOCK*)clisp_malloc(sizeof(DB_LOCK));
  begin_blocking_system_call();
  status = dbe->lock_get(dbe,locker,flags,&obj,mode,dblock);
  free(obj.data);
  if (status) free(dblock);
  end_blocking_system_call();
  if (status) error_bdb(status,"dbe->lock_get");
  pushSTACK(allocate_fpointer(dblock)); pushSTACK(STACK_2);
  funcall(O(object_bdb__mkdblock),2); STACK_0 = STACK_1 = value1;
  pushSTACK(F(subr_bdb_lock_close)); funcall(L(finalize),2);
  VALUES1(popSTACK()); /* DBLOCK */
}

DEFUN(BDB:LOCK-ID, dbe,(subr_bdb_lock_id,seclass_default,1,0,norest,nokey,0,NIL))
{ /* Acquire a locker ID */
  DB_ENV *dbe = (DB_ENV*)bdb_handle(popSTACK(),O(object_bdb__dbe),BH_VALID);
  u_int32_t id;
  SYSCALL(dbe->lock_id,(dbe,&id));
  VALUES1(uint32_to_I(id));
}
DEFUN(BDB:LOCK-ID-FREE, dbe id,(subr_bdb_lock_id_free,seclass_default,2,0,norest,nokey,0,NIL))
{ /* Release a locker ID */
  u_int32_t id = I_to_uint32(check_uint32(popSTACK()));
  DB_ENV *dbe = (DB_ENV*)bdb_handle(popSTACK(),O(object_bdb__dbe),BH_VALID);
  SYSCALL(dbe->lock_id_free,(dbe,id));
  VALUES0;
}

DEFUN(BDB:LOCK-PUT, dbe lock,(subr_bdb_lock_put,seclass_default,2,0,norest,nokey,0,NIL))
{ /* Release a lock */
  DB_LOCK *lock = (DB_LOCK*)bdb_handle(popSTACK(),O(object_bdb__dblock),BH_INVALIDATE);
  DB_ENV *dbe = (DB_ENV*)bdb_handle(popSTACK(),O(object_bdb__dbe),BH_VALID);
  SYSCALL1(dbe->lock_put,(dbe,lock),{free(lock);});
  VALUES0;
}
DEFUN(BDB:LOCK-CLOSE, lock,(subr_bdb_lock_close,seclass_default,1,0,norest,nokey,0,NIL))
{ /* Close a lock and free the memory */
  DB_LOCK *lock = (DB_LOCK*)bdb_handle(STACK_0,O(object_bdb__dblock),
                                       BH_INVALID_IS_NULL);
  if (lock) {
    object parent = Parents(STACK_0); /* parent of DBLOCK is a single DBE! */
    DB_ENV *dbe = (DB_ENV*)bdb_handle(parent,O(object_bdb__dbe),BH_INVALID_IS_NULL);
    if (dbe == NULL) { /* the DBE has been closed */
      pushSTACK(O(object_bdb__bdb_error));  /* error type */
      pushSTACK(S(Kcode)); pushSTACK(NIL);
      pushSTACK(CLSTEXT("~S (~S): cannot close a lock whose environment has been already closed; you must re-open the environment and call ~S"));
      pushSTACK(TheSubr(subr_self)->name);
      pushSTACK(STACK_5);       /* lock */
      pushSTACK(O(object_bdb__lock_put));
      funcall(L(error_of_type),7);
    }
    pushSTACK(parent); pushSTACK(STACK_1); funcall(F(subr_bdb_lock_put),2);
    VALUES1(T);
  } else VALUES1(NIL);
  skipSTACK(1);
}


DEFUN(BDB:LOCK-STAT,dbe &key STAT-CLEAR,(subr_bdb_lock_stat,seclass_default,1,0,norest,key,1,NIL))
{ /* Return lock subsystem statistics */
  u_int32_t flags = stat_flags();
  DB_ENV *dbe = (DB_ENV*)bdb_handle(popSTACK(),O(object_bdb__dbe),BH_VALID);
  DB_LOCK_STAT *ls;
  SYSCALL(dbe->lock_stat,(dbe,&ls,flags));
  pushSTACK(uint32_to_I(ls->st_id));
  pushSTACK(uint32_to_I(ls->st_cur_maxid));
  pushSTACK(uint32_to_I(ls->st_nmodes));
  pushSTACK(uint32_to_I(ls->st_maxlocks));
  pushSTACK(uint32_to_I(ls->st_maxlockers));
  pushSTACK(uint32_to_I(ls->st_maxobjects));
  pushSTACK(uint32_to_I(ls->st_nlocks));
  pushSTACK(uint32_to_I(ls->st_maxnlocks));
  pushSTACK(uint32_to_I(ls->st_nlockers));
  pushSTACK(uint32_to_I(ls->st_maxnlockers));
  pushSTACK(uint32_to_I(ls->st_nobjects));
  pushSTACK(uint32_to_I(ls->st_maxnobjects));
  pushSTACK(uint32_to_I(ls->st_nrequests));
  pushSTACK(uint32_to_I(ls->st_nreleases));
#if defined(HAVE_DB_LOCK_STAT_ST_NNOWAITS)
  pushSTACK(uint32_to_I(ls->st_nnowaits));
#elif defined(HAVE_DB_LOCK_STAT_ST_LOCK_NOWAIT)
  pushSTACK(uint32_to_I(ls->st_lock_nowait));
#else
# error neither st_lock_nowait nor st_nnowaits is found in DB_LOCK_STAT
#endif
#if defined(HAVE_DB_LOCK_STAT_ST_NCONFLICTS)
  pushSTACK(uint32_to_I(ls->st_nconflicts));
#elif defined(HAVE_DB_LOCK_STAT_ST_LOCK_WAIT)
  pushSTACK(uint32_to_I(ls->st_lock_wait));
#else
# error neither st_lock_wait nor st_nconflicts is found in DB_LOCK_STAT
#endif
  pushSTACK(uint32_to_I(ls->st_ndeadlocks));
  pushSTACK(uint32_to_I(ls->st_locktimeout));
  pushSTACK(uint32_to_I(ls->st_nlocktimeouts));
  pushSTACK(uint32_to_I(ls->st_txntimeout));
  pushSTACK(uint32_to_I(ls->st_ntxntimeouts));
  pushSTACK(uint32_to_I(ls->st_regsize));
  pushSTACK(uint32_to_I(ls->st_region_wait));
  pushSTACK(uint32_to_I(ls->st_region_nowait));
  funcall(O(object_bdb__mklockstat),24);
  begin_system_call(); free(ls); end_system_call();
}

/* ===== logs ===== */

#line 2475

DEFUN(BDB:LOG-ARCHIVE, dbe &key ARCH-ABS ARCH-DATA ARCH-LOG ARCH-REMOVE,(subr_bdb_log_archive,seclass_default,1,0,norest,key,4,NIL))
{ /* return a list of log or database filenames. */
  u_int32_t flags = log_archive_flags();
  DB_ENV *dbe = (DB_ENV*)bdb_handle(popSTACK(),O(object_bdb__dbe),BH_VALID);
  char **list = NULL;
  SYSCALL(dbe->log_archive,(dbe,&list,flags));
  if (list) {
    int count = 0;
    for (; *list; list++, count++)
      pushSTACK(asciz_to_string(*list,GLO(pathname_encoding)));
    begin_system_call(); free(list); end_system_call();
    VALUES1(listof(count));
  } else VALUES0;
}

/* extract the DB_LSN data from the object
 can trigger GC */
static void check_lsn (gcv_object_t *obj_, DB_LSN *lsn) {
  *obj_ = check_classname(*obj_,O(object_bdb__lsn));
  lsn->file = I_to_uint32(TheStructure(*obj_)->recdata[1]);
  lsn->offset = I_to_uint32(TheStructure(*obj_)->recdata[2]);
}

DEFUN(BDB:LOG-FILE, dbe lsn,(subr_bdb_log_file,seclass_default,2,0,norest,nokey,0,NIL))
{ /* return the name of the file containing the record named by lsn. */
  DB_LSN lsn;
  DB_ENV *dbe = (DB_ENV*)bdb_handle(STACK_1,O(object_bdb__dbe),BH_VALID);
  char path[BUFSIZ];
  check_lsn(&STACK_0,&lsn);
  SYSCALL(dbe->log_file,(dbe,&lsn,path,BUFSIZ));
  VALUES1(asciz_to_string(path,GLO(pathname_encoding)));
  skipSTACK(2);
}

DEFUN(BDB:LOG-FLUSH, dbe lsn,(subr_bdb_log_flush,seclass_default,2,0,norest,nokey,0,NIL))
{ /* flush log records to disk */
  DB_LSN lsn;
  DB_ENV *dbe = (DB_ENV*)bdb_handle(STACK_1,O(object_bdb__dbe),BH_VALID);
  check_lsn(&STACK_0,&lsn);
  SYSCALL(dbe->log_flush,(dbe,&lsn));
  VALUES0;
  skipSTACK(2);
}

/* convert C srtuct DB_LSN to Lisp structure LSN
 can trigger GC */
static object make_lsn (DB_LSN *lsn) {
  pushSTACK(uint32_to_I(lsn->file));
  pushSTACK(uint32_to_I(lsn->offset));
  funcall(O(object_bdb__mklsn),2);
  return value1;
}


DEFUN(BDB:LOG-PUT, dbe data &key FLUSH,(subr_bdb_log_put,seclass_default,2,0,norest,key,1,NIL))
{ /* write a log record */
  u_int32_t flags = log_put_flags();
  DB_LSN lsn;
  DB_ENV *dbe = (DB_ENV*)bdb_handle(STACK_1,O(object_bdb__dbe),BH_VALID);
  DBT data;
  fill_dbt(STACK_0,&data,0); skipSTACK(2);
  SYSCALL1(dbe->log_put,(dbe,&lsn,&data,flags),{free(data.data);});
  make_lsn(&lsn);
}

DEFUN(BDB:LOG-STAT, dbe &key STAT-CLEAR,(subr_bdb_log_stat,seclass_default,1,0,norest,key,1,NIL))
{ /* logging subsystem statistics */
  u_int32_t flags = stat_flags();
  DB_ENV *dbe = (DB_ENV*)bdb_handle(popSTACK(),O(object_bdb__dbe),BH_VALID);
  DB_LOG_STAT *stat;
  SYSCALL(dbe->log_stat,(dbe,&stat,flags));
  pushSTACK(uint32_to_I(stat->st_magic));
  pushSTACK(uint32_to_I(stat->st_version));
  pushSTACK(uint32_to_I(stat->st_mode));
  pushSTACK(uint32_to_I(stat->st_lg_bsize));
  pushSTACK(uint32_to_I(stat->st_lg_size));
  pushSTACK(uint32_to_I(stat->st_w_mbytes));
  pushSTACK(uint32_to_I(stat->st_w_bytes));
  pushSTACK(uint32_to_I(stat->st_wc_mbytes));
  pushSTACK(uint32_to_I(stat->st_wc_bytes));
  pushSTACK(uint32_to_I(stat->st_wcount));
  pushSTACK(uint32_to_I(stat->st_wcount_fill));
  pushSTACK(uint32_to_I(stat->st_scount));
  pushSTACK(uint32_to_I(stat->st_cur_file));
  pushSTACK(uint32_to_I(stat->st_cur_offset));
  pushSTACK(uint32_to_I(stat->st_disk_file));
  pushSTACK(uint32_to_I(stat->st_disk_offset));
  pushSTACK(uint32_to_I(stat->st_maxcommitperflush));
  pushSTACK(uint32_to_I(stat->st_mincommitperflush));
  pushSTACK(uint32_to_I(stat->st_regsize));
  pushSTACK(uint32_to_I(stat->st_region_wait));
  pushSTACK(uint32_to_I(stat->st_region_nowait));
  funcall(O(object_bdb__mklogstat),21);
  begin_system_call(); free(stat); end_system_call();
}

DEFUN(BDB:LOG-CURSOR, dbe,(subr_bdb_log_cursor,seclass_default,1,0,norest,nokey,0,NIL))
{ /* create a log cursor. */
  DB_ENV *dbe = (DB_ENV*)bdb_handle(STACK_0,O(object_bdb__dbe),BH_VALID);
  DB_LOGC *cursor;
  SYSCALL(dbe->log_cursor,(dbe,&cursor,0));
  wrap_finalize(cursor,STACK_0,O(object_bdb__mklogc),F(subr_bdb_logc_close));
}

DEFUN(BDB:LOGC-CLOSE, logc,(subr_bdb_logc_close,seclass_default,1,0,norest,nokey,0,NIL))
{ /* discard the log cursor. */
  DB_LOGC *logc = (DB_LOGC*)bdb_handle(STACK_0,O(object_bdb__logc),BH_INVALIDATE);
  if (logc) {
    funcall(O(object_bdb__kill_handle),1);
    SYSCALL(logc->close,(logc,0));
    VALUES1(T);
  } else { skipSTACK(1); VALUES1(NIL); }
}

#line 2591

DEFUN(BDB:LOGC-GET, logc action &key :TYPE :ERROR,(subr_bdb_logc_get,seclass_default,2,0,norest,key,2,NIL))
{ /* return records from the log. */
  int no_error = nullp(popSTACK());
  dbt_o_t out_type = check_dbt_type(popSTACK());
  DB_LOGC *logc = (DB_LOGC*)bdb_handle(STACK_1,O(object_bdb__logc),BH_VALID);
  DB_LSN lsn;
  u_int32_t action;
  DBT data;
  int status;
  if (symbolp(STACK_0) || fixnump(STACK_0)) {
    action = logc_get_action(STACK_0);
  } else {
    action = DB_SET;
    check_lsn(&STACK_0,&lsn);
  }
  init_dbt(&data,DB_DBT_MALLOC);
  begin_blocking_system_call();
  status = logc->get(logc,&lsn,&data,action);
  end_blocking_system_call();
  if (status) {
    if (no_error) {
      switch (status) {
        case DB_NOTFOUND: VALUES1(O(object_Knotfound)); error_message_reset(); return;
      }
    }
    error_bdb(status,"logc->get");
  }
  if (action == DB_SET) {       /* STACK_0 is the LSN */
  } else STACK_0 = make_lsn(&lsn);
  VALUES2(dbt_to_object(&data,out_type,0),popSTACK());
  free_dbt(&data);
  skipSTACK(1);
}

DEFUN(BDB:LOG-COMPARE, lsn1 lsn2,(subr_bdb_log_compare,seclass_default,2,0,norest,nokey,0,NIL))
{ /* Compare two Log Sequence Numbers */
  DB_LSN lsn1, lsn2;
  int value;
  check_lsn(&STACK_1,&lsn1);
  check_lsn(&STACK_0,&lsn2);
  begin_system_call(); value = log_compare(&lsn1,&lsn2); end_system_call();
  VALUES1(fixnum(value));
  skipSTACK(2);
}

/* ===== transactions ===== */

#line 2640

#line 2642
DEFUN(BDB:TXN-BEGIN, dbe &key PARENT READ-COMMITTED          READ-UNCOMMITTED NOSYNC NOWAIT SYNC,(subr_bdb_txn_begin,seclass_default,1,0,norest,key,6,NIL))
{ /* create a transaction */
  u_int32_t flags = txn_begin_flags();
  DB_TXN *parent = (DB_TXN*)bdb_handle(STACK_0,O(object_bdb__txn),BH_NIL_IS_NULL), *ret;
  DB_ENV *dbe = (DB_ENV*)bdb_handle(STACK_1,O(object_bdb__dbe),BH_VALID);
  SYSCALL(dbe->txn_begin,(dbe,parent,&ret,flags));
  if (parent) {
    object parents = listof(2);
    pushSTACK(parents);
  } else skipSTACK(1);          /* drop TXN=NIL */
  wrap_finalize(ret,STACK_0,O(object_bdb__mktxn),F(subr_bdb_txn_commit));
  skipSTACK(1);
}

DEFUN(BDB:TXN-ABORT, txn,(subr_bdb_txn_abort,seclass_default,1,0,norest,nokey,0,NIL))
{ /* Abort a transaction */
  DB_TXN *txn = (DB_TXN*)bdb_handle(STACK_0,O(object_bdb__txn),BH_INVALIDATE);
  if (txn) {
    funcall(O(object_bdb__kill_handle),1);
    SYSCALL(txn->abort,(txn));
    VALUES1(T);
  } else { skipSTACK(1); VALUES1(NIL); }
}


DEFUN(BDB:TXN-COMMIT, txn &key SYNC,(subr_bdb_txn_commit,seclass_default,1,0,norest,key,1,NIL))
{ /* Commit a transaction */
  u_int32_t flags = txn_check_sync(popSTACK());
  DB_TXN *txn = (DB_TXN*)bdb_handle(STACK_0,O(object_bdb__txn),BH_INVALIDATE);
  if (txn) {
    funcall(O(object_bdb__kill_handle),1);
    SYSCALL(txn->commit,(txn,flags));
    VALUES1(T);
  } else { skipSTACK(1); VALUES1(NIL); }
}

DEFUN(BDB:TXN-DISCARD, txn,(subr_bdb_txn_discard,seclass_default,1,0,norest,nokey,0,NIL))
{ /* Discard a transaction */
  DB_TXN *txn = (DB_TXN*)bdb_handle(STACK_0,O(object_bdb__txn),BH_INVALIDATE);
  if (txn) {
    funcall(O(object_bdb__kill_handle),1);
    SYSCALL(txn->discard,(txn,0));
    VALUES1(T);
  } else { skipSTACK(1); VALUES1(NIL); }
}

DEFUN(BDB:TXN-ID, txn,(subr_bdb_txn_id,seclass_default,1,0,norest,nokey,0,NIL))
{ /* Return the transaction's ID */
  DB_TXN *txn = (DB_TXN*)bdb_handle(popSTACK(),O(object_bdb__txn),BH_VALID);
  u_int32_t id;
  begin_system_call(); id = txn->id(txn); end_system_call();
  VALUES1(UL_to_I(id));
}


DEFUN(BDB:TXN-CHECKPOINT, dbe &key KBYTE MIN FORCE,(subr_bdb_txn_checkpoint,seclass_default,1,0,norest,key,3,NIL))
{ /* flush the underlying memory pool, write a checkpoint record to the
     log, and then flush the log. */
  u_int32_t flags = txn_checkpoint_flags();
  u_int32_t min = check_uint_default0(popSTACK());
  u_int32_t kbyte = check_uint_default0(popSTACK());
  DB_ENV *dbe = (DB_ENV*)bdb_handle(popSTACK(),O(object_bdb__dbe),BH_VALID);
  SYSCALL(dbe->txn_checkpoint,(dbe,kbyte,min,flags));
  VALUES0;
}

/* return the pointer into the obj (which must be
   a (vector (unsigned-byte 8) DB_GID_SIZE))
 can trigger GC, the return value is invalidated by GC */
static u_int8_t* check_gid (gcv_object_t *obj_) {
  uintL idx = 0;
  object data_vector;
  *obj_ = check_byte_vector_len(*obj_,DB_GID_SIZE);
  data_vector = array_displace_check(*obj_,DB_GID_SIZE,&idx);
  return TheSbvector(data_vector)->data+idx;
}

DEFUN(BDB:TXN-PREPARE, txn gid,(subr_bdb_txn_prepare,seclass_default,2,0,norest,nokey,0,NIL))
{ /* initiate the beginning of a two-phase commit */
  DB_TXN *txn = (DB_TXN*)bdb_handle(STACK_1,O(object_bdb__txn),BH_VALID);
  u_int8_t *gid = check_gid(&STACK_0);
  SYSCALL(txn->prepare,(txn,gid));
  VALUES0; skipSTACK(2);
}

/* allocate a (vector (unsigned-byte 8) DB_GID_SIZE) for this gid
 can trigger GC */
static object gid_to_vector (u_int8_t gid[DB_GID_SIZE]) {
  object vec = allocate_bit_vector(Atype_8Bit,DB_GID_SIZE);
  begin_system_call();
  memcpy(TheSbvector(vec)->data,gid,DB_GID_SIZE);
  end_system_call();
  return vec;
}


DEFUN(BDB:TXN-RECOVER, dbe &key FIRST :NEXT,(subr_bdb_txn_recover,seclass_default,1,0,norest,key,2,NIL))
{ /* return a list of prepared but not yet resolved transactions */
  u_int32_t flags = txn_recover_flags();
  DB_ENV *dbe = (DB_ENV*)bdb_handle(popSTACK(),O(object_bdb__dbe),BH_VALID);
  u_int32_t tx_max;
  DB_PREPLIST *preplist;
  int status, ii;
  u_int32_t retnum;
  SYSCALL(dbe->get_tx_max,(dbe,&tx_max));
  preplist = (DB_PREPLIST*)clisp_malloc(tx_max * sizeof(DB_PREPLIST));
  begin_blocking_system_call();
  status = dbe->txn_recover(dbe,preplist,tx_max,&retnum,flags);
  if (status) free(preplist);
  end_blocking_system_call();
  if (status) error_bdb(status,"dbe->txn_recover");
  for (ii=0; ii<retnum; ii++) {
    pushSTACK(allocate_fpointer(preplist[ii].txn));
    funcall(O(object_bdb__mktxn),1); pushSTACK(value1);
    pushSTACK(gid_to_vector(preplist[ii].gid));
    value1 = allocate_cons();
    Cdr(value1) = popSTACK();   /* gid */
    Car(value1) = popSTACK();   /* txn */
    pushSTACK(value1);          /* (TXN . GID) */
  }
  VALUES1(listof(retnum));
}


DEFUN(BDB:TXN-SET-TIMEOUT, txn timeout which,(subr_bdb_txn_set_timeout,seclass_default,3,0,norest,nokey,0,NIL))
{ /* set timeout values for locks or transactions for the specified
     transaction */
  u_int32_t which = txn_timeout_check(popSTACK());
  db_timeout_t timeout = I_to_uint32(check_uint32(popSTACK()));
  DB_TXN *txn = (DB_TXN*)bdb_handle(popSTACK(),O(object_bdb__txn),BH_VALID);
  SYSCALL(txn->set_timeout,(txn,timeout,which));
  VALUES0;
}

#line 2777

DEFUN(BDB:TXN-STAT, dbe &key STAT-CLEAR,(subr_bdb_txn_stat,seclass_default,1,0,norest,key,1,NIL))
{ /* transaction subsystem statistics */
  u_int32_t flags = stat_flags();
  DB_ENV *dbe = (DB_ENV*)bdb_handle(popSTACK(),O(object_bdb__dbe),BH_VALID);
  DB_TXN_STAT *stat;
  SYSCALL(dbe->txn_stat,(dbe,&stat,flags));
  pushSTACK(make_lsn(&(stat->st_last_ckp)));
  pushSTACK(convert_time_to_universal(&(stat->st_time_ckp)));
  pushSTACK(uint32_to_I(stat->st_last_txnid));
  pushSTACK(uint32_to_I(stat->st_maxtxns));
  pushSTACK(uint32_to_I(stat->st_nactive));
  pushSTACK(uint32_to_I(stat->st_maxnactive));
  pushSTACK(uint32_to_I(stat->st_nbegins));
  pushSTACK(uint32_to_I(stat->st_naborts));
  pushSTACK(uint32_to_I(stat->st_ncommits));
  pushSTACK(uint32_to_I(stat->st_nrestores));
  pushSTACK(uint32_to_I(stat->st_regsize));
  pushSTACK(uint32_to_I(stat->st_region_wait));
  pushSTACK(uint32_to_I(stat->st_region_nowait));
  { /* txnarray */
    int ii, size = stat->st_nactive;
    DB_TXN_ACTIVE *txn_active = stat->st_txnarray;
    for (ii=0; ii<size; ii++, txn_active++) {
      pushSTACK(uint32_to_I(txn_active->txnid));
      pushSTACK(uint32_to_I(txn_active->parentid));
      pushSTACK(make_lsn(&(txn_active->lsn)));
     #if defined(HAVE_DB_TXN_ACTIVE_STATUS) /* 4.7 */
      pushSTACK(txn_status_check_reverse(txn_active->status));
     #else
      pushSTACK(uint32_to_I(txn_active->xa_status));
     #endif
     #if defined(HAVE_DB_TXN_ACTIVE_GID) /* 4.8 */
      pushSTACK(gid_to_vector(txn_active->gid));
     #else
      pushSTACK(gid_to_vector(txn_active->xid));
     #endif
      funcall(O(object_bdb__mktxnactive),5); pushSTACK(value1);
    }
    value1 = vectorof(size); pushSTACK(value1);
  }
  funcall(O(object_bdb__mktxnstat),14);
  begin_system_call(); free(stat); end_system_call();
}

void module__bdb__init_function_2 (module_t* module);
void module__bdb__init_function_2 (module_t* module)
{
#if defined(DEBUG)
  char *options = getenv("DMALLOC_OPTIONS");
  dmalloc_debug_setup(options);
  printf("dmalloc options: %s\n",options);
#endif
}


struct module__bdb__subr_tab_t module__bdb__subr_tab
  #if defined(HEAPCODES) && (alignment_long < varobject_alignment) && defined(__GNUC__)
    __attribute__ ((aligned (varobject_alignment)))
  #endif
  = {
  #if varobjects_misaligned
  { 0 },
  #endif
  LISPFUN_F(subr_bdb_dbc_close,seclass_default,1,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_dbc_count,seclass_default,1,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_dbc_del,seclass_default,1,0,norest,key,1,NIL)
  LISPFUN_F(subr_bdb_dbc_dup,seclass_default,1,0,norest,key,1,NIL)
  LISPFUN_F(subr_bdb_dbc_get,seclass_default,4,0,norest,key,6,NIL)
  LISPFUN_F(subr_bdb_dbc_put,seclass_default,4,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_dbe_close,seclass_default,1,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_dbe_create,seclass_default,0,0,norest,key,5,NIL)
  LISPFUN_F(subr_bdb_dbe_dbremove,seclass_default,3,0,norest,key,2,NIL)
  LISPFUN_F(subr_bdb_dbe_dbrename,seclass_default,4,0,norest,key,2,NIL)
  LISPFUN_F(subr_bdb_dbe_get_options,seclass_default,1,1,norest,nokey,0,NIL)
#if defined(HAVE_DB_ENV_SET_MSGCALL)
  LISPFUN_F(subr_bdb_dbe_messages,seclass_default,1,0,norest,nokey,0,NIL)
#endif
  LISPFUN_F(subr_bdb_dbe_open,seclass_default,1,0,norest,key,18,NIL)
  LISPFUN_F(subr_bdb_dbe_remove,seclass_default,1,0,norest,key,4,NIL)
  LISPFUN_F(subr_bdb_dbe_set_options,seclass_default,1,0,norest,key,50,NIL)
  LISPFUN_F(subr_bdb_db_close,seclass_default,1,0,norest,key,1,NIL)
  LISPFUN_F(subr_bdb_db_create,seclass_default,1,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_db_del,seclass_default,2,0,norest,key,2,NIL)
  LISPFUN_F(subr_bdb_db_fd,seclass_default,1,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_db_get,seclass_default,2,0,norest,key,10,NIL)
  LISPFUN_F(subr_bdb_db_get_options,seclass_default,1,1,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_db_join,seclass_default,2,0,norest,key,1,NIL)
  LISPFUN_F(subr_bdb_db_key_range,seclass_default,2,0,norest,key,1,NIL)
  LISPFUN_F(subr_bdb_db_open,seclass_default,2,0,norest,key,13,NIL)
  LISPFUN_F(subr_bdb_db_put,seclass_default,3,0,norest,key,3,NIL)
  LISPFUN_F(subr_bdb_db_remove,seclass_default,3,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_db_rename,seclass_default,4,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_db_set_options,seclass_default,1,0,norest,key,28,NIL)
  LISPFUN_F(subr_bdb_db_stat,seclass_default,1,0,norest,key,2,NIL)
  LISPFUN_F(subr_bdb_db_sync,seclass_default,1,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_db_truncate,seclass_default,1,0,norest,key,2,NIL)
  LISPFUN_F(subr_bdb_db_upgrade,seclass_default,2,0,norest,key,1,NIL)
  LISPFUN_F(subr_bdb_db_verify,seclass_default,2,0,norest,key,5,NIL)
  LISPFUN_F(subr_bdb_db_version,seclass_default,0,1,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_lock_close,seclass_default,1,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_lock_detect,seclass_default,2,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_lock_get,seclass_default,4,0,norest,key,1,NIL)
  LISPFUN_F(subr_bdb_lock_id,seclass_default,1,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_lock_id_free,seclass_default,2,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_lock_put,seclass_default,2,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_lock_stat,seclass_default,1,0,norest,key,1,NIL)
  LISPFUN_F(subr_bdb_logc_close,seclass_default,1,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_logc_get,seclass_default,2,0,norest,key,2,NIL)
  LISPFUN_F(subr_bdb_log_archive,seclass_default,1,0,norest,key,4,NIL)
  LISPFUN_F(subr_bdb_log_compare,seclass_default,2,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_log_cursor,seclass_default,1,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_log_file,seclass_default,2,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_log_flush,seclass_default,2,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_log_put,seclass_default,2,0,norest,key,1,NIL)
  LISPFUN_F(subr_bdb_log_stat,seclass_default,1,0,norest,key,1,NIL)
  LISPFUN_F(subr_bdb_make_dbc,seclass_default,1,0,norest,key,4,NIL)
  LISPFUN_F(subr_bdb_txn_abort,seclass_default,1,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_txn_begin,seclass_default,1,0,norest,key,6,NIL)
  LISPFUN_F(subr_bdb_txn_checkpoint,seclass_default,1,0,norest,key,3,NIL)
  LISPFUN_F(subr_bdb_txn_commit,seclass_default,1,0,norest,key,1,NIL)
  LISPFUN_F(subr_bdb_txn_discard,seclass_default,1,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_txn_id,seclass_default,1,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_txn_prepare,seclass_default,2,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_txn_recover,seclass_default,1,0,norest,key,2,NIL)
  LISPFUN_F(subr_bdb_txn_set_timeout,seclass_default,3,0,norest,nokey,0,NIL)
  LISPFUN_F(subr_bdb_txn_stat,seclass_default,1,0,norest,key,1,NIL)
  0
};
uintC module__bdb__subr_tab_size = (sizeof(struct module__bdb__subr_tab_t)-varobjects_misaligned-sizeof(int))/sizeof(subr_t);

struct module__bdb__subr_tab_initdata_t {
  subr_initdata_t _subr_bdb_dbc_close;
  subr_initdata_t _subr_bdb_dbc_count;
  subr_initdata_t _subr_bdb_dbc_del;
  subr_initdata_t _subr_bdb_dbc_dup;
  subr_initdata_t _subr_bdb_dbc_get;
  subr_initdata_t _subr_bdb_dbc_put;
  subr_initdata_t _subr_bdb_dbe_close;
  subr_initdata_t _subr_bdb_dbe_create;
  subr_initdata_t _subr_bdb_dbe_dbremove;
  subr_initdata_t _subr_bdb_dbe_dbrename;
  subr_initdata_t _subr_bdb_dbe_get_options;
#if defined(HAVE_DB_ENV_SET_MSGCALL)
  subr_initdata_t _subr_bdb_dbe_messages;
#endif
  subr_initdata_t _subr_bdb_dbe_open;
  subr_initdata_t _subr_bdb_dbe_remove;
  subr_initdata_t _subr_bdb_dbe_set_options;
  subr_initdata_t _subr_bdb_db_close;
  subr_initdata_t _subr_bdb_db_create;
  subr_initdata_t _subr_bdb_db_del;
  subr_initdata_t _subr_bdb_db_fd;
  subr_initdata_t _subr_bdb_db_get;
  subr_initdata_t _subr_bdb_db_get_options;
  subr_initdata_t _subr_bdb_db_join;
  subr_initdata_t _subr_bdb_db_key_range;
  subr_initdata_t _subr_bdb_db_open;
  subr_initdata_t _subr_bdb_db_put;
  subr_initdata_t _subr_bdb_db_remove;
  subr_initdata_t _subr_bdb_db_rename;
  subr_initdata_t _subr_bdb_db_set_options;
  subr_initdata_t _subr_bdb_db_stat;
  subr_initdata_t _subr_bdb_db_sync;
  subr_initdata_t _subr_bdb_db_truncate;
  subr_initdata_t _subr_bdb_db_upgrade;
  subr_initdata_t _subr_bdb_db_verify;
  subr_initdata_t _subr_bdb_db_version;
  subr_initdata_t _subr_bdb_lock_close;
  subr_initdata_t _subr_bdb_lock_detect;
  subr_initdata_t _subr_bdb_lock_get;
  subr_initdata_t _subr_bdb_lock_id;
  subr_initdata_t _subr_bdb_lock_id_free;
  subr_initdata_t _subr_bdb_lock_put;
  subr_initdata_t _subr_bdb_lock_stat;
  subr_initdata_t _subr_bdb_logc_close;
  subr_initdata_t _subr_bdb_logc_get;
  subr_initdata_t _subr_bdb_log_archive;
  subr_initdata_t _subr_bdb_log_compare;
  subr_initdata_t _subr_bdb_log_cursor;
  subr_initdata_t _subr_bdb_log_file;
  subr_initdata_t _subr_bdb_log_flush;
  subr_initdata_t _subr_bdb_log_put;
  subr_initdata_t _subr_bdb_log_stat;
  subr_initdata_t _subr_bdb_make_dbc;
  subr_initdata_t _subr_bdb_txn_abort;
  subr_initdata_t _subr_bdb_txn_begin;
  subr_initdata_t _subr_bdb_txn_checkpoint;
  subr_initdata_t _subr_bdb_txn_commit;
  subr_initdata_t _subr_bdb_txn_discard;
  subr_initdata_t _subr_bdb_txn_id;
  subr_initdata_t _subr_bdb_txn_prepare;
  subr_initdata_t _subr_bdb_txn_recover;
  subr_initdata_t _subr_bdb_txn_set_timeout;
  subr_initdata_t _subr_bdb_txn_stat;
  int _dummy_to_avoid_trailing_comma_in_initializer;
} module__bdb__subr_tab_initdata = {
  { "BDB", "DBC-CLOSE" },
  { "BDB", "DBC-COUNT" },
  { "BDB", "DBC-DEL" },
  { "BDB", "DBC-DUP" },
  { "BDB", "DBC-GET" },
  { "BDB", "DBC-PUT" },
  { "BDB", "DBE-CLOSE" },
  { "BDB", "DBE-CREATE" },
  { "BDB", "DBE-DBREMOVE" },
  { "BDB", "DBE-DBRENAME" },
  { "BDB", "DBE-GET-OPTIONS" },
#if defined(HAVE_DB_ENV_SET_MSGCALL)
  { "BDB", "DBE-MESSAGES" },
#endif
  { "BDB", "DBE-OPEN" },
  { "BDB", "DBE-REMOVE" },
  { "BDB", "DBE-SET-OPTIONS" },
  { "BDB", "DB-CLOSE" },
  { "BDB", "DB-CREATE" },
  { "BDB", "DB-DEL" },
  { "BDB", "DB-FD" },
  { "BDB", "DB-GET" },
  { "BDB", "DB-GET-OPTIONS" },
  { "BDB", "DB-JOIN" },
  { "BDB", "DB-KEY-RANGE" },
  { "BDB", "DB-OPEN" },
  { "BDB", "DB-PUT" },
  { "BDB", "DB-REMOVE" },
  { "BDB", "DB-RENAME" },
  { "BDB", "DB-SET-OPTIONS" },
  { "BDB", "DB-STAT" },
  { "BDB", "DB-SYNC" },
  { "BDB", "DB-TRUNCATE" },
  { "BDB", "DB-UPGRADE" },
  { "BDB", "DB-VERIFY" },
  { "BDB", "DB-VERSION" },
  { "BDB", "LOCK-CLOSE" },
  { "BDB", "LOCK-DETECT" },
  { "BDB", "LOCK-GET" },
  { "BDB", "LOCK-ID" },
  { "BDB", "LOCK-ID-FREE" },
  { "BDB", "LOCK-PUT" },
  { "BDB", "LOCK-STAT" },
  { "BDB", "LOGC-CLOSE" },
  { "BDB", "LOGC-GET" },
  { "BDB", "LOG-ARCHIVE" },
  { "BDB", "LOG-COMPARE" },
  { "BDB", "LOG-CURSOR" },
  { "BDB", "LOG-FILE" },
  { "BDB", "LOG-FLUSH" },
  { "BDB", "LOG-PUT" },
  { "BDB", "LOG-STAT" },
  { "BDB", "MAKE-DBC" },
  { "BDB", "TXN-ABORT" },
  { "BDB", "TXN-BEGIN" },
  { "BDB", "TXN-CHECKPOINT" },
  { "BDB", "TXN-COMMIT" },
  { "BDB", "TXN-DISCARD" },
  { "BDB", "TXN-ID" },
  { "BDB", "TXN-PREPARE" },
  { "BDB", "TXN-RECOVER" },
  { "BDB", "TXN-SET-TIMEOUT" },
  { "BDB", "TXN-STAT" },
  0
};

void module__bdb__init_function_1 (module_t* module);
void module__bdb__init_function_1 (module_t* module)
{
  pushSTACK(O(object_Kconsume));
  module__bdb__subr_tab._subr_bdb_dbc_del.keywords = vectorof(1);
  pushSTACK(O(object_Kposition));
  module__bdb__subr_tab._subr_bdb_dbc_dup.keywords = vectorof(1);
  pushSTACK(O(object_Kread_committed));
  pushSTACK(O(object_Kread_uncommitted));
  pushSTACK(O(object_Kmultiple));
  pushSTACK(O(object_Kmultiple_key));
  pushSTACK(O(object_Krmw));
  pushSTACK(O(object_Kerror));
  module__bdb__subr_tab._subr_bdb_dbc_get.keywords = vectorof(6);
  pushSTACK(O(object_Kpassword));
  pushSTACK(O(object_Kencrypt));
  pushSTACK(O(object_Khost));
  pushSTACK(O(object_Kclient_timeout));
  pushSTACK(O(object_Kserver_timeout));
  module__bdb__subr_tab._subr_bdb_dbe_create.keywords = vectorof(5);
  pushSTACK(O(object_Ktransaction));
  pushSTACK(O(object_Kauto_commit));
  module__bdb__subr_tab._subr_bdb_dbe_dbremove.keywords = vectorof(2);
  pushSTACK(O(object_Ktransaction));
  pushSTACK(O(object_Kauto_commit));
  module__bdb__subr_tab._subr_bdb_dbe_dbrename.keywords = vectorof(2);
  pushSTACK(O(object_Khome));
  pushSTACK(O(object_Kflags));
  pushSTACK(O(object_Kjoinenv));
  pushSTACK(O(object_Kinit_cdb));
  pushSTACK(O(object_Kinit_lock));
  pushSTACK(O(object_Kinit_log));
  pushSTACK(O(object_Kinit_mpool));
  pushSTACK(O(object_Kinit_txn));
  pushSTACK(O(object_Krecover));
  pushSTACK(O(object_Krecover_fatal));
  pushSTACK(O(object_Kuse_environ));
  pushSTACK(O(object_Kuse_environ_root));
  pushSTACK(O(object_Kcreate));
  pushSTACK(O(object_Klockdown));
  pushSTACK(O(object_Kprivate));
  pushSTACK(O(object_Ksystem_mem));
  pushSTACK(O(object_Kthread));
  pushSTACK(O(object_Kmode));
  module__bdb__subr_tab._subr_bdb_dbe_open.keywords = vectorof(18);
  pushSTACK(O(object_Khome));
  pushSTACK(O(object_Kforce));
  pushSTACK(O(object_Kuse_environ));
  pushSTACK(O(object_Kuse_environ_root));
  module__bdb__subr_tab._subr_bdb_dbe_remove.keywords = vectorof(4);
  pushSTACK(O(object_Kerrfile));
  pushSTACK(O(object_Kerrpfx));
  pushSTACK(O(object_Kpassword));
  pushSTACK(O(object_Kencrypt));
  pushSTACK(O(object_Klock_timeout));
  pushSTACK(O(object_Ktxn_timeout));
  pushSTACK(O(object_Ktimeout));
  pushSTACK(O(object_Kshm_key));
  pushSTACK(O(object_Ktas_spins));
  pushSTACK(O(object_Ktx_timestamp));
  pushSTACK(O(object_Ktx_max));
  pushSTACK(O(object_Kdata_dir));
  pushSTACK(O(object_Ktmp_dir));
  pushSTACK(O(object_Kintermediate_dir_mode));
  pushSTACK(O(object_Klg_bsize));
  pushSTACK(O(object_Klg_dir));
  pushSTACK(O(object_Klg_max));
  pushSTACK(O(object_Klg_regionmax));
  pushSTACK(O(object_Kncache));
  pushSTACK(O(object_Kcachesize));
  pushSTACK(O(object_Kcache));
  pushSTACK(O(object_Klk_conflicts));
  pushSTACK(O(object_Klk_detect));
  pushSTACK(O(object_Klk_max_lockers));
  pushSTACK(O(object_Klk_max_locks));
  pushSTACK(O(object_Klk_max_objects));
  pushSTACK(O(object_Klog_direct));
  pushSTACK(O(object_Klog_dsync));
  pushSTACK(O(object_Klog_auto_remove));
  pushSTACK(O(object_Klog_in_memory));
  pushSTACK(O(object_Klog_zero));
  pushSTACK(O(object_Kauto_commit));
  pushSTACK(O(object_Kcdb_alldb));
  pushSTACK(O(object_Kdirect_db));
  pushSTACK(O(object_Knolocking));
  pushSTACK(O(object_Knommap));
  pushSTACK(O(object_Knopanic));
  pushSTACK(O(object_Koverwrite));
  pushSTACK(O(object_Kpanic_environment));
  pushSTACK(O(object_Kregion_init));
  pushSTACK(O(object_Ktxn_nosync));
  pushSTACK(O(object_Ktxn_write_nosync));
  pushSTACK(O(object_Kyieldcpu));
  pushSTACK(O(object_Kverb_chkpoint));
  pushSTACK(O(object_Kverb_deadlock));
  pushSTACK(O(object_Kverb_recovery));
  pushSTACK(O(object_Kverb_replication));
  pushSTACK(O(object_Kverb_waitsfor));
  pushSTACK(O(object_Kverbose));
  pushSTACK(O(object_Kmsgfile));
  module__bdb__subr_tab._subr_bdb_dbe_set_options.keywords = vectorof(50);
  pushSTACK(O(object_Knosync));
  module__bdb__subr_tab._subr_bdb_db_close.keywords = vectorof(1);
  pushSTACK(O(object_Ktransaction));
  pushSTACK(O(object_Kauto_commit));
  module__bdb__subr_tab._subr_bdb_db_del.keywords = vectorof(2);
  pushSTACK(O(object_Kaction));
  pushSTACK(O(object_Kauto_commit));
  pushSTACK(O(object_Kread_committed));
  pushSTACK(O(object_Kread_uncommitted));
  pushSTACK(O(object_Kmultiple));
  pushSTACK(O(object_Krmw));
  pushSTACK(O(object_Ktransaction));
  pushSTACK(O(object_Kerror));
  pushSTACK(O(object_Ktype));
  pushSTACK(O(object_Kkey_type));
  module__bdb__subr_tab._subr_bdb_db_get.keywords = vectorof(10);
  pushSTACK(O(object_Kjoin_nosort));
  module__bdb__subr_tab._subr_bdb_db_join.keywords = vectorof(1);
  pushSTACK(O(object_Ktransaction));
  module__bdb__subr_tab._subr_bdb_db_key_range.keywords = vectorof(1);
  pushSTACK(O(object_Kdatabase));
  pushSTACK(O(object_Ktype));
  pushSTACK(O(object_Kmode));
  pushSTACK(O(object_Kflags));
  pushSTACK(O(object_Kcreate));
  pushSTACK(O(object_Kread_uncommitted));
  pushSTACK(O(object_Kexcl));
  pushSTACK(O(object_Knommap));
  pushSTACK(O(object_Krdonly));
  pushSTACK(O(object_Kthread));
  pushSTACK(O(object_Ktruncate));
  pushSTACK(O(object_Kauto_commit));
  pushSTACK(O(object_Ktransaction));
  module__bdb__subr_tab._subr_bdb_db_open.keywords = vectorof(13);
  pushSTACK(O(object_Kauto_commit));
  pushSTACK(O(object_Kaction));
  pushSTACK(O(object_Ktransaction));
  module__bdb__subr_tab._subr_bdb_db_put.keywords = vectorof(3);
  pushSTACK(O(object_Kmsgfile));
  pushSTACK(O(object_Kerrfile));
  pushSTACK(O(object_Kerrpfx));
  pushSTACK(O(object_Kpassword));
  pushSTACK(O(object_Kencryption));
  pushSTACK(O(object_Kncache));
  pushSTACK(O(object_Kcachesize));
  pushSTACK(O(object_Kcache));
  pushSTACK(O(object_Klorder));
  pushSTACK(O(object_Kpagesize));
  pushSTACK(O(object_Kbt_minkey));
  pushSTACK(O(object_Kh_ffactor));
  pushSTACK(O(object_Kh_nelem));
  pushSTACK(O(object_Kq_extentsize));
  pushSTACK(O(object_Kre_delim));
  pushSTACK(O(object_Kre_len));
  pushSTACK(O(object_Kre_pad));
  pushSTACK(O(object_Kre_source));
  pushSTACK(O(object_Kchksum));
  pushSTACK(O(object_Kdup));
  pushSTACK(O(object_Kdupsort));
  pushSTACK(O(object_Kencrypt));
  pushSTACK(O(object_Kinorder));
  pushSTACK(O(object_Krecnum));
  pushSTACK(O(object_Krenumber));
  pushSTACK(O(object_Krevsplitoff));
  pushSTACK(O(object_Ksnapshot));
  pushSTACK(O(object_Ktxn_not_durable));
  module__bdb__subr_tab._subr_bdb_db_set_options.keywords = vectorof(28);
  pushSTACK(O(object_Kfast_stat));
  pushSTACK(O(object_Ktransaction));
  module__bdb__subr_tab._subr_bdb_db_stat.keywords = vectorof(2);
  pushSTACK(O(object_Ktransaction));
  pushSTACK(O(object_Kauto_commit));
  module__bdb__subr_tab._subr_bdb_db_truncate.keywords = vectorof(2);
  pushSTACK(O(object_Kdupsort));
  module__bdb__subr_tab._subr_bdb_db_upgrade.keywords = vectorof(1);
  pushSTACK(O(object_Kdatabase));
  pushSTACK(O(object_Ksalvage));
  pushSTACK(O(object_Kaggressive));
  pushSTACK(O(object_Kprintable));
  pushSTACK(O(object_Knoorderchk));
  module__bdb__subr_tab._subr_bdb_db_verify.keywords = vectorof(5);
  pushSTACK(O(object_Knowait));
  module__bdb__subr_tab._subr_bdb_lock_get.keywords = vectorof(1);
  pushSTACK(O(object_Kstat_clear));
  module__bdb__subr_tab._subr_bdb_lock_stat.keywords = vectorof(1);
  pushSTACK(O(object_Ktype));
  pushSTACK(O(object_Kerror));
  module__bdb__subr_tab._subr_bdb_logc_get.keywords = vectorof(2);
  pushSTACK(O(object_Karch_abs));
  pushSTACK(O(object_Karch_data));
  pushSTACK(O(object_Karch_log));
  pushSTACK(O(object_Karch_remove));
  module__bdb__subr_tab._subr_bdb_log_archive.keywords = vectorof(4);
  pushSTACK(O(object_Kflush));
  module__bdb__subr_tab._subr_bdb_log_put.keywords = vectorof(1);
  pushSTACK(O(object_Kstat_clear));
  module__bdb__subr_tab._subr_bdb_log_stat.keywords = vectorof(1);
  pushSTACK(O(object_Ktransaction));
  pushSTACK(O(object_Kread_committed));
  pushSTACK(O(object_Kread_uncommitted));
  pushSTACK(O(object_Kwritecursor));
  module__bdb__subr_tab._subr_bdb_make_dbc.keywords = vectorof(4);
  pushSTACK(O(object_Kparent));
  pushSTACK(O(object_Kread_committed));
  pushSTACK(O(object_Kread_uncommitted));
  pushSTACK(O(object_Knosync));
  pushSTACK(O(object_Knowait));
  pushSTACK(O(object_Ksync));
  module__bdb__subr_tab._subr_bdb_txn_begin.keywords = vectorof(6);
  pushSTACK(O(object_Kkbyte));
  pushSTACK(O(object_Kmin));
  pushSTACK(O(object_Kforce));
  module__bdb__subr_tab._subr_bdb_txn_checkpoint.keywords = vectorof(3);
  pushSTACK(O(object_Ksync));
  module__bdb__subr_tab._subr_bdb_txn_commit.keywords = vectorof(1);
  pushSTACK(O(object_Kfirst));
  pushSTACK(O(object_Knext));
  module__bdb__subr_tab._subr_bdb_txn_recover.keywords = vectorof(2);
  pushSTACK(O(object_Kstat_clear));
  module__bdb__subr_tab._subr_bdb_txn_stat.keywords = vectorof(1);
  O(giga_byte) = (O(object__23_2E_28byte_2030_200_29));
}

void module__bdb__fini_function (module_t* module);
void module__bdb__fini_function (module_t* module)
{
}
