]> Savannah Git Hosting - gnulib.git/commitdiff
stdioext: Fix compilation errors with newer Android headers.
authorBruno Haible <bruno@clisp.org>
Sat, 12 May 2018 18:58:58 +0000 (20:58 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 13 May 2018 11:47:48 +0000 (13:47 +0200)
* lib/stdio-impl.h (fp_, fp_ub): Define differently for Android.
(__SLBF, __SNBF, __SRD, __SWR, __SRW, __SEOF, __SERR, __SOFF): Define
fallbacks for Android.
* lib/fpending.c: Update comments.
* lib/fpurge.c: Likewise.
* lib/freadable.h: Likewise.
* lib/freadable.c: Likewise.
* lib/freadahead.c: Likewise.
* lib/freading.h: Likewise.
* lib/freadptr.c: Likewise.
* lib/fseterr.c: Likewise.
* lib/fwritable.h: Likewise.
* lib/fwritable.c: Likewise.
* lib/fwriting.h: Likewise.
* lib/fwriting.c: Likewise.

14 files changed:
ChangeLog
lib/fpending.c
lib/fpurge.c
lib/freadable.c
lib/freadable.h
lib/freadahead.c
lib/freading.h
lib/freadptr.c
lib/fseterr.c
lib/fwritable.c
lib/fwritable.h
lib/fwriting.c
lib/fwriting.h
lib/stdio-impl.h

index 0bd75bbc24950269a49337ead74badf6dbe3907b..f4c0138511ccf6826fc03331090d11b306687c5c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2018-05-13  Bruno Haible  <bruno@clisp.org>
+
+       stdioext: Fix compilation errors with newer Android headers.
+       * lib/stdio-impl.h (fp_, fp_ub): Define differently for Android.
+       (__SLBF, __SNBF, __SRD, __SWR, __SRW, __SEOF, __SERR, __SOFF): Define
+       fallbacks for Android.
+       * lib/fpending.c: Update comments.
+       * lib/fpurge.c: Likewise.
+       * lib/freadable.h: Likewise.
+       * lib/freadable.c: Likewise.
+       * lib/freadahead.c: Likewise.
+       * lib/freading.h: Likewise.
+       * lib/freadptr.c: Likewise.
+       * lib/fseterr.c: Likewise.
+       * lib/fwritable.h: Likewise.
+       * lib/fwritable.c: Likewise.
+       * lib/fwriting.h: Likewise.
+       * lib/fwriting.c: Likewise.
+
 2018-05-13  Bruno Haible  <bruno@clisp.org>
 
        doc: Add info about Android versions 2.0 to 8.1.
index 7bc235deda2073f77db7f119c4312a299f604f6d..de370d4b10f6623a0e44eff8222d398878a1111f 100644 (file)
@@ -24,6 +24,9 @@
 
 #include "stdio-impl.h"
 
+/* This file is not used on systems that already have the __fpending function,
+   namely glibc >= 2.2, Solaris >= 7, Android API >= 23.  */
+
 /* Return the number of pending (aka buffered, unflushed)
    bytes on the stream, FP, that is open for writing.  */
 size_t
index 554790b562b5cf21ebbe68e63bdff6fe8c64769b..f9c82cdadd55cd07d5d769b258a8a305ff199b76 100644 (file)
@@ -19,7 +19,7 @@
 /* Specification.  */
 #include <stdio.h>
 
-#if HAVE___FPURGE                   /* glibc >= 2.2, Haiku, Solaris >= 7 */
+#if HAVE___FPURGE                   /* glibc >= 2.2, Haiku, Solaris >= 7, Android API >= 23 */
 # include <stdio_ext.h>
 #endif
 #include <stdlib.h>
@@ -29,7 +29,7 @@
 int
 fpurge (FILE *fp)
 {
-#if HAVE___FPURGE                   /* glibc >= 2.2, Haiku, Solaris >= 7, musl libc */
+#if HAVE___FPURGE                   /* glibc >= 2.2, Haiku, Solaris >= 7, Android API >= 23, musl libc */
 
   __fpurge (fp);
   /* The __fpurge function does not have a return value.  */
index 53cdbee08ac82c99d99c484a0790953467dd978a..f4ce079202fd8201ebf3595f49c30114649a001a 100644 (file)
@@ -25,6 +25,9 @@
 # include <fcntl.h>
 #endif
 
+/* This file is not used on systems that have the __freadable function,
+   namely glibc >= 2.2, Solaris >= 7, Android API >= 23, musl libc.  */
+
 bool
 freadable (FILE *fp)
 {
index 000e95babd68d8495aab68a891a097ea270995be..4b51570d5ee688041e9935d8959e3021cf8ebdec 100644 (file)
@@ -22,7 +22,7 @@
    STREAM must not be wide-character oriented.
    The result doesn't change until the stream is closed or re-opened.  */
 
-#if HAVE___FREADABLE /* glibc >= 2.2, Solaris >= 7, musl libc */
+#if HAVE___FREADABLE /* glibc >= 2.2, Solaris >= 7, Android API >= 23, musl libc */
 
 # include <stdio_ext.h>
 # define freadable(stream) (__freadable (stream) != 0)
index ed3dd0ebdaa94953e37019301e97145991d7fab1..fd5411c57eba218fdbda918faabacaec3b7c71e8 100644 (file)
@@ -27,6 +27,9 @@
 extern size_t __sreadahead (FILE *);
 #endif
 
+/* This file is not used on systems that have the __freadahead function,
+   namely musl libc.  */
+
 size_t
 freadahead (FILE *fp)
 {
index 29d92b13916f81a7fef8590ceb4384a015d3ad5d..31d71fdb759f98a1b127eb60aaf7e1d21d1c643e 100644 (file)
@@ -33,7 +33,7 @@
    STREAM must not be wide-character oriented.  */
 
 #if HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7))
-/* Solaris >= 7, not glibc >= 2.2, but glibc >= 2.7, or musl libc  */
+/* Solaris >= 7, Android API >= 29, not glibc >= 2.2, but glibc >= 2.7, or musl libc  */
 
 # include <stdio_ext.h>
 # define freading(stream) (__freading (stream) != 0)
index 3afa6214924ec86bca67442238dc1d60f26726a0..91765595fd1c749d058e50f3445ad937669e50e3 100644 (file)
@@ -23,6 +23,9 @@
 
 #include "stdio-impl.h"
 
+/* This file is not used on systems that have the __freadptr function,
+   namely musl libc.  */
+
 const char *
 freadptr (FILE *fp, size_t *sizep)
 {
index fd9da63381a53b06c944d55e56405ee176b5eaea..81f51edade3efb01647d9ea5c120e114d1c2aa93 100644 (file)
@@ -23,6 +23,9 @@
 
 #include "stdio-impl.h"
 
+/* This file is not used on systems that have the __fseterr function,
+   namely musl libc.  */
+
 void
 fseterr (FILE *fp)
 {
index 24a148aee2ad66396344a8069316fb8960a5617a..79e7c38ac7c19b07149c699b5d71b9f426017b20 100644 (file)
@@ -25,6 +25,9 @@
 # include <fcntl.h>
 #endif
 
+/* This file is not used on systems that have the __fwritable function,
+   namely glibc >= 2.2, Solaris >= 7, Android API >= 23, musl libc.  */
+
 bool
 fwritable (FILE *fp)
 {
index 1821352d0cea448d4c4a1ebd277a80de78549c2e..43ce3d6772b816a2ba778c65cd734a01d18b9caf 100644 (file)
@@ -22,7 +22,7 @@
    STREAM must not be wide-character oriented.
    The result doesn't change until the stream is closed or re-opened.  */
 
-#if HAVE___FWRITABLE /* glibc >= 2.2, Solaris >= 7, musl libc */
+#if HAVE___FWRITABLE /* glibc >= 2.2, Solaris >= 7, Android API >= 23, musl libc */
 
 # include <stdio_ext.h>
 # define fwritable(stream) (__fwritable (stream) != 0)
index 9be6fb2200024e7179c7e74e871942297fb85a61..4ffa12d32195a6adfd0e560e718346b92b92b917 100644 (file)
@@ -21,6 +21,9 @@
 
 #include "stdio-impl.h"
 
+/* This file is not used on systems that have the __fwritable function,
+   namely glibc >= 2.2, Solaris >= 7, Android API >= 29, musl libc.  */
+
 bool
 fwriting (FILE *fp)
 {
index f2a6c5ecb5d415993535010bef2fc21a6ec0d162..42f7e9435ab92489f4cad7318df4d80ab08b7524 100644 (file)
@@ -33,7 +33,7 @@
 
    STREAM must not be wide-character oriented.  */
 
-#if HAVE___FWRITING /* glibc >= 2.2, Solaris >= 7, musl libc */
+#if HAVE___FWRITING /* glibc >= 2.2, Solaris >= 7, Android API >= 29, musl libc */
 
 # include <stdio_ext.h>
 # define fwriting(stream) (__fwriting (stream) != 0)
index 7a0ac4d50b70c5ad3d3b63d7f3274ba5d6df43a3..393ef0cf58d013ec18cfcbb2ee120c4d1df7e028 100644 (file)
 #  define _flags pub._flags
 #  define _r pub._r
 #  define _w pub._w
+# elif defined __ANDROID__ /* Android */
+  /* Up to this commit from 2015-10-12
+     <https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a>
+     the innards of FILE were public, and fp_ub could be defined like for OpenBSD,
+     see <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/fileext.h>
+     and <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/local.h>.
+     After this commit, the innards of FILE are hidden.  */
+#  define fp_ ((struct { unsigned char *_p; \
+                         int _r; \
+                         int _w; \
+                         int _flags; \
+                         int _file; \
+                         struct { unsigned char *_base; size_t _size; } _bf; \
+                         int _lbfsize; \
+                         void *_cookie; \
+                         void *_close; \
+                         void *_read; \
+                         void *_seek; \
+                         void *_write; \
+                         struct { unsigned char *_base; size_t _size; } _ext; \
+                         unsigned char *_up; \
+                         int _ur; \
+                         unsigned char _ubuf[3]; \
+                         unsigned char _nbuf[1]; \
+                         struct { unsigned char *_base; size_t _size; } _lb; \
+                         int _blksize; \
+                         fpos_t _offset; \
+                         /* More fields, not relevant here.  */ \
+                       } *) fp)
 # else
 #  define fp_ fp
 # endif
 
-# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix || defined __ANDROID__ /* NetBSD >= 1.5ZA, OpenBSD, Minix 3, Android */
+# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */
   /* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
-     and <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> */
+     and <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
+     and <https://github.com/Stichting-MINIX-Research-Foundation/minix/blob/master/lib/libc/stdio/fileext.h> */
   struct __sfileext
     {
       struct  __sbuf _ub; /* ungetc buffer */
       /* More fields, not relevant here.  */
     };
 #  define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
-# else                                         /* FreeBSD, NetBSD <= 1.5Z, DragonFly, Mac OS X, Cygwin, Android */
+# elif defined __ANDROID__                     /* Android */
+  struct __sfileext
+    {
+      struct { unsigned char *_base; size_t _size; } _ub; /* ungetc buffer */
+      /* More fields, not relevant here.  */
+    };
+#  define fp_ub ((struct __sfileext *) fp_->_ext._base)->_ub
+# else                                         /* FreeBSD, NetBSD <= 1.5Z, DragonFly, Mac OS X, Cygwin */
 #  define fp_ub fp_->_ub
 # endif
 
 # define HASUB(fp) (fp_ub._base != NULL)
 
+# if defined __ANDROID__ /* Android */
+  /* Needed after this commit from 2016-01-25
+     <https://android.googlesource.com/platform/bionic.git/+/e70e0e9267d069bf56a5078c99307e08a7280de7> */
+#  ifndef __SEOF
+#   define __SLBF 1
+#   define __SNBF 2
+#   define __SRD 4
+#   define __SWR 8
+#   define __SRW 0x10
+#   define __SEOF 0x20
+#   define __SERR 0x40
+#  endif
+#  ifndef __SOFF
+#   define __SOFF 0x1000
+#  endif
+# endif
+
 #endif