1 /* Public domain. */ 2 3 #ifndef _LINUX_PREEMPT_H 4 #define _LINUX_PREEMPT_H 5 6 #include <asm/preempt.h> 7 #include <sys/param.h> /* for curcpu in machine/cpu.h */ 8 9 static inline void 10 preempt_enable(void) 11 { 12 } 13 14 static inline void 15 preempt_disable(void) 16 { 17 } 18 19 static inline bool 20 in_irq(void) 21 { 22 #if defined(__amd64__) || defined(__arm__) || defined(__arm64__) || \ 23 defined(__i386__) || defined(__powerpc64__) || defined(__riscv64__) 24 return (curcpu()->ci_idepth > 0); 25 #else 26 return false; 27 #endif 28 } 29 30 static inline bool 31 in_interrupt(void) 32 { 33 return in_irq(); 34 } 35 36 static inline bool 37 in_task(void) 38 { 39 return !in_irq(); 40 } 41 42 static inline bool 43 in_atomic(void) 44 { 45 return false; 46 } 47 48 #endif 49