llvm-project
d98d12cb - [libc++] Support file offsets larger than 2GB in basic_filebuf on 32-bit AIX and 32-bit glibc Linux (#215892)

Commit
13 days ago
[libc++] Support file offsets larger than 2GB in basic_filebuf on 32-bit AIX and 32-bit glibc Linux (#215892) Currently, opening files greater than 2GB on 32-bit AIX doesn't work, even with `_LARGE_FILES` defined in the user program. A similar issue exists with 32-bit glibc. On AIX, the `_LARGE_FILES` macro enables programs to handle large files (greater than 2GB). When `_LARGE_FILES` is defined, all data types, structures, and subroutine names are mapped to their 64-bit versions during preprocessing ([source](https://www.ibm.com/docs/en/aix/7.2.0?topic=volumes-writing-programs-that-access-large-files)). Since the shared library is pre-compiled, defining the macro in user programs doesn't affect fstream's open/seek/tell, causing failure with large files on 32-bit. Instead of building libc++ with `_LARGE_FILES` defined, which could cause ODR violations, we can swap `fopen`/`fseeko`/`ftello` calls with their 64-bit counter-parts. --------- Co-authored-by: Hubert Tong <hubert.reinterpretcast@gmail.com> Co-authored-by: Nikolas Klauser <nikolasklauser@berlin.de>
Author
Parents
Loading