[Gc] GC patch for DJGPP
Mon, 3 Nov 2003 11:23:42 -0800
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
I applied the attached patch. I made the code conditional on DJGPP, since
I have no idea why it helps, and it seems to really be a workaround for a stdio
problem that's specific to DJGPP.
> -----Original Message-----
> From: Fergus Henderson [mailto:email@example.com.OZ.AU]On
> Behalf Of Fergus
> Sent: Sunday, November 02, 2003 7:08 PM
> To: Doug Kaufman
> Cc: Boehm, Hans; firstname.lastname@example.org
> Subject: Re: [Gc] GC patch for DJGPP
> On 02-Nov-2003, Doug Kaufman <email@example.com> wrote:
> > On Mon, 3 Nov 2003, Fergus Henderson wrote:
> > > On 01-Nov-2003, Doug Kaufman <firstname.lastname@example.org> wrote:
> > > > The errno was EACCESS. Adding a call to fflush() seems
> to fix the
> > > > problem. I am not really sure why.
> > > ...
> > > > if ((f = fopen(FNAME2, "w")) == 0) ABORT("2nd open
> > > > + fflush(f);
> > >
> > > That really ought to be
> > >
> > > if (fflush(f) == EOF) ABORT("fflush failed");
> > But how do you make this compatible across different operating
> > systems?
> That code will work on any system which conforms to the ISO C standard
> (either the 1990 version or the 1999 version).
> > The DJGPP version of fflush returns "0" on success and "-1"
> > on failure. I see that Redhat linux, cygwin, and SunOS 4.1
> all return
> > EOF on failure and "0" on success.
> On DJGPP, EOF will be -1, I'm pretty sure. So this code should work
> with DJGPP as well as those other systems.
> > So you would probably be better off using "if (fflush(f) != 0)".
> That would work too.
> Fergus Henderson <email@example.com> | "I have always known
> that the pursuit
> The University of Melbourne | of excellence is a
> lethal habit"
> WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words
> of T. S. Garp.
--- cordtest.c.orig 2003-11-03 11:23:42.000000000 -0800=0A=
+++ cordtest.c 2003-11-03 11:27:30.000000000 -0800=0A=
@@ -162,6 +162,10 @@=0A=
x =3D CORD_cat(x,x);=0A=
if ((f =3D fopen(FNAME2, "w")) =3D=3D 0) ABORT("2nd open =
+# ifdef __DJGPP__=0A=
+ /* FIXME: DJGPP workaround. Why does this help? */=0A=
+ if (fflush(f) !=3D 0) ABORT("fflush failed");=0A=
if (CORD_put(x,f) =3D=3D EOF) ABORT("CORD_put failed");=0A=
if (fclose(f) =3D=3D EOF) ABORT("fclose failed");=0A=
w =3D CORD_from_file(f2 =3D fopen(FNAME2, "rb"));=0A=