r1617: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 22 Mar 2002 20:51:08 +0000 (20:51 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 22 Mar 2002 20:51:08 +0000 (20:51 +0000)
ChangeLog
examples/gethostname.cl
src/objects.cl
src/strings.cl
tests/gethostname.cl

index 300f25e5c4a804b73f9fac2fe708b82a8c8b5c1d..c2fe7311ec4502b5d52efbbc180011428b9d8da5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,10 +13,11 @@ See TODO file -- actively maintained. Includes changes that you
        * 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.
index 0062e4037035bc6f01ec3538b28498092cc1c7a4..fcec16e66fca67142cf7dc6abe89ed0432021cfe 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; 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
 ;;;;
@@ -44,5 +44,6 @@
        (error "gethostname() failed."))))
 
 #+test-uffi
-(format t "~&Hostname: ~A" (gethostname))
+(format t "~&Hostname (technique 1): ~A" (gethostname))
+(format t "~&Hostname (technique 2): ~A" (gethostname2))
 
index 6a33f9b1cc04a9b145e6c27924ad13ddbef7d4e0..b510b35bcd47f9627f0b1d46445c389d9bb85797 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; 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
 ;;;;
@@ -107,20 +107,20 @@ an array of TYPE with size SIZE."
   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)
   )
 
index ba4dfa297b4d926a7daf7ec2501970acdf0aadac..75496e08a3c77a1069e774bea0155d641e6f73d0 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; 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
 ;;;;
@@ -150,6 +150,7 @@ that LW/CMU automatically converts strings from c-calls."
   )
 
 (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)))
index 0062e4037035bc6f01ec3538b28498092cc1c7a4..fcec16e66fca67142cf7dc6abe89ed0432021cfe 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; 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
 ;;;;
@@ -44,5 +44,6 @@
        (error "gethostname() failed."))))
 
 #+test-uffi
-(format t "~&Hostname: ~A" (gethostname))
+(format t "~&Hostname (technique 1): ~A" (gethostname))
+(format t "~&Hostname (technique 2): ~A" (gethostname2))