Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: third_party/crashpad/crashpad/util/file/file_writer.cc

Issue 2478633002: Update Crashpad to b47bf6c250c6b825dee1c5fbad9152c2c962e828 (Closed)
Patch Set: mac comment 2 Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 // Get an iovec*, because that’s what writev wants. The only difference 67 // Get an iovec*, because that’s what writev wants. The only difference
68 // between WritableIoVec and iovec is that WritableIoVec’s iov_base is a 68 // between WritableIoVec and iovec is that WritableIoVec’s iov_base is a
69 // pointer to a const buffer, where iovec’s iov_base isn’t. writev doesn’t 69 // pointer to a const buffer, where iovec’s iov_base isn’t. writev doesn’t
70 // actually write to the data, so this cast is safe here. iovec’s iov_base is 70 // actually write to the data, so this cast is safe here. iovec’s iov_base is
71 // non-const because the same structure is used for readv and writev, and 71 // non-const because the same structure is used for readv and writev, and
72 // readv needs to write to the buffer that iov_base points to. 72 // readv needs to write to the buffer that iov_base points to.
73 iovec* iov = reinterpret_cast<iovec*>(&(*iovecs)[0]); 73 iovec* iov = reinterpret_cast<iovec*>(&(*iovecs)[0]);
74 size_t remaining_iovecs = iovecs->size(); 74 size_t remaining_iovecs = iovecs->size();
75 75
76 #if defined(OS_ANDROID)
77 // Android does not expose the IOV_MAX macro, but makes its value available
78 // via sysconf(). See Android 7.0.0 bionic/libc/bionic/sysconf.cpp sysconf().
79 // Bionic defines IOV_MAX at bionic/libc/include/limits.h, but does not ship
80 // this file to the NDK as <limits.h>, substituting
81 // bionic/libc/include/bits/posix_limits.h.
82 const size_t kIovMax = sysconf(_SC_IOV_MAX);
83 #else
84 const size_t kIovMax = IOV_MAX;
85 #endif
86
76 while (size > 0) { 87 while (size > 0) {
77 size_t writev_iovec_count = 88 size_t writev_iovec_count = std::min(remaining_iovecs, kIovMax);
78 std::min(remaining_iovecs, implicit_cast<size_t>(IOV_MAX));
79 ssize_t written = 89 ssize_t written =
80 HANDLE_EINTR(writev(file_handle_, iov, writev_iovec_count)); 90 HANDLE_EINTR(writev(file_handle_, iov, writev_iovec_count));
81 if (written < 0) { 91 if (written < 0) {
82 PLOG(ERROR) << "writev"; 92 PLOG(ERROR) << "writev";
83 return false; 93 return false;
84 } else if (written == 0) { 94 } else if (written == 0) {
85 LOG(ERROR) << "writev: returned 0"; 95 LOG(ERROR) << "writev: returned 0";
86 return false; 96 return false;
87 } 97 }
88 98
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 DCHECK(file_.is_valid()); 181 DCHECK(file_.is_valid());
172 return weak_file_handle_file_writer_.WriteIoVec(iovecs); 182 return weak_file_handle_file_writer_.WriteIoVec(iovecs);
173 } 183 }
174 184
175 FileOffset FileWriter::Seek(FileOffset offset, int whence) { 185 FileOffset FileWriter::Seek(FileOffset offset, int whence) {
176 DCHECK(file_.is_valid()); 186 DCHECK(file_.is_valid());
177 return weak_file_handle_file_writer_.Seek(offset, whence); 187 return weak_file_handle_file_writer_.Seek(offset, whence);
178 } 188 }
179 189
180 } // namespace crashpad 190 } // namespace crashpad
OLDNEW
« no previous file with comments | « third_party/crashpad/crashpad/tools/mac/run_with_crashpad.cc ('k') | third_party/crashpad/crashpad/util/misc/clock_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698