diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /include/linux/kernel.h | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 454 |
1 files changed, 204 insertions, 250 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 2b0a35e6bc69..953352a88336 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -17,13 +17,11 @@ | |||
17 | #include <linux/bitops.h> | 17 | #include <linux/bitops.h> |
18 | #include <linux/log2.h> | 18 | #include <linux/log2.h> |
19 | #include <linux/typecheck.h> | 19 | #include <linux/typecheck.h> |
20 | #include <linux/printk.h> | ||
20 | #include <linux/dynamic_debug.h> | 21 | #include <linux/dynamic_debug.h> |
21 | #include <asm/byteorder.h> | 22 | #include <asm/byteorder.h> |
22 | #include <asm/bug.h> | 23 | #include <asm/bug.h> |
23 | 24 | ||
24 | extern const char linux_banner[]; | ||
25 | extern const char linux_proc_banner[]; | ||
26 | |||
27 | #define USHRT_MAX ((u16)(~0U)) | 25 | #define USHRT_MAX ((u16)(~0U)) |
28 | #define SHRT_MAX ((s16)(USHRT_MAX>>1)) | 26 | #define SHRT_MAX ((s16)(USHRT_MAX>>1)) |
29 | #define SHRT_MIN ((s16)(-SHRT_MAX - 1)) | 27 | #define SHRT_MIN ((s16)(-SHRT_MAX - 1)) |
@@ -58,7 +56,20 @@ extern const char linux_proc_banner[]; | |||
58 | 56 | ||
59 | #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) | 57 | #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) |
60 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) | 58 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) |
61 | #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) | 59 | |
60 | /* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */ | ||
61 | #define roundup(x, y) ( \ | ||
62 | { \ | ||
63 | const typeof(y) __y = y; \ | ||
64 | (((x) + (__y - 1)) / __y) * __y; \ | ||
65 | } \ | ||
66 | ) | ||
67 | #define rounddown(x, y) ( \ | ||
68 | { \ | ||
69 | typeof(x) __x = (x); \ | ||
70 | __x - (__x % (y)); \ | ||
71 | } \ | ||
72 | ) | ||
62 | #define DIV_ROUND_CLOSEST(x, divisor)( \ | 73 | #define DIV_ROUND_CLOSEST(x, divisor)( \ |
63 | { \ | 74 | { \ |
64 | typeof(divisor) __divisor = divisor; \ | 75 | typeof(divisor) __divisor = divisor; \ |
@@ -99,31 +110,6 @@ extern const char linux_proc_banner[]; | |||
99 | */ | 110 | */ |
100 | #define lower_32_bits(n) ((u32)(n)) | 111 | #define lower_32_bits(n) ((u32)(n)) |
101 | 112 | ||
102 | #define KERN_EMERG "<0>" /* system is unusable */ | ||
103 | #define KERN_ALERT "<1>" /* action must be taken immediately */ | ||
104 | #define KERN_CRIT "<2>" /* critical conditions */ | ||
105 | #define KERN_ERR "<3>" /* error conditions */ | ||
106 | #define KERN_WARNING "<4>" /* warning conditions */ | ||
107 | #define KERN_NOTICE "<5>" /* normal but significant condition */ | ||
108 | #define KERN_INFO "<6>" /* informational */ | ||
109 | #define KERN_DEBUG "<7>" /* debug-level messages */ | ||
110 | |||
111 | /* Use the default kernel loglevel */ | ||
112 | #define KERN_DEFAULT "<d>" | ||
113 | /* | ||
114 | * Annotation for a "continued" line of log printout (only done after a | ||
115 | * line that had no enclosing \n). Only to be used by core/arch code | ||
116 | * during early bootup (a continued line is not SMP-safe otherwise). | ||
117 | */ | ||
118 | #define KERN_CONT "<c>" | ||
119 | |||
120 | extern int console_printk[]; | ||
121 | |||
122 | #define console_loglevel (console_printk[0]) | ||
123 | #define default_message_loglevel (console_printk[1]) | ||
124 | #define minimum_console_loglevel (console_printk[2]) | ||
125 | #define default_console_loglevel (console_printk[3]) | ||
126 | |||
127 | struct completion; | 113 | struct completion; |
128 | struct pt_regs; | 114 | struct pt_regs; |
129 | struct user; | 115 | struct user; |
@@ -157,8 +143,26 @@ extern int _cond_resched(void); | |||
157 | 143 | ||
158 | #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) | 144 | #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) |
159 | 145 | ||
160 | #define abs(x) ({ \ | 146 | /* |
161 | long __x = (x); \ | 147 | * abs() handles unsigned and signed longs, ints, shorts and chars. For all |
148 | * input types abs() returns a signed long. | ||
149 | * abs() should not be used for 64-bit types (s64, u64, long long) - use abs64() | ||
150 | * for those. | ||
151 | */ | ||
152 | #define abs(x) ({ \ | ||
153 | long ret; \ | ||
154 | if (sizeof(x) == sizeof(long)) { \ | ||
155 | long __x = (x); \ | ||
156 | ret = (__x < 0) ? -__x : __x; \ | ||
157 | } else { \ | ||
158 | int __x = (x); \ | ||
159 | ret = (__x < 0) ? -__x : __x; \ | ||
160 | } \ | ||
161 | ret; \ | ||
162 | }) | ||
163 | |||
164 | #define abs64(x) ({ \ | ||
165 | s64 __x = (x); \ | ||
162 | (__x < 0) ? -__x : __x; \ | 166 | (__x < 0) ? -__x : __x; \ |
163 | }) | 167 | }) |
164 | 168 | ||
@@ -171,11 +175,6 @@ static inline void might_fault(void) | |||
171 | } | 175 | } |
172 | #endif | 176 | #endif |
173 | 177 | ||
174 | struct va_format { | ||
175 | const char *fmt; | ||
176 | va_list *va; | ||
177 | }; | ||
178 | |||
179 | extern struct atomic_notifier_head panic_notifier_list; | 178 | extern struct atomic_notifier_head panic_notifier_list; |
180 | extern long (*panic_blink)(int state); | 179 | extern long (*panic_blink)(int state); |
181 | NORET_TYPE void panic(const char * fmt, ...) | 180 | NORET_TYPE void panic(const char * fmt, ...) |
@@ -188,14 +187,107 @@ NORET_TYPE void do_exit(long error_code) | |||
188 | ATTRIB_NORET; | 187 | ATTRIB_NORET; |
189 | NORET_TYPE void complete_and_exit(struct completion *, long) | 188 | NORET_TYPE void complete_and_exit(struct completion *, long) |
190 | ATTRIB_NORET; | 189 | ATTRIB_NORET; |
190 | |||
191 | /* Internal, do not use. */ | ||
192 | int __must_check _kstrtoul(const char *s, unsigned int base, unsigned long *res); | ||
193 | int __must_check _kstrtol(const char *s, unsigned int base, long *res); | ||
194 | |||
195 | int __must_check kstrtoull(const char *s, unsigned int base, unsigned long long *res); | ||
196 | int __must_check kstrtoll(const char *s, unsigned int base, long long *res); | ||
197 | static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res) | ||
198 | { | ||
199 | /* | ||
200 | * We want to shortcut function call, but | ||
201 | * __builtin_types_compatible_p(unsigned long, unsigned long long) = 0. | ||
202 | */ | ||
203 | if (sizeof(unsigned long) == sizeof(unsigned long long) && | ||
204 | __alignof__(unsigned long) == __alignof__(unsigned long long)) | ||
205 | return kstrtoull(s, base, (unsigned long long *)res); | ||
206 | else | ||
207 | return _kstrtoul(s, base, res); | ||
208 | } | ||
209 | |||
210 | static inline int __must_check kstrtol(const char *s, unsigned int base, long *res) | ||
211 | { | ||
212 | /* | ||
213 | * We want to shortcut function call, but | ||
214 | * __builtin_types_compatible_p(long, long long) = 0. | ||
215 | */ | ||
216 | if (sizeof(long) == sizeof(long long) && | ||
217 | __alignof__(long) == __alignof__(long long)) | ||
218 | return kstrtoll(s, base, (long long *)res); | ||
219 | else | ||
220 | return _kstrtol(s, base, res); | ||
221 | } | ||
222 | |||
223 | int __must_check kstrtouint(const char *s, unsigned int base, unsigned int *res); | ||
224 | int __must_check kstrtoint(const char *s, unsigned int base, int *res); | ||
225 | |||
226 | static inline int __must_check kstrtou64(const char *s, unsigned int base, u64 *res) | ||
227 | { | ||
228 | return kstrtoull(s, base, res); | ||
229 | } | ||
230 | |||
231 | static inline int __must_check kstrtos64(const char *s, unsigned int base, s64 *res) | ||
232 | { | ||
233 | return kstrtoll(s, base, res); | ||
234 | } | ||
235 | |||
236 | static inline int __must_check kstrtou32(const char *s, unsigned int base, u32 *res) | ||
237 | { | ||
238 | return kstrtouint(s, base, res); | ||
239 | } | ||
240 | |||
241 | static inline int __must_check kstrtos32(const char *s, unsigned int base, s32 *res) | ||
242 | { | ||
243 | return kstrtoint(s, base, res); | ||
244 | } | ||
245 | |||
246 | int __must_check kstrtou16(const char *s, unsigned int base, u16 *res); | ||
247 | int __must_check kstrtos16(const char *s, unsigned int base, s16 *res); | ||
248 | int __must_check kstrtou8(const char *s, unsigned int base, u8 *res); | ||
249 | int __must_check kstrtos8(const char *s, unsigned int base, s8 *res); | ||
250 | |||
251 | int __must_check kstrtoull_from_user(const char __user *s, size_t count, unsigned int base, unsigned long long *res); | ||
252 | int __must_check kstrtoll_from_user(const char __user *s, size_t count, unsigned int base, long long *res); | ||
253 | int __must_check kstrtoul_from_user(const char __user *s, size_t count, unsigned int base, unsigned long *res); | ||
254 | int __must_check kstrtol_from_user(const char __user *s, size_t count, unsigned int base, long *res); | ||
255 | int __must_check kstrtouint_from_user(const char __user *s, size_t count, unsigned int base, unsigned int *res); | ||
256 | int __must_check kstrtoint_from_user(const char __user *s, size_t count, unsigned int base, int *res); | ||
257 | int __must_check kstrtou16_from_user(const char __user *s, size_t count, unsigned int base, u16 *res); | ||
258 | int __must_check kstrtos16_from_user(const char __user *s, size_t count, unsigned int base, s16 *res); | ||
259 | int __must_check kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, u8 *res); | ||
260 | int __must_check kstrtos8_from_user(const char __user *s, size_t count, unsigned int base, s8 *res); | ||
261 | |||
262 | static inline int __must_check kstrtou64_from_user(const char __user *s, size_t count, unsigned int base, u64 *res) | ||
263 | { | ||
264 | return kstrtoull_from_user(s, count, base, res); | ||
265 | } | ||
266 | |||
267 | static inline int __must_check kstrtos64_from_user(const char __user *s, size_t count, unsigned int base, s64 *res) | ||
268 | { | ||
269 | return kstrtoll_from_user(s, count, base, res); | ||
270 | } | ||
271 | |||
272 | static inline int __must_check kstrtou32_from_user(const char __user *s, size_t count, unsigned int base, u32 *res) | ||
273 | { | ||
274 | return kstrtouint_from_user(s, count, base, res); | ||
275 | } | ||
276 | |||
277 | static inline int __must_check kstrtos32_from_user(const char __user *s, size_t count, unsigned int base, s32 *res) | ||
278 | { | ||
279 | return kstrtoint_from_user(s, count, base, res); | ||
280 | } | ||
281 | |||
191 | extern unsigned long simple_strtoul(const char *,char **,unsigned int); | 282 | extern unsigned long simple_strtoul(const char *,char **,unsigned int); |
192 | extern long simple_strtol(const char *,char **,unsigned int); | 283 | extern long simple_strtol(const char *,char **,unsigned int); |
193 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); | 284 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); |
194 | extern long long simple_strtoll(const char *,char **,unsigned int); | 285 | extern long long simple_strtoll(const char *,char **,unsigned int); |
195 | extern int strict_strtoul(const char *, unsigned int, unsigned long *); | 286 | #define strict_strtoul kstrtoul |
196 | extern int strict_strtol(const char *, unsigned int, long *); | 287 | #define strict_strtol kstrtol |
197 | extern int strict_strtoull(const char *, unsigned int, unsigned long long *); | 288 | #define strict_strtoull kstrtoull |
198 | extern int strict_strtoll(const char *, unsigned int, long long *); | 289 | #define strict_strtoll kstrtoll |
290 | |||
199 | extern int sprintf(char * buf, const char * fmt, ...) | 291 | extern int sprintf(char * buf, const char * fmt, ...) |
200 | __attribute__ ((format (printf, 2, 3))); | 292 | __attribute__ ((format (printf, 2, 3))); |
201 | extern int vsprintf(char *buf, const char *, va_list) | 293 | extern int vsprintf(char *buf, const char *, va_list) |
@@ -222,6 +314,7 @@ extern char *get_options(const char *str, int nints, int *ints); | |||
222 | extern unsigned long long memparse(const char *ptr, char **retptr); | 314 | extern unsigned long long memparse(const char *ptr, char **retptr); |
223 | 315 | ||
224 | extern int core_kernel_text(unsigned long addr); | 316 | extern int core_kernel_text(unsigned long addr); |
317 | extern int core_kernel_data(unsigned long addr); | ||
225 | extern int __kernel_text_address(unsigned long addr); | 318 | extern int __kernel_text_address(unsigned long addr); |
226 | extern int kernel_text_address(unsigned long addr); | 319 | extern int kernel_text_address(unsigned long addr); |
227 | extern int func_ptr_is_kernel_text(void *ptr); | 320 | extern int func_ptr_is_kernel_text(void *ptr); |
@@ -229,109 +322,8 @@ extern int func_ptr_is_kernel_text(void *ptr); | |||
229 | struct pid; | 322 | struct pid; |
230 | extern struct pid *session_of_pgrp(struct pid *pgrp); | 323 | extern struct pid *session_of_pgrp(struct pid *pgrp); |
231 | 324 | ||
232 | /* | ||
233 | * FW_BUG | ||
234 | * Add this to a message where you are sure the firmware is buggy or behaves | ||
235 | * really stupid or out of spec. Be aware that the responsible BIOS developer | ||
236 | * should be able to fix this issue or at least get a concrete idea of the | ||
237 | * problem by reading your message without the need of looking at the kernel | ||
238 | * code. | ||
239 | * | ||
240 | * Use it for definite and high priority BIOS bugs. | ||
241 | * | ||
242 | * FW_WARN | ||
243 | * Use it for not that clear (e.g. could the kernel messed up things already?) | ||
244 | * and medium priority BIOS bugs. | ||
245 | * | ||
246 | * FW_INFO | ||
247 | * Use this one if you want to tell the user or vendor about something | ||
248 | * suspicious, but generally harmless related to the firmware. | ||
249 | * | ||
250 | * Use it for information or very low priority BIOS bugs. | ||
251 | */ | ||
252 | #define FW_BUG "[Firmware Bug]: " | ||
253 | #define FW_WARN "[Firmware Warn]: " | ||
254 | #define FW_INFO "[Firmware Info]: " | ||
255 | |||
256 | /* | ||
257 | * HW_ERR | ||
258 | * Add this to a message for hardware errors, so that user can report | ||
259 | * it to hardware vendor instead of LKML or software vendor. | ||
260 | */ | ||
261 | #define HW_ERR "[Hardware Error]: " | ||
262 | |||
263 | #ifdef CONFIG_PRINTK | ||
264 | asmlinkage int vprintk(const char *fmt, va_list args) | ||
265 | __attribute__ ((format (printf, 1, 0))); | ||
266 | asmlinkage int printk(const char * fmt, ...) | ||
267 | __attribute__ ((format (printf, 1, 2))) __cold; | ||
268 | |||
269 | extern int __printk_ratelimit(const char *func); | ||
270 | #define printk_ratelimit() __printk_ratelimit(__func__) | ||
271 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, | ||
272 | unsigned int interval_msec); | ||
273 | |||
274 | extern int printk_delay_msec; | ||
275 | |||
276 | /* | ||
277 | * Print a one-time message (analogous to WARN_ONCE() et al): | ||
278 | */ | ||
279 | #define printk_once(x...) ({ \ | ||
280 | static bool __print_once; \ | ||
281 | \ | ||
282 | if (!__print_once) { \ | ||
283 | __print_once = true; \ | ||
284 | printk(x); \ | ||
285 | } \ | ||
286 | }) | ||
287 | |||
288 | void log_buf_kexec_setup(void); | ||
289 | #else | ||
290 | static inline int vprintk(const char *s, va_list args) | ||
291 | __attribute__ ((format (printf, 1, 0))); | ||
292 | static inline int vprintk(const char *s, va_list args) { return 0; } | ||
293 | static inline int printk(const char *s, ...) | ||
294 | __attribute__ ((format (printf, 1, 2))); | ||
295 | static inline int __cold printk(const char *s, ...) { return 0; } | ||
296 | static inline int printk_ratelimit(void) { return 0; } | ||
297 | static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ | ||
298 | unsigned int interval_msec) \ | ||
299 | { return false; } | ||
300 | |||
301 | /* No effect, but we still get type checking even in the !PRINTK case: */ | ||
302 | #define printk_once(x...) printk(x) | ||
303 | |||
304 | static inline void log_buf_kexec_setup(void) | ||
305 | { | ||
306 | } | ||
307 | #endif | ||
308 | |||
309 | /* | ||
310 | * Dummy printk for disabled debugging statements to use whilst maintaining | ||
311 | * gcc's format and side-effect checking. | ||
312 | */ | ||
313 | static inline __attribute__ ((format (printf, 1, 2))) | ||
314 | int no_printk(const char *s, ...) { return 0; } | ||
315 | |||
316 | extern int printk_needs_cpu(int cpu); | ||
317 | extern void printk_tick(void); | ||
318 | |||
319 | extern void asmlinkage __attribute__((format(printf, 1, 2))) | ||
320 | early_printk(const char *fmt, ...); | ||
321 | |||
322 | unsigned long int_sqrt(unsigned long); | 325 | unsigned long int_sqrt(unsigned long); |
323 | 326 | ||
324 | static inline void console_silent(void) | ||
325 | { | ||
326 | console_loglevel = 0; | ||
327 | } | ||
328 | |||
329 | static inline void console_verbose(void) | ||
330 | { | ||
331 | if (console_loglevel) | ||
332 | console_loglevel = 15; | ||
333 | } | ||
334 | |||
335 | extern void bust_spinlocks(int yes); | 327 | extern void bust_spinlocks(int yes); |
336 | extern void wake_up_klogd(void); | 328 | extern void wake_up_klogd(void); |
337 | extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ | 329 | extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ |
@@ -345,6 +337,8 @@ extern int test_taint(unsigned flag); | |||
345 | extern unsigned long get_taint(void); | 337 | extern unsigned long get_taint(void); |
346 | extern int root_mountflags; | 338 | extern int root_mountflags; |
347 | 339 | ||
340 | extern bool early_boot_irqs_disabled; | ||
341 | |||
348 | /* Values used for system_state */ | 342 | /* Values used for system_state */ |
349 | extern enum system_states { | 343 | extern enum system_states { |
350 | SYSTEM_BOOTING, | 344 | SYSTEM_BOOTING, |
@@ -368,22 +362,6 @@ extern enum system_states { | |||
368 | #define TAINT_CRAP 10 | 362 | #define TAINT_CRAP 10 |
369 | #define TAINT_FIRMWARE_WORKAROUND 11 | 363 | #define TAINT_FIRMWARE_WORKAROUND 11 |
370 | 364 | ||
371 | extern void dump_stack(void) __cold; | ||
372 | |||
373 | enum { | ||
374 | DUMP_PREFIX_NONE, | ||
375 | DUMP_PREFIX_ADDRESS, | ||
376 | DUMP_PREFIX_OFFSET | ||
377 | }; | ||
378 | extern void hex_dump_to_buffer(const void *buf, size_t len, | ||
379 | int rowsize, int groupsize, | ||
380 | char *linebuf, size_t linebuflen, bool ascii); | ||
381 | extern void print_hex_dump(const char *level, const char *prefix_str, | ||
382 | int prefix_type, int rowsize, int groupsize, | ||
383 | const void *buf, size_t len, bool ascii); | ||
384 | extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, | ||
385 | const void *buf, size_t len); | ||
386 | |||
387 | extern const char hex_asc[]; | 365 | extern const char hex_asc[]; |
388 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] | 366 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] |
389 | #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] | 367 | #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] |
@@ -396,94 +374,7 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
396 | } | 374 | } |
397 | 375 | ||
398 | extern int hex_to_bin(char ch); | 376 | extern int hex_to_bin(char ch); |
399 | 377 | extern void hex2bin(u8 *dst, const char *src, size_t count); | |
400 | #ifndef pr_fmt | ||
401 | #define pr_fmt(fmt) fmt | ||
402 | #endif | ||
403 | |||
404 | #define pr_emerg(fmt, ...) \ | ||
405 | printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) | ||
406 | #define pr_alert(fmt, ...) \ | ||
407 | printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) | ||
408 | #define pr_crit(fmt, ...) \ | ||
409 | printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) | ||
410 | #define pr_err(fmt, ...) \ | ||
411 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | ||
412 | #define pr_warning(fmt, ...) \ | ||
413 | printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | ||
414 | #define pr_warn pr_warning | ||
415 | #define pr_notice(fmt, ...) \ | ||
416 | printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | ||
417 | #define pr_info(fmt, ...) \ | ||
418 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ||
419 | #define pr_cont(fmt, ...) \ | ||
420 | printk(KERN_CONT fmt, ##__VA_ARGS__) | ||
421 | |||
422 | /* pr_devel() should produce zero code unless DEBUG is defined */ | ||
423 | #ifdef DEBUG | ||
424 | #define pr_devel(fmt, ...) \ | ||
425 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
426 | #else | ||
427 | #define pr_devel(fmt, ...) \ | ||
428 | ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) | ||
429 | #endif | ||
430 | |||
431 | /* If you are writing a driver, please use dev_dbg instead */ | ||
432 | #if defined(DEBUG) | ||
433 | #define pr_debug(fmt, ...) \ | ||
434 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
435 | #elif defined(CONFIG_DYNAMIC_DEBUG) | ||
436 | /* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ | ||
437 | #define pr_debug(fmt, ...) \ | ||
438 | dynamic_pr_debug(fmt, ##__VA_ARGS__) | ||
439 | #else | ||
440 | #define pr_debug(fmt, ...) \ | ||
441 | ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) | ||
442 | #endif | ||
443 | |||
444 | /* | ||
445 | * ratelimited messages with local ratelimit_state, | ||
446 | * no local ratelimit_state used in the !PRINTK case | ||
447 | */ | ||
448 | #ifdef CONFIG_PRINTK | ||
449 | #define printk_ratelimited(fmt, ...) ({ \ | ||
450 | static DEFINE_RATELIMIT_STATE(_rs, \ | ||
451 | DEFAULT_RATELIMIT_INTERVAL, \ | ||
452 | DEFAULT_RATELIMIT_BURST); \ | ||
453 | \ | ||
454 | if (__ratelimit(&_rs)) \ | ||
455 | printk(fmt, ##__VA_ARGS__); \ | ||
456 | }) | ||
457 | #else | ||
458 | /* No effect, but we still get type checking even in the !PRINTK case: */ | ||
459 | #define printk_ratelimited printk | ||
460 | #endif | ||
461 | |||
462 | #define pr_emerg_ratelimited(fmt, ...) \ | ||
463 | printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) | ||
464 | #define pr_alert_ratelimited(fmt, ...) \ | ||
465 | printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) | ||
466 | #define pr_crit_ratelimited(fmt, ...) \ | ||
467 | printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) | ||
468 | #define pr_err_ratelimited(fmt, ...) \ | ||
469 | printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | ||
470 | #define pr_warning_ratelimited(fmt, ...) \ | ||
471 | printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | ||
472 | #define pr_warn_ratelimited pr_warning_ratelimited | ||
473 | #define pr_notice_ratelimited(fmt, ...) \ | ||
474 | printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | ||
475 | #define pr_info_ratelimited(fmt, ...) \ | ||
476 | printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ||
477 | /* no pr_cont_ratelimited, don't do that... */ | ||
478 | /* If you are writing a driver, please use dev_dbg instead */ | ||
479 | #if defined(DEBUG) | ||
480 | #define pr_debug_ratelimited(fmt, ...) \ | ||
481 | printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
482 | #else | ||
483 | #define pr_debug_ratelimited(fmt, ...) \ | ||
484 | ({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \ | ||
485 | ##__VA_ARGS__); 0; }) | ||
486 | #endif | ||
487 | 378 | ||
488 | /* | 379 | /* |
489 | * General tracing related utility functions - trace_printk(), | 380 | * General tracing related utility functions - trace_printk(), |
@@ -640,6 +531,34 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
640 | (void) (&_max1 == &_max2); \ | 531 | (void) (&_max1 == &_max2); \ |
641 | _max1 > _max2 ? _max1 : _max2; }) | 532 | _max1 > _max2 ? _max1 : _max2; }) |
642 | 533 | ||
534 | #define min3(x, y, z) ({ \ | ||
535 | typeof(x) _min1 = (x); \ | ||
536 | typeof(y) _min2 = (y); \ | ||
537 | typeof(z) _min3 = (z); \ | ||
538 | (void) (&_min1 == &_min2); \ | ||
539 | (void) (&_min1 == &_min3); \ | ||
540 | _min1 < _min2 ? (_min1 < _min3 ? _min1 : _min3) : \ | ||
541 | (_min2 < _min3 ? _min2 : _min3); }) | ||
542 | |||
543 | #define max3(x, y, z) ({ \ | ||
544 | typeof(x) _max1 = (x); \ | ||
545 | typeof(y) _max2 = (y); \ | ||
546 | typeof(z) _max3 = (z); \ | ||
547 | (void) (&_max1 == &_max2); \ | ||
548 | (void) (&_max1 == &_max3); \ | ||
549 | _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \ | ||
550 | (_max2 > _max3 ? _max2 : _max3); }) | ||
551 | |||
552 | /** | ||
553 | * min_not_zero - return the minimum that is _not_ zero, unless both are zero | ||
554 | * @x: value1 | ||
555 | * @y: value2 | ||
556 | */ | ||
557 | #define min_not_zero(x, y) ({ \ | ||
558 | typeof(x) __x = (x); \ | ||
559 | typeof(y) __y = (y); \ | ||
560 | __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); }) | ||
561 | |||
643 | /** | 562 | /** |
644 | * clamp - return a value clamped to a given range with strict typechecking | 563 | * clamp - return a value clamped to a given range with strict typechecking |
645 | * @val: current value | 564 | * @val: current value |
@@ -750,11 +669,12 @@ struct sysinfo { | |||
750 | char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ | 669 | char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ |
751 | }; | 670 | }; |
752 | 671 | ||
753 | /* Force a compilation error if condition is true */ | 672 | #ifdef __CHECKER__ |
754 | #define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition)) | 673 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) |
755 | 674 | #define BUILD_BUG_ON_ZERO(e) (0) | |
756 | /* Force a compilation error if condition is constant and true */ | 675 | #define BUILD_BUG_ON_NULL(e) ((void*)0) |
757 | #define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)])) | 676 | #define BUILD_BUG_ON(condition) |
677 | #else /* __CHECKER__ */ | ||
758 | 678 | ||
759 | /* Force a compilation error if a constant expression is not a power of 2 */ | 679 | /* Force a compilation error if a constant expression is not a power of 2 */ |
760 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ | 680 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ |
@@ -767,6 +687,33 @@ struct sysinfo { | |||
767 | #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) | 687 | #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) |
768 | #define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) | 688 | #define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) |
769 | 689 | ||
690 | /** | ||
691 | * BUILD_BUG_ON - break compile if a condition is true. | ||
692 | * @condition: the condition which the compiler should know is false. | ||
693 | * | ||
694 | * If you have some code which relies on certain constants being equal, or | ||
695 | * other compile-time-evaluated condition, you should use BUILD_BUG_ON to | ||
696 | * detect if someone changes it. | ||
697 | * | ||
698 | * The implementation uses gcc's reluctance to create a negative array, but | ||
699 | * gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments | ||
700 | * to inline functions). So as a fallback we use the optimizer; if it can't | ||
701 | * prove the condition is false, it will cause a link error on the undefined | ||
702 | * "__build_bug_on_failed". This error message can be harder to track down | ||
703 | * though, hence the two different methods. | ||
704 | */ | ||
705 | #ifndef __OPTIMIZE__ | ||
706 | #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) | ||
707 | #else | ||
708 | extern int __build_bug_on_failed; | ||
709 | #define BUILD_BUG_ON(condition) \ | ||
710 | do { \ | ||
711 | ((void)sizeof(char[1 - 2*!!(condition)])); \ | ||
712 | if (condition) __build_bug_on_failed = 1; \ | ||
713 | } while(0) | ||
714 | #endif | ||
715 | #endif /* __CHECKER__ */ | ||
716 | |||
770 | /* Trap pasters of __FUNCTION__ at compile-time */ | 717 | /* Trap pasters of __FUNCTION__ at compile-time */ |
771 | #define __FUNCTION__ (__func__) | 718 | #define __FUNCTION__ (__func__) |
772 | 719 | ||
@@ -777,6 +724,13 @@ struct sysinfo { | |||
777 | #define NUMA_BUILD 0 | 724 | #define NUMA_BUILD 0 |
778 | #endif | 725 | #endif |
779 | 726 | ||
727 | /* This helps us avoid #ifdef CONFIG_COMPACTION */ | ||
728 | #ifdef CONFIG_COMPACTION | ||
729 | #define COMPACTION_BUILD 1 | ||
730 | #else | ||
731 | #define COMPACTION_BUILD 0 | ||
732 | #endif | ||
733 | |||
780 | /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ | 734 | /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ |
781 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD | 735 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD |
782 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD | 736 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD |