[PATCH 1/2] liblockdep: Fix compile errors
From: Vishal Thanki
Date: Thu Jun 09 2016 - 09:34:58 EST
Following commit caused failures.
dfaaf3fa0: (Use __jhash_mix() for iterate_chain_key())
Fixed by adding jhash.h with minimal stuff required
75dd602a5: (lockdep: Fix lock_chain::base size)
Fixed by adding ARRAY_SIZE macro definition and
changing the MAX_LOCK_DEPTH value to similar defined
in linux/sched.h
Signed-off-by: Vishal Thanki <vishalthanki@xxxxxxxxx>
---
tools/lib/lockdep/lockdep.c | 2 +-
tools/lib/lockdep/uinclude/linux/jhash.h | 20 ++++++++++++++++++++
tools/lib/lockdep/uinclude/linux/kernel.h | 1 +
tools/lib/lockdep/uinclude/linux/lockdep.h | 2 +-
4 files changed, 23 insertions(+), 2 deletions(-)
create mode 100644 tools/lib/lockdep/uinclude/linux/jhash.h
diff --git a/tools/lib/lockdep/lockdep.c b/tools/lib/lockdep/lockdep.c
index a0a2e3a..1ba6f33 100644
--- a/tools/lib/lockdep/lockdep.c
+++ b/tools/lib/lockdep/lockdep.c
@@ -4,5 +4,5 @@
#define hlist_for_each_entry_rcu hlist_for_each_entry
#define hlist_add_head_rcu hlist_add_head
#define hlist_del_rcu hlist_del
-
+#define prandom_u32 rand
#include "../../../kernel/locking/lockdep.c"
diff --git a/tools/lib/lockdep/uinclude/linux/jhash.h b/tools/lib/lockdep/uinclude/linux/jhash.h
new file mode 100644
index 0000000..5c40bd1
--- /dev/null
+++ b/tools/lib/lockdep/uinclude/linux/jhash.h
@@ -0,0 +1,20 @@
+#ifndef _LINUX_JHASH_H
+#define _LINUX_JHASH_H
+
+static inline __u32 rol32(__u32 word, unsigned int shift)
+{
+ return (word << shift) | (word >> ((-shift) & 31));
+}
+
+/* __jhash_mix -- mix 3 32-bit values reversibly. */
+#define __jhash_mix(a, b, c) \
+{ \
+ a -= c; a ^= rol32(c, 4); c += b; \
+ b -= a; b ^= rol32(a, 6); a += c; \
+ c -= b; c ^= rol32(b, 8); b += a; \
+ a -= c; a ^= rol32(c, 16); c += b; \
+ b -= a; b ^= rol32(a, 19); a += c; \
+ c -= b; c ^= rol32(b, 4); b += a; \
+}
+
+#endif /* _LINUX_JHASH_H */
diff --git a/tools/lib/lockdep/uinclude/linux/kernel.h b/tools/lib/lockdep/uinclude/linux/kernel.h
index 276c7a8..ab204c8 100644
--- a/tools/lib/lockdep/uinclude/linux/kernel.h
+++ b/tools/lib/lockdep/uinclude/linux/kernel.h
@@ -44,4 +44,5 @@
#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
#endif
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
diff --git a/tools/lib/lockdep/uinclude/linux/lockdep.h b/tools/lib/lockdep/uinclude/linux/lockdep.h
index c808c7d..8f6e725 100644
--- a/tools/lib/lockdep/uinclude/linux/lockdep.h
+++ b/tools/lib/lockdep/uinclude/linux/lockdep.h
@@ -8,7 +8,7 @@
#include <linux/utsname.h>
#include <linux/compiler.h>
-#define MAX_LOCK_DEPTH 2000UL
+#define MAX_LOCK_DEPTH 48UL
#define asmlinkage
#define __visible
--
2.4.11