blob: 5c3b58cce8a9b911c7cac5f795bf402140b89ea5 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Sasha Levin5634bd72013-06-13 18:41:17 -04002#include <stddef.h>
3#include <stdbool.h>
4#include <linux/compiler.h>
5#include <linux/lockdep.h>
6#include <unistd.h>
7#include <sys/syscall.h>
8
9static __thread struct task_struct current_obj;
10
11/* lockdep wants these */
12bool debug_locks = true;
13bool debug_locks_silent;
14
Sasha Levin5634bd72013-06-13 18:41:17 -040015__attribute__((destructor)) static void liblockdep_exit(void)
16{
Sasha Levin1393ba52015-11-06 15:29:52 -050017 debug_check_no_locks_held();
Sasha Levin5634bd72013-06-13 18:41:17 -040018}
19
20struct task_struct *__curr(void)
21{
22 if (current_obj.pid == 0) {
23 /* Makes lockdep output pretty */
24 prctl(PR_GET_NAME, current_obj.comm);
25 current_obj.pid = syscall(__NR_gettid);
26 }
27
28 return &current_obj;
29}