Cleanup portability/compatibility layer

* Removes mingw-compat.h
* Cleans up separation of compiler/platform idiosyncrasies
* Unifies mingw/msvc stat structures and functions
* (Tries to) hide more compiler specific implementation details (even in our internal API)
Consistently use p_snprintf
Use p_snprintf also in tests
Use p_strcasecmp/p_strncasecmp instead of strcasecmp/strncasecmp
Move p_realpath logic to realpath.c
Introduce some consistency in definition/declaration ordering