18186b527SHans Petter Selasky /*-
28186b527SHans Petter Selasky  * Copyright (c) 2017 Mellanox Technologies, Ltd.
38186b527SHans Petter Selasky  * All rights reserved.
48186b527SHans Petter Selasky  *
58186b527SHans Petter Selasky  * Redistribution and use in source and binary forms, with or without
68186b527SHans Petter Selasky  * modification, are permitted provided that the following conditions
78186b527SHans Petter Selasky  * are met:
88186b527SHans Petter Selasky  * 1. Redistributions of source code must retain the above copyright
98186b527SHans Petter Selasky  *    notice unmodified, this list of conditions, and the following
108186b527SHans Petter Selasky  *    disclaimer.
118186b527SHans Petter Selasky  * 2. Redistributions in binary form must reproduce the above copyright
128186b527SHans Petter Selasky  *    notice, this list of conditions and the following disclaimer in the
138186b527SHans Petter Selasky  *    documentation and/or other materials provided with the distribution.
148186b527SHans Petter Selasky  *
158186b527SHans Petter Selasky  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
168186b527SHans Petter Selasky  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
178186b527SHans Petter Selasky  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
188186b527SHans Petter Selasky  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
198186b527SHans Petter Selasky  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
208186b527SHans Petter Selasky  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
218186b527SHans Petter Selasky  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
228186b527SHans Petter Selasky  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
238186b527SHans Petter Selasky  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
248186b527SHans Petter Selasky  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
258186b527SHans Petter Selasky  */
268186b527SHans Petter Selasky 
27307f78f3SVladimir Kondratyev #ifndef _LINUXKPI_LINUX_PREEMPT_H_
28307f78f3SVladimir Kondratyev #define	_LINUXKPI_LINUX_PREEMPT_H_
298186b527SHans Petter Selasky 
30f12af2b3SEmmanuel Vadot #include <linux/hardirq.h>
318186b527SHans Petter Selasky #include <linux/list.h>
328186b527SHans Petter Selasky 
338186b527SHans Petter Selasky #define	in_interrupt() \
348186b527SHans Petter Selasky 	(curthread->td_intr_nesting_level || curthread->td_critnest)
358186b527SHans Petter Selasky 
366da2681fSJohannes Lundberg #define	in_task() (curthread->td_priority >= PI_SOFT)
376da2681fSJohannes Lundberg 
38cb564d24SMark Johnston #define	preempt_disable()	critical_enter()
39cb564d24SMark Johnston #define	preempt_enable()	critical_exit()
40cb564d24SMark Johnston 
41307f78f3SVladimir Kondratyev #endif					/* _LINUXKPI_LINUX_PREEMPT_H_ */
42