[plt-scheme] Build problems on amd64--freebsd7.0?

From: Andrew Reilly (andrew-scheme at areilly.bpc-users.org)
Date: Tue Dec 18 17:04:52 EST 2007

Hi Matthew,

On Mon, Dec 17, 2007 at 08:23:01PM -0700, Matthew Flatt wrote:
> At Tue, 18 Dec 2007 10:16:37 +1100, Andrew Reilly wrote:
> > I remember some mailing list commentary earlier this month about
> > several Lisp implementations having problems with a change to
> > which signal is delivered on a memory fault, in FreeBSD-7, but I
> > can't remember what the outcome of that was. 
> 
> In src/mzscheme/gc2/sighand.c, find the FreeBSD part, and change SIGBUS
> to SIGSEGV.
> 
> Here's the general fix, from the SVN trunk:
> 
> #  if defined(__FreeBSD__) && (__FreeBSD_version < 700000)
> #    define USE_SIGACTON_SIGNAL_KIND SIGBUS
> #  else
> #    define USE_SIGACTON_SIGNAL_KIND SIGSEGV
> #  endif

Thanks for that!  It wasn't all of the answer, but it was enough
to get me started.  The #include <sys/param.h> was necessary
too: it defines __FreeBSD_version.

Having got past that, though, there also seemed to be a problem
with wxme/wx_keym.cxx.  I just copied the version from trunk,
and it seems to have worked fine.

So, to summarize, this is the patch necessary to get 371.3 to
compile and run on FreeBSD-7:

diff -ur plt-371.3/src/mred/wxme/wx_keym.cxx plt-371.3.new/src/mred/wxme/wx_keym.cxx
--- plt-371.3/src/mred/wxme/wx_keym.cxx	2007-08-03 02:56:05.000000000 +1000
+++ plt-371.3.new/src/mred/wxme/wx_keym.cxx	2007-12-18 17:19:10.000000000 +1100
@@ -512,14 +512,20 @@
     if (i >= MAX_BUF - 1)
       return 0;
     buffer[i] = keyseq[kp];
-    if (buffer[i] < 128)
-      buffer[i] = tolower(buffer[i]);
+    if (buffer[i] < 128) {
+      wxchar t;
+      t = tolower(buffer[i]);
+      buffer[i] = t;
+    }
   }
   buffer[i] = 0;
   code = 0;
   if (buffer[1]) {
-    if (buffer[0] < 128)
-      buffer[0] = tolower(buffer[0]);
+    if (buffer[0] < 128) {
+      wxchar t;
+      t = tolower(buffer[0]);
+      buffer[0] = t;
+    }
     for (i = 0; keylist[i].str; i++) {
       if (!wx_c_strcmp(buffer, keylist[i].str)) {
 	code = keylist[i].code;
diff -ur plt-371.3/src/mzscheme/gc2/sighand.c plt-371.3.new/src/mzscheme/gc2/sighand.c
--- plt-371.3/src/mzscheme/gc2/sighand.c	2007-08-08 22:11:24.000000000 +1000
+++ plt-371.3.new/src/mzscheme/gc2/sighand.c	2007-12-18 16:56:53.000000000 +1100
@@ -27,13 +27,14 @@
 /*  As of 2007/06/29, this is a guess for NetBSD!  */
 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
 # include <signal.h>
+# include <sys/param.h>
 void fault_handler(int sn, siginfo_t *si, void *ctx)
 {
   if (!designate_modified(si->si_addr))
     abort();
 }
 #  define NEED_SIGACTION
-#  if defined(__FreeBSD__)
+#  if defined(__FreeBSD__) && (__FreeBSD_version < 700000)
 #    define USE_SIGACTON_SIGNAL_KIND SIGBUS
 #  else
 #    define USE_SIGACTON_SIGNAL_KIND SIGSEGV

I expect that at least the sighand.c part of that patch will be
necessary for 370 and 371, too.  As I mentioned in the original
post, 399/trunk already has all of these fixes, and works
beautifully.

I've raised a FreeBSD ports PR with this patch, so hopefully the
port build will be happy soon, too.

Cheers,

-- 
Andrew


Posted on the users mailing list.