bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fpending Android bug


From: Bruno Haible
Subject: Re: fpending Android bug
Date: Sun, 15 Jan 2023 11:10:49 +0100

Po Lu wrote:
> It doesn't compile because ->_p and ->_base are undefined in FILE *.
> ...
> I'm using the NDK r25b; however, bits/struct_file.h in the NDK r25b only
> includes:
> 
> __BEGIN_DECLS
> 
> /** The opaque structure implementing `FILE`. Do not make any assumptions 
> about its content. */
> struct __sFILE {
> #if defined(__LP64__)
>   char __private[152];
> #else
>   char __private[84];
> #endif
> } __attribute__((aligned(sizeof(void*))));
> 
> __END_DECLS
> 
> even when __ANDROID_API__ is 19.

Ah, now that makes sense: When they moved 'struct __sFILE' out of <stdio.h>
into <bits/struct_file.h>, they also removed its named fields.

In other words, looking at the timeline of the Android API level 19 support:
  - They added this support in NDK r10e,
  - In NDK r13b the elements of a FILE were accessible,
  - In NDK r14b the elements of a FILE were suddenly not accessible any more.

I'm applying your patch:


2023-01-15  Bruno Haible  <bruno@clisp.org>

        fpending: Fix compilation error with NDK ≥ r14b and Android API < 23.
        Report and patch by Po Lu <luangruo@yahoo.com>.
        * lib/fpending.c (__fpending) [__ANDROID__]: Use the fp_ macro.

diff --git a/lib/fpending.c b/lib/fpending.c
index afa840b851..e57155e586 100644
--- a/lib/fpending.c
+++ b/lib/fpending.c
@@ -41,7 +41,7 @@ __fpending (FILE *fp)
   return fp->_IO_write_ptr - fp->_IO_write_base;
 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
   /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin < 1.7.34, Minix 3, 
Android */
-  return fp->_p - fp->_bf._base;
+  return fp_->_p - fp_->_bf._base;
 #elif defined __EMX__                /* emx+gcc */
   return fp->_ptr - fp->_buffer;
 #elif defined __minix                /* Minix */






reply via email to

[Prev in Thread] Current Thread [Next in Thread]