diff options
Diffstat (limited to 'include/linux/kernel.h')
| -rw-r--r-- | include/linux/kernel.h | 270 |
1 files changed, 142 insertions, 128 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index c566927efcb..54bf5a471e1 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
| @@ -1,6 +1,13 @@ | |||
| 1 | #ifndef _LINUX_KERNEL_H | 1 | #ifndef _LINUX_KERNEL_H |
| 2 | #define _LINUX_KERNEL_H | 2 | #define _LINUX_KERNEL_H |
| 3 | 3 | ||
| 4 | /* | ||
| 5 | * 'kernel.h' contains some often-used function prototypes etc | ||
| 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)) | ||
| 9 | |||
| 10 | #ifdef __KERNEL__ | ||
| 4 | 11 | ||
| 5 | #include <stdarg.h> | 12 | #include <stdarg.h> |
| 6 | #include <linux/linkage.h> | 13 | #include <linux/linkage.h> |
| @@ -13,7 +20,7 @@ | |||
| 13 | #include <linux/printk.h> | 20 | #include <linux/printk.h> |
| 14 | #include <linux/dynamic_debug.h> | 21 | #include <linux/dynamic_debug.h> |
| 15 | #include <asm/byteorder.h> | 22 | #include <asm/byteorder.h> |
| 16 | #include <uapi/linux/kernel.h> | 23 | #include <asm/bug.h> |
| 17 | 24 | ||
| 18 | #define USHRT_MAX ((u16)(~0U)) | 25 | #define USHRT_MAX ((u16)(~0U)) |
| 19 | #define SHRT_MAX ((s16)(USHRT_MAX>>1)) | 26 | #define SHRT_MAX ((s16)(USHRT_MAX>>1)) |
| @@ -27,12 +34,9 @@ | |||
| 27 | #define LLONG_MAX ((long long)(~0ULL>>1)) | 34 | #define LLONG_MAX ((long long)(~0ULL>>1)) |
| 28 | #define LLONG_MIN (-LLONG_MAX - 1) | 35 | #define LLONG_MIN (-LLONG_MAX - 1) |
| 29 | #define ULLONG_MAX (~0ULL) | 36 | #define ULLONG_MAX (~0ULL) |
| 30 | #define SIZE_MAX (~(size_t)0) | ||
| 31 | 37 | ||
| 32 | #define STACK_MAGIC 0xdeadbeef | 38 | #define STACK_MAGIC 0xdeadbeef |
| 33 | 39 | ||
| 34 | #define REPEAT_BYTE(x) ((~0ul / 0xff) * (x)) | ||
| 35 | |||
| 36 | #define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) | 40 | #define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) |
| 37 | #define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask)) | 41 | #define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask)) |
| 38 | #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))) |
| @@ -74,36 +78,13 @@ | |||
| 74 | __x - (__x % (y)); \ | 78 | __x - (__x % (y)); \ |
| 75 | } \ | 79 | } \ |
| 76 | ) | 80 | ) |
| 77 | |||
| 78 | /* | ||
| 79 | * Divide positive or negative dividend by positive divisor and round | ||
| 80 | * to closest integer. Result is undefined for negative divisors and | ||
| 81 | * for negative dividends if the divisor variable type is unsigned. | ||
| 82 | */ | ||
| 83 | #define DIV_ROUND_CLOSEST(x, divisor)( \ | 81 | #define DIV_ROUND_CLOSEST(x, divisor)( \ |
| 84 | { \ | 82 | { \ |
| 85 | typeof(x) __x = x; \ | 83 | typeof(divisor) __divisor = divisor; \ |
| 86 | typeof(divisor) __d = divisor; \ | 84 | (((x) + ((__divisor) / 2)) / (__divisor)); \ |
| 87 | (((typeof(x))-1) > 0 || \ | ||
| 88 | ((typeof(divisor))-1) > 0 || (__x) > 0) ? \ | ||
| 89 | (((__x) + ((__d) / 2)) / (__d)) : \ | ||
| 90 | (((__x) - ((__d) / 2)) / (__d)); \ | ||
| 91 | } \ | 85 | } \ |
| 92 | ) | 86 | ) |
| 93 | 87 | ||
| 94 | /* | ||
| 95 | * Multiplies an integer by a fraction, while avoiding unnecessary | ||
| 96 | * overflow or loss of precision. | ||
| 97 | */ | ||
| 98 | #define mult_frac(x, numer, denom)( \ | ||
| 99 | { \ | ||
| 100 | typeof(x) quot = (x) / (denom); \ | ||
| 101 | typeof(x) rem = (x) % (denom); \ | ||
| 102 | (quot * (numer)) + ((rem * (numer)) / (denom)); \ | ||
| 103 | } \ | ||
| 104 | ) | ||
| 105 | |||
| 106 | |||
| 107 | #define _RET_IP_ (unsigned long)__builtin_return_address(0) | 88 | #define _RET_IP_ (unsigned long)__builtin_return_address(0) |
| 108 | #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) | 89 | #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) |
| 109 | 90 | ||
| @@ -204,17 +185,16 @@ static inline void might_fault(void) | |||
| 204 | 185 | ||
| 205 | extern struct atomic_notifier_head panic_notifier_list; | 186 | extern struct atomic_notifier_head panic_notifier_list; |
| 206 | extern long (*panic_blink)(int state); | 187 | extern long (*panic_blink)(int state); |
| 207 | __printf(1, 2) | 188 | NORET_TYPE void panic(const char * fmt, ...) |
| 208 | void panic(const char *fmt, ...) | 189 | __attribute__ ((NORET_AND format (printf, 1, 2))) __cold; |
| 209 | __noreturn __cold; | ||
| 210 | extern void oops_enter(void); | 190 | extern void oops_enter(void); |
| 211 | extern void oops_exit(void); | 191 | extern void oops_exit(void); |
| 212 | void print_oops_end_marker(void); | 192 | void print_oops_end_marker(void); |
| 213 | extern int oops_may_print(void); | 193 | extern int oops_may_print(void); |
| 214 | void do_exit(long error_code) | 194 | NORET_TYPE void do_exit(long error_code) |
| 215 | __noreturn; | 195 | ATTRIB_NORET; |
| 216 | void complete_and_exit(struct completion *, long) | 196 | NORET_TYPE void complete_and_exit(struct completion *, long) |
| 217 | __noreturn; | 197 | ATTRIB_NORET; |
| 218 | 198 | ||
| 219 | /* Internal, do not use. */ | 199 | /* Internal, do not use. */ |
| 220 | int __must_check _kstrtoul(const char *s, unsigned int base, unsigned long *res); | 200 | int __must_check _kstrtoul(const char *s, unsigned int base, unsigned long *res); |
| @@ -222,23 +202,6 @@ int __must_check _kstrtol(const char *s, unsigned int base, long *res); | |||
| 222 | 202 | ||
| 223 | int __must_check kstrtoull(const char *s, unsigned int base, unsigned long long *res); | 203 | int __must_check kstrtoull(const char *s, unsigned int base, unsigned long long *res); |
| 224 | int __must_check kstrtoll(const char *s, unsigned int base, long long *res); | 204 | int __must_check kstrtoll(const char *s, unsigned int base, long long *res); |
| 225 | |||
| 226 | /** | ||
| 227 | * kstrtoul - convert a string to an unsigned long | ||
| 228 | * @s: The start of the string. The string must be null-terminated, and may also | ||
| 229 | * include a single newline before its terminating null. The first character | ||
| 230 | * may also be a plus sign, but not a minus sign. | ||
| 231 | * @base: The number base to use. The maximum supported base is 16. If base is | ||
| 232 | * given as 0, then the base of the string is automatically detected with the | ||
| 233 | * conventional semantics - If it begins with 0x the number will be parsed as a | ||
| 234 | * hexadecimal (case insensitive), if it otherwise begins with 0, it will be | ||
| 235 | * parsed as an octal number. Otherwise it will be parsed as a decimal. | ||
| 236 | * @res: Where to write the result of the conversion on success. | ||
| 237 | * | ||
| 238 | * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. | ||
| 239 | * Used as a replacement for the obsolete simple_strtoull. Return code must | ||
| 240 | * be checked. | ||
| 241 | */ | ||
| 242 | static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res) | 205 | static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res) |
| 243 | { | 206 | { |
| 244 | /* | 207 | /* |
| @@ -252,22 +215,6 @@ static inline int __must_check kstrtoul(const char *s, unsigned int base, unsign | |||
| 252 | return _kstrtoul(s, base, res); | 215 | return _kstrtoul(s, base, res); |
| 253 | } | 216 | } |
| 254 | 217 | ||
| 255 | /** | ||
| 256 | * kstrtol - convert a string to a long | ||
| 257 | * @s: The start of the string. The string must be null-terminated, and may also | ||
| 258 | * include a single newline before its terminating null. The first character | ||
| 259 | * may also be a plus sign or a minus sign. | ||
| 260 | * @base: The number base to use. The maximum supported base is 16. If base is | ||
| 261 | * given as 0, then the base of the string is automatically detected with the | ||
| 262 | * conventional semantics - If it begins with 0x the number will be parsed as a | ||
| 263 | * hexadecimal (case insensitive), if it otherwise begins with 0, it will be | ||
| 264 | * parsed as an octal number. Otherwise it will be parsed as a decimal. | ||
| 265 | * @res: Where to write the result of the conversion on success. | ||
| 266 | * | ||
| 267 | * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. | ||
| 268 | * Used as a replacement for the obsolete simple_strtoull. Return code must | ||
| 269 | * be checked. | ||
| 270 | */ | ||
| 271 | static inline int __must_check kstrtol(const char *s, unsigned int base, long *res) | 218 | static inline int __must_check kstrtol(const char *s, unsigned int base, long *res) |
| 272 | { | 219 | { |
| 273 | /* | 220 | /* |
| @@ -340,8 +287,6 @@ static inline int __must_check kstrtos32_from_user(const char __user *s, size_t | |||
| 340 | return kstrtoint_from_user(s, count, base, res); | 287 | return kstrtoint_from_user(s, count, base, res); |
| 341 | } | 288 | } |
| 342 | 289 | ||
| 343 | /* Obsolete, do not use. Use kstrto<foo> instead */ | ||
| 344 | |||
| 345 | extern unsigned long simple_strtoul(const char *,char **,unsigned int); | 290 | extern unsigned long simple_strtoul(const char *,char **,unsigned int); |
| 346 | extern long simple_strtol(const char *,char **,unsigned int); | 291 | extern long simple_strtol(const char *,char **,unsigned int); |
| 347 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); | 292 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); |
| @@ -351,28 +296,26 @@ extern long long simple_strtoll(const char *,char **,unsigned int); | |||
| 351 | #define strict_strtoull kstrtoull | 296 | #define strict_strtoull kstrtoull |
| 352 | #define strict_strtoll kstrtoll | 297 | #define strict_strtoll kstrtoll |
| 353 | 298 | ||
| 354 | extern int num_to_str(char *buf, int size, unsigned long long num); | 299 | extern int sprintf(char * buf, const char * fmt, ...) |
| 355 | 300 | __attribute__ ((format (printf, 2, 3))); | |
| 356 | /* lib/printf utilities */ | 301 | extern int vsprintf(char *buf, const char *, va_list) |
| 357 | 302 | __attribute__ ((format (printf, 2, 0))); | |
| 358 | extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...); | 303 | extern int snprintf(char * buf, size_t size, const char * fmt, ...) |
| 359 | extern __printf(2, 0) int vsprintf(char *buf, const char *, va_list); | 304 | __attribute__ ((format (printf, 3, 4))); |
| 360 | extern __printf(3, 4) | 305 | extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) |
| 361 | int snprintf(char *buf, size_t size, const char *fmt, ...); | 306 | __attribute__ ((format (printf, 3, 0))); |
| 362 | extern __printf(3, 0) | 307 | extern int scnprintf(char * buf, size_t size, const char * fmt, ...) |
| 363 | int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); | 308 | __attribute__ ((format (printf, 3, 4))); |
| 364 | extern __printf(3, 4) | 309 | extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args) |
| 365 | int scnprintf(char *buf, size_t size, const char *fmt, ...); | 310 | __attribute__ ((format (printf, 3, 0))); |
| 366 | extern __printf(3, 0) | 311 | extern char *kasprintf(gfp_t gfp, const char *fmt, ...) |
| 367 | int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); | 312 | __attribute__ ((format (printf, 2, 3))); |
| 368 | extern __printf(2, 3) | ||
| 369 | char *kasprintf(gfp_t gfp, const char *fmt, ...); | ||
| 370 | extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); | 313 | extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); |
| 371 | 314 | ||
| 372 | extern __scanf(2, 3) | 315 | extern int sscanf(const char *, const char *, ...) |
| 373 | int sscanf(const char *, const char *, ...); | 316 | __attribute__ ((format (scanf, 2, 3))); |
| 374 | extern __scanf(2, 0) | 317 | extern int vsscanf(const char *, const char *, va_list) |
| 375 | int vsscanf(const char *, const char *, va_list); | 318 | __attribute__ ((format (scanf, 2, 0))); |
| 376 | 319 | ||
| 377 | extern int get_option(char **str, int *pint); | 320 | extern int get_option(char **str, int *pint); |
| 378 | extern char *get_options(const char *str, int nints, int *ints); | 321 | extern char *get_options(const char *str, int nints, int *ints); |
| @@ -396,7 +339,6 @@ extern int panic_timeout; | |||
| 396 | extern int panic_on_oops; | 339 | extern int panic_on_oops; |
| 397 | extern int panic_on_unrecovered_nmi; | 340 | extern int panic_on_unrecovered_nmi; |
| 398 | extern int panic_on_io_nmi; | 341 | extern int panic_on_io_nmi; |
| 399 | extern int sysctl_panic_on_stackoverflow; | ||
| 400 | extern const char *print_tainted(void); | 342 | extern const char *print_tainted(void); |
| 401 | extern void add_taint(unsigned flag); | 343 | extern void add_taint(unsigned flag); |
| 402 | extern int test_taint(unsigned flag); | 344 | extern int test_taint(unsigned flag); |
| @@ -412,6 +354,7 @@ extern enum system_states { | |||
| 412 | SYSTEM_HALT, | 354 | SYSTEM_HALT, |
| 413 | SYSTEM_POWER_OFF, | 355 | SYSTEM_POWER_OFF, |
| 414 | SYSTEM_RESTART, | 356 | SYSTEM_RESTART, |
| 357 | SYSTEM_SUSPEND_DISK, | ||
| 415 | } system_state; | 358 | } system_state; |
| 416 | 359 | ||
| 417 | #define TAINT_PROPRIETARY_MODULE 0 | 360 | #define TAINT_PROPRIETARY_MODULE 0 |
| @@ -426,26 +369,20 @@ extern enum system_states { | |||
| 426 | #define TAINT_WARN 9 | 369 | #define TAINT_WARN 9 |
| 427 | #define TAINT_CRAP 10 | 370 | #define TAINT_CRAP 10 |
| 428 | #define TAINT_FIRMWARE_WORKAROUND 11 | 371 | #define TAINT_FIRMWARE_WORKAROUND 11 |
| 429 | #define TAINT_OOT_MODULE 12 | ||
| 430 | 372 | ||
| 431 | extern const char hex_asc[]; | 373 | extern const char hex_asc[]; |
| 432 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] | 374 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] |
| 433 | #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] | 375 | #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] |
| 434 | 376 | ||
| 435 | static inline char *hex_byte_pack(char *buf, u8 byte) | 377 | static inline char *pack_hex_byte(char *buf, u8 byte) |
| 436 | { | 378 | { |
| 437 | *buf++ = hex_asc_hi(byte); | 379 | *buf++ = hex_asc_hi(byte); |
| 438 | *buf++ = hex_asc_lo(byte); | 380 | *buf++ = hex_asc_lo(byte); |
| 439 | return buf; | 381 | return buf; |
| 440 | } | 382 | } |
| 441 | 383 | ||
| 442 | static inline char * __deprecated pack_hex_byte(char *buf, u8 byte) | ||
| 443 | { | ||
| 444 | return hex_byte_pack(buf, byte); | ||
| 445 | } | ||
| 446 | |||
| 447 | extern int hex_to_bin(char ch); | 384 | extern int hex_to_bin(char ch); |
| 448 | extern int __must_check hex2bin(u8 *dst, const char *src, size_t count); | 385 | extern void hex2bin(u8 *dst, const char *src, size_t count); |
| 449 | 386 | ||
| 450 | /* | 387 | /* |
| 451 | * General tracing related utility functions - trace_printk(), | 388 | * General tracing related utility functions - trace_printk(), |
| @@ -467,10 +404,16 @@ extern int __must_check hex2bin(u8 *dst, const char *src, size_t count); | |||
| 467 | * Most likely, you want to use tracing_on/tracing_off. | 404 | * Most likely, you want to use tracing_on/tracing_off. |
| 468 | */ | 405 | */ |
| 469 | #ifdef CONFIG_RING_BUFFER | 406 | #ifdef CONFIG_RING_BUFFER |
| 407 | void tracing_on(void); | ||
| 408 | void tracing_off(void); | ||
| 470 | /* trace_off_permanent stops recording with no way to bring it back */ | 409 | /* trace_off_permanent stops recording with no way to bring it back */ |
| 471 | void tracing_off_permanent(void); | 410 | void tracing_off_permanent(void); |
| 411 | int tracing_is_on(void); | ||
| 472 | #else | 412 | #else |
| 413 | static inline void tracing_on(void) { } | ||
| 414 | static inline void tracing_off(void) { } | ||
| 473 | static inline void tracing_off_permanent(void) { } | 415 | static inline void tracing_off_permanent(void) { } |
| 416 | static inline int tracing_is_on(void) { return 0; } | ||
| 474 | #endif | 417 | #endif |
| 475 | 418 | ||
| 476 | enum ftrace_dump_mode { | 419 | enum ftrace_dump_mode { |
| @@ -480,16 +423,12 @@ enum ftrace_dump_mode { | |||
| 480 | }; | 423 | }; |
| 481 | 424 | ||
| 482 | #ifdef CONFIG_TRACING | 425 | #ifdef CONFIG_TRACING |
| 483 | void tracing_on(void); | ||
| 484 | void tracing_off(void); | ||
| 485 | int tracing_is_on(void); | ||
| 486 | |||
| 487 | extern void tracing_start(void); | 426 | extern void tracing_start(void); |
| 488 | extern void tracing_stop(void); | 427 | extern void tracing_stop(void); |
| 489 | extern void ftrace_off_permanent(void); | 428 | extern void ftrace_off_permanent(void); |
| 490 | 429 | ||
| 491 | static inline __printf(1, 2) | 430 | static inline void __attribute__ ((format (printf, 1, 2))) |
| 492 | void ____trace_printk_check_format(const char *fmt, ...) | 431 | ____trace_printk_check_format(const char *fmt, ...) |
| 493 | { | 432 | { |
| 494 | } | 433 | } |
| 495 | #define __trace_printk_check_format(fmt, args...) \ | 434 | #define __trace_printk_check_format(fmt, args...) \ |
| @@ -517,23 +456,24 @@ do { \ | |||
| 517 | 456 | ||
| 518 | #define trace_printk(fmt, args...) \ | 457 | #define trace_printk(fmt, args...) \ |
| 519 | do { \ | 458 | do { \ |
| 520 | static const char *trace_printk_fmt \ | ||
| 521 | __attribute__((section("__trace_printk_fmt"))) = \ | ||
| 522 | __builtin_constant_p(fmt) ? fmt : NULL; \ | ||
| 523 | \ | ||
| 524 | __trace_printk_check_format(fmt, ##args); \ | 459 | __trace_printk_check_format(fmt, ##args); \ |
| 460 | if (__builtin_constant_p(fmt)) { \ | ||
| 461 | static const char *trace_printk_fmt \ | ||
| 462 | __attribute__((section("__trace_printk_fmt"))) = \ | ||
| 463 | __builtin_constant_p(fmt) ? fmt : NULL; \ | ||
| 525 | \ | 464 | \ |
| 526 | if (__builtin_constant_p(fmt)) \ | ||
| 527 | __trace_bprintk(_THIS_IP_, trace_printk_fmt, ##args); \ | 465 | __trace_bprintk(_THIS_IP_, trace_printk_fmt, ##args); \ |
| 528 | else \ | 466 | } else \ |
| 529 | __trace_printk(_THIS_IP_, fmt, ##args); \ | 467 | __trace_printk(_THIS_IP_, fmt, ##args); \ |
| 530 | } while (0) | 468 | } while (0) |
| 531 | 469 | ||
| 532 | extern __printf(2, 3) | 470 | extern int |
| 533 | int __trace_bprintk(unsigned long ip, const char *fmt, ...); | 471 | __trace_bprintk(unsigned long ip, const char *fmt, ...) |
| 472 | __attribute__ ((format (printf, 2, 3))); | ||
| 534 | 473 | ||
| 535 | extern __printf(2, 3) | 474 | extern int |
| 536 | int __trace_printk(unsigned long ip, const char *fmt, ...); | 475 | __trace_printk(unsigned long ip, const char *fmt, ...) |
| 476 | __attribute__ ((format (printf, 2, 3))); | ||
| 537 | 477 | ||
| 538 | extern void trace_dump_stack(void); | 478 | extern void trace_dump_stack(void); |
| 539 | 479 | ||
| @@ -562,17 +502,15 @@ __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); | |||
| 562 | 502 | ||
| 563 | extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode); | 503 | extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode); |
| 564 | #else | 504 | #else |
| 505 | static inline int | ||
| 506 | trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); | ||
| 507 | |||
| 565 | static inline void tracing_start(void) { } | 508 | static inline void tracing_start(void) { } |
| 566 | static inline void tracing_stop(void) { } | 509 | static inline void tracing_stop(void) { } |
| 567 | static inline void ftrace_off_permanent(void) { } | 510 | static inline void ftrace_off_permanent(void) { } |
| 568 | static inline void trace_dump_stack(void) { } | 511 | static inline void trace_dump_stack(void) { } |
| 569 | 512 | static inline int | |
| 570 | static inline void tracing_on(void) { } | 513 | trace_printk(const char *fmt, ...) |
| 571 | static inline void tracing_off(void) { } | ||
| 572 | static inline int tracing_is_on(void) { return 0; } | ||
| 573 | |||
| 574 | static inline __printf(1, 2) | ||
| 575 | int trace_printk(const char *fmt, ...) | ||
| 576 | { | 514 | { |
| 577 | return 0; | 515 | return 0; |
| 578 | } | 516 | } |
| @@ -716,14 +654,66 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
| 716 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | 654 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
| 717 | (type *)( (char *)__mptr - offsetof(type,member) );}) | 655 | (type *)( (char *)__mptr - offsetof(type,member) );}) |
| 718 | 656 | ||
| 657 | #ifdef __CHECKER__ | ||
| 658 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) | ||
| 659 | #define BUILD_BUG_ON_ZERO(e) (0) | ||
| 660 | #define BUILD_BUG_ON_NULL(e) ((void*)0) | ||
| 661 | #define BUILD_BUG_ON(condition) | ||
| 662 | #else /* __CHECKER__ */ | ||
| 663 | |||
| 664 | /* Force a compilation error if a constant expression is not a power of 2 */ | ||
| 665 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ | ||
| 666 | BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) | ||
| 667 | |||
| 668 | /* Force a compilation error if condition is true, but also produce a | ||
| 669 | result (of value 0 and type size_t), so the expression can be used | ||
| 670 | e.g. in a structure initializer (or where-ever else comma expressions | ||
| 671 | aren't permitted). */ | ||
| 672 | #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) | ||
| 673 | #define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) | ||
| 674 | |||
| 675 | /** | ||
| 676 | * BUILD_BUG_ON - break compile if a condition is true. | ||
| 677 | * @condition: the condition which the compiler should know is false. | ||
| 678 | * | ||
| 679 | * If you have some code which relies on certain constants being equal, or | ||
| 680 | * other compile-time-evaluated condition, you should use BUILD_BUG_ON to | ||
| 681 | * detect if someone changes it. | ||
| 682 | * | ||
| 683 | * The implementation uses gcc's reluctance to create a negative array, but | ||
| 684 | * gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments | ||
| 685 | * to inline functions). So as a fallback we use the optimizer; if it can't | ||
| 686 | * prove the condition is false, it will cause a link error on the undefined | ||
| 687 | * "__build_bug_on_failed". This error message can be harder to track down | ||
| 688 | * though, hence the two different methods. | ||
| 689 | */ | ||
| 690 | #ifndef __OPTIMIZE__ | ||
| 691 | #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) | ||
| 692 | #else | ||
| 693 | extern int __build_bug_on_failed; | ||
| 694 | #define BUILD_BUG_ON(condition) \ | ||
| 695 | do { \ | ||
| 696 | ((void)sizeof(char[1 - 2*!!(condition)])); \ | ||
| 697 | if (condition) __build_bug_on_failed = 1; \ | ||
| 698 | } while(0) | ||
| 699 | #endif | ||
| 700 | #endif /* __CHECKER__ */ | ||
| 701 | |||
| 719 | /* Trap pasters of __FUNCTION__ at compile-time */ | 702 | /* Trap pasters of __FUNCTION__ at compile-time */ |
| 720 | #define __FUNCTION__ (__func__) | 703 | #define __FUNCTION__ (__func__) |
| 721 | 704 | ||
| 722 | /* This helps us to avoid #ifdef CONFIG_SYMBOL_PREFIX */ | 705 | /* This helps us to avoid #ifdef CONFIG_NUMA */ |
| 723 | #ifdef CONFIG_SYMBOL_PREFIX | 706 | #ifdef CONFIG_NUMA |
| 724 | #define SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX | 707 | #define NUMA_BUILD 1 |
| 708 | #else | ||
| 709 | #define NUMA_BUILD 0 | ||
| 710 | #endif | ||
| 711 | |||
| 712 | /* This helps us avoid #ifdef CONFIG_COMPACTION */ | ||
| 713 | #ifdef CONFIG_COMPACTION | ||
| 714 | #define COMPACTION_BUILD 1 | ||
| 725 | #else | 715 | #else |
| 726 | #define SYMBOL_PREFIX "" | 716 | #define COMPACTION_BUILD 0 |
| 727 | #endif | 717 | #endif |
| 728 | 718 | ||
| 729 | /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ | 719 | /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ |
| @@ -731,6 +721,30 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
| 731 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD | 721 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD |
| 732 | #endif | 722 | #endif |
| 733 | 723 | ||
| 724 | struct sysinfo; | ||
| 734 | extern int do_sysinfo(struct sysinfo *info); | 725 | extern int do_sysinfo(struct sysinfo *info); |
| 735 | 726 | ||
| 727 | #endif /* __KERNEL__ */ | ||
| 728 | |||
| 729 | #define SI_LOAD_SHIFT 16 | ||
| 730 | struct sysinfo { | ||
| 731 | long uptime; /* Seconds since boot */ | ||
| 732 | unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ | ||
| 733 | unsigned long totalram; /* Total usable main memory size */ | ||
| 734 | unsigned long freeram; /* Available memory size */ | ||
| 735 | unsigned long sharedram; /* Amount of shared memory */ | ||
| 736 | unsigned long bufferram; /* Memory used by buffers */ | ||
| 737 | unsigned long totalswap; /* Total swap space size */ | ||
| 738 | unsigned long freeswap; /* swap space still available */ | ||
| 739 | unsigned short procs; /* Number of current processes */ | ||
| 740 | unsigned short pad; /* explicit padding for m68k */ | ||
| 741 | unsigned long totalhigh; /* Total high memory size */ | ||
| 742 | unsigned long freehigh; /* Available high memory size */ | ||
| 743 | unsigned int mem_unit; /* Memory unit size in bytes */ | ||
| 744 | char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ | ||
| 745 | }; | ||
| 746 | |||
| 747 | /* To identify board information in panic logs, set this */ | ||
| 748 | extern char *mach_panic_string; | ||
| 749 | |||
| 736 | #endif | 750 | #endif |
