[libcxx-commits] [libcxx] [libcxx] Use _ftelli64/_fseeki64 on Windows (PR #123128)
Hubert Tong via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Aug 13 22:00:59 PDT 2026
Martin =?utf-8?q?Storsjö?= <martin at martin.st>,
Martin =?utf-8?q?Storsjö?= <martin at martin.st>,
Martin =?utf-8?q?Storsjö?= <martin at martin.st>,
Martin =?utf-8?q?Storsjö?= <martin at martin.st>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/123128 at github.com>
================
@@ -936,31 +933,42 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
default:
return pos_type(off_type(-1));
}
-# if !_LIBCPP_HAS_OFF_T_FUNCTIONS
- if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence))
+ if (__fseek(__file_, __width > 0 ? __width * __off : 0, __whence))
return pos_type(off_type(-1));
- pos_type __r = ftell(__file_);
-# else
- if (::fseeko(__file_, __width > 0 ? __width * __off : 0, __whence))
- return pos_type(off_type(-1));
- pos_type __r = ftello(__file_);
-# endif
+ pos_type __r = __ftell(__file_);
__r.state(__st_);
return __r;
}
+template <class _CharT, class _Traits>
+int basic_filebuf<_CharT, _Traits>::__fseek(FILE* __file, pos_type __offset, int __whence) {
+# if defined(_LIBCPP_MSVCRT_LIKE)
+ return _fseeki64(__file, __offset, __whence);
+# elif defined(_NEWLIB_VERSION)
+ return fseek(__file, __offset, __whence);
+# else
+ return ::fseeko(__file, __offset, __whence);
----------------
hubert-reinterpretcast wrote:
What is the rationale for the asymmetric use of `::`?
For any possible ADL concern tied to `pos_type`, a more reliable solution would be to cast `__offset` to the type of the intended corresponding function parameter.
https://github.com/llvm/llvm-project/pull/123128
More information about the libcxx-commits
mailing list