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 22f623a17c72468c2fe32e58f57475593ec22e89..663e4785eb0847c250e60fe6e0a89d16969999f8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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.
index 6df6a20050cbe7a1b7baf3bf2aa77a77dd180259..58c3bc247a418d52b39dcb5e0c65e7e8e0121a41 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 e5d673ae96c0ee663a475f29619930993fe208f9..eb18b76840d75f86e69eb44db072f7cef2664528 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 38fd0155a6ddec91900e099e26334f303c4d92e2..c5bdd6eee7393a1399cabba6bba14d09af013255 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 006f8b29be9b941fa3575837a818511236d73cad..1b51f88f1b72b001139b61335d40e1fdcbdcd82b 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 8e9ac0ad9ae14cf74402ff52a23f1e252945a16b..d0137428b3776dc8ec8d6e5289b41df7835ee279 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 302053733a31e718073917503930940a6c10860b..1f02db3f35bd88ce6caaf8d6e14ee10138c500ca 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 ef43ad7dfeb3c3f8d067c39e82055aca02930e40..8dd0f110c7b55c932ba906307b6424a5f20afa5c 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);