<br><br><div class="gmail_quote">On Thu, Nov 19, 2009 at 1:47 AM, Gary Dunn <span dir="ltr">&lt;<a href="mailto:osp@aloha.com">osp@aloha.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
In conjunction with getting Open Cobalt running on FreeBSD I have been<br>
looking into the problems with SqueakFFIPrims on FreeBSD and have<br>
reached a point that is beyond my understanding. I am not sure if the<br>
fix should come from the VM side or the FreeBSD port maintainer.<br>
<br>
I needed to get source code back into the ports tree so I did a make<br>
in /usr/ports/lang/squeak. I already had the 3.9 tarball, so that just<br>
repopulated the source and did the initial build.<br>
<br>
In the &quot;files&quot; folder I found patch files typical for a FreeBSD port.<br>
These patch source files from a generic tarball to work with FreeBSD.<br>
The one of interest was<br>
<br>
patch-platforms__unix__plugins__SqueakFFIPrims__ffi-config<br>
<br>
which contains<br>
<br>
----x-----x-----<br>
--- platforms/unix/plugins/SqueakFFIPrims/<a href="http://ffi-config.org" target="_blank">ffi-config.org</a>        Wed Apr<br>
26 20:27:53 2006<br>
+++ platforms/unix/plugins/SqueakFFIPrims/ffi-config    Wed Apr 26<br>
20:29:00 2006<br>
@@ -39,6 +39,7 @@<br>
<br>
 case ${abi} in<br>
     linux)             abi=sysv;;<br>
+    freebsd*)          abi=sysv;;<br>
     darwin*)           abi=darwin;;<br>
     *)                 abi=libffi; lib=&quot;-lffi&quot;;;<br>
 esac<br>
-----x-----x-----<br>
<br>
I then had the folder<br>
<br>
work/Squeak-3.9-7/platforms/unix/plugins/SqueakFFIPrims<br>
<br>
In it is a file 00README which explains how to test FFI.<br>
<br>
It says to run ffi-test-config but I have no such file.<br>
<br>
It says to type &quot;make&quot; to build a test suite but the build failed.<br>
<br>
It says to try with make CPU=any ABI=libffi LIB=-lffi<br>
<br>
which also failed. I traced the problem to the gcc search paths for<br>
includes and libraries -- turns out FreeBSD only searches /usr/include<br>
and /usr/lib when the required files are in /usr/local/include<br>
and /usr/local/lib.<br>
<br>
After some fiddling I finally had a &quot;main&quot; to test. It failed:<br>
ffi-test-main.c failed at line 361. Here is a bit from that file, ending<br>
with line 361:<br>
<br>
    ffiInitialize();<br>
    for (ul= 0;  ul &lt; 15;  ++ul)<br>
      ffiPushSingleFloat(fa[ul]);<br>
    GO(FFITypeSingleFloat, many);<br>
    f= ffiReturnFloatValue();<br>
    ffiCleanup();<br>
    CHECK(f - ff &lt; FLT_EPSILON);<br>
<br>
I worked out the CHECK macro but could not find what FLT_EPSILON is. At<br>
that point I decided to stop and come to you for help.<br></blockquote><div><br></div><div>define FLT_EPSILON as something like 1e-20 and rewrite the check as CHECK(fabs(f - ff) &lt; FLT_EPSILON)?</div><div><br></div><div>
In math epsilon is a small value tending towards zero.  The intent here is to check that you get back something close to ff without assuming that the floating-point arithmetic involved in many is exact enough to return ff.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Where do I go from here?<br>
<font color="#888888"><br>
--<br>
Gary Dunn, Honolulu<br>
<a href="mailto:osp@aloha.com">osp@aloha.com</a><br>
<a href="http://openslate.net/" target="_blank">http://openslate.net/</a><br>
<a href="http://e9erust.blogspot.com/" target="_blank">http://e9erust.blogspot.com/</a><br>
Sent from Slate001<br>
<br>
</font></blockquote></div><br>