Some cross-platform code cleanups.

Fixes for MinGW and clang with HS_DEBUGGING enabled.
Could include an 'errno' equivalent for POSIX