diff --git a/configure.ac b/configure.ac
index 595199e1..ed747015 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,7 @@ AC_TYPE_PID_T
 AC_TYPE_OFF_T
 AC_TYPE_SIZE_T
 AC_TYPE_SSIZE_T
+AC_TYPE_INTMAX_T
 AC_TYPE_UINTMAX_T
 
 # Find out whether our struct stat returns nanosecond resolution timestamps.
diff --git a/src/config.ami.template b/src/config.ami.template
index c79593e6..d741b7e4 100644
--- a/src/config.ami.template
+++ b/src/config.ami.template
@@ -37,6 +37,10 @@ this program.  If not, see <http://www.gnu.org/licenses/>.  */
 /* Define for DGUX with <sys/dg_sys_info.h>.  */
 /* #undef DGUX */
 
+/* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
+   not define. */
+#define intmax_t long
+
 /* Define to 'unsigned long' or 'unsigned long long'
    if <inttypes.h> doesn't define.  */
 #define uintmax_t unsigned long
diff --git a/src/config.h-vms.template b/src/config.h-vms.template
index 900b4468..a08905e2 100644
--- a/src/config.h-vms.template
+++ b/src/config.h-vms.template
@@ -65,6 +65,10 @@ this program.  If not, see <http://www.gnu.org/licenses/>.  */
 /* Define for DGUX with <sys/dg_sys_info.h>.  */
 /* #undef DGUX */
 
+/* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
+   not define. */
+#define intmax_t unsigned long
+
 /* Define to 'unsigned long' or 'unsigned long long'
    if <inttypes.h> doesn't define.  */
 #define uintmax_t unsigned long
diff --git a/src/config.h.W32.template b/src/config.h.W32.template
index 1a4caa45..03a05ce3 100644
--- a/src/config.h.W32.template
+++ b/src/config.h.W32.template
@@ -177,6 +177,9 @@ this program.  If not, see <http://www.gnu.org/licenses/>.  */
 /* Define to 1 if you have the <locale.h> header file. */
 /* #undef HAVE_LOCALE_H */
 
+/* Define to 1 if the system has the type 'long long int'. */
+#define HAVE_LONG_LONG_INT 1
+
 /* Define to 1 if you have the 'lstat' function. */
 /* #undef HAVE_LSTAT */
 
@@ -390,6 +393,9 @@ this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #define HAVE_TTYNAME 1
 char *ttyname (int);
 
+/* Define to 1 if the system has the type `intmax_t'. */
+#define HAVE_INTMAX_T 1
+
 /* Define to 1 if the system has the type `uintmax_t'. */
 #define HAVE_UINTMAX_T 1
 
@@ -547,6 +553,14 @@ char *ttyname (int);
 # define __USE_MINGW_ANSI_STDIO 1
 #endif
 
+/* Number of bits in a timestamp, on hosts where this is settable. */
+/* #undef _TIME_BITS */
+
+/* For 64-bit time_t on 32-bit mingw. */
+#ifdef __MINGW32__
+# define __MINGW_USE_VC2005_COMPAT 1
+#endif
+
 #include <sys/types.h>
 
 /* Define to 'int' if <sys/types.h> doesn't define. */
@@ -568,9 +582,10 @@ char *ttyname (int);
 /* Define to 'int' if <sys/types.h> doesn't define. */
 #define uid_t int
 
-/* Define uintmax_t if not defined in <stdint.h> or <inttypes.h>. */
+/* Define {u,}intmax_t if not defined in <stdint.h> or <inttypes.h>. */
 #if !HAVE_STDINT_H && !HAVE_INTTYPES_H
-#define uintmax_t unsigned long
+#define intmax_t long long
+#define uintmax_t unsigned long long
 #endif
 
 /* Define if you have <sys/wait.h> that is POSIX.1 compatible.  */
diff --git a/src/configh.dos.template b/src/configh.dos.template
index addbf2e3..3f0f6e0a 100644
--- a/src/configh.dos.template
+++ b/src/configh.dos.template
@@ -49,6 +49,9 @@ this program.  If not, see <http://www.gnu.org/licenses/>.  */
 /* Define to 1 if you have the 'getgroups' function. */
 #define HAVE_GETGROUPS 1
 
+/* Define to 1 if the system has the type 'long long int'. */
+#define HAVE_LONG_LONG_INT 1
+
 /* Define to 1 if you have the <memory.h> header file.  */
 #define HAVE_MEMORY_H 1
 
@@ -66,13 +69,6 @@ this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #define SCCS_GET "get"
 
-/* Define to 'unsigned long' or 'unsigned long long'
-   if <inttypes.h> doesn't define.  */
-#define uintmax_t unsigned long long
-
-/* Define the type of the first arg to select().  */
-#define fd_set_size_t int
-
 /* Define to 1 if you have the select function.  */
 #define HAVE_SELECT 1
 
@@ -112,5 +108,16 @@ this program.  If not, see <http://www.gnu.org/licenses/>.  */
 /* Grok DOS paths (drive specs and backslash path element separators) */
 #define HAVE_DOS_PATHS
 
+/* Define the type of the first arg to select().  */
+#define fd_set_size_t int
+
+/* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
+   not define. */
+#define intmax_t long long
+
 /* Define to `int' if <sys/types.h> does not define. */
 #define ssize_t int
+
+/* Define to 'unsigned long' or 'unsigned long long'
+   if <inttypes.h> doesn't define.  */
+#define uintmax_t unsigned long long