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.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d6320a3e8def..d3cd23f30039 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})
@@ -675,13 +678,17 @@ struct sysinfo {
675}; 678};
676 679
677/* Force a compilation error if condition is true */ 680/* Force a compilation error if condition is true */
678#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) 681#define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition))
682
683/* Force a compilation error if condition is constant and true */
684#define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)]))
679 685
680/* Force a compilation error if condition is true, but also produce a 686/* Force a compilation error if condition is true, but also produce a
681 result (of value 0 and type size_t), so the expression can be used 687 result (of value 0 and type size_t), so the expression can be used
682 e.g. in a structure initializer (or where-ever else comma expressions 688 e.g. in a structure initializer (or where-ever else comma expressions
683 aren't permitted). */ 689 aren't permitted). */
684#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1) 690#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
691#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
685 692
686/* Trap pasters of __FUNCTION__ at compile-time */ 693/* Trap pasters of __FUNCTION__ at compile-time */
687#define __FUNCTION__ (__func__) 694#define __FUNCTION__ (__func__)