1/*-
2 * Copyright (c) 2010 Isilon Systems, Inc.
3 * Copyright (c) 2010 iX Systems, Inc.
4 * Copyright (c) 2010 Panasas, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice unmodified, this list of conditions, and the following
12 *    disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28#ifndef	_LINUX_KERNEL_H_
29#define	_LINUX_KERNEL_H_
30
31#include <sys/systm.h>
32#include <sys/param.h>
33#include <sys/libkern.h>
34#include <sys/stat.h>
35#include <sys/smp.h>
36
37#include <linux/bitops.h>
38#include <linux/compiler.h>
39#include <linux/errno.h>
40#include <linux/stddef.h>
41#include <linux/kthread.h>
42#include <linux/types.h>
43#include <linux/jiffies.h>
44#include <linux/wait.h>
45#include <linux/fs.h>
46#include <linux/notifier.h>
47#include <linux/log2.h>
48#include <asm/byteorder.h>
49
50#define	KERN_EMERG	"<0>"
51#define	KERN_ALERT	"<1>"
52#define	KERN_CRIT	"<2>"
53#define	KERN_ERR	"<3>"
54#define	KERN_WARNING	"<4>"
55#define	KERN_NOTICE	"<5>"
56#define	KERN_INFO	"<6>"
57#define	KERN_DEBUG	"<7>"
58
59#define BUG()			panic("BUG")
60#define BUG_ON(condition)	do { if (condition) BUG(); } while(0)
61#define	WARN_ON			BUG_ON
62
63#undef	ALIGN
64#define	ALIGN(x, y)		roundup2((x), (y))
65#define	DIV_ROUND_UP		howmany
66
67#define	printk(X...)		printf(X)
68#define	pr_debug(fmt, ...)	printk(KERN_DEBUG # fmt, ##__VA_ARGS__)
69#define udelay(t)       	DELAY(t)
70
71#define container_of(ptr, type, member)				\
72({								\
73	__typeof(((type *)0)->member) *_p = (ptr);		\
74	(type *)((char *)_p - offsetof(type, member));		\
75})
76
77#define	ARRAY_SIZE(x)	(sizeof(x) / sizeof((x)[0]))
78
79#define	simple_strtoul	strtoul
80
81#define min(x, y)	(x < y ? x : y)
82#define max(x, y)	(x > y ? x : y)
83#define min_t(type, _x, _y)	(type)(_x) < (type)(_y) ? (type)(_x) : (_y)
84#define max_t(type, _x, _y)	(type)(_x) > (type)(_y) ? (type)(_x) : (_y)
85
86#define	num_possible_cpus()	mp_ncpus
87
88#endif	/* _LINUX_KERNEL_H_ */
89