bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: Po Lu <luangruo@yahoo.com>
Cc: bug-gnulib@gnu.org
Subject: Re: fpending Android bug
Date: Sun, 15 Jan 2023 11:10:49 +0100	[thread overview]
Message-ID: <5411576.7OPFtVAQ6q@nimes> (raw)
In-Reply-To: <87sfgcbpza.fsf@yahoo.com>

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:
> /** 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*))));
> 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	other threads:[~2023-01-15 10:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87wn5pb3dv.fsf.ref@yahoo.com>
2023-01-14 14:24 ` fpending Android bug Po Lu
2023-01-14 17:07   ` Bruno Haible
2023-01-14 17:12     ` Bruno Haible
2023-01-15  0:28     ` Po Lu
2023-01-15 10:10       ` Bruno Haible [this message]
2023-01-15 11:11         ` Po Lu
2023-01-17 16:10         ` Bruno Haible

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5411576.7OPFtVAQ6q@nimes \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=luangruo@yahoo.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).