diff options
Diffstat (limited to 'tools/lib/lockdep/common.c')
-rw-r--r-- | tools/lib/lockdep/common.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/lib/lockdep/common.c b/tools/lib/lockdep/common.c new file mode 100644 index 000000000000..8ef602f18a32 --- /dev/null +++ b/tools/lib/lockdep/common.c | |||
@@ -0,0 +1,33 @@ | |||
1 | #include <stddef.h> | ||
2 | #include <stdbool.h> | ||
3 | #include <linux/compiler.h> | ||
4 | #include <linux/lockdep.h> | ||
5 | #include <unistd.h> | ||
6 | #include <sys/syscall.h> | ||
7 | |||
8 | static __thread struct task_struct current_obj; | ||
9 | |||
10 | /* lockdep wants these */ | ||
11 | bool debug_locks = true; | ||
12 | bool debug_locks_silent; | ||
13 | |||
14 | __attribute__((constructor)) static void liblockdep_init(void) | ||
15 | { | ||
16 | lockdep_init(); | ||
17 | } | ||
18 | |||
19 | __attribute__((destructor)) static void liblockdep_exit(void) | ||
20 | { | ||
21 | debug_check_no_locks_held(¤t_obj); | ||
22 | } | ||
23 | |||
24 | struct task_struct *__curr(void) | ||
25 | { | ||
26 | if (current_obj.pid == 0) { | ||
27 | /* Makes lockdep output pretty */ | ||
28 | prctl(PR_GET_NAME, current_obj.comm); | ||
29 | current_obj.pid = syscall(__NR_gettid); | ||
30 | } | ||
31 | |||
32 | return ¤t_obj; | ||
33 | } | ||