Add tentative support for FreeMiNT.
authorBruno Haible <bruno@clisp.org>
Sat, 28 Feb 2009 20:24:24 +0000 (21:24 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 28 Feb 2009 20:24:24 +0000 (21:24 +0100)
13 files changed:
ChangeLog
lib/fbufmode.c
lib/fflush.c
lib/fpurge.c
lib/freadable.c
lib/freadahead.c
lib/freading.c
lib/freadptr.c
lib/freadseek.c
lib/fseeko.c
lib/fseterr.c
lib/fwritable.c
lib/fwriting.c

index 276a9f4..fc7b505 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2009-02-28  Bruno Haible  <bruno@clisp.org>
 
+       Add tentative support for FreeMiNT.
+       * lib/fbufmode.c (fbufmode) [__MINT__]: Add conditional code.
+       * lib/fflush.c (clear_ungetc_buffer): Likewise.
+       * lib/fpurge.c (fpurge): Likewise.
+       * lib/freadable.c (freadable): Likewise.
+       * lib/freading.c (freading): Likewise.
+       * lib/freadptr.c (freadptr): Likewise.
+       * lib/freadseek.c (freadptrinc): Likewise.
+       * lib/fseeko.c (rpl_fseeko): Likewise.
+       * lib/fseterr.c (fseterr): Likewise.
+       * lib/fwritable.c (fwritable): Likewise.
+       * lib/fwriting.c (fwriting): Likewise.
+       * lib/freadahead.c (freadahead): Likewise, based on code by Alan
+       Hourihane.
+       Reported by Alan Hourihane <alanh@fairlite.co.uk>.
+
+2009-02-28  Bruno Haible  <bruno@clisp.org>
+
        * lib/wait-process.h (wait_subprocess): Clarify restriction regarding
        SIGCHLD.
        Reported by Jim Meyering.
index d5b456f..7cd9df7 100644 (file)
@@ -1,5 +1,5 @@
 /* Retrieve information about a FILE stream.
-   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
@@ -73,6 +73,10 @@ fbufmode (FILE *fp)
   if (fp->_Mode & 0x800 /* _MNBF */)
     return _IONBF;
   return _IOFBF;
+#elif defined __MINT__              /* Atari FreeMiNT */
+  if (fp->__linebuf)
+    return _IOLBF;
+  return (fp->__bufsize > 0 ? _IOFBF : _IONBF);
 #else
  #error "Please port gnulib fbufmode.c to your platform! Look at the setvbuf implementation."
 #endif
index 9f75ccd..3b17655 100644 (file)
@@ -63,6 +63,12 @@ clear_ungetc_buffer (FILE *fp)
     }
 # 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;
+    }
 # else                              /* other implementations */
   fseek (fp, 0, SEEK_CUR);
 # endif
index 916b17b..0e2931e 100644 (file)
@@ -1,5 +1,5 @@
 /* Flushing buffers of a FILE stream.
-   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
@@ -114,6 +114,16 @@ fpurge (FILE *fp)
     /* fp->_Buf <= fp->_Next <= fp->_Rend */
     fp->_Rend = fp->_Next;
   return 0;
+# elif defined __MINT__             /* Atari FreeMiNT */
+  if (fp->__pushed_back)
+    {
+      fp->__bufp = fp->__pushback_bufp;
+      fp->__pushed_back = 0;
+    }
+  fp->__bufp = fp->__buffer;
+  fp->__get_limit = fp->__bufp;
+  fp->__put_limit = fp->__bufp;
+  return 0;
 # else
  #error "Please port gnulib fpurge.c to your platform! Look at the definitions of fflush, setvbuf and ungetc on your system, then report this to bug-gnulib."
 # endif
index b501404..9895b2c 100644 (file)
@@ -1,5 +1,5 @@
 /* Retrieve information about a FILE stream.
-   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
@@ -37,6 +37,8 @@ freadable (FILE *fp)
   return (fp->_flag & (_IORW | _IOREAD)) != 0;
 #elif defined __QNX__               /* QNX */
   return (fp->_Mode & 0x1 /* _MOPENR */) != 0;
+#elif defined __MINT__              /* Atari FreeMiNT */
+  return fp->__mode.__read;
 #else
  #error "Please port gnulib freadable.c to your platform! Look at the definition of fopen, fdopen on your system, then report this to bug-gnulib."
 #endif
index 25bfc1e..f4b5ed7 100644 (file)
@@ -1,5 +1,5 @@
 /* Retrieve information about a FILE stream.
-   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
@@ -70,6 +70,12 @@ freadahead (FILE *fp)
         + (fp->_Mode & 0x4000 /* _MBYTE */
            ? (fp->_Back + sizeof (fp->_Back)) - fp->_Rback
            : 0);
+#elif defined __MINT__              /* Atari FreeMiNT */
+  if (!fp->__mode.__read)
+    return 0;
+  return (fp->__pushed_back
+         ? fp->__get_limit - fp->__pushback_bufp + 1
+         : fp->__get_limit - fp->__bufp);
 #elif defined SLOW_BUT_NO_HACKS     /* users can define this */
   abort ();
   return 0;
index b08fbea..f20affc 100644 (file)
@@ -1,5 +1,5 @@
 /* Retrieve information about a FILE stream.
-   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
@@ -46,6 +46,11 @@ freading (FILE *fp)
 #elif defined __QNX__               /* QNX */
   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 ??*/)));
 #else
  #error "Please port gnulib freading.c to your platform!"
 #endif
index f78ec1a..3abe58e 100644 (file)
@@ -1,5 +1,5 @@
 /* Retrieve information about a FILE stream.
-   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
@@ -85,6 +85,14 @@ freadptr (FILE *fp, size_t *sizep)
     return NULL;
   *sizep = size;
   return (const char *) fp->_Next;
+#elif defined __MINT__              /* Atari FreeMiNT */
+  if (!fp->__mode.__read)
+    return NULL;
+  size = fp->__get_limit - fp->__bufp;
+  if (size == 0)
+    return NULL;
+  *sizep = size;
+  return fp->__bufp;
 #elif defined SLOW_BUT_NO_HACKS     /* users can define this */
   /* This implementation is correct on any ANSI C platform.  It is just
      awfully slow.  */
index 311c699..23046fa 100644 (file)
@@ -1,5 +1,5 @@
 /* Skipping input from a FILE stream.
-   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
@@ -53,6 +53,8 @@ freadptrinc (FILE *fp, size_t increment)
 # endif
 #elif defined __QNX__               /* QNX */
   fp->_Next += increment;
+#elif defined __MINT__              /* Atari FreeMiNT */
+  fp->__bufp += increment;
 #elif defined SLOW_BUT_NO_HACKS     /* users can define this */
 #else
  #error "Please port gnulib freadseek.c to your platform! Look at the definition of getc, getc_unlocked on your system, then report this to bug-gnulib."
index 47beac4..78e2b2f 100644 (file)
@@ -82,6 +82,11 @@ rpl_fseeko (FILE *fp, off_t offset, int whence)
   if ((fp->_Mode & _MWRITE ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend)
       && fp->_Rback == fp->_Back + sizeof (fp->_Back)
       && fp->_Rsave == NULL)
+#elif defined __MINT__              /* Atari FreeMiNT */
+  if (fp->__bufp == fp->__buffer
+      && fp->__get_limit == fp->__bufp
+      && fp->__put_limit == fp->__bufp
+      && !fp->__pushed_back)
 #else
   #error "Please port gnulib fseeko.c to your platform! Look at the code in fpurge.c, then report this to bug-gnulib."
 #endif
index ebe3580..110716b 100644 (file)
@@ -1,5 +1,5 @@
 /* Set the error indicator of a stream.
-   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
@@ -41,6 +41,8 @@ fseterr (FILE *fp)
   fp->__modeflags |= __FLAG_ERROR;
 #elif defined __QNX__               /* QNX */
   fp->_Mode |= 0x200 /* _MERR */;
+#elif defined __MINT__              /* Atari FreeMiNT */
+  fp->__error = 1;
 #elif 0                             /* unknown  */
   /* Portable fallback, based on an idea by Rich Felker.
      Wow! 6 system calls for something that is just a bit operation!
index ed7be9d..d295777 100644 (file)
@@ -1,5 +1,5 @@
 /* Retrieve information about a FILE stream.
-   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
@@ -37,6 +37,8 @@ fwritable (FILE *fp)
   return (fp->_flag & (_IORW | _IOWRT)) != 0;
 #elif defined __QNX__               /* QNX */
   return (fp->_Mode & 0x2 /* _MOPENW */) != 0;
+#elif defined __MINT__              /* Atari FreeMiNT */
+  return fp->__mode.__write;
 #else
  #error "Please port gnulib fwritable.c to your platform! Look at the definition of fopen, fdopen on your system, then report this to bug-gnulib."
 #endif
index 4ecf4b0..b7fa455 100644 (file)
@@ -1,5 +1,5 @@
 /* Retrieve information about a FILE stream.
-   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
@@ -40,6 +40,11 @@ fwriting (FILE *fp)
 #elif defined __QNX__               /* QNX */
   return ((fp->_Mode & 0x1 /* _MOPENR */) == 0
          || (fp->_Mode & 0x2000 /* _MWRITE */) != 0);
+#elif defined __MINT__              /* Atari FreeMiNT */
+  return (!fp->__mode.__read
+         || (fp->__mode.__write
+             && (fp->__buffer < fp->__put_limit
+                 /*|| fp->__bufp == fp->__get_limit ??*/)));
 #else
  #error "Please port gnulib fwriting.c to your platform!"
 #endif