]> xenbits.xensource.com Git - xen.git/commitdiff
xen: consolidate implementations of LOG() macro
authorIan Campbell <ian.campbell@citrix.com>
Fri, 22 Feb 2013 08:57:43 +0000 (08:57 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 22 Feb 2013 12:14:50 +0000 (12:14 +0000)
arm64 is going to add another one shortly, so take control now.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Keir Fraser <keir@xen.org>
xen/arch/arm/arm32/asm-offsets.c
xen/arch/x86/x86_64/asm-offsets.c
xen/include/xen/bitops.h

index 104430ab03097c2e43120923b243e6e27470a0ac..776c974bffcd1cb7428c8e925ab5bf7b8cd1595b 100644 (file)
@@ -8,6 +8,7 @@
 #include <xen/config.h>
 #include <xen/types.h>
 #include <xen/sched.h>
+#include <xen/bitops.h>
 #include <public/xen.h>
 #include <asm/current.h>
 
 #define OFFSET(_sym, _str, _mem) \
     DEFINE(_sym, offsetof(_str, _mem));
 
-/* base-2 logarithm */
-#define __L2(_x)  (((_x) & 0x00000002) ?   1 : 0)
-#define __L4(_x)  (((_x) & 0x0000000c) ? ( 2 + __L2( (_x)>> 2)) : __L2( _x))
-#define __L8(_x)  (((_x) & 0x000000f0) ? ( 4 + __L4( (_x)>> 4)) : __L4( _x))
-#define __L16(_x) (((_x) & 0x0000ff00) ? ( 8 + __L8( (_x)>> 8)) : __L8( _x))
-#define LOG_2(_x) (((_x) & 0xffff0000) ? (16 + __L16((_x)>>16)) : __L16(_x))
-
 void __dummy__(void)
 {
    OFFSET(UREGS_sp, struct cpu_user_regs, sp);
index b6d1919cc24c6ab2f68d17f526e2dd658332c5a3..6dc832c01c4f066c3a574ad26ce81361a579e5a8 100644 (file)
@@ -8,6 +8,7 @@
 #include <xen/config.h>
 #include <xen/perfc.h>
 #include <xen/sched.h>
+#include <xen/bitops.h>
 #include <compat/xen.h>
 #include <asm/fixmap.h>
 #include <asm/hardirq.h>
 #define OFFSET(_sym, _str, _mem) \
     DEFINE(_sym, offsetof(_str, _mem));
 
-/* base-2 logarithm */
-#define __L2(_x)  (((_x) & 0x00000002) ?   1 : 0)
-#define __L4(_x)  (((_x) & 0x0000000c) ? ( 2 + __L2( (_x)>> 2)) : __L2( _x))
-#define __L8(_x)  (((_x) & 0x000000f0) ? ( 4 + __L4( (_x)>> 4)) : __L4( _x))
-#define __L16(_x) (((_x) & 0x0000ff00) ? ( 8 + __L8( (_x)>> 8)) : __L8( _x))
-#define LOG_2(_x) (((_x) & 0xffff0000) ? (16 + __L16((_x)>>16)) : __L16(_x))
-
 void __dummy__(void)
 {
     OFFSET(UREGS_r15, struct cpu_user_regs, r15);
index 190d96baa76961b657706e67ff49f8f167333551..c6a78b6512c880985ddcab3df6ea0d85130bc6bd 100644 (file)
@@ -175,4 +175,11 @@ static inline __u32 ror32(__u32 word, unsigned int shift)
     return (word >> shift) | (word << (32 - shift));
 }
 
+/* base-2 logarithm */
+#define __L2(_x)  (((_x) & 0x00000002) ?   1 : 0)
+#define __L4(_x)  (((_x) & 0x0000000c) ? ( 2 + __L2( (_x)>> 2)) : __L2( _x))
+#define __L8(_x)  (((_x) & 0x000000f0) ? ( 4 + __L4( (_x)>> 4)) : __L4( _x))
+#define __L16(_x) (((_x) & 0x0000ff00) ? ( 8 + __L8( (_x)>> 8)) : __L8( _x))
+#define LOG_2(_x) (((_x) & 0xffff0000) ? (16 + __L16((_x)>>16)) : __L16(_x))
+
 #endif