r1604: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Thu, 21 Mar 2002 09:54:34 +0000 (09:54 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Thu, 21 Mar 2002 09:54:34 +0000 (09:54 +0000)
ChangeLog
doc/ref.sgml
examples/c-test-fns.c
examples/c-test-fns.cl
tests/c-test-fns.c
tests/c-test-fns.cl

index e69da6a5157c190a8674d9ffb4a2dfa673a8107b..ec600198970d373a6cbd940a502356cfd4368f68 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,7 @@ See TODO file -- actively maintained. Includes changes that you
        * Added 2-d array example to examples/arrays.cl 
        * Fixed documentation error on gethostname
        * Added ensure-char-* and def-union to documentation
+       * Added double-float vector example to c-test-fns
        
 20 Mar 2002
        * Updated strings.cl so that foreign-strings are always unsigned.
index 714d8e99ca665e0f9a6500129b380dad5412ae0d..58ac773cac341a8ec6f7a275f640b487a902f1f6 100644 (file)
@@ -1101,7 +1101,7 @@ array of <parameter>type</parameter> that is <parameter>size</parameter> members
     <refentry id="ensure-char-character">
       <refnamediv>
        <refname>ensure-char-character</refname>
-       <refpurpose>Ensures that a dereferenced :char pointer is
+       <refpurpose>Ensures that a dereferenced <constant>:char</constant> pointer is
 a character.
        </refpurpose>
        <refclass>Macro</refclass>
@@ -1169,7 +1169,7 @@ integer.</para>
     <refentry id="ensure-char-integer">
       <refnamediv>
        <refname>ensure-char-integer</refname>
-       <refpurpose>Ensures that a dereferenced :char pointer is
+       <refpurpose>Ensures that a dereferenced <constant>:char</constant> pointer is
 an integer.
        </refpurpose>
        <refclass>Macro</refclass>
index 7358114f02d1f01d94ad4646e602fd362ef2a230..cab2dd67bad15a6b46fdaac8d7c62233c10ebdf5 100644 (file)
@@ -6,7 +6,7 @@
  *  Programer:    Kevin M. Rosenberg
  *  Date Started: Mar 2002
  *
- *  CVS Id:   $Id: c-test-fns.c,v 1.3 2002/03/21 05:29:57 kevin Exp $
+ *  CVS Id:   $Id: c-test-fns.c,v 1.4 2002/03/21 09:54:34 kevin Exp $
  *
  * This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
  *
@@ -36,6 +36,8 @@ BOOL WINAPI DllEntryPoint(HINSTANCE hinstdll,
 
 #include <ctype.h>
 #include <stdlib.h>
+#include <math.h>
+
 
 /* Test of constant input string */
 DLLEXPORT
@@ -79,5 +81,16 @@ cs_make_random (int size, char* buffer)
 }
 
     
+/* Test of input/output vector */
+DLLEXPORT
+void
+half_double_vector (int size, double* vec)
+{
+  int i;
+  for (i = 0; i < size; i++)
+    vec[i] /= 2.;
+}
+
+    
 
     
index 3bb4f6157c3534c7e88faf707b6657ab5e90ce34..45f144dfb3fec093773ba1c274a762f28c851ead 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.2 2002/03/21 09:54:34 kevin Exp $
 ;;;;
 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
   (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 +95,6 @@
 (format t "~&(string-count-upper nil) => ~A" 
        (string-count-upper nil))
 
-
-
+#+test-uffi
+(format t "~&Half vector: ~S" (test-half-double-vector))
 
index 7358114f02d1f01d94ad4646e602fd362ef2a230..cab2dd67bad15a6b46fdaac8d7c62233c10ebdf5 100644 (file)
@@ -6,7 +6,7 @@
  *  Programer:    Kevin M. Rosenberg
  *  Date Started: Mar 2002
  *
- *  CVS Id:   $Id: c-test-fns.c,v 1.3 2002/03/21 05:29:57 kevin Exp $
+ *  CVS Id:   $Id: c-test-fns.c,v 1.4 2002/03/21 09:54:34 kevin Exp $
  *
  * This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
  *
@@ -36,6 +36,8 @@ BOOL WINAPI DllEntryPoint(HINSTANCE hinstdll,
 
 #include <ctype.h>
 #include <stdlib.h>
+#include <math.h>
+
 
 /* Test of constant input string */
 DLLEXPORT
@@ -79,5 +81,16 @@ cs_make_random (int size, char* buffer)
 }
 
     
+/* Test of input/output vector */
+DLLEXPORT
+void
+half_double_vector (int size, double* vec)
+{
+  int i;
+  for (i = 0; i < size; i++)
+    vec[i] /= 2.;
+}
+
+    
 
     
index 3bb4f6157c3534c7e88faf707b6657ab5e90ce34..45f144dfb3fec093773ba1c274a762f28c851ead 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.2 2002/03/21 09:54:34 kevin Exp $
 ;;;;
 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
   (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 +95,6 @@
 (format t "~&(string-count-upper nil) => ~A" 
        (string-count-upper nil))
 
-
-
+#+test-uffi
+(format t "~&Half vector: ~S" (test-half-double-vector))