everbase/catta — pull request #2 by pesco (2014-08-26 13:16:03+00:00)
Title: Port the library to Windows

[Opening pull-request early for ongoing discussion.]

Target build environment (quoting @niklashofmann):
> Our Windows build environment for Everbase: Windows 7/8 32/64bit + Visual Studio 2013. Everbase uses cmake.

Tips from @gsliepen:
> I prefer cross-compiling on Linux; install mingw and then run ./configure --host=i686-w64-mingw32; make. It is faster and much less painful than trying to compile an autoconf project on Windows natively. An example of how to cross-compile tinc and the libraries it uses is here: http://tinc-vpn.org/examples/cross-compiling-windows-binary/ Some info about how to get MSVC to link the resulting DLLs is here: http://factisresearch.blogspot.se/2010/08/cross-compiling-dlls-with-linux.html It seems straightforward to me, but I have to admit that I never used MSVC myself, so it might be more complicated in practice.

Issue areas identified so far:
* `inet_ntop` (exists only as 'InetNtop' starting with Vista)
* `poll` (exists only as 'WSAPoll' starting with Vista and has portability problems (see below))
* `select` (usage differences)
* `uname` (does not exist on Windows)
* function return codes and error checks (Windows sockets are unsigned integers)
* `close` and other file descriptor functions do not work on Windows sockets (they are not file descriptors)
* `fcntl` (does not exist on Windows, parts supported by `socketioctl`)
* `readv`/`writev`/`iovec`/`uio.h` (do not exist on Windows)
* `pipe` (does not exist on Windows)
* `interface` is a keyword (syntax errors all over the code where it is used as an identifier)

Link dump:

"HOWTO Create and Deploy a Sample DLL using MinGW"
http://www.mingw.org/wiki/sampleDLL

"Porting Socket Applications to Winsock" (official Winsock documentation)
http://msdn.microsoft.com/en-us/library/ms740096(v=vs.85).aspx

"BSD Sockets Compatibility" (an unofficial guide)
http://tangentsoft.net/wskfaq/articles/bsd-compatibility.html

Portability problems with WSAPoll
http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/18769abd-fca0-4d3c-9884-1a38ce27ae90/wsapoll-and-nonblocking-connects-to-nonexistent-ports?forum=wsk

'sys/uio.h' and the 'iovec' structure (don't exist on Windows)
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/uio.h.html

Windows equivalent of pipe()
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365152(v=vs.85).aspx