On Thu, Nov 19, 2009 at 1:47 AM, Gary Dunn <osp@aloha.com> wrote:

In conjunction with getting Open Cobalt running on FreeBSD I have been
looking into the problems with SqueakFFIPrims on FreeBSD and have
reached a point that is beyond my understanding. I am not sure if the
fix should come from the VM side or the FreeBSD port maintainer.

I needed to get source code back into the ports tree so I did a make
in /usr/ports/lang/squeak. I already had the 3.9 tarball, so that just
repopulated the source and did the initial build.

In the "files" folder I found patch files typical for a FreeBSD port.
These patch source files from a generic tarball to work with FreeBSD.
The one of interest was

patch-platforms__unix__plugins__SqueakFFIPrims__ffi-config

which contains

----x-----x-----
--- platforms/unix/plugins/SqueakFFIPrims/ffi-config.org        Wed Apr
26 20:27:53 2006
+++ platforms/unix/plugins/SqueakFFIPrims/ffi-config    Wed Apr 26
20:29:00 2006
@@ -39,6 +39,7 @@

 case ${abi} in
    linux)             abi=sysv;;
+    freebsd*)          abi=sysv;;
    darwin*)           abi=darwin;;
    *)                 abi=libffi; lib="-lffi";;
 esac
-----x-----x-----

I then had the folder

work/Squeak-3.9-7/platforms/unix/plugins/SqueakFFIPrims

In it is a file 00README which explains how to test FFI.

It says to run ffi-test-config but I have no such file.

It says to type "make" to build a test suite but the build failed.

It says to try with make CPU=any ABI=libffi LIB=-lffi

which also failed. I traced the problem to the gcc search paths for
includes and libraries -- turns out FreeBSD only searches /usr/include
and /usr/lib when the required files are in /usr/local/include
and /usr/local/lib.

After some fiddling I finally had a "main" to test. It failed:
ffi-test-main.c failed at line 361. Here is a bit from that file, ending
with line 361:

   ffiInitialize();
   for (ul= 0;  ul < 15;  ++ul)
     ffiPushSingleFloat(fa[ul]);
   GO(FFITypeSingleFloat, many);
   f= ffiReturnFloatValue();
   ffiCleanup();
   CHECK(f - ff < FLT_EPSILON);

I worked out the CHECK macro but could not find what FLT_EPSILON is. At
that point I decided to stop and come to you for help.

define FLT_EPSILON as something like 1e-20 and rewrite the check as CHECK(fabs(f - ff) < FLT_EPSILON)?

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.

 

Where do I go from here?

--
Gary Dunn, Honolulu
osp@aloha.com
http://openslate.net/
http://e9erust.blogspot.com/
Sent from Slate001