[PATCH] D90201: Try reading a smaller chunk when (p)read fails
Jonas Devlieghere via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 26 20:01:33 PDT 2020
JDevlieghere updated this revision to Diff 300867.
JDevlieghere added a comment.
Seems like the issue might be specific to macOS (with a fixed max value of INT32_MAX).
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90201/new/
https://reviews.llvm.org/D90201
Files:
llvm/lib/Support/Unix/Path.inc
Index: llvm/lib/Support/Unix/Path.inc
===================================================================
--- llvm/lib/Support/Unix/Path.inc
+++ llvm/lib/Support/Unix/Path.inc
@@ -1075,14 +1075,19 @@
Expected<size_t> readNativeFileSlice(file_t FD, MutableArrayRef<char> Buf,
uint64_t Offset) {
+#if defined(__APPLE__)
+ size_t Size = Buf.size() < INT32_MAX ? Buf.size() : INT32_MAX;
+#else
+ size_t Size = Buf.size();
+#endif
#ifdef HAVE_PREAD
ssize_t NumRead =
- sys::RetryAfterSignal(-1, ::pread, FD, Buf.data(), Buf.size(), Offset);
+ sys::RetryAfterSignal(-1, ::pread, FD, Buf.data(), Size, Offset);
#else
if (lseek(FD, Offset, SEEK_SET) == -1)
return errorCodeToError(std::error_code(errno, std::generic_category()));
ssize_t NumRead =
- sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Buf.size());
+ sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size);
#endif
if (NumRead == -1)
return errorCodeToError(std::error_code(errno, std::generic_category()));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90201.300867.patch
Type: text/x-patch
Size: 1053 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201027/6ba12253/attachment-0001.bin>
More information about the llvm-commits
mailing list