File: spin_lock_debug.c

package info (click to toggle)
optee-os 4.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,960 kB
  • sloc: ansic: 444,388; asm: 12,922; python: 3,719; makefile: 1,681; sh: 238
file content (42 lines) | stat: -rw-r--r-- 790 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// SPDX-License-Identifier: BSD-2-Clause
/*
 * Copyright (c) 2016, Linaro Limited
 */

#include <assert.h>
#include <compiler.h>
#include <kernel/spinlock.h>

void spinlock_count_incr(void)
{
	struct thread_core_local *l = thread_get_core_local();

	l->locked_count++;
	assert(l->locked_count);
}

void spinlock_count_decr(void)
{
	struct thread_core_local *l = thread_get_core_local();

	assert(l->locked_count);
	l->locked_count--;
}

bool __nostackcheck have_spinlock(void)
{
	struct thread_core_local *l;

	if (!thread_foreign_intr_disabled()) {
		/*
		 * Normally we can't be holding a spinlock since doing so would
		 * imply foreign interrupts are disabled (or the spinlock
		 * logic is flawed).
		 */
		return false;
	}

	l = thread_get_core_local();

	return !!l->locked_count;
}