diff options
Diffstat (limited to 'include/linux/kernel.h')
| -rw-r--r-- | include/linux/kernel.h | 365 |
1 files changed, 109 insertions, 256 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index cc5e3ffe9fce..e2f4d6af2125 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
| @@ -17,16 +17,14 @@ | |||
| 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 | #define USHRT_MAX ((u16)(~0U)) |
| 25 | extern const char linux_proc_banner[]; | 26 | #define SHRT_MAX ((s16)(USHRT_MAX>>1)) |
| 26 | 27 | #define SHRT_MIN ((s16)(-SHRT_MAX - 1)) | |
| 27 | #define USHORT_MAX ((u16)(~0U)) | ||
| 28 | #define SHORT_MAX ((s16)(USHORT_MAX>>1)) | ||
| 29 | #define SHORT_MIN (-SHORT_MAX - 1) | ||
| 30 | #define INT_MAX ((int)(~0U>>1)) | 28 | #define INT_MAX ((int)(~0U>>1)) |
| 31 | #define INT_MIN (-INT_MAX - 1) | 29 | #define INT_MIN (-INT_MAX - 1) |
| 32 | #define UINT_MAX (~0U) | 30 | #define UINT_MAX (~0U) |
| @@ -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 | ||
| @@ -172,11 +176,12 @@ static inline void might_fault(void) | |||
| 172 | #endif | 176 | #endif |
| 173 | 177 | ||
| 174 | extern struct atomic_notifier_head panic_notifier_list; | 178 | extern struct atomic_notifier_head panic_notifier_list; |
| 175 | extern long (*panic_blink)(long time); | 179 | extern long (*panic_blink)(int state); |
| 176 | NORET_TYPE void panic(const char * fmt, ...) | 180 | NORET_TYPE void panic(const char * fmt, ...) |
| 177 | __attribute__ ((NORET_AND format (printf, 1, 2))) __cold; | 181 | __attribute__ ((NORET_AND format (printf, 1, 2))) __cold; |
| 178 | extern void oops_enter(void); | 182 | extern void oops_enter(void); |
| 179 | extern void oops_exit(void); | 183 | extern void oops_exit(void); |
| 184 | void print_oops_end_marker(void); | ||
| 180 | extern int oops_may_print(void); | 185 | extern int oops_may_print(void); |
| 181 | NORET_TYPE void do_exit(long error_code) | 186 | NORET_TYPE void do_exit(long error_code) |
| 182 | ATTRIB_NORET; | 187 | ATTRIB_NORET; |
| @@ -186,10 +191,10 @@ extern unsigned long simple_strtoul(const char *,char **,unsigned int); | |||
| 186 | extern long simple_strtol(const char *,char **,unsigned int); | 191 | extern long simple_strtol(const char *,char **,unsigned int); |
| 187 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); | 192 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); |
| 188 | extern long long simple_strtoll(const char *,char **,unsigned int); | 193 | extern long long simple_strtoll(const char *,char **,unsigned int); |
| 189 | extern int strict_strtoul(const char *, unsigned int, unsigned long *); | 194 | extern int __must_check strict_strtoul(const char *, unsigned int, unsigned long *); |
| 190 | extern int strict_strtol(const char *, unsigned int, long *); | 195 | extern int __must_check strict_strtol(const char *, unsigned int, long *); |
| 191 | extern int strict_strtoull(const char *, unsigned int, unsigned long long *); | 196 | extern int __must_check strict_strtoull(const char *, unsigned int, unsigned long long *); |
| 192 | extern int strict_strtoll(const char *, unsigned int, long long *); | 197 | extern int __must_check strict_strtoll(const char *, unsigned int, long long *); |
| 193 | extern int sprintf(char * buf, const char * fmt, ...) | 198 | extern int sprintf(char * buf, const char * fmt, ...) |
| 194 | __attribute__ ((format (printf, 2, 3))); | 199 | __attribute__ ((format (printf, 2, 3))); |
| 195 | extern int vsprintf(char *buf, const char *, va_list) | 200 | extern int vsprintf(char *buf, const char *, va_list) |
| @@ -223,95 +228,8 @@ extern int func_ptr_is_kernel_text(void *ptr); | |||
| 223 | struct pid; | 228 | struct pid; |
| 224 | extern struct pid *session_of_pgrp(struct pid *pgrp); | 229 | extern struct pid *session_of_pgrp(struct pid *pgrp); |
| 225 | 230 | ||
| 226 | /* | ||
| 227 | * FW_BUG | ||
| 228 | * Add this to a message where you are sure the firmware is buggy or behaves | ||
| 229 | * really stupid or out of spec. Be aware that the responsible BIOS developer | ||
| 230 | * should be able to fix this issue or at least get a concrete idea of the | ||
| 231 | * problem by reading your message without the need of looking at the kernel | ||
| 232 | * code. | ||
| 233 | * | ||
| 234 | * Use it for definite and high priority BIOS bugs. | ||
| 235 | * | ||
| 236 | * FW_WARN | ||
| 237 | * Use it for not that clear (e.g. could the kernel messed up things already?) | ||
| 238 | * and medium priority BIOS bugs. | ||
| 239 | * | ||
| 240 | * FW_INFO | ||
| 241 | * Use this one if you want to tell the user or vendor about something | ||
| 242 | * suspicious, but generally harmless related to the firmware. | ||
| 243 | * | ||
| 244 | * Use it for information or very low priority BIOS bugs. | ||
| 245 | */ | ||
| 246 | #define FW_BUG "[Firmware Bug]: " | ||
| 247 | #define FW_WARN "[Firmware Warn]: " | ||
| 248 | #define FW_INFO "[Firmware Info]: " | ||
| 249 | |||
| 250 | #ifdef CONFIG_PRINTK | ||
| 251 | asmlinkage int vprintk(const char *fmt, va_list args) | ||
| 252 | __attribute__ ((format (printf, 1, 0))); | ||
| 253 | asmlinkage int printk(const char * fmt, ...) | ||
| 254 | __attribute__ ((format (printf, 1, 2))) __cold; | ||
| 255 | |||
| 256 | extern int __printk_ratelimit(const char *func); | ||
| 257 | #define printk_ratelimit() __printk_ratelimit(__func__) | ||
| 258 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, | ||
| 259 | unsigned int interval_msec); | ||
| 260 | |||
| 261 | extern int printk_delay_msec; | ||
| 262 | |||
| 263 | /* | ||
| 264 | * Print a one-time message (analogous to WARN_ONCE() et al): | ||
| 265 | */ | ||
| 266 | #define printk_once(x...) ({ \ | ||
| 267 | static bool __print_once; \ | ||
| 268 | \ | ||
| 269 | if (!__print_once) { \ | ||
| 270 | __print_once = true; \ | ||
| 271 | printk(x); \ | ||
| 272 | } \ | ||
| 273 | }) | ||
| 274 | |||
| 275 | void log_buf_kexec_setup(void); | ||
| 276 | #else | ||
| 277 | static inline int vprintk(const char *s, va_list args) | ||
| 278 | __attribute__ ((format (printf, 1, 0))); | ||
| 279 | static inline int vprintk(const char *s, va_list args) { return 0; } | ||
| 280 | static inline int printk(const char *s, ...) | ||
| 281 | __attribute__ ((format (printf, 1, 2))); | ||
| 282 | static inline int __cold printk(const char *s, ...) { return 0; } | ||
| 283 | static inline int printk_ratelimit(void) { return 0; } | ||
| 284 | static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ | ||
| 285 | unsigned int interval_msec) \ | ||
| 286 | { return false; } | ||
| 287 | |||
| 288 | /* No effect, but we still get type checking even in the !PRINTK case: */ | ||
| 289 | #define printk_once(x...) printk(x) | ||
| 290 | |||
| 291 | static inline void log_buf_kexec_setup(void) | ||
| 292 | { | ||
| 293 | } | ||
| 294 | #endif | ||
| 295 | |||
| 296 | extern int printk_needs_cpu(int cpu); | ||
| 297 | extern void printk_tick(void); | ||
| 298 | |||
| 299 | extern void asmlinkage __attribute__((format(printf, 1, 2))) | ||
| 300 | early_printk(const char *fmt, ...); | ||
| 301 | |||
| 302 | unsigned long int_sqrt(unsigned long); | 231 | unsigned long int_sqrt(unsigned long); |
| 303 | 232 | ||
| 304 | static inline void console_silent(void) | ||
| 305 | { | ||
| 306 | console_loglevel = 0; | ||
| 307 | } | ||
| 308 | |||
| 309 | static inline void console_verbose(void) | ||
| 310 | { | ||
| 311 | if (console_loglevel) | ||
| 312 | console_loglevel = 15; | ||
| 313 | } | ||
| 314 | |||
| 315 | extern void bust_spinlocks(int yes); | 233 | extern void bust_spinlocks(int yes); |
| 316 | extern void wake_up_klogd(void); | 234 | extern void wake_up_klogd(void); |
| 317 | extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ | 235 | extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ |
| @@ -325,6 +243,8 @@ extern int test_taint(unsigned flag); | |||
| 325 | extern unsigned long get_taint(void); | 243 | extern unsigned long get_taint(void); |
| 326 | extern int root_mountflags; | 244 | extern int root_mountflags; |
| 327 | 245 | ||
| 246 | extern bool early_boot_irqs_disabled; | ||
| 247 | |||
| 328 | /* Values used for system_state */ | 248 | /* Values used for system_state */ |
| 329 | extern enum system_states { | 249 | extern enum system_states { |
| 330 | SYSTEM_BOOTING, | 250 | SYSTEM_BOOTING, |
| @@ -348,22 +268,6 @@ extern enum system_states { | |||
| 348 | #define TAINT_CRAP 10 | 268 | #define TAINT_CRAP 10 |
| 349 | #define TAINT_FIRMWARE_WORKAROUND 11 | 269 | #define TAINT_FIRMWARE_WORKAROUND 11 |
| 350 | 270 | ||
| 351 | extern void dump_stack(void) __cold; | ||
| 352 | |||
| 353 | enum { | ||
| 354 | DUMP_PREFIX_NONE, | ||
| 355 | DUMP_PREFIX_ADDRESS, | ||
| 356 | DUMP_PREFIX_OFFSET | ||
| 357 | }; | ||
| 358 | extern void hex_dump_to_buffer(const void *buf, size_t len, | ||
| 359 | int rowsize, int groupsize, | ||
| 360 | char *linebuf, size_t linebuflen, bool ascii); | ||
| 361 | extern void print_hex_dump(const char *level, const char *prefix_str, | ||
| 362 | int prefix_type, int rowsize, int groupsize, | ||
| 363 | const void *buf, size_t len, bool ascii); | ||
| 364 | extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, | ||
| 365 | const void *buf, size_t len); | ||
| 366 | |||
| 367 | extern const char hex_asc[]; | 271 | extern const char hex_asc[]; |
| 368 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] | 272 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] |
| 369 | #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] | 273 | #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] |
| @@ -375,92 +279,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
| 375 | return buf; | 279 | return buf; |
| 376 | } | 280 | } |
| 377 | 281 | ||
| 378 | #ifndef pr_fmt | 282 | extern int hex_to_bin(char ch); |
| 379 | #define pr_fmt(fmt) fmt | 283 | extern void hex2bin(u8 *dst, const char *src, size_t count); |
| 380 | #endif | ||
| 381 | |||
| 382 | #define pr_emerg(fmt, ...) \ | ||
| 383 | printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) | ||
| 384 | #define pr_alert(fmt, ...) \ | ||
| 385 | printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) | ||
| 386 | #define pr_crit(fmt, ...) \ | ||
| 387 | printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) | ||
| 388 | #define pr_err(fmt, ...) \ | ||
| 389 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | ||
| 390 | #define pr_warning(fmt, ...) \ | ||
| 391 | printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | ||
| 392 | #define pr_notice(fmt, ...) \ | ||
| 393 | printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | ||
| 394 | #define pr_info(fmt, ...) \ | ||
| 395 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ||
| 396 | #define pr_cont(fmt, ...) \ | ||
| 397 | printk(KERN_CONT fmt, ##__VA_ARGS__) | ||
| 398 | |||
| 399 | /* pr_devel() should produce zero code unless DEBUG is defined */ | ||
| 400 | #ifdef DEBUG | ||
| 401 | #define pr_devel(fmt, ...) \ | ||
| 402 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
| 403 | #else | ||
| 404 | #define pr_devel(fmt, ...) \ | ||
| 405 | ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) | ||
| 406 | #endif | ||
| 407 | |||
| 408 | /* If you are writing a driver, please use dev_dbg instead */ | ||
| 409 | #if defined(DEBUG) | ||
| 410 | #define pr_debug(fmt, ...) \ | ||
| 411 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
| 412 | #elif defined(CONFIG_DYNAMIC_DEBUG) | ||
| 413 | /* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ | ||
| 414 | #define pr_debug(fmt, ...) \ | ||
| 415 | dynamic_pr_debug(fmt, ##__VA_ARGS__) | ||
| 416 | #else | ||
| 417 | #define pr_debug(fmt, ...) \ | ||
| 418 | ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) | ||
| 419 | #endif | ||
| 420 | |||
| 421 | /* | ||
| 422 | * ratelimited messages with local ratelimit_state, | ||
| 423 | * no local ratelimit_state used in the !PRINTK case | ||
| 424 | */ | ||
| 425 | #ifdef CONFIG_PRINTK | ||
| 426 | #define printk_ratelimited(fmt, ...) ({ \ | ||
| 427 | static struct ratelimit_state _rs = { \ | ||
| 428 | .interval = DEFAULT_RATELIMIT_INTERVAL, \ | ||
| 429 | .burst = DEFAULT_RATELIMIT_BURST, \ | ||
| 430 | }; \ | ||
| 431 | \ | ||
| 432 | if (__ratelimit(&_rs)) \ | ||
| 433 | printk(fmt, ##__VA_ARGS__); \ | ||
| 434 | }) | ||
| 435 | #else | ||
| 436 | /* No effect, but we still get type checking even in the !PRINTK case: */ | ||
| 437 | #define printk_ratelimited printk | ||
| 438 | #endif | ||
| 439 | |||
| 440 | #define pr_emerg_ratelimited(fmt, ...) \ | ||
| 441 | printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) | ||
| 442 | #define pr_alert_ratelimited(fmt, ...) \ | ||
| 443 | printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) | ||
| 444 | #define pr_crit_ratelimited(fmt, ...) \ | ||
| 445 | printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) | ||
| 446 | #define pr_err_ratelimited(fmt, ...) \ | ||
| 447 | printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) | ||
| 448 | #define pr_warning_ratelimited(fmt, ...) \ | ||
| 449 | printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) | ||
| 450 | #define pr_notice_ratelimited(fmt, ...) \ | ||
| 451 | printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) | ||
| 452 | #define pr_info_ratelimited(fmt, ...) \ | ||
| 453 | printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ||
| 454 | /* no pr_cont_ratelimited, don't do that... */ | ||
| 455 | /* If you are writing a driver, please use dev_dbg instead */ | ||
| 456 | #if defined(DEBUG) | ||
| 457 | #define pr_debug_ratelimited(fmt, ...) \ | ||
| 458 | printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
| 459 | #else | ||
| 460 | #define pr_debug_ratelimited(fmt, ...) \ | ||
| 461 | ({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \ | ||
| 462 | ##__VA_ARGS__); 0; }) | ||
| 463 | #endif | ||
| 464 | 284 | ||
| 465 | /* | 285 | /* |
| 466 | * General tracing related utility functions - trace_printk(), | 286 | * General tracing related utility functions - trace_printk(), |
| @@ -505,9 +325,6 @@ extern void tracing_start(void); | |||
| 505 | extern void tracing_stop(void); | 325 | extern void tracing_stop(void); |
| 506 | extern void ftrace_off_permanent(void); | 326 | extern void ftrace_off_permanent(void); |
| 507 | 327 | ||
| 508 | extern void | ||
| 509 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); | ||
| 510 | |||
| 511 | static inline void __attribute__ ((format (printf, 1, 2))) | 328 | static inline void __attribute__ ((format (printf, 1, 2))) |
| 512 | ____trace_printk_check_format(const char *fmt, ...) | 329 | ____trace_printk_check_format(const char *fmt, ...) |
| 513 | { | 330 | { |
| @@ -583,8 +400,6 @@ __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); | |||
| 583 | 400 | ||
| 584 | extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode); | 401 | extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode); |
| 585 | #else | 402 | #else |
| 586 | static inline void | ||
| 587 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { } | ||
| 588 | static inline int | 403 | static inline int |
| 589 | trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); | 404 | trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); |
| 590 | 405 | ||
| @@ -606,17 +421,6 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
| 606 | #endif /* CONFIG_TRACING */ | 421 | #endif /* CONFIG_TRACING */ |
| 607 | 422 | ||
| 608 | /* | 423 | /* |
| 609 | * Display an IP address in readable format. | ||
| 610 | */ | ||
| 611 | |||
| 612 | #define NIPQUAD(addr) \ | ||
| 613 | ((unsigned char *)&addr)[0], \ | ||
| 614 | ((unsigned char *)&addr)[1], \ | ||
| 615 | ((unsigned char *)&addr)[2], \ | ||
| 616 | ((unsigned char *)&addr)[3] | ||
| 617 | #define NIPQUAD_FMT "%u.%u.%u.%u" | ||
| 618 | |||
| 619 | /* | ||
| 620 | * min()/max()/clamp() macros that also do | 424 | * min()/max()/clamp() macros that also do |
| 621 | * strict type-checking.. See the | 425 | * strict type-checking.. See the |
| 622 | * "unnecessary" pointer comparison. | 426 | * "unnecessary" pointer comparison. |
| @@ -633,6 +437,34 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
| 633 | (void) (&_max1 == &_max2); \ | 437 | (void) (&_max1 == &_max2); \ |
| 634 | _max1 > _max2 ? _max1 : _max2; }) | 438 | _max1 > _max2 ? _max1 : _max2; }) |
| 635 | 439 | ||
| 440 | #define min3(x, y, z) ({ \ | ||
| 441 | typeof(x) _min1 = (x); \ | ||
| 442 | typeof(y) _min2 = (y); \ | ||
| 443 | typeof(z) _min3 = (z); \ | ||
| 444 | (void) (&_min1 == &_min2); \ | ||
| 445 | (void) (&_min1 == &_min3); \ | ||
| 446 | _min1 < _min2 ? (_min1 < _min3 ? _min1 : _min3) : \ | ||
| 447 | (_min2 < _min3 ? _min2 : _min3); }) | ||
| 448 | |||
| 449 | #define max3(x, y, z) ({ \ | ||
| 450 | typeof(x) _max1 = (x); \ | ||
| 451 | typeof(y) _max2 = (y); \ | ||
| 452 | typeof(z) _max3 = (z); \ | ||
| 453 | (void) (&_max1 == &_max2); \ | ||
| 454 | (void) (&_max1 == &_max3); \ | ||
| 455 | _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \ | ||
| 456 | (_max2 > _max3 ? _max2 : _max3); }) | ||
| 457 | |||
| 458 | /** | ||
| 459 | * min_not_zero - return the minimum that is _not_ zero, unless both are zero | ||
| 460 | * @x: value1 | ||
| 461 | * @y: value2 | ||
| 462 | */ | ||
| 463 | #define min_not_zero(x, y) ({ \ | ||
| 464 | typeof(x) __x = (x); \ | ||
| 465 | typeof(y) __y = (y); \ | ||
| 466 | __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); }) | ||
| 467 | |||
| 636 | /** | 468 | /** |
| 637 | * clamp - return a value clamped to a given range with strict typechecking | 469 | * clamp - return a value clamped to a given range with strict typechecking |
| 638 | * @val: current value | 470 | * @val: current value |
| @@ -725,12 +557,6 @@ extern int do_sysinfo(struct sysinfo *info); | |||
| 725 | 557 | ||
| 726 | #endif /* __KERNEL__ */ | 558 | #endif /* __KERNEL__ */ |
| 727 | 559 | ||
| 728 | #ifndef __EXPORTED_HEADERS__ | ||
| 729 | #ifndef __KERNEL__ | ||
| 730 | #warning Attempt to use kernel headers from user space, see http://kernelnewbies.org/KernelHeaders | ||
| 731 | #endif /* __KERNEL__ */ | ||
| 732 | #endif /* __EXPORTED_HEADERS__ */ | ||
| 733 | |||
| 734 | #define SI_LOAD_SHIFT 16 | 560 | #define SI_LOAD_SHIFT 16 |
| 735 | struct sysinfo { | 561 | struct sysinfo { |
| 736 | long uptime; /* Seconds since boot */ | 562 | long uptime; /* Seconds since boot */ |
| @@ -749,12 +575,6 @@ struct sysinfo { | |||
| 749 | char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ | 575 | char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ |
| 750 | }; | 576 | }; |
| 751 | 577 | ||
| 752 | /* Force a compilation error if condition is true */ | ||
| 753 | #define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition)) | ||
| 754 | |||
| 755 | /* Force a compilation error if condition is constant and true */ | ||
| 756 | #define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)])) | ||
| 757 | |||
| 758 | /* Force a compilation error if a constant expression is not a power of 2 */ | 578 | /* Force a compilation error if a constant expression is not a power of 2 */ |
| 759 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ | 579 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ |
| 760 | BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) | 580 | BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) |
| @@ -766,6 +586,32 @@ struct sysinfo { | |||
| 766 | #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) | 586 | #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) |
| 767 | #define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) | 587 | #define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) |
| 768 | 588 | ||
| 589 | /** | ||
| 590 | * BUILD_BUG_ON - break compile if a condition is true. | ||
| 591 | * @cond: the condition which the compiler should know is false. | ||
| 592 | * | ||
| 593 | * If you have some code which relies on certain constants being equal, or | ||
| 594 | * other compile-time-evaluated condition, you should use BUILD_BUG_ON to | ||
| 595 | * detect if someone changes it. | ||
| 596 | * | ||
| 597 | * The implementation uses gcc's reluctance to create a negative array, but | ||
| 598 | * gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments | ||
| 599 | * to inline functions). So as a fallback we use the optimizer; if it can't | ||
| 600 | * prove the condition is false, it will cause a link error on the undefined | ||
| 601 | * "__build_bug_on_failed". This error message can be harder to track down | ||
| 602 | * though, hence the two different methods. | ||
| 603 | */ | ||
| 604 | #ifndef __OPTIMIZE__ | ||
| 605 | #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) | ||
| 606 | #else | ||
| 607 | extern int __build_bug_on_failed; | ||
| 608 | #define BUILD_BUG_ON(condition) \ | ||
| 609 | do { \ | ||
| 610 | ((void)sizeof(char[1 - 2*!!(condition)])); \ | ||
| 611 | if (condition) __build_bug_on_failed = 1; \ | ||
| 612 | } while(0) | ||
| 613 | #endif | ||
| 614 | |||
| 769 | /* Trap pasters of __FUNCTION__ at compile-time */ | 615 | /* Trap pasters of __FUNCTION__ at compile-time */ |
| 770 | #define __FUNCTION__ (__func__) | 616 | #define __FUNCTION__ (__func__) |
| 771 | 617 | ||
| @@ -776,6 +622,13 @@ struct sysinfo { | |||
| 776 | #define NUMA_BUILD 0 | 622 | #define NUMA_BUILD 0 |
| 777 | #endif | 623 | #endif |
| 778 | 624 | ||
| 625 | /* This helps us avoid #ifdef CONFIG_COMPACTION */ | ||
| 626 | #ifdef CONFIG_COMPACTION | ||
| 627 | #define COMPACTION_BUILD 1 | ||
| 628 | #else | ||
| 629 | #define COMPACTION_BUILD 0 | ||
| 630 | #endif | ||
| 631 | |||
| 779 | /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ | 632 | /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ |
| 780 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD | 633 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD |
| 781 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD | 634 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD |
