Sasha Levin | 5634bd7 | 2013-06-13 18:41:17 -0400 | [diff] [blame] | 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 | |
Sasha Levin | 5634bd7 | 2013-06-13 18:41:17 -0400 | [diff] [blame] | 14 | __attribute__((destructor)) static void liblockdep_exit(void) |
| 15 | { |
Sasha Levin | 1393ba5 | 2015-11-06 15:29:52 -0500 | [diff] [blame] | 16 | debug_check_no_locks_held(); |
Sasha Levin | 5634bd7 | 2013-06-13 18:41:17 -0400 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | struct task_struct *__curr(void) |
| 20 | { |
| 21 | if (current_obj.pid == 0) { |
| 22 | /* Makes lockdep output pretty */ |
| 23 | prctl(PR_GET_NAME, current_obj.comm); |
| 24 | current_obj.pid = syscall(__NR_gettid); |
| 25 | } |
| 26 | |
| 27 | return ¤t_obj; |
| 28 | } |