diff --git a/configure b/configure
index 199d569b9baedfbe6d17c28b138fabcdbfbb85ad..5296f0a60a558838884ef826a4b6162bad4b684f 100755
--- a/configure
+++ b/configure
@@ -7034,6 +7034,7 @@ done
 
 
 
+
 
 
 for ac_header in \
@@ -7106,6 +7107,7 @@ for ac_header in \
 	sys/filio.h \
 	sys/ioctl.h \
 	sys/ipc.h \
+	sys/limits.h \
 	sys/link.h \
 	sys/lwp.h \
 	sys/mman.h \
diff --git a/configure.ac b/configure.ac
index 2a6aee0863835ae75bb9aea165b46de03ca7e707..20feb2f8d60b296d19b85b1b57dbcf69342be72d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -241,6 +241,7 @@ AC_CHECK_HEADERS(\
 	sys/filio.h \
 	sys/ioctl.h \
 	sys/ipc.h \
+	sys/limits.h \
 	sys/link.h \
 	sys/lwp.h \
 	sys/mman.h \
diff --git a/dlls/kernel/time.c b/dlls/kernel/time.c
index 5f3a275956ae60847728d10a73568b303f956d81..5208235372930e38f2f6e167f4799d4e5998a949 100644
--- a/dlls/kernel/time.c
+++ b/dlls/kernel/time.c
@@ -33,7 +33,9 @@
 #ifdef HAVE_SYS_TIMES_H
 # include <sys/times.h>
 #endif
-#ifdef HAVE_MACHINE_LIMITS_H
+#ifdef HAVE_SYS_LIMITS_H
+#include <sys/limits.h>
+#elif defined(HAVE_MACHINE_LIMITS_H)
 #include <machine/limits.h>
 #endif
 
diff --git a/include/config.h.in b/include/config.h.in
index 48ae78ea63d48ed1b36ddecadc836f6fc01ef0ff..c075484819f46f973e730d3138dfc5b5896b98b6 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -644,6 +644,9 @@
 /* Define to 1 if you have the <sys/ipc.h> header file. */
 #undef HAVE_SYS_IPC_H
 
+/* Define to 1 if you have the <sys/limits.h> header file. */
+#undef HAVE_SYS_LIMITS_H
+
 /* Define to 1 if you have the <sys/link.h> header file. */
 #undef HAVE_SYS_LINK_H