From 426fe0cbaffab4547cd20726d766b099e5f3b53e Mon Sep 17 00:00:00 2001 From: yangsheng Date: Tue, 14 Jul 2009 08:12:49 +0000 Subject: [PATCH] Branch HEAD b=19869 i=johann, shadow Config check for the U64 type independent in user & kernel space. --- libcfs/autoconf/lustre-libcfs.m4 | 23 +++++++++++++++++++++-- libcfs/include/libcfs/linux/kp30.h | 3 ++- libcfs/include/libcfs/posix/posix-wordsize.h | 3 ++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index c200cae..a78f408 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -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" @@ -185,12 +185,31 @@ AC_COMPILE_IFELSE([ } ],[ 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" +AC_MSG_CHECKING([kernel __u64 is long long type]) +tmp_flags="$EXTRA_KCFLAGS" +EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror" +LB_LINUX_TRY_COMPILE([ + #include + #include +],[ + 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 diff --git a/libcfs/include/libcfs/linux/kp30.h b/libcfs/include/libcfs/linux/kp30.h index cbea707..ae23e8c 100644 --- a/libcfs/include/libcfs/linux/kp30.h +++ b/libcfs/include/libcfs/linux/kp30.h @@ -351,7 +351,8 @@ extern int lwt_snapshot (cycles_t *now, int *ncpu, int *total_size, #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" diff --git a/libcfs/include/libcfs/posix/posix-wordsize.h b/libcfs/include/libcfs/posix/posix-wordsize.h index 62bd289..f70c3ed 100644 --- a/libcfs/include/libcfs/posix/posix-wordsize.h +++ b/libcfs/include/libcfs/posix/posix-wordsize.h @@ -112,7 +112,8 @@ typedef struct { # 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" -- 1.8.3.1