From 555c3d668283df0cb7d4d29463db275cff9acecd Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 9 Jun 2007 01:27:49 +0000 Subject: [PATCH] Add support for uClibc 0.9.29. --- ChangeLog | 11 +++++++++++ lib/fbufmode.c | 6 ++++++ lib/fpurge.c | 8 ++++++++ lib/freading.c | 2 ++ lib/fseeko.c | 5 +++++ lib/fseterr.c | 2 ++ lib/fwriting.c | 2 ++ tests/test-fflush.c | 4 ++-- 8 files changed, 38 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 22f623a17c..663e4785eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-06-08 Bruno Haible + + 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 * m4/intlmacosx.m4: New file, extracted from gettext.m4. diff --git a/lib/fbufmode.c b/lib/fbufmode.c index 6df6a20050..58c3bc247a 100644 --- a/lib/fbufmode.c +++ b/lib/fbufmode.c @@ -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 diff --git a/lib/fpurge.c b/lib/fpurge.c index e5d673ae96..eb18b76840 100644 --- a/lib/fpurge.c +++ b/lib/fpurge.c @@ -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 diff --git a/lib/freading.c b/lib/freading.c index 38fd0155a6..c5bdd6eee7 100644 --- a/lib/freading.c +++ b/lib/freading.c @@ -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 diff --git a/lib/fseeko.c b/lib/fseeko.c index 006f8b29be..1b51f88f1b 100644 --- a/lib/fseeko.c +++ b/lib/fseeko.c @@ -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 diff --git a/lib/fseterr.c b/lib/fseterr.c index 8e9ac0ad9a..d0137428b3 100644 --- a/lib/fseterr.c +++ b/lib/fseterr.c @@ -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! diff --git a/lib/fwriting.c b/lib/fwriting.c index 302053733a..1f02db3f35 100644 --- a/lib/fwriting.c +++ b/lib/fwriting.c @@ -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 diff --git a/tests/test-fflush.c b/tests/test-fflush.c index ef43ad7dfe..8dd0f110c7 100755 --- a/tests/test-fflush.c +++ b/tests/test-fflush.c @@ -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); -- 2.30.2