uffi/examples Makefile,1.17,1.18 arrays.lisp,1.1,1.2 compress.lisp,1.1,1.2 union.lisp,1.1,1.2
"Kevin M. Rosenberg" <[email protected]> Mon, 2 Dec 2002 23:58:41 -0700
| Newsgroups | gmane.lisp.uffi.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /pubcvs/uffi/examples
In directory boa.b9.com:/tmp/cvs-serv24260/examples
Modified Files:
Makefile arrays.lisp compress.lisp union.lisp
Log Message:
Index: Makefile
===================================================================
RCS file: /pubcvs/uffi/examples/Makefile,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** Makefile 29 Nov 2002 11:10:08 -0000 1.17
--- Makefile 3 Dec 2002 06:58:39 -0000 1.18
***************
*** 38,45 ****
cc -dynamic -c $(source) -o $(object)
ld -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress -o $(base).dylib $(object)
!
! mac-bundle:
! cc -dynamic -c $(source) -o $(object)
! ld -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress -o $(base).bundle $(object)
solaris:
--- 38,42 ----
cc -dynamic -c $(source) -o $(object)
ld -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress -o $(base).dylib $(object)
! ld -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress /usr/lib/libz.dylib -o z.dylib
solaris:
Index: arrays.lisp
===================================================================
RCS file: /pubcvs/uffi/examples/arrays.lisp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** arrays.lisp 30 Sep 2002 10:02:36 -0000 1.1
--- arrays.lisp 3 Dec 2002 06:58:39 -0000 1.2
***************
*** 22,25 ****
--- 22,27 ----
(uffi:def-constant +row-length+ 10)
+ (uffi:def-foreign-type long-ptr '(* :long))
+
(defun test-array-1d ()
"Tests vector"
***************
*** 34,38 ****
(defun test-array-2d ()
"Tests 2d array"
! (let ((a (uffi:allocate-foreign-object '(* :long) +row-length+)))
(dotimes (r +row-length+)
(declare (fixnum r))
--- 36,40 ----
(defun test-array-2d ()
"Tests 2d array"
! (let ((a (uffi:allocate-foreign-object 'long-ptr +row-length+)))
(dotimes (r +row-length+)
(declare (fixnum r))
Index: compress.lisp
===================================================================
RCS file: /pubcvs/uffi/examples/compress.lisp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** compress.lisp 30 Sep 2002 10:02:36 -0000 1.1
--- compress.lisp 3 Dec 2002 06:58:39 -0000 1.2
***************
*** 19,31 ****
(in-package :cl-user)
! (unless (uffi:load-foreign-library
! (uffi:find-foreign-library
! "libz"
! '("/usr/local/lib/" "/usr/lib/" "/zlib/")
! :types '("so" "a" "dylib"))
! :module "zlib"
! :supporting-libraries '("c"))
! (warn "Unable to load zlib"))
!
(uffi:def-function ("compress" c-compress)
((dest (* :unsigned-char))
--- 19,36 ----
(in-package :cl-user)
! (eval-when (:load-toplevel :execute)
! (unless (uffi:load-foreign-library
! #-(or macosx darwin)
! (uffi:find-foreign-library
! "libz"
! '("/usr/local/lib/" "/usr/lib/" "/zlib/")
! :types '("so" "a"))
! #+(or macosx darwin)
! (uffi:find-foreign-library "z"
! `(,(pathname-directory *load-pathname*)))
! :module "zlib"
! :supporting-libraries '("c"))
! (warn "Unable to load zlib")))
!
(uffi:def-function ("compress" c-compress)
((dest (* :unsigned-char))
Index: union.lisp
===================================================================
RCS file: /pubcvs/uffi/examples/union.lisp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** union.lisp 30 Sep 2002 10:02:36 -0000 1.1
--- union.lisp 3 Dec 2002 06:58:39 -0000 1.2
***************
*** 30,49 ****
(setf (uffi:get-slot-value u 'tunion1 'uint)
;; little endian
! #-(or sparc sparc-v9 powerpc ppc)
(+ (* 1 (char-code #\A))
(* 256 (char-code #\B))
(* 65536 (char-code #\C))
! (* 16777216 128))
;; big endian
! #+(or sparc sparc-v9 powerpc ppc)
(+ (* 16777216 (char-code #\A))
(* 65536 (char-code #\B))
(* 256 (char-code #\C))
! (* 1 128)))
(format *standard-output* "~&Should be #\A: ~S"
(uffi:ensure-char-character
(uffi:get-slot-value u 'tunion1 'char)))
! (format *standard-output* "~&Should be negative number: ~D"
! (uffi:get-slot-value u 'tunion1 'int))
(format *standard-output* "~&Should be positive number: ~D"
(uffi:get-slot-value u 'tunion1 'uint))
--- 30,49 ----
(setf (uffi:get-slot-value u 'tunion1 'uint)
;; little endian
! #-(or sparc sparc-v9 powerpc ppc little-endian)
(+ (* 1 (char-code #\A))
(* 256 (char-code #\B))
(* 65536 (char-code #\C))
! (* 16777216 255))
;; big endian
! #+(or sparc sparc-v9 powerpc ppc big-endian)
(+ (* 16777216 (char-code #\A))
(* 65536 (char-code #\B))
(* 256 (char-code #\C))
! (* 1 255)))
(format *standard-output* "~&Should be #\A: ~S"
(uffi:ensure-char-character
(uffi:get-slot-value u 'tunion1 'char)))
! ;; (format *standard-output* "~&Should be negative number: ~D"
! ;; (uffi:get-slot-value u 'tunion1 'int))
(format *standard-output* "~&Should be positive number: ~D"
(uffi:get-slot-value u 'tunion1 'uint))
***************
*** 71,78 ****
:fail-info "Error with union character")
#-(or sparc sparc-v9 mcl)
! (util.test:test (> 0 (uffi:get-slot-value u 'tunion1 'int))
! t
! :fail-info
! "Error with negative int in union")
(util.test:test (plusp (uffi:get-slot-value u 'tunion1 'uint))
t
--- 71,78 ----
:fail-info "Error with union character")
#-(or sparc sparc-v9 mcl)
! ;; (util.test:test (> 0 (uffi:get-slot-value u 'tunion1 'int))
! ;; t
! ;; :fail-info
! ;; "Error with negative int in union")
(util.test:test (plusp (uffi:get-slot-value u 'tunion1 'uint))
t