aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h28
1 files changed, 21 insertions, 7 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index fac104e7186a..f4e3184fa054 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -125,7 +125,7 @@ extern int _cond_resched(void);
125#endif 125#endif
126 126
127#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP 127#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
128 void __might_sleep(char *file, int line); 128 void __might_sleep(char *file, int line, int preempt_offset);
129/** 129/**
130 * might_sleep - annotation for functions that can sleep 130 * might_sleep - annotation for functions that can sleep
131 * 131 *
@@ -137,15 +137,16 @@ extern int _cond_resched(void);
137 * supposed to. 137 * supposed to.
138 */ 138 */
139# define might_sleep() \ 139# define might_sleep() \
140 do { __might_sleep(__FILE__, __LINE__); might_resched(); } while (0) 140 do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0)
141#else 141#else
142 static inline void __might_sleep(char *file, int line, int preempt_offset) { }
142# define might_sleep() do { might_resched(); } while (0) 143# define might_sleep() do { might_resched(); } while (0)
143#endif 144#endif
144 145
145#define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) 146#define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
146 147
147#define abs(x) ({ \ 148#define abs(x) ({ \
148 int __x = (x); \ 149 long __x = (x); \
149 (__x < 0) ? -__x : __x; \ 150 (__x < 0) ? -__x : __x; \
150 }) 151 })
151 152
@@ -245,14 +246,16 @@ extern int printk_ratelimit(void);
245extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, 246extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
246 unsigned int interval_msec); 247 unsigned int interval_msec);
247 248
249extern int printk_delay_msec;
250
248/* 251/*
249 * Print a one-time message (analogous to WARN_ONCE() et al): 252 * Print a one-time message (analogous to WARN_ONCE() et al):
250 */ 253 */
251#define printk_once(x...) ({ \ 254#define printk_once(x...) ({ \
252 static int __print_once = 1; \ 255 static bool __print_once = true; \
253 \ 256 \
254 if (__print_once) { \ 257 if (__print_once) { \
255 __print_once = 0; \ 258 __print_once = false; \
256 printk(x); \ 259 printk(x); \
257 } \ 260 } \
258}) 261})
@@ -303,6 +306,7 @@ extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in
303extern int panic_timeout; 306extern int panic_timeout;
304extern int panic_on_oops; 307extern int panic_on_oops;
305extern int panic_on_unrecovered_nmi; 308extern int panic_on_unrecovered_nmi;
309extern int panic_on_io_nmi;
306extern const char *print_tainted(void); 310extern const char *print_tainted(void);
307extern void add_taint(unsigned flag); 311extern void add_taint(unsigned flag);
308extern int test_taint(unsigned flag); 312extern int test_taint(unsigned flag);
@@ -655,6 +659,12 @@ extern int do_sysinfo(struct sysinfo *info);
655 659
656#endif /* __KERNEL__ */ 660#endif /* __KERNEL__ */
657 661
662#ifndef __EXPORTED_HEADERS__
663#ifndef __KERNEL__
664#warning Attempt to use kernel headers from user space, see http://kernelnewbies.org/KernelHeaders
665#endif /* __KERNEL__ */
666#endif /* __EXPORTED_HEADERS__ */
667
658#define SI_LOAD_SHIFT 16 668#define SI_LOAD_SHIFT 16
659struct sysinfo { 669struct sysinfo {
660 long uptime; /* Seconds since boot */ 670 long uptime; /* Seconds since boot */
@@ -674,13 +684,17 @@ struct sysinfo {
674}; 684};
675 685
676/* Force a compilation error if condition is true */ 686/* Force a compilation error if condition is true */
677#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) 687#define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition))
688
689/* Force a compilation error if condition is constant and true */
690#define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)]))
678 691
679/* Force a compilation error if condition is true, but also produce a 692/* Force a compilation error if condition is true, but also produce a
680 result (of value 0 and type size_t), so the expression can be used 693 result (of value 0 and type size_t), so the expression can be used
681 e.g. in a structure initializer (or where-ever else comma expressions 694 e.g. in a structure initializer (or where-ever else comma expressions
682 aren't permitted). */ 695 aren't permitted). */
683#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1) 696#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
697#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
684 698
685/* Trap pasters of __FUNCTION__ at compile-time */ 699/* Trap pasters of __FUNCTION__ at compile-time */
686#define __FUNCTION__ (__func__) 700#define __FUNCTION__ (__func__)