diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2010-12-30 00:20:30 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-12-30 00:21:47 -0500 |
commit | d392da5207352f09030e95d9ea335a4225667ec0 (patch) | |
tree | 7d6cd1932afcad0a5619a5c504a6d93ca318187c /include/linux/kernel.h | |
parent | e39d5ef678045d61812c1401f04fe8edb14d6359 (diff) | |
parent | 387c31c7e5c9805b0aef8833d1731a5fe7bdea14 (diff) |
Merge v2.6.37-rc8 into powerpc/next
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 289 |
1 files changed, 52 insertions, 237 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 5b57236dfbd0..b6de9a6f7018 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,18 @@ 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 | #define roundup(x, y) ( \ |
60 | { \ | ||
61 | const typeof(y) __y = y; \ | ||
62 | (((x) + (__y - 1)) / __y) * __y; \ | ||
63 | } \ | ||
64 | ) | ||
65 | #define rounddown(x, y) ( \ | ||
66 | { \ | ||
67 | typeof(x) __x = (x); \ | ||
68 | __x - (__x % (y)); \ | ||
69 | } \ | ||
70 | ) | ||
62 | #define DIV_ROUND_CLOSEST(x, divisor)( \ | 71 | #define DIV_ROUND_CLOSEST(x, divisor)( \ |
63 | { \ | 72 | { \ |
64 | typeof(divisor) __divisor = divisor; \ | 73 | typeof(divisor) __divisor = divisor; \ |
@@ -99,31 +108,6 @@ extern const char linux_proc_banner[]; | |||
99 | */ | 108 | */ |
100 | #define lower_32_bits(n) ((u32)(n)) | 109 | #define lower_32_bits(n) ((u32)(n)) |
101 | 110 | ||
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; | 111 | struct completion; |
128 | struct pt_regs; | 112 | struct pt_regs; |
129 | struct user; | 113 | struct user; |
@@ -162,6 +146,11 @@ extern int _cond_resched(void); | |||
162 | (__x < 0) ? -__x : __x; \ | 146 | (__x < 0) ? -__x : __x; \ |
163 | }) | 147 | }) |
164 | 148 | ||
149 | #define abs64(x) ({ \ | ||
150 | s64 __x = (x); \ | ||
151 | (__x < 0) ? -__x : __x; \ | ||
152 | }) | ||
153 | |||
165 | #ifdef CONFIG_PROVE_LOCKING | 154 | #ifdef CONFIG_PROVE_LOCKING |
166 | void might_fault(void); | 155 | void might_fault(void); |
167 | #else | 156 | #else |
@@ -171,17 +160,13 @@ static inline void might_fault(void) | |||
171 | } | 160 | } |
172 | #endif | 161 | #endif |
173 | 162 | ||
174 | struct va_format { | ||
175 | const char *fmt; | ||
176 | va_list *va; | ||
177 | }; | ||
178 | |||
179 | extern struct atomic_notifier_head panic_notifier_list; | 163 | extern struct atomic_notifier_head panic_notifier_list; |
180 | extern long (*panic_blink)(long time); | 164 | extern long (*panic_blink)(int state); |
181 | NORET_TYPE void panic(const char * fmt, ...) | 165 | NORET_TYPE void panic(const char * fmt, ...) |
182 | __attribute__ ((NORET_AND format (printf, 1, 2))) __cold; | 166 | __attribute__ ((NORET_AND format (printf, 1, 2))) __cold; |
183 | extern void oops_enter(void); | 167 | extern void oops_enter(void); |
184 | extern void oops_exit(void); | 168 | extern void oops_exit(void); |
169 | void print_oops_end_marker(void); | ||
185 | extern int oops_may_print(void); | 170 | extern int oops_may_print(void); |
186 | NORET_TYPE void do_exit(long error_code) | 171 | NORET_TYPE void do_exit(long error_code) |
187 | ATTRIB_NORET; | 172 | ATTRIB_NORET; |
@@ -191,10 +176,10 @@ extern unsigned long simple_strtoul(const char *,char **,unsigned int); | |||
191 | extern long simple_strtol(const char *,char **,unsigned int); | 176 | extern long simple_strtol(const char *,char **,unsigned int); |
192 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); | 177 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); |
193 | extern long long simple_strtoll(const char *,char **,unsigned int); | 178 | extern long long simple_strtoll(const char *,char **,unsigned int); |
194 | extern int strict_strtoul(const char *, unsigned int, unsigned long *); | 179 | extern int __must_check strict_strtoul(const char *, unsigned int, unsigned long *); |
195 | extern int strict_strtol(const char *, unsigned int, long *); | 180 | extern int __must_check strict_strtol(const char *, unsigned int, long *); |
196 | extern int strict_strtoull(const char *, unsigned int, unsigned long long *); | 181 | extern int __must_check strict_strtoull(const char *, unsigned int, unsigned long long *); |
197 | extern int strict_strtoll(const char *, unsigned int, long long *); | 182 | extern int __must_check strict_strtoll(const char *, unsigned int, long long *); |
198 | extern int sprintf(char * buf, const char * fmt, ...) | 183 | extern int sprintf(char * buf, const char * fmt, ...) |
199 | __attribute__ ((format (printf, 2, 3))); | 184 | __attribute__ ((format (printf, 2, 3))); |
200 | extern int vsprintf(char *buf, const char *, va_list) | 185 | extern int vsprintf(char *buf, const char *, va_list) |
@@ -228,102 +213,8 @@ extern int func_ptr_is_kernel_text(void *ptr); | |||
228 | struct pid; | 213 | struct pid; |
229 | extern struct pid *session_of_pgrp(struct pid *pgrp); | 214 | extern struct pid *session_of_pgrp(struct pid *pgrp); |
230 | 215 | ||
231 | /* | ||
232 | * FW_BUG | ||
233 | * Add this to a message where you are sure the firmware is buggy or behaves | ||
234 | * really stupid or out of spec. Be aware that the responsible BIOS developer | ||
235 | * should be able to fix this issue or at least get a concrete idea of the | ||
236 | * problem by reading your message without the need of looking at the kernel | ||
237 | * code. | ||
238 | * | ||
239 | * Use it for definite and high priority BIOS bugs. | ||
240 | * | ||
241 | * FW_WARN | ||
242 | * Use it for not that clear (e.g. could the kernel messed up things already?) | ||
243 | * and medium priority BIOS bugs. | ||
244 | * | ||
245 | * FW_INFO | ||
246 | * Use this one if you want to tell the user or vendor about something | ||
247 | * suspicious, but generally harmless related to the firmware. | ||
248 | * | ||
249 | * Use it for information or very low priority BIOS bugs. | ||
250 | */ | ||
251 | #define FW_BUG "[Firmware Bug]: " | ||
252 | #define FW_WARN "[Firmware Warn]: " | ||
253 | #define FW_INFO "[Firmware Info]: " | ||
254 | |||
255 | /* | ||
256 | * HW_ERR | ||
257 | * Add this to a message for hardware errors, so that user can report | ||
258 | * it to hardware vendor instead of LKML or software vendor. | ||
259 | */ | ||
260 | #define HW_ERR "[Hardware Error]: " | ||
261 | |||
262 | #ifdef CONFIG_PRINTK | ||
263 | asmlinkage int vprintk(const char *fmt, va_list args) | ||
264 | __attribute__ ((format (printf, 1, 0))); | ||
265 | asmlinkage int printk(const char * fmt, ...) | ||
266 | __attribute__ ((format (printf, 1, 2))) __cold; | ||
267 | |||
268 | extern int __printk_ratelimit(const char *func); | ||
269 | #define printk_ratelimit() __printk_ratelimit(__func__) | ||
270 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, | ||
271 | unsigned int interval_msec); | ||
272 | |||
273 | extern int printk_delay_msec; | ||
274 | |||
275 | /* | ||
276 | * Print a one-time message (analogous to WARN_ONCE() et al): | ||
277 | */ | ||
278 | #define printk_once(x...) ({ \ | ||
279 | static bool __print_once; \ | ||
280 | \ | ||
281 | if (!__print_once) { \ | ||
282 | __print_once = true; \ | ||
283 | printk(x); \ | ||
284 | } \ | ||
285 | }) | ||
286 | |||
287 | void log_buf_kexec_setup(void); | ||
288 | #else | ||
289 | static inline int vprintk(const char *s, va_list args) | ||
290 | __attribute__ ((format (printf, 1, 0))); | ||
291 | static inline int vprintk(const char *s, va_list args) { return 0; } | ||
292 | static inline int printk(const char *s, ...) | ||
293 | __attribute__ ((format (printf, 1, 2))); | ||
294 | static inline int __cold printk(const char *s, ...) { return 0; } | ||
295 | static inline int printk_ratelimit(void) { return 0; } | ||
296 | static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ | ||
297 | unsigned int interval_msec) \ | ||
298 | { return false; } | ||
299 | |||
300 | /* No effect, but we still get type checking even in the !PRINTK case: */ | ||
301 | #define printk_once(x...) printk(x) | ||
302 | |||
303 | static inline void log_buf_kexec_setup(void) | ||
304 | { | ||
305 | } | ||
306 | #endif | ||
307 | |||
308 | extern int printk_needs_cpu(int cpu); | ||
309 | extern void printk_tick(void); | ||
310 | |||
311 | extern void asmlinkage __attribute__((format(printf, 1, 2))) | ||
312 | early_printk(const char *fmt, ...); | ||
313 | |||
314 | unsigned long int_sqrt(unsigned long); | 216 | unsigned long int_sqrt(unsigned long); |
315 | 217 | ||
316 | static inline void console_silent(void) | ||
317 | { | ||
318 | console_loglevel = 0; | ||
319 | } | ||
320 | |||
321 | static inline void console_verbose(void) | ||
322 | { | ||
323 | if (console_loglevel) | ||
324 | console_loglevel = 15; | ||
325 | } | ||
326 | |||
327 | extern void bust_spinlocks(int yes); | 218 | extern void bust_spinlocks(int yes); |
328 | extern void wake_up_klogd(void); | 219 | extern void wake_up_klogd(void); |
329 | extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ | 220 | extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ |
@@ -360,22 +251,6 @@ extern enum system_states { | |||
360 | #define TAINT_CRAP 10 | 251 | #define TAINT_CRAP 10 |
361 | #define TAINT_FIRMWARE_WORKAROUND 11 | 252 | #define TAINT_FIRMWARE_WORKAROUND 11 |
362 | 253 | ||
363 | extern void dump_stack(void) __cold; | ||
364 | |||
365 | enum { | ||
366 | DUMP_PREFIX_NONE, | ||
367 | DUMP_PREFIX_ADDRESS, | ||
368 | DUMP_PREFIX_OFFSET | ||
369 | }; | ||
370 | extern void hex_dump_to_buffer(const void *buf, size_t len, | ||
371 | int rowsize, int groupsize, | ||
372 | char *linebuf, size_t linebuflen, bool ascii); | ||
373 | extern void print_hex_dump(const char *level, const char *prefix_str, | ||
374 | int prefix_type, int rowsize, int groupsize, | ||
375 | const void *buf, size_t len, bool ascii); | ||
376 | extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, | ||
377 | const void *buf, size_t len); | ||
378 | |||
379 | extern const char hex_asc[]; | 254 | extern const char hex_asc[]; |
380 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] | 255 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] |
381 | #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] | 256 | #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] |
@@ -389,94 +264,6 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
389 | 264 | ||
390 | extern int hex_to_bin(char ch); | 265 | extern int hex_to_bin(char ch); |
391 | 266 | ||
392 | #ifndef pr_fmt | ||
393 | #define pr_fmt(fmt) fmt | ||
394 | #endif | ||
395 | |||
396 | #define pr_emerg(fmt, ...) \ | ||
397 | printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) | ||
398 | #define pr_alert(fmt, ...) \ | ||
399 | printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) | ||
400 | #define pr_crit(fmt, ...) \ | ||
401 | printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) | ||
402 | #define pr_err(fmt, ...) \ | ||
403 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | ||
404 | #define pr_warning(fmt, ...) \ | ||
405 | printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | ||
406 | #define pr_warn pr_warning | ||
407 | #define pr_notice(fmt, ...) \ | ||
408 | printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | ||
409 | #define pr_info(fmt, ...) \ | ||
410 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ||
411 | #define pr_cont(fmt, ...) \ | ||
412 | printk(KERN_CONT fmt, ##__VA_ARGS__) | ||
413 | |||
414 | /* pr_devel() should produce zero code unless DEBUG is defined */ | ||
415 | #ifdef DEBUG | ||
416 | #define pr_devel(fmt, ...) \ | ||
417 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
418 | #else | ||
419 | #define pr_devel(fmt, ...) \ | ||
420 | ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) | ||
421 | #endif | ||
422 | |||
423 | /* If you are writing a driver, please use dev_dbg instead */ | ||
424 | #if defined(DEBUG) | ||
425 | #define pr_debug(fmt, ...) \ | ||
426 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
427 | #elif defined(CONFIG_DYNAMIC_DEBUG) | ||
428 | /* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ | ||
429 | #define pr_debug(fmt, ...) \ | ||
430 | dynamic_pr_debug(fmt, ##__VA_ARGS__) | ||
431 | #else | ||
432 | #define pr_debug(fmt, ...) \ | ||
433 | ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) | ||
434 | #endif | ||
435 | |||
436 | /* | ||
437 | * ratelimited messages with local ratelimit_state, | ||
438 | * no local ratelimit_state used in the !PRINTK case | ||
439 | */ | ||
440 | #ifdef CONFIG_PRINTK | ||
441 | #define printk_ratelimited(fmt, ...) ({ \ | ||
442 | static DEFINE_RATELIMIT_STATE(_rs, \ | ||
443 | DEFAULT_RATELIMIT_INTERVAL, \ | ||
444 | DEFAULT_RATELIMIT_BURST); \ | ||
445 | \ | ||
446 | if (__ratelimit(&_rs)) \ | ||
447 | printk(fmt, ##__VA_ARGS__); \ | ||
448 | }) | ||
449 | #else | ||
450 | /* No effect, but we still get type checking even in the !PRINTK case: */ | ||
451 | #define printk_ratelimited printk | ||
452 | #endif | ||
453 | |||
454 | #define pr_emerg_ratelimited(fmt, ...) \ | ||
455 | printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) | ||
456 | #define pr_alert_ratelimited(fmt, ...) \ | ||
457 | printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) | ||
458 | #define pr_crit_ratelimited(fmt, ...) \ | ||
459 | printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) | ||
460 | #define pr_err_ratelimited(fmt, ...) \ | ||
461 | printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | ||
462 | #define pr_warning_ratelimited(fmt, ...) \ | ||
463 | printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | ||
464 | #define pr_warn_ratelimited pr_warning_ratelimited | ||
465 | #define pr_notice_ratelimited(fmt, ...) \ | ||
466 | printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | ||
467 | #define pr_info_ratelimited(fmt, ...) \ | ||
468 | printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ||
469 | /* no pr_cont_ratelimited, don't do that... */ | ||
470 | /* If you are writing a driver, please use dev_dbg instead */ | ||
471 | #if defined(DEBUG) | ||
472 | #define pr_debug_ratelimited(fmt, ...) \ | ||
473 | printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
474 | #else | ||
475 | #define pr_debug_ratelimited(fmt, ...) \ | ||
476 | ({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \ | ||
477 | ##__VA_ARGS__); 0; }) | ||
478 | #endif | ||
479 | |||
480 | /* | 267 | /* |
481 | * General tracing related utility functions - trace_printk(), | 268 | * General tracing related utility functions - trace_printk(), |
482 | * tracing_on/tracing_off and tracing_start()/tracing_stop | 269 | * tracing_on/tracing_off and tracing_start()/tracing_stop |
@@ -632,6 +419,34 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
632 | (void) (&_max1 == &_max2); \ | 419 | (void) (&_max1 == &_max2); \ |
633 | _max1 > _max2 ? _max1 : _max2; }) | 420 | _max1 > _max2 ? _max1 : _max2; }) |
634 | 421 | ||
422 | #define min3(x, y, z) ({ \ | ||
423 | typeof(x) _min1 = (x); \ | ||
424 | typeof(y) _min2 = (y); \ | ||
425 | typeof(z) _min3 = (z); \ | ||
426 | (void) (&_min1 == &_min2); \ | ||
427 | (void) (&_min1 == &_min3); \ | ||
428 | _min1 < _min2 ? (_min1 < _min3 ? _min1 : _min3) : \ | ||
429 | (_min2 < _min3 ? _min2 : _min3); }) | ||
430 | |||
431 | #define max3(x, y, z) ({ \ | ||
432 | typeof(x) _max1 = (x); \ | ||
433 | typeof(y) _max2 = (y); \ | ||
434 | typeof(z) _max3 = (z); \ | ||
435 | (void) (&_max1 == &_max2); \ | ||
436 | (void) (&_max1 == &_max3); \ | ||
437 | _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \ | ||
438 | (_max2 > _max3 ? _max2 : _max3); }) | ||
439 | |||
440 | /** | ||
441 | * min_not_zero - return the minimum that is _not_ zero, unless both are zero | ||
442 | * @x: value1 | ||
443 | * @y: value2 | ||
444 | */ | ||
445 | #define min_not_zero(x, y) ({ \ | ||
446 | typeof(x) __x = (x); \ | ||
447 | typeof(y) __y = (y); \ | ||
448 | __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); }) | ||
449 | |||
635 | /** | 450 | /** |
636 | * clamp - return a value clamped to a given range with strict typechecking | 451 | * clamp - return a value clamped to a given range with strict typechecking |
637 | * @val: current value | 452 | * @val: current value |