Whamcloud - gitweb
Branch b1_4
authoradilger <adilger>
Tue, 31 May 2005 18:15:45 +0000 (18:15 +0000)
committeradilger <adilger>
Tue, 31 May 2005 18:15:45 +0000 (18:15 +0000)
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
lustre/tests/test_brw.c
lustre/utils/lfs.c
lustre/utils/liblustreapi.c
lustre/utils/obd.c

index 233c954..6a961d1 100644 (file)
 #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
 
index ecefe92..dd94d1b 100644 (file)
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#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 <liblustre.h>
 
 #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;
index 35b123f..61f1579 100644 (file)
@@ -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 : "");
                 }
index c8929fc..079fbba 100644 (file)
@@ -40,8 +40,6 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/syscall.h>
-#include <linux/types.h>
-#include <linux/unistd.h>
 
 #include <portals/ptlctl.h>
 
index 346a581..eab833c 100644 (file)
@@ -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];