Ruby 1.8.7pl330 + DJGPP (was Re: GCC-4.5.2)

Hi,

On Jan 11, 12:15am, Andris P. [email protected] wrote:

I have done only very little testing myself.

Cool, thanks. I’ll be honest, I wasn’t sure 4.5.x would ever arrive on
DJGPP, and I blindly assumed the plugin architecture made that harder.
Nevertheless, at least whats-his-face can properly tune for Atom
now. :wink:

Anyways, I noticed you said you weren’t able to test it too heavily
yet. Well, I wanted to (weakly) help, so I decided to build Ruby 1.8.7
pl330, esp. since I’ve compiled it with DJGPP before (a year ago) and
it’s non-trivial. (Unfortunately I don’t really know any Ruby, far
from it.)

Good news! It (almost) compiles, had to tweak util.c first, then it
built okay (miniruby, ruby), plus “make test” works even with default -
O2 now (thankfully). It also works with the only two Ruby programs
I’ve ever written (see old thread). So I guess that’s a fair test.
However, note that I didn’t even bother trying the /djgpp/ subdir as
last time that didn’t work, and I doubt they fixed it since then. I
just did a normal “./configure && make” under Bash (and using DJDEV
2.04 beta) on WinXP (Home SP3 32-bit).

It’s probably a dumb idea, I’ll probably get flamed, but I guess I’ll
cc news://comp.lang.ruby anyways so somebody can know that I actually
tried (and barely patched) it for DJGPP. Here’s the fix (and I admit I
didn’t know a good way to use #define inside a DJGPP #ifdef to use
open() instead of _open, so I had to just manually fix it).

— util.c 2010-11-22 07:21:34 +0000
+++ …/ruby-1.8.7-p330/util.c 2011-01-13 12:28:14 +0000
@@ -234,7 +234,7 @@
memcpy(RSTRING_PTR(str), buf, RSTRING_LEN(str));
}

-#if defined(CYGWIN32) || defined(_WIN32)
+//#if defined(CYGWIN32) || defined(_WIN32)
#if defined CYGWIN32 || defined MINGW32
extern int _open(const char *, int, …);
extern int _close(int);
@@ -250,9 +250,9 @@
// It doesn’t exist, so see if we can open it.
*/

  • if ((fd = _open(s, O_CREAT|O_EXCL, 0666)) >= 0) {
  • _close(fd);
  • _unlink(s); /* don’t leave it laying around */
  • if ((fd = open(s, O_CREAT|O_EXCL, 0666)) >= 0) {
  • close(fd);
  • unlink(s); /* don’t leave it laying around */
    return 1;
    }
    else if (errno == EEXIST) {
    @@ -262,7 +262,7 @@
    return 0;
    }
    #endif
    -#endif
    +//#endif

#if defined DJGPP