changeset 8926:1d4c80b053f0

Add support for uClibc 0.9.29.
author Bruno Haible <bruno@clisp.org>
date Sat, 09 Jun 2007 01:27:49 +0000
parents 8cbef316a127
children 90623e8d6690
files ChangeLog lib/fbufmode.c lib/fpurge.c lib/freading.c lib/fseeko.c lib/fseterr.c lib/fwriting.c tests/test-fflush.c
diffstat 8 files changed, 38 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- a/lib/fbufmode.c
+++ b/lib/fbufmode.c
@@ -62,6 +62,12 @@
     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
--- a/lib/fpurge.c
+++ b/lib/fpurge.c
@@ -96,6 +96,14 @@
   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
--- a/lib/freading.c
+++ b/lib/freading.c
@@ -38,6 +38,8 @@
   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
--- a/lib/fseeko.c
+++ b/lib/fseeko.c
@@ -83,6 +83,11 @@
   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
--- a/lib/fseterr.c
+++ b/lib/fseterr.c
@@ -38,6 +38,8 @@
 # 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!
--- a/lib/fwriting.c
+++ b/lib/fwriting.c
@@ -32,6 +32,8 @@
   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
--- a/tests/test-fflush.c
+++ b/tests/test-fflush.c
@@ -49,8 +49,8 @@
       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);