path: root/kerncompat.h
diff options
authorWade Cline <>2012-09-20 14:26:28 -0700
committerDavid Sterba <>2013-01-17 18:12:57 +0100
commit0d5cfddc2c8c34648ff21d99a1e34aae92ff25d0 (patch)
treee3a46250fc213e97da9292995983068fd9581961 /kerncompat.h
parent91d9eec1ff044394f2b98ee7fcb76713dd33b994 (diff)
Btrfs-progs: Fix compiler warnings on PPC64
The kernel uses unsigned long long for u64, but PPC64 uses unsigned long by default. This results in compilation warnings such as: print-tree.c:333: warning: format '%llu' expects type 'long long unsigned int', but argument 4 has type 'u64' To fix this, the macro __KERNEL__ needs to be defined before including the file <asm/types.h>. This can be done by defining the macro in "kerncompat.h" and making it the first included file in the relevant header files; this fixes the compiler warnings on PPC64. Reviewed-by: David Sterba <> Signed-off-by: Wade Cline <>
Diffstat (limited to 'kerncompat.h')
1 files changed, 12 insertions, 0 deletions
diff --git a/kerncompat.h b/kerncompat.h
index 46236cd5..d60f7222 100644
--- a/kerncompat.h
+++ b/kerncompat.h
@@ -18,6 +18,7 @@
#ifndef __KERNCOMPAT
#define __KERNCOMPAT
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@@ -57,11 +58,22 @@
#ifndef __CHECKER__
+ * Since we're using primitive definitions from kernel-space, we need to
+ * define __KERNEL__ so that system header files know which definitions
+ * to use.
+ */
+#define __KERNEL__
#include <asm/types.h>
typedef __u32 u32;
typedef __u64 u64;
typedef __u16 u16;
typedef __u8 u8;
+ * Continuing to define __KERNEL__ breaks others parts of the code, so
+ * we can just undefine it now that we have the correct headers...
+ */
+#undef __KERNEL__
typedef unsigned int u32;
typedef unsigned int __u32;