r1708: *** empty log message ***
[uffi.git] / tests / c-test-fns.cl
index 3bb4f6157c3534c7e88faf707b6657ab5e90ce34..a45dda9f23be766e78e84feb9616ec8a28fd700c 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Mar 2002
 ;;;;
-;;;; $Id: c-test-fns.cl,v 1.1 2002/03/21 04:04:45 kevin Exp $
+;;;; $Id: c-test-fns.cl,v 1.3 2002/03/31 23:05:07 kevin Exp $
 ;;;;
 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
@@ -20,7 +20,9 @@
 
 (unless (uffi:load-foreign-library 
         (make-pathname :name "c-test-fns" 
-                       :type #+(or linux unix)"so" #+(or win32 mswindows) "dll"
+                       :type #+(or linux unix)"so"
+                       #+(or win32 mswindows) "dll"
+                       #+freebsd "a"
                        :defaults *load-truename*)
         :supporting-libraries '("c")
         :force-load t)
   (uffi:with-cstring (str-cstring str)
     (cs-count-upper str-cstring)))
 
+(uffi:def-function ("half_double_vector" half-double-vector)
+    ((size :int)
+     (vec (* :double)))
+  :returning :void)
+
+(uffi:def-constant +double-vec-length+ 10)
+(defun test-half-double-vector ()
+  (let ((vec (uffi:allocate-foreign-object :double +double-vec-length+))
+       results)
+    (dotimes (i +double-vec-length+)
+      (setf (uffi:deref-array vec '(:array :double) i) 
+           (coerce i 'double-float)))
+    (half-double-vector +double-vec-length+ vec)
+    (dotimes (i +double-vec-length+)
+      (push (uffi:deref-array vec '(:array :double) i) results))
+    (uffi:free-foreign-object vec)
+    (nreverse results)))
+
+(defun t2 ()
+  (let ((vec (make-array +double-vec-length+ :element-type 'double-float)))
+    (dotimes (i +double-vec-length+)
+      (setf (aref vec i) (coerce i 'double-float)))
+    (half-double-vector +double-vec-length+ vec)
+    vec))
+
+#+cmu
+(defun t3 ()
+  (let ((vec (make-array +double-vec-length+ :element-type 'double-float)))
+    (dotimes (i +double-vec-length+)
+      (setf (aref vec i) (coerce i 'double-float)))
+    (system:without-gcing
+     (half-double-vector +double-vec-length+ (system:vector-sap vec)))
+    vec))
+    
 #+test-uffi
 (format t "~&(string-to-upper \"this is a test\") => ~A" 
        (string-to-upper "this is a test"))
@@ -61,6 +97,6 @@
 (format t "~&(string-count-upper nil) => ~A" 
        (string-count-upper nil))
 
-
-
+#+test-uffi
+(format t "~&Half vector: ~S" (test-half-double-vector))