treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / tools / testing / selftests / rcutorture / formal / srcu-cbmc / src / preempt.h
blobf8b762cd214cb59520e447548014cd8220b72f24
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef PREEMPT_H
3 #define PREEMPT_H
5 #include <stdbool.h>
7 #include "bug_on.h"
9 /* This flag contains garbage if preempt_disable_count is 0. */
10 extern __thread int thread_cpu_id;
12 /* Support recursive preemption disabling. */
13 extern __thread int preempt_disable_count;
15 void preempt_disable(void);
16 void preempt_enable(void);
18 static inline void preempt_disable_notrace(void)
20 preempt_disable();
23 static inline void preempt_enable_no_resched(void)
25 preempt_enable();
28 static inline void preempt_enable_notrace(void)
30 preempt_enable();
33 static inline int preempt_count(void)
35 return preempt_disable_count;
38 static inline bool preemptible(void)
40 return !preempt_count();
43 static inline int get_cpu(void)
45 preempt_disable();
46 return thread_cpu_id;
49 static inline void put_cpu(void)
51 preempt_enable();
54 static inline void might_sleep(void)
56 BUG_ON(preempt_disable_count);
59 #endif