Whamcloud - gitweb
LU-5018 libcfs: don't depend on configure for lustre_user.h 58/10258/5
authorAndreas Dilger <andreas.dilger@intel.com>
Fri, 9 May 2014 04:38:58 +0000 (22:38 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 19 May 2014 16:19:20 +0000 (16:19 +0000)
Don't depend on configure to detect the presence of <linux/types.h>
in order to define the __u8, __u16, __u32, and __u64 types.  Instead,
just define these types directly if <linux/types.h> is not included
already.

The <linux/types.h> header is available on Linux systems with GCC
installed, which is required to build Lustre anyway.  On non-Linux
systems they should create an appropriate <linux/types.h> compat
header in the include path.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: Ida0915fe1b5829f3378e459c782844cf9df060e6
Reviewed-on: http://review.whamcloud.com/10258
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/kp30.h
libcfs/include/libcfs/posix/posix-types.h

index dba971d..ac5c413 100644 (file)
@@ -377,71 +377,6 @@ AC_CHECK_TYPE([umode_t],
        [],
        [#include <asm/types.h>])
 
-AC_CHECK_TYPE([__s8],
-       [AC_DEFINE(HAVE___S8, 1, [__s8 is defined])],
-       [],
-       [#include <asm/types.h>])
-
-AC_CHECK_TYPE([__u8],
-       [AC_DEFINE(HAVE___U8, 1, [__u8 is defined])],
-       [],
-       [#include <asm/types.h>])
-
-AC_CHECK_TYPE([__s16],
-       [AC_DEFINE(HAVE___S16, 1, [__s16 is defined])],
-       [],
-       [#include <asm/types.h>])
-
-AC_CHECK_TYPE([__u16],
-       [AC_DEFINE(HAVE___U16, 1, [__u16 is defined])],
-       [],
-       [#include <asm/types.h>])
-
-AC_CHECK_TYPE([__s32],
-       [AC_DEFINE(HAVE___S32, 1, [__s32 is defined])],
-       [],
-       [#include <asm/types.h>])
-
-AC_CHECK_TYPE([__u32],
-       [AC_DEFINE(HAVE___U32, 1, [__u32 is defined])],
-       [],
-       [#include <asm/types.h>])
-
-AC_CHECK_TYPE([__u64],
-       [AC_DEFINE(HAVE___U64, 1, [__u64 is defined])],
-       [],
-       [#include <asm/types.h>])
-
-AC_CHECK_TYPE([__s64],
-       [AC_DEFINE(HAVE___S64, 1, [__s64 is defined])],
-       [],
-       [#include <asm/types.h>])
-
-# check userland __u64 type
-tmp_flags="$CFLAGS"
-CFLAGS="$CFLAGS -Werror"
-AC_CACHE_CHECK([if userspace '__u64' is 'long long' type],
-lb_cv_compile_userspace_u64_long_long, [
-AC_COMPILE_IFELSE([AC_LANG_SOURCE([
-       #include <stdio.h>
-       #include <linux/types.h>
-       #include <linux/stddef.h>
-       int main(void) {
-               unsigned long long *data1;
-               __u64 *data2 = NULL;
-               data1 = data2;
-               data2 = data1;
-               return 0;
-       }
-])],
-       [lb_cv_compile_userspace_u64_long_long="yes"],
-       [lb_cv_compile_userspace_u64_long_long="no"])
-])
-CFLAGS="$tmp_flags"
-AS_IF([test "x$lb_cv_compile_userspace_u64_long_long" = xyes],
-       [AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
-               [__u64 is long long type])])
-
 # --------  Check for required packages  --------------
 
 AC_MSG_NOTICE([LibCFS required packages checks
index 2dfdf6c..e100620 100644 (file)
 
 #define _LWORDSIZE BITS_PER_LONG
 
-#if (defined(__KERNEL__) && defined(HAVE_KERN__U64_LONG_LONG)) || \
-    (!defined(__KERNEL__) && defined(HAVE_USER__U64_LONG_LONG))
+#if defined(HAVE_KERN__U64_LONG_LONG)
 # define LPU64 "%llu"
 # define LPD64 "%lld"
 # define LPX64 "%#llx"
index 510b178..ee722a5 100644 (file)
@@ -42,7 +42,7 @@
 #ifndef _LUSTRE_POSIX_TYPES_H
 #define _LUSTRE_POSIX_TYPES_H
 
-#ifdef HAVE_LINUX_TYPES_H
+#ifdef __linux__
 # include <linux/types.h>
 #endif
 #include <stdbool.h> /* for bool */
@@ -51,29 +51,36 @@ typedef unsigned short umode_t;
 #else
 #endif
 
+#ifndef _LINUX_TYPES_H
 /*
  * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
  * header files exported to user space
  */
 
 #ifndef HAVE___S8
+#define HAVE___S8
 typedef __signed__ char __s8;
 #endif
 #ifndef HAVE___U8
+#define HAVE___U8
 typedef unsigned char __u8;
 #endif
 
 #ifndef HAVE___S16
+#define HAVE___S16
 typedef __signed__ short __s16;
 #endif
 #ifndef HAVE___U16
+#define HAVE___U16
 typedef unsigned short __u16;
 #endif
 
 #ifndef HAVE___S32
+#define HAVE___S32
 typedef __signed__ int __s32;
 #endif
 #ifndef HAVE___U32
+#define HAVE___U32
 typedef unsigned int __u32;
 #endif
 
@@ -83,19 +90,24 @@ typedef unsigned int __u32;
  */
 #if defined(__powerpc64__) && !defined(__KERNEL__)
 # ifndef HAVE___S64
+# define HAVE___S64
 typedef __signed__ long __s64;
 # endif
 # ifndef HAVE___U64
+# define HAVE___U64
 typedef unsigned long __u64;
 # endif
 #else /* !defined(__powerpc64__) || defined(__KERNEL__) */
 # ifndef HAVE___S64
+# define HAVE___S64
 typedef __signed__ long long __s64;
 # endif
 # ifndef HAVE___U64
+# define HAVE___U64
 typedef unsigned long long __u64;
 # endif
-#endif
+#endif /* defined(__powerpc64__) && !defined(__KERNEL__) */
+#endif /* _LINUX_TYPES_H */
 
 /* long integer with size equal to pointer */
 typedef unsigned long ulong_ptr_t;