Staging
v0.5.1
https://github.com/torvalds/linux
Raw File
Tip revision: a99d8080aaf358d5d23581244e5da23b35e340b9 authored by Linus Torvalds on 03 November 2019, 22:07:26 UTC
Linux 5.4-rc6
Tip revision: a99d808
common.c
// SPDX-License-Identifier: GPL-2.0
#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__((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