Bruno Haible | 1 Mar 01:34 2009

Re: [patch #6758] Add support for Atari FreeMiNT OS

Alan Hourihane wrote:
> I know. It's a kernel issue that needs dealing with

OK, if you already know it's a kernel issue, it's certainly not a problem
caused by your proposed ftello / fseek... patches. So I'm applying your patch:

2009-02-28  Bruno Haible  <bruno <at> clisp.org>

	* tests/test-freadseek.c (main): Disable test beyond end of file on FreeMiNT.
	* tests/test-ftello.c (main): Likewise.
	Patch by Alan Hourihane <alanh <at> fairlite.co.uk>.

--- tests/test-freadseek.c.orig	2009-03-01 01:31:50.000000000 +0100
+++ tests/test-freadseek.c	2009-03-01 01:30:09.000000000 +0100
 <at>  <at>  -1,5 +1,5  <at>  <at> 
 /* Test of freadseek() function.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 <at>  <at>  -92,10 +92,12  <at>  <at> 
   ASSERT (fgetc (stdin) == EOF);
   ASSERT (!ferror (stdin));

+#if !defined __MINT__ /* FreeMiNT has problems seeking past end of file */
   /* Test move beyond end of file.  */
   ASSERT (freadseek (stdin, 1000000) == 0);
   ASSERT (fgetc (stdin) == EOF);
   ASSERT (!ferror (stdin));
(Continue reading)

Alan Hourihane | 1 Mar 01:43 2009
Picon

Re: [patch #6758] Add support for Atari FreeMiNT OS

On Sun, 2009-03-01 at 01:34 +0100, Bruno Haible wrote:
> Alan Hourihane wrote:
> > I know. It's a kernel issue that needs dealing with
> 
> OK, if you already know it's a kernel issue, it's certainly not a problem
> caused by your proposed ftello / fseek... patches. So I'm applying your patch:

You missed my point. The tests still fail even with those test patches
applied because the fseeko.c code is broken. 

I've had to resort to using if (0) in fseeko.c to really pass the test,
even with the test patches.

Alan.

Alan Hourihane | 1 Mar 01:48 2009
Picon

Re: [patch #6758] Add support for Atari FreeMiNT OS

Hi Bruno,

So I can see the test patches applied in git HEAD.

If I take that code and apply the attached conglomeration patch, then
all the tests pass.

Alan.
Attachment (freemint.patch): text/x-patch, 3229 bytes
Bruno Haible | 1 Mar 02:17 2009

Re: [patch #6758] Add support for Atari FreeMiNT OS to fpurge

Alan Hourihane wrote:
+  fp->__pushback_bufp = 0;
+  if (fp->__mode.__write)
+    fp->__put_limit = fp->__buffer;
+  fp->__bufp = fp->__get_limit;

I don't think the last statement is right. The purpose of fpurge, on the read
side, is to empty the buffer, i.e. drop all read contents. I do agree that
at the end of this function, fp->__bufp == fp->__get_limit, should hold.

Compare what is done on glibc systems. There, essentially
  #define getc(fp) (fp->_IO_read_ptr < fp->_IO_read_end ? *_fp->_IO_read_ptr++ : ...)
and fpurge does
  fp->_IO_read_end = fp->_IO_read_ptr;
Consequently, on FreeMiNT, where getc is essentially
  #define getc(fp) (fp->__bufp < fp->__get_limit ? *fp->__bufp++ : ...)
hence fpurge has to do
  fp->__get_limit = fp->__bufp;

I propose this instead in fpurge.c

# elif defined __MINT__             /* Atari FreeMiNT */
  if (fp->__pushed_back)
    {
      fp->__bufp = fp->__pushback_bufp;
      fp->__pushed_back = 0;
    }
  /* Preserve the current file position.  */
  if (fp->__target != -1)
    fp->__target += fp->__bufp - fp->__buffer;
(Continue reading)

Bruno Haible | 1 Mar 02:21 2009

Re: [patch #6758] Add support for Atari FreeMiNT OS

Alan Hourihane wrote:
> > > > --- lib/fflush.c.orig	2009-02-28 21:09:16.000000000 +0100
> > > > +++ lib/fflush.c	2009-02-28 21:01:40.000000000 +0100
> > > >  <at>  <at>  -63,6 +63,12  <at>  <at> 
> > > >      }
> > > >  # elif defined _IOERR               /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw */
> > > >    /* Nothing to do.  */
> > > > +# elif defined __MINT__             /* Atari FreeMiNT */
> > > > +  if (fp->__pushed_back)
> > > > +    {
> > > > +      fp->__bufp = fp->__pushback_bufp;
> > > > +      fp->__pushed_back = 0;
> > > > +    }
> This breaks the test. If I remove this code above, the tests pass.

OK, I remove it. It was meant as an optimization over fseek(fp,0,SEEK_CUR).
But if it's not correct, better take it out.

Bruno

Bruno Haible | 1 Mar 02:40 2009

Re: [patch #6758] Add support for Atari FreeMiNT OS

Alan Hourihane wrote:
> Attached are the freading.c and fwriting.c patches to make them pass.

Thanks. I've committed it like this:

2009-02-28  Bruno Haible  <bruno <at> clisp.org>

	More support for FreeMiNT.
	* lib/freading.c (freading) [__MINT__]: Use new macros that were added
	to FreeMiNT today.
	* lib/fwriting.c (fwriting): Likewise.
	Based on patch by Alan Hourihane <alanh <at> fairlite.co.uk>.

--- lib/freading.c.orig	2009-03-01 02:35:56.000000000 +0100
+++ lib/freading.c	2009-03-01 02:27:09.000000000 +0100
 <at>  <at>  -47,10 +47,15  <at>  <at> 
   return ((fp->_Mode & 0x2 /* _MOPENW */) == 0
 	  || (fp->_Mode & 0x1000 /* _MREAD */) != 0);
 #elif defined __MINT__              /* Atari FreeMiNT */
-  return (!fp->__mode.__write
-	  || (fp->__mode.__read
-	      && (fp->__buffer < fp->__get_limit
-		  /*|| fp->__bufp == fp->__put_limit ??*/)));
+  if (!fp->__mode.__write)
+    return 1;
+  if (!fp->__mode.__read)
+    return 0;
+# ifdef _IO_CURRENTLY_GETTING /* Flag added on 2009-02-28 */
+  return (fp->__flags & _IO_CURRENTLY_GETTING) != 0;
+# else
(Continue reading)

Alan Hourihane | 1 Mar 09:06 2009
Picon

Re: [patch #6758] Add support for Atari FreeMiNT OS to fpurge

On Sun, 2009-03-01 at 02:17 +0100, Bruno Haible wrote:
> Alan Hourihane wrote:
> +  fp->__pushback_bufp = 0;
> +  if (fp->__mode.__write)
> +    fp->__put_limit = fp->__buffer;
> +  fp->__bufp = fp->__get_limit;
> 
> I don't think the last statement is right. The purpose of fpurge, on the read
> side, is to empty the buffer, i.e. drop all read contents. I do agree that
> at the end of this function, fp->__bufp == fp->__get_limit, should hold.
> 
> Compare what is done on glibc systems. There, essentially
>   #define getc(fp) (fp->_IO_read_ptr < fp->_IO_read_end ? *_fp->_IO_read_ptr++ : ...)
> and fpurge does
>   fp->_IO_read_end = fp->_IO_read_ptr;
> Consequently, on FreeMiNT, where getc is essentially
>   #define getc(fp) (fp->__bufp < fp->__get_limit ? *fp->__bufp++ : ...)
> hence fpurge has to do
>   fp->__get_limit = fp->__bufp;

Quite right. Good catch.

> I propose this instead in fpurge.c
> 
> # elif defined __MINT__             /* Atari FreeMiNT */
>   if (fp->__pushed_back)
>     {
>       fp->__bufp = fp->__pushback_bufp;
>       fp->__pushed_back = 0;
>     }
(Continue reading)

Jim Meyering | 1 Mar 09:35 2009
Picon

Re: vc-list-files-cvs failure?

Ralf Wildenhues wrote:
...
>> That fall-back code relies on gawk, sed and /bin/sh,
>> so you might try with a different shell, e.g., bash vs. dash,
>> or inserting "| tee /tmp/log " into the pipeline to see if
>> the damage is already done before the eval'd "sed" code runs.
>
> I can reproduce this when awk is mawk.  The following patch fixes
> the failure, the portability issue is documented in the gawk manual.
>
> OK to apply?
>
> Thanks,
> Ralf
>
>     Fix unportable awk script in vc-list-files.
>
>     * build-aux/vc-list-files: In the replacement awk script, use
>     substr with a second argument of 1, not zero.
>     Report by Simon Josefsson.

Sure.  Thanks, Ralf!

Alan Hourihane | 1 Mar 10:44 2009
Picon

Re: [patch #6758] Add support for Atari FreeMiNT OS

On Sun, 2009-03-01 at 02:40 +0100, Bruno Haible wrote:
> Alan Hourihane wrote:
> > Attached are the freading.c and fwriting.c patches to make them pass.
> 
> Thanks. I've committed it like this:

Thanks, but the #else section is still broken for older mintlibs, and
it's really not going to work. That's why I added the new functionality.

Alan.

> 2009-02-28  Bruno Haible  <bruno <at> clisp.org>
> 
> 	More support for FreeMiNT.
> 	* lib/freading.c (freading) [__MINT__]: Use new macros that were added
> 	to FreeMiNT today.
> 	* lib/fwriting.c (fwriting): Likewise.
> 	Based on patch by Alan Hourihane <alanh <at> fairlite.co.uk>.
> 
> --- lib/freading.c.orig	2009-03-01 02:35:56.000000000 +0100
> +++ lib/freading.c	2009-03-01 02:27:09.000000000 +0100
>  <at>  <at>  -47,10 +47,15  <at>  <at> 
>    return ((fp->_Mode & 0x2 /* _MOPENW */) == 0
>  	  || (fp->_Mode & 0x1000 /* _MREAD */) != 0);
>  #elif defined __MINT__              /* Atari FreeMiNT */
> -  return (!fp->__mode.__write
> -	  || (fp->__mode.__read
> -	      && (fp->__buffer < fp->__get_limit
> -		  /*|| fp->__bufp == fp->__put_limit ??*/)));
> +  if (!fp->__mode.__write)
(Continue reading)

Bruno Haible | 1 Mar 11:03 2009

Re: [patch #6758] Add support for Atari FreeMiNT OS

Alan Hourihane wrote:
> Thanks, but the #else section is still broken for older mintlibs, and
> it's really not going to work. That's why I added the new functionality.

I know, and thanks for adding the new functionality. But for older mintlibs
I prefer some something that compiles and works approximately to a compile
error. Don't know how many users this package has.

Bruno


Gmane