common.c 611 B

123456789101112131415161718192021222324252627282930
  1. // SPDX-License-Identifier: GPL-2.0
  2. #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. static __thread struct task_struct current_obj;
  9. /* lockdep wants these */
  10. bool debug_locks = true;
  11. bool debug_locks_silent;
  12. __attribute__((destructor)) static void liblockdep_exit(void)
  13. {
  14. debug_check_no_locks_held();
  15. }
  16. struct task_struct *__curr(void)
  17. {
  18. if (current_obj.pid == 0) {
  19. /* Makes lockdep output pretty */
  20. prctl(PR_GET_NAME, current_obj.comm);
  21. current_obj.pid = syscall(__NR_gettid);
  22. }
  23. return &current_obj;
  24. }