swh:1:snp:49cd9498d6cccc5e78252c27dcb645bcf7bf0c91
Raw File
Tip revision: 168309855a7d1e16db751e9c647119fe2d2dc878 authored by Linus Torvalds on 03 January 2016, 23:15:37 UTC
Linux 4.4-rc8
Tip revision: 1683098
common.c
#include <stddef.h>
#include <stdbool.h>
#include <linux/compiler.h>
#include <linux/lockdep.h>
#include <unistd.h>
#include <sys/syscall.h>

static __thread struct task_struct current_obj;

/* lockdep wants these */
bool debug_locks = true;
bool debug_locks_silent;

__attribute__((constructor)) static void liblockdep_init(void)
{
	lockdep_init();
}

__attribute__((destructor)) static void liblockdep_exit(void)
{
	debug_check_no_locks_held();
}

struct task_struct *__curr(void)
{
	if (current_obj.pid == 0) {
		/* Makes lockdep output pretty */
		prctl(PR_GET_NAME, current_obj.comm);
		current_obj.pid = syscall(__NR_gettid);
	}

	return &current_obj;
}
back to top