* 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.
<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>
<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>
* 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
*
#include <ctype.h>
#include <stdlib.h>
+#include <math.h>
+
/* Test of constant input string */
DLLEXPORT
}
+/* 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.;
+}
+
+
;;;; 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"))
(format t "~&(string-count-upper nil) => ~A"
(string-count-upper nil))
-
-
+#+test-uffi
+(format t "~&Half vector: ~S" (test-half-double-vector))
* 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
*
#include <ctype.h>
#include <stdlib.h>
+#include <math.h>
+
/* Test of constant input string */
DLLEXPORT
}
+/* 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.;
+}
+
+
;;;; 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"))
(format t "~&(string-count-upper nil) => ~A"
(string-count-upper nil))
-
-
+#+test-uffi
+(format t "~&Half vector: ~S" (test-half-double-vector))