Improve portability checks.

This fix some compiling issues on CYGWIN.