Use _chmod on Windows, when available.

Don't check for umask, not used.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3ee9024..dc2f03e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,6 +30,7 @@
 
 # Checks
 
+CHECK_FUNCTION_EXISTS(_chmod HAVE__CHMOD)
 CHECK_FUNCTION_EXISTS(_close HAVE__CLOSE)
 CHECK_FUNCTION_EXISTS(_dup HAVE__DUP)
 CHECK_FUNCTION_EXISTS(_fdopen HAVE__FDOPEN)
@@ -57,7 +58,6 @@
 CHECK_FUNCTION_EXISTS(stricmp HAVE_STRICMP)
 CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL)
 CHECK_FUNCTION_EXISTS(strtoull HAVE_STRTOULL)
-CHECK_FUNCTION_EXISTS(umask HAVE_UMASK)
 
 CHECK_INCLUDE_FILES(fts.h HAVE_FTS_H)
 CHECK_INCLUDE_FILES(stdbool.h HAVE_STDBOOL_H)
diff --git a/cmake-config.h.in b/cmake-config.h.in
index 60e5d15..2c2ade6 100644
--- a/cmake-config.h.in
+++ b/cmake-config.h.in
@@ -5,6 +5,7 @@
 #endif
 /* BEGIN DEFINES */
 #cmakedefine HAVE___PROGNAME
+#cmakedefine HAVE__CHMOD
 #cmakedefine HAVE__CLOSE
 #cmakedefine HAVE__DUP
 #cmakedefine HAVE__FDOPEN
diff --git a/configure.ac b/configure.ac
index 450ea69..b1b2f38 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,7 +74,7 @@
 
 LT_INIT
 
-AC_CHECK_FUNCS([_close _dup _fdopen _fileno _open _setmode _snprintf _strdup _stricmp _strtoi64 _strtoui64 _umask explicit_bzero explicit_memset fileno fseeko ftello getopt getprogname open setmode snprintf strcasecmp strdup stricmp strtoll strtoull umask])
+AC_CHECK_FUNCS([_chmod _close _dup _fdopen _fileno _open _setmode _snprintf _strdup _stricmp _strtoi64 _strtoui64 _umask explicit_bzero explicit_memset fileno fseeko ftello getopt getprogname open setmode snprintf strcasecmp strdup stricmp strtoll strtoull])
 AC_CHECK_FUNCS([mkstemp], [], [AC_LIBOBJ(mkstemp)])
 
 dnl assume dlsym in libc, but check in libdl
diff --git a/lib/compat.h b/lib/compat.h
index 6be9ee0..47e0c96 100644
--- a/lib/compat.h
+++ b/lib/compat.h
@@ -72,6 +72,9 @@
 #endif
 
 #ifdef _WIN32
+#if defined(HAVE__CHMOD)
+#define chmod		_chmod
+#endif
 #if defined(HAVE__CLOSE)
 #define close		_close
 #endif