aom: common/tools_common.h: port f{seek,tell}o fix from libvpx

From f4eaf8b55e58102c3f9d2bab7658b9f6063ad400 Mon Sep 17 00:00:00 2001
From: James Zern <[EMAIL REDACTED]>
Date: Tue, 30 Apr 2024 16:20:47 -0700
Subject: [PATCH] common/tools_common.h: port f{seek,tell}o fix from libvpx

https://chromium-review.googlesource.com/c/webm/libvpx/+/5074786
bf0755418 Add the needed Android API level predicates.

Bug: aomedia:3561
Change-Id: Ie5c4b3134f3842cd55e5b07e22dffa4ba2584ea8
---
 common/tools_common.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/common/tools_common.h b/common/tools_common.h
index b31371c670..9d891d1561 100644
--- a/common/tools_common.h
+++ b/common/tools_common.h
@@ -37,8 +37,13 @@ typedef int64_t FileOffset;
 #define fseeko fseeko64
 #define ftello ftello64
 typedef off64_t FileOffset;
-#elif CONFIG_OS_SUPPORT
-#include <sys/types.h> /* NOLINT*/
+#elif CONFIG_OS_SUPPORT &&                                                  \
+    !(defined(__ANDROID__) && __ANDROID_API__ < 24 && !defined(__LP64__) && \
+      defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
+/* POSIX.1 has fseeko and ftello. fseeko and ftello are not available before
+ * Android API level 24. See
+ * https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md */
+#include <sys/types.h> /* NOLINT */
 typedef off_t FileOffset;
 /* Use 32-bit file operations in WebM file format when building ARM
  * executables (.axf) with RVCT. */