The tips and insights are very much appreciated.  Thanks!

Cheers,
Josh

On May 28, 2007, at 10:50 AM, Ian Piumarta wrote:

> Josh,
>
>> My real question is: how can I pass floating-point arguments to  
>> native library functions obtained by using dlopen/dlsym?
>
> Currently you can't (at least not reliably and portably) since  
> there is no way to tell the Jolt compiler how to coerce the 64-bit  
> Float contents into a 32- or 64-bit float or double nor how to  
> store the resulting value in registers or stack as an argument.   
> Adding types to Jolt is high on my to-do list and should be done  
> within the next few weeks.  (As well as native floats and non- 
> integer parameters it'll add some degree of static type safety when  
> dealing with known interfaces, such as those described in /usr/ 
> include.)
>
> The work-around that I've been using is to create a thin wrapper in  
> Pepsi around the library of interest, then send messages to the  
> wrapper from Jolt.  To extract the float/double from a Float  
> argument you can, e.g:
>
> Float print
> {
>     double d;
>     memcpy(&d, self, sizeof(d));
>     printf("%g", d);
> }
>
> (the memcpy is required, to avoid violating alignment restrictions)  
> and to return a Float:
>
> Float sin
> [
>     self := self copy.
>     {
>         double d;
>         memcpy(&d, self, sizeof(d));
>         d = sin(d);
>         memcpy(self, &d, sizeof(d));
>     }
> ]
>
> Of course this doesn't help you pass floats or doubles through  
> '...' (to the printf functions, for example) but it might help fill  
> a gap until we have types.
>
> Cheers,
> Ian
>

_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc

Reply via email to