[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 01/11] Fix FILE struct compatibility with Android API level >= 21
From: |
Kevin Cernekee |
Subject: |
[PATCH 01/11] Fix FILE struct compatibility with Android API level >= 21 |
Date: |
Wed, 11 Feb 2015 15:22:49 -0800 |
* lib/stdio-impl.h: Test explicitly for __ANDROID__ instead of
__sferror. Recent versions of Bionic's stdio.h no longer define
__sferror.
* lib/fbufmode.c: Likewise.
* lib/fflush.c: Likewise.
* lib/fpurge.c: Likewise.
* lib/freadable.c: Likewise.
* lib/freadahead.c: Likewise.
* lib/freading.c: Likewise.
* lib/freadptr.c: Likewise.
* lib/freadseek.c: Likewise.
* lib/fseeko.c: Likewise.
* lib/fseterr.c: Likewise.
* lib/fwritable.c: Likewise.
* lib/fwriting.c: Likewise.
---
ChangeLog | 19 +++++++++++++++++++
lib/fbufmode.c | 3 ++-
lib/fflush.c | 12 ++++++++----
lib/fpurge.c | 6 ++++--
lib/freadable.c | 3 ++-
lib/freadahead.c | 3 ++-
lib/freading.c | 3 ++-
lib/freadptr.c | 3 ++-
lib/freadseek.c | 3 ++-
lib/fseeko.c | 9 ++++++---
lib/fseterr.c | 3 ++-
lib/fwritable.c | 3 ++-
lib/fwriting.c | 3 ++-
lib/stdio-impl.h | 5 +++--
14 files changed, 58 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4b5092dd0e47..a6f26301f28d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2015-02-09 Kevin Cernekee <address@hidden>
+
+ Fix FILE struct compatibility with Android API level >= 21
+ * lib/stdio-impl.h: Test explicitly for __ANDROID__ instead of
+ __sferror. Recent versions of Bionic's stdio.h no longer define
+ __sferror.
+ * lib/fbufmode.c: Likewise.
+ * lib/fflush.c: Likewise.
+ * lib/fpurge.c: Likewise.
+ * lib/freadable.c: Likewise.
+ * lib/freadahead.c: Likewise.
+ * lib/freading.c: Likewise.
+ * lib/freadptr.c: Likewise.
+ * lib/freadseek.c: Likewise.
+ * lib/fseeko.c: Likewise.
+ * lib/fseterr.c: Likewise.
+ * lib/fwritable.c: Likewise.
+ * lib/fwriting.c: Likewise.
+
2015-02-08 Daiki Ueno <address@hidden>
uniname/unimame-tests: don't link with -lunistring
diff --git a/lib/fbufmode.c b/lib/fbufmode.c
index 1a37bdacf08a..d138b816958f 100644
--- a/lib/fbufmode.c
+++ b/lib/fbufmode.c
@@ -42,7 +42,8 @@ fbufmode (FILE *fp)
if (fp->_flags & _IO_UNBUFFERED)
return _IONBF;
return _IOFBF;
-#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
if (fp_->_flags & __SLBF)
return _IOLBF;
if (fp_->_flags & __SNBF)
diff --git a/lib/fflush.c b/lib/fflush.c
index 4b43a323e73f..5ae3e41793a8 100644
--- a/lib/fflush.c
+++ b/lib/fflush.c
@@ -50,7 +50,8 @@ clear_ungetc_buffer_preserving_position (FILE *fp)
static void
clear_ungetc_buffer (FILE *fp)
{
-# if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
if (HASUB (fp))
{
fp_->_p += fp_->_r;
@@ -73,7 +74,8 @@ clear_ungetc_buffer (FILE *fp)
#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS,
Haiku, Linux libc5 */)
-# if (defined __sferror || defined __DragonFly__) && defined __SNPT /*
FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
+# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) &&
defined __SNPT
+/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
static int
disable_seek_optimization (FILE *fp)
@@ -95,7 +97,8 @@ static void
update_fpos_cache (FILE *fp _GL_UNUSED_PARAMETER,
off_t pos _GL_UNUSED_PARAMETER)
{
-# if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
# if defined __CYGWIN__
/* fp_->_offset is typed as an integer. */
fp_->_offset = pos;
@@ -195,7 +198,8 @@ rpl_fflush (FILE *stream)
return result;
}
-# if (defined __sferror || defined __DragonFly__) && defined __SNPT /*
FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
+# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) &&
defined __SNPT
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
{
/* Disable seek optimization for the next fseeko call. This tells the
diff --git a/lib/fpurge.c b/lib/fpurge.c
index f8ad6926efef..f313b2217838 100644
--- a/lib/fpurge.c
+++ b/lib/fpurge.c
@@ -43,7 +43,8 @@ fpurge (FILE *fp)
extern int fpurge (FILE *);
# endif
int result = fpurge (fp);
-# if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
if (result == 0)
/* Correct the invariants that fpurge broke.
<stdio.h> on BSD systems says:
@@ -71,7 +72,8 @@ fpurge (FILE *fp)
fp->_IO_save_base = NULL;
}
return 0;
-# elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
fp_->_p = fp_->_bf._base;
fp_->_r = 0;
fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered
and not currently reading? */
diff --git a/lib/freadable.c b/lib/freadable.c
index e65e39d02783..3e7b7b5b42a8 100644
--- a/lib/freadable.c
+++ b/lib/freadable.c
@@ -33,7 +33,8 @@ freadable (FILE *fp)
fast macros. */
#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku,
Linux libc5 */
return (fp->_flags & _IO_NO_READS) == 0;
-#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
return (fp_->_flags & (__SRW | __SRD)) != 0;
#elif defined __EMX__ /* emx+gcc */
return (fp->_flags & (_IORW | _IOREAD)) != 0;
diff --git a/lib/freadahead.c b/lib/freadahead.c
index aa4b36746359..094daabfc6b7 100644
--- a/lib/freadahead.c
+++ b/lib/freadahead.c
@@ -31,7 +31,8 @@ freadahead (FILE *fp)
return (fp->_IO_read_end - fp->_IO_read_ptr)
+ (fp->_flags & _IO_IN_BACKUP ? fp->_IO_save_end - fp->_IO_save_base :
0);
-#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0)
return 0;
# if defined __DragonFly__
diff --git a/lib/freading.c b/lib/freading.c
index f6e5edd9cdfe..0512b190ad9e 100644
--- a/lib/freading.c
+++ b/lib/freading.c
@@ -35,7 +35,8 @@ freading (FILE *fp)
return ((fp->_flags & _IO_NO_WRITES) != 0
|| ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
&& fp->_IO_read_base != NULL));
-# elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
return (fp_->_flags & __SRD) != 0;
# elif defined __EMX__ /* emx+gcc */
return (fp->_flags & _IOREAD) != 0;
diff --git a/lib/freadptr.c b/lib/freadptr.c
index 7dc5e4756510..818c7ee607c3 100644
--- a/lib/freadptr.c
+++ b/lib/freadptr.c
@@ -37,7 +37,8 @@ freadptr (FILE *fp, size_t *sizep)
return NULL;
*sizep = size;
return (const char *) fp->_IO_read_ptr;
-#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0)
return NULL;
size = fp_->_r;
diff --git a/lib/freadseek.c b/lib/freadseek.c
index 4eedf0ad79c4..43a80cbe1287 100644
--- a/lib/freadseek.c
+++ b/lib/freadseek.c
@@ -38,7 +38,8 @@ freadptrinc (FILE *fp, size_t increment)
__freadptrinc (fp, increment);
#elif defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS,
Haiku, Linux libc5 */
fp->_IO_read_ptr += increment;
-#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
fp_->_p += increment;
fp_->_r -= increment;
#elif defined __EMX__ /* emx+gcc */
diff --git a/lib/fseeko.c b/lib/fseeko.c
index 46ee04bf70ce..db67e0277a17 100644
--- a/lib/fseeko.c
+++ b/lib/fseeko.c
@@ -51,7 +51,8 @@ fseeko (FILE *fp, off_t offset, int whence)
if (fp->_IO_read_end == fp->_IO_read_ptr
&& fp->_IO_write_ptr == fp->_IO_write_base
&& fp->_IO_save_base == NULL)
-#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
# if defined __SL64 && defined __SCLE /* Cygwin */
if ((fp->_flags & __SL64) == 0)
{
@@ -115,7 +116,8 @@ fseeko (FILE *fp, off_t offset, int whence)
off_t pos = lseek (fileno (fp), offset, whence);
if (pos == -1)
{
-#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
fp_->_flags &= ~__SOFF;
#endif
return -1;
@@ -124,7 +126,8 @@ fseeko (FILE *fp, off_t offset, int whence)
#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku,
Linux libc5 */
fp->_flags &= ~_IO_EOF_SEEN;
fp->_offset = pos;
-#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
# if defined __CYGWIN__
/* fp_->_offset is typed as an integer. */
fp_->_offset = pos;
diff --git a/lib/fseterr.c b/lib/fseterr.c
index c8cede820b9c..a35daa730ef7 100644
--- a/lib/fseterr.c
+++ b/lib/fseterr.c
@@ -31,7 +31,8 @@ fseterr (FILE *fp)
fast macros. */
#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku,
Linux libc5 */
fp->_flags |= _IO_ERR_SEEN;
-#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
fp_->_flags |= __SERR;
#elif defined __EMX__ /* emx+gcc */
fp->_flags |= _IOERR;
diff --git a/lib/fwritable.c b/lib/fwritable.c
index 55ba4314b7f4..cf614a5c17a0 100644
--- a/lib/fwritable.c
+++ b/lib/fwritable.c
@@ -33,7 +33,8 @@ fwritable (FILE *fp)
fast macros. */
#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku,
Linux libc5 */
return (fp->_flags & _IO_NO_WRITES) == 0;
-#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
return (fp_->_flags & (__SRW | __SWR)) != 0;
#elif defined __EMX__ /* emx+gcc */
return (fp->_flags & (_IORW | _IOWRT)) != 0;
diff --git a/lib/fwriting.c b/lib/fwriting.c
index 3e6b6c653c11..61756c44e556 100644
--- a/lib/fwriting.c
+++ b/lib/fwriting.c
@@ -29,7 +29,8 @@ fwriting (FILE *fp)
fast macros. */
#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku,
Linux libc5 */
return (fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) != 0;
-#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
return (fp_->_flags & __SWR) != 0;
#elif defined __EMX__ /* emx+gcc */
return (fp->_flags & _IOWRT) != 0;
diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
index 0509f861ebf0..502d891b2fc8 100644
--- a/lib/stdio-impl.h
+++ b/lib/stdio-impl.h
@@ -28,7 +28,8 @@
#include <errno.h> /* For detecting Plan9. */
-#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD,
DragonFly, Mac OS X, Cygwin */
+#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
# if defined __DragonFly__ /* DragonFly */
/* See
<http://www.dragonflybsd.org/cvsweb/src/lib/libc/stdio/priv_stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>.
*/
@@ -66,7 +67,7 @@
/* More fields, not relevant here. */
};
# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
-# else /* FreeBSD, NetBSD <= 1.5Z,
DragonFly, Mac OS X, Cygwin */
+# else /* FreeBSD, NetBSD <= 1.5Z,
DragonFly, Mac OS X, Cygwin, Android */
# define fp_ub fp_->_ub
# endif
--
2.2.0.rc0.207.ga3a616c
- [PATCH 00/11] Android compatibility, Kevin Cernekee, 2015/02/11
- [PATCH 01/11] Fix FILE struct compatibility with Android API level >= 21,
Kevin Cernekee <=
- [PATCH 02/11] Assume unbroken ungetc() on Android, Kevin Cernekee, 2015/02/11
- [PATCH 03/11] getdtablesize: Fix Android build, Kevin Cernekee, 2015/02/11
- [PATCH 04/11] localename: Fix Android build, Kevin Cernekee, 2015/02/11
- [PATCH 06/11] euidaccess: Fix Android build, Kevin Cernekee, 2015/02/11
- [PATCH 08/11] net_if: Handle content-free <net/if.h> system headers, Kevin Cernekee, 2015/02/11
- [PATCH 07/11] linkat_nofollow: Add fallback case for cross compiling, Kevin Cernekee, 2015/02/11
- [PATCH 05/11] getugroups: Fix Android build, Kevin Cernekee, 2015/02/11
- [PATCH 09/11] signal_h: Fix Android build, Kevin Cernekee, 2015/02/11
- [PATCH 11/11] getdtablesize: Fix RLIMIT_NOFILE fallback case, Kevin Cernekee, 2015/02/11