[w32file] Push coop transitions into functions, closer to syscalls (#4370)
authorAleksey Kliger (λgeek) <akliger@gmail.com>
Tue, 14 Feb 2017 16:41:38 +0000 (11:41 -0500)
committerGitHub <noreply@github.com>
Tue, 14 Feb 2017 16:41:38 +0000 (11:41 -0500)
commitf238640c9ff855bc5c2ab812cf21fd747a624dc9
tree7e46ba45584f60a22a47dd8ccb3c95928a8362ce
parent16edc1e552f348a5ccdcd0b6e0c191c902f97422
[w32file] Push coop transitions into functions, closer to syscalls (#4370)

* [w32file] Push coop transitions into functions, closer to syscalls

Previous the coop transitions happened in the icalls and high level
platform-independent functions.  Now they surround syscalls and platform API
calls, instead.

(Among other benefits, this fixes a problem where MoveFile on unix was
implemented in some circumstances in terms of CopyFile which resulted in an
illegal coop transition from blocking to blocking.)

* There is a FIXME with `mono_w32handle_new_fd` and `mono_w32handle_close`: the w32handle API is not coop-friendly yet, so we have to switch to gc safe mode around calls to `w32handle_new_fd` and `w32handle_close`.  In the case of `w32handle_close`, it calls back into the w32file functions `pipe_close`, `console_close` and `file_close`.  So the calls to `close(2)` inside those functions are not surrounded by transitions to GC safe mode - instead they require that we're already in safe mode (as is the case when they're called from w32handle).
mono/metadata/w32file-unix.c
mono/metadata/w32file-win32.c
mono/metadata/w32file.c