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.h87
1 files changed, 49 insertions, 38 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 9365227dbaf6..2b0a35e6bc69 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -4,6 +4,8 @@
4/* 4/*
5 * 'kernel.h' contains some often-used function prototypes etc 5 * 'kernel.h' contains some often-used function prototypes etc
6 */ 6 */
7#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
8#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
7 9
8#ifdef __KERNEL__ 10#ifdef __KERNEL__
9 11
@@ -22,9 +24,9 @@
22extern const char linux_banner[]; 24extern const char linux_banner[];
23extern const char linux_proc_banner[]; 25extern const char linux_proc_banner[];
24 26
25#define USHORT_MAX ((u16)(~0U)) 27#define USHRT_MAX ((u16)(~0U))
26#define SHORT_MAX ((s16)(USHORT_MAX>>1)) 28#define SHRT_MAX ((s16)(USHRT_MAX>>1))
27#define SHORT_MIN (-SHORT_MAX - 1) 29#define SHRT_MIN ((s16)(-SHRT_MAX - 1))
28#define INT_MAX ((int)(~0U>>1)) 30#define INT_MAX ((int)(~0U>>1))
29#define INT_MIN (-INT_MAX - 1) 31#define INT_MIN (-INT_MAX - 1)
30#define UINT_MAX (~0U) 32#define UINT_MAX (~0U)
@@ -37,8 +39,8 @@ extern const char linux_proc_banner[];
37 39
38#define STACK_MAGIC 0xdeadbeef 40#define STACK_MAGIC 0xdeadbeef
39 41
40#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) 42#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
41#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) 43#define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask))
42#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a))) 44#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
43#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) 45#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
44 46
@@ -169,12 +171,18 @@ static inline void might_fault(void)
169} 171}
170#endif 172#endif
171 173
174struct va_format {
175 const char *fmt;
176 va_list *va;
177};
178
172extern struct atomic_notifier_head panic_notifier_list; 179extern struct atomic_notifier_head panic_notifier_list;
173extern long (*panic_blink)(long time); 180extern long (*panic_blink)(int state);
174NORET_TYPE void panic(const char * fmt, ...) 181NORET_TYPE void panic(const char * fmt, ...)
175 __attribute__ ((NORET_AND format (printf, 1, 2))) __cold; 182 __attribute__ ((NORET_AND format (printf, 1, 2))) __cold;
176extern void oops_enter(void); 183extern void oops_enter(void);
177extern void oops_exit(void); 184extern void oops_exit(void);
185void print_oops_end_marker(void);
178extern int oops_may_print(void); 186extern int oops_may_print(void);
179NORET_TYPE void do_exit(long error_code) 187NORET_TYPE void do_exit(long error_code)
180 ATTRIB_NORET; 188 ATTRIB_NORET;
@@ -245,6 +253,13 @@ extern struct pid *session_of_pgrp(struct pid *pgrp);
245#define FW_WARN "[Firmware Warn]: " 253#define FW_WARN "[Firmware Warn]: "
246#define FW_INFO "[Firmware Info]: " 254#define FW_INFO "[Firmware Info]: "
247 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
248#ifdef CONFIG_PRINTK 263#ifdef CONFIG_PRINTK
249asmlinkage int vprintk(const char *fmt, va_list args) 264asmlinkage int vprintk(const char *fmt, va_list args)
250 __attribute__ ((format (printf, 1, 0))); 265 __attribute__ ((format (printf, 1, 0)));
@@ -291,6 +306,13 @@ static inline void log_buf_kexec_setup(void)
291} 306}
292#endif 307#endif
293 308
309/*
310 * Dummy printk for disabled debugging statements to use whilst maintaining
311 * gcc's format and side-effect checking.
312 */
313static inline __attribute__ ((format (printf, 1, 2)))
314int no_printk(const char *s, ...) { return 0; }
315
294extern int printk_needs_cpu(int cpu); 316extern int printk_needs_cpu(int cpu);
295extern void printk_tick(void); 317extern void printk_tick(void);
296 318
@@ -344,6 +366,7 @@ extern enum system_states {
344#define TAINT_OVERRIDDEN_ACPI_TABLE 8 366#define TAINT_OVERRIDDEN_ACPI_TABLE 8
345#define TAINT_WARN 9 367#define TAINT_WARN 9
346#define TAINT_CRAP 10 368#define TAINT_CRAP 10
369#define TAINT_FIRMWARE_WORKAROUND 11
347 370
348extern void dump_stack(void) __cold; 371extern void dump_stack(void) __cold;
349 372
@@ -372,6 +395,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
372 return buf; 395 return buf;
373} 396}
374 397
398extern int hex_to_bin(char ch);
399
375#ifndef pr_fmt 400#ifndef pr_fmt
376#define pr_fmt(fmt) fmt 401#define pr_fmt(fmt) fmt
377#endif 402#endif
@@ -386,6 +411,7 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
386 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) 411 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
387#define pr_warning(fmt, ...) \ 412#define pr_warning(fmt, ...) \
388 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) 413 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
414#define pr_warn pr_warning
389#define pr_notice(fmt, ...) \ 415#define pr_notice(fmt, ...) \
390 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) 416 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
391#define pr_info(fmt, ...) \ 417#define pr_info(fmt, ...) \
@@ -420,14 +446,13 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
420 * no local ratelimit_state used in the !PRINTK case 446 * no local ratelimit_state used in the !PRINTK case
421 */ 447 */
422#ifdef CONFIG_PRINTK 448#ifdef CONFIG_PRINTK
423#define printk_ratelimited(fmt, ...) ({ \ 449#define printk_ratelimited(fmt, ...) ({ \
424 static struct ratelimit_state _rs = { \ 450 static DEFINE_RATELIMIT_STATE(_rs, \
425 .interval = DEFAULT_RATELIMIT_INTERVAL, \ 451 DEFAULT_RATELIMIT_INTERVAL, \
426 .burst = DEFAULT_RATELIMIT_BURST, \ 452 DEFAULT_RATELIMIT_BURST); \
427 }; \ 453 \
428 \ 454 if (__ratelimit(&_rs)) \
429 if (__ratelimit(&_rs)) \ 455 printk(fmt, ##__VA_ARGS__); \
430 printk(fmt, ##__VA_ARGS__); \
431}) 456})
432#else 457#else
433/* No effect, but we still get type checking even in the !PRINTK case: */ 458/* No effect, but we still get type checking even in the !PRINTK case: */
@@ -444,6 +469,7 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
444 printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) 469 printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
445#define pr_warning_ratelimited(fmt, ...) \ 470#define pr_warning_ratelimited(fmt, ...) \
446 printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) 471 printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
472#define pr_warn_ratelimited pr_warning_ratelimited
447#define pr_notice_ratelimited(fmt, ...) \ 473#define pr_notice_ratelimited(fmt, ...) \
448 printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) 474 printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
449#define pr_info_ratelimited(fmt, ...) \ 475#define pr_info_ratelimited(fmt, ...) \
@@ -490,14 +516,18 @@ static inline void tracing_off(void) { }
490static inline void tracing_off_permanent(void) { } 516static inline void tracing_off_permanent(void) { }
491static inline int tracing_is_on(void) { return 0; } 517static inline int tracing_is_on(void) { return 0; }
492#endif 518#endif
519
520enum ftrace_dump_mode {
521 DUMP_NONE,
522 DUMP_ALL,
523 DUMP_ORIG,
524};
525
493#ifdef CONFIG_TRACING 526#ifdef CONFIG_TRACING
494extern void tracing_start(void); 527extern void tracing_start(void);
495extern void tracing_stop(void); 528extern void tracing_stop(void);
496extern void ftrace_off_permanent(void); 529extern void ftrace_off_permanent(void);
497 530
498extern void
499ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
500
501static inline void __attribute__ ((format (printf, 1, 2))) 531static inline void __attribute__ ((format (printf, 1, 2)))
502____trace_printk_check_format(const char *fmt, ...) 532____trace_printk_check_format(const char *fmt, ...)
503{ 533{
@@ -571,10 +601,8 @@ __ftrace_vbprintk(unsigned long ip, const char *fmt, va_list ap);
571extern int 601extern int
572__ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); 602__ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap);
573 603
574extern void ftrace_dump(void); 604extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode);
575#else 605#else
576static inline void
577ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
578static inline int 606static inline int
579trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); 607trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
580 608
@@ -592,21 +620,10 @@ ftrace_vprintk(const char *fmt, va_list ap)
592{ 620{
593 return 0; 621 return 0;
594} 622}
595static inline void ftrace_dump(void) { } 623static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
596#endif /* CONFIG_TRACING */ 624#endif /* CONFIG_TRACING */
597 625
598/* 626/*
599 * Display an IP address in readable format.
600 */
601
602#define NIPQUAD(addr) \
603 ((unsigned char *)&addr)[0], \
604 ((unsigned char *)&addr)[1], \
605 ((unsigned char *)&addr)[2], \
606 ((unsigned char *)&addr)[3]
607#define NIPQUAD_FMT "%u.%u.%u.%u"
608
609/*
610 * min()/max()/clamp() macros that also do 627 * min()/max()/clamp() macros that also do
611 * strict type-checking.. See the 628 * strict type-checking.. See the
612 * "unnecessary" pointer comparison. 629 * "unnecessary" pointer comparison.
@@ -715,12 +732,6 @@ extern int do_sysinfo(struct sysinfo *info);
715 732
716#endif /* __KERNEL__ */ 733#endif /* __KERNEL__ */
717 734
718#ifndef __EXPORTED_HEADERS__
719#ifndef __KERNEL__
720#warning Attempt to use kernel headers from user space, see http://kernelnewbies.org/KernelHeaders
721#endif /* __KERNEL__ */
722#endif /* __EXPORTED_HEADERS__ */
723
724#define SI_LOAD_SHIFT 16 735#define SI_LOAD_SHIFT 16
725struct sysinfo { 736struct sysinfo {
726 long uptime; /* Seconds since boot */ 737 long uptime; /* Seconds since boot */