This source file includes following definitions.
- preempt_disable_notrace
- preempt_enable_no_resched
- preempt_enable_notrace
- preempt_count
- preemptible
- get_cpu
- put_cpu
- might_sleep
1
2 #ifndef PREEMPT_H
3 #define PREEMPT_H
4
5 #include <stdbool.h>
6
7 #include "bug_on.h"
8
9
10 extern __thread int thread_cpu_id;
11
12
13 extern __thread int preempt_disable_count;
14
15 void preempt_disable(void);
16 void preempt_enable(void);
17
18 static inline void preempt_disable_notrace(void)
19 {
20 preempt_disable();
21 }
22
23 static inline void preempt_enable_no_resched(void)
24 {
25 preempt_enable();
26 }
27
28 static inline void preempt_enable_notrace(void)
29 {
30 preempt_enable();
31 }
32
33 static inline int preempt_count(void)
34 {
35 return preempt_disable_count;
36 }
37
38 static inline bool preemptible(void)
39 {
40 return !preempt_count();
41 }
42
43 static inline int get_cpu(void)
44 {
45 preempt_disable();
46 return thread_cpu_id;
47 }
48
49 static inline void put_cpu(void)
50 {
51 preempt_enable();
52 }
53
54 static inline void might_sleep(void)
55 {
56 BUG_ON(preempt_disable_count);
57 }
58
59 #endif