1 /****************************************************************************** 2 * preempt.h 3 * 4 * Track atomic regions in the hypervisor which disallow sleeping. 5 * 6 * Copyright (c) 2010, Keir Fraser <keir@xen.org> 7 */ 8 9 #ifndef __XEN_PREEMPT_H__ 10 #define __XEN_PREEMPT_H__ 11 12 #include <xen/types.h> 13 #include <xen/percpu.h> 14 15 DECLARE_PER_CPU(unsigned int, __preempt_count); 16 17 #define preempt_count() (this_cpu(__preempt_count)) 18 19 #define preempt_disable() do { \ 20 preempt_count()++; \ 21 barrier(); \ 22 } while (0) 23 24 #define preempt_enable() do { \ 25 barrier(); \ 26 preempt_count()--; \ 27 } while (0) 28 29 bool_t in_atomic(void); 30 31 #ifndef NDEBUG 32 void ASSERT_NOT_IN_ATOMIC(void); 33 #else 34 #define ASSERT_NOT_IN_ATOMIC() ((void)0) 35 #endif 36 37 #endif /* __XEN_PREEMPT_H__ */ 38