win: remove try-except outside MSVC

Fixes: https://github.com/libuv/libuv/issues/2407
PR-URL: https://github.com/libuv/libuv/pull/2412
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
This commit is contained in:
Crunkle 2019-08-08 12:20:16 +01:00 committed by cjihrig
parent be1e71916d
commit 813264add0
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5
2 changed files with 18 additions and 0 deletions

View File

@ -218,6 +218,11 @@ API
Equivalent to :man:`preadv(2)`.
.. warning::
On Windows, under non-MSVC environments (e.g. when GCC or Clang is used
to build libuv), files opened using ``UV_FS_O_FILEMAP`` may cause a fatal
crash if the memory mapped read operation fails.
.. c:function:: int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
Equivalent to :man:`unlink(2)`.
@ -226,6 +231,11 @@ API
Equivalent to :man:`pwritev(2)`.
.. warning::
On Windows, under non-MSVC environments (e.g. when GCC or Clang is used
to build libuv), files opened using ``UV_FS_O_FILEMAP`` may cause a fatal
crash if the memory mapped write operation fails.
.. c:function:: int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb)
Equivalent to :man:`mkdir(2)`.

View File

@ -786,10 +786,13 @@ void fs__read_filemap(uv_fs_t* req, struct uv__fd_info_s* fd_info) {
int err = 0;
size_t this_read_size = MIN(req->fs.info.bufs[index].len,
read_size - done_read);
#ifdef _MSC_VER
__try {
#endif
memcpy(req->fs.info.bufs[index].base,
(char*)view + view_offset + done_read,
this_read_size);
#ifdef _MSC_VER
}
__except (fs__filemap_ex_filter(GetExceptionCode(),
GetExceptionInformation(), &err)) {
@ -797,6 +800,7 @@ void fs__read_filemap(uv_fs_t* req, struct uv__fd_info_s* fd_info) {
UnmapViewOfFile(view);
return;
}
#endif
done_read += this_read_size;
}
assert(done_read == read_size);
@ -978,10 +982,13 @@ void fs__write_filemap(uv_fs_t* req, HANDLE file,
done_write = 0;
for (index = 0; index < req->fs.info.nbufs; ++index) {
int err = 0;
#ifdef _MSC_VER
__try {
#endif
memcpy((char*)view + view_offset + done_write,
req->fs.info.bufs[index].base,
req->fs.info.bufs[index].len);
#ifdef _MSC_VER
}
__except (fs__filemap_ex_filter(GetExceptionCode(),
GetExceptionInformation(), &err)) {
@ -989,6 +996,7 @@ void fs__write_filemap(uv_fs_t* req, HANDLE file,
UnmapViewOfFile(view);
return;
}
#endif
done_write += req->fs.info.bufs[index].len;
}
assert(done_write == write_size);