[libcxx-commits] [libcxx] [libc++] Support file offsets larger than 2GB in basic_filebuf on 32-bit AIX and 32-bit glibc Linux (PR #215892)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Aug 14 00:42:04 PDT 2026
================
@@ -217,6 +217,20 @@ typedef basic_fstream<wchar_t> wfstream;
# pragma GCC system_header
# endif
+# if defined(_AIX) || (defined(__linux__) && defined(__GLIBC__))
+# define _LIBCPP_HAS_LARGEFILE_API 1
+# else
+# define _LIBCPP_HAS_LARGEFILE_API 0
+# endif
+
+# if _LIBCPP_HAS_LARGEFILE_API
+// On AIX and glibc on Linux, fopen64/fseeko64/ftello64 are not guaranteed to always be declared, so we declare them
+// here. They are not POSIX-reserved names, so we use __asm__ to guard them against a user #define.
+extern "C" FILE* __libcpp_fopen64(const char*, const char*) __asm__("fopen64");
+extern "C" long long __libcpp_ftello64(FILE*) __asm__("ftello64");
+extern "C" int __libcpp_fseeko64(FILE*, long long, int) __asm__("fseeko64");
+# endif
----------------
philnik777 wrote:
I'm not a huge fan of this. We're assuming that the libc never wants to change what function is called. IMO this is a horrible hack and if at all possible we should avoid it.
https://github.com/llvm/llvm-project/pull/215892
More information about the libcxx-commits
mailing list