|
5 | 5 | #define NOMINMAX
|
6 | 6 | #endif // !defined(NOMINMAX)
|
7 | 7 |
|
8 |
| -#if defined(__unix__) || defined(__APPLE__) || defined(__MINGW32__) |
| 8 | +#if defined(__unix__) || defined(__APPLE__) |
9 | 9 | #include <fcntl.h> // for open, O_RDONLY
|
10 | 10 | #include <sys/mman.h> // for mmap, mmap64, munmap
|
11 | 11 | #include <unistd.h> // for close, getpagesize
|
12 |
| -#elif defined(_MSC_VER) |
| 12 | +#elif defined(_MSC_VER) || defined(__MINGW32__) |
13 | 13 | #define WIN32_LEAN_AND_MEAN
|
14 | 14 | #include <windows.h>
|
15 | 15 | #endif // defined(__unix__)
|
@@ -231,7 +231,7 @@ char* PrivateMmapStream::Open(std::string path, bool read_only, std::size_t offs
|
231 | 231 | access = read_only ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS;
|
232 | 232 | std::uint32_t loff = static_cast<std::uint32_t>(view_start);
|
233 | 233 | std::uint32_t hoff = view_start >> 32;
|
234 |
| - CHECK(map_file) << "Failed to map: " << path << ". " << GetLastError(); |
| 234 | + CHECK(map_file) << "Failed to map: " << path << ". " << SystemErrorMsg(); |
235 | 235 | ptr = reinterpret_cast<char*>(MapViewOfFile(map_file, access, hoff, loff, view_size));
|
236 | 236 | CHECK_NE(ptr, nullptr) << "Failed to map: " << path << ". " << SystemErrorMsg();
|
237 | 237 | #else
|
@@ -261,16 +261,16 @@ PrivateMmapStream::~PrivateMmapStream() {
|
261 | 261 | CHECK(handle_);
|
262 | 262 | #if defined(_MSC_VER)
|
263 | 263 | if (p_buffer_) {
|
264 |
| - CHECK(UnmapViewOfFile(handle_->base_ptr)) "Faled to munmap." << GetLastError(); |
| 264 | + CHECK(UnmapViewOfFile(handle_->base_ptr)) "Faled to munmap. " << SystemErrorMsg(); |
265 | 265 | }
|
266 | 266 | if (handle_->fd != INVALID_HANDLE_VALUE) {
|
267 |
| - CHECK(CloseHandle(handle_->fd)); |
| 267 | + CHECK(CloseHandle(handle_->fd)) << "Failed to close handle. " << SystemErrorMsg(); |
268 | 268 | }
|
269 | 269 | #else
|
270 | 270 | CHECK_NE(munmap(handle_->base_ptr, handle_->base_size), -1)
|
271 |
| - << "Faled to munmap." << handle_->path << ". " << strerror(errno); |
| 271 | + << "Faled to munmap." << handle_->path << ". " << SystemErrorMsg(); |
272 | 272 | CHECK_NE(close(handle_->fd), -1)
|
273 |
| - << "Faled to close: " << handle_->path << ". " << strerror(errno); |
| 273 | + << "Faled to close: " << handle_->path << ". " << SystemErrorMsg(); |
274 | 274 | #endif
|
275 | 275 | }
|
276 | 276 | } // namespace common
|
|
0 commit comments