Update of /project/elephant/cvsroot/elephant/src/db-bdb In directory common-lisp:/tmp/cvs-serv25268/src/db-bdb
Modified Files: sleepycat.lisp Added Files: libsleepycat.def Log Message: New build process completed & tested for BDB
--- /project/elephant/cvsroot/elephant/src/db-bdb/sleepycat.lisp 2006/02/19 04:53:00 1.1 +++ /project/elephant/cvsroot/elephant/src/db-bdb/sleepycat.lisp 2006/02/19 17:25:53 1.2 @@ -45,8 +45,69 @@ %db-sequence-get-lower db-sequence-get-fixnum ))
+;; +;; EXTERNAL LIBRARY DEPENDENCIES - LOAD DURING LOAD/COMPILATION +;; + +(eval-when (:compile-toplevel :load-toplevel) + + ;; + ;; Under Linux we need pthreads! + ;; + + #+linux + (unless + (uffi:load-foreign-library "/lib/tls/libpthread.so.0" :module "pthread") + (error "Couldn't load libpthread!")) + + ;; + ;; Our interface library requires that the main Berkeley DB library be loaded + ;; + + (unless + (uffi:load-foreign-library + ele-bdb-system::*sleepycat-foreign-library-path* + :module "sleepycat") + (error "Couldn't load libdb (Sleepycat)!")) + + ;; + ;; Our local interface library + ;; + + (unless + (uffi:load-foreign-library + (merge-pathnames + (make-pathname :name "libsleepycat" :type *c-library-extension*) + (merge-pathnames (make-pathname :directory "src/db-bdb") + (asdf:component-pathname (asdf:find-system 'elephant)))) + :module "libsleepycat") + (error "Couldn't load src/db-bdb/libsleepycat.~A!" elephant-memutil::*c-library-extension*)) + + ;; Error handling + ;; I put this here so we could validate that the library was loaded + + (def-function ("db_strerr" %db-strerror) + ((error :int)) + :returning :cstring) + + (defun db-strerror (errno) + "Get the string error associated with an error number." + (convert-from-cstring (%db-strerror errno))) + + (define-condition db-error (error) + ((errno :type fixnum :initarg :errno :reader db-error-errno)) + (:report + (lambda (condition stream) + (declare (type db-error condition) (type stream stream)) + (format stream "Berkeley DB error: ~A" + (db-strerror (db-error-errno condition))))) + (:documentation "Berkeley DB / Sleepycat errors.")) + ) + +;; ;; Constants and Flags ;; eventually write a macro which generates a custom flag function. +;;
;I don't like the UFFI syntax for enumerations (defconstant DB-BTREE 1) @@ -327,45 +388,6 @@ ,@(when set-transaction-timeout `((when ,set-transaction-timeout (setq ,flags (logior ,flags DB_SET_TXN_TIMEOUT))))) ,flags)))
- -(eval-when (:compile-toplevel :load-toplevel) - (def-enum DBTYPE ((:BTREE 1) :HASH :QUEUE :RECNO :UNKNOWN)) - - #+linux - (unless - (uffi:load-foreign-library "/lib/tls/libpthread.so.0" :module "pthread") - (error "Couldn't load libpthread!")) - - (unless - (uffi:load-foreign-library - ;; Sleepycat: this works on linux - #+linux -;; "/db/ben/lisp/db43/lib/libdb.so" - "/usr/local/BerkeleyDB.4.3/lib/libdb-4.3.so" - ;; this works on FreeBSD - #+(and (or bsd freebsd) (not darwin) (not macosx)) - "/usr/local/lib/db43/libdb.so" - #+(or darwin macosx) - ;; for Fink (OS X) -- but I will assume Linux more common... -;; "/sw/lib/libdb-4.3.dylib" - ;; a possible manual install - "/usr/local/BerkeleyDB.4.3/lib/libdb.dylib" - :module "sleepycat") - (error "Couldn't load libdb (Sleepycat)!")) - - ;; Libsleepycat.so: edit this - (unless - (uffi:load-foreign-library - (if (find-package 'asdf) - (merge-pathnames - (make-pathname :name "libsleepycat" :type elephant-memutil::*c-library-extension*) - (asdf:component-pathname (asdf:find-system 'elephant))) - (format nil "/usr/local/share/common-lisp/elephant-0.3/libsleepycat.~A" elephant-memutil::*c-library-extension*)) - :module "libsleepycat") - (error "Couldn't load libsleepycat.~A!" elephant-memutil::*c-library-extension*)) - ) - - ;; Environment
(def-function ("db_env_cr" %db-env-create) @@ -470,6 +492,9 @@
;; Database
+(eval-when (:compile-toplevel :load-toplevel) + (def-enum DBTYPE ((:BTREE 1) :HASH :QUEUE :RECNO :UNKNOWN))) + (def-function ("db_cr" %db-create) ((dbenv :pointer-void) (flags :unsigned-int) @@ -1845,24 +1870,3 @@ (if (< ret 0) (error 'db-error :errno ret) ret))) - -;; Misc - -;; Errors - -(def-function ("db_strerr" %db-strerror) - ((error :int)) - :returning :cstring) - -(defun db-strerror (errno) - "Get the string error associated with an error number." - (convert-from-cstring (%db-strerror errno))) - -(define-condition db-error (error) - ((errno :type fixnum :initarg :errno :reader db-error-errno)) - (:report - (lambda (condition stream) - (declare (type db-error condition) (type stream stream)) - (format stream "Berkeley DB error: ~A" - (db-strerror (db-error-errno condition))))) - (:documentation "Berkeley DB / Sleepycat errors."))
--- /project/elephant/cvsroot/elephant/src/db-bdb/libsleepycat.def 2006/02/19 17:25:53 NONE +++ /project/elephant/cvsroot/elephant/src/db-bdb/libsleepycat.def 2006/02/19 17:25:53 1.1 LIBRARY Elephant EXPORTS read_int read_uint read_float read_double write_int write_uint write_float write_double offset_charp copy_buf db_env_cr db_strerr db_env_close db_env_open db_env_dbremove db_env_dbrename db_env_remove db_env_set_flags db_env_get_flags db_cr db_close db_open db_remove db_rename db_sync db_truncate db_set_flags db_get_flags db_set_pagesize db_get_pagesize db_set_bt_compare db_set_dup_compare read_num lisp_compare db_set_lisp_compare db_set_lisp_dup_compare case_cmp lex_cmp utf16_cmp db_get_raw db_put_raw db_del db_cursor db_cursor_close db_cursor_del db_cursor_dup db_cursor_get_raw db_cursor_pget_raw db_cursor_put_raw db_del_kv db_cursor_get_multiple_key db_multiple_key_next db_txn_begin db_txn_abort db_txn_commit db_txnp_begin db_txn_id db_env_lock_id db_env_lock_id_free db_env_lock_get db_env_lock_put db_env_lock_vec db_env_set_timeout db_env_get_timeout db_env_set_lk_detect db_env_get_lk_detect db_env_lock_detect db_associate never_index db_fake_associate next_counter