Hi David,<br><br><div class="gmail_quote">On Mon, Mar 21, 2011 at 6:50 AM, David Graham <span dir="ltr">&lt;<a href="mailto:dgraham@unthinkable.org">dgraham@unthinkable.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Hello,<br>
<br>
I&#39;ve noticed a few emails about running Cog on FreeBSD on some of the other mailing lists and was wondering if it would be possible to get a few patches integrated into the main repository?  Sorry if I&#39;m not following protocol for patch submission or style, I couldn&#39;t find any guidelines.  I&#39;d be happy to resubmit if this isn&#39;t the place.<br>
</blockquote><div><br></div><div>This&#39;ll do.  This is the place.  Thanks, but I have some reservations.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<br>
With the following patches, Cog r2372 will compile and run on FreeBSD (and PCBSD) 8.2 i386.  I&#39;ve been able to use Squeak, Pharo, and Seaside images.  Here is the configure line:<br>
<br>
../../platforms/unix/config/configure CFLAGS=&quot;-g -O2 -msse2 -DNDEBUG -DITIMER_HEARTBEAT=1 -DNO_VM_PROFILE=1 -DCOGMTVM=0 -DNOEXECINFO -DDEBUGVM=0&quot; LIBS=-lpthread --without-npsqueak<br></blockquote><div><br></div>
<div>Thanks.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Here is the diff.<br>
Index: platforms/unix/plugins/SqueakFFIPrims/ffi-config<br>
===================================================================<br>
--- platforms/unix/plugins/SqueakFFIPrims/ffi-config    (revision 2372)<br>
+++ platforms/unix/plugins/SqueakFFIPrims/ffi-config    (working copy)<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></blockquote><div><br></div><div>This should be irrelevant.  You should not be building the old plugin but instead be using ReentrantFFIPlugin or ThreadedFFIPlugin.  Is this simply to get the configure to run?  If so I&#39;ll try and excise support for the old FFI plugin.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Index: platforms/unix/vm/sqUnixMain.c<br>
===================================================================<br>
--- platforms/unix/vm/sqUnixMain.c      (revision 2372)<br>
+++ platforms/unix/vm/sqUnixMain.c      (working copy)<br>
@@ -60,6 +60,9 @@<br>
 # include &lt;execinfo.h&gt;<br>
 # define BACKTRACE_DEPTH 64<br>
 #endif<br>
+#if __FreeBSD__<br>
+# include &lt;sys/ucontext.h&gt;<br>
+#endif<br>
<br>
 #if defined(__alpha__) &amp;&amp; defined(__osf__)<br>
 # include &lt;sys/sysinfo.h&gt;<br>
@@ -777,6 +780,9 @@<br>
 # elif __linux__ &amp;&amp; __i386__<br>
                        void *fp = (void *)(uap ? uap-&gt;uc_mcontext.gregs[REG_EBP]: 0);<br>
                        void *sp = (void *)(uap ? uap-&gt;uc_mcontext.gregs[REG_ESP]: 0);<br>
+# elif __FreeBSD__ &amp;&amp; __i386__<br>
+                       void *fp = (void *)(uap ? uap-&gt;uc_mcontext.mc_ebp: 0);<br>
+                       void *sp = (void *)(uap ? uap-&gt;uc_mcontext.mc_esp: 0);<br>
 # else<br>
 #      error need to implement extracting pc from a ucontext_t on this system<br>
 # endif<br></blockquote><div><br></div><div>Excellent.  Thanks.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Index: platforms/Cross/plugins/SqueakFFIPrims/sqFFIPlugin.c<br>
===================================================================<br>
--- platforms/Cross/plugins/SqueakFFIPrims/sqFFIPlugin.c        (revision 2372)<br>
+++ platforms/Cross/plugins/SqueakFFIPrims/sqFFIPlugin.c        (working copy)<br>
@@ -10,7 +10,7 @@<br>
 *****************************************************************************/<br>
<br>
 #include &lt;stdio.h&gt;<br>
-#if !WIN32<br>
+#if !WIN32 &amp;&amp; !__FreeBSD__<br>
 # include &lt;alloca.h&gt;<br>
 #endif<br>
 #include &lt;string.h&gt;</blockquote></div><br><div>Great, thanks!</div>