^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <stddef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <stdbool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/lockdep.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <sys/syscall.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) static __thread struct task_struct current_obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) /* lockdep wants these */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) bool debug_locks = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) bool debug_locks_silent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) __attribute__((destructor)) static void liblockdep_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) debug_check_no_locks_held();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct task_struct *__curr(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) if (current_obj.pid == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /* Makes lockdep output pretty */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) prctl(PR_GET_NAME, current_obj.comm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) current_obj.pid = syscall(__NR_gettid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) return ¤t_obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) }