Slightly reduce sensitivity to thread local win32 last error. (#9379)
commitef23a0655e04359455132ce06324b7a10b96fbc7
authorJay Krell <jay.krell@cornell.edu>
Mon, 9 Jul 2018 21:21:33 +0000 (9 14:21 -0700)
committerGitHub <noreply@github.com>
Mon, 9 Jul 2018 21:21:33 +0000 (9 14:21 -0700)
tree92a5213018fff0a53b3e6a5b716435adc8633d01
parentb1487b6116bc0c8c19d67b1207849d0740cadb18
Slightly reduce sensitivity to thread local win32 last error. (#9379)

It is too easily trashed, e.g. by mono_thread_info_uninstall_interrupt.

See https://github.com/mono/mono/pull/9104.
See https://github.com/Unity-Technologies/mono/commit/b6f1ba89f7ab285a0990e696e78798f7cf18dafb
Which this should be an alterate fix for, as discussed in 9104.

This is a small change, but ultimately we should be able to thread
gint32 *win32error around enough, such as to eliminate the thread local on Unix.
It doesn't appear to take much. Thread locals, it turns out, are not a good mechanism.
They are sensitive to loss as addressed here. They are slower to access than regular globals
or locals. They do have the advantage of "automatic threading through a callgraph", as long
as you are very careful with their use (this PR demonstrates that problem).

As well we could/should move the GetLastError calls down one layer on Win32,
from w32file.c to w32file-win32.c.

But this change addresses only ReadFile/WriteFile.

Also remove unnecessary void** vs. void* cast.
Also combine Unix mono_w32file_read and mono_w32file_write.
mono/metadata/appdomain.c
mono/metadata/sre-save.c
mono/metadata/w32file-unix.c
mono/metadata/w32file-win32.c
mono/metadata/w32file.c
mono/metadata/w32file.h