+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.
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
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
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
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
# 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!
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
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);