Add support for uClibc 0.9.29.
authorBruno Haible <bruno@clisp.org>
Sat, 9 Jun 2007 01:27:49 +0000 (01:27 +0000)
committerBruno Haible <bruno@clisp.org>
Sat, 9 Jun 2007 01:27:49 +0000 (01:27 +0000)
ChangeLog
lib/fbufmode.c
lib/fpurge.c
lib/freading.c
lib/fseeko.c
lib/fseterr.c
lib/fwriting.c
tests/test-fflush.c

index 22f623a..663e478 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2007-06-08  Bruno Haible  <bruno@clisp.org>
 
+       Port to uClibc.
+       * lib/fbufmode.c (fbufmode): Add special code for uClibc.
+       * lib/fpurge.c (fpurge): Likewise.
+       * lib/freading.c (freading): Likewise.
+       * lib/fseeko.c (rpl_fseeko): Likewise.
+       * lib/fseterr.c (fseterr): Likewise.
+       * lib/fwriting.c (fwriting): Likewise.
+       * tests/test-fflush.c (main): Avoid a failure on uClibc.
+
+2007-06-08  Bruno Haible  <bruno@clisp.org>
+
        * m4/intlmacosx.m4: New file, extracted from gettext.m4.
        * m4/gettext.m4 (gt_INTL_MACOSX): Remove macro, moved to intlmacosx.m4.
        * modules/gettext (Files): Add m4/intlmacosx.m4.
index 6df6a20..58c3bc2 100644 (file)
@@ -62,6 +62,12 @@ fbufmode (FILE *fp)
     return _IONBF;
   return _IOFBF;
 # endif
+#elif defined __UCLIBC__            /* uClibc */
+  if (fp->__modeflags & __FLAG_LBF)
+    return _IOLBF;
+  if (fp->__modeflags & __FLAG_NBF)
+    return _IONBF;
+  return _IOFBF;
 #else
  #error "Please port gnulib fbufmode.c to your platform! Look at the setvbuf implementation."
 #endif
index e5d673a..eb18b76 100644 (file)
@@ -96,6 +96,14 @@ fpurge (FILE *fp)
   if (fp->_ptr != NULL)
     fp->_cnt = 0;
   return 0;
+# elif defined __UCLIBC__           /* uClibc */
+#  ifdef __STDIO_BUFFERS
+  if (fp->__modeflags & __FLAG_WRITING)
+    fp->__bufpos = fp->__bufstart;
+  else if (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING))
+    fp->__bufpos = fp->__bufread;
+#  endif
+  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 38fd015..c5bdd6e 100644 (file)
@@ -38,6 +38,8 @@ freading (FILE *fp)
   return (fp->_flags & __SRD) != 0;
 #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, mingw */
   return (fp->_flag & _IOREAD) != 0;
+#elif defined __UCLIBC__            /* uClibc */
+  return (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) != 0;
 #else
  #error "Please port gnulib freading.c to your platform!"
 #endif
index 006f8b2..1b51f88 100644 (file)
@@ -83,6 +83,11 @@ rpl_fseeko (FILE *fp, off_t offset, int whence)
   if (fp->_ptr == fp->_base
       && (fp->_ptr == NULL || fp->_cnt == 0))
 # endif
+#elif defined __UCLIBC__            /* uClibc */
+  if (((fp->__modeflags & __FLAG_WRITING) == 0
+       || fp->__bufpos == fp->__bufstart)
+      && ((fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) == 0
+         || fp->__bufpos == fp->__bufread))
 #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 8e9ac0a..d013742 100644 (file)
@@ -38,6 +38,8 @@ fseterr (FILE *fp)
 # else
   fp->_flag |= _IOERR;
 # endif
+#elif defined __UCLIBC__            /* uClibc */
+  fp->__modeflags |= __FLAG_ERROR;
 #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 3020537..1f02db3 100644 (file)
@@ -32,6 +32,8 @@ fwriting (FILE *fp)
   return (fp->_flags & __SWR) != 0;
 #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, mingw */
   return (fp->_flag & _IOWRT) != 0;
+#elif defined __UCLIBC__            /* uClibc */
+  return (fp->__modeflags & __FLAG_WRITING) != 0;
 #else
  #error "Please port gnulib fwriting.c to your platform!"
 #endif
index ef43ad7..8dd0f11 100755 (executable)
@@ -49,8 +49,8 @@ main (int argc, char *argv[])
       return 1;
     }
   /* For deterministic results, ensure f read a bigger buffer.
-     This is not the case on BeOS.  */
-#if !defined __BEOS__
+     This is not the case on BeOS, nor on uClibc.  */
+#if !(defined __BEOS__ || defined __UCLIBC__)
   if (lseek (fd, 0, SEEK_CUR) == 5)
     {
       fputs ("Sample file was not buffered after fread.\n", stderr);