diff options
author | jbj <devnull@localhost> | 2002-08-14 19:19:13 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2002-08-14 19:19:13 +0000 |
commit | 41d4fce5c44bed0df416eac8f24f31240a391b22 (patch) | |
tree | 37aaec5d8afb11eaefd0a86d11e6400b87ee5baa /db | |
parent | 372fe8d762b5d501f546e37996d5e5e9185ba558 (diff) | |
download | rpm-41d4fce5c44bed0df416eac8f24f31240a391b22.tar.gz rpm-41d4fce5c44bed0df416eac8f24f31240a391b22.tar.bz2 rpm-41d4fce5c44bed0df416eac8f24f31240a391b22.zip |
db-4.1.17 orphans.
CVS patchset: 5634
CVS date: 2002/08/14 19:19:13
Diffstat (limited to 'db')
-rw-r--r-- | db/build_win32/db_cxx.h | 404 | ||||
-rw-r--r-- | db/build_win32/db_perf.dsp | 428 | ||||
-rw-r--r-- | db/cxx/cxx_db.cpp | 768 | ||||
-rw-r--r-- | db/cxx/cxx_dbc.cpp | 192 | ||||
-rw-r--r-- | db/cxx/cxx_dbt.cpp | 19 | ||||
-rw-r--r-- | db/cxx/cxx_env.cpp | 878 | ||||
-rw-r--r-- | db/cxx/cxx_logc.cpp | 58 | ||||
-rw-r--r-- | db/dist/aclocal/config.ac | 8 | ||||
-rw-r--r-- | db/dist/aclocal/cxx.ac | 2 | ||||
-rw-r--r-- | db/dist/aclocal/libtool.ac | 50 | ||||
-rw-r--r-- | db/dist/aclocal/mutex.ac | 608 | ||||
-rw-r--r-- | db/dist/aclocal/options.ac | 72 | ||||
-rw-r--r-- | db/dist/buildrel | 40 | ||||
-rw-r--r-- | db/dist/configure.ac | 271 | ||||
-rw-r--r-- | db/dist/pubdef.in | 98 | ||||
-rwxr-xr-x | db/dist/s_test | 49 | ||||
-rw-r--r-- | db/dist/win_exports.in | 34 |
17 files changed, 1948 insertions, 2031 deletions
diff --git a/db/build_win32/db_cxx.h b/db/build_win32/db_cxx.h index df7e1ddfd..7c4967228 100644 --- a/db/build_win32/db_cxx.h +++ b/db/build_win32/db_cxx.h @@ -2,10 +2,10 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997-2001 + * Copyright (c) 1997-2002 * Sleepycat Software. All rights reserved. * - * Id: db_cxx.in,v 11.87 2001/11/09 21:31:35 bostic Exp + * Id: db_cxx.in,v 11.112 2002/08/08 23:44:43 mjc Exp */ #ifndef _DB_CXX_H_ @@ -55,10 +55,10 @@ #define HAVE_CXX_STDHEADERS 1 #ifdef HAVE_CXX_STDHEADERS #include <iostream> -#define OSTREAMCLASS std::ostream +#define __DB_OSTREAMCLASS std::ostream #else #include <iostream.h> -#define OSTREAMCLASS ostream +#define __DB_OSTREAMCLASS ostream #endif #include "db.h" @@ -73,6 +73,7 @@ class DbLock; // forward class DbLogc; // forward class DbLsn; // forward class DbMpoolFile; // forward +class DbPreplist; // forward class Dbt; // forward class DbTxn; // forward @@ -162,9 +163,6 @@ class _exported DbLock public: DbLock(); - - int put(DbEnv *env); - DbLock(const DbLock &); DbLock &operator = (const DbLock &); @@ -199,6 +197,10 @@ class _exported DbMpoolFile { friend class DbEnv; +private: + // Put this first to allow inlining with some C++ compilers (g++-2.95) + DEFINE_DB_CLASS(DbMpoolFile); + public: int close(u_int32_t flags); int get(db_pgno_t *pgnoaddr, u_int32_t flags, void *pagep); @@ -215,6 +217,16 @@ public: void set_unlink(int); int sync(); + virtual DB_MPOOLFILE *get_DB_MPOOLFILE() + { + return (DB_MPOOLFILE *)imp(); + } + + virtual const DB_MPOOLFILE *get_const_DB_MPOOLFILE() const + { + return (const DB_MPOOLFILE *)constimp(); + } + private: // We can add data to this class if needed // since it is implemented via a pointer. @@ -227,14 +239,25 @@ private: // Shut g++ up. protected: - ~DbMpoolFile(); + virtual ~DbMpoolFile(); private: // no copying DbMpoolFile(const DbMpoolFile &); void operator = (const DbMpoolFile &); +}; - DEFINE_DB_CLASS(DbMpoolFile); +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +// +// This is filled in and returned by the DbEnv::txn_recover() method. +// + +class _exported DbPreplist +{ +public: + DbTxn *txn; + u_int8_t gid[DB_XIDDATASIZE]; }; //////////////////////////////////////////////////////////////// @@ -247,13 +270,41 @@ class _exported DbTxn { friend class DbEnv; +private: + // Put this first to allow inlining with some C++ compilers (g++-2.95) + DEFINE_DB_CLASS(DbTxn); + public: int abort(); int commit(u_int32_t flags); + int discard(u_int32_t flags); u_int32_t id(); int prepare(u_int8_t *gid); int set_timeout(db_timeout_t timeout, u_int32_t flags); + virtual DB_TXN *get_DB_TXN() + { + return (DB_TXN *)imp(); + } + + virtual const DB_TXN *get_const_DB_TXN() const + { + return (const DB_TXN *)constimp(); + } + + static DbTxn* get_DbTxn(DB_TXN *txn) + { + return (DbTxn *)txn->api_internal; + } + + static const DbTxn* get_const_DbTxn(const DB_TXN *txn) + { + return (const DbTxn *)txn->api_internal; + } + + // For internal use only. + static DbTxn* wrap_DB_TXN(DB_TXN *txn); + private: // We can add data to this class if needed // since it is implemented via a pointer. @@ -264,13 +315,13 @@ private: // delete to release them. // DbTxn(); - ~DbTxn(); + // For internal use only. + DbTxn(DB_TXN *txn); + virtual ~DbTxn(); // no copying DbTxn(const DbTxn &); void operator = (const DbTxn &); - - DEFINE_DB_CLASS(DbTxn); }; // @@ -288,10 +339,11 @@ class _exported DbEnv friend class DbLock; friend class DbMpoolFile; -public: - - ~DbEnv(); +private: + // Put this first to allow inlining with some C++ compilers (g++-2.95) + DEFINE_DB_CLASS(DbEnv); +public: // After using this constructor, you can set any needed // parameters for the environment using the set_* methods. // Then call open() to finish initializing the environment @@ -299,46 +351,53 @@ public: // DbEnv(u_int32_t flags); + virtual ~DbEnv(); + // These methods match those in the C interface. // - int close(u_int32_t); - void err(int, const char *, ...); - void errx(const char *, ...); - void *get_app_private() const; - int open(const char *, u_int32_t, int); - int remove(const char *, u_int32_t); - int set_alloc(db_malloc_fcn_type, db_realloc_fcn_type, + virtual int close(u_int32_t); + virtual int dbremove(DbTxn *txn, const char *name, const char *subdb, + u_int32_t flags); + virtual int dbrename(DbTxn *txn, const char *name, const char *subdb, + const char *newname, u_int32_t flags); + virtual void err(int, const char *, ...); + virtual void errx(const char *, ...); + virtual void *get_app_private() const; + virtual int open(const char *, u_int32_t, int); + virtual int remove(const char *, u_int32_t); + virtual int set_alloc(db_malloc_fcn_type, db_realloc_fcn_type, db_free_fcn_type); - void set_app_private(void *); - int set_cachesize(u_int32_t, u_int32_t, int); - int set_data_dir(const char *); - void set_errcall(void (*)(const char *, char *)); - void set_errfile(FILE *); - void set_errpfx(const char *); - int set_flags(u_int32_t, int); - int set_feedback(void (*)(DbEnv *, int, int)); - int set_recovery_init(int (*)(DbEnv *)); - int set_lg_bsize(u_int32_t); - int set_lg_dir(const char *); - int set_lg_max(u_int32_t); - int set_lg_regionmax(u_int32_t); - int set_lk_conflicts(u_int8_t *, int); - int set_lk_detect(u_int32_t); - int set_lk_max(u_int32_t); - int set_lk_max_lockers(u_int32_t); - int set_lk_max_locks(u_int32_t); - int set_lk_max_objects(u_int32_t); - int set_mp_mmapsize(size_t); - int set_paniccall(void (*)(DbEnv *, int)); - int set_rpc_server(void *, char *, long, long, u_int32_t); - int set_shm_key(long); - int set_timeout(db_timeout_t timeout, u_int32_t flags); - int set_tmp_dir(const char *); - int set_tas_spins(u_int32_t); - int set_tx_max(u_int32_t); - int set_tx_recover(int (*)(DbEnv *, Dbt *, DbLsn *, db_recops)); - int set_tx_timestamp(time_t *); - int set_verbose(u_int32_t which, int onoff); + virtual void set_app_private(void *); + virtual int set_cachesize(u_int32_t, u_int32_t, int); + virtual int set_data_dir(const char *); + virtual int set_encrypt(const char *, int); + virtual void set_errcall(void (*)(const char *, char *)); + virtual void set_errfile(FILE *); + virtual void set_errpfx(const char *); + virtual int set_flags(u_int32_t, int); + virtual int set_feedback(void (*)(DbEnv *, int, int)); + virtual int set_lg_bsize(u_int32_t); + virtual int set_lg_dir(const char *); + virtual int set_lg_max(u_int32_t); + virtual int set_lg_regionmax(u_int32_t); + virtual int set_lk_conflicts(u_int8_t *, int); + virtual int set_lk_detect(u_int32_t); + virtual int set_lk_max(u_int32_t); + virtual int set_lk_max_lockers(u_int32_t); + virtual int set_lk_max_locks(u_int32_t); + virtual int set_lk_max_objects(u_int32_t); + virtual int set_mp_mmapsize(size_t); + virtual int set_paniccall(void (*)(DbEnv *, int)); + virtual int set_rpc_server(void *, char *, long, long, u_int32_t); + virtual int set_shm_key(long); + virtual int set_timeout(db_timeout_t timeout, u_int32_t flags); + virtual int set_tmp_dir(const char *); + virtual int set_tas_spins(u_int32_t); + virtual int set_tx_max(u_int32_t); + virtual int set_app_dispatch(int (*)(DbEnv *, + Dbt *, DbLsn *, db_recops)); + virtual int set_tx_timestamp(time_t *); + virtual int set_verbose(u_int32_t which, int onoff); // Version information. A static method so it can be obtained anytime. // @@ -356,96 +415,103 @@ public: // set_error_stream() to force all errors to a C++ stream. // It is unwise to mix these approaches. // - void set_error_stream(OSTREAMCLASS *); + virtual void set_error_stream(__DB_OSTREAMCLASS *); // used internally static void runtime_error(const char *caller, int err, int error_policy); static void runtime_error_dbt(const char *caller, Dbt *dbt, int error_policy); + static void runtime_error_lock_get(const char *caller, int err, + db_lockop_t op, db_lockmode_t mode, + const Dbt *obj, DbLock lock, int index, + int error_policy); // Lock functions // - int lock_detect(u_int32_t flags, u_int32_t atype, int *aborted); - int lock_get(u_int32_t locker, u_int32_t flags, const Dbt *obj, + virtual int lock_detect(u_int32_t flags, u_int32_t atype, int *aborted); + virtual int lock_get(u_int32_t locker, u_int32_t flags, const Dbt *obj, db_lockmode_t lock_mode, DbLock *lock); - int lock_id(u_int32_t *idp); - int lock_id_free(u_int32_t id); - int lock_stat(DB_LOCK_STAT **statp, u_int32_t flags); - int lock_vec(u_int32_t locker, u_int32_t flags, DB_LOCKREQ list[], + virtual int lock_id(u_int32_t *idp); + virtual int lock_id_free(u_int32_t id); + virtual int lock_put(DbLock *lock); + virtual int lock_stat(DB_LOCK_STAT **statp, u_int32_t flags); + virtual int lock_vec(u_int32_t locker, u_int32_t flags, DB_LOCKREQ list[], int nlist, DB_LOCKREQ **elistp); // Log functions // - int log_archive(char **list[], u_int32_t flags); + virtual int log_archive(char **list[], u_int32_t flags); static int log_compare(const DbLsn *lsn0, const DbLsn *lsn1); - int log_cursor(DbLogc **cursorp, u_int32_t flags); - int log_file(DbLsn *lsn, char *namep, size_t len); - int log_flush(const DbLsn *lsn); - int log_put(DbLsn *lsn, const Dbt *data, u_int32_t flags); + virtual int log_cursor(DbLogc **cursorp, u_int32_t flags); + virtual int log_file(DbLsn *lsn, char *namep, size_t len); + virtual int log_flush(const DbLsn *lsn); + virtual int log_put(DbLsn *lsn, const Dbt *data, u_int32_t flags); - int log_register(Db *dbp, const char *name); - int log_stat(DB_LOG_STAT **spp, u_int32_t flags); - int log_unregister(Db *dbp); + virtual int log_stat(DB_LOG_STAT **spp, u_int32_t flags); // Mpool functions // - int memp_fcreate(DbMpoolFile **dbmfp, u_int32_t flags); - int memp_register(int ftype, + virtual int memp_fcreate(DbMpoolFile **dbmfp, u_int32_t flags); + virtual int memp_register(int ftype, pgin_fcn_type pgin_fcn, pgout_fcn_type pgout_fcn); - int memp_stat(DB_MPOOL_STAT + virtual int memp_stat(DB_MPOOL_STAT **gsp, DB_MPOOL_FSTAT ***fsp, u_int32_t flags); - int memp_sync(DbLsn *lsn); - int memp_trickle(int pct, int *nwrotep); + virtual int memp_sync(DbLsn *lsn); + virtual int memp_trickle(int pct, int *nwrotep); // Transaction functions // - int txn_begin(DbTxn *pid, DbTxn **tid, u_int32_t flags); - int txn_checkpoint(u_int32_t kbyte, u_int32_t min, u_int32_t flags); - int txn_recover(DB_PREPLIST *preplist, long count, + virtual int txn_begin(DbTxn *pid, DbTxn **tid, u_int32_t flags); + virtual int txn_checkpoint(u_int32_t kbyte, u_int32_t min, u_int32_t flags); + virtual int txn_recover(DbPreplist *preplist, long count, long *retp, u_int32_t flags); - int txn_stat(DB_TXN_STAT **statp, u_int32_t flags); + virtual int txn_stat(DB_TXN_STAT **statp, u_int32_t flags); // Replication functions // - int rep_elect(int, int, u_int32_t, int *); - int rep_process_message(Dbt *, Dbt *, int *); - int rep_start(Dbt *, u_int32_t); - int set_rep_transport(u_int32_t, + virtual int rep_elect(int, int, u_int32_t, int *); + virtual int rep_process_message(Dbt *, Dbt *, int *); + virtual int rep_start(Dbt *, u_int32_t); + virtual int rep_stat(DB_REP_STAT **statp, u_int32_t flags); + virtual int set_rep_limit(u_int32_t, u_int32_t); + virtual int set_rep_transport(u_int32_t, int (*)(DbEnv *, const Dbt *, const Dbt *, int, u_int32_t)); // Conversion functions // - DB_ENV *get_DB_ENV() + virtual DB_ENV *get_DB_ENV() { return (DB_ENV *)imp(); } - const DB_ENV *get_const_DB_ENV() const + virtual const DB_ENV *get_const_DB_ENV() const { return (const DB_ENV *)constimp(); } static DbEnv* get_DbEnv(DB_ENV *dbenv) { - return (DbEnv *)dbenv->cj_internal; + return (DbEnv *)dbenv->api1_internal; } static const DbEnv* get_const_DbEnv(const DB_ENV *dbenv) { - return (const DbEnv *)dbenv->cj_internal; + return (const DbEnv *)dbenv->api1_internal; } + // For internal use only. + static DbEnv* wrap_DB_ENV(DB_ENV *dbenv); + // These are public only because they need to be called // via C functions. They should never be called by users // of this class. // static void _stream_error_function(const char *, char *); - static int _tx_recover_intercept(DB_ENV *env, DBT *dbt, DB_LSN *lsn, + static int _app_dispatch_intercept(DB_ENV *env, DBT *dbt, DB_LSN *lsn, db_recops op); static void _paniccall_intercept(DB_ENV *env, int errval); - static int _recovery_init_intercept(DB_ENV *env); static void _feedback_intercept(DB_ENV *env, int opcode, int pct); static int _rep_send_intercept(DB_ENV *env, const DBT *cntrl, const DBT *data, @@ -457,22 +523,19 @@ private: int initialize(DB_ENV *env); int error_policy(); - // Used internally + // For internal use only. DbEnv(DB_ENV *, u_int32_t flags); // no copying DbEnv(const DbEnv &); void operator = (const DbEnv &); - DEFINE_DB_CLASS(DbEnv); - // instance data int construct_error_; u_int32_t construct_flags_; - int (*tx_recover_callback_)(DbEnv *, Dbt *, DbLsn *, db_recops); - int (*recovery_init_callback_)(DbEnv *); - void (*paniccall_callback_)(DbEnv *, int); + int (*app_dispatch_callback_)(DbEnv *, Dbt *, DbLsn *, db_recops); void (*feedback_callback_)(DbEnv *, int, int); + void (*paniccall_callback_)(DbEnv *, int); int (*pgin_callback_)(DbEnv *dbenv, db_pgno_t pgno, void *pgaddr, Dbt *pgcookie); int (*pgout_callback_)(DbEnv *dbenv, db_pgno_t pgno, @@ -481,7 +544,7 @@ private: const Dbt *, const Dbt *, int, u_int32_t); // class data - static OSTREAMCLASS *error_stream_; + static __DB_OSTREAMCLASS *error_stream_; }; //////////////////////////////////////////////////////////////// @@ -497,112 +560,106 @@ class _exported Db { friend class DbEnv; +private: + // Put this first to allow inlining with some C++ compilers (g++-2.95) + DEFINE_DB_CLASS(Db); + public: Db(DbEnv*, u_int32_t); // create a Db object, then call open() - ~Db(); // does *not* call close. + virtual ~Db(); // does *not* call close. // These methods exactly match those in the C interface. // - int associate(Db *secondary, int (*callback)(Db *, const Dbt *, - const Dbt *, Dbt *), u_int32_t flags); - int close(u_int32_t flags); - int cursor(DbTxn *txnid, Dbc **cursorp, u_int32_t flags); - int del(DbTxn *txnid, Dbt *key, u_int32_t flags); - void err(int, const char *, ...); - void errx(const char *, ...); - int fd(int *fdp); - int get(DbTxn *txnid, Dbt *key, Dbt *data, u_int32_t flags); - void *get_app_private() const; - int get_byteswapped(int *); - int get_type(DBTYPE *); - int join(Dbc **curslist, Dbc **dbcp, u_int32_t flags); - int key_range(DbTxn *, Dbt *, DB_KEY_RANGE *, u_int32_t); - int open(const char *, const char *subname, DBTYPE, u_int32_t, int); - int pget(DbTxn *txnid, Dbt *key, Dbt *pkey, Dbt *data, + virtual int associate(DbTxn *txn, Db *secondary, + int (*callback)(Db *, const Dbt *, const Dbt *, Dbt *), + u_int32_t flags); + virtual int close(u_int32_t flags); + virtual int cursor(DbTxn *txnid, Dbc **cursorp, u_int32_t flags); + virtual int del(DbTxn *txnid, Dbt *key, u_int32_t flags); + virtual void err(int, const char *, ...); + virtual void errx(const char *, ...); + virtual int fd(int *fdp); + virtual int get(DbTxn *txnid, Dbt *key, Dbt *data, u_int32_t flags); + virtual void *get_app_private() const; + virtual int get_byteswapped(int *); + virtual int get_type(DBTYPE *); + virtual int join(Dbc **curslist, Dbc **dbcp, u_int32_t flags); + virtual int key_range(DbTxn *, Dbt *, DB_KEY_RANGE *, u_int32_t); + virtual int open(DbTxn *txnid, + const char *, const char *subname, DBTYPE, u_int32_t, int); + virtual int pget(DbTxn *txnid, Dbt *key, Dbt *pkey, Dbt *data, u_int32_t flags); - int put(DbTxn *, Dbt *, Dbt *, u_int32_t); - int remove(const char *, const char *, u_int32_t); - int rename(const char *, const char *, const char *, u_int32_t); - int set_alloc(db_malloc_fcn_type, db_realloc_fcn_type, + virtual int put(DbTxn *, Dbt *, Dbt *, u_int32_t); + virtual int remove(const char *, const char *, u_int32_t); + virtual int rename(const char *, const char *, const char *, u_int32_t); + virtual int set_alloc(db_malloc_fcn_type, db_realloc_fcn_type, db_free_fcn_type); - void set_app_private(void *); - int set_append_recno(int (*)(Db *, Dbt *, db_recno_t)); - int set_bt_compare(bt_compare_fcn_type); /*deprecated*/ - int set_bt_compare(int (*)(Db *, const Dbt *, const Dbt *)); - int set_bt_maxkey(u_int32_t); - int set_bt_minkey(u_int32_t); - int set_bt_prefix(bt_prefix_fcn_type); /*deprecated*/ - int set_bt_prefix(size_t (*)(Db *, const Dbt *, const Dbt *)); - int set_cachesize(u_int32_t, u_int32_t, int); - int set_dup_compare(dup_compare_fcn_type); /*deprecated*/ - int set_dup_compare(int (*)(Db *, const Dbt *, const Dbt *)); - void set_errcall(void (*)(const char *, char *)); - void set_errfile(FILE *); - void set_errpfx(const char *); - int set_feedback(void (*)(Db *, int, int)); - int set_flags(u_int32_t); - int set_h_ffactor(u_int32_t); - int set_h_hash(h_hash_fcn_type); /*deprecated*/ - int set_h_hash(u_int32_t (*)(Db *, const void *, u_int32_t)); - int set_h_nelem(u_int32_t); - int set_lorder(int); - int set_pagesize(u_int32_t); - int set_paniccall(void (*)(DbEnv *, int)); - int set_re_delim(int); - int set_re_len(u_int32_t); - int set_re_pad(int); - int set_re_source(char *); - int set_q_extentsize(u_int32_t); - int stat(void *sp, u_int32_t flags); - int sync(u_int32_t flags); - int truncate(DbTxn *, u_int32_t *, u_int32_t); - int upgrade(const char *name, u_int32_t flags); - int verify(const char *, const char *, OSTREAMCLASS *, u_int32_t); + virtual void set_app_private(void *); + virtual int set_append_recno(int (*)(Db *, Dbt *, db_recno_t)); + virtual int set_bt_compare(bt_compare_fcn_type); /*deprecated*/ + virtual int set_bt_compare(int (*)(Db *, const Dbt *, const Dbt *)); + virtual int set_bt_maxkey(u_int32_t); + virtual int set_bt_minkey(u_int32_t); + virtual int set_bt_prefix(bt_prefix_fcn_type); /*deprecated*/ + virtual int set_bt_prefix(size_t (*)(Db *, const Dbt *, const Dbt *)); + virtual int set_cachesize(u_int32_t, u_int32_t, int); + virtual int set_cache_priority(DB_CACHE_PRIORITY); + virtual int set_dup_compare(dup_compare_fcn_type); /*deprecated*/ + virtual int set_dup_compare(int (*)(Db *, const Dbt *, const Dbt *)); + virtual int set_encrypt(const char *, int); + virtual void set_errcall(void (*)(const char *, char *)); + virtual void set_errfile(FILE *); + virtual void set_errpfx(const char *); + virtual int set_feedback(void (*)(Db *, int, int)); + virtual int set_flags(u_int32_t); + virtual int set_h_ffactor(u_int32_t); + virtual int set_h_hash(h_hash_fcn_type); /*deprecated*/ + virtual int set_h_hash(u_int32_t (*)(Db *, const void *, u_int32_t)); + virtual int set_h_nelem(u_int32_t); + virtual int set_lorder(int); + virtual int set_pagesize(u_int32_t); + virtual int set_paniccall(void (*)(DbEnv *, int)); + virtual int set_re_delim(int); + virtual int set_re_len(u_int32_t); + virtual int set_re_pad(int); + virtual int set_re_source(char *); + virtual int set_q_extentsize(u_int32_t); + virtual int stat(void *sp, u_int32_t flags); + virtual int sync(u_int32_t flags); + virtual int truncate(DbTxn *, u_int32_t *, u_int32_t); + virtual int upgrade(const char *name, u_int32_t flags); + virtual int verify(const char *, const char *, __DB_OSTREAMCLASS *, u_int32_t); // These additional methods are not in the C interface, and // are only available for C++. // - void set_error_stream(OSTREAMCLASS *); + virtual void set_error_stream(__DB_OSTREAMCLASS *); - DB *get_DB() + virtual DB *get_DB() { return (DB *)imp(); } - const DB *get_const_DB() const + virtual const DB *get_const_DB() const { return (const DB *)constimp(); } static Db* get_Db(DB *db) { - return (Db *)db->cj_internal; + return (Db *)db->api_internal; } static const Db* get_const_Db(const DB *db) { - return (const Db *)db->cj_internal; + return (const Db *)db->api_internal; } - // These are public only because they need to be called - // via C callback functions. They should never be used by - // external users of this class. - // - void (*feedback_callback_)(Db *, int, int); - int (*append_recno_callback_)(Db *, Dbt *, db_recno_t); - int (*bt_compare_callback_)(Db *, const Dbt *, const Dbt *); - size_t (*bt_prefix_callback_)(Db *, const Dbt *, const Dbt *); - int (*dup_compare_callback_)(Db *, const Dbt *, const Dbt *); - u_int32_t (*h_hash_callback_)(Db *, const void *, u_int32_t); - int (*associate_callback_)(Db *, const Dbt *, const Dbt *, Dbt *); private: - // no copying Db(const Db &); Db &operator = (const Db &); - DEFINE_DB_CLASS(Db); - void cleanup(); int initialize(); int error_policy(); @@ -612,6 +669,19 @@ private: int construct_error_; u_int32_t flags_; u_int32_t construct_flags_; + +public: + // These are public only because they need to be called + // via C callback functions. They should never be used by + // external users of this class. + // + int (*append_recno_callback_)(Db *, Dbt *, db_recno_t); + int (*associate_callback_)(Db *, const Dbt *, const Dbt *, Dbt *); + int (*bt_compare_callback_)(Db *, const Dbt *, const Dbt *); + size_t (*bt_prefix_callback_)(Db *, const Dbt *, const Dbt *); + int (*dup_compare_callback_)(Db *, const Dbt *, const Dbt *); + void (*feedback_callback_)(Db *, int, int); + u_int32_t (*h_hash_callback_)(Db *, const void *, u_int32_t); }; // @@ -658,7 +728,7 @@ public: static const Dbt* get_const_Dbt(const DBT *dbt) { return (const Dbt *)dbt; } - Dbt(void *data, size_t size); + Dbt(void *data, u_int32_t size); Dbt(); ~Dbt(); Dbt(const Dbt &); diff --git a/db/build_win32/db_perf.dsp b/db/build_win32/db_perf.dsp index ae3ef78d9..21b79ed9e 100644 --- a/db/build_win32/db_perf.dsp +++ b/db/build_win32/db_perf.dsp @@ -1,212 +1,216 @@ -# Microsoft Developer Studio Project File - Name="db_perf" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=db_perf - Win32 Debug Static -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "db_perf.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "db_perf.mak" CFG="db_perf - Win32 Debug Static" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "db_perf - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "db_perf - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE "db_perf - Win32 Release Static" (based on "Win32 (x86) Console Application") -!MESSAGE "db_perf - Win32 Debug Static" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "db_perf - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "../include" /I "../include_auto" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 Release/libdb40.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"libcmt" - -!ELSEIF "$(CFG)" == "db_perf - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "." /I "../include" /I "../include_auto" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 Debug/libdb40d.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /nodefaultlib:"libcmtd" /fixed:no - -!ELSEIF "$(CFG)" == "db_perf - Win32 Release Static" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release_static" -# PROP Intermediate_Dir "Release_static" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "." /I "../include" /I "../include_auto" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "." /I "../include" /I "../include_auto" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 Release_static/libdb40.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 Release_static/libdb40s.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "db_perf - Win32 Debug Static" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug_static" -# PROP Intermediate_Dir "Debug_static" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /GX /Z7 /Od /I "." /I "../include" /I "../include_auto" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "." /I "../include" /I "../include_auto" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 Debug_static/libdb40d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /fixed:no -# ADD LINK32 Debug_static/libdb40sd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /fixed:no - -!ENDIF - -# Begin Target - -# Name "db_perf - Win32 Release" -# Name "db_perf - Win32 Debug" -# Name "db_perf - Win32 Release Static" -# Name "db_perf - Win32 Debug Static" -# Begin Source File - -SOURCE=..\test_perf\db_perf.c -# End Source File -# Begin Source File - -SOURCE=..\clib\getopt.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_cache_check.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_checkpoint.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_config.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_dbs.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_debug.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_file.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_key.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_log.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_misc.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_op.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_parse.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_spawn.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_thread.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_trickle.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_txn.c -# End Source File -# Begin Source File - -SOURCE=..\test_perf\perf_util.c -# End Source File -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="db_perf" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=db_perf - Win32 Debug Static
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "db_perf.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "db_perf.mak" CFG="db_perf - Win32 Debug Static"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "db_perf - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "db_perf - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "db_perf - Win32 Release Static" (based on "Win32 (x86) Console Application")
+!MESSAGE "db_perf - Win32 Debug Static" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "db_perf - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I ".." /I "../dbinc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 Release/libdb41.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"libcmt"
+
+!ELSEIF "$(CFG)" == "db_perf - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "." /I ".." /I "../dbinc" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 Debug/libdb41d.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /nodefaultlib:"libcmtd" /fixed:no
+
+!ELSEIF "$(CFG)" == "db_perf - Win32 Release Static"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release_static"
+# PROP Intermediate_Dir "Release_static"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "." /I ".." /I "../dbinc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "." /I ".." /I "../dbinc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 Release_static/libdb41.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 Release_static/libdb41s.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF "$(CFG)" == "db_perf - Win32 Debug Static"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug_static"
+# PROP Intermediate_Dir "Debug_static"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /GX /Z7 /Od /I "." /I ".." /I "../dbinc" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "." /I ".." /I "../dbinc" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 Debug_static/libdb41d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /fixed:no
+# ADD LINK32 Debug_static/libdb41sd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /fixed:no
+
+!ENDIF
+
+# Begin Target
+
+# Name "db_perf - Win32 Release"
+# Name "db_perf - Win32 Debug"
+# Name "db_perf - Win32 Release Static"
+# Name "db_perf - Win32 Debug Static"
+# Begin Source File
+
+SOURCE=..\test_perf\db_perf.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_cache_check.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_checkpoint.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_config.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_dbs.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_debug.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_file.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_key.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_log.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_misc.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_op.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_parse.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_rand.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_spawn.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_thread.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_trickle.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_txn.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\test_perf\perf_util.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\clib\getopt.c
+# End Source File
+# End Target
+# End Project
diff --git a/db/cxx/cxx_db.cpp b/db/cxx/cxx_db.cpp index 66858ab16..b52f96a08 100644 --- a/db/cxx/cxx_db.cpp +++ b/db/cxx/cxx_db.cpp @@ -1,28 +1,81 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997-2001 + * Copyright (c) 1997-2002 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: cxx_db.cpp,v 11.50 2001/11/10 04:59:06 mjc Exp "; +static const char revid[] = "Id: cxx_db.cpp,v 11.69 2002/07/20 13:50:10 dda Exp "; #endif /* not lint */ #include <errno.h> #include <string.h> #include "db_cxx.h" -#include "cxx_int.h" +#include "dbinc/cxx_int.h" #include "db_int.h" -#include "db_page.h" -#include "db_auto.h" -#include "crdel_auto.h" -#include "db_ext.h" -#include "common_ext.h" +#include "dbinc/db_page.h" +#include "dbinc_auto/db_auto.h" +#include "dbinc_auto/crdel_auto.h" +#include "dbinc/db_dispatch.h" +#include "dbinc_auto/db_ext.h" +#include "dbinc_auto/common_ext.h" + +// Helper macros for simple methods that pass through to the +// underlying C method. It may return an error or raise an exception. +// Note this macro expects that input _argspec is an argument +// list element (e.g., "char *arg") and that _arglist is the arguments +// that should be passed through to the C method (e.g., "(db, arg)") +// +#define DB_METHOD(_name, _argspec, _arglist, _retok) \ +int Db::_name _argspec \ +{ \ + int ret; \ + DB *db = unwrap(this); \ + \ + ret = db->_name _arglist; \ + if (!_retok(ret)) \ + DB_ERROR("Db::" # _name, ret, error_policy()); \ + return (ret); \ +} + +#define DB_METHOD_CHECKED(_name, _cleanup, _argspec, _arglist, _retok) \ +int Db::_name _argspec \ +{ \ + int ret; \ + DB *db = unwrap(this); \ + \ + if (!db) { \ + DB_ERROR("Db::" # _name, EINVAL, error_policy()); \ + return (EINVAL); \ + } \ + if (_cleanup) \ + cleanup(); \ + ret = db->_name _arglist; \ + if (!_retok(ret)) \ + DB_ERROR("Db::" # _name, ret, error_policy()); \ + return (ret); \ +} + +#define DB_METHOD_QUIET(_name, _argspec, _arglist) \ +int Db::_name _argspec \ +{ \ + DB *db = unwrap(this); \ + \ + return (db->_name _arglist); \ +} + +#define DB_METHOD_VOID(_name, _argspec, _arglist) \ +void Db::_name _argspec \ +{ \ + DB *db = unwrap(this); \ + \ + db->_name _arglist; \ +} // A truism for the Db object is that there is a valid // DB handle from the constructor until close(). @@ -42,6 +95,13 @@ Db::Db(DbEnv *env, u_int32_t flags) , construct_error_(0) , flags_(0) , construct_flags_(flags) +, append_recno_callback_(0) +, associate_callback_(0) +, bt_compare_callback_(0) +, bt_prefix_callback_(0) +, dup_compare_callback_(0) +, feedback_callback_(0) +, h_hash_callback_(0) { if (env_ == 0) flags_ |= DB_CXX_PRIVATE_ENV; @@ -72,10 +132,10 @@ Db::~Db() // int Db::initialize() { - u_int32_t cxx_flags; DB *db; - int err; DB_ENV *cenv = unwrap(env_); + int ret; + u_int32_t cxx_flags; cxx_flags = construct_flags_ & DB_CXX_NO_EXCEPTIONS; @@ -83,15 +143,15 @@ int Db::initialize() // We rely on the fact that if a NULL DB_ENV* is given, // one is allocated by DB. // - if ((err = db_create(&db, cenv, + if ((ret = db_create(&db, cenv, construct_flags_ & ~cxx_flags)) != 0) { - construct_error_ = err; - return (err); + construct_error_ = ret; + return (ret); } // Associate the DB with this object imp_ = wrap(db); - db->cj_internal = this; + db->api_internal = this; // Create a new DbEnv from a DB_ENV* if it was created locally. // It is deleted in Db::close(). @@ -113,7 +173,7 @@ void Db::cleanup() if (db != NULL) { // extra safety - db->cj_internal = 0; + db->api_internal = 0; imp_ = 0; // we must dispose of the DbEnv object if @@ -159,7 +219,7 @@ int Db::error_policy() int Db::close(u_int32_t flags) { DB *db = unwrap(this); - int err; + int ret; // after a DB->close (no matter if success or failure), // the underlying DB object must not be accessed, @@ -171,96 +231,54 @@ int Db::close(u_int32_t flags) // since our error mechanism does not peer into // the DB* structures. // - if ((err = db->close(db, flags)) != 0 && err != DB_INCOMPLETE) - DB_ERROR("Db::close", err, error_policy()); - - return (err); -} - -int Db::cursor(DbTxn *txnid, Dbc **cursorp, u_int32_t flags) -{ - DB *db = unwrap(this); - DBC *dbc = 0; - int err; + if ((ret = db->close(db, flags)) != 0) + DB_ERROR("Db::close", ret, error_policy()); - if ((err = db->cursor(db, unwrap(txnid), &dbc, flags)) != 0) { - DB_ERROR("Db::cursor", err, error_policy()); - return (err); - } - - // The following cast implies that Dbc can be no larger than DBC - *cursorp = (Dbc*)dbc; - return (0); + return (ret); } -int Db::del(DbTxn *txnid, Dbt *key, u_int32_t flags) -{ - DB *db = unwrap(this); - int err; +// The following cast implies that Dbc can be no larger than DBC +DB_METHOD(cursor, (DbTxn *txnid, Dbc **cursorp, u_int32_t flags), + (db, unwrap(txnid), (DBC **)cursorp, flags), + DB_RETOK_STD) - if ((err = db->del(db, unwrap(txnid), key, flags)) != 0) { - // DB_NOTFOUND is a "normal" return, so should not be - // thrown as an error - // - if (err != DB_NOTFOUND) { - DB_ERROR("Db::del", err, error_policy()); - return (err); - } - } - return (err); -} +DB_METHOD(del, (DbTxn *txnid, Dbt *key, u_int32_t flags), + (db, unwrap(txnid), key, flags), + DB_RETOK_DBDEL) void Db::err(int error, const char *format, ...) { - va_list args; DB *db = unwrap(this); - va_start(args, format); - __db_real_err(db->dbenv, error, 1, 1, format, args); - va_end(args); + DB_REAL_ERR(db->dbenv, error, 1, 1, format); } void Db::errx(const char *format, ...) { - va_list args; DB *db = unwrap(this); - va_start(args, format); - __db_real_err(db->dbenv, 0, 0, 1, format, args); - va_end(args); + DB_REAL_ERR(db->dbenv, 0, 0, 1, format); } -int Db::fd(int *fdp) -{ - DB *db = unwrap(this); - int err; - - if ((err = db->fd(db, fdp)) != 0) { - DB_ERROR("Db::fd", err, error_policy()); - return (err); - } - return (0); -} +DB_METHOD(fd, (int *fdp), + (db, fdp), + DB_RETOK_STD) int Db::get(DbTxn *txnid, Dbt *key, Dbt *value, u_int32_t flags) { DB *db = unwrap(this); - int err; + int ret; - if ((err = db->get(db, unwrap(txnid), key, value, flags)) != 0) { - // DB_NOTFOUND and DB_KEYEMPTY are "normal" returns, - // so should not be thrown as an error - // - if (err != DB_NOTFOUND && err != DB_KEYEMPTY) { - const char *name = "Db::get"; - if (err == ENOMEM && DB_OVERFLOWED_DBT(value)) - DB_ERROR_DBT(name, value, error_policy()); - else - DB_ERROR(name, err, error_policy()); - return (err); - } + ret = db->get(db, unwrap(txnid), key, value, flags); + + if (!DB_RETOK_DBGET(ret)) { + if (ret == ENOMEM && DB_OVERFLOWED_DBT(value)) + DB_ERROR_DBT("Db::get", value, error_policy()); + else + DB_ERROR("Db::get", ret, error_policy()); } - return (err); + + return (ret); } int Db::get_byteswapped(int *isswapped) @@ -275,206 +293,84 @@ int Db::get_type(DBTYPE *dbtype) return (db->get_type(db, dbtype)); } -int Db::join(Dbc **curslist, Dbc **cursorp, u_int32_t flags) -{ - // Dbc is a "compatible" subclass of DBC - - // that is, no virtual functions or even extra data members, - // so this cast, although technically non-portable, - // "should" always be okay. - // - DBC **list = (DBC **)(curslist); - DB *db = unwrap(this); - DBC *dbc = 0; - int err; +// Dbc is a "compatible" subclass of DBC - that is, no virtual functions +// or even extra data members, so these casts, although technically +// non-portable, "should" always be okay. +DB_METHOD(join, (Dbc **curslist, Dbc **cursorp, u_int32_t flags), + (db, (DBC **)curslist, (DBC **)cursorp, flags), + DB_RETOK_STD) - if ((err = db->join(db, list, &dbc, flags)) != 0) { - DB_ERROR("Db::join_cursor", err, error_policy()); - return (err); - } - *cursorp = (Dbc*)dbc; - return (0); -} - -int Db::key_range(DbTxn *txnid, Dbt *key, - DB_KEY_RANGE *results, u_int32_t flags) -{ - DB *db = unwrap(this); - int err; - - if ((err = db->key_range(db, unwrap(txnid), key, - results, flags)) != 0) { - DB_ERROR("Db::key_range", err, error_policy()); - return (err); - } - return (0); -} +DB_METHOD(key_range, + (DbTxn *txnid, Dbt *key, DB_KEY_RANGE *results, u_int32_t flags), + (db, unwrap(txnid), key, results, flags), + DB_RETOK_STD) // If an error occurred during the constructor, report it now. // Otherwise, call the underlying DB->open method. // -int Db::open(const char *file, const char *database, +int Db::open(DbTxn *txnid, const char *file, const char *database, DBTYPE type, u_int32_t flags, int mode) { - int err; + int ret; DB *db = unwrap(this); - if ((err = construct_error_) != 0) - DB_ERROR("Db::open", construct_error_, error_policy()); - else if ((err = db->open(db, file, database, type, flags, mode)) != 0) - DB_ERROR("Db::open", err, error_policy()); - - return (err); -} + if (construct_error_ != 0) + ret = construct_error_; + else + ret = db->open(db, unwrap(txnid), file, database, type, flags, + mode); -int Db::pget(DbTxn *txnid, Dbt *key, Dbt *pkey, Dbt *value, u_int32_t flags) -{ - DB *db = unwrap(this); - int err; + if (!DB_RETOK_STD(ret)) + DB_ERROR("Db::open", ret, error_policy()); - if ((err = db->pget(db, unwrap(txnid), key, pkey, - value, flags)) != 0) { - // DB_NOTFOUND and DB_KEYEMPTY are "normal" returns, - // so should not be thrown as an error - // - if (err != DB_NOTFOUND && err != DB_KEYEMPTY) { - const char *name = "Db::pget"; - if (err == ENOMEM && DB_OVERFLOWED_DBT(value)) - DB_ERROR_DBT(name, value, error_policy()); - else - DB_ERROR(name, err, error_policy()); - return (err); - } - } - return (err); + return (ret); } -int Db::put(DbTxn *txnid, Dbt *key, Dbt *value, u_int32_t flags) +int Db::pget(DbTxn *txnid, Dbt *key, Dbt *pkey, Dbt *value, u_int32_t flags) { - int err; DB *db = unwrap(this); + int ret; - if ((err = db->put(db, unwrap(txnid), key, value, flags)) != 0) { - - // DB_KEYEXIST is a "normal" return, so should not be - // thrown as an error - // - if (err != DB_KEYEXIST) { - DB_ERROR("Db::put", err, error_policy()); - return (err); - } - } - return (err); -} - -int Db::rename(const char *file, const char *database, - const char *newname, u_int32_t flags) -{ - int err = 0; - DB *db = unwrap(this); + ret = db->pget(db, unwrap(txnid), key, pkey, value, flags); - if (!db) { - DB_ERROR("Db::rename", EINVAL, error_policy()); - return (EINVAL); + /* The logic here is identical to Db::get - reuse the macro. */ + if (!DB_RETOK_DBGET(ret)) { + if (ret == ENOMEM && DB_OVERFLOWED_DBT(value)) + DB_ERROR_DBT("Db::pget", value, error_policy()); + else + DB_ERROR("Db::pget", ret, error_policy()); } - // after a DB->rename (no matter if success or failure), - // the underlying DB object must not be accessed, - // so we clean up in advance. - // - cleanup(); - - if ((err = db->rename(db, file, database, newname, flags)) != 0) { - DB_ERROR("Db::rename", err, error_policy()); - return (err); - } - return (0); + return (ret); } -int Db::remove(const char *file, const char *database, u_int32_t flags) -{ - int err = 0; - DB *db = unwrap(this); +DB_METHOD(put, + (DbTxn *txnid, Dbt *key, Dbt *value, u_int32_t flags), + (db, unwrap(txnid), key, value, flags), + DB_RETOK_DBPUT) - if (!db) { - DB_ERROR("Db::remove", EINVAL, error_policy()); - return (EINVAL); - } +DB_METHOD_CHECKED(rename, 1, + (const char *file, const char *database, const char *newname, + u_int32_t flags), + (db, file, database, newname, flags), DB_RETOK_STD) - // after a DB->remove (no matter if success or failure), - // the underlying DB object must not be accessed, - // so we clean up in advance. - // - cleanup(); +DB_METHOD_CHECKED(remove, 1, + (const char *file, const char *database, u_int32_t flags), + (db, file, database, flags), DB_RETOK_STD) - if ((err = db->remove(db, file, database, flags)) != 0) - DB_ERROR("Db::remove", err, error_policy()); +DB_METHOD_CHECKED(truncate, 0, + (DbTxn *txnid, u_int32_t *countp, u_int32_t flags), + (db, unwrap(txnid), countp, flags), DB_RETOK_STD) - return (err); -} +DB_METHOD_CHECKED(stat, 0, + (void *sp, u_int32_t flags), (db, sp, flags), DB_RETOK_STD) -int Db::truncate(DbTxn *txnid, u_int32_t *countp, u_int32_t flags) -{ - int err = 0; - DB *db = unwrap(this); +DB_METHOD_CHECKED(sync, 0, + (u_int32_t flags), (db, flags), DB_RETOK_STD) - if (!db) { - DB_ERROR("Db::truncate", EINVAL, error_policy()); - return (EINVAL); - } - if ((err = db->truncate(db, unwrap(txnid), countp, flags)) != 0) { - DB_ERROR("Db::truncate", err, error_policy()); - return (err); - } - return (0); -} +DB_METHOD_CHECKED(upgrade, 0, + (const char *name, u_int32_t flags), (db, name, flags), DB_RETOK_STD) -int Db::stat(void *sp, u_int32_t flags) -{ - int err; - DB *db = unwrap(this); - - if (!db) { - DB_ERROR("Db::stat", EINVAL, error_policy()); - return (EINVAL); - } - if ((err = db->stat(db, sp, flags)) != 0) { - DB_ERROR("Db::stat", err, error_policy()); - return (err); - } - return (0); -} - -int Db::sync(u_int32_t flags) -{ - int err; - DB *db = unwrap(this); - - if (!db) { - DB_ERROR("Db::sync", EINVAL, error_policy()); - return (EINVAL); - } - if ((err = db->sync(db, flags)) != 0 && err != DB_INCOMPLETE) { - DB_ERROR("Db::sync", err, error_policy()); - return (err); - } - return (err); -} - -int Db::upgrade(const char *name, u_int32_t flags) -{ - int err; - DB *db = unwrap(this); - - if (!db) { - DB_ERROR("Db::upgrade", EINVAL, error_policy()); - return (EINVAL); - } - if ((err = db->upgrade(db, name, flags)) != 0) { - DB_ERROR("Db::upgrade", err, error_policy()); - return (err); - } - return (0); -} //////////////////////////////////////////////////////////////////////// // // callbacks @@ -508,26 +404,39 @@ int Db::upgrade(const char *name, u_int32_t flags) // The alternative, creating a Dbt here in the callback, and populating // it from the DBT, is just too slow and cumbersome to be very useful. -/* associate callback */ -extern "C" int _db_associate_intercept_c(DB *secondary, - const DBT *key, - const DBT *data, - DBT *retval) -{ - Db *cxxthis; - - DB_ASSERT(secondary != NULL); - cxxthis = (Db *)secondary->cj_internal; - DB_ASSERT(cxxthis != NULL); - DB_ASSERT(cxxthis->associate_callback_ != 0); - - return (*cxxthis->associate_callback_)(cxxthis, - Dbt::get_const_Dbt(key), - Dbt::get_const_Dbt(data), - Dbt::get_Dbt(retval)); -} - -int Db::associate(Db *secondary, int (*callback)(Db *, const Dbt *, +// These macros avoid a lot of boilerplate code for callbacks + +#define DB_CALLBACK_C_INTERCEPT(_name, _rettype, _cargspec, \ + _return, _cxxargs) \ +extern "C" _rettype _db_##_name##_intercept_c _cargspec \ +{ \ + Db *cxxthis; \ + \ + DB_ASSERT(cthis != NULL); \ + cxxthis = (Db *)cthis->api_internal; \ + DB_ASSERT(cxxthis != NULL); \ + DB_ASSERT(cxxthis->_name##_callback_ != 0); \ + \ + _return (*cxxthis->_name##_callback_) _cxxargs; \ +} + +#define DB_SET_CALLBACK(_cxxname, _name, _cxxargspec, _cb) \ +int Db::_cxxname _cxxargspec \ +{ \ + DB *cthis = unwrap(this); \ + \ + _name##_callback_ = _cb; \ + return ((*(cthis->_cxxname))(cthis, \ + (_cb) ? _db_##_name##_intercept_c : NULL)); \ +} + +/* associate callback - doesn't quite fit the pattern because of the flags */ +DB_CALLBACK_C_INTERCEPT(associate, + int, (DB *cthis, const DBT *key, const DBT *data, DBT *retval), + return, (cxxthis, Dbt::get_const_Dbt(key), Dbt::get_const_Dbt(data), + Dbt::get_Dbt(retval))) + +int Db::associate(DbTxn *txn, Db *secondary, int (*callback)(Db *, const Dbt *, const Dbt *, Dbt *), u_int32_t flags) { DB *cthis = unwrap(this); @@ -537,153 +446,54 @@ int Db::associate(Db *secondary, int (*callback)(Db *, const Dbt *, * rather than on 'this'. */ secondary->associate_callback_ = callback; - return ((*(cthis->associate)) - (cthis, unwrap(secondary), _db_associate_intercept_c, flags)); -} - -/* feedback callback */ -extern "C" void _db_feedback_intercept_c(DB *cthis, int opcode, int pct) -{ - Db *cxxthis; - - DB_ASSERT(cthis != NULL); - cxxthis = (Db *)cthis->cj_internal; - DB_ASSERT(cxxthis != NULL); - DB_ASSERT(cxxthis->feedback_callback_ != 0); - - (*cxxthis->feedback_callback_)(cxxthis, opcode, pct); - return; -} - -int Db::set_feedback(void (*arg)(Db *cxxthis, int opcode, int pct)) -{ - DB *cthis = unwrap(this); - feedback_callback_ = arg; - return ((*(cthis->set_feedback)) - (cthis, _db_feedback_intercept_c)); -} - -/* append_recno callback */ -extern "C" int _db_append_recno_intercept_c(DB *cthis, DBT *data, - db_recno_t recno) -{ - Db *cxxthis; - - DB_ASSERT(cthis != NULL); - cxxthis = (Db *)cthis->cj_internal; - DB_ASSERT(cxxthis != NULL); - DB_ASSERT(cxxthis->append_recno_callback_ != 0); - - return (*cxxthis->append_recno_callback_)(cxxthis, - Dbt::get_Dbt(data), - recno); -} - -int Db::set_append_recno(int (*arg)(Db *cxxthis, Dbt *data, db_recno_t recno)) -{ - DB *cthis = unwrap(this); - append_recno_callback_ = arg; - return ((*(cthis->set_append_recno)) - (cthis, _db_append_recno_intercept_c)); -} - -/* bt_compare callback */ -extern "C" int _db_bt_compare_intercept_c(DB *cthis, const DBT *data1, - const DBT *data2) -{ - Db *cxxthis; - - DB_ASSERT(cthis != NULL); - cxxthis = (Db *)cthis->cj_internal; - DB_ASSERT(cxxthis != NULL); - DB_ASSERT(cxxthis->bt_compare_callback_ != 0); - - return (*cxxthis->bt_compare_callback_)(cxxthis, - Dbt::get_const_Dbt(data1), - Dbt::get_const_Dbt(data2)); + return ((*(cthis->associate))(cthis, unwrap(txn), unwrap(secondary), + (callback) ? _db_associate_intercept_c : NULL, flags)); } -int Db::set_bt_compare(int (*arg)(Db *cxxthis, const Dbt *data1, - const Dbt *data2)) -{ - DB *cthis = unwrap(this); - bt_compare_callback_ = arg; - return ((*(cthis->set_bt_compare)) - (cthis, _db_bt_compare_intercept_c)); -} +DB_CALLBACK_C_INTERCEPT(feedback, + void, (DB *cthis, int opcode, int pct), + /* no return */ (void), (cxxthis, opcode, pct)) -/* bt_prefix callback */ -extern "C" size_t _db_bt_prefix_intercept_c(DB *cthis, const DBT *data1, - const DBT *data2) -{ - Db *cxxthis; +DB_SET_CALLBACK(set_feedback, feedback, + (void (*arg)(Db *cxxthis, int opcode, int pct)), arg) - DB_ASSERT(cthis != NULL); - cxxthis = (Db *)cthis->cj_internal; - DB_ASSERT(cxxthis != NULL); - DB_ASSERT(cxxthis->bt_prefix_callback_ != 0); +DB_CALLBACK_C_INTERCEPT(append_recno, + int, (DB *cthis, DBT *data, db_recno_t recno), + return, (cxxthis, Dbt::get_Dbt(data), recno)) - return (*cxxthis->bt_prefix_callback_)(cxxthis, - Dbt::get_const_Dbt(data1), - Dbt::get_const_Dbt(data2)); -} +DB_SET_CALLBACK(set_append_recno, append_recno, + (int (*arg)(Db *cxxthis, Dbt *data, db_recno_t recno)), arg) -int Db::set_bt_prefix(size_t (*arg)(Db *cxxthis, const Dbt *data1, - const Dbt *data2)) -{ - DB *cthis = unwrap(this); - bt_prefix_callback_ = arg; - return ((*(cthis->set_bt_prefix)) - (cthis, _db_bt_prefix_intercept_c)); -} +DB_CALLBACK_C_INTERCEPT(bt_compare, + int, (DB *cthis, const DBT *data1, const DBT *data2), + return, + (cxxthis, Dbt::get_const_Dbt(data1), Dbt::get_const_Dbt(data2))) -/* dup_compare callback */ -extern "C" int _db_dup_compare_intercept_c(DB *cthis, const DBT *data1, - const DBT *data2) -{ - Db *cxxthis; +DB_SET_CALLBACK(set_bt_compare, bt_compare, + (int (*arg)(Db *cxxthis, const Dbt *data1, const Dbt *data2)), arg) - DB_ASSERT(cthis != NULL); - cxxthis = (Db *)cthis->cj_internal; - DB_ASSERT(cxxthis != NULL); - DB_ASSERT(cxxthis->dup_compare_callback_ != 0); +DB_CALLBACK_C_INTERCEPT(bt_prefix, + size_t, (DB *cthis, const DBT *data1, const DBT *data2), + return, + (cxxthis, Dbt::get_const_Dbt(data1), Dbt::get_const_Dbt(data2))) - return (*cxxthis->dup_compare_callback_)(cxxthis, - Dbt::get_const_Dbt(data1), - Dbt::get_const_Dbt(data2)); -} +DB_SET_CALLBACK(set_bt_prefix, bt_prefix, + (size_t (*arg)(Db *cxxthis, const Dbt *data1, const Dbt *data2)), arg) -int Db::set_dup_compare(int (*arg)(Db *cxxthis, const Dbt *data1, - const Dbt *data2)) -{ - DB *cthis = unwrap(this); - dup_compare_callback_ = arg; - return ((*(cthis->set_dup_compare)) - (cthis, _db_dup_compare_intercept_c)); -} +DB_CALLBACK_C_INTERCEPT(dup_compare, + int, (DB *cthis, const DBT *data1, const DBT *data2), + return, + (cxxthis, Dbt::get_const_Dbt(data1), Dbt::get_const_Dbt(data2))) -/* h_hash callback */ -extern "C" u_int32_t _db_h_hash_intercept_c(DB *cthis, const void *data, - u_int32_t len) -{ - Db *cxxthis; +DB_SET_CALLBACK(set_dup_compare, dup_compare, + (int (*arg)(Db *cxxthis, const Dbt *data1, const Dbt *data2)), arg) - DB_ASSERT(cthis != NULL); - cxxthis = (Db *)cthis->cj_internal; - DB_ASSERT(cxxthis != NULL); - DB_ASSERT(cxxthis->h_hash_callback_ != 0); +DB_CALLBACK_C_INTERCEPT(h_hash, + u_int32_t, (DB *cthis, const void *data, u_int32_t len), + return, (cxxthis, data, len)) - return (*cxxthis->h_hash_callback_)(cxxthis, data, len); -} - -int Db::set_h_hash(u_int32_t (*arg)(Db *cxxthis, const void *data, - u_int32_t len)) -{ - DB *cthis = unwrap(this); - h_hash_callback_ = arg; - return ((*(cthis->set_h_hash)) - (cthis, _db_h_hash_intercept_c)); -} +DB_SET_CALLBACK(set_h_hash, h_hash, + (u_int32_t (*arg)(Db *cxxthis, const void *data, u_int32_t len)), arg) // This is a 'glue' function declared as extern "C" so it will // be compatible with picky compilers that do not allow mixing @@ -694,10 +504,10 @@ extern "C" int _verify_callback_c(void *handle, const void *str_arg) { char *str; - OSTREAMCLASS *out; + __DB_OSTREAMCLASS *out; str = (char *)str_arg; - out = (OSTREAMCLASS *)handle; + out = (__DB_OSTREAMCLASS *)handle; (*out) << str; if (out->fail()) @@ -707,83 +517,63 @@ int _verify_callback_c(void *handle, const void *str_arg) } int Db::verify(const char *name, const char *subdb, - OSTREAMCLASS *ostr, u_int32_t flags) + __DB_OSTREAMCLASS *ostr, u_int32_t flags) { - int err; DB *db = unwrap(this); + int ret; - if (!db) { - DB_ERROR("Db::verify", EINVAL, error_policy()); - return (EINVAL); - } - if ((err = __db_verify_internal(db, name, subdb, ostr, - _verify_callback_c, flags)) != 0) { - DB_ERROR("Db::verify", err, error_policy()); - return (err); - } - return (0); -} + if (!db) + ret = EINVAL; + else + ret = __db_verify_internal(db, name, subdb, ostr, + _verify_callback_c, flags); -// This is a variant of the DB_WO_ACCESS macro to define a simple set_ -// method calling the underlying C method, but unlike a simple -// set method, it may return an error or raise an exception. -// Note this macro expects that input _argspec is an argument -// list element (e.g. "char *arg") defined in terms of "arg". -// -#define DB_DB_ACCESS(_name, _argspec) \ -\ -int Db::set_##_name(_argspec) \ -{ \ - int ret; \ - DB *db = unwrap(this); \ - \ - if ((ret = (*(db->set_##_name))(db, arg)) != 0) { \ - DB_ERROR("Db::set_" # _name, ret, error_policy()); \ - } \ - return (ret); \ -} + if (!DB_RETOK_STD(ret)) + DB_ERROR("Db::verify", ret, error_policy()); -#define DB_DB_ACCESS_NORET(_name, _argspec) \ - \ -void Db::set_##_name(_argspec) \ -{ \ - DB *db = unwrap(this); \ - \ - (*(db->set_##_name))(db, arg); \ - return; \ + return (ret); } -DB_DB_ACCESS(bt_compare, bt_compare_fcn_type arg) -DB_DB_ACCESS(bt_maxkey, u_int32_t arg) -DB_DB_ACCESS(bt_minkey, u_int32_t arg) -DB_DB_ACCESS(bt_prefix, bt_prefix_fcn_type arg) -DB_DB_ACCESS(dup_compare, dup_compare_fcn_type arg) -DB_DB_ACCESS_NORET(errfile, FILE *arg) -DB_DB_ACCESS_NORET(errpfx, const char *arg) -DB_DB_ACCESS(flags, u_int32_t arg) -DB_DB_ACCESS(h_ffactor, u_int32_t arg) -DB_DB_ACCESS(h_hash, h_hash_fcn_type arg) -DB_DB_ACCESS(h_nelem, u_int32_t arg) -DB_DB_ACCESS(lorder, int arg) -DB_DB_ACCESS(pagesize, u_int32_t arg) -DB_DB_ACCESS(re_delim, int arg) -DB_DB_ACCESS(re_len, u_int32_t arg) -DB_DB_ACCESS(re_pad, int arg) -DB_DB_ACCESS(re_source, char *arg) -DB_DB_ACCESS(q_extentsize, u_int32_t arg) - -// Here are the get/set methods that don't fit the above mold. -// - -int Db::set_alloc(db_malloc_fcn_type malloc_fcn, - db_realloc_fcn_type realloc_fcn, - db_free_fcn_type free_fcn) -{ - DB *db; - - db = unwrap(this); - return db->set_alloc(db, malloc_fcn, realloc_fcn, free_fcn); -} +DB_METHOD(set_bt_compare, (bt_compare_fcn_type func), + (db, func), DB_RETOK_STD) +DB_METHOD(set_bt_maxkey, (u_int32_t bt_maxkey), + (db, bt_maxkey), DB_RETOK_STD) +DB_METHOD(set_bt_minkey, (u_int32_t bt_minkey), + (db, bt_minkey), DB_RETOK_STD) +DB_METHOD(set_bt_prefix, (bt_prefix_fcn_type func), + (db, func), DB_RETOK_STD) +DB_METHOD(set_dup_compare, (dup_compare_fcn_type func), + (db, func), DB_RETOK_STD) +DB_METHOD(set_encrypt, (const char *passwd, int flags), + (db, passwd, flags), DB_RETOK_STD) +DB_METHOD_VOID(set_errfile, (FILE *errfile), (db, errfile)) +DB_METHOD_VOID(set_errpfx, (const char *errpfx), (db, errpfx)) +DB_METHOD(set_flags, (u_int32_t flags), (db, flags), + DB_RETOK_STD) +DB_METHOD(set_h_ffactor, (u_int32_t h_ffactor), + (db, h_ffactor), DB_RETOK_STD) +DB_METHOD(set_h_hash, (h_hash_fcn_type func), + (db, func), DB_RETOK_STD) +DB_METHOD(set_h_nelem, (u_int32_t h_nelem), + (db, h_nelem), DB_RETOK_STD) +DB_METHOD(set_lorder, (int db_lorder), (db, db_lorder), + DB_RETOK_STD) +DB_METHOD(set_pagesize, (u_int32_t db_pagesize), + (db, db_pagesize), DB_RETOK_STD) +DB_METHOD(set_re_delim, (int re_delim), + (db, re_delim), DB_RETOK_STD) +DB_METHOD(set_re_len, (u_int32_t re_len), + (db, re_len), DB_RETOK_STD) +DB_METHOD(set_re_pad, (int re_pad), + (db, re_pad), DB_RETOK_STD) +DB_METHOD(set_re_source, (char *re_source), + (db, re_source), DB_RETOK_STD) +DB_METHOD(set_q_extentsize, (u_int32_t extentsize), + (db, extentsize), DB_RETOK_STD) + +DB_METHOD_QUIET(set_alloc, (db_malloc_fcn_type malloc_fcn, + db_realloc_fcn_type realloc_fcn, db_free_fcn_type free_fcn), + (db, malloc_fcn, realloc_fcn, free_fcn)) void Db::set_errcall(void (*arg)(const char *, char *)) { @@ -800,23 +590,17 @@ void Db::set_app_private(void *value) unwrap(this)->app_private = value; } -int Db::set_cachesize(u_int32_t gbytes, u_int32_t bytes, int ncache) -{ - int ret; - DB *db = unwrap(this); - - if ((ret = (*(db->set_cachesize))(db, gbytes, bytes, ncache)) != 0) { - DB_ERROR("Db::set_cachesize", ret, error_policy()); - } - return (ret); -} +DB_METHOD(set_cachesize, (u_int32_t gbytes, u_int32_t bytes, int ncache), + (db, gbytes, bytes, ncache), DB_RETOK_STD) +DB_METHOD(set_cache_priority, (DB_CACHE_PRIORITY priority), + (db, priority), DB_RETOK_STD) int Db::set_paniccall(void (*callback)(DbEnv *, int)) { return (env_->set_paniccall(callback)); } -void Db::set_error_stream(OSTREAMCLASS *error_stream) +void Db::set_error_stream(__DB_OSTREAMCLASS *error_stream) { env_->set_error_stream(error_stream); } diff --git a/db/cxx/cxx_dbc.cpp b/db/cxx/cxx_dbc.cpp index 721bfa2fc..67ba544b3 100644 --- a/db/cxx/cxx_dbc.cpp +++ b/db/cxx/cxx_dbc.cpp @@ -1,28 +1,47 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997-2001 + * Copyright (c) 1997-2002 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: cxx_dbc.cpp,v 11.50 2001/09/29 15:48:05 dda Exp "; +static const char revid[] = "Id: cxx_dbc.cpp,v 11.55 2002/07/03 21:03:52 bostic Exp "; #endif /* not lint */ #include <errno.h> #include <string.h> #include "db_cxx.h" -#include "cxx_int.h" +#include "dbinc/cxx_int.h" #include "db_int.h" -#include "db_page.h" -#include "db_auto.h" -#include "crdel_auto.h" -#include "db_ext.h" -#include "common_ext.h" +#include "dbinc/db_page.h" +#include "dbinc_auto/db_auto.h" +#include "dbinc_auto/crdel_auto.h" +#include "dbinc/db_dispatch.h" +#include "dbinc_auto/db_ext.h" +#include "dbinc_auto/common_ext.h" + +// Helper macro for simple methods that pass through to the +// underlying C method. It may return an error or raise an exception. +// Note this macro expects that input _argspec is an argument +// list element (e.g., "char *arg") and that _arglist is the arguments +// that should be passed through to the C method (e.g., "(db, arg)") +// +#define DBC_METHOD(_name, _argspec, _arglist, _retok) \ +int Dbc::_name _argspec \ +{ \ + int ret; \ + DBC *dbc = this; \ + \ + ret = dbc->c_##_name _arglist; \ + if (!_retok(ret)) \ + DB_ERROR("Dbc::" # _name, ret, ON_ERROR_UNKNOWN); \ + return (ret); \ +} // It's private, and should never be called, but VC4.0 needs it resolved // @@ -30,128 +49,67 @@ Dbc::~Dbc() { } -int Dbc::close() -{ - DBC *cursor = this; - int err; - - if ((err = cursor->c_close(cursor)) != 0) { - DB_ERROR("Dbc::close", err, ON_ERROR_UNKNOWN); - return (err); - } - return (0); -} +DBC_METHOD(close, (void), (dbc), DB_RETOK_STD) +DBC_METHOD(count, (db_recno_t *countp, u_int32_t _flags), + (dbc, countp, _flags), DB_RETOK_STD) +DBC_METHOD(del, (u_int32_t _flags), + (dbc, _flags), DB_RETOK_DBCDEL) -int Dbc::count(db_recno_t *countp, u_int32_t flags_arg) +int Dbc::dup(Dbc** cursorp, u_int32_t _flags) { - DBC *cursor = this; - int err; + int ret; + DBC *dbc = this; + DBC *new_cursor = 0; - if ((err = cursor->c_count(cursor, countp, flags_arg)) != 0) { - DB_ERROR("Db::count", err, ON_ERROR_UNKNOWN); - return (err); - } - return (0); -} + ret = dbc->c_dup(dbc, &new_cursor, _flags); -int Dbc::del(u_int32_t flags_arg) -{ - DBC *cursor = this; - int err; - - if ((err = cursor->c_del(cursor, flags_arg)) != 0) { - - // DB_KEYEMPTY is a "normal" return, so should not be - // thrown as an error - // - if (err != DB_KEYEMPTY) { - DB_ERROR("Dbc::del", err, ON_ERROR_UNKNOWN); - return (err); - } - } - return (err); + if (DB_RETOK_STD(ret)) + // The following cast implies that Dbc can be no larger than DBC + *cursorp = (Dbc*)new_cursor; + else + DB_ERROR("Dbc::dup", ret, ON_ERROR_UNKNOWN); + + return (ret); } -int Dbc::dup(Dbc** cursorp, u_int32_t flags_arg) +int Dbc::get(Dbt* key, Dbt *data, u_int32_t _flags) { - DBC *cursor = this; - DBC *new_cursor = 0; - int err; - - if ((err = cursor->c_dup(cursor, &new_cursor, flags_arg)) != 0) { - DB_ERROR("Dbc::dup", err, ON_ERROR_UNKNOWN); - return (err); + int ret; + DBC *dbc = this; + + ret = dbc->c_get(dbc, key, data, _flags); + + if (!DB_RETOK_DBCGET(ret)) { + if (ret == ENOMEM && DB_OVERFLOWED_DBT(key)) + DB_ERROR_DBT("Dbc::get", key, ON_ERROR_UNKNOWN); + else if (ret == ENOMEM && DB_OVERFLOWED_DBT(data)) + DB_ERROR_DBT("Dbc::get", data, ON_ERROR_UNKNOWN); + else + DB_ERROR("Dbc::get", ret, ON_ERROR_UNKNOWN); } - // The following cast implies that Dbc can be no larger than DBC - *cursorp = (Dbc*)new_cursor; - return (0); + return (ret); } -int Dbc::get(Dbt* key, Dbt *data, u_int32_t flags_arg) +int Dbc::pget(Dbt* key, Dbt *pkey, Dbt *data, u_int32_t _flags) { - DBC *cursor = this; - int err; - - if ((err = cursor->c_get(cursor, key, data, flags_arg)) != 0) { - - // DB_NOTFOUND and DB_KEYEMPTY are "normal" returns, - // so should not be thrown as an error - // - if (err != DB_NOTFOUND && err != DB_KEYEMPTY) { - const char *name = "Dbc::get"; - if (err == ENOMEM && DB_OVERFLOWED_DBT(key)) - DB_ERROR_DBT(name, key, ON_ERROR_UNKNOWN); - else if (err == ENOMEM && DB_OVERFLOWED_DBT(data)) - DB_ERROR_DBT(name, data, ON_ERROR_UNKNOWN); - else - DB_ERROR(name, err, ON_ERROR_UNKNOWN); - - return (err); - } + int ret; + DBC *dbc = this; + + ret = dbc->c_pget(dbc, key, pkey, data, _flags); + + /* Logic is the same as for Dbc::get - reusing macro. */ + if (!DB_RETOK_DBCGET(ret)) { + if (ret == ENOMEM && DB_OVERFLOWED_DBT(key)) + DB_ERROR_DBT("Dbc::pget", key, ON_ERROR_UNKNOWN); + else if (ret == ENOMEM && DB_OVERFLOWED_DBT(data)) + DB_ERROR_DBT("Dbc::pget", data, ON_ERROR_UNKNOWN); + else + DB_ERROR("Dbc::pget", ret, ON_ERROR_UNKNOWN); } - return (err); -} -int Dbc::pget(Dbt* key, Dbt *pkey, Dbt *data, u_int32_t flags_arg) -{ - DBC *cursor = this; - int err; - - if ((err = cursor->c_pget(cursor, key, pkey, data, flags_arg)) != 0) { - - // DB_NOTFOUND and DB_KEYEMPTY are "normal" returns, - // so should not be thrown as an error - // - if (err != DB_NOTFOUND && err != DB_KEYEMPTY) { - const char *name = "Dbc::pget"; - if (err == ENOMEM && DB_OVERFLOWED_DBT(key)) - DB_ERROR_DBT(name, key, ON_ERROR_UNKNOWN); - else if (err == ENOMEM && DB_OVERFLOWED_DBT(data)) - DB_ERROR_DBT(name, data, ON_ERROR_UNKNOWN); - else - DB_ERROR(name, err, ON_ERROR_UNKNOWN); - - return (err); - } - } - return (err); + return (ret); } -int Dbc::put(Dbt* key, Dbt *data, u_int32_t flags_arg) -{ - DBC *cursor = this; - int err; - - if ((err = cursor->c_put(cursor, key, data, flags_arg)) != 0) { - - // DB_KEYEXIST is a "normal" return, so should not be - // thrown as an error - // - if (err != DB_KEYEXIST) { - DB_ERROR("Dbc::put", err, ON_ERROR_UNKNOWN); - return (err); - } - } - return (err); -} +DBC_METHOD(put, (Dbt* key, Dbt *data, u_int32_t _flags), + (dbc, key, data, _flags), DB_RETOK_DBCPUT) diff --git a/db/cxx/cxx_dbt.cpp b/db/cxx/cxx_dbt.cpp index 1c06f6f38..e50e7e572 100644 --- a/db/cxx/cxx_dbt.cpp +++ b/db/cxx/cxx_dbt.cpp @@ -1,28 +1,29 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997-2001 + * Copyright (c) 1997-2002 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: cxx_dbt.cpp,v 11.49 2001/07/28 20:01:18 dda Exp "; +static const char revid[] = "Id: cxx_dbt.cpp,v 11.53 2002/03/27 04:31:14 bostic Exp "; #endif /* not lint */ #include <errno.h> #include <string.h> #include "db_cxx.h" -#include "cxx_int.h" +#include "dbinc/cxx_int.h" #include "db_int.h" -#include "db_page.h" -#include "db_auto.h" -#include "crdel_auto.h" -#include "db_ext.h" -#include "common_ext.h" +#include "dbinc/db_page.h" +#include "dbinc_auto/db_auto.h" +#include "dbinc_auto/crdel_auto.h" +#include "dbinc/db_dispatch.h" +#include "dbinc_auto/db_ext.h" +#include "dbinc_auto/common_ext.h" Dbt::Dbt() { @@ -30,7 +31,7 @@ Dbt::Dbt() memset(dbt, 0, sizeof(DBT)); } -Dbt::Dbt(void *data_arg, size_t size_arg) +Dbt::Dbt(void *data_arg, u_int32_t size_arg) { DBT *dbt = this; memset(dbt, 0, sizeof(DBT)); diff --git a/db/cxx/cxx_env.cpp b/db/cxx/cxx_env.cpp index d332f533d..377b97361 100644 --- a/db/cxx/cxx_env.cpp +++ b/db/cxx/cxx_env.cpp @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997-2001 + * Copyright (c) 1997-2002 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: cxx_env.cpp,v 11.62 2001/11/10 04:59:06 mjc Exp "; +static const char revid[] = "Id: cxx_env.cpp,v 11.86 2002/08/08 15:43:25 bostic Exp "; #endif /* not lint */ #include <errno.h> @@ -16,15 +16,53 @@ static const char revid[] = "Id: cxx_env.cpp,v 11.62 2001/11/10 04:59:06 mjc Exp #include <string.h> #include "db_cxx.h" -#include "cxx_int.h" +#include "dbinc/cxx_int.h" #include "db_int.h" -#include "common_ext.h" +#include "dbinc_auto/common_ext.h" #ifdef HAVE_CXX_STDHEADERS using std::cerr; #endif +// Helper macros for simple methods that pass through to the +// underlying C method. They may return an error or raise an exception. +// These macros expect that input _argspec is an argument +// list element (e.g., "char *arg") and that _arglist is the arguments +// that should be passed through to the C method (e.g., "(dbenv, arg)") +// +#define DBENV_METHOD_ERR(_name, _argspec, _arglist, _on_err) \ +int DbEnv::_name _argspec \ +{ \ + DB_ENV *dbenv = unwrap(this); \ + int ret; \ + \ + if ((ret = dbenv->_name _arglist) != 0) { \ + _on_err; \ + } \ + return (ret); \ +} + +#define DBENV_METHOD(_name, _argspec, _arglist) \ + DBENV_METHOD_ERR(_name, _argspec, _arglist, \ + DB_ERROR("DbEnv::" # _name, ret, error_policy())) + +#define DBENV_METHOD_QUIET(_name, _argspec, _arglist) \ +int DbEnv::_name _argspec \ +{ \ + DB_ENV *dbenv = unwrap(this); \ + \ + return (dbenv->_name _arglist); \ +} + +#define DBENV_METHOD_VOID(_name, _argspec, _arglist) \ +void DbEnv::_name _argspec \ +{ \ + DB_ENV *dbenv = unwrap(this); \ + \ + dbenv->_name _arglist; \ +} + // This datatype is needed for picky compilers. // extern "C" { @@ -43,7 +81,7 @@ extern "C" { // static int last_known_error_policy = ON_ERROR_UNKNOWN; -OSTREAMCLASS *DbEnv::error_stream_ = 0; +__DB_OSTREAMCLASS *DbEnv::error_stream_ = 0; // These 'glue' function are declared as extern "C" so they will // be compatible with picky compilers that do not allow mixing @@ -63,22 +101,16 @@ void _paniccall_intercept_c(DB_ENV *env, int errval) } extern "C" -int _recovery_init_intercept_c(DB_ENV *env) -{ - return (DbEnv::_recovery_init_intercept(env)); -} - -extern "C" void _stream_error_function_c(const char *prefix, char *message) { DbEnv::_stream_error_function(prefix, message); } extern "C" -int _tx_recover_intercept_c(DB_ENV *env, DBT *dbt, +int _app_dispatch_intercept_c(DB_ENV *env, DBT *dbt, DB_LSN *lsn, db_recops op) { - return (DbEnv::_tx_recover_intercept(env, dbt, lsn, op)); + return (DbEnv::_app_dispatch_intercept(env, dbt, lsn, op)); } extern "C" @@ -97,13 +129,14 @@ int _rep_send_intercept_c(DB_ENV *env, const DBT *cntrl, // void DbEnv::_destroy_check(const char *str, int isDbEnv) { - OSTREAMCLASS *out; + __DB_OSTREAMCLASS *out; out = error_stream_; if (out == NULL || isDbEnv == 1) out = &cerr; - (*out) << "DbEnv::_destroy_check: open " << str << " object destroyed\n"; + (*out) << "DbEnv::_destroy_check: open " << str << + " object destroyed\n"; } void DbEnv::_feedback_intercept(DB_ENV *env, int opcode, int pct) @@ -112,7 +145,7 @@ void DbEnv::_feedback_intercept(DB_ENV *env, int opcode, int pct) DB_ERROR("DbEnv::feedback_callback", EINVAL, ON_ERROR_UNKNOWN); return; } - DbEnv *cxxenv = (DbEnv *)env->cj_internal; + DbEnv *cxxenv = (DbEnv *)env->api1_internal; if (cxxenv == 0) { DB_ERROR("DbEnv::feedback_callback", EINVAL, ON_ERROR_UNKNOWN); return; @@ -128,55 +161,43 @@ void DbEnv::_feedback_intercept(DB_ENV *env, int opcode, int pct) void DbEnv::_paniccall_intercept(DB_ENV *env, int errval) { if (env == 0) { - DB_ERROR("DbEnv::paniccall_callback", EINVAL, ON_ERROR_UNKNOWN); + DB_ERROR("DbEnv::paniccall_callback", EINVAL, + ON_ERROR_UNKNOWN); } - DbEnv *cxxenv = (DbEnv *)env->cj_internal; + DbEnv *cxxenv = (DbEnv *)env->api1_internal; if (cxxenv == 0) { - DB_ERROR("DbEnv::paniccall_callback", EINVAL, ON_ERROR_UNKNOWN); + DB_ERROR("DbEnv::paniccall_callback", EINVAL, + ON_ERROR_UNKNOWN); } if (cxxenv->paniccall_callback_ == 0) { - DB_ERROR("DbEnv::paniccall_callback", EINVAL, cxxenv->error_policy()); + DB_ERROR("DbEnv::paniccall_callback", EINVAL, + cxxenv->error_policy()); } (*cxxenv->paniccall_callback_)(cxxenv, errval); } -int DbEnv::_recovery_init_intercept(DB_ENV *env) -{ - if (env == 0) { - DB_ERROR("DbEnv::recovery_init_callback", EINVAL, - ON_ERROR_UNKNOWN); - } - DbEnv *cxxenv = (DbEnv *)env->cj_internal; - if (cxxenv == 0) { - DB_ERROR("DbEnv::recovery_init_callback", EINVAL, - ON_ERROR_UNKNOWN); - } - if (cxxenv->recovery_init_callback_ == 0) { - DB_ERROR("DbEnv::recovery_init_callback", EINVAL, - cxxenv->error_policy()); - } - return ((*cxxenv->recovery_init_callback_)(cxxenv)); -} - -int DbEnv::_tx_recover_intercept(DB_ENV *env, DBT *dbt, +int DbEnv::_app_dispatch_intercept(DB_ENV *env, DBT *dbt, DB_LSN *lsn, db_recops op) { if (env == 0) { - DB_ERROR("DbEnv::tx_recover_callback", EINVAL, ON_ERROR_UNKNOWN); + DB_ERROR("DbEnv::app_dispatch_callback", + EINVAL, ON_ERROR_UNKNOWN); return (EINVAL); } - DbEnv *cxxenv = (DbEnv *)env->cj_internal; + DbEnv *cxxenv = (DbEnv *)env->api1_internal; if (cxxenv == 0) { - DB_ERROR("DbEnv::tx_recover_callback", EINVAL, ON_ERROR_UNKNOWN); + DB_ERROR("DbEnv::app_dispatch_callback", + EINVAL, ON_ERROR_UNKNOWN); return (EINVAL); } - if (cxxenv->tx_recover_callback_ == 0) { - DB_ERROR("DbEnv::tx_recover_callback", EINVAL, cxxenv->error_policy()); + if (cxxenv->app_dispatch_callback_ == 0) { + DB_ERROR("DbEnv::app_dispatch_callback", + EINVAL, cxxenv->error_policy()); return (EINVAL); } Dbt *cxxdbt = (Dbt *)dbt; DbLsn *cxxlsn = (DbLsn *)lsn; - return ((*cxxenv->tx_recover_callback_)(cxxenv, cxxdbt, cxxlsn, op)); + return ((*cxxenv->app_dispatch_callback_)(cxxenv, cxxdbt, cxxlsn, op)); } int DbEnv::_rep_send_intercept(DB_ENV *env, const DBT *cntrl, @@ -187,7 +208,7 @@ int DbEnv::_rep_send_intercept(DB_ENV *env, const DBT *cntrl, DB_ERROR("DbEnv::rep_send_callback", EINVAL, ON_ERROR_UNKNOWN); return (EINVAL); } - DbEnv *cxxenv = (DbEnv *)env->cj_internal; + DbEnv *cxxenv = (DbEnv *)env->api1_internal; if (cxxenv == 0) { DB_ERROR("DbEnv::rep_send_callback", EINVAL, ON_ERROR_UNKNOWN); return (EINVAL); @@ -195,7 +216,7 @@ int DbEnv::_rep_send_intercept(DB_ENV *env, const DBT *cntrl, const Dbt *cxxcntrl = (const Dbt *)cntrl; Dbt *cxxdata = (Dbt *)data; return ((*cxxenv->rep_send_callback_)(cxxenv, - cxxcntrl, cxxdata, flags, id)); + cxxcntrl, cxxdata, id, flags)); } // A truism for the DbEnv object is that there is a valid @@ -214,30 +235,34 @@ DbEnv::DbEnv(u_int32_t flags) : imp_(0) , construct_error_(0) , construct_flags_(flags) -, tx_recover_callback_(0) +, app_dispatch_callback_(0) +, feedback_callback_(0) , paniccall_callback_(0) +, pgin_callback_(0) +, pgout_callback_(0) , rep_send_callback_(0) { - int err; + int ret; - COMPQUIET(err, 0); - if ((err = initialize(0)) != 0) - DB_ERROR("DbEnv::DbEnv", err, error_policy()); + if ((ret = initialize(0)) != 0) + DB_ERROR("DbEnv::DbEnv", ret, error_policy()); } DbEnv::DbEnv(DB_ENV *env, u_int32_t flags) : imp_(0) , construct_error_(0) , construct_flags_(flags) -, tx_recover_callback_(0) +, app_dispatch_callback_(0) +, feedback_callback_(0) , paniccall_callback_(0) +, pgin_callback_(0) +, pgout_callback_(0) , rep_send_callback_(0) { - int err; + int ret; - COMPQUIET(err, 0); - if ((err = initialize(env)) != 0) - DB_ERROR("DbEnv::DbEnv", err, error_policy()); + if ((ret = initialize(env)) != 0) + DB_ERROR("DbEnv::DbEnv", ret, error_policy()); } // Note: if the user has not closed, we call _destroy_check @@ -250,28 +275,27 @@ DbEnv::~DbEnv() if (env != NULL) { _destroy_check("DbEnv", 1); - (void)env->close(env, 0); - // extra safety cleanup(); + (void)env->close(env, 0); } } -// called by Db destructor when the DbEnv is owned by DB. +// called by destructors before the DB_ENV is destroyed. void DbEnv::cleanup() { DB_ENV *env = unwrap(this); if (env != NULL) { - env->cj_internal = 0; + env->api1_internal = 0; imp_ = 0; } } int DbEnv::close(u_int32_t flags) { + int ret; DB_ENV *env = unwrap(this); - int err; // after a close (no matter if success or failure), // the underlying DB_ENV object must not be accessed, @@ -283,20 +307,24 @@ int DbEnv::close(u_int32_t flags) // since our error mechanism does not peer into // the DB* structures. // - if ((err = env->close(env, flags)) != 0) { - DB_ERROR("DbEnv::close", err, error_policy()); - } - return (err); + if ((ret = env->close(env, flags)) != 0) + DB_ERROR("DbEnv::close", ret, error_policy()); + + return (ret); } +DBENV_METHOD(dbremove, + (DbTxn *txn, const char *name, const char *subdb, u_int32_t flags), + (dbenv, unwrap(txn), name, subdb, flags)) +DBENV_METHOD(dbrename, (DbTxn *txn, const char *name, const char *subdb, + const char *newname, u_int32_t flags), + (dbenv, unwrap(txn), name, subdb, newname, flags)) + void DbEnv::err(int error, const char *format, ...) { - va_list args; DB_ENV *env = unwrap(this); - va_start(args, format); - __db_real_err(env, error, 1, 1, format, args); - va_end(args); + DB_REAL_ERR(env, error, 1, 1, format); } // Return a tristate value corresponding to whether we should @@ -317,12 +345,9 @@ int DbEnv::error_policy() void DbEnv::errx(const char *format, ...) { - va_list args; DB_ENV *env = unwrap(this); - va_start(args, format); - __db_real_err(env, 0, 0, 1, format, args); - va_end(args); + DB_REAL_ERR(env, 0, 0, 1, format); } void *DbEnv::get_app_private() const @@ -337,300 +362,122 @@ void *DbEnv::get_app_private() const // int DbEnv::initialize(DB_ENV *env) { - int err; + int ret; last_known_error_policy = error_policy(); if (env == 0) { // Create a new DB_ENV environment. - if ((err = ::db_env_create(&env, + if ((ret = ::db_env_create(&env, construct_flags_ & ~DB_CXX_NO_EXCEPTIONS)) != 0) { - construct_error_ = err; - return (err); + construct_error_ = ret; + return (ret); } } imp_ = wrap(env); - env->cj_internal = this; // for DB_ENV* to DbEnv* conversion - return (0); -} - -int DbEnv::lock_detect(u_int32_t flags, u_int32_t atype, int *aborted) -{ - DB_ENV *env = unwrap(this); - int err; - - if ((err = env->lock_detect(env, flags, atype, aborted)) != 0) { - DB_ERROR("DbEnv::lock_detect", err, error_policy()); - return (err); - } - return (err); -} - -int DbEnv::lock_get(u_int32_t locker, u_int32_t flags, const Dbt *obj, - db_lockmode_t lock_mode, DbLock *lock) -{ - DB_ENV *env = unwrap(this); - int err; - - if ((err = env->lock_get(env, locker, flags, obj, - lock_mode, &lock->lock_)) != 0) { - DB_ERROR("DbEnv::lock_get", err, error_policy()); - return (err); - } - return (err); -} - -int DbEnv::lock_id(u_int32_t *idp) -{ - DB_ENV *env = unwrap(this); - int err; - - if ((err = env->lock_id(env, idp)) != 0) { - DB_ERROR("DbEnv::lock_id", err, error_policy()); - } - return (err); -} - -int DbEnv::lock_id_free(u_int32_t id) -{ - DB_ENV *env = unwrap(this); - int err; - - if ((err = env->lock_id_free(env, id)) != 0) { - DB_ERROR("DbEnv::lock_id_free", err, error_policy()); - } - return (err); -} - -int DbEnv::lock_stat(DB_LOCK_STAT **statp, u_int32_t flags) -{ - DB_ENV *env = unwrap(this); - int err; - - if ((err = env->lock_stat(env, statp, flags)) != 0) { - DB_ERROR("DbEnv::lock_stat", err, error_policy()); - return (err); - } + env->api1_internal = this; // for DB_ENV* to DbEnv* conversion return (0); } -int DbEnv::lock_vec(u_int32_t locker, u_int32_t flags, - DB_LOCKREQ list[], - int nlist, DB_LOCKREQ **elist_returned) -{ - DB_ENV *env = unwrap(this); - int err; - - if ((err = env->lock_vec(env, locker, flags, list, - nlist, elist_returned)) != 0) { - DB_ERROR("DbEnv::lock_vec", err, error_policy()); - return (err); - } - return (err); -} - -int DbEnv::log_archive(char **list[], u_int32_t flags) -{ - int err; - DB_ENV *env = unwrap(this); - - if ((err = env->log_archive(env, list, flags)) != 0) { - DB_ERROR("DbEnv::log_archive", err, error_policy()); - return (err); - } - return (0); -} +// lock methods +DBENV_METHOD(lock_detect, (u_int32_t flags, u_int32_t atype, int *aborted), + (dbenv, flags, atype, aborted)) +DBENV_METHOD_ERR(lock_get, + (u_int32_t locker, u_int32_t flags, const Dbt *obj, + db_lockmode_t lock_mode, DbLock *lock), + (dbenv, locker, flags, obj, lock_mode, &lock->lock_), + DbEnv::runtime_error_lock_get("DbEnv::lock_get", ret, + DB_LOCK_GET, lock_mode, obj, *lock, + -1, error_policy())) +DBENV_METHOD(lock_id, (u_int32_t *idp), (dbenv, idp)) +DBENV_METHOD(lock_id_free, (u_int32_t id), (dbenv, id)) +DBENV_METHOD(lock_put, (DbLock *lock), (dbenv, &lock->lock_)) +DBENV_METHOD(lock_stat, (DB_LOCK_STAT **statp, u_int32_t flags), + (dbenv, statp, flags)) +DBENV_METHOD_ERR(lock_vec, + (u_int32_t locker, u_int32_t flags, DB_LOCKREQ list[], + int nlist, DB_LOCKREQ **elist_returned), + (dbenv, locker, flags, list, nlist, elist_returned), + DbEnv::runtime_error_lock_get("DbEnv::lock_vec", ret, + (*elist_returned)->op, (*elist_returned)->mode, + Dbt::get_Dbt((*elist_returned)->obj), DbLock((*elist_returned)->lock), + (*elist_returned) - list, error_policy())) +// log methods +DBENV_METHOD(log_archive, (char **list[], u_int32_t flags), + (dbenv, list, flags)) int DbEnv::log_compare(const DbLsn *lsn0, const DbLsn *lsn1) { return (::log_compare(lsn0, lsn1)); } -int DbEnv::log_cursor(DbLogc **cursorp, u_int32_t flags) -{ - int err; - DB_ENV *env = unwrap(this); - DB_LOGC *dblogc = NULL; - - if ((err = env->log_cursor(env, &dblogc, flags)) != 0) { - DB_ERROR("DbEnv::log_cursor", err, error_policy()); - return (err); - } - - // The following cast implies that DbLogc can be no larger than DB_LOGC - *cursorp = (DbLogc*)dblogc; - return (0); -} - -int DbEnv::log_file(DbLsn *lsn, char *namep, size_t len) -{ - int err; - DB_ENV *env = unwrap(this); - - if ((err = env->log_file(env, lsn, namep, len)) != 0) { - DB_ERROR("DbEnv::log_file", err, error_policy()); - return (err); - } - return (0); -} - -int DbEnv::log_flush(const DbLsn *lsn) -{ - int err; - DB_ENV *env = unwrap(this); - - if ((err = env->log_flush(env, lsn)) != 0) { - DB_ERROR("DbEnv::log_flush", err, error_policy()); - return (err); - } - return (0); -} - -int DbEnv::log_put(DbLsn *lsn, const Dbt *data, u_int32_t flags) -{ - int err = 0; - DB_ENV *env = unwrap(this); - - if ((err = env->log_put(env, lsn, data, flags)) != 0) { - DB_ERROR("DbEnv::log_put", err, error_policy()); - return (err); - } - return (0); -} - -int DbEnv::log_register(Db *dbp, const char *name) -{ - int err = 0; - DB_ENV *env = unwrap(this); - - if ((err = env->log_register(env, unwrap(dbp), name)) != 0) { - DB_ERROR("DbEnv::log_register", err, error_policy()); - return (err); - } - return (0); -} - -int DbEnv::log_stat(DB_LOG_STAT **spp, u_int32_t flags) -{ - int err = 0; - DB_ENV *env = unwrap(this); - - if ((err = env->log_stat(env, spp, flags)) != 0) { - DB_ERROR("DbEnv::log_stat", err, error_policy()); - return (err); - } - return (0); -} - -int DbEnv::log_unregister(Db *dbp) -{ - int err; - DB_ENV *env = unwrap(this); - - if ((err = env->log_unregister(env, unwrap(dbp))) != 0) { - DB_ERROR("DbEnv::log_unregister", err, error_policy()); - return (err); - } - return (0); -} +// The following cast implies that DbLogc can be no larger than DB_LOGC +DBENV_METHOD(log_cursor, (DbLogc **cursorp, u_int32_t flags), + (dbenv, (DB_LOGC **)cursorp, flags)) +DBENV_METHOD(log_file, (DbLsn *lsn, char *namep, size_t len), + (dbenv, lsn, namep, len)) +DBENV_METHOD(log_flush, (const DbLsn *lsn), (dbenv, lsn)) +DBENV_METHOD(log_put, (DbLsn *lsn, const Dbt *data, u_int32_t flags), + (dbenv, lsn, data, flags)) +DBENV_METHOD(log_stat, (DB_LOG_STAT **spp, u_int32_t flags), + (dbenv, spp, flags)) int DbEnv::memp_fcreate(DbMpoolFile **dbmfp, u_int32_t flags) { - DB_ENV *env; - int err; + DB_ENV *env = unwrap(this); + int ret; DB_MPOOLFILE *mpf; - env = unwrap(this); - if (env == NULL) { - err = EINVAL; - } - else if ((err = env->memp_fcreate(env, &mpf, flags)) != 0) { - DB_ERROR("DbMpoolFile::f_create", err, ON_ERROR_UNKNOWN); - } - else { + if (env == NULL) + ret = EINVAL; + else + ret = env->memp_fcreate(env, &mpf, flags); + + if (DB_RETOK_STD(ret)) { *dbmfp = new DbMpoolFile(); (*dbmfp)->imp_ = wrap(mpf); - } - return (err); -} + } else + DB_ERROR("DbMpoolFile::f_create", ret, ON_ERROR_UNKNOWN); -int DbEnv::memp_register(int ftype, - pgin_fcn_type pgin_fcn, - pgout_fcn_type pgout_fcn) -{ - DB_ENV *env; - int err; - - env = unwrap(this); - if ((err = env->memp_register(env, ftype, pgin_fcn, pgout_fcn)) != 0) { - DB_ERROR("DbEnv::memp_register", err, error_policy()); - return (err); - } - return (err); + return (ret); } -int DbEnv::memp_stat(DB_MPOOL_STAT **gsp, - DB_MPOOL_FSTAT ***fsp, u_int32_t flags) -{ - DB_ENV *env; - int err; +DBENV_METHOD(memp_register, + (int ftype, pgin_fcn_type pgin_fcn, pgout_fcn_type pgout_fcn), + (dbenv, ftype, pgin_fcn, pgout_fcn)) - env = unwrap(this); - if ((err = env->memp_stat(env, gsp, fsp, flags)) != 0) { - DB_ERROR("DbEnv::memp_stat", err, error_policy()); - return (err); - } - return (err); -} - -int DbEnv::memp_sync(DbLsn *sn) -{ - DB_ENV *env; - int err; +// memory pool methods +DBENV_METHOD(memp_stat, + (DB_MPOOL_STAT **gsp, DB_MPOOL_FSTAT ***fsp, u_int32_t flags), + (dbenv, gsp, fsp, flags)) - env = unwrap(this); - if ((err = env->memp_sync(env, sn)) != 0 && err != DB_INCOMPLETE) { - DB_ERROR("DbEnv::memp_sync", err, error_policy()); - return (err); - } - return (err); -} +DBENV_METHOD(memp_sync, (DbLsn *sn), (dbenv, sn)) -int DbEnv::memp_trickle(int pct, int *nwrotep) -{ - DB_ENV *env; - int err; - - env = unwrap(this); - if ((err = env->memp_trickle(env, pct, nwrotep)) != 0) { - DB_ERROR("DbEnv::memp_trickle", err, error_policy()); - return (err); - } - return (err); -} +DBENV_METHOD(memp_trickle, (int pct, int *nwrotep), (dbenv, pct, nwrotep)) // If an error occurred during the constructor, report it now. // Otherwise, call the underlying DB->open method. // int DbEnv::open(const char *db_home, u_int32_t flags, int mode) { + int ret; DB_ENV *env = unwrap(this); - int err; - if ((err = construct_error_) != 0) - DB_ERROR("Db::open", err, error_policy()); - else if ((err = env->open(env, db_home, flags, mode)) != 0) - DB_ERROR("DbEnv::open", err, error_policy()); + if (construct_error_ != 0) + ret = construct_error_; + else + ret = env->open(env, db_home, flags, mode); - return (err); + if (!DB_RETOK_STD(ret)) + DB_ERROR("DbEnv::open", ret, error_policy()); + + return (ret); } int DbEnv::remove(const char *db_home, u_int32_t flags) { - DB_ENV *env; int ret; - - env = unwrap(this); + DB_ENV *env = unwrap(this); // after a remove (no matter if success or failure), // the underlying DB_ENV object must not be accessed, @@ -657,8 +504,26 @@ void DbEnv::runtime_error(const char *caller, int error, int error_policy) if (error_policy == ON_ERROR_THROW) { // Creating and throwing the object in two separate // statements seems to be necessary for HP compilers. - DbException except(caller, error); - throw except; + switch (error) { + case DB_LOCK_DEADLOCK: + { + DbDeadlockException dl_except(caller); + throw dl_except; + } + break; + case DB_RUNRECOVERY: + { + DbRunRecoveryException rr_except(caller); + throw rr_except; + } + break; + default: + { + DbException except(caller, error); + throw except; + } + break; + } } } @@ -676,6 +541,29 @@ void DbEnv::runtime_error_dbt(const char *caller, Dbt *dbt, int error_policy) } } +// Like DbEnv::runtime_error, but issue a DbLockNotGrantedException, +// or a regular runtime error. +// call regular runtime_error if it +void DbEnv::runtime_error_lock_get(const char *caller, int error, + db_lockop_t op, db_lockmode_t mode, const Dbt *obj, + DbLock lock, int index, int error_policy) +{ + if (error != DB_LOCK_NOTGRANTED) { + runtime_error(caller, error, error_policy); + return; + } + + if (error_policy == ON_ERROR_UNKNOWN) + error_policy = last_known_error_policy; + if (error_policy == ON_ERROR_THROW) { + // Creating and throwing the object in two separate + // statements seems to be necessary for HP compilers. + DbLockNotGrantedException except(caller, op, mode, + obj, lock, index); + throw except; + } +} + // static method char *DbEnv::strerror(int error) { @@ -698,84 +586,41 @@ void DbEnv::_stream_error_function(const char *prefix, char *message) // set methods -// This is a variant of the DB_WO_ACCESS macro to define a simple set_ -// method calling the underlying C method, but unlike a simple -// set method, it may return an error or raise an exception. -// Note this macro expects that input _argspec is an argument -// list element (e.g. "char *arg") defined in terms of "arg". -// -#define DB_DBENV_ACCESS(_name, _argspec) \ - \ -int DbEnv::set_##_name(_argspec) \ -{ \ - int ret; \ - DB_ENV *dbenv = unwrap(this); \ - \ - if ((ret = (*(dbenv->set_##_name))(dbenv, arg)) != 0) {\ - DB_ERROR("DbEnv::set_" # _name, ret, error_policy()); \ - } \ - return (ret); \ -} - -#define DB_DBENV_ACCESS_NORET(_name, _argspec) \ - \ -void DbEnv::set_##_name(_argspec) \ -{ \ - DB_ENV *dbenv = unwrap(this); \ - \ - (*(dbenv->set_##_name))(dbenv, arg); \ - return; \ -} - -DB_DBENV_ACCESS_NORET(errfile, FILE *arg) -DB_DBENV_ACCESS_NORET(errpfx, const char *arg) +DBENV_METHOD_VOID(set_errfile, (FILE *errfile), (dbenv, errfile)) +DBENV_METHOD_VOID(set_errpfx, (const char *errpfx), (dbenv, errpfx)) // We keep these alphabetical by field name, // for comparison with Java's list. // -DB_DBENV_ACCESS(data_dir, const char *arg) -DB_DBENV_ACCESS(lg_bsize, u_int32_t arg) -DB_DBENV_ACCESS(lg_dir, const char *arg) -DB_DBENV_ACCESS(lg_max, u_int32_t arg) -DB_DBENV_ACCESS(lg_regionmax, u_int32_t arg) -DB_DBENV_ACCESS(lk_detect, u_int32_t arg) -DB_DBENV_ACCESS(lk_max, u_int32_t arg) -DB_DBENV_ACCESS(lk_max_lockers, u_int32_t arg) -DB_DBENV_ACCESS(lk_max_locks, u_int32_t arg) -DB_DBENV_ACCESS(lk_max_objects, u_int32_t arg) -DB_DBENV_ACCESS(mp_mmapsize, size_t arg) -DB_DBENV_ACCESS(tmp_dir, const char *arg) -DB_DBENV_ACCESS(tx_max, u_int32_t arg) - -// Here are the get/set methods that don't fit the above mold. -// - -int DbEnv::set_alloc(db_malloc_fcn_type malloc_fcn, - db_realloc_fcn_type realloc_fcn, - db_free_fcn_type free_fcn) -{ - DB_ENV *dbenv; - - dbenv = unwrap(this); - return dbenv->set_alloc(dbenv, malloc_fcn, realloc_fcn, free_fcn); -} +DBENV_METHOD(set_data_dir, (const char *dir), (dbenv, dir)) +DBENV_METHOD(set_encrypt, (const char *passwd, int flags), + (dbenv, passwd, flags)) +DBENV_METHOD(set_lg_bsize, (u_int32_t bsize), (dbenv, bsize)) +DBENV_METHOD(set_lg_dir, (const char *dir), (dbenv, dir)) +DBENV_METHOD(set_lg_max, (u_int32_t max), (dbenv, max)) +DBENV_METHOD(set_lg_regionmax, (u_int32_t regionmax), (dbenv, regionmax)) +DBENV_METHOD(set_lk_detect, (u_int32_t detect), (dbenv, detect)) +DBENV_METHOD(set_lk_max, (u_int32_t max), (dbenv, max)) +DBENV_METHOD(set_lk_max_lockers, (u_int32_t max_lockers), (dbenv, max_lockers)) +DBENV_METHOD(set_lk_max_locks, (u_int32_t max_locks), (dbenv, max_locks)) +DBENV_METHOD(set_lk_max_objects, (u_int32_t max_objects), (dbenv, max_objects)) +DBENV_METHOD(set_mp_mmapsize, (size_t mmapsize), (dbenv, mmapsize)) +DBENV_METHOD(set_tmp_dir, (const char *tmp_dir), (dbenv, tmp_dir)) +DBENV_METHOD(set_tx_max, (u_int32_t tx_max), (dbenv, tx_max)) + +DBENV_METHOD_QUIET(set_alloc, + (db_malloc_fcn_type malloc_fcn, db_realloc_fcn_type realloc_fcn, + db_free_fcn_type free_fcn), + (dbenv, malloc_fcn, realloc_fcn, free_fcn)) void DbEnv::set_app_private(void *value) { unwrap(this)->app_private = value; } -int DbEnv::set_cachesize(u_int32_t gbytes, u_int32_t bytes, int ncache) -{ - int ret; - DB_ENV *dbenv = unwrap(this); - - if ((ret = - (*(dbenv->set_cachesize))(dbenv, gbytes, bytes, ncache)) != 0) - DB_ERROR("DbEnv::set_cachesize", ret, error_policy()); - - return (ret); -} +DBENV_METHOD(set_cachesize, + (u_int32_t gbytes, u_int32_t bytes, int ncache), + (dbenv, gbytes, bytes, ncache)) void DbEnv::set_errcall(void (*arg)(const char *, char *)) { @@ -802,7 +647,7 @@ void DbEnv::set_errcall(void (*arg)(const char *, char *)) // db_env triggered the call. A user that has multiple DB_ENVs // will simply not be able to have different streams for each one. // -void DbEnv::set_error_stream(OSTREAMCLASS *stream) +void DbEnv::set_error_stream(__DB_OSTREAMCLASS *stream) { DB_ENV *dbenv = unwrap(this); @@ -820,28 +665,9 @@ int DbEnv::set_feedback(void (*arg)(DbEnv *, int, int)) return ((*(dbenv->set_feedback))(dbenv, _feedback_intercept_c)); } -int DbEnv::set_flags(u_int32_t flags, int onoff) -{ - int ret; - DB_ENV *dbenv = unwrap(this); - - if ((ret = (dbenv->set_flags)(dbenv, flags, onoff)) != 0) - DB_ERROR("DbEnv::set_flags", ret, error_policy()); - - return (ret); -} - -int DbEnv::set_lk_conflicts(u_int8_t *lk_conflicts, int lk_max) -{ - int ret; - DB_ENV *dbenv = unwrap(this); - - if ((ret = (*(dbenv->set_lk_conflicts)) - (dbenv, lk_conflicts, lk_max)) != 0) - DB_ERROR("DbEnv::set_lk_conflicts", ret, error_policy()); - - return (ret); -} +DBENV_METHOD(set_flags, (u_int32_t flags, int onoff), (dbenv, flags, onoff)) +DBENV_METHOD(set_lk_conflicts, (u_int8_t *lk_conflicts, int lk_max), + (dbenv, lk_conflicts, lk_max)) int DbEnv::set_paniccall(void (*arg)(DbEnv *, int)) { @@ -852,141 +678,99 @@ int DbEnv::set_paniccall(void (*arg)(DbEnv *, int)) return ((*(dbenv->set_paniccall))(dbenv, _paniccall_intercept_c)); } -int DbEnv::set_recovery_init(int (*arg)(DbEnv *)) -{ - DB_ENV *dbenv = unwrap(this); +DBENV_METHOD(set_rpc_server, + (void *cl, char *host, long tsec, long ssec, u_int32_t flags), + (dbenv, cl, host, tsec, ssec, flags)) +DBENV_METHOD(set_shm_key, (long shm_key), (dbenv, shm_key)) +// Note: this changes from last_known_error_policy to error_policy() +DBENV_METHOD(set_tas_spins, (u_int32_t arg), (dbenv, arg)) - recovery_init_callback_ = arg; - - return ((*(dbenv->set_recovery_init))(dbenv, _recovery_init_intercept_c)); -} - -int DbEnv::set_rpc_server(void *cl, char *host, long tsec, long ssec, u_int32_t flags) +int DbEnv::set_app_dispatch + (int (*arg)(DbEnv *, Dbt *, DbLsn *, db_recops)) { - int ret; DB_ENV *dbenv = unwrap(this); - - if ((ret = dbenv->set_rpc_server(dbenv, cl, host, tsec, ssec, flags)) - != 0) - DB_ERROR("DbEnv::set_rpc_server", ret, error_policy()); - - return (ret); -} - -int DbEnv::set_shm_key(long shm_key) -{ int ret; - DB_ENV *dbenv = unwrap(this); - if ((ret = dbenv->set_shm_key(dbenv, shm_key)) != 0) - DB_ERROR("DbEnv::set_shm_key", ret, error_policy()); + app_dispatch_callback_ = arg; + if ((ret = (*(dbenv->set_app_dispatch))(dbenv, + _app_dispatch_intercept_c)) != 0) + DB_ERROR("DbEnv::set_app_dispatch", ret, error_policy()); return (ret); } -int DbEnv::set_tas_spins(u_int32_t arg) -{ - int ret; - DB_ENV *dbenv = unwrap(this); +DBENV_METHOD(set_tx_timestamp, (time_t *timestamp), (dbenv, timestamp)) +DBENV_METHOD(set_verbose, (u_int32_t which, int onoff), (dbenv, which, onoff)) - if ((ret = dbenv->set_tas_spins(dbenv, arg)) != 0) - DB_ERROR("DbEnv::set_tas_spins", ret, last_known_error_policy); - - return (ret); -} - -int DbEnv::set_tx_recover - (int (*arg)(DbEnv *, Dbt *, DbLsn *, db_recops)) +int DbEnv::txn_begin(DbTxn *pid, DbTxn **tid, u_int32_t flags) { + DB_ENV *env = unwrap(this); + DB_TXN *txn; int ret; - DB_ENV *dbenv = unwrap(this); - tx_recover_callback_ = arg; - if ((ret = - (*(dbenv->set_tx_recover))(dbenv, _tx_recover_intercept_c)) != 0) - DB_ERROR("DbEnv::set_tx_recover", ret, error_policy()); + ret = env->txn_begin(env, unwrap(pid), &txn, flags); + if (DB_RETOK_STD(ret)) + *tid = new DbTxn(txn); + else + DB_ERROR("DbEnv::txn_begin", ret, error_policy()); return (ret); } -int DbEnv::set_tx_timestamp(time_t *timestamp) -{ - int ret; - DB_ENV *dbenv = unwrap(this); +DBENV_METHOD(txn_checkpoint, (u_int32_t kbyte, u_int32_t min, u_int32_t flags), + (dbenv, kbyte, min, flags)) - if ((ret = dbenv->set_tx_timestamp(dbenv, timestamp)) != 0) - DB_ERROR("DbEnv::set_tx_timestamp", ret, error_policy()); - - return (ret); -} - -int DbEnv::set_verbose(u_int32_t which, int onoff) +int DbEnv::txn_recover(DbPreplist *preplist, long count, + long *retp, u_int32_t flags) { - int ret; DB_ENV *dbenv = unwrap(this); + DB_PREPLIST *c_preplist; + long i; + int ret; - if ((ret = (*(dbenv->set_verbose))(dbenv, which, onoff)) != 0) - DB_ERROR("DbEnv::set_verbose", ret, error_policy()); + /* + * We need to allocate some local storage for the + * returned preplist, and that requires us to do + * our own argument validation. + */ + if (count <= 0) + ret = EINVAL; + else + ret = __os_malloc(dbenv, sizeof(DB_PREPLIST) * count, + &c_preplist); - return (ret); -} - -int DbEnv::txn_begin(DbTxn *pid, DbTxn **tid, u_int32_t flags) -{ - int err; - DB_ENV *env = unwrap(this); - DB_TXN *txn; - - if ((err = env->txn_begin(env, unwrap(pid), &txn, flags)) != 0) { - DB_ERROR("DbEnv::txn_begin", err, error_policy()); - return (err); + if (ret != 0) { + DB_ERROR("DbEnv::txn_recover", ret, error_policy()); + return (ret); } - DbTxn *result = new DbTxn(); - result->imp_ = wrap(txn); - *tid = result; - return (err); -} -int DbEnv::txn_checkpoint(u_int32_t kbyte, u_int32_t min, u_int32_t flags) -{ - int err; - DB_ENV *env = unwrap(this); - if ((err = env->txn_checkpoint(env, kbyte, min, flags)) != 0 && - err != DB_INCOMPLETE) { - DB_ERROR("DbEnv::txn_checkpoint", err, error_policy()); - return (err); + if ((ret = + dbenv->txn_recover(dbenv, c_preplist, count, retp, flags)) != 0) { + __os_free(dbenv, c_preplist); + DB_ERROR("DbEnv::txn_recover", ret, error_policy()); + return (ret); } - return (err); -} -int DbEnv::txn_recover(DB_PREPLIST *preplist, long count, - long *retp, u_int32_t flags) -{ - int err; - DB_ENV *env = unwrap(this); - if ((err = env->txn_recover(env, preplist, count, retp, flags)) != 0) { - DB_ERROR("DbEnv::txn_recover", err, error_policy()); - return (err); + for (i = 0; i < *retp; i++) { + preplist[i].txn = new DbTxn(); + preplist[i].txn->imp_ = wrap(c_preplist[i].txn); + memcpy(preplist[i].gid, c_preplist[i].gid, + sizeof(preplist[i].gid)); } - return (err); -} -int DbEnv::txn_stat(DB_TXN_STAT **statp, u_int32_t flags) -{ - int err; - DB_ENV *env = unwrap(this); - if ((err = env->txn_stat(env, statp, flags)) != 0) { - DB_ERROR("DbEnv::txn_stat", err, error_policy()); - return (err); - } - return (err); + __os_free(dbenv, c_preplist); + + return (0); } +DBENV_METHOD(txn_stat, (DB_TXN_STAT **statp, u_int32_t flags), + (dbenv, statp, flags)) + int DbEnv::set_rep_transport(u_int32_t myid, int (*f_send)(DbEnv *, const Dbt *, const Dbt *, int, u_int32_t)) { - int ret; DB_ENV *dbenv = unwrap(this); + int ret; rep_send_callback_ = f_send; if ((ret = dbenv->set_rep_transport(dbenv, @@ -996,53 +780,47 @@ int DbEnv::set_rep_transport(u_int32_t myid, return (ret); } -int DbEnv::rep_elect(int nsites, int pri, u_int32_t timeout, int *idp) -{ - int ret; - DB_ENV *dbenv = unwrap(this); - if ((ret = dbenv->rep_elect(dbenv, - nsites, pri, timeout, idp)) != 0) - DB_ERROR("DbEnv::rep_elect", ret, error_policy()); - - return (ret); -} +DBENV_METHOD(rep_elect, + (int nsites, int pri, u_int32_t timeout, int *idp), + (dbenv, nsites, pri, timeout, idp)) int DbEnv::rep_process_message(Dbt *control, Dbt *rec, int *idp) { - int ret; DB_ENV *dbenv = unwrap(this); - if ((ret = dbenv->rep_process_message(dbenv, control, rec, idp)) != 0 && - ret != DB_REP_HOLDELECTION && ret != DB_REP_NEWSITE && - ret != DB_REP_NEWMASTER && ret != DB_REP_OUTDATED) + int ret; + + ret = dbenv->rep_process_message(dbenv, control, rec, idp); + if (!DB_RETOK_REPPMSG(ret)) DB_ERROR("DbEnv::rep_process_message", ret, error_policy()); return (ret); } -int DbEnv::rep_start(Dbt *cookie, u_int32_t flags) -{ - int ret; - DBT *cxxcookie = (DBT *)cookie; - DB_ENV *dbenv = unwrap(this); - if ((ret = dbenv->rep_start(dbenv, cxxcookie, flags)) != 0) - DB_ERROR("DbEnv::rep_start", ret, error_policy()); +DBENV_METHOD(rep_start, + (Dbt *cookie, u_int32_t flags), + (dbenv, (DBT *)cookie, flags)) - return (ret); -} +DBENV_METHOD(rep_stat, (DB_REP_STAT **statp, u_int32_t flags), + (dbenv, statp, flags)) -int DbEnv::set_timeout(db_timeout_t timeout, u_int32_t flags) -{ - int err; - DB_ENV *env = unwrap(this); - if ((err = env->set_timeout(env, timeout, flags)) != 0) { - DB_ERROR("DbEnv::set_timeout", err, error_policy()); - return (err); - } - return (err); -} +DBENV_METHOD(set_rep_limit, (u_int32_t gbytes, u_int32_t bytes), + (dbenv, gbytes, bytes)) + +DBENV_METHOD(set_timeout, + (db_timeout_t timeout, u_int32_t flags), + (dbenv, timeout, flags)) // static method char *DbEnv::version(int *major, int *minor, int *patch) { return (db_version(major, minor, patch)); } + +// static method +DbEnv *DbEnv::wrap_DB_ENV(DB_ENV *dbenv) +{ + DbEnv *wrapped_env = get_DbEnv(dbenv); + if (wrapped_env == NULL) + wrapped_env = new DbEnv(dbenv, 0); + return wrapped_env; +} diff --git a/db/cxx/cxx_logc.cpp b/db/cxx/cxx_logc.cpp index 61fb524a9..8bb70c1dc 100644 --- a/db/cxx/cxx_logc.cpp +++ b/db/cxx/cxx_logc.cpp @@ -1,28 +1,29 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997-2001 + * Copyright (c) 1997-2002 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: cxx_logc.cpp,v 11.3 2001/11/08 06:18:08 mjc Exp "; +static const char revid[] = "Id: cxx_logc.cpp,v 11.8 2002/07/03 21:03:53 bostic Exp "; #endif /* not lint */ #include <errno.h> #include <string.h> #include "db_cxx.h" -#include "cxx_int.h" +#include "dbinc/cxx_int.h" #include "db_int.h" -#include "db_page.h" -#include "db_auto.h" -#include "crdel_auto.h" -#include "db_ext.h" -#include "common_ext.h" +#include "dbinc/db_page.h" +#include "dbinc_auto/db_auto.h" +#include "dbinc_auto/crdel_auto.h" +#include "dbinc/db_dispatch.h" +#include "dbinc_auto/db_ext.h" +#include "dbinc_auto/common_ext.h" // It's private, and should never be called, // but some compilers need it resolved @@ -34,36 +35,31 @@ DbLogc::~DbLogc() // The name _flags prevents a name clash with __db_log_cursor::flags int DbLogc::close(u_int32_t _flags) { - DB_LOGC *cursor = this; - int err; + DB_LOGC *logc = this; + int ret; - if ((err = cursor->close(cursor, _flags)) != 0) { - DB_ERROR("DbLogc::close", err, ON_ERROR_UNKNOWN); - return (err); - } - return (0); + ret = logc->close(logc, _flags); + + if (!DB_RETOK_STD(ret)) + DB_ERROR("DbLogc::close", ret, ON_ERROR_UNKNOWN); + + return (ret); } // The name _flags prevents a name clash with __db_log_cursor::flags int DbLogc::get(DbLsn *lsn, Dbt *data, u_int32_t _flags) { - DB_LOGC *cursor = this; - int err; + DB_LOGC *logc = this; + int ret; - if ((err = cursor->get(cursor, lsn, data, _flags)) != 0) { + ret = logc->get(logc, lsn, data, _flags); - // DB_NOTFOUND is a "normal" returns, - // so should not be thrown as an error - // - if (err != DB_NOTFOUND) { - const char *name = "DbLogc::get"; - if (err == ENOMEM && DB_OVERFLOWED_DBT(data)) - DB_ERROR_DBT(name, data, ON_ERROR_UNKNOWN); - else - DB_ERROR(name, err, ON_ERROR_UNKNOWN); - - return (err); - } + if (!DB_RETOK_LGGET(ret)) { + if (ret == ENOMEM && DB_OVERFLOWED_DBT(data)) + DB_ERROR_DBT("DbLogc::get", data, ON_ERROR_UNKNOWN); + else + DB_ERROR("DbLogc::get", ret, ON_ERROR_UNKNOWN); } - return (err); + + return (ret); } diff --git a/db/dist/aclocal/config.ac b/db/dist/aclocal/config.ac index ae7b613b1..cd2884259 100644 --- a/db/dist/aclocal/config.ac +++ b/db/dist/aclocal/config.ac @@ -1,9 +1,12 @@ # Features we don't test for, but want the #defines to exist for # other ports. -AH_TEMPLATE(HAVE_VXWORKS, [Define if building VxWorks.]) +AH_TEMPLATE(HAVE_VXWORKS, [Define to 1 if building VxWorks.]) AH_TEMPLATE(HAVE_FILESYSTEM_NOTZERO, - [Define if allocated filesystem blocks are not zeroed.]) + [Define to 1 if allocated filesystem blocks are not zeroed.]) + +AH_TEMPLATE(HAVE_UNLINK_WITH_OPEN_FAILURE, + [Define to 1 if unlink of file with open file descriptors will fail.]) AH_BOTTOM([/* * Exit success/failure macros. @@ -38,6 +41,7 @@ AH_BOTTOM([/* #endif #ifndef HAVE_STRCASECMP #define strcasecmp __db_Cstrcasecmp +#define strncasecmp __db_Cstrncasecmp #endif #ifndef HAVE_STRERROR #define strerror __db_Cstrerror diff --git a/db/dist/aclocal/cxx.ac b/db/dist/aclocal/cxx.ac index d19171c33..49103cc66 100644 --- a/db/dist/aclocal/cxx.ac +++ b/db/dist/aclocal/cxx.ac @@ -8,7 +8,7 @@ db_cv_cxx_have_stdheaders, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include <iostream> -],[return 0;], +],[std::ostream *o; return 0;], db_cv_cxx_have_stdheaders=yes, db_cv_cxx_have_stdheaders=no) AC_LANG_RESTORE ]) diff --git a/db/dist/aclocal/libtool.ac b/db/dist/aclocal/libtool.ac index 29eef2f17..8e764711c 100644 --- a/db/dist/aclocal/libtool.ac +++ b/db/dist/aclocal/libtool.ac @@ -1482,6 +1482,15 @@ else hardcode_direct=yes archive_cmds='' hardcode_libdir_separator=':' + + #### Local change for Sleepycat's Berkeley DB [#5779]: + # Added $aix_export variable to control use of exports file. + # For non-gcc, we don't use exports files, and rather trust + # the binder's -qmkshrobj option to export all the mangled + # symbols we need for C++ and java. + + aix_export="\${wl}$exp_sym_flag:\$export_symbols" + if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) collect2name=`${CC} -print-prog-name=collect2` @@ -1514,6 +1523,22 @@ else shared_flag='${wl}-bM:SRE' fi fi + + # Test for -qmkshrobj and use it if it's available. + # It's superior for determining exportable symbols, + # especially for C++ or JNI libraries, which have + # mangled names. + # + AC_LANG_CONFTEST(void f(){}) + if AC_TRY_EVAL(CC -c conftest.c) && AC_TRY_EVAL(CC -o conftest conftest.$ac_objext -qmkshrobj -lC_r); then + lt_cv_aix_mkshrobj=yes + else + lt_cv_aix_mkshrobj=no + fi + + if test "$lt_cv_aix_mkshrobj" = yes; then + aix_export="-qmkshrobj" + fi fi # It seems that -bexpall can do strange things, so it is better to @@ -1524,12 +1549,12 @@ else # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib' - archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag $aix_export $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag $aix_export" else hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib' # Warning - without using the other run time loading flags, @@ -1537,7 +1562,7 @@ else allow_undefined_flag='${wl}-berok' # This is a bit strange, but is similar to how AIX traditionally builds # it's shared libraries. - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname' + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag $aix_export"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname' fi fi ;; @@ -1580,7 +1605,11 @@ else # FIXME: Relying on posixy $() will cause problems for # cross-compilation, but unfortunately the echo tests do not # yet detect zsh echo's removal of \ escapes. - archive_cmds='$nonopt $(test "x$module" = xyes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linker_flags -install_name $rpath/$soname $verstring' + + #### Local change for Sleepycat's Berkeley DB [#5664] + # removed double quotes in the following line: + archive_cmds='$nonopt $(test x$module = xyes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linker_flags -install_name $rpath/$soname $verstring' + # We need to add '_' to the symbols in $export_symbols first #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols' hardcode_direct=yes @@ -1947,6 +1976,12 @@ aix3*) aix4* | aix5*) version_type=linux + + #### Local change for Sleepycat's Berkeley DB [#5779]: + # If we don't set need_version, we'll get x.so.0.0.0, + # even if -avoid-version is set. + need_version=no + if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}.so$major ${libname}${release}.so$versuffix $libname.so' @@ -2054,8 +2089,11 @@ darwin* | rhapsody*) # FIXME: Relying on posixy $() will cause problems for # cross-compilation, but unfortunately the echo tests do not # yet detect zsh echo's removal of \ escapes. - library_names_spec='${libname}${release}${versuffix}.$(test .$module = .yes && echo so || echo dylib) ${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib) ${libname}.$(test .$module = .yes && echo so || echo dylib)' - soname_spec='${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib)' + #### Local change for Sleepycat's Berkeley DB [#6117]: + # added support for -jnimodule, encapsulated below in ${darwin_suffix} + darwin_suffix='$(test .$jnimodule = .yes && echo jnilib || (test .$module = .yes && echo so || echo dylib))' + library_names_spec='${libname}${release}${versuffix}.'"${darwin_suffix}"' ${libname}${release}${major}.'"${darwin_suffix}"' ${libname}.'"${darwin_suffix}" + soname_spec='${libname}${release}${major}.'"${darwin_suffix}" shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH ;; diff --git a/db/dist/aclocal/mutex.ac b/db/dist/aclocal/mutex.ac index 5f46873a0..ecfd7261c 100644 --- a/db/dist/aclocal/mutex.ac +++ b/db/dist/aclocal/mutex.ac @@ -1,49 +1,146 @@ -# Id: mutex.ac,v 11.25 2001/08/28 13:09:19 krinsky Exp +# Id: mutex.ac,v 11.38 2002/07/25 20:07:52 sue Exp + +# POSIX pthreads tests: inter-process safe and intra-process only. +# +# We need to run a test here, because the PTHREAD_PROCESS_SHARED flag compiles +# fine on problematic systems, but won't actually work. This is a problem for +# cross-compilation environments. I think inter-process mutexes are as likely +# to fail in cross-compilation environments as real ones (especially since the +# likely cross-compilation environment is Linux, where inter-process mutexes +# don't currently work -- the latest estimate I've heard is Q1 2002, as part +# of IBM's NGPT package). So: +# +# If checking for inter-process pthreads mutexes: +# If it's local, run a test. +# If it's a cross-compilation, fail. +# +# If the user specified pthreads mutexes and we're checking for intra-process +# mutexes only: +# If it's local, run a test. +# If it's a cross-compilation, run a link-test. +# +# So, the thing you can't do here is configure for inter-process POSIX pthread +# mutexes when cross-compiling. Since we're using the GNU/Cygnus toolchain for +# cross-compilation, the target system is likely Linux or *BSD, so we're doing +# the right thing. +AC_DEFUN(AM_PTHREADS_SHARED, [ +AC_TRY_RUN([ +#include <pthread.h> +main() { + pthread_cond_t cond; + pthread_mutex_t mutex; + pthread_condattr_t condattr; + pthread_mutexattr_t mutexattr; + exit ( + pthread_condattr_init(&condattr) || + pthread_condattr_setpshared(&condattr, PTHREAD_PROCESS_SHARED) || + pthread_mutexattr_init(&mutexattr) || + pthread_mutexattr_setpshared(&mutexattr, PTHREAD_PROCESS_SHARED) || + pthread_cond_init(&cond, &condattr) || + pthread_mutex_init(&mutex, &mutexattr) || + pthread_mutex_lock(&mutex) || + pthread_mutex_unlock(&mutex) || + pthread_mutex_destroy(&mutex) || + pthread_cond_destroy(&cond) || + pthread_condattr_destroy(&condattr) || + pthread_mutexattr_destroy(&mutexattr)); +}], [db_cv_mutex="$1"],, [db_cv_mutex="no"])]) +AC_DEFUN(AM_PTHREADS_PRIVATE, [ +AC_TRY_RUN([ +#include <pthread.h> +main() { + pthread_cond_t cond; + pthread_mutex_t mutex; + pthread_condattr_t condattr; + pthread_mutexattr_t mutexattr; + exit ( + pthread_condattr_init(&condattr) || + pthread_mutexattr_init(&mutexattr) || + pthread_cond_init(&cond, &condattr) || + pthread_mutex_init(&mutex, &mutexattr) || + pthread_mutex_lock(&mutex) || + pthread_mutex_unlock(&mutex) || + pthread_mutex_destroy(&mutex) || + pthread_cond_destroy(&cond) || + pthread_condattr_destroy(&condattr) || + pthread_mutexattr_destroy(&mutexattr)); +}], [db_cv_mutex="$1"],, +AC_TRY_LINK([ +#include <pthread.h>],[ + pthread_cond_t cond; + pthread_mutex_t mutex; + pthread_condattr_t condattr; + pthread_mutexattr_t mutexattr; + exit ( + pthread_condattr_init(&condattr) || + pthread_mutexattr_init(&mutexattr) || + pthread_cond_init(&cond, &condattr) || + pthread_mutex_init(&mutex, &mutexattr) || + pthread_mutex_lock(&mutex) || + pthread_mutex_unlock(&mutex) || + pthread_mutex_destroy(&mutex) || + pthread_cond_destroy(&cond) || + pthread_condattr_destroy(&condattr) || + pthread_mutexattr_destroy(&mutexattr)); +], [db_cv_mutex="$1"]))]) # Figure out mutexes for this compiler/architecture. AC_DEFUN(AM_DEFINE_MUTEXES, [ # Mutexes we don't test for, but want the #defines to exist for # other ports. -AH_TEMPLATE(HAVE_MUTEX_VMS, [Define to use VMS mutexes.]) -AH_TEMPLATE(HAVE_MUTEX_VXWORKS, [Define to use VxWorks mutexes.]) -AH_TEMPLATE(HAVE_MUTEX_WIN32, [Define to use Windows mutexes.]) +AH_TEMPLATE(HAVE_MUTEX_VMS, [Define to 1 to use VMS mutexes.]) +AH_TEMPLATE(HAVE_MUTEX_VXWORKS, [Define to 1 to use VxWorks mutexes.]) +AH_TEMPLATE(HAVE_MUTEX_WIN32, [Define to 1 to use Windows mutexes.]) AC_CACHE_CHECK([for mutexes], db_cv_mutex, [ db_cv_mutex=no orig_libs=$LIBS -# User-specified POSIX mutexes. +# User-specified POSIX or UI mutexes. +# +# There are two different reasons to specify mutexes: First, the application +# is already using one type of mutex and doesn't want to mix-and-match (for +# example, on Solaris, which has POSIX, UI and LWP mutexes). Second, the +# applications POSIX pthreads mutexes don't support inter-process locking, +# but the application wants to use them anyway (for example, current Linux +# and *BSD systems). +# +# If we're on Solaris, we insist that -lthread or -lpthread be used. The +# problem is the Solaris C library has UI/POSIX interface stubs, but they're +# broken, configuring them for inter-process mutexes doesn't return an error, +# but it doesn't work either. Otherwise, we try first without the library +# and then with it: there's some information that SCO/UnixWare/OpenUNIX needs +# this. [#4950] # -# Assume that -lpthread exists when the user specifies POSIX mutexes. (I -# only expect this option to be used on Solaris, which has -lpthread.) +# Test for LWP threads before testing for UI/POSIX threads, we prefer them +# on Solaris. There's a bug in SunOS 5.7 where applications get pwrite, not +# pwrite64, if they load the C library before the appropriate threads library, +# e.g., tclsh using dlopen to load the DB library. By using LWP threads we +# avoid answering lots of user questions, not to mention the bugs. if test "$db_cv_posixmutexes" = yes; then - db_cv_mutex="posix_only" + case "$host_os" in + solaris*) + db_cv_mutex="posix_library_only";; + *) + db_cv_mutex="posix_only";; + esac fi -# User-specified UI mutexes. -# -# Assume that -lthread exists when the user specifies UI mutexes. (I only -# expect this option to be used on Solaris, which has -lthread.) if test "$db_cv_uimutexes" = yes; then - db_cv_mutex="ui_only" + case "$host_os" in + solaris*) + db_cv_mutex="ui_library_only";; + *) + db_cv_mutex="ui_only";; + esac fi # LWP threads: _lwp_XXX -# -# Test for LWP threads before testing for UI/POSIX threads, we prefer them -# on Solaris. There are two reasons: the Solaris C library has UI/POSIX -# interface stubs, but they're broken, configuring them for inter-process -# mutexes doesn't return an error, but it doesn't work either. Second, -# there's a bug in SunOS 5.7 where applications get pwrite, not pwrite64, -# if they load the C library before the appropriate threads library, e.g., -# tclsh using dlopen to load the DB library. Anyway, by using LWP threads -# we avoid answering lots of user questions, not to mention the bugs. if test "$db_cv_mutex" = no; then -AC_TRY_RUN([ -#include <synch.h> -main(){ +AC_TRY_LINK([ +#include <synch.h>],[ static lwp_mutex_t mi = SHAREDMUTEX; static lwp_cond_t ci = SHAREDCV; lwp_mutex_t mutex = mi; @@ -51,18 +148,16 @@ main(){ exit ( _lwp_mutex_lock(&mutex) || _lwp_mutex_unlock(&mutex)); -}], [db_cv_mutex="Solaris/lwp"]) +], [db_cv_mutex="Solaris/lwp"]) fi # UI threads: thr_XXX # # Try with and without the -lthread library. if test "$db_cv_mutex" = no -o "$db_cv_mutex" = "ui_only"; then -LIBS="-lthread $LIBS" -AC_TRY_RUN([ +AC_TRY_LINK([ #include <thread.h> -#include <synch.h> -main(){ +#include <synch.h>],[ mutex_t mutex; cond_t cond; int type = USYNC_PROCESS; @@ -71,14 +166,14 @@ main(){ cond_init(&cond, type, NULL) || mutex_lock(&mutex) || mutex_unlock(&mutex)); -}], [db_cv_mutex="UI/threads/library"]) -LIBS="$orig_libs" +], [db_cv_mutex="UI/threads"]) fi -if test "$db_cv_mutex" = no -o "$db_cv_mutex" = "ui_only"; then -AC_TRY_RUN([ +if test "$db_cv_mutex" = no -o \ + "$db_cv_mutex" = "ui_only" -o "$db_cv_mutex" = "ui_library_only"; then +LIBS="$LIBS -lthread" +AC_TRY_LINK([ #include <thread.h> -#include <synch.h> -main(){ +#include <synch.h>],[ mutex_t mutex; cond_t cond; int type = USYNC_PROCESS; @@ -87,74 +182,47 @@ main(){ cond_init(&cond, type, NULL) || mutex_lock(&mutex) || mutex_unlock(&mutex)); -}], [db_cv_mutex="UI/threads"]) +], [db_cv_mutex="UI/threads/library"]) +LIBS="$orig_libs" fi -if test "$db_cv_mutex" = "ui_only"; then +if test "$db_cv_mutex" = "ui_only" -o "$db_cv_mutex" = "ui_library_only"; then AC_MSG_ERROR([unable to find UI mutex interfaces]) fi - # POSIX.1 pthreads: pthread_XXX # -# Try with and without the -lpthread library. +# Try with and without the -lpthread library. If the user specified we use +# POSIX pthreads mutexes, and we fail to find the full interface, try and +# configure for just intra-process support. if test "$db_cv_mutex" = no -o "$db_cv_mutex" = "posix_only"; then -AC_TRY_RUN([ -#include <pthread.h> -main(){ - pthread_cond_t cond; - pthread_mutex_t mutex; - pthread_condattr_t condattr; - pthread_mutexattr_t mutexattr; - exit ( - pthread_condattr_init(&condattr) || - pthread_condattr_setpshared(&condattr, PTHREAD_PROCESS_SHARED) || - pthread_mutexattr_init(&mutexattr) || - pthread_mutexattr_setpshared(&mutexattr, PTHREAD_PROCESS_SHARED) || - pthread_cond_init(&cond, &condattr) || - pthread_mutex_init(&mutex, &mutexattr) || - pthread_mutex_lock(&mutex) || - pthread_mutex_unlock(&mutex) || - pthread_mutex_destroy(&mutex) || - pthread_cond_destroy(&cond) || - pthread_condattr_destroy(&condattr) || - pthread_mutexattr_destroy(&mutexattr)); -}], [db_cv_mutex="POSIX/pthreads"]) + AM_PTHREADS_SHARED("POSIX/pthreads") fi -if test "$db_cv_mutex" = no -o "$db_cv_mutex" = "posix_only"; then -LIBS="-lpthread $LIBS" -AC_TRY_RUN([ -#include <pthread.h> -main(){ - pthread_cond_t cond; - pthread_mutex_t mutex; - pthread_condattr_t condattr; - pthread_mutexattr_t mutexattr; - exit ( - pthread_condattr_init(&condattr) || - pthread_condattr_setpshared(&condattr, PTHREAD_PROCESS_SHARED) || - pthread_mutexattr_init(&mutexattr) || - pthread_mutexattr_setpshared(&mutexattr, PTHREAD_PROCESS_SHARED) || - pthread_cond_init(&cond, &condattr) || - pthread_mutex_init(&mutex, &mutexattr) || - pthread_mutex_lock(&mutex) || - pthread_mutex_unlock(&mutex) || - pthread_mutex_destroy(&mutex) || - pthread_cond_destroy(&cond) || - pthread_condattr_destroy(&condattr) || - pthread_mutexattr_destroy(&mutexattr)); -}], [db_cv_mutex="POSIX/pthreads/library"]) -LIBS="$orig_libs" +if test "$db_cv_mutex" = no -o \ + "$db_cv_mutex" = "posix_only" -o "$db_cv_mutex" = "posix_library_only"; then + LIBS="$LIBS -lpthread" + AM_PTHREADS_SHARED("POSIX/pthreads/library") + LIBS="$orig_libs" fi if test "$db_cv_mutex" = "posix_only"; then - AC_MSG_ERROR([unable to find POSIX mutex interfaces]) + AM_PTHREADS_PRIVATE("POSIX/pthreads/private") +fi +if test "$db_cv_mutex" = "posix_only" -o \ + "$db_cv_mutex" = "posix_library_only"; then + LIBS="$LIBS -lpthread" + AM_PTHREADS_PRIVATE("POSIX/pthreads/library/private") + LIBS="$orig_libs" +fi + +if test "$db_cv_mutex" = "posix_only" -o \ + "$db_cv_mutex" = "posix_library_only"; then + AC_MSG_ERROR([unable to find POSIX 1003.1 mutex interfaces]) fi # msemaphore: HPPA only # Try HPPA before general msem test, it needs special alignment. if test "$db_cv_mutex" = no; then -AC_TRY_RUN([ -#include <sys/mman.h> -main(){ +AC_TRY_LINK([ +#include <sys/mman.h>],[ #if defined(__hppa) typedef msemaphore tsl_t; msemaphore x; @@ -163,53 +231,60 @@ main(){ msem_unlock(&x, 0); exit(0); #else - exit(1); + FAIL TO COMPILE/LINK #endif -}], [db_cv_mutex="HP/msem_init"]) +], [db_cv_mutex="HP/msem_init"]) fi # msemaphore: AIX, OSF/1 if test "$db_cv_mutex" = no; then -AC_TRY_RUN([ +AC_TRY_LINK([ #include <sys/types.h> -#include <sys/mman.h> -main(){ +#include <sys/mman.h>],[ typedef msemaphore tsl_t; msemaphore x; msem_init(&x, 0); msem_lock(&x, 0); msem_unlock(&x, 0); exit(0); -}], [db_cv_mutex="UNIX/msem_init"]) +], [db_cv_mutex="UNIX/msem_init"]) fi # ReliantUNIX if test "$db_cv_mutex" = no; then LIBS="$LIBS -lmproc" -AC_TRY_LINK([#include <ulocks.h>], -[typedef spinlock_t tsl_t; -spinlock_t x; initspin(&x, 1); cspinlock(&x); spinunlock(&x);], -[db_cv_mutex="ReliantUNIX/initspin"]) +AC_TRY_LINK([ +#include <ulocks.h>],[ + typedef spinlock_t tsl_t; + spinlock_t x; + initspin(&x, 1); + cspinlock(&x); + spinunlock(&x); +], [db_cv_mutex="ReliantUNIX/initspin"]) LIBS="$orig_libs" fi # SCO: UnixWare has threads in libthread, but OpenServer doesn't. if test "$db_cv_mutex" = no; then -AC_TRY_RUN([ -main(){ +AC_TRY_COMPILE(,[ #if defined(__USLC__) exit(0); +#else + FAIL TO COMPILE/LINK #endif - exit(1); -}], [db_cv_mutex="SCO/x86/cc-assembly"]) +], [db_cv_mutex="SCO/x86/cc-assembly"]) fi # abilock_t: SGI if test "$db_cv_mutex" = no; then -AC_TRY_LINK([#include <abi_mutex.h>], -[typedef abilock_t tsl_t; -abilock_t x; init_lock(&x); acquire_lock(&x); release_lock(&x);], -[db_cv_mutex="SGI/init_lock"]) +AC_TRY_LINK([ +#include <abi_mutex.h>],[ + typedef abilock_t tsl_t; + abilock_t x; + init_lock(&x); + acquire_lock(&x); + release_lock(&x); +], [db_cv_mutex="SGI/init_lock"]) fi # sema_t: Solaris @@ -217,11 +292,14 @@ fi # turn this test on, unless we find some other platform that uses the old # POSIX.1 interfaces. (I plan to move directly to pthreads on Solaris.) if test "$db_cv_mutex" = DOESNT_WORK; then -AC_TRY_LINK([#include <synch.h>], -[typedef sema_t tsl_t; - sema_t x; - sema_init(&x, 1, USYNC_PROCESS, NULL); sema_wait(&x); sema_post(&x);], -[db_cv_mutex="UNIX/sema_init"]) +AC_TRY_LINK([ +#include <synch.h>],[ + typedef sema_t tsl_t; + sema_t x; + sema_init(&x, 1, USYNC_PROCESS, NULL); + sema_wait(&x); + sema_post(&x); +], [db_cv_mutex="UNIX/sema_init"]) fi # _lock_try/_lock_clear: Solaris @@ -230,210 +308,304 @@ fi # sema_trywait(3T) or sema_wait(3T) function calls. This is because of # problems in those interfaces in some releases of the Solaris C library. if test "$db_cv_mutex" = no; then -AC_TRY_LINK([#include <sys/machlock.h>], -[typedef lock_t tsl_t; - lock_t x; - _lock_try(&x); _lock_clear(&x);], -[db_cv_mutex="Solaris/_lock_try"]) +AC_TRY_LINK([ +#include <sys/machlock.h>],[ + typedef lock_t tsl_t; + lock_t x; + _lock_try(&x); + _lock_clear(&x); +], [db_cv_mutex="Solaris/_lock_try"]) fi # _check_lock/_clear_lock: AIX if test "$db_cv_mutex" = no; then -AC_TRY_LINK([#include <sys/atomic_op.h>], -[int x; _check_lock(&x,0,1); _clear_lock(&x,0);], -[db_cv_mutex="AIX/_check_lock"]) +AC_TRY_LINK([ +#include <sys/atomic_op.h>],[ + int x; + _check_lock(&x,0,1); + _clear_lock(&x,0); +], [db_cv_mutex="AIX/_check_lock"]) fi # Alpha/gcc: OSF/1 if test "$db_cv_mutex" = no; then -AC_TRY_RUN([main(){ -#if defined(__alpha) -#if defined(__GNUC__) -exit(0); +AC_TRY_COMPILE(,[ +#if defined(__alpha) && defined(__GNUC__) + exit(0); +#else + FAIL TO COMPILE/LINK #endif +], [db_cv_mutex="ALPHA/gcc-assembly"]) +fi + +# ARM/gcc: Linux +if test "$db_cv_mutex" = no; then +AC_TRY_COMPILE(,[ +#if defined(__arm__) && defined(__GNUC__) + exit(0); +#else + FAIL TO COMPILE/LINK #endif -exit(1);}], -[db_cv_mutex="ALPHA/gcc-assembly"]) +], [db_cv_mutex="ARM/gcc-assembly"]) fi # PaRisc/gcc: HP/UX if test "$db_cv_mutex" = no; then -AC_TRY_RUN([main(){ -#if defined(__hppa) -#if defined(__GNUC__) -exit(0); -#endif +AC_TRY_COMPILE(,[ +#if (defined(__hppa) || defined(__hppa__)) && defined(__GNUC__) + exit(0); +#else + FAIL TO COMPILE/LINK #endif -exit(1);}], -[db_cv_mutex="HPPA/gcc-assembly"]) +], [db_cv_mutex="HPPA/gcc-assembly"]) fi # PPC/gcc: +# Test for Apple first, it requires slightly different assembly. if test "$db_cv_mutex" = no; then -AC_TRY_RUN([main(){ -#if defined(__powerpc__) || defined(__ppc__) -#if defined(__GNUC__) -exit(0); +AC_TRY_COMPILE(,[ +#if (defined(__powerpc__) || defined(__ppc__)) && defined(__GNUC__) && defined(__APPLE__) + exit(0); +#else + FAIL TO COMPILE/LINK #endif +], [db_cv_mutex="PPC_APPLE/gcc-assembly"]) +fi +if test "$db_cv_mutex" = no; then +AC_TRY_COMPILE(,[ +#if (defined(__powerpc__) || defined(__ppc__)) && defined(__GNUC__) + exit(0); +#else + FAIL TO COMPILE/LINK #endif -exit(1);}], -[db_cv_mutex="PPC/gcc-assembly"]) +], [db_cv_mutex="PPC_GENERIC/gcc-assembly"]) fi # Sparc/gcc: SunOS, Solaris if test "$db_cv_mutex" = no; then -AC_TRY_RUN([main(){ -#if defined(__sparc__) -#if defined(__GNUC__) +AC_TRY_COMPILE(,[ +#if defined(__sparc__) && defined(__GNUC__) exit(0); +#else + FAIL TO COMPILE/LINK #endif -#endif - exit(1); -}], [db_cv_mutex="Sparc/gcc-assembly"]) +], [db_cv_mutex="Sparc/gcc-assembly"]) fi # 68K/gcc: SunOS if test "$db_cv_mutex" = no; then -AC_TRY_RUN([main(){ -#if (defined(mc68020) || defined(sun3)) -#if defined(__GNUC__) +AC_TRY_COMPILE(,[ +#if (defined(mc68020) || defined(sun3)) && defined(__GNUC__) exit(0); +#else + FAIL TO COMPILE/LINK #endif -#endif - exit(1); -}], [db_cv_mutex="68K/gcc-assembly"]) +], [db_cv_mutex="68K/gcc-assembly"]) fi # x86/gcc: FreeBSD, NetBSD, BSD/OS, Linux if test "$db_cv_mutex" = no; then -AC_TRY_RUN([main(){ -#if defined(i386) || defined(__i386__) -#if defined(__GNUC__) +AC_TRY_COMPILE(,[ +#if (defined(i386) || defined(__i386__)) && defined(__GNUC__) exit(0); +#else + FAIL TO COMPILE/LINK #endif +], [db_cv_mutex="x86/gcc-assembly"]) +fi + +# S390/gcc: Linux +if test "$db_cv_mutex" = no; then +AC_TRY_COMPILE(,[ +#if defined(__s390__) && defined(__GNUC__) + exit(0); +#else + FAIL TO COMPILE/LINK #endif - exit(1); -}], [db_cv_mutex="x86/gcc-assembly"]) +], [db_cv_mutex="S390/gcc-assembly"]) fi # ia86/gcc: Linux if test "$db_cv_mutex" = no; then -AC_TRY_RUN([main(){ -#if defined(__ia64) -#if defined(__GNUC__) +AC_TRY_COMPILE(,[ +#if defined(__ia64) && defined(__GNUC__) exit(0); +#else + FAIL TO COMPILE/LINK #endif -#endif - exit(1); -}], [db_cv_mutex="ia64/gcc-assembly"]) +], [db_cv_mutex="ia64/gcc-assembly"]) fi # uts/cc: UTS if test "$db_cv_mutex" = no; then -AC_TRY_RUN([main(){ +AC_TRY_COMPILE(,[ #if defined(_UTS) exit(0); +#else + FAIL TO COMPILE/LINK #endif - exit(1); -}], [db_cv_mutex="UTS/cc-assembly"]) +], [db_cv_mutex="UTS/cc-assembly"]) fi -]) +# default to UNIX fcntl system call mutexes. if test "$db_cv_mutex" = no; then - AC_MSG_WARN( - [THREAD MUTEXES NOT AVAILABLE FOR THIS COMPILER/ARCHITECTURE.]) - ADDITIONAL_OBJS="mut_fcntl${o} $ADDITIONAL_OBJS" -else - AC_DEFINE(HAVE_MUTEX_THREADS) - AH_TEMPLATE(HAVE_MUTEX_THREADS, [Define if fast mutexes available.]) + db_cv_mutex="UNIX/fcntl" fi +]) case "$db_cv_mutex" in 68K/gcc-assembly) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_68K_GCC_ASSEMBLY) - AH_TEMPLATE(HAVE_MUTEX_68K_GCC_ASSEMBLY, [ - Define to use the GCC compiler and 68K assembly language mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_68K_GCC_ASSEMBLY, + [Define to 1 to use the GCC compiler and 68K assembly language mutexes.]);; AIX/_check_lock) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_AIX_CHECK_LOCK) - AH_TEMPLATE(HAVE_MUTEX_AIX_CHECK_LOCK, [ - Define to use the AIX _check_lock mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_AIX_CHECK_LOCK, + [Define to 1 to use the AIX _check_lock mutexes.]);; ALPHA/gcc-assembly) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_ALPHA_GCC_ASSEMBLY) - AH_TEMPLATE(HAVE_MUTEX_ALPHA_GCC_ASSEMBLY, [ - Define to use the GCC compiler and Alpha assembly language mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_ALPHA_GCC_ASSEMBLY, + [Define to 1 to use the GCC compiler and Alpha assembly language mutexes.]);; +ARM/gcc-assembly) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" + AC_DEFINE(HAVE_MUTEX_ARM_GCC_ASSEMBLY) + AH_TEMPLATE(HAVE_MUTEX_ARM_GCC_ASSEMBLY, + [Define to 1 to use the GCC compiler and ARM assembly language mutexes.]);; HP/msem_init) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_HPPA_MSEM_INIT) - AH_TEMPLATE(HAVE_MUTEX_HPPA_MSEM_INIT, [ - Define to use the msem_XXX mutexes on HP-UX.]);; + AH_TEMPLATE(HAVE_MUTEX_HPPA_MSEM_INIT, + [Define to 1 to use the msem_XXX mutexes on HP-UX.]);; HPPA/gcc-assembly) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_HPPA_GCC_ASSEMBLY) - AH_TEMPLATE(HAVE_MUTEX_HPPA_GCC_ASSEMBLY, [ - Define to use the GCC compiler and PaRisc assembly language mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_HPPA_GCC_ASSEMBLY, + [Define to 1 to use the GCC compiler and PaRisc assembly language mutexes.]);; ia64/gcc-assembly) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_IA64_GCC_ASSEMBLY) - AH_TEMPLATE(HAVE_MUTEX_IA64_GCC_ASSEMBLY, [ - Define to use the GCC compiler and IA64 assembly language mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_IA64_GCC_ASSEMBLY, + [Define to 1 to use the GCC compiler and IA64 assembly language mutexes.]);; POSIX/pthreads) ADDITIONAL_OBJS="mut_pthread${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_PTHREADS) - AH_TEMPLATE(HAVE_MUTEX_PTHREADS, [ - Define to use POSIX 1003.1 pthread_XXX mutexes.]);; -POSIX/pthreads/library) LIBS="-lpthread $LIBS" + AH_TEMPLATE(HAVE_MUTEX_PTHREADS, + [Define to 1 to use POSIX 1003.1 pthread_XXX mutexes.]);; +POSIX/pthreads/private) ADDITIONAL_OBJS="mut_pthread${o} $ADDITIONAL_OBJS" + AC_DEFINE(HAVE_MUTEX_PTHREADS) + AH_TEMPLATE(HAVE_MUTEX_PTHREADS, + [Define to 1 to use POSIX 1003.1 pthread_XXX mutexes.]) + AC_DEFINE(HAVE_MUTEX_THREAD_ONLY) + AH_TEMPLATE(HAVE_MUTEX_THREAD_ONLY, + [Define to 1 to configure mutexes intra-process only.]);; +POSIX/pthreads/library) LIBS="$LIBS -lpthread" ADDITIONAL_OBJS="mut_pthread${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_PTHREADS) - AH_TEMPLATE(HAVE_MUTEX_PTHREADS, [ - Define to use POSIX 1003.1 pthread_XXX mutexes.]);; -PPC/gcc-assembly) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" - AC_DEFINE(HAVE_MUTEX_PPC_GCC_ASSEMBLY) - AH_TEMPLATE(HAVE_MUTEX_PPC_GCC_ASSEMBLY, [ - Define to use the GCC compiler and PowerPC assembly language mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_PTHREADS, + [Define to 1 to use POSIX 1003.1 pthread_XXX mutexes.]);; +POSIX/pthreads/library/private) + LIBS="$LIBS -lpthread" + ADDITIONAL_OBJS="mut_pthread${o} $ADDITIONAL_OBJS" + AC_DEFINE(HAVE_MUTEX_PTHREADS) + AH_TEMPLATE(HAVE_MUTEX_PTHREADS, + [Define to 1 to use POSIX 1003.1 pthread_XXX mutexes.]) + AC_DEFINE(HAVE_MUTEX_THREAD_ONLY) + AH_TEMPLATE(HAVE_MUTEX_THREAD_ONLY, + [Define to 1 to configure mutexes intra-process only.]);; +PPC_GENERIC/gcc-assembly) + ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" + AC_DEFINE(HAVE_MUTEX_PPC_GENERIC_GCC_ASSEMBLY) + AH_TEMPLATE(HAVE_MUTEX_PPC_GENERIC_GCC_ASSEMBLY, + [Define to 1 to use the GCC compiler and generic PowerPC assembly language.]);; +PPC_APPLE/gcc-assembly) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" + AC_DEFINE(HAVE_MUTEX_PPC_APPLE_GCC_ASSEMBLY) + AH_TEMPLATE(HAVE_MUTEX_PPC_APPLE_GCC_ASSEMBLY, + [Define to 1 to use the GCC compiler and Apple PowerPC assembly language.]);; ReliantUNIX/initspin) LIBS="$LIBS -lmproc" ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_RELIANTUNIX_INITSPIN) - AH_TEMPLATE(HAVE_MUTEX_RELIANTUNIX_INITSPIN, [ - Define to use Reliant UNIX initspin mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_RELIANTUNIX_INITSPIN, + [Define to 1 to use Reliant UNIX initspin mutexes.]);; +S390/gcc-assembly) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" + AC_DEFINE(HAVE_MUTEX_S390_GCC_ASSEMBLY) + AH_TEMPLATE(HAVE_MUTEX_S390_GCC_ASSEMBLY, + [Define to 1 to use the GCC compiler and S/390 assembly language mutexes.]);; SCO/x86/cc-assembly) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_SCO_X86_CC_ASSEMBLY) - AH_TEMPLATE(HAVE_MUTEX_SCO_X86_CC_ASSEMBLY, [ - Define to use the SCO compiler and x86 assembly language mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_SCO_X86_CC_ASSEMBLY, + [Define to 1 to use the SCO compiler and x86 assembly language mutexes.]);; SGI/init_lock) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_SGI_INIT_LOCK) - AH_TEMPLATE(HAVE_MUTEX_SGI_INIT_LOCK, [ - Define to use the SGI XXX_lock mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_SGI_INIT_LOCK, + [Define to 1 to use the SGI XXX_lock mutexes.]);; Solaris/_lock_try) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_SOLARIS_LOCK_TRY) - AH_TEMPLATE(HAVE_MUTEX_SOLARIS_LOCK_TRY, [ - Define to use the Solaris _lock_XXX mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_SOLARIS_LOCK_TRY, + [Define to 1 to use the Solaris _lock_XXX mutexes.]);; Solaris/lwp) ADDITIONAL_OBJS="mut_pthread${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_SOLARIS_LWP) - AH_TEMPLATE(HAVE_MUTEX_SOLARIS_LWP, [ - Define to use the Solaris lwp threads mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_SOLARIS_LWP, + [Define to 1 to use the Solaris lwp threads mutexes.]);; Sparc/gcc-assembly) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_SPARC_GCC_ASSEMBLY) - AH_TEMPLATE(HAVE_MUTEX_SPARC_GCC_ASSEMBLY, [ - Define to use the GCC compiler and Sparc assembly language mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_SPARC_GCC_ASSEMBLY, + [Define to 1 to use the GCC compiler and Sparc assembly language mutexes.]);; UI/threads) ADDITIONAL_OBJS="mut_pthread${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_UI_THREADS) - AH_TEMPLATE(HAVE_MUTEX_UI_THREADS, [ - Define to use the UNIX International mutexes.]);; -UI/threads/library) LIBS="-lthread $LIBS" + AH_TEMPLATE(HAVE_MUTEX_UI_THREADS, + [Define to 1 to use the UNIX International mutexes.]);; +UI/threads/library) LIBS="$LIBS -lthread" ADDITIONAL_OBJS="mut_pthread${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_UI_THREADS) - AH_TEMPLATE(HAVE_MUTEX_UI_THREADS, [ - Define to use the UNIX International mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_UI_THREADS, + [Define to 1 to use the UNIX International mutexes.]);; UNIX/msem_init) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_MSEM_INIT) - AH_TEMPLATE(HAVE_MUTEX_MSEM_INIT, [ - Define to use the msem_XXX mutexes on systems other than HP-UX.]);; + AH_TEMPLATE(HAVE_MUTEX_MSEM_INIT, + [Define to 1 to use the msem_XXX mutexes on systems other than HP-UX.]);; UNIX/sema_init) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_SEMA_INIT) - AH_TEMPLATE(HAVE_MUTEX_SEMA_INIT, [ - Define to use the obsolete POSIX 1003.1 sema_XXX mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_SEMA_INIT, + [Define to 1 to use the obsolete POSIX 1003.1 sema_XXX mutexes.]);; UTS/cc-assembly) ADDITIONAL_OBJS="$ADDITIONAL_OBJS uts4.cc${o}" AC_DEFINE(HAVE_MUTEX_UTS_CC_ASSEMBLY) - AH_TEMPLATE(HAVE_MUTEX_UTS_CC_ASSEMBLY, [ - Define to use the UTS compiler and assembly language mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_UTS_CC_ASSEMBLY, + [Define to 1 to use the UTS compiler and assembly language mutexes.]);; x86/gcc-assembly) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS" AC_DEFINE(HAVE_MUTEX_X86_GCC_ASSEMBLY) - AH_TEMPLATE(HAVE_MUTEX_X86_GCC_ASSEMBLY, [ - Define to use the GCC compiler and x86 assembly language mutexes.]);; + AH_TEMPLATE(HAVE_MUTEX_X86_GCC_ASSEMBLY, + [Define to 1 to use the GCC compiler and x86 assembly language mutexes.]);; +UNIX/fcntl) AC_MSG_WARN( + [NO FAST MUTEXES FOUND FOR THIS COMPILER/ARCHITECTURE.]) + ADDITIONAL_OBJS="mut_fcntl${o} $ADDITIONAL_OBJS" + AC_DEFINE(HAVE_MUTEX_FCNTL) + AH_TEMPLATE(HAVE_MUTEX_FCNTL, + [Define to 1 to use the UNIX fcntl system call mutexes.]);; +*) AC_MSG_ERROR([Unknown mutex interface: $db_cv_mutex]);; +esac + +if test "$db_cv_mutex" != "UNIX/fcntl"; then + AC_DEFINE(HAVE_MUTEX_THREADS) + AH_TEMPLATE(HAVE_MUTEX_THREADS, + [Define to 1 if fast mutexes are available.]) +fi + +# There are 3 classes of mutexes: +# +# 1: Mutexes requiring no cleanup, for example, test-and-set mutexes. +# 2: Mutexes that must be destroyed, but which don't hold permanent system +# resources, for example, pthread mutexes on MVS aka OS/390 aka z/OS. +# 3: Mutexes that must be destroyed, even after the process is gone, for +# example, pthread mutexes on QNX and binary semaphores on VxWorks. +# +# DB cannot currently distinguish between #2 and #3 because DB does not know +# if the application is running environment recovery as part of startup and +# does not need to do cleanup, or if the environment is being removed and/or +# recovered in a loop in the application, and so does need to clean up. If +# we get it wrong, we're going to call the mutex destroy routine on a random +# piece of memory, which usually works, but just might drop core. For now, +# we group #2 and #3 into the HAVE_MUTEX_SYSTEM_RESOURCES define, until we +# have a better solution or reason to solve this in a general way -- so far, +# the places we've needed to handle this are few. +AH_TEMPLATE(HAVE_MUTEX_SYSTEM_RESOURCES, + [Define to 1 if mutexes hold system resources.]) + +case "$host_os$db_cv_mutex" in +*qnx*POSIX/pthread*|openedition*POSIX/pthread*) + AC_DEFINE(HAVE_MUTEX_SYSTEM_RESOURCES);; esac]) diff --git a/db/dist/aclocal/options.ac b/db/dist/aclocal/options.ac index 846538bf2..7c2c6a70b 100644 --- a/db/dist/aclocal/options.ac +++ b/db/dist/aclocal/options.ac @@ -1,4 +1,4 @@ -# Id: options.ac,v 11.17 2001/06/07 21:23:36 bostic Exp +# Id: options.ac,v 11.19 2002/06/25 19:31:48 bostic Exp # Process user-specified options. AC_DEFUN(AM_OPTIONS_SET, [ @@ -6,97 +6,113 @@ AC_DEFUN(AM_OPTIONS_SET, [ # --enable-bigfile was the configuration option that Berkeley DB used before # autoconf 2.50 was released (which had --enable-largefile integrated in). AC_ARG_ENABLE(bigfile, - [ --disable-bigfile Obsolete; use --disable-largefile instead.], + [AC_HELP_STRING([--disable-bigfile], + [Obsolete; use --disable-largefile instead.])], [AC_MSG_ERROR( [--enable-bigfile no longer supported, use --enable-largefile])]) AC_MSG_CHECKING(if --enable-compat185 option specified) AC_ARG_ENABLE(compat185, - [ --enable-compat185 Build DB 1.85 compatibility API.], + [AC_HELP_STRING([--enable-compat185], + [Build DB 1.85 compatibility API.])], [db_cv_compat185="$enable_compat185"], [db_cv_compat185="no"]) AC_MSG_RESULT($db_cv_compat185) AC_MSG_CHECKING(if --enable-cxx option specified) AC_ARG_ENABLE(cxx, - [ --enable-cxx Build C++ API.], + [AC_HELP_STRING([--enable-cxx], + [Build C++ API.])], [db_cv_cxx="$enable_cxx"], [db_cv_cxx="no"]) AC_MSG_RESULT($db_cv_cxx) AC_MSG_CHECKING(if --enable-debug option specified) AC_ARG_ENABLE(debug, - [ --enable-debug Build a debugging version.], + [AC_HELP_STRING([--enable-debug], + [Build a debugging version.])], [db_cv_debug="$enable_debug"], [db_cv_debug="no"]) AC_MSG_RESULT($db_cv_debug) AC_MSG_CHECKING(if --enable-debug_rop option specified) AC_ARG_ENABLE(debug_rop, - [ --enable-debug_rop Build a version that logs read operations.], + [AC_HELP_STRING([--enable-debug_rop], + [Build a version that logs read operations.])], [db_cv_debug_rop="$enable_debug_rop"], [db_cv_debug_rop="no"]) AC_MSG_RESULT($db_cv_debug_rop) AC_MSG_CHECKING(if --enable-debug_wop option specified) AC_ARG_ENABLE(debug_wop, - [ --enable-debug_wop Build a version that logs write operations.], + [AC_HELP_STRING([--enable-debug_wop], + [Build a version that logs write operations.])], [db_cv_debug_wop="$enable_debug_wop"], [db_cv_debug_wop="no"]) AC_MSG_RESULT($db_cv_debug_wop) AC_MSG_CHECKING(if --enable-diagnostic option specified) AC_ARG_ENABLE(diagnostic, - [ --enable-diagnostic Build a version with run-time diagnostics.], + [AC_HELP_STRING([--enable-diagnostic], + [Build a version with run-time diagnostics.])], [db_cv_diagnostic="$enable_diagnostic"], [db_cv_diagnostic="no"]) AC_MSG_RESULT($db_cv_diagnostic) AC_MSG_CHECKING(if --enable-dump185 option specified) AC_ARG_ENABLE(dump185, - [ --enable-dump185 Build db_dump185(1) to dump 1.85 databases.], + [AC_HELP_STRING([--enable-dump185], + [Build db_dump185(1) to dump 1.85 databases.])], [db_cv_dump185="$enable_dump185"], [db_cv_dump185="no"]) AC_MSG_RESULT($db_cv_dump185) AC_MSG_CHECKING(if --enable-java option specified) AC_ARG_ENABLE(java, - [ --enable-java Build Java API.], + [AC_HELP_STRING([--enable-java], + [Build Java API.])], [db_cv_java="$enable_java"], [db_cv_java="no"]) AC_MSG_RESULT($db_cv_java) AC_MSG_CHECKING(if --enable-posixmutexes option specified) AC_ARG_ENABLE(posixmutexes, - [ --enable-posixmutexes Force use of POSIX standard mutexes.], + [AC_HELP_STRING([--enable-posixmutexes], + [Force use of POSIX standard mutexes.])], [db_cv_posixmutexes="$enable_posixmutexes"], [db_cv_posixmutexes="no"]) AC_MSG_RESULT($db_cv_posixmutexes) AC_MSG_CHECKING(if --enable-rpc option specified) AC_ARG_ENABLE(rpc, - [ --enable-rpc Build RPC client/server.], + [AC_HELP_STRING([--enable-rpc], + [Build RPC client/server.])], [db_cv_rpc="$enable_rpc"], [db_cv_rpc="no"]) AC_MSG_RESULT($db_cv_rpc) AC_MSG_CHECKING(if --enable-tcl option specified) AC_ARG_ENABLE(tcl, - [ --enable-tcl Build Tcl API.], + [AC_HELP_STRING([--enable-tcl], + [Build Tcl API.])], [db_cv_tcl="$enable_tcl"], [db_cv_tcl="no"]) AC_MSG_RESULT($db_cv_tcl) AC_MSG_CHECKING(if --enable-test option specified) AC_ARG_ENABLE(test, - [ --enable-test Configure to run the test suite.], + [AC_HELP_STRING([--enable-test], + [Configure to run the test suite.])], [db_cv_test="$enable_test"], [db_cv_test="no"]) AC_MSG_RESULT($db_cv_test) AC_MSG_CHECKING(if --enable-uimutexes option specified) AC_ARG_ENABLE(uimutexes, - [ --enable-uimutexes Force use of Unix International mutexes.], + [AC_HELP_STRING([--enable-uimutexes], + [Force use of Unix International mutexes.])], [db_cv_uimutexes="$enable_uimutexes"], [db_cv_uimutexes="no"]) AC_MSG_RESULT($db_cv_uimutexes) AC_MSG_CHECKING(if --enable-umrw option specified) AC_ARG_ENABLE(umrw, - [ --enable-umrw Mask harmless unitialized memory read/writes.], + [AC_HELP_STRING([--enable-umrw], + [Mask harmless unitialized memory read/writes.])], [db_cv_umrw="$enable_umrw"], [db_cv_umrw="no"]) AC_MSG_RESULT($db_cv_umrw) AC_MSG_CHECKING([if --with-embedix=DIR option specified]) AC_ARG_WITH(embedix, - [ --with-embedix=DIR Embedix install directory location.], + [AC_HELP_STRING([--with-embedix=DIR], + [Embedix install directory location.])], [with_embedix="$withval"], [with_embedix="no"]) if test "$with_embedix" = "no"; then db_cv_embedix="no" @@ -111,9 +127,23 @@ else AC_MSG_RESULT($db_cv_path_embedix_install) fi +AC_MSG_CHECKING(if --with-mutex=MUTEX option specified) +AC_ARG_WITH(mutex, + [AC_HELP_STRING([--with-mutex=MUTEX], + [Selection of non-standard mutexes.])], + [with_mutex="$withval"], [with_mutex="no"]) +if test "$with_mutex" = "yes"; then + AC_MSG_ERROR([--with-mutex requires a mutex name argument]) +fi +if test "$with_mutex" != "no"; then + db_cv_mutex="$with_mutex" +fi +AC_MSG_RESULT($with_mutex) + AC_MSG_CHECKING(if --with-rpm=DIR option specified) AC_ARG_WITH(rpm, - [ --with-rpm=DIR Directory location of RPM archive.], + [AC_HELP_STRING([--with-rpm=DIR], + [Directory location of RPM archive.])], [with_rpm="$withval"], [with_rpm="no"]) if test "$with_rpm" = "no"; then db_cv_rpm="no" @@ -128,7 +158,8 @@ AC_MSG_RESULT($with_rpm) AC_MSG_CHECKING([if --with-tcl=DIR option specified]) AC_ARG_WITH(tcl, - [ --with-tcl=DIR Directory location of tclConfig.sh.], + [AC_HELP_STRING([--with-tcl=DIR], + [Directory location of tclConfig.sh.])], [with_tclconfig="$withval"], [with_tclconfig="no"]) AC_MSG_RESULT($with_tclconfig) if test "$with_tclconfig" != "no"; then @@ -137,7 +168,8 @@ fi AC_MSG_CHECKING([if --with-uniquename=NAME option specified]) AC_ARG_WITH(uniquename, - [ --with-uniquename=NAME Build a uniquely named library.], + [AC_HELP_STRING([--with-uniquename=NAME], + [Build a uniquely named library.])], [with_uniquename="$withval"], [with_uniquename="no"]) if test "$with_uniquename" = "no"; then db_cv_uniquename="no" diff --git a/db/dist/buildrel b/db/dist/buildrel index ef589abcb..bddb1d1ff 100644 --- a/db/dist/buildrel +++ b/db/dist/buildrel @@ -1,5 +1,5 @@ #!/bin/sh - -# Id: buildrel,v 1.31 2001/10/14 15:31:11 bostic Exp +# Id: buildrel,v 1.34 2002/06/24 17:48:25 bostic Exp # # Build the distribution archives. # @@ -32,18 +32,19 @@ cd $D && tar cf - \ cd $R/dist && sh s_perm cd $R/dist && sh s_symlink -# Build the documentation. -cd $R/docs_src && make - # Build a version. cd $R && rm -rf build_run && mkdir build_run cd $R/build_run && ~bostic/bin/dbconf && make >& mklog # Smoke test. -./ex_access +cd $R/build_run && ./ex_access + +# Build the documentation. +cd $R/docs_src && sh build clean +cd $R/docs_src && sh build |& sed '/.html$/d' # Check the install -make prefix=`pwd`/BDB install +cd $R/build_run && make prefix=`pwd`/BDB install # Clean up the tree. cd $R && rm -rf build_run docs_src @@ -65,19 +66,36 @@ cd $R/../db-${LR} && find . | sort > /tmp/__OLD cd $R && find . | sort > /tmp/__NEW diff -c /tmp/__OLD /tmp/__NEW -# Create the tar archive release. +# Create the crypto tar archive release. setenv T "$R/../db-$VERSION.tar.gz" cd $R/.. && tar cf - db-$VERSION | gzip --best > $T chmod 444 $T -# Create the zip archive release. -# -# Remove symbolic links to tags files. They're large and we don't want to -# store real symbolic links in the archive for portability reasons. +# Create the non-crypto tree. +setenv RNC "$R/../db-$VERSION.NC" +rm -rf $R/../__TMP && mkdir $R/../__TMP +cd $R/../__TMP && gzcat $T | tar xpf - && mv -i db-$VERSION $RNC +cd $R && rm -rf $R/../__TMP +cd $RNC/dist && sh s_crypto + +# Create the non-crypto tar archive release. +setenv T "$R/../db-$VERSION.NC.tar.gz" +cd $RNC/.. && tar cf - db-$VERSION.NC | gzip --best > $T +chmod 444 $T + +# Remove symbolic links to tags files. They're large and we don't want +# to store real symbolic links in the zip archive for portability reasons. # ACQUIRE ROOT PRIVILEGES cd $R && rm -f `find . -type l -name 'tags'` +cd $RNC && rm -f `find . -type l -name 'tags'` # DISCARD ROOT PRIVILEGES +# Create the crypto zip archive release. setenv T "$R/../db-$VERSION.zip" cd $R/.. && zip -r - db-$VERSION > $T chmod 444 $T + +# Create the non-crypto zip archive release. +setenv T "$R/../db-$VERSION.NC.zip" +cd $RNC/.. && zip -r - db-$VERSION.NC > $T +chmod 444 $T diff --git a/db/dist/configure.ac b/db/dist/configure.ac index 45e8680d3..8ff1ee715 100644 --- a/db/dist/configure.ac +++ b/db/dist/configure.ac @@ -1,13 +1,14 @@ -# Id: configure.ac,v 11.125 2001/11/12 14:29:59 bostic Exp +# Id: configure.ac,v 11.155 2002/07/12 18:56:44 bostic Exp # Process this file with autoconf to produce a configure script. PACKAGE=db -AC_INIT +AC_INIT(Berkeley DB, + __EDIT_DB_VERSION__, support@sleepycat.com, db-__EDIT_DB_VERSION__) AC_CONFIG_SRCDIR([../db/db.c]) AC_CONFIG_HEADER(db_config.h:config.hin) # Configure setup. -AC_CANONICAL_HOST +AC_CANONICAL_HOST() AC_ARG_PROGRAM() # We cannot build in the top-level directory. @@ -28,7 +29,6 @@ AC_SUBST(CONFIGURATION_PATH) AC_SUBST(CPPFLAGS) AC_SUBST(CXX) AC_SUBST(CXXFLAGS) -AC_SUBST(DEFAULT_INSTALL) AC_SUBST(DEFAULT_LIB) AC_SUBST(DEFAULT_LIB_CXX) AC_SUBST(EMBEDIX_ECD_CXX) @@ -58,9 +58,9 @@ AC_SUBST(RPC_CLIENT_OBJS) AC_SUBST(RPM_POST_INSTALL) AC_SUBST(RPM_POST_UNINSTALL) AC_SUBST(SOFLAGS) -AC_SUBST(SOSUFFIX) AC_SUBST(db_cv_path_embedix_install) AC_SUBST(db_cv_path_rpm_archive) +AC_SUBST(db_int_def) AC_SUBST(o) # RPM needs the current absolute path. @@ -82,29 +82,29 @@ AM_OPTIONS_SET # Set some #defines based on configuration options. if test "$db_cv_diagnostic" = yes; then AC_DEFINE(DIAGNOSTIC) - AH_TEMPLATE(DIAGNOSTIC, [ - Define if you want a version with run-time diagnostic checking.]) + AH_TEMPLATE(DIAGNOSTIC, + [Define to 1 if you want a version with run-time diagnostic checking.]) fi if test "$db_cv_debug_rop" = yes; then AC_DEFINE(DEBUG_ROP) - AH_TEMPLATE(DEBUG_ROP, [ - Define if you want a version that logs read operations.]) + AH_TEMPLATE(DEBUG_ROP, + [Define to 1 if you want a version that logs read operations.]) fi if test "$db_cv_debug_wop" = yes; then AC_DEFINE(DEBUG_WOP) - AH_TEMPLATE(DEBUG_WOP, [ - Define if you want a version that logs write operations.]) + AH_TEMPLATE(DEBUG_WOP, + [Define to 1 if you want a version that logs write operations.]) fi if test "$db_cv_umrw" = yes; then AC_DEFINE(UMRW) - AH_TEMPLATE(UMRW, [ - Define to mask harmless unitialized memory read/writes.]) + AH_TEMPLATE(UMRW, + [Define to 1 to mask harmless unitialized memory read/writes.]) fi if test "$db_cv_test" = yes; then AC_DEFINE(CONFIG_TEST) - AH_TEMPLATE(CONFIG_TEST, [ - Define if you are building a version for running the test suite.]) + AH_TEMPLATE(CONFIG_TEST, + [Define to 1 if you want to build a version for running the test suite.]) fi # Check for programs used in building and installation. @@ -146,15 +146,11 @@ fi # Don't override anything if it's already set from the environment. optimize_def="-O" case "$host_os" in -aix4.3.1*|aix4.3.2*) - optimize_def="-O2" - CC=${CC-"xlc_r"} - CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE";; -aix4.3.3*) +aix4.3.*|aix5*) optimize_def="-O2" CC=${CC-"xlc_r"} CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" - LDFLAGS="$LDFLAGS -pthread";; + LDFLAGS="$LDFLAGS -Wl,-brtl";; bsdi3*) optimize_def="-O2" CC=${CC-"shlicc2"} LIBS="$LIBS -lipc";; @@ -173,12 +169,7 @@ mpeix*) CPPFLAGS="$CPPFLAGS -D_POSIX_SOURCE -D_SOCKET_SOURCE" osf*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" LDFLAGS="$LDFLAGS -pthread";; *qnx) AC_DEFINE(HAVE_QNX) - AH_TEMPLATE(HAVE_QNX, [Define if building on QNX.]);; -sco3.2v4*) - CC=${CC-"cc -belf"} - LIBS="$LIBS -lsocket -lnsl_s";; -sco*) CC=${CC-"cc -belf"} - LIBS="$LIBS -lsocket -lnsl";; + AH_TEMPLATE(HAVE_QNX, [Define to 1 if building on QNX.]);; solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT";; esac @@ -196,18 +187,16 @@ CXXFLAGS=${CXXFLAGS-"$CFLAGS"} # handle this is to specify CFLAGS in the environment before configuring. if test "$db_cv_debug" = yes; then AC_DEFINE(DEBUG) - AH_TEMPLATE(DEBUG, [Define if you want a debugging version.]) + AH_TEMPLATE(DEBUG, [Define to 1 if you want a debugging version.]) CFLAGS="$CFLAGS -g" CXXFLAGS="$CXXFLAGS -g" fi # The default compiler is cc (NOT gcc), the default CFLAGS is as specified -# above, NOT what is set by AC_PROG_CC, as it won't set optimization flags. -# We still call AC_PROG_CC so that we get the other side-effects. -AC_CHECK_TOOL(CC, cc) -AC_CHECK_TOOL(CC, gcc) -AC_PROG_CC +# above, NOT what is set by AC_PROG_CC, as it won't set optimization flags +# for any compiler other than gcc. +AC_PROG_CC(cc gcc) # Because of shared library building, the ${CC} used for config tests # may be different than the ${CC} we want to put in the Makefile. @@ -231,6 +220,7 @@ if test "$db_cv_cxx" = "yes"; then LIBXSO_LIBS="-lC_r $LIBXSO_LIBS" LIBS="-lC_r $LIBS";; hpux*) AC_CHECK_TOOL(CCC, aCC);; + irix*) AC_CHECK_TOOL(CCC, CC);; osf*) AC_CHECK_TOOL(CCC, cxx);; solaris*) AC_CHECK_TOOL(CCC, CC);; esac @@ -245,6 +235,20 @@ fi AC_GCC_CONFIG1 AC_GCC_CONFIG2 +# We need the -Kthread/-pthread flag when compiling on SCO/Caldera's UnixWare +# and OpenUNIX releases. We can't make the test until we know which compiler +# we're using. +case "$host_os" in +sysv5UnixWare*|sysv5OpenUNIX8*) + if test "$GCC" == "yes"; then + CPPFLAGS="$CPPFLAGS -pthread" + LDFLAGS="$LDFLAGS -pthread" + else + CPPFLAGS="$CPPFLAGS -Kthread" + LDFLAGS="$LDFLAGS -Kthread" + fi;; +esac + # Export our compiler preferences for the libtool configuration. export CC CCC CCC=CXX @@ -255,27 +259,12 @@ AC_PROG_LIBTOOL LIBTOOL="\$(SHELL) ./libtool" SOFLAGS="-rpath \$(libdir)" -AC_MSG_CHECKING([SOSUFFIX from libtool]) -# $library_names_spec is a snippet of shell that may -# defined in terms of $versuffix, $release, $libname. -# All we want is to eval it and grab the suffix used -# for shared objects. -versuffix="" -release="" -libname=libfoo -eval library_names=\"$library_names_spec\" -SOSUFFIX=`echo "$library_names" | sed -e 's/.*\.\([[a-zA-Z0-9_]]*\).*/\1/'` -AC_MSG_RESULT($SOSUFFIX) - -if test "$SOSUFFIX" = '' ; then - SOSUFFIX=so - if test "$enable_shared" = "yes"; then - AC_MSG_WARN([libtool may not know about this architecture.]) - AC_MSG_WARN([assuming .$SOSUFFIX suffix for dynamic libraries.]) - fi -fi +# Set SOSUFFIX and friends +SOSUFFIX_CONFIG +MODSUFFIX_CONFIG +JMODSUFFIX_CONFIG -INSTALLER="\$(LIBTOOL) --mode=install cp" +INSTALLER="\$(LIBTOOL) --mode=install cp -p" MAKEFILE_CC="\$(LIBTOOL) --mode=compile ${MAKEFILE_CC}" MAKEFILE_SOLINK="\$(LIBTOOL) --mode=link ${MAKEFILE_CCLINK} -avoid-version" @@ -358,11 +347,11 @@ fi # Optional RPC client/server. if test "$db_cv_rpc" = "yes"; then AC_DEFINE(HAVE_RPC) - AH_TEMPLATE(HAVE_RPC, [Define if building RPC client/server.]) + AH_TEMPLATE(HAVE_RPC, [Define to 1 if building RPC client/server.]) RPC_CLIENT_OBJS="\$(RPC_CLIENT_OBJS)" ADDITIONAL_PROGS="berkeley_db_svc $ADDITIONAL_PROGS" - + EMBEDIX_ECD_RPC="/usr/bin/berkeley_db_svc" case "$host_os" in @@ -377,6 +366,14 @@ fi AM_TCL_LOAD +# Optional crypto support. +if test -d "$srcdir/../crypto"; then + AC_DEFINE(HAVE_CRYPTO) + AH_TEMPLATE(HAVE_CRYPTO, + [Define to 1 if Berkeley DB release includes strong cryptography.]) + ADDITIONAL_OBJS="aes_method${o} crypto${o} mt19937db${o} rijndael-alg-fst${o} rijndael-api-fst${o} $ADDITIONAL_OBJS" +fi + # Optional DB 1.85 compatibility API. if test "$db_cv_compat185" = "yes"; then ADDITIONAL_INCS="db_185.h $ADDITIONAL_INCS" @@ -388,19 +385,15 @@ if test "$db_cv_dump185" = "yes"; then ADDITIONAL_PROGS="db_dump185 $ADDITIONAL_PROGS" fi -# Checks for system/compiler characteristics. -AC_C_BIGENDIAN +# Checks for compiler characteristics. AC_C_CONST -# Checks for include files, structures. +# Checks for include files, structures, C types. AC_HEADER_STAT AC_HEADER_TIME AC_HEADER_DIRENT -AC_CHECK_HEADERS(sys/select.h) -AC_CHECK_HEADERS(sys/time.h) +AC_CHECK_HEADERS(sys/select.h sys/time.h) AC_CHECK_MEMBERS([struct stat.st_blksize]) - -# Check for C types. AM_TYPES AC_CACHE_CHECK([for ANSI C exit success/failure values], db_cv_exit_defines, [ @@ -408,8 +401,8 @@ AC_TRY_COMPILE([#include <stdlib.h>], return (EXIT_SUCCESS);, [db_cv_exit_defines=yes], [db_cv_exit_defines=no])]) if test "$db_cv_exit_defines" = yes; then AC_DEFINE(HAVE_EXIT_SUCCESS) - AH_TEMPLATE(HAVE_EXIT_SUCCESS, [ - Define if you have EXIT_SUCCESS/EXIT_FAILURE #defines.]) + AH_TEMPLATE(HAVE_EXIT_SUCCESS, + [Define to 1 if you have EXIT_SUCCESS/EXIT_FAILURE #defines.]) fi # Test for various functions/libraries that the test and example programs use: @@ -444,23 +437,19 @@ AM_DEFINE_MUTEXES # The only portable getcwd call is getcwd(char *, size_t), where the # buffer is non-NULL -- Solaris can't handle a NULL buffer, and they # deleted getwd(). -AC_REPLACE_FUNCS(getcwd getopt memcmp memcpy memmove) -AC_REPLACE_FUNCS(raise snprintf strcasecmp strerror vsnprintf) - -# XXX -# Nasty hack. AC_REPLACE_FUNCS added entries of the form xxx.o to the -# LIBOBJS variable. They have to be xxx.lo if we are building shared -# libraries. Use sed, configure already requires it. -tmp="`echo \"$LIBOBJS\" | sed \"s/\.o/${o}/g\"`" -LIBOBJS="$tmp" +AC_REPLACE_FUNCS(getcwd getopt memcmp memcpy memmove raise) +AC_REPLACE_FUNCS(snprintf strcasecmp strdup strerror vsnprintf) # Check for system functions we optionally use. -AC_CHECK_FUNCS(_fstati64 getuid pstat_getdynamic sched_yield select strtoul) -AC_CHECK_FUNCS(gettimeofday clock_gettime sysconf yield) +AC_CHECK_FUNCS(_fstati64 clock_gettime directio gettimeofday getuid) +AC_CHECK_FUNCS(pstat_getdynamic sched_yield select strtoul sysconf yield) + +# Checks for system functions for which we don't have replacements. +# We require qsort(3). +AC_CHECK_FUNCS(qsort, , AC_MSG_ERROR([No qsort library function.])) # Pread/pwrite. -# -# HP-UX has pread/pwrite, but it doesn't work with bigfile support. +# HP-UX has pread/pwrite, but it doesn't work with largefile support. case "$host_os" in hpux*) AC_MSG_WARN([pread/pwrite interfaces ignored on $host_os.]);; @@ -469,15 +458,15 @@ esac # Check for fcntl(2) to deny child process access to file descriptors. AC_CACHE_CHECK([for fcntl/F_SETFD], db_cv_fcntl_f_setfd, [ -AC_TRY_RUN([ +AC_TRY_LINK([ #include <sys/types.h> -#include <fcntl.h> -main(){exit(fcntl(1, F_SETFD, 1) == -1);}], - [db_cv_fcntl_f_setfd=yes], [db_cv_fcntl_f_setfd=no])]) +#include <fcntl.h>], [ + fcntl(1, F_SETFD, 1); +], [db_cv_fcntl_f_setfd=yes], [db_cv_fcntl_f_setfd=no])]) if test "$db_cv_fcntl_f_setfd" = yes; then AC_DEFINE(HAVE_FCNTL_F_SETFD) - AH_TEMPLATE(HAVE_FCNTL_F_SETFD, [ - Define if fcntl/F_SETFD denies child access to file descriptors.]) + AH_TEMPLATE(HAVE_FCNTL_F_SETFD, + [Define to 1 if fcntl/F_SETFD denies child access to file descriptors.]) fi # A/UX has a broken getopt(3). @@ -485,31 +474,35 @@ case "$host_os" in aux*) ADDITIONAL_OBJS="getopt${o} $ADDITIONAL_OBJS";; esac -# Checks for system functions for which we don't have replacements. -# We require qsort(3). -AC_CHECK_FUNCS(qsort, , AC_MSG_ERROR([No qsort library function.])) - -# Some versions of sprintf return a pointer to the first argument instead -# of a character count. We assume that the return value of snprintf and -# vsprintf etc. will be the same as sprintf, and check the easy one. -AC_CACHE_CHECK([for int type sprintf return value], db_cv_sprintf_count, [ -AC_TRY_RUN([main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}], - [db_cv_sprintf_count=yes], [db_cv_sprintf_count=no])]) -if test "$db_cv_sprintf_count" = no; then - AC_DEFINE(SPRINTF_RET_CHARPNT) - AH_TEMPLATE(SPRINTF_RET_CHARPNT, - [Define if your sprintf returns a pointer, not a length.]) +# Linux has the O_DIRECT flag, but you can't actually use it. +AC_CACHE_CHECK([for open/O_DIRECT], db_cv_open_o_direct, [ +echo "test for working open/O_DIRECT" > __o_direct_file +AC_TRY_RUN([ +#include <sys/types.h> +#include <fcntl.h> +main() { +int c, fd = open("__o_direct_file", O_RDONLY | O_DIRECT, 0); +exit ((fd == -1) || (read(fd, &c, 1) != 1)); +}], [db_cv_open_o_direct=yes], [db_cv_open_o_direct=no], +AC_TRY_LINK([ +#include <sys/types.h> +#include <fcntl.h>], [ + open("__o_direct_file", O_RDONLY | O_DIRECT, 0); +], [db_cv_open_o_direct=yes], [db_cv_open_o_direct=no])) +rm -f __o_direct_file]) +if test "$db_cv_open_o_direct" = yes; then + AC_DEFINE(HAVE_O_DIRECT) + AH_TEMPLATE(HAVE_O_DIRECT, [Define to 1 if you have the O_DIRECT flag.]) fi # You can't build C++ with big-file support on HP-UX, the include files -# are wrong. On Solaris 8, the <fcntl.h> included with big-file support -# is not compatible with C++. +# are wrong. largefile_ok=yes case "$host_os" in -solaris2.8|hpux*) +hpux*) if test "$db_cv_cxx" = "yes"; then AC_MSG_WARN([Large file and C++ API support are incompatible on HP-UX]) -AC_MSG_WARN([and Solaris 8; large file support has been turned off.]) +AC_MSG_WARN([large file support has been turned off.]) largefile_ok=no fi;; esac @@ -560,61 +553,65 @@ if test "$mmap_ok" = no -a "$shmget_ok" = no; then AC_MSG_WARN([Neither mmap/munmap(2) or shmget(2) library functions.]) fi +# If we're not doing version name substitution, DB_VERSION_UNIQUE_NAME +# needs to be erased. +if test "$db_cv_uniquename" = "no"; then + DB_VERSION_UNIQUE_NAME="" +fi + +# This is necessary so that .o files in LIBOBJS are also built via +# the ANSI2KNR-filtering rules. +LIB@&t@OBJS=`echo "$LIB@&t@OBJS" | + sed 's,\.[[^.]]* ,$U&,g;s,\.[[^.]]*$,$U&,'` +LTLIBOBJS=`echo "$LIB@&t@OBJS" | + sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'` +AC_SUBST(LTLIBOBJS) + # Initial output file list. CREATE_LIST="Makefile - include.tcl:$srcdir/../test/include.tcl - db_cxx.h:$srcdir/../include/db_cxx.in - db_int.h:$srcdir/../include/db_int.in" + db_cxx.h:$srcdir/../dbinc/db_cxx.in + db_int.h:$srcdir/../dbinc/db_int.in + include.tcl:$srcdir/../test/include.tcl" -# Create the db.h file -- append the global function prototypes to the -# file. If the user has requested unique names, use the file that does -# DB_VERSION_UNIQUE_NAME substitution. +# Create the db.h file from a source file, a list of global function +# prototypes, and, if configured for unique names, a list of #defines +# to do DB_VERSION_UNIQUE_NAME substitution. if test "$db_cv_uniquename" = "yes"; then - CREATE_LIST="$CREATE_LIST - db.h:$srcdir/../include/db.in:$srcdir/../include_auto/rpc_defs.in:$srcdir/../include_auto/global_uext.in" + CREATE_LIST="$CREATE_LIST + db.h:$srcdir/../dbinc/db.in:$srcdir/../dbinc_auto/rpc_defs.in:$srcdir/../dbinc_auto/ext_def.in:$srcdir/../dbinc_auto/ext_prot.in" else - CREATE_LIST="$CREATE_LIST - db.h:$srcdir/../include/db.in:$srcdir/../include_auto/rpc_defs.in:$srcdir/../include_auto/global_ext.in" + CREATE_LIST="$CREATE_LIST + db.h:$srcdir/../dbinc/db.in:$srcdir/../dbinc_auto/rpc_defs.in:$srcdir/../dbinc_auto/ext_prot.in" fi -# Create the function prototype include files. If the user has requested -# unique names, use the files that do DB_VERSION_UNIQUE_NAME substitution. +# If configured for unique names, create the db_int_uext.h file (which +# does the DB_VERSION_UNIQUE_NAME substitution), which is included by +# the db_int.h file. if test "$db_cv_uniquename" = "yes"; then - CREATE_LIST="$CREATE_LIST - db_ext.h:$srcdir/../include_auto/db_ext.in - btree_ext.h:$srcdir/../include_auto/btree_ext.in - clib_ext.h:$srcdir/../include_auto/clib_ext.in - common_ext.h:$srcdir/../include_auto/common_ext.in - db_server.h:$srcdir/../include_auto/db_server.in - env_ext.h:$srcdir/../include_auto/env_ext.in - hash_ext.h:$srcdir/../include_auto/hash_ext.in - lock_ext.h:$srcdir/../include_auto/lock_ext.in - log_ext.h:$srcdir/../include_auto/log_ext.in - mp_ext.h:$srcdir/../include_auto/mp_ext.in - mutex_ext.h:$srcdir/../include_auto/mutex_ext.in - os_ext.h:$srcdir/../include_auto/os_ext.in - qam_ext.h:$srcdir/../include_auto/qam_ext.in - rep_ext.h:$srcdir/../include_auto/rep_ext.in - rpc_client_ext.h:$srcdir/../include_auto/rpc_client_ext.in - rpc_server_ext.h:$srcdir/../include_auto/rpc_server_ext.in - tcl_ext.h:$srcdir/../include_auto/tcl_ext.in - txn_ext.h:$srcdir/../include_auto/txn_ext.in - xa_ext.h:$srcdir/../include_auto/xa_ext.in" + CREATE_LIST="$CREATE_LIST + db_int_def.h:$srcdir/../dbinc_auto/int_def.in" + db_int_def='#include "db_int_def.h"' fi + +# Create the db_185.h and db185_int.h files from source files, a list of +# global function prototypes, and, if configured for unique names, a list +# of #defines to do DB_VERSION_UNIQUE_NAME substitution. if test "$db_cv_compat185" = "yes"; then if test "$db_cv_uniquename" = "yes"; then CREATE_LIST="$CREATE_LIST -db_185.h:$srcdir/../include/db_185.in:$srcdir/../include_auto/db185_uext.in -db185_int.h:$srcdir/../db185/db185_int.in:$srcdir/../include_auto/db185_uext.in" + db_185.h:$srcdir/../dbinc/db_185.in:$srcdir/../dbinc_auto/ext_185_def.in:$srcdir/../dbinc_auto/ext_185_prot.in + db185_int.h:$srcdir/../db185/db185_int.in:$srcdir/../dbinc_auto/ext_185_def.in:$srcdir/../dbinc_auto/ext_185_prot.in" else CREATE_LIST="$CREATE_LIST -db_185.h:$srcdir/../include/db_185.in:$srcdir/../include_auto/db185_ext.in -db185_int.h:$srcdir/../db185/db185_int.in:$srcdir/../include_auto/db185_ext.in" + db_185.h:$srcdir/../dbinc/db_185.in:$srcdir/../dbinc_auto/ext_185_prot.in + db185_int.h:$srcdir/../db185/db185_int.in:$srcdir/../dbinc_auto/ext_185_prot.in" fi fi + if test "$db_cv_embedix" = "yes"; then CREATE_LIST="$CREATE_LIST db.ecd:../dist/db.ecd.in" fi + if test "$db_cv_rpm" = "yes"; then CREATE_LIST="$CREATE_LIST db.spec:../dist/db.spec.in" fi diff --git a/db/dist/pubdef.in b/db/dist/pubdef.in index fd0a9f589..55fdae244 100644 --- a/db/dist/pubdef.in +++ b/db/dist/pubdef.in @@ -6,46 +6,57 @@ DB_AFTER D I J DB_AGGRESSIVE D I J DB_ALREADY_ABORTED * I * +DB_AM_CHKSUM * I * +DB_AM_CL_WRITER * I * +DB_AM_COMPENSATE * I * +DB_AM_CREATED * I * +DB_AM_CREATED_MSTR * I * +DB_AM_DBM_ERROR * I * +DB_AM_DELIMITER * I * DB_AM_DIRTY * I * DB_AM_DISCARD * I * DB_AM_DUP * I * DB_AM_DUPSORT * I * +DB_AM_ENCRYPT * I * +DB_AM_FIXEDLEN * I * DB_AM_INMEM * I * +DB_AM_IN_RENAME * I * +DB_AM_OPEN_CALLED * I * +DB_AM_PAD * I * DB_AM_PGDEF * I * DB_AM_RDONLY * I * +DB_AM_RECNUM * I * DB_AM_RECOVER * I * +DB_AM_RENUMBER * I * +DB_AM_REVSPLITOFF * I * DB_AM_SECONDARY * I * +DB_AM_SNAPSHOT * I * DB_AM_SUBDB * I * DB_AM_SWAP * I * DB_AM_TXN * I * DB_AM_VERIFYING * I * DB_APPEND D I J -DB_APPLY_LOGREG * I * DB_ARCH_ABS D I J DB_ARCH_DATA D I J DB_ARCH_LOG D I J +DB_AUTO_COMMIT D I J DB_BEFORE D I J -DB_BTREE * I C +DB_BTREE D I C DB_BTREEMAGIC * I * DB_BTREEOLDVER * I * DB_BTREEVERSION * I * -DB_BT_RECNUM * I * -DB_BT_REVSPLIT * I * -DB_CACHED_COUNTS D I J +DB_CACHED_COUNTS * I J DB_CDB_ALLDB D I J -DB_CHECKPOINT D I J +DB_CHKSUM_SHA1 D I J DB_CLIENT D I J -DB_CL_WRITER * I * DB_COMMIT * I * DB_CONFIG D * * DB_CONSUME D I J DB_CONSUME_WAIT D I J DB_CREATE D I J -DB_CURLSN D I J DB_CURRENT D I J DB_CURRENT_PUT D * * DB_CXX_NO_EXCEPTIONS D I J -DB_DBM_ERROR * I * DB_DBM_HSEARCH * I * DB_DBT_APPMALLOC D I * DB_DBT_DUPOK * I * @@ -55,21 +66,31 @@ DB_DBT_PARTIAL D I J DB_DBT_REALLOC D I J DB_DBT_USERMEM D I J DB_DELETED * I * +DB_DIRECT D I J +DB_DIRECT_DB D I J +DB_DIRECT_LOG D I J DB_DIRTY_READ D I J DB_DONOTINDEX D I C DB_DUP D I J DB_DUPSORT D I J DB_EID_BROADCAST D I J DB_EID_INVALID D I J +DB_ENCRYPT D I J +DB_ENCRYPT_AES D I J +DB_ENV_AUTO_COMMIT * I * DB_ENV_CDB * I * DB_ENV_CDB_ALLDB * I * DB_ENV_CREATE * I * DB_ENV_DBLOCAL * I * +DB_ENV_DIRECT_DB * I * +DB_ENV_DIRECT_LOG * I * +DB_ENV_FATAL * I * DB_ENV_LOCKDOWN * I * DB_ENV_NOLOCKING * I * DB_ENV_NOMMAP * I * DB_ENV_NOPANIC * I * DB_ENV_OPEN_CALLED * I * +DB_ENV_OVERWRITE * I * DB_ENV_PRIVATE * I * DB_ENV_REGION_INIT * I * DB_ENV_REP_CLIENT * I * @@ -77,11 +98,10 @@ DB_ENV_REP_LOGSONLY * I * DB_ENV_REP_MASTER * I * DB_ENV_RPCCLIENT * I * DB_ENV_RPCCLIENT_GIVEN * I * -DB_ENV_STANDALONE * I * DB_ENV_SYSTEM_MEM * I * DB_ENV_THREAD * I * DB_ENV_TXN_NOSYNC * I * -DB_ENV_USER_ALLOC * I * +DB_ENV_TXN_WRITE_NOSYNC * I * DB_ENV_YIELDCPU * I * DB_EXCL D I J DB_EXTENT * I * @@ -95,12 +115,12 @@ DB_GET_BOTH D I J DB_GET_BOTHC * I * DB_GET_BOTH_RANGE D I J DB_GET_RECNO D I J -DB_HASH * I C +DB_HANDLE_LOCK * I * +DB_HASH D I C DB_HASHMAGIC * I * DB_HASHOLDVER * I * DB_HASHVERSION * I * DB_HOME D * * -DB_INCOMPLETE D I C DB_INIT_CDB D I J DB_INIT_LOCK D I J DB_INIT_LOG D I J @@ -126,14 +146,15 @@ DB_LOCK_FREE_LOCKER * I * DB_LOCK_GET D I J DB_LOCK_GET_TIMEOUT D I J DB_LOCK_INHERIT * I * -DB_LOCK_IREAD * I J -DB_LOCK_IWR * I J -DB_LOCK_IWRITE * I J +DB_LOCK_IREAD D I J +DB_LOCK_IWR D I J +DB_LOCK_IWRITE D I J DB_LOCK_MAXLOCKS D I J DB_LOCK_MINLOCKS D I J DB_LOCK_MINWRITE D I J DB_LOCK_NG * I * DB_LOCK_NORUN * I * +DB_LOCK_NOTEXIST * I * DB_LOCK_NOTGRANTED D I C DB_LOCK_NOWAIT D I J DB_LOCK_OLDEST D I J @@ -142,15 +163,17 @@ DB_LOCK_PUT_ALL D I J DB_LOCK_PUT_OBJ D I J DB_LOCK_PUT_READ * I * DB_LOCK_RANDOM D I J -DB_LOCK_READ * I J +DB_LOCK_READ D I J DB_LOCK_RECORD * I * +DB_LOCK_REMOVE * I * DB_LOCK_SET_TIMEOUT * I * DB_LOCK_SWITCH * I * DB_LOCK_TIMEOUT D I J +DB_LOCK_TRADE * I * DB_LOCK_UPGRADE * I * DB_LOCK_UPGRADE_WRITE * I * DB_LOCK_WAIT * I * -DB_LOCK_WRITE * I J +DB_LOCK_WRITE D I J DB_LOCK_WWRITE * I * DB_LOCK_YOUNGEST D I J DB_LOGC_BUF_SIZE * I * @@ -166,6 +189,7 @@ DB_LSTAT_ERR * I * DB_LSTAT_EXPIRED * I * DB_LSTAT_FREE * I * DB_LSTAT_HELD * I * +DB_LSTAT_NOTEXIST * I * DB_LSTAT_PENDING * I * DB_LSTAT_WAITING * I * DB_MAX_PAGES * I * @@ -186,6 +210,7 @@ DB_NEEDSPLIT * I * DB_NEXT D I J DB_NEXT_DUP D I J DB_NEXT_NODUP D I J +DB_NOCOPY * I * DB_NODUPDATA D I J DB_NOLOCKING D I J DB_NOMMAP D I J @@ -203,34 +228,42 @@ DB_OK_HASH * I * DB_OK_QUEUE * I * DB_OK_RECNO * I * DB_OLD_VERSION D I C -DB_OPEN_CALLED * I * DB_OPFLAGS_MASK * I * DB_ORDERCHKONLY D I J +DB_OVERWRITE D I J DB_PAGE_LOCK * I * DB_PAGE_NOTFOUND D I C DB_PANIC_ENVIRONMENT D I J +DB_PERMANENT * I * DB_POSITION D I J DB_POSITIONI * I * DB_PREV D I J DB_PREV_NODUP D I J +DB_PRINTABLE D I J +DB_PRIORITY_DEFAULT D I J +DB_PRIORITY_HIGH D I J +DB_PRIORITY_LOW D I J +DB_PRIORITY_VERY_HIGH D I J +DB_PRIORITY_VERY_LOW D I J DB_PRIVATE D I J DB_PR_PAGE * I * DB_PR_RECOVERYTEST * I * DB_QAMMAGIC * I * DB_QAMOLDVER * I * DB_QAMVERSION * I * -DB_QUEUE * I C +DB_QUEUE D I C DB_RDONLY D I J DB_RDWRMASTER * I * -DB_RECNO * I C +DB_RECNO D I C DB_RECNUM D I J -DB_RECORDCOUNT D I J +DB_RECORDCOUNT * I J DB_RECORD_LOCK * I * DB_RECOVER D I J DB_RECOVER_FATAL D I J DB_REDO * I * DB_REGION_INIT D I J DB_REGION_MAGIC * I * +DB_RENAMEMAGIC * I * DB_RENUMBER D I J DB_REP_CLIENT D I J DB_REP_DUPMASTER D I C @@ -243,11 +276,6 @@ DB_REP_OUTDATED D I C DB_REP_PERMANENT D I J DB_REP_UNAVAIL D I J DB_REVSPLITOFF D I J -DB_RE_DELIMITER * I * -DB_RE_FIXEDLEN * I * -DB_RE_PAD * I * -DB_RE_RENUMBER * I * -DB_RE_SNAPSHOT * I * DB_RMW D I J DB_RUNRECOVERY D I C DB_SALVAGE D I J @@ -263,6 +291,12 @@ DB_STAT_CLEAR D I J DB_SURPRISE_KID * I * DB_SWAPBYTES * I * DB_SYSTEM_MEM D I J +DB_TEST_ELECTINIT * I * +DB_TEST_ELECTSEND * I * +DB_TEST_ELECTVOTE1 * I * +DB_TEST_ELECTVOTE2 * I * +DB_TEST_ELECTWAIT1 * I * +DB_TEST_ELECTWAIT2 * I * DB_TEST_POSTDESTROY * I * DB_TEST_POSTLOG * I * DB_TEST_POSTLOGMETA * I * @@ -270,22 +304,28 @@ DB_TEST_POSTOPEN * I * DB_TEST_POSTSYNC * I * DB_TEST_PREDESTROY * I * DB_TEST_PREOPEN * I * +DB_TEST_SUBDB_LOCKS * I * DB_THREAD D I J DB_TIMEOUT * I * DB_TRUNCATE D I J DB_TXNVERSION * I * DB_TXN_ABORT D I C DB_TXN_APPLY D I C +DB_TXN_BACKWARD_ALLOC * I * DB_TXN_BACKWARD_ROLL D I C DB_TXN_CKP * I * DB_TXN_FORWARD_ROLL D I C +DB_TXN_GETPGNOS * I * +DB_TXN_LOCK * I * DB_TXN_NOSYNC D I J DB_TXN_NOWAIT D I J DB_TXN_OPENFILES * I * DB_TXN_POPENFILES * I * +DB_TXN_PRINT D I C DB_TXN_SYNC D I J +DB_TXN_WRITE_NOSYNC D I J DB_UNDO * I * -DB_UNKNOWN * I C +DB_UNKNOWN D I C DB_UPDATE_SECONDARY * I * DB_UPGRADE D I J DB_USE_ENVIRON D I J @@ -304,6 +344,8 @@ DB_VERSION_PATCH * I J DB_VERSION_STRING * I * DB_WRITECURSOR D I J DB_WRITELOCK * I * +DB_WRITEOPEN * I * +DB_WRNOSYNC * I * DB_XA_CREATE D I J DB_XIDDATASIZE D I J DB_YIELDCPU D I J diff --git a/db/dist/s_test b/db/dist/s_test index 978d0e466..8a0ae9edf 100755 --- a/db/dist/s_test +++ b/db/dist/s_test @@ -1,71 +1,77 @@ #!/bin/sh - -# Id: s_test,v 1.21 2001/09/24 20:46:59 sandstro Exp +# Id: s_test,v 1.24 2002/08/09 02:24:58 bostic Exp # # Build the Tcl test files. -msgshb="# DO NOT EDIT BELOW THIS LINE: automatically built by dist/s_test." +msg1="# Automatically built by dist/s_test; may require local editing." +msg2="# Automatically built by dist/s_test; may require local editing." t=/tmp/__t trap 'rm -f $t; exit 0' 0 1 2 3 13 15 . RELEASE -(echo "set tclsh_path @TCL_TCLSH@" && \ - echo "set tcllib .libs/libdb_tcl-@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@SOSUFFIX@" && \ +(echo "$msg1" && \ + echo "" && \ + echo "set tclsh_path @TCL_TCLSH@" && \ + echo "set tcllib .libs/libdb_tcl-@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@MODSUFFIX@" && \ + echo "" && \ echo "set rpc_server localhost" && \ echo "set rpc_path ." && \ + echo "set rpc_testdir \$rpc_path/TESTDIR" && \ + echo "" && \ echo "set src_root @srcdir@/.." && \ echo "set test_path @srcdir@/../test" && \ + echo "" && \ echo "global testdir" && \ echo "set testdir ./TESTDIR" && \ echo "" && \ - echo "set KILL \"@db_cv_path_kill@\"" && \ - echo "" && \ - echo "$msgshb" && \ - echo "" && \ echo "global dict" && \ echo "global util_path" && \ - echo "set rpc_testdir \$rpc_path/TESTDIR" && \ echo "" && \ echo "global is_hp_test" && \ echo "global is_qnx_test" && \ - echo "global is_windows_test") > $t + echo "global is_windows_test" && \ + echo "" && \ + echo "set KILL \"@db_cv_path_kill@\"") > $t f=../test/include.tcl cmp $t $f > /dev/null 2>&1 || (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f) -(echo "set tclsh_path SET_YOUR_TCLSH_PATH" && \ - echo "set test_path ../test" && \ - echo "set src_root .." && \ - echo "global testdir" && \ - echo "set testdir ./TESTDIR" && \ +(echo "$msg1" && \ + echo "" && \ + echo "set tclsh_path SET_YOUR_TCLSH_PATH" && \ echo "set tcllib ./Debug/libdb_tcl${DB_VERSION_MAJOR}${DB_VERSION_MINOR}d.dll" && \ echo "" && \ - echo "set KILL ./dbkill.exe" && \ + echo "set src_root .." && \ + echo "set test_path ../test" && \ echo "" && \ - echo "$msgshb" && \ + echo "global testdir" && \ + echo "set testdir ./TESTDIR" && \ echo "" && \ echo "global dict" && \ echo "global util_path" && \ echo "" && \ echo "global is_hp_test" && \ echo "global is_qnx_test" && \ - echo "global is_windows_test") > $t + echo "global is_windows_test" && \ + echo "" && \ + echo "set KILL ./dbkill.exe") > $t f=../build_win32/include.tcl cmp $t $f > /dev/null 2>&1 || (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f) # Build the test directory TESTS file. -(echo $msgshb; +(echo $msg2; cat `egrep -l '^#[ ][ ]*TEST' ../test/*.tcl` | sed -e '/^#[ ][ ]*TEST/!{' \ -e 's/.*//' \ -e '}' | cat -s | sed -e '/TEST/{' \ - -e 's/^#[ ][ ]*TEST//' \ + -e 's/^#[ ][ ]*TEST[ ]*//' \ -e 's/^ //' \ -e 'H' \ -e 'd' \ @@ -78,7 +84,8 @@ sed -e 's/__LINEBREAK__/\ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\ /' \ -e 's/__LINEBREAK__/\ - /g') > $t + /g' | +sed -e 's/^[ ][ ]*$//') > $t f=../test/TESTS cmp $t $f > /dev/null 2>&1 || diff --git a/db/dist/win_exports.in b/db/dist/win_exports.in index 25e00cbc3..e20fbd168 100644 --- a/db/dist/win_exports.in +++ b/db/dist/win_exports.in @@ -1,4 +1,4 @@ -# Id: win_exports.in,v 1.10 2001/11/05 18:24:58 bostic Exp +# Id: win_exports.in,v 1.24 2002/07/15 06:07:55 mjc Exp # Standard interfaces. db_create @@ -31,12 +31,13 @@ db_env_set_func_unmap db_env_set_func_write db_env_set_func_yield + db_env_set_thread_func + db_env_xa_attach # Needed for application-specific logging and recovery routines. __db_add_recovery - __txn_activekids -# These are only for testing. +# These are needed to link the tcl library. __db_dbm_close __db_dbm_delete __db_dbm_fetch @@ -63,9 +64,9 @@ __db_panic __db_r_attach __db_r_detach - __db_tas_mutex_init - __db_tas_mutex_lock - __db_tas_mutex_unlock + __db_win32_mutex_init + __db_win32_mutex_lock + __db_win32_mutex_unlock __ham_func2 __ham_func3 __ham_func4 @@ -76,12 +77,12 @@ __os_calloc __os_closehandle __os_free - __os_freestr __os_ioinfo __os_malloc __os_open __os_openhandle __os_read + __os_realloc __os_strdup __os_umalloc __os_write @@ -100,27 +101,32 @@ __db_global_values __db_init_print __db_inmemdbflags - __db_jump + __db_isbigendian __db_omode + __db_overwrite __db_pgin __db_pgout __db_prdbt __db_prfooter __db_prheader __db_rpath + __db_util_cache __db_util_interrupted __db_util_logset __db_util_siginit __db_util_sigresend __db_verify_callback __db_verify_internal + __dbreg_init_print + __fop_init_print __ham_get_meta __ham_init_print __ham_pgin __ham_pgout __ham_release_meta - __log_init_print + __os_clock __os_get_errno + __os_id __os_set_errno __os_sleep __os_ufree @@ -128,3 +134,13 @@ __qam_init_print __qam_pgin_out __txn_init_print + __db_xa_close + __db_xa_commit + __db_xa_end + __db_xa_forget + __db_xa_open + __db_xa_prepare + __db_xa_recover + __db_xa_rollback + __db_xa_start + __db_rmid_to_env |