Deleted Added
full compact
kernel.h (271127) kernel.h (277139)
1/*-
2 * Copyright (c) 2010 Isilon Systems, Inc.
3 * Copyright (c) 2010 iX Systems, Inc.
4 * Copyright (c) 2010 Panasas, Inc.
5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 21 unchanged lines hidden (view full) ---

30#define _LINUX_KERNEL_H_
31
32#include <sys/systm.h>
33#include <sys/param.h>
34#include <sys/libkern.h>
35#include <sys/stat.h>
36#include <sys/smp.h>
37#include <sys/stddef.h>
1/*-
2 * Copyright (c) 2010 Isilon Systems, Inc.
3 * Copyright (c) 2010 iX Systems, Inc.
4 * Copyright (c) 2010 Panasas, Inc.
5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 21 unchanged lines hidden (view full) ---

30#define _LINUX_KERNEL_H_
31
32#include <sys/systm.h>
33#include <sys/param.h>
34#include <sys/libkern.h>
35#include <sys/stat.h>
36#include <sys/smp.h>
37#include <sys/stddef.h>
38#include <sys/syslog.h>
38
39#include <linux/bitops.h>
40#include <linux/compiler.h>
41#include <linux/errno.h>
42#include <linux/kthread.h>
43#include <linux/types.h>
44#include <linux/jiffies.h>
45#include <linux/wait.h>

--- 14 unchanged lines hidden (view full) ---

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)
39
40#include <linux/bitops.h>
41#include <linux/compiler.h>
42#include <linux/errno.h>
43#include <linux/kthread.h>
44#include <linux/types.h>
45#include <linux/jiffies.h>
46#include <linux/wait.h>

--- 14 unchanged lines hidden (view full) ---

61#define BUG_ON(condition) do { if (condition) BUG(); } while(0)
62#define WARN_ON BUG_ON
63
64#undef ALIGN
65#define ALIGN(x, y) roundup2((x), (y))
66#define DIV_ROUND_UP howmany
67
68#define printk(X...) printf(X)
68#define pr_debug(fmt, ...) printk(KERN_DEBUG # fmt, ##__VA_ARGS__)
69
70/*
71 * The "pr_debug()" and "pr_devel()" macros should produce zero code
72 * unless DEBUG is defined:
73 */
74#ifdef DEBUG
75#define pr_debug(fmt, ...) \
76 log(LOG_DEBUG, fmt, ##__VA_ARGS__)
77#define pr_devel(fmt, ...) \
78 log(LOG_DEBUG, pr_fmt(fmt), ##__VA_ARGS__)
79#else
80#define pr_debug(fmt, ...) \
81 ({ if (0) log(LOG_DEBUG, fmt, ##__VA_ARGS__); 0; })
82#define pr_devel(fmt, ...) \
83 ({ if (0) log(LOG_DEBUG, pr_fmt(fmt), ##__VA_ARGS__); 0; })
84#endif
85
69#define udelay(t) DELAY(t)
70
71#ifndef pr_fmt
72#define pr_fmt(fmt) fmt
73#endif
74
75/*
76 * Print a one-time message (analogous to WARN_ONCE() et al):
77 */
86#define udelay(t) DELAY(t)
87
88#ifndef pr_fmt
89#define pr_fmt(fmt) fmt
90#endif
91
92/*
93 * Print a one-time message (analogous to WARN_ONCE() et al):
94 */
78#define printk_once(x...) ({ \
79 static bool __print_once; \
80 \
81 if (!__print_once) { \
82 __print_once = true; \
83 printk(x); \
84 } \
85})
95#define printk_once(...) do { \
96 static bool __print_once; \
97 \
98 if (!__print_once) { \
99 __print_once = true; \
100 printk(__VA_ARGS__); \
101 } \
102} while (0)
86
103
104/*
105 * Log a one-time message (analogous to WARN_ONCE() et al):
106 */
107#define log_once(level,...) do { \
108 static bool __log_once; \
109 \
110 if (!__log_once) { \
111 __log_once = true; \
112 log(level, __VA_ARGS__); \
113 } \
114} while (0)
87
115
88
89#define pr_emerg(fmt, ...) \
116#define pr_emerg(fmt, ...) \
90 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
117 log(LOG_EMERG, pr_fmt(fmt), ##__VA_ARGS__)
91#define pr_alert(fmt, ...) \
118#define pr_alert(fmt, ...) \
92 printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
119 log(LOG_ALERT, pr_fmt(fmt), ##__VA_ARGS__)
93#define pr_crit(fmt, ...) \
120#define pr_crit(fmt, ...) \
94 printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
121 log(LOG_CRIT, pr_fmt(fmt), ##__VA_ARGS__)
95#define pr_err(fmt, ...) \
122#define pr_err(fmt, ...) \
96 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
123 log(LOG_ERR, pr_fmt(fmt), ##__VA_ARGS__)
97#define pr_warning(fmt, ...) \
124#define pr_warning(fmt, ...) \
98 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
125 log(LOG_WARNING, pr_fmt(fmt), ##__VA_ARGS__)
99#define pr_warn pr_warning
100#define pr_notice(fmt, ...) \
126#define pr_warn pr_warning
127#define pr_notice(fmt, ...) \
101 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
128 log(LOG_NOTICE, pr_fmt(fmt), ##__VA_ARGS__)
102#define pr_info(fmt, ...) \
129#define pr_info(fmt, ...) \
103 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
130 log(LOG_INFO, pr_fmt(fmt), ##__VA_ARGS__)
104#define pr_info_once(fmt, ...) \
131#define pr_info_once(fmt, ...) \
105 printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
132 log_once(LOG_INFO, pr_fmt(fmt), ##__VA_ARGS__)
106#define pr_cont(fmt, ...) \
133#define pr_cont(fmt, ...) \
107 printk(KERN_CONT fmt, ##__VA_ARGS__)
134 printk(KERN_CONT fmt, ##__VA_ARGS__)
108
135
109/* pr_devel() should produce zero code unless DEBUG is defined */
110#ifdef DEBUG
111#define pr_devel(fmt, ...) \
112 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
113#else
114#define pr_devel(fmt, ...) \
115 ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
116#endif
117
118#ifndef WARN
119#define WARN(condition, format...) ({ \
120 int __ret_warn_on = !!(condition); \
121 if (unlikely(__ret_warn_on)) \
122 pr_warning(format); \
123 unlikely(__ret_warn_on); \
124})
125#endif

--- 5 unchanged lines hidden (view full) ---

131})
132
133#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
134
135#define simple_strtoul strtoul
136#define simple_strtol strtol
137#define kstrtol(a,b,c) ({*(c) = strtol(a,0,b);})
138
136#ifndef WARN
137#define WARN(condition, format...) ({ \
138 int __ret_warn_on = !!(condition); \
139 if (unlikely(__ret_warn_on)) \
140 pr_warning(format); \
141 unlikely(__ret_warn_on); \
142})
143#endif

--- 5 unchanged lines hidden (view full) ---

149})
150
151#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
152
153#define simple_strtoul strtoul
154#define simple_strtol strtol
155#define kstrtol(a,b,c) ({*(c) = strtol(a,0,b);})
156
139#define min(x, y) (x < y ? x : y)
140#define max(x, y) (x > y ? x : y)
141#define min_t(type, _x, _y) (type)(_x) < (type)(_y) ? (type)(_x) : (_y)
142#define max_t(type, _x, _y) (type)(_x) > (type)(_y) ? (type)(_x) : (_y)
157#define min(x, y) ((x) < (y) ? (x) : (y))
158#define max(x, y) ((x) > (y) ? (x) : (y))
159#define min_t(type, _x, _y) ((type)(_x) < (type)(_y) ? (type)(_x) : (type)(_y))
160#define max_t(type, _x, _y) ((type)(_x) > (type)(_y) ? (type)(_x) : (type)(_y))
143
144/*
145 * This looks more complex than it should be. But we need to
146 * get the type for the ~ right in round_down (it needs to be
147 * as wide as the result!), and we want to evaluate the macro
148 * arguments just once each.
149 */
150#define __round_mask(x, y) ((__typeof__(x))((y)-1))
151#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
152#define round_down(x, y) ((x) & ~__round_mask(x, y))
153
154#define num_possible_cpus() mp_ncpus
155
156typedef struct pm_message {
157 int event;
158} pm_message_t;
159
160#endif /* _LINUX_KERNEL_H_ */
161
162/*
163 * This looks more complex than it should be. But we need to
164 * get the type for the ~ right in round_down (it needs to be
165 * as wide as the result!), and we want to evaluate the macro
166 * arguments just once each.
167 */
168#define __round_mask(x, y) ((__typeof__(x))((y)-1))
169#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
170#define round_down(x, y) ((x) & ~__round_mask(x, y))
171
172#define num_possible_cpus() mp_ncpus
173
174typedef struct pm_message {
175 int event;
176} pm_message_t;
177
178#endif /* _LINUX_KERNEL_H_ */