]> asedeno.scripts.mit.edu Git - linux.git/blob - tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/preempt.h
Merge branches 'pm-core', 'pm-qos', 'pm-domains' and 'pm-opp'
[linux.git] / tools / testing / selftests / rcutorture / formal / srcu-cbmc / src / preempt.h
1 #ifndef PREEMPT_H
2 #define PREEMPT_H
3
4 #include <stdbool.h>
5
6 #include "bug_on.h"
7
8 /* This flag contains garbage if preempt_disable_count is 0. */
9 extern __thread int thread_cpu_id;
10
11 /* Support recursive preemption disabling. */
12 extern __thread int preempt_disable_count;
13
14 void preempt_disable(void);
15 void preempt_enable(void);
16
17 static inline void preempt_disable_notrace(void)
18 {
19         preempt_disable();
20 }
21
22 static inline void preempt_enable_no_resched(void)
23 {
24         preempt_enable();
25 }
26
27 static inline void preempt_enable_notrace(void)
28 {
29         preempt_enable();
30 }
31
32 static inline int preempt_count(void)
33 {
34         return preempt_disable_count;
35 }
36
37 static inline bool preemptible(void)
38 {
39         return !preempt_count();
40 }
41
42 static inline int get_cpu(void)
43 {
44         preempt_disable();
45         return thread_cpu_id;
46 }
47
48 static inline void put_cpu(void)
49 {
50         preempt_enable();
51 }
52
53 static inline void might_sleep(void)
54 {
55         BUG_ON(preempt_disable_count);
56 }
57
58 #endif