From b754c8d595afdbc69f6e4dab9358d8c16bb5f96e Mon Sep 17 00:00:00 2001 From: adilger Date: Tue, 31 May 2005 18:15:45 +0000 Subject: [PATCH] Branch b1_4 On x86_64 the kernel declares __u64 as long long, but userspace uses long. Fix LP*64 printf format macros to handle this difference to quiet warnings. --- lustre/include/linux/lustre_lib.h | 31 ++++++++++++++++++++++--------- lustre/tests/test_brw.c | 16 +++------------- lustre/utils/lfs.c | 12 ++++++------ lustre/utils/liblustreapi.c | 2 -- lustre/utils/obd.c | 2 +- 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/lustre/include/linux/lustre_lib.h b/lustre/include/linux/lustre_lib.h index 233c954..6a961d1 100644 --- a/lustre/include/linux/lustre_lib.h +++ b/lustre/include/linux/lustre_lib.h @@ -53,15 +53,28 @@ #endif #ifndef LPU64 -/* x86_64 has 64bit longs and defines u64 as long long */ -#if BITS_PER_LONG > 32 && !defined(__x86_64__) -#define LPU64 "%lu" -#define LPD64 "%ld" -#define LPX64 "%#lx" -#else -#define LPU64 "%Lu" -#define LPD64 "%Ld" -#define LPX64 "%#Lx" +/* x86_64 defines __u64 as "long" in userspace, but "long long" in the kernel */ +#if defined(__x86_64__) && defined(__KERNEL__) +# define LPU64 "%Lu" +# define LPD64 "%Ld" +# define LPX64 "%#Lx" +# define LPSZ "%lu" +# define LPSSZ "%ld" +#elif (BITS_PER_LONG == 32 || __WORDSIZE == 32) +# define LPU64 "%Lu" +# define LPD64 "%Ld" +# define LPX64 "%#Lx" +# define LPSZ "%u" +# define LPSSZ "%d" +#elif (BITS_PER_LONG == 64 || __WORDSIZE == 64) +# define LPU64 "%lu" +# define LPD64 "%ld" +# define LPX64 "%#lx" +# define LPSZ "%lu" +# define LPSSZ "%ld" +#endif +#ifndef LPU64 +# error "No word size defined" #endif #endif diff --git a/lustre/tests/test_brw.c b/lustre/tests/test_brw.c index ecefe92..dd94d1b 100644 --- a/lustre/tests/test_brw.c +++ b/lustre/tests/test_brw.c @@ -15,17 +15,7 @@ #include #include -#define CERROR(fmt, arg...) fprintf(stderr, fmt, ## arg) -#ifndef __u64 -#define __u64 long long -#define cpu_to_le64(v) (v) -#define le64_to_cpu(v) (v) -#endif - -#ifndef LPU64 -#define LPU64 "%Lu" -#define LPX64 "%#Lx" -#endif +#include #define READ 1 #define WRITE 2 @@ -91,9 +81,9 @@ int main(int argc, char **argv) { int fd; char *buf; - long long count, last, offset; + loff_t count, last, offset; long pg_vec, len; - long long objid; + __u64 objid; struct stat st; int flags = 0; int cmd = 0; diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 35b123f..61f1579 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -855,16 +855,16 @@ static void print_quota(char *mnt, char *name, struct if_quotactl *qctl) printf("%15s", mnt); if (bover) diff2str(dqb->dqb_btime, timebuf, now); - sprintf(numbuf[0], "%llu", toqb(dqb->dqb_curspace)); - sprintf(numbuf[1], "%llu", dqb->dqb_bsoftlimit); - sprintf(numbuf[2], "%llu", dqb->dqb_bhardlimit); + sprintf(numbuf[0], LPU64, toqb(dqb->dqb_curspace)); + sprintf(numbuf[1], LPU64, dqb->dqb_bsoftlimit); + sprintf(numbuf[2], LPU64, dqb->dqb_bhardlimit); printf(" %7s%c %6s %7s %7s", numbuf[0], bover ? '*' : ' ', numbuf[1], numbuf[2], bover > 1 ? timebuf : ""); if (iover) diff2str(dqb->dqb_itime, timebuf, now); - sprintf(numbuf[0], "%llu", dqb->dqb_curinodes); - sprintf(numbuf[1], "%llu", dqb->dqb_isoftlimit); - sprintf(numbuf[2], "%llu", dqb->dqb_ihardlimit); + sprintf(numbuf[0], LPU64, dqb->dqb_curinodes); + sprintf(numbuf[1], LPU64, dqb->dqb_isoftlimit); + sprintf(numbuf[2], LPU64, dqb->dqb_ihardlimit); printf(" %7s%c %6s %7s %7s\n", numbuf[0], iover ? '*' : ' ', numbuf[1], numbuf[2], iover > 1 ? timebuf : ""); } diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index c8929fc..079fbba 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -40,8 +40,6 @@ #include #include #include -#include -#include #include diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 346a581..eab833c 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -83,7 +83,7 @@ static int max = sizeof(rawbuf); static int thread; static int nthreads; -static uint32_t cur_device = MAX_OBD_DEVICES; +static int cur_device = MAX_OBD_DEVICES; union lsm_buffer { char space [4096]; -- 1.8.3.1