common.c 575 B

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