Whamcloud - gitweb
Branch HEAD
authoryangsheng <yangsheng>
Tue, 14 Jul 2009 08:12:49 +0000 (08:12 +0000)
committeryangsheng <yangsheng>
Tue, 14 Jul 2009 08:12:49 +0000 (08:12 +0000)
b=19869

i=johann, shadow

Config check for the U64 type independent in user & kernel space.

libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/kp30.h
libcfs/include/libcfs/posix/posix-wordsize.h

index c200cae..a78f408 100644 (file)
@@ -169,7 +169,7 @@ AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
 ])
 ])
 
 ])
 ])
 
-# check userland __u64 type
+# check userland & kernel __u64 type
 AC_DEFUN([LIBCFS_U64_LONG_LONG],
 [AC_MSG_CHECKING([u64 is long long type])
 tmp_flags="$CFLAGS"
 AC_DEFUN([LIBCFS_U64_LONG_LONG],
 [AC_MSG_CHECKING([u64 is long long type])
 tmp_flags="$CFLAGS"
@@ -185,12 +185,31 @@ AC_COMPILE_IFELSE([
        }
 ],[
        AC_MSG_RESULT([yes])
        }
 ],[
        AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_U64_LONG_LONG, 1,
+        AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
                   [__u64 is long long type])
 ],[
        AC_MSG_RESULT([no])
 ])
 CFLAGS="$tmp_flags"
                   [__u64 is long long type])
 ],[
        AC_MSG_RESULT([no])
 ])
 CFLAGS="$tmp_flags"
+AC_MSG_CHECKING([kernel __u64 is long long type])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror"
+LB_LINUX_TRY_COMPILE([
+       #include <linux/types.h>
+       #include <linux/stddef.h>
+],[
+       unsigned long long *data1;
+       __u64 *data2 = NULL;
+               
+       data1 = data2;
+],[
+       AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_KERN__U64_LONG_LONG, 1,
+                  [kernel __u64 is long long type])
+],[
+       AC_MSG_RESULT([no])
+])
+EXTRA_KCFLAGS="$tmp_flags"
 ])
 
 # check userland size_t type
 ])
 
 # check userland size_t type
index cbea707..ae23e8c 100644 (file)
@@ -351,7 +351,8 @@ extern int  lwt_snapshot (cycles_t *now, int *ncpu, int *total_size,
 
 #define _LWORDSIZE BITS_PER_LONG
 
 
 #define _LWORDSIZE BITS_PER_LONG
 
-#if defined(HAVE_U64_LONG_LONG)
+#if (defined(__KERNEL__) && defined(HAVE_KERN__U64_LONG_LONG)) || \
+    (!defined(__KERNEL__) && defined(HAVE_USER__U64_LONG_LONG))
 # define LPU64 "%Lu"
 # define LPD64 "%Ld"
 # define LPX64 "%#Lx"
 # define LPU64 "%Lu"
 # define LPD64 "%Ld"
 # define LPX64 "%#Lx"
index 62bd289..f70c3ed 100644 (file)
@@ -112,7 +112,8 @@ typedef struct {
 # define LP_POISON ((void *)(long)0x5a5a5a5a)
 #endif
 
 # define LP_POISON ((void *)(long)0x5a5a5a5a)
 #endif
 
-#if defined(HAVE_U64_LONG_LONG) 
+#if (defined(__KERNEL__) && defined(HAVE_KERN__U64_LONG_LONG)) || \
+    (!defined(__KERNEL__) && defined(HAVE_USER__U64_LONG_LONG))
 /* x86_64 defines __u64 as "long" in userspace, but "long long" in the kernel */
 # define LPU64 "%Lu"
 # define LPD64 "%Ld"
 /* x86_64 defines __u64 as "long" in userspace, but "long long" in the kernel */
 # define LPU64 "%Lu"
 # define LPD64 "%Ld"