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.