[Gc] GC patch for DJGPP

Boehm, Hans hans_boehm@hp.com
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.

------_=_NextPart_000_01C3A23F.FE098282
Content-Type: text/plain;
	charset="iso-8859-1"

Thanks.

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.

Hans

> -----Original Message-----
> From: Fergus Henderson [mailto:fjh@ceres.cs.mu.OZ.AU]On 
> Behalf Of Fergus
> Henderson
> Sent: Sunday, November 02, 2003 7:08 PM
> To: Doug Kaufman
> Cc: Boehm, Hans; gc@napali.hpl.hp.com
> Subject: Re: [Gc] GC patch for DJGPP
> 
> 
> On 02-Nov-2003, Doug Kaufman <dkaufman@rahul.net> wrote:
> > On Mon, 3 Nov 2003, Fergus Henderson wrote:
> > 
> > > On 01-Nov-2003, Doug Kaufman <dkaufman@rahul.net> 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 
> failed");
> > > > +    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 <fjh@cs.mu.oz.au>  |  "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.
> 


------_=_NextPart_000_01C3A23F.FE098282
Content-Type: application/octet-stream;
	name="cordtest.c.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="cordtest.c.diff"

--- 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=
     }=0A=
     if ((f =3D fopen(FNAME2, "w")) =3D=3D 0) ABORT("2nd open =
failed");=0A=
+#   ifdef __DJGPP__=0A=
+      /* FIXME: DJGPP workaround.  Why does this help? */=0A=
+      if (fflush(f) !=3D 0) ABORT("fflush failed");=0A=
+#   endif=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=

------_=_NextPart_000_01C3A23F.FE098282--