diff options
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 9fb1c1299032..8317ec4b9f3b 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 @@ | |||
22 | extern const char linux_banner[]; | 24 | extern const char linux_banner[]; |
23 | extern const char linux_proc_banner[]; | 25 | extern 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 | ||
@@ -344,6 +346,7 @@ extern enum system_states { | |||
344 | #define TAINT_OVERRIDDEN_ACPI_TABLE 8 | 346 | #define TAINT_OVERRIDDEN_ACPI_TABLE 8 |
345 | #define TAINT_WARN 9 | 347 | #define TAINT_WARN 9 |
346 | #define TAINT_CRAP 10 | 348 | #define TAINT_CRAP 10 |
349 | #define TAINT_FIRMWARE_WORKAROUND 11 | ||
347 | 350 | ||
348 | extern void dump_stack(void) __cold; | 351 | extern void dump_stack(void) __cold; |
349 | 352 | ||
@@ -372,6 +375,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
372 | return buf; | 375 | return buf; |
373 | } | 376 | } |
374 | 377 | ||
378 | extern int hex_to_bin(char ch); | ||
379 | |||
375 | #ifndef pr_fmt | 380 | #ifndef pr_fmt |
376 | #define pr_fmt(fmt) fmt | 381 | #define pr_fmt(fmt) fmt |
377 | #endif | 382 | #endif |
@@ -386,6 +391,7 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
386 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | 391 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) |
387 | #define pr_warning(fmt, ...) \ | 392 | #define pr_warning(fmt, ...) \ |
388 | printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | 393 | printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
394 | #define pr_warn pr_warning | ||
389 | #define pr_notice(fmt, ...) \ | 395 | #define pr_notice(fmt, ...) \ |
390 | printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | 396 | printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) |
391 | #define pr_info(fmt, ...) \ | 397 | #define pr_info(fmt, ...) \ |
@@ -420,14 +426,13 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
420 | * no local ratelimit_state used in the !PRINTK case | 426 | * no local ratelimit_state used in the !PRINTK case |
421 | */ | 427 | */ |
422 | #ifdef CONFIG_PRINTK | 428 | #ifdef CONFIG_PRINTK |
423 | #define printk_ratelimited(fmt, ...) ({ \ | 429 | #define printk_ratelimited(fmt, ...) ({ \ |
424 | static struct ratelimit_state _rs = { \ | 430 | static DEFINE_RATELIMIT_STATE(_rs, \ |
425 | .interval = DEFAULT_RATELIMIT_INTERVAL, \ | 431 | DEFAULT_RATELIMIT_INTERVAL, \ |
426 | .burst = DEFAULT_RATELIMIT_BURST, \ | 432 | DEFAULT_RATELIMIT_BURST); \ |
427 | }; \ | 433 | \ |
428 | \ | 434 | if (__ratelimit(&_rs)) \ |
429 | if (__ratelimit(&_rs)) \ | 435 | printk(fmt, ##__VA_ARGS__); \ |
430 | printk(fmt, ##__VA_ARGS__); \ | ||
431 | }) | 436 | }) |
432 | #else | 437 | #else |
433 | /* No effect, but we still get type checking even in the !PRINTK case: */ | 438 | /* No effect, but we still get type checking even in the !PRINTK case: */ |
@@ -444,6 +449,7 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
444 | printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | 449 | printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) |
445 | #define pr_warning_ratelimited(fmt, ...) \ | 450 | #define pr_warning_ratelimited(fmt, ...) \ |
446 | printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | 451 | printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
452 | #define pr_warn_ratelimited pr_warning_ratelimited | ||
447 | #define pr_notice_ratelimited(fmt, ...) \ | 453 | #define pr_notice_ratelimited(fmt, ...) \ |
448 | printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | 454 | printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) |
449 | #define pr_info_ratelimited(fmt, ...) \ | 455 | #define pr_info_ratelimited(fmt, ...) \ |