src/io.c: Some cleanup related to fseeko/ftello
Include <unistd.h> for the definition of _POSIX_VERSION. See
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/unistd.h.html
Add the AVIF_ prefix to USE_FSEEKO.
Remove the definition of the unused macro USE_FSEEK_FALLBACK.
diff --git a/src/io.c b/src/io.c
index a27cf38..823be1a 100644
--- a/src/io.c
+++ b/src/io.c
@@ -5,7 +5,7 @@
// Ensure off_t is 64 bits.
#undef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
-// Ensure we have some POSIX compatible with fseeko/ftello.
+// Ensure we have some POSIX compatibility with fseeko/ftello.
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112L
#endif
@@ -34,22 +34,19 @@
}
#else
+#include <unistd.h>
+
#if defined(__ANDROID__)
#include <android/api-level.h>
#if __ANDROID_API__ >= 24
-#define USE_FSEEKO
-#else
-#define USE_FSEEK_FALLBACK
+#define AVIF_USE_FSEEKO
#endif
#elif defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L
/* Standard Modern POSIX */
-#define USE_FSEEKO
-#else
-/* Unknown or very old platform */
-#define USE_FSEEK_FALLBACK
+#define AVIF_USE_FSEEKO
#endif
-#if defined(USE_FSEEKO)
+#if defined(AVIF_USE_FSEEKO)
// POSIX large file support
static_assert(sizeof(off_t) == sizeof(int64_t), "");
typedef off_t avif_off_t;
@@ -65,6 +62,7 @@
return ftello(stream);
}
#else
+// Unknown or very old platform. Fall back on fseek/ftell.
typedef long avif_off_t;
#define AVIF_OFF_MAX LONG_MAX
@@ -77,7 +75,7 @@
{
return ftell(stream);
}
-#endif // defined(USE_FSEEKO)
+#endif // defined(AVIF_USE_FSEEKO)
#endif // defined(_WIN32)