changeset 15485:20a2699b8a90

stdioext: Add support for Minix. * lib/fbufmode.c (fbufmode) [__minix]: Add conditional code. * lib/fpurge.c (fpurge): Likewise. * lib/freadahead.c (freadahead): 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/fflush.c (clear_ungetc_buffer): Update comment. * m4/fpending.m4 (gl_PREREQ_FPENDING): Add a variant for Minix.
author Bruno Haible <bruno@clisp.org>
date Sun, 31 Jul 2011 21:16:15 +0200
parents 80735ab15b24
children 3f9f907b5afe
files 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 m4/fpending.m4
diffstat 14 files changed, 57 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2011-07-31  Bruno Haible  <bruno@clisp.org>
+
+	stdioext: Add support for Minix.
+	* lib/fbufmode.c (fbufmode) [__minix]: Add conditional code.
+	* lib/fpurge.c (fpurge): Likewise.
+	* lib/freadahead.c (freadahead): 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/fflush.c (clear_ungetc_buffer): Update comment.
+	* m4/fpending.m4 (gl_PREREQ_FPENDING): Add a variant for Minix.
+
 2011-07-31  Bruno Haible  <bruno@clisp.org>
 
 	errno: Port to Minix.
--- a/lib/fbufmode.c
+++ b/lib/fbufmode.c
@@ -50,6 +50,8 @@
   return _IOFBF;
 #elif defined __EMX__               /* emx+gcc */
   return fp->_flags & (_IOLBF | _IONBF | _IOFBF);
+#elif defined __minix               /* Minix */
+  return fp->_flags & (_IOLBF | _IONBF | _IOFBF);
 #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
 # if HAVE___FLBF                    /* Solaris >= 7 */
   if (__flbf (fp))
--- a/lib/fflush.c
+++ b/lib/fflush.c
@@ -60,7 +60,7 @@
       fp->_ungetc_count = 0;
       fp->_rcount = - fp->_rcount;
     }
-# elif defined _IOERR               /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
+# elif defined _IOERR               /* Minix, AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
   /* Nothing to do.  */
 # else                              /* other implementations */
   fseeko (fp, 0, SEEK_CUR);
--- a/lib/fpurge.c
+++ b/lib/fpurge.c
@@ -91,6 +91,11 @@
   fp->_wcount = 0;
   fp->_ungetc_count = 0;
   return 0;
+# elif defined __minix              /* Minix */
+  fp->_ptr = fp->_buf;
+  if (fp->_ptr != NULL)
+    fp->_count = 0;
+  return 0;
 # elif defined _IOERR               /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
   fp->_ptr = fp->_base;
   if (fp->_ptr != NULL)
--- a/lib/freadable.c
+++ b/lib/freadable.c
@@ -33,6 +33,8 @@
   return (fp_->_flags & (__SRW | __SRD)) != 0;
 #elif defined __EMX__               /* emx+gcc */
   return (fp->_flags & (_IORW | _IOREAD)) != 0;
+#elif defined __minix               /* Minix */
+  return (fp->_flags & _IOREAD) != 0;
 #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
   return (fp->_flag & (_IORW | _IOREAD)) != 0;
 #elif defined __QNX__               /* QNX */
--- a/lib/freadahead.c
+++ b/lib/freadahead.c
@@ -48,6 +48,10 @@
   /* equivalent to
      (fp->_ungetc_count == 0 ? fp->_rcount : fp->_ungetc_count - fp->_rcount) */
   return (fp->_rcount > 0 ? fp->_rcount : fp->_ungetc_count - fp->_rcount);
+#elif defined __minix               /* Minix */
+  if ((fp_->_flags & _IOWRITING) != 0)
+    return 0;
+  return fp_->_count;
 #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
   if ((fp_->_flag & _IOWRT) != 0)
     return 0;
--- a/lib/freading.c
+++ b/lib/freading.c
@@ -39,6 +39,8 @@
   return (fp_->_flags & __SRD) != 0;
 # elif defined __EMX__               /* emx+gcc */
   return (fp->_flags & _IOREAD) != 0;
+# elif defined __minix               /* Minix */
+  return (fp->_flags & _IOREADING) != 0;
 # elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
 #  if defined __sun                  /* Solaris */
   return (fp->_flag & _IOREAD) != 0 && (fp->_flag & _IOWRT) == 0;
--- a/lib/freadptr.c
+++ b/lib/freadptr.c
@@ -56,6 +56,14 @@
     abort ();
   *sizep = fp->_rcount;
   return fp->_ptr;
+#elif defined __minix               /* Minix */
+  if ((fp_->_flags & _IOWRITING) != 0)
+    return NULL;
+  size = fp_->_count;
+  if (size == 0)
+    return NULL;
+  *sizep = size;
+  return (const char *) fp_->_ptr;
 #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
   if ((fp_->_flag & _IOWRT) != 0)
     return NULL;
--- a/lib/freadseek.c
+++ b/lib/freadseek.c
@@ -42,6 +42,9 @@
 #elif defined __EMX__               /* emx+gcc */
   fp->_ptr += increment;
   fp->_rcount -= increment;
+#elif defined __minix               /* Minix */
+  fp_->_ptr += increment;
+  fp_->_count -= increment;
 #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
   fp_->_ptr += increment;
   fp_->_cnt -= increment;
--- a/lib/fseeko.c
+++ b/lib/fseeko.c
@@ -69,6 +69,9 @@
       && fp->_rcount == 0
       && fp->_wcount == 0
       && fp->_ungetc_count == 0)
+#elif defined __minix               /* Minix */
+  if (fp_->_ptr == fp_->_buf
+      && (fp_->_ptr == NULL || fp_->_count == 0))
 #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
   if (fp_->_ptr == fp_->_base
       && (fp_->_ptr == NULL || fp_->_cnt == 0))
--- a/lib/fseterr.c
+++ b/lib/fseterr.c
@@ -35,6 +35,8 @@
   fp_->_flags |= __SERR;
 #elif defined __EMX__               /* emx+gcc */
   fp->_flags |= _IOERR;
+#elif defined __minix               /* Minix */
+  fp->_flags |= _IOERR;
 #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
   fp_->_flag |= _IOERR;
 #elif defined __UCLIBC__            /* uClibc */
--- a/lib/fwritable.c
+++ b/lib/fwritable.c
@@ -33,6 +33,8 @@
   return (fp_->_flags & (__SRW | __SWR)) != 0;
 #elif defined __EMX__               /* emx+gcc */
   return (fp->_flags & (_IORW | _IOWRT)) != 0;
+#elif defined __minix               /* Minix */
+  return (fp->_flags & _IOWRITE) != 0;
 #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
   return (fp->_flag & (_IORW | _IOWRT)) != 0;
 #elif defined __QNX__               /* QNX */
--- a/lib/fwriting.c
+++ b/lib/fwriting.c
@@ -33,6 +33,8 @@
   return (fp_->_flags & __SWR) != 0;
 #elif defined __EMX__               /* emx+gcc */
   return (fp->_flags & _IOWRT) != 0;
+#elif defined __minix               /* Minix */
+  return (fp->_flags & _IOWRITING) != 0;
 #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
   return (fp->_flag & _IOWRT) != 0;
 #elif defined __UCLIBC__            /* uClibc */
--- a/m4/fpending.m4
+++ b/m4/fpending.m4
@@ -1,4 +1,4 @@
-# serial 16
+# serial 17
 
 # Copyright (C) 2000-2001, 2004-2011 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -58,6 +58,9 @@
           '# emx+gcc'                                                   \
           'fp->_ptr - fp->_buffer'                                      \
                                                                         \
+          '# Minix'                                                     \
+          'fp->_ptr - fp->_buf'                                         \
+                                                                        \
           '# VMS'                                                       \
           '(*fp)->_ptr - (*fp)->_base'                                  \
                                                                         \