If we receive a functions error via `GetLastError`, we can stringify it
via `FormatMessage`. Sadly `FormatMessage` isn't auto imported into
Swift, which is why we need to use the shim layer.
These are part of the BSD sockets APIs, but not directly related to the
socket interfaces. Create an extension point to permit the different
platforms to shuffle their implementation into place. This provides a
nicer spelling for the functions and enables the codepaths on Windows as
well.
This repairs the build on the CNIOWindows module on Windows. The `NIO`
macro is unavailable in the definition (intentionally) and was being
used accidentally.
These need to be filled out, but lets stub them out for the time being
to get the symbol resolution sorted out. These are possible to
implement using the WinSDK.
This adds the necessary code to add a module constructor for NIO. On
Windows, the socketing subsystem (WinSock) must be explicitly
initialized unlike Unices. Add a module constructor that will be
handled by the C runtime to initialize the subsystem before the module
code is executed so that the user does not need to worry about this.
Since there is no way to inject this in Swift, write a tiny helper in C
and link that into the final NIO binary.
Since swift-package-manager does not support mixed-language directories,
add this to `CNIOWindows` which will need to be statically linked and
must always be imported as `@_implementationOnly` as this cannot be
linked into any user libraries.
Co-authored-by: Cory Benfield <lukasa@apple.com>