Re: Open Source, then...?
- Posted by alban read <alban.read at mac.com> Nov 14, 2006
- 506 views
Jeremy Cowgar wrote: > > Yes, see The Archive. I believe it has a bug though in the Dynamic Library > support. > I tried wrapping libdbi and it fails randomly. Wrapping pgsql did the same > thing, > random weirdness. > > Jeremy > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> About OSX Intel components random dynamic library chaos.. Sorry - the random chaos in dynamic library calls is being caused by at least two problems. One is that Mac OSX (Intel) expects each half of a double to be copied the opposite way around to the way you would push them onto a stack. This may makes sense since they are being copied on rather than pushed down. That is very easy to do as it doesnt change the function much. The other problem is that the entire argument list needs to be reversed. e.g If you called mul(22/7) it would end up doing mul(7/22) which doesnt matter, but div(22/7) compared to div(7/22) would matter quite a lot :) Things seem to work a lot better if the arguments in the list are reversed then copied. I have tested copying the arguments into a buffer and then copying them out of the buffer in reverse order, this was easy to add to the call_c function. It seems wrong to copy arguments out of the sequence twice. I thought about reversing the argument sequence - but that may be slower if anything. Reading the sequence of arguments in reverse would work, if that was easy to do. Another option would be to work out the complete argument list size (in bytes), add it the pointer then copy the arguments on in the reverse direction, decrementing the pointer as you do it. I dont know what is likely to be fastest and most reliable.