* Added double-float vector example to c-test-fns
* Reworked cstring on Lispworks to have LW handle string conversion
* First pass at with-foreign-object -- unoptimized
- * Added gethostname2 to examples/gethostname.cl which uses with-foreign-object
- * Added char-array-to-pointer function to encapsulate converting a char array
- to a pointer to char
+ * Added gethostname2 example which uses with-foreign-object
+ * Added char-array-to-pointer function to encapsulate
+ converting a char array to a char pointer
* Converted with-foreign-object to use stack allocation on CMUCL and LW
+ * Added benchmark code, first file is for allocation
20 Mar 2002
* Updated strings.cl so that foreign-strings are always unsigned.
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: gethostname.cl,v 1.7 2002/03/21 15:57:01 kevin Exp $
+;;;; $Id: gethostname.cl,v 1.8 2002/03/22 20:51:08 kevin Exp $
;;;;
;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(error "gethostname() failed."))))
#+test-uffi
-(format t "~&Hostname: ~A" (gethostname))
+(format t "~&Hostname (technique 1): ~A" (gethostname))
+(format t "~&Hostname (technique 2): ~A" (gethostname2))
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: objects.cl,v 1.13 2002/03/21 16:47:46 kevin Exp $
+;;;; $Id: objects.cl,v 1.14 2002/03/22 20:51:08 kevin Exp $
;;;;
;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
obj
)
-;; Simple first pass. Will later create optimized routines for
-;; various platforms.
(defmacro with-foreign-object ((var type) &rest body)
- #+allegro
+ #-(or cmu lispworks) ; default version
`(let ((,var (allocate-foreign-object ,type)))
(unwind-protect
(progn ,@body)
(free-foreign-object ,var)))
#+cmu
- `(alien:with-alien ((,var ,(convert-from-uffi-type type :allocate)))
- (setq ,var (alien:addr ,var))
- ,@body)
+ (let ((obj (gensym)))
+ `(alien:with-alien ((,obj ,(convert-from-uffi-type type :allocate)))
+ (let ((,var (alien:addr ,obj)))
+ ,@body)))
#+lispworks
- `(fli:with-dynamic-foreign-objects ((,var ,(convert-from-uffi-type type :allocate)))
+ `(fli:with-dynamic-foreign-objects ((,var ,(convert-from-uffi-type
+ type :allocate)))
,@body)
)
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: strings.cl,v 1.11 2002/03/21 11:38:07 kevin Exp $
+;;;; $Id: strings.cl,v 1.12 2002/03/22 20:51:08 kevin Exp $
;;;;
;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
)
(defmacro with-foreign-string ((foreign-string lisp-string) &body body)
+ #-(or lispworks cmu)
(let ((result (gensym)))
`(let* ((,foreign-string (convert-to-foreign-string ,lisp-string))
(,result (progn ,@body)))
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: gethostname.cl,v 1.7 2002/03/21 15:57:01 kevin Exp $
+;;;; $Id: gethostname.cl,v 1.8 2002/03/22 20:51:08 kevin Exp $
;;;;
;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(error "gethostname() failed."))))
#+test-uffi
-(format t "~&Hostname: ~A" (gethostname))
+(format t "~&Hostname (technique 1): ~A" (gethostname))
+(format t "~&Hostname (technique 2): ~A" (gethostname2))