Update of /project/elephant/cvsroot/elephant/src In directory common-lisp.net:/tmp/cvs-serv32447/src
Modified Files: sleepycat.lisp Log Message: linux / sbcl, reorg
Date: Sun Aug 29 09:55:29 2004 Author: blee
Index: elephant/src/sleepycat.lisp diff -u elephant/src/sleepycat.lisp:1.4 elephant/src/sleepycat.lisp:1.5 --- elephant/src/sleepycat.lisp:1.4 Sat Aug 28 08:41:49 2004 +++ elephant/src/sleepycat.lisp Sun Aug 29 09:55:29 2004 @@ -67,6 +67,49 @@
(in-package "SLEEPYCAT")
+(eval-when (:compile-toplevel :load-toplevel) + ;; UFFI + ;;(asdf:operate 'asdf:load-op :uffi) + + ;; DSO loading + + ;; Under linux you need to load some kind of pthread + ;; library. I can't figure out which is the right one. + ;; This one worked for me. There are known issues with + ;; Red Hat and Berkeley DB, search google. + #+linux + (uffi:load-foreign-library "/lib/tls/libpthread.so.0" :module "pthread") + + (uffi:load-foreign-library "/usr/local/lib/db42/libdb.so" + :module "sleepycat") + (uffi:load-foreign-library + "/home/ben/lisp/elephant/libsleepycat.so" +;; "/usr/local/share/common-lisp/elephant/libsleepycat.so" + :module "libsleepycat") + + (def-type pointer-int (* :int)) + (def-type pointer-void :pointer-void) + (def-foreign-type array-or-pointer-char + #+allegro (:array :char) + #+(or cmu sbcl scl) (* :char)) + (def-type array-or-pointer-char array-or-pointer-char) + (def-enum DBTYPE ((:BTREE 1) :HASH :QUEUE :RECNO :UNKNOWN)) +) + +(declaim (inline read-int read-uint read-float read-double + write-int write-uint write-float write-double + offset-char-pointer copy-str-to-buf copy-bufs + %db-get-key-buffered db-get-key-buffered + %db-get-buffered db-get-buffered db-get + %db-put-buffered db-put-buffered + %db-put db-put + %db-delete db-delete-buffered db-delete + %db-txn-begin db-transaction-begin + %db-txn-abort db-transaction-abort + %db-txn-commit db-transaction-commit + %db-transaction-id + flags)) + ;; Constants and Flags ;; eventually write a macro which generates a custom flag function.
@@ -112,41 +155,9 @@ (defconstant DB_LOCK_NOTGRANTED -30994) (defconstant DB_NOTFOUND -30990)
+(defconstant +NULL-VOID+ (make-null-pointer :void)) +(defconstant +NULL-CHAR+ (make-null-pointer :char))
-(eval-when (:compile-toplevel :load-toplevel) - ;; UFFI - ;;(asdf:operate 'asdf:load-op :uffi) - - ;; DSO loading - (defconstant +path-to-libsleepycat+ - "/home/ben/lisp/elephant/libsleepycat.so") - (defconstant +path-to-sleepycat+ - "/usr/local/lib/db42/libdb.so") - (uffi:load-foreign-library +path-to-sleepycat+ :module "sleepycat") - (uffi:load-foreign-library +path-to-libsleepycat+ :module "libsleepycat") - - (def-type pointer-int (* :int)) - (def-type pointer-void :pointer-void) - (def-foreign-type array-or-pointer-char - #+allegro (:array :char) - #+(or cmu sbcl scl) (* :char)) - (def-type array-or-pointer-char array-or-pointer-char) - (def-enum DBTYPE ((:BTREE 1) :HASH :QUEUE :RECNO :UNKNOWN)) -) - -(declaim (inline read-int read-uint read-float read-double - write-int write-uint write-float write-double - offset-char-pointer copy-str-to-buf copy-bufs - %db-get-key-buffered db-get-key-buffered - %db-get-buffered db-get-buffered db-get - %db-put-buffered db-put-buffered - %db-put db-put - %db-delete db-delete-buffered db-delete - %db-txn-begin db-transaction-begin - %db-txn-abort db-transaction-abort - %db-txn-commit db-transaction-commit - %db-transaction-id - flags))
;; Buffer management / pointer arithmetic
@@ -280,16 +291,13 @@
;; Thread local storage (special variables)
-(defconstant +NULL-VOID+ (make-null-pointer :void)) -(defconstant +NULL-CHAR+ (make-null-pointer :char)) +(declaim (type array-or-pointer-char *get-buffer*) + (type fixnum *get-buffer-length*))
(defvar *current-transaction* +NULL-VOID+)
(defvar *errno-buffer* (allocate-foreign-object :int 1))
-(declaim (type array-or-pointer-char *get-buffer*) - (type fixnum *get-buffer-length*)) - (defvar *get-buffer* (allocate-foreign-object :char 1)) (defvar *get-buffer-length* 0)
@@ -1035,7 +1043,7 @@ (let ((ret (%next-counter env db key key-length lockid lockid-length))) (if (< ret 0) (error 'db-error :errno ret) - ret)))) + ret)))
;; Misc