Windows: Use overlapped I/O, CreateFile
authorDavid Lichteblau <david@lichteblau.com>
Tue, 18 Sep 2012 15:12:19 +0000 (17:12 +0200)
committerDavid Lichteblau <david@lichteblau.com>
Fri, 19 Oct 2012 16:07:24 +0000 (18:07 +0200)
commit7572e0506af331534e6f97b027d56e8bea09410c
tree29bd3643e54917f2825a49ff3f92bed523e0107d
parent67f44c921881037d272c5245f0ca2ab74ce1f763
Windows: Use overlapped I/O, CreateFile

Overlapped I/O is win32's asynchronous I/O mechanism, which allows
us to start an I/O operation and explicitly wait for it to finish at
a time of our choosing, such that we can simultaneously await other
events instead of blocking unconditionally.

  - Support for overlapped I/O is a per-HANDLE flag specified at
    file opening time, necessitating a switch to win32's CreateFile
    and away from the CRT's _open.

  - Wrap win32 file operations in POSIX-compatible functions, so
    that UNIX-OPEN, UNIX-READ, UNIX-WRITE, UNIX-CLOSE continue to
    work as before.  Under the hood, these now call our Lisp or C
    functions instead of versions from CRT.

  - For now, these functions still return and expect what passes as
    file descriptors in CRT.

  - INTERRUPT-THREAD is now capable of performing the interruption
    in a target thread blocked in socket I/O, indicated using an
    errno of "EINTR".  Minor changes in FD streams to retry the I/O
    operation explicitly in that case.

Does not yet include changes for console I/O, and instead still
falls back to _read and _write in that case.  Also not yet included
is interruptible non-overlapped I/O, e.g. for unnamed pipes.

Thanks to Anton Kovalenko.
contrib/sb-bsd-sockets/win32-sockets.lisp
package-data-list.lisp-expr
src/code/fd-stream.lisp
src/code/unix.lisp
src/code/win32.lisp
src/runtime/Config.x86-win32
src/runtime/print.c
src/runtime/runtime.h
src/runtime/safepoint.c
src/runtime/win32-os.c
tools-for-build/grovel-headers.c