Remove unused variables

This change is technically not required to support MSVC, but it was
detected by Microsoft's compiler.

[JES: fixed commit message]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Include Winsock2 header before windows.h include

That's because there are duplicate #defines, and when Winsock2 is defined
before windows.h then windows.h detects that and prevent redefinition.

See
http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/4a90b143-1fb8-43e9-a54c-956127e0c579/windowsh-and-winsock2h?forum=windowssdk

[JES: fixed commit message]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Use correct winsock header

We link to ws2_32.lib which corresponds to the winsock2.h header, not the
winsock.h header.

[JES: fixed commit message]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
MSVC: Use _snprintf instead of snprintf

In Microsoft's Visual C runtime, the snprintf() function is actually
called _snprintf. Let's just #define the former to call the latter.

[JES: fixed commit message]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add MSVC compatible unix headers

The stdint.h file was copied from:

	https://runexe.googlecode.com/svn-history/r9/trunk/src/runlib/msstdint.h

(we can incorporate it because it is licensed under the 3-clause BSD
license.)

[JES: fixed commit message, fixed stripped copyright header]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Use WIN32 for Windows-specific #ifdef guards

To support Microsoft Visual C++, we must not guard Windows-specific code
in MinGW-specific #ifdef guards.

Happily, even 64-bit MSVC defines the WIN32 constant, therefore we can use
that instead.

[JES: fixed commit message, reordered commit, split out unrelated changes]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
MSVC: Use the Unix emulation headers

[JES: provided commit message, split out unrelated changes]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Perform pointer arithmetic on char * instead of void *

Microsoft Visual C++ does not allow pointer arithmetic on void pointers.

[JES: fixed commit message]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Use Windows' critical sections to emulate pthread's mutexes

With Microsoft Visual C++, we cannot use pthreads (MinGW sports an
emulation library which is the reason we did not need Windows-specific
hacks earlier). Happily, it is very easy to provide Windows-specific
emulations for the pthread calls we use.

[JES: fixed commit message]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Merge branch 'msvc'

This topic branch provides compatibility for Windows, without the
MINGW32 dependency.

It is based on https://github.com/LibVNC/libvncserver/pull/22.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Fix tv_usec calculation

This bug was introduced in the MSVC patches.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>