[Openmcl-devel] defcallback and doubles

Gary Byers gb at clozure.com
Thu Jul 14 13:56:36 PDT 2005

On Thu, 14 Jul 2005, Chris Curtis wrote:

> Hello all,
> I'm having a strange problem with a defcallback'ed function that takes 
> doubles. The function signature in C is:
> int (*pfunc)(const char*, const char*, const char*, double, double, double, 
> double, double, double, void*)
> (I didn't write it.)
> My callback function looks like this:
> (defcallback my-cb-func ((:* :char) s1 (:* :char) s2 (:* :char) s3
>                         :double d1 :double d2 :double d3 :double :d4 :double 
> d5 :double d6
>                         (:* T) ref
>                         :integer)
>  (format t "~A ~A ~A ~G ~G ~G ~G ~G ~G~%" (ccl::%get-cstring s1) 
> (ccl::%get-cstring s2)
>           (ccl::%get-cstring s3) d1 d2 d3 d4 d5 d6))
> When this callback is executed by the C library I'm using, the three cstrings 
> are handled correctly but the doubles are way off, seeming to indicate that 
> somehow the wrong value and/or wrong alignment is being used for those 
> parameters.

Whether or not the function has a C prototype in effect at the point
of call may be the most sigificant factor.  If no prototype had
existed, I think that the callback would have worked (C would have had
to consider the possibility that the function took a variable number
of args; FF-CALL basically always passes arguments in a way that'll
allow varargs to work.)

This is fixable, but it'll require changes on both the lisp and kernel

> If I call the same callback using ff-call, it works correctly. I'm not even 
> sure how to debug this further yet. Is there something obvious I'm missing?
> Thanks,
> --chris
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel

More information about the Openmcl-devel mailing list