diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4
index 492b0e73ec0d74cab5d5a0d3e8016c4c8eddcbeb..c200cae23555730eaccec2f4304c57ae78185a15 100644
--- a/libcfs/autoconf/lustre-libcfs.m4
+++ b/libcfs/autoconf/lustre-libcfs.m4
@@ -433,7 +433,6 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
-
 #
 # LIBCFS_PROG_LINUX
 #
@@ -510,6 +509,21 @@ AC_CHECK_TYPE([spinlock_t],
 # lnet/utils/wirecheck.c
 AC_CHECK_FUNCS([strnlen])
 
+AC_CHECK_TYPE([umode_t],
+	[AC_DEFINE(HAVE_UMODE_T, 1, [umode_t is defined])],
+	[],
+	[#include <signal.h>])
+
+AC_CHECK_TYPE([__u64],
+	[AC_DEFINE(HAVE___U64, 1, [__u64 is defined])],
+	[],
+	[#include <signal.h>])
+
+AC_CHECK_TYPE([__s64],
+	[AC_DEFINE(HAVE___S64, 1, [__s64 is defined])],
+	[],
+	[#include <signal.h>])
+
 # --------  Check for required packages  --------------
 
 
diff --git a/libcfs/include/libcfs/posix/posix-types.h b/libcfs/include/libcfs/posix/posix-types.h
index 392e70e04d6529215bc25dab919c8d0b3621f3e5..911ba95f50ab6372affc852c070cd454eef241e6 100644
--- a/libcfs/include/libcfs/posix/posix-types.h
+++ b/libcfs/include/libcfs/posix/posix-types.h
@@ -42,7 +42,9 @@
 #ifndef _LUSTRE_POSIX_TYPES_H
 #define _LUSTRE_POSIX_TYPES_H
 
+#ifndef HAVE_UMODE_T
 typedef unsigned short umode_t;
+#endif
 
 /*
  * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
@@ -58,8 +60,12 @@ typedef unsigned short __u16;
 typedef __signed__ int __s32;
 typedef unsigned int __u32;
 
+#ifndef HAVE___S64
 typedef __signed__ long long __s64;
+#endif
+#ifndef HAVE___U64
 typedef unsigned long long __u64;
+#endif
 
 /* long integer with size equal to pointer */
 typedef unsigned long ulong_ptr_t;