diff options
| author | Paul Mundt <lethal@linux-sh.org> | 2011-01-13 01:06:28 -0500 |
|---|---|---|
| committer | Paul Mundt <lethal@linux-sh.org> | 2011-01-13 01:06:28 -0500 |
| commit | f43dc23d5ea91fca257be02138a255f02d98e806 (patch) | |
| tree | b29722f6e965316e90ac97abf79923ced250dc21 /include/linux/kernel.h | |
| parent | f8e53553f452dcbf67cb89c8cba63a1cd6eb4cc0 (diff) | |
| parent | 4162cf64973df51fc885825bc9ca4d055891c49f (diff) | |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 into common/serial-rework
Conflicts:
arch/sh/kernel/cpu/sh2/setup-sh7619.c
arch/sh/kernel/cpu/sh2a/setup-mxg.c
arch/sh/kernel/cpu/sh2a/setup-sh7201.c
arch/sh/kernel/cpu/sh2a/setup-sh7203.c
arch/sh/kernel/cpu/sh2a/setup-sh7206.c
arch/sh/kernel/cpu/sh3/setup-sh7705.c
arch/sh/kernel/cpu/sh3/setup-sh770x.c
arch/sh/kernel/cpu/sh3/setup-sh7710.c
arch/sh/kernel/cpu/sh3/setup-sh7720.c
arch/sh/kernel/cpu/sh4/setup-sh4-202.c
arch/sh/kernel/cpu/sh4/setup-sh7750.c
arch/sh/kernel/cpu/sh4/setup-sh7760.c
arch/sh/kernel/cpu/sh4a/setup-sh7343.c
arch/sh/kernel/cpu/sh4a/setup-sh7366.c
arch/sh/kernel/cpu/sh4a/setup-sh7722.c
arch/sh/kernel/cpu/sh4a/setup-sh7723.c
arch/sh/kernel/cpu/sh4a/setup-sh7724.c
arch/sh/kernel/cpu/sh4a/setup-sh7763.c
arch/sh/kernel/cpu/sh4a/setup-sh7770.c
arch/sh/kernel/cpu/sh4a/setup-sh7780.c
arch/sh/kernel/cpu/sh4a/setup-sh7785.c
arch/sh/kernel/cpu/sh4a/setup-sh7786.c
arch/sh/kernel/cpu/sh4a/setup-shx3.c
arch/sh/kernel/cpu/sh5/setup-sh5.c
drivers/serial/sh-sci.c
drivers/serial/sh-sci.h
include/linux/serial_sci.h
Diffstat (limited to 'include/linux/kernel.h')
| -rw-r--r-- | include/linux/kernel.h | 309 |
1 files changed, 102 insertions, 207 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index fac104e7186a..d0fbc043de60 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 | ||
| @@ -15,17 +17,14 @@ | |||
| 15 | #include <linux/bitops.h> | 17 | #include <linux/bitops.h> |
| 16 | #include <linux/log2.h> | 18 | #include <linux/log2.h> |
| 17 | #include <linux/typecheck.h> | 19 | #include <linux/typecheck.h> |
| 18 | #include <linux/ratelimit.h> | 20 | #include <linux/printk.h> |
| 19 | #include <linux/dynamic_debug.h> | 21 | #include <linux/dynamic_debug.h> |
| 20 | #include <asm/byteorder.h> | 22 | #include <asm/byteorder.h> |
| 21 | #include <asm/bug.h> | 23 | #include <asm/bug.h> |
| 22 | 24 | ||
| 23 | extern const char linux_banner[]; | 25 | #define USHRT_MAX ((u16)(~0U)) |
| 24 | extern const char linux_proc_banner[]; | 26 | #define SHRT_MAX ((s16)(USHRT_MAX>>1)) |
| 25 | 27 | #define SHRT_MIN ((s16)(-SHRT_MAX - 1)) | |
| 26 | #define USHORT_MAX ((u16)(~0U)) | ||
| 27 | #define SHORT_MAX ((s16)(USHORT_MAX>>1)) | ||
| 28 | #define SHORT_MIN (-SHORT_MAX - 1) | ||
| 29 | #define INT_MAX ((int)(~0U>>1)) | 28 | #define INT_MAX ((int)(~0U>>1)) |
| 30 | #define INT_MIN (-INT_MAX - 1) | 29 | #define INT_MIN (-INT_MAX - 1) |
| 31 | #define UINT_MAX (~0U) | 30 | #define UINT_MAX (~0U) |
| @@ -38,16 +37,39 @@ extern const char linux_proc_banner[]; | |||
| 38 | 37 | ||
| 39 | #define STACK_MAGIC 0xdeadbeef | 38 | #define STACK_MAGIC 0xdeadbeef |
| 40 | 39 | ||
| 41 | #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) | 40 | #define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) |
| 42 | #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) | 41 | #define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask)) |
| 43 | #define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a))) | 42 | #define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a))) |
| 44 | #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) | 43 | #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) |
| 45 | 44 | ||
| 46 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) | 45 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) |
| 47 | 46 | ||
| 47 | /* | ||
| 48 | * This looks more complex than it should be. But we need to | ||
| 49 | * get the type for the ~ right in round_down (it needs to be | ||
| 50 | * as wide as the result!), and we want to evaluate the macro | ||
| 51 | * arguments just once each. | ||
| 52 | */ | ||
| 53 | #define __round_mask(x, y) ((__typeof__(x))((y)-1)) | ||
| 54 | #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) | ||
| 55 | #define round_down(x, y) ((x) & ~__round_mask(x, y)) | ||
| 56 | |||
| 48 | #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) | 57 | #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) |
| 49 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) | 58 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) |
| 50 | #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 | ) | ||
| 51 | #define DIV_ROUND_CLOSEST(x, divisor)( \ | 73 | #define DIV_ROUND_CLOSEST(x, divisor)( \ |
| 52 | { \ | 74 | { \ |
| 53 | typeof(divisor) __divisor = divisor; \ | 75 | typeof(divisor) __divisor = divisor; \ |
| @@ -88,31 +110,6 @@ extern const char linux_proc_banner[]; | |||
| 88 | */ | 110 | */ |
| 89 | #define lower_32_bits(n) ((u32)(n)) | 111 | #define lower_32_bits(n) ((u32)(n)) |
| 90 | 112 | ||
| 91 | #define KERN_EMERG "<0>" /* system is unusable */ | ||
| 92 | #define KERN_ALERT "<1>" /* action must be taken immediately */ | ||
| 93 | #define KERN_CRIT "<2>" /* critical conditions */ | ||
| 94 | #define KERN_ERR "<3>" /* error conditions */ | ||
| 95 | #define KERN_WARNING "<4>" /* warning conditions */ | ||
| 96 | #define KERN_NOTICE "<5>" /* normal but significant condition */ | ||
| 97 | #define KERN_INFO "<6>" /* informational */ | ||
| 98 | #define KERN_DEBUG "<7>" /* debug-level messages */ | ||
| 99 | |||
| 100 | /* Use the default kernel loglevel */ | ||
| 101 | #define KERN_DEFAULT "<d>" | ||
| 102 | /* | ||
| 103 | * Annotation for a "continued" line of log printout (only done after a | ||
| 104 | * line that had no enclosing \n). Only to be used by core/arch code | ||
| 105 | * during early bootup (a continued line is not SMP-safe otherwise). | ||
| 106 | */ | ||
| 107 | #define KERN_CONT "<c>" | ||
| 108 | |||
| 109 | extern int console_printk[]; | ||
| 110 | |||
| 111 | #define console_loglevel (console_printk[0]) | ||
| 112 | #define default_message_loglevel (console_printk[1]) | ||
| 113 | #define minimum_console_loglevel (console_printk[2]) | ||
| 114 | #define default_console_loglevel (console_printk[3]) | ||
| 115 | |||
| 116 | struct completion; | 113 | struct completion; |
| 117 | struct pt_regs; | 114 | struct pt_regs; |
| 118 | struct user; | 115 | struct user; |
| @@ -125,7 +122,7 @@ extern int _cond_resched(void); | |||
| 125 | #endif | 122 | #endif |
| 126 | 123 | ||
| 127 | #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP | 124 | #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP |
| 128 | void __might_sleep(char *file, int line); | 125 | void __might_sleep(const char *file, int line, int preempt_offset); |
| 129 | /** | 126 | /** |
| 130 | * might_sleep - annotation for functions that can sleep | 127 | * might_sleep - annotation for functions that can sleep |
| 131 | * | 128 | * |
| @@ -137,15 +134,22 @@ extern int _cond_resched(void); | |||
| 137 | * supposed to. | 134 | * supposed to. |
| 138 | */ | 135 | */ |
| 139 | # define might_sleep() \ | 136 | # define might_sleep() \ |
| 140 | do { __might_sleep(__FILE__, __LINE__); might_resched(); } while (0) | 137 | do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0) |
| 141 | #else | 138 | #else |
| 139 | static inline void __might_sleep(const char *file, int line, | ||
| 140 | int preempt_offset) { } | ||
| 142 | # define might_sleep() do { might_resched(); } while (0) | 141 | # define might_sleep() do { might_resched(); } while (0) |
| 143 | #endif | 142 | #endif |
| 144 | 143 | ||
| 145 | #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) |
| 146 | 145 | ||
| 147 | #define abs(x) ({ \ | 146 | #define abs(x) ({ \ |
| 148 | int __x = (x); \ | 147 | long __x = (x); \ |
| 148 | (__x < 0) ? -__x : __x; \ | ||
| 149 | }) | ||
| 150 | |||
| 151 | #define abs64(x) ({ \ | ||
| 152 | s64 __x = (x); \ | ||
| 149 | (__x < 0) ? -__x : __x; \ | 153 | (__x < 0) ? -__x : __x; \ |
| 150 | }) | 154 | }) |
| 151 | 155 | ||
| @@ -159,11 +163,12 @@ static inline void might_fault(void) | |||
| 159 | #endif | 163 | #endif |
| 160 | 164 | ||
| 161 | extern struct atomic_notifier_head panic_notifier_list; | 165 | extern struct atomic_notifier_head panic_notifier_list; |
| 162 | extern long (*panic_blink)(long time); | 166 | extern long (*panic_blink)(int state); |
| 163 | NORET_TYPE void panic(const char * fmt, ...) | 167 | NORET_TYPE void panic(const char * fmt, ...) |
| 164 | __attribute__ ((NORET_AND format (printf, 1, 2))) __cold; | 168 | __attribute__ ((NORET_AND format (printf, 1, 2))) __cold; |
| 165 | extern void oops_enter(void); | 169 | extern void oops_enter(void); |
| 166 | extern void oops_exit(void); | 170 | extern void oops_exit(void); |
| 171 | void print_oops_end_marker(void); | ||
| 167 | extern int oops_may_print(void); | 172 | extern int oops_may_print(void); |
| 168 | NORET_TYPE void do_exit(long error_code) | 173 | NORET_TYPE void do_exit(long error_code) |
| 169 | ATTRIB_NORET; | 174 | ATTRIB_NORET; |
| @@ -173,10 +178,10 @@ extern unsigned long simple_strtoul(const char *,char **,unsigned int); | |||
| 173 | extern long simple_strtol(const char *,char **,unsigned int); | 178 | extern long simple_strtol(const char *,char **,unsigned int); |
| 174 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); | 179 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); |
| 175 | extern long long simple_strtoll(const char *,char **,unsigned int); | 180 | extern long long simple_strtoll(const char *,char **,unsigned int); |
| 176 | extern int strict_strtoul(const char *, unsigned int, unsigned long *); | 181 | extern int __must_check strict_strtoul(const char *, unsigned int, unsigned long *); |
| 177 | extern int strict_strtol(const char *, unsigned int, long *); | 182 | extern int __must_check strict_strtol(const char *, unsigned int, long *); |
| 178 | extern int strict_strtoull(const char *, unsigned int, unsigned long long *); | 183 | extern int __must_check strict_strtoull(const char *, unsigned int, unsigned long long *); |
| 179 | extern int strict_strtoll(const char *, unsigned int, long long *); | 184 | extern int __must_check strict_strtoll(const char *, unsigned int, long long *); |
| 180 | extern int sprintf(char * buf, const char * fmt, ...) | 185 | extern int sprintf(char * buf, const char * fmt, ...) |
| 181 | __attribute__ ((format (printf, 2, 3))); | 186 | __attribute__ ((format (printf, 2, 3))); |
| 182 | extern int vsprintf(char *buf, const char *, va_list) | 187 | extern int vsprintf(char *buf, const char *, va_list) |
| @@ -210,99 +215,15 @@ extern int func_ptr_is_kernel_text(void *ptr); | |||
| 210 | struct pid; | 215 | struct pid; |
| 211 | extern struct pid *session_of_pgrp(struct pid *pgrp); | 216 | extern struct pid *session_of_pgrp(struct pid *pgrp); |
| 212 | 217 | ||
| 213 | /* | ||
| 214 | * FW_BUG | ||
| 215 | * Add this to a message where you are sure the firmware is buggy or behaves | ||
| 216 | * really stupid or out of spec. Be aware that the responsible BIOS developer | ||
| 217 | * should be able to fix this issue or at least get a concrete idea of the | ||
| 218 | * problem by reading your message without the need of looking at the kernel | ||
| 219 | * code. | ||
| 220 | * | ||
| 221 | * Use it for definite and high priority BIOS bugs. | ||
| 222 | * | ||
| 223 | * FW_WARN | ||
| 224 | * Use it for not that clear (e.g. could the kernel messed up things already?) | ||
| 225 | * and medium priority BIOS bugs. | ||
| 226 | * | ||
| 227 | * FW_INFO | ||
| 228 | * Use this one if you want to tell the user or vendor about something | ||
| 229 | * suspicious, but generally harmless related to the firmware. | ||
| 230 | * | ||
| 231 | * Use it for information or very low priority BIOS bugs. | ||
| 232 | */ | ||
| 233 | #define FW_BUG "[Firmware Bug]: " | ||
| 234 | #define FW_WARN "[Firmware Warn]: " | ||
| 235 | #define FW_INFO "[Firmware Info]: " | ||
| 236 | |||
| 237 | #ifdef CONFIG_PRINTK | ||
| 238 | asmlinkage int vprintk(const char *fmt, va_list args) | ||
| 239 | __attribute__ ((format (printf, 1, 0))); | ||
| 240 | asmlinkage int printk(const char * fmt, ...) | ||
| 241 | __attribute__ ((format (printf, 1, 2))) __cold; | ||
| 242 | |||
| 243 | extern struct ratelimit_state printk_ratelimit_state; | ||
| 244 | extern int printk_ratelimit(void); | ||
| 245 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, | ||
| 246 | unsigned int interval_msec); | ||
| 247 | |||
| 248 | /* | ||
| 249 | * Print a one-time message (analogous to WARN_ONCE() et al): | ||
| 250 | */ | ||
| 251 | #define printk_once(x...) ({ \ | ||
| 252 | static int __print_once = 1; \ | ||
| 253 | \ | ||
| 254 | if (__print_once) { \ | ||
| 255 | __print_once = 0; \ | ||
| 256 | printk(x); \ | ||
| 257 | } \ | ||
| 258 | }) | ||
| 259 | |||
| 260 | void log_buf_kexec_setup(void); | ||
| 261 | #else | ||
| 262 | static inline int vprintk(const char *s, va_list args) | ||
| 263 | __attribute__ ((format (printf, 1, 0))); | ||
| 264 | static inline int vprintk(const char *s, va_list args) { return 0; } | ||
| 265 | static inline int printk(const char *s, ...) | ||
| 266 | __attribute__ ((format (printf, 1, 2))); | ||
| 267 | static inline int __cold printk(const char *s, ...) { return 0; } | ||
| 268 | static inline int printk_ratelimit(void) { return 0; } | ||
| 269 | static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ | ||
| 270 | unsigned int interval_msec) \ | ||
| 271 | { return false; } | ||
| 272 | |||
| 273 | /* No effect, but we still get type checking even in the !PRINTK case: */ | ||
| 274 | #define printk_once(x...) printk(x) | ||
| 275 | |||
| 276 | static inline void log_buf_kexec_setup(void) | ||
| 277 | { | ||
| 278 | } | ||
| 279 | #endif | ||
| 280 | |||
| 281 | extern int printk_needs_cpu(int cpu); | ||
| 282 | extern void printk_tick(void); | ||
| 283 | |||
| 284 | extern void asmlinkage __attribute__((format(printf, 1, 2))) | ||
| 285 | early_printk(const char *fmt, ...); | ||
| 286 | |||
| 287 | unsigned long int_sqrt(unsigned long); | 218 | unsigned long int_sqrt(unsigned long); |
| 288 | 219 | ||
| 289 | static inline void console_silent(void) | ||
| 290 | { | ||
| 291 | console_loglevel = 0; | ||
| 292 | } | ||
| 293 | |||
| 294 | static inline void console_verbose(void) | ||
| 295 | { | ||
| 296 | if (console_loglevel) | ||
| 297 | console_loglevel = 15; | ||
| 298 | } | ||
| 299 | |||
| 300 | extern void bust_spinlocks(int yes); | 220 | extern void bust_spinlocks(int yes); |
| 301 | extern void wake_up_klogd(void); | 221 | extern void wake_up_klogd(void); |
| 302 | extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ | 222 | extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ |
| 303 | extern int panic_timeout; | 223 | extern int panic_timeout; |
| 304 | extern int panic_on_oops; | 224 | extern int panic_on_oops; |
| 305 | extern int panic_on_unrecovered_nmi; | 225 | extern int panic_on_unrecovered_nmi; |
| 226 | extern int panic_on_io_nmi; | ||
| 306 | extern const char *print_tainted(void); | 227 | extern const char *print_tainted(void); |
| 307 | extern void add_taint(unsigned flag); | 228 | extern void add_taint(unsigned flag); |
| 308 | extern int test_taint(unsigned flag); | 229 | extern int test_taint(unsigned flag); |
| @@ -330,22 +251,7 @@ extern enum system_states { | |||
| 330 | #define TAINT_OVERRIDDEN_ACPI_TABLE 8 | 251 | #define TAINT_OVERRIDDEN_ACPI_TABLE 8 |
| 331 | #define TAINT_WARN 9 | 252 | #define TAINT_WARN 9 |
| 332 | #define TAINT_CRAP 10 | 253 | #define TAINT_CRAP 10 |
| 333 | 254 | #define TAINT_FIRMWARE_WORKAROUND 11 | |
| 334 | extern void dump_stack(void) __cold; | ||
| 335 | |||
| 336 | enum { | ||
| 337 | DUMP_PREFIX_NONE, | ||
| 338 | DUMP_PREFIX_ADDRESS, | ||
| 339 | DUMP_PREFIX_OFFSET | ||
| 340 | }; | ||
| 341 | extern void hex_dump_to_buffer(const void *buf, size_t len, | ||
| 342 | int rowsize, int groupsize, | ||
| 343 | char *linebuf, size_t linebuflen, bool ascii); | ||
| 344 | extern void print_hex_dump(const char *level, const char *prefix_str, | ||
| 345 | int prefix_type, int rowsize, int groupsize, | ||
| 346 | const void *buf, size_t len, bool ascii); | ||
| 347 | extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, | ||
| 348 | const void *buf, size_t len); | ||
| 349 | 255 | ||
| 350 | extern const char hex_asc[]; | 256 | extern const char hex_asc[]; |
| 351 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] | 257 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] |
| @@ -358,49 +264,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
| 358 | return buf; | 264 | return buf; |
| 359 | } | 265 | } |
| 360 | 266 | ||
| 361 | #ifndef pr_fmt | 267 | extern int hex_to_bin(char ch); |
| 362 | #define pr_fmt(fmt) fmt | 268 | extern void hex2bin(u8 *dst, const char *src, size_t count); |
| 363 | #endif | ||
| 364 | |||
| 365 | #define pr_emerg(fmt, ...) \ | ||
| 366 | printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) | ||
| 367 | #define pr_alert(fmt, ...) \ | ||
| 368 | printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) | ||
| 369 | #define pr_crit(fmt, ...) \ | ||
| 370 | printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) | ||
| 371 | #define pr_err(fmt, ...) \ | ||
| 372 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | ||
| 373 | #define pr_warning(fmt, ...) \ | ||
| 374 | printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | ||
| 375 | #define pr_notice(fmt, ...) \ | ||
| 376 | printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | ||
| 377 | #define pr_info(fmt, ...) \ | ||
| 378 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ||
| 379 | #define pr_cont(fmt, ...) \ | ||
| 380 | printk(KERN_CONT fmt, ##__VA_ARGS__) | ||
| 381 | |||
| 382 | /* pr_devel() should produce zero code unless DEBUG is defined */ | ||
| 383 | #ifdef DEBUG | ||
| 384 | #define pr_devel(fmt, ...) \ | ||
| 385 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
| 386 | #else | ||
| 387 | #define pr_devel(fmt, ...) \ | ||
| 388 | ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) | ||
| 389 | #endif | ||
| 390 | |||
| 391 | /* If you are writing a driver, please use dev_dbg instead */ | ||
| 392 | #if defined(DEBUG) | ||
| 393 | #define pr_debug(fmt, ...) \ | ||
| 394 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
| 395 | #elif defined(CONFIG_DYNAMIC_DEBUG) | ||
| 396 | /* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ | ||
| 397 | #define pr_debug(fmt, ...) do { \ | ||
| 398 | dynamic_pr_debug(fmt, ##__VA_ARGS__); \ | ||
| 399 | } while (0) | ||
| 400 | #else | ||
| 401 | #define pr_debug(fmt, ...) \ | ||
| 402 | ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) | ||
| 403 | #endif | ||
| 404 | 269 | ||
| 405 | /* | 270 | /* |
| 406 | * General tracing related utility functions - trace_printk(), | 271 | * General tracing related utility functions - trace_printk(), |
| @@ -433,14 +298,18 @@ static inline void tracing_off(void) { } | |||
| 433 | static inline void tracing_off_permanent(void) { } | 298 | static inline void tracing_off_permanent(void) { } |
| 434 | static inline int tracing_is_on(void) { return 0; } | 299 | static inline int tracing_is_on(void) { return 0; } |
| 435 | #endif | 300 | #endif |
| 301 | |||
| 302 | enum ftrace_dump_mode { | ||
| 303 | DUMP_NONE, | ||
| 304 | DUMP_ALL, | ||
| 305 | DUMP_ORIG, | ||
| 306 | }; | ||
| 307 | |||
| 436 | #ifdef CONFIG_TRACING | 308 | #ifdef CONFIG_TRACING |
| 437 | extern void tracing_start(void); | 309 | extern void tracing_start(void); |
| 438 | extern void tracing_stop(void); | 310 | extern void tracing_stop(void); |
| 439 | extern void ftrace_off_permanent(void); | 311 | extern void ftrace_off_permanent(void); |
| 440 | 312 | ||
| 441 | extern void | ||
| 442 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); | ||
| 443 | |||
| 444 | static inline void __attribute__ ((format (printf, 1, 2))) | 313 | static inline void __attribute__ ((format (printf, 1, 2))) |
| 445 | ____trace_printk_check_format(const char *fmt, ...) | 314 | ____trace_printk_check_format(const char *fmt, ...) |
| 446 | { | 315 | { |
| @@ -489,6 +358,8 @@ extern int | |||
| 489 | __trace_printk(unsigned long ip, const char *fmt, ...) | 358 | __trace_printk(unsigned long ip, const char *fmt, ...) |
| 490 | __attribute__ ((format (printf, 2, 3))); | 359 | __attribute__ ((format (printf, 2, 3))); |
| 491 | 360 | ||
| 361 | extern void trace_dump_stack(void); | ||
| 362 | |||
| 492 | /* | 363 | /* |
| 493 | * The double __builtin_constant_p is because gcc will give us an error | 364 | * The double __builtin_constant_p is because gcc will give us an error |
| 494 | * if we try to allocate the static variable to fmt if it is not a | 365 | * if we try to allocate the static variable to fmt if it is not a |
| @@ -512,16 +383,15 @@ __ftrace_vbprintk(unsigned long ip, const char *fmt, va_list ap); | |||
| 512 | extern int | 383 | extern int |
| 513 | __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); | 384 | __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); |
| 514 | 385 | ||
| 515 | extern void ftrace_dump(void); | 386 | extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode); |
| 516 | #else | 387 | #else |
| 517 | static inline void | ||
| 518 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { } | ||
| 519 | static inline int | 388 | static inline int |
| 520 | trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); | 389 | trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); |
| 521 | 390 | ||
| 522 | static inline void tracing_start(void) { } | 391 | static inline void tracing_start(void) { } |
| 523 | static inline void tracing_stop(void) { } | 392 | static inline void tracing_stop(void) { } |
| 524 | static inline void ftrace_off_permanent(void) { } | 393 | static inline void ftrace_off_permanent(void) { } |
| 394 | static inline void trace_dump_stack(void) { } | ||
| 525 | static inline int | 395 | static inline int |
| 526 | trace_printk(const char *fmt, ...) | 396 | trace_printk(const char *fmt, ...) |
| 527 | { | 397 | { |
| @@ -532,21 +402,10 @@ ftrace_vprintk(const char *fmt, va_list ap) | |||
| 532 | { | 402 | { |
| 533 | return 0; | 403 | return 0; |
| 534 | } | 404 | } |
| 535 | static inline void ftrace_dump(void) { } | 405 | static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } |
| 536 | #endif /* CONFIG_TRACING */ | 406 | #endif /* CONFIG_TRACING */ |
| 537 | 407 | ||
| 538 | /* | 408 | /* |
| 539 | * Display an IP address in readable format. | ||
| 540 | */ | ||
| 541 | |||
| 542 | #define NIPQUAD(addr) \ | ||
| 543 | ((unsigned char *)&addr)[0], \ | ||
| 544 | ((unsigned char *)&addr)[1], \ | ||
| 545 | ((unsigned char *)&addr)[2], \ | ||
| 546 | ((unsigned char *)&addr)[3] | ||
| 547 | #define NIPQUAD_FMT "%u.%u.%u.%u" | ||
| 548 | |||
| 549 | /* | ||
| 550 | * min()/max()/clamp() macros that also do | 409 | * min()/max()/clamp() macros that also do |
| 551 | * strict type-checking.. See the | 410 | * strict type-checking.. See the |
| 552 | * "unnecessary" pointer comparison. | 411 | * "unnecessary" pointer comparison. |
| @@ -563,6 +422,34 @@ static inline void ftrace_dump(void) { } | |||
| 563 | (void) (&_max1 == &_max2); \ | 422 | (void) (&_max1 == &_max2); \ |
| 564 | _max1 > _max2 ? _max1 : _max2; }) | 423 | _max1 > _max2 ? _max1 : _max2; }) |
| 565 | 424 | ||
| 425 | #define min3(x, y, z) ({ \ | ||
| 426 | typeof(x) _min1 = (x); \ | ||
| 427 | typeof(y) _min2 = (y); \ | ||
| 428 | typeof(z) _min3 = (z); \ | ||
| 429 | (void) (&_min1 == &_min2); \ | ||
| 430 | (void) (&_min1 == &_min3); \ | ||
| 431 | _min1 < _min2 ? (_min1 < _min3 ? _min1 : _min3) : \ | ||
| 432 | (_min2 < _min3 ? _min2 : _min3); }) | ||
| 433 | |||
| 434 | #define max3(x, y, z) ({ \ | ||
| 435 | typeof(x) _max1 = (x); \ | ||
| 436 | typeof(y) _max2 = (y); \ | ||
| 437 | typeof(z) _max3 = (z); \ | ||
| 438 | (void) (&_max1 == &_max2); \ | ||
| 439 | (void) (&_max1 == &_max3); \ | ||
| 440 | _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \ | ||
| 441 | (_max2 > _max3 ? _max2 : _max3); }) | ||
| 442 | |||
| 443 | /** | ||
| 444 | * min_not_zero - return the minimum that is _not_ zero, unless both are zero | ||
| 445 | * @x: value1 | ||
| 446 | * @y: value2 | ||
| 447 | */ | ||
| 448 | #define min_not_zero(x, y) ({ \ | ||
| 449 | typeof(x) __x = (x); \ | ||
| 450 | typeof(y) __y = (y); \ | ||
| 451 | __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); }) | ||
| 452 | |||
| 566 | /** | 453 | /** |
| 567 | * clamp - return a value clamped to a given range with strict typechecking | 454 | * clamp - return a value clamped to a given range with strict typechecking |
| 568 | * @val: current value | 455 | * @val: current value |
| @@ -674,13 +561,21 @@ struct sysinfo { | |||
| 674 | }; | 561 | }; |
| 675 | 562 | ||
| 676 | /* Force a compilation error if condition is true */ | 563 | /* Force a compilation error if condition is true */ |
| 677 | #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) | 564 | #define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition)) |
| 565 | |||
| 566 | /* Force a compilation error if condition is constant and true */ | ||
| 567 | #define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)])) | ||
| 568 | |||
| 569 | /* Force a compilation error if a constant expression is not a power of 2 */ | ||
| 570 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ | ||
| 571 | BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) | ||
| 678 | 572 | ||
| 679 | /* Force a compilation error if condition is true, but also produce a | 573 | /* Force a compilation error if condition is true, but also produce a |
| 680 | result (of value 0 and type size_t), so the expression can be used | 574 | result (of value 0 and type size_t), so the expression can be used |
| 681 | e.g. in a structure initializer (or where-ever else comma expressions | 575 | e.g. in a structure initializer (or where-ever else comma expressions |
| 682 | aren't permitted). */ | 576 | aren't permitted). */ |
| 683 | #define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1) | 577 | #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) |
| 578 | #define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) | ||
| 684 | 579 | ||
| 685 | /* Trap pasters of __FUNCTION__ at compile-time */ | 580 | /* Trap pasters of __FUNCTION__ at compile-time */ |
| 686 | #define __FUNCTION__ (__func__) | 581 | #define __FUNCTION__ (__func__) |
