diff options
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 112 |
1 files changed, 63 insertions, 49 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 567a6f7bbeed..e8b1597b5cf2 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -56,6 +56,14 @@ | |||
56 | 56 | ||
57 | #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) | 57 | #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) |
58 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) | 58 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) |
59 | #define DIV_ROUND_UP_ULL(ll,d) \ | ||
60 | ({ unsigned long long _tmp = (ll)+(d)-1; do_div(_tmp, d); _tmp; }) | ||
61 | |||
62 | #if BITS_PER_LONG == 32 | ||
63 | # define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP_ULL(ll, d) | ||
64 | #else | ||
65 | # define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP(ll,d) | ||
66 | #endif | ||
59 | 67 | ||
60 | /* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */ | 68 | /* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */ |
61 | #define roundup(x, y) ( \ | 69 | #define roundup(x, y) ( \ |
@@ -279,6 +287,8 @@ static inline int __must_check kstrtos32_from_user(const char __user *s, size_t | |||
279 | return kstrtoint_from_user(s, count, base, res); | 287 | return kstrtoint_from_user(s, count, base, res); |
280 | } | 288 | } |
281 | 289 | ||
290 | /* Obsolete, do not use. Use kstrto<foo> instead */ | ||
291 | |||
282 | extern unsigned long simple_strtoul(const char *,char **,unsigned int); | 292 | extern unsigned long simple_strtoul(const char *,char **,unsigned int); |
283 | extern long simple_strtol(const char *,char **,unsigned int); | 293 | extern long simple_strtol(const char *,char **,unsigned int); |
284 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); | 294 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); |
@@ -288,20 +298,20 @@ extern long long simple_strtoll(const char *,char **,unsigned int); | |||
288 | #define strict_strtoull kstrtoull | 298 | #define strict_strtoull kstrtoull |
289 | #define strict_strtoll kstrtoll | 299 | #define strict_strtoll kstrtoll |
290 | 300 | ||
291 | extern int sprintf(char * buf, const char * fmt, ...) | 301 | /* lib/printf utilities */ |
292 | __attribute__ ((format (printf, 2, 3))); | 302 | |
293 | extern int vsprintf(char *buf, const char *, va_list) | 303 | extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...); |
294 | __attribute__ ((format (printf, 2, 0))); | 304 | extern __printf(2, 0) int vsprintf(char *buf, const char *, va_list); |
295 | extern int snprintf(char * buf, size_t size, const char * fmt, ...) | 305 | extern __printf(3, 4) |
296 | __attribute__ ((format (printf, 3, 4))); | 306 | int snprintf(char *buf, size_t size, const char *fmt, ...); |
297 | extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) | 307 | extern __printf(3, 0) |
298 | __attribute__ ((format (printf, 3, 0))); | 308 | int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); |
299 | extern int scnprintf(char * buf, size_t size, const char * fmt, ...) | 309 | extern __printf(3, 4) |
300 | __attribute__ ((format (printf, 3, 4))); | 310 | int scnprintf(char *buf, size_t size, const char *fmt, ...); |
301 | extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args) | 311 | extern __printf(3, 0) |
302 | __attribute__ ((format (printf, 3, 0))); | 312 | int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); |
303 | extern char *kasprintf(gfp_t gfp, const char *fmt, ...) | 313 | extern __printf(2, 3) |
304 | __attribute__ ((format (printf, 2, 3))); | 314 | char *kasprintf(gfp_t gfp, const char *fmt, ...); |
305 | extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); | 315 | extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); |
306 | 316 | ||
307 | extern int sscanf(const char *, const char *, ...) | 317 | extern int sscanf(const char *, const char *, ...) |
@@ -361,20 +371,26 @@ extern enum system_states { | |||
361 | #define TAINT_WARN 9 | 371 | #define TAINT_WARN 9 |
362 | #define TAINT_CRAP 10 | 372 | #define TAINT_CRAP 10 |
363 | #define TAINT_FIRMWARE_WORKAROUND 11 | 373 | #define TAINT_FIRMWARE_WORKAROUND 11 |
374 | #define TAINT_OOT_MODULE 12 | ||
364 | 375 | ||
365 | extern const char hex_asc[]; | 376 | extern const char hex_asc[]; |
366 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] | 377 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] |
367 | #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] | 378 | #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] |
368 | 379 | ||
369 | static inline char *pack_hex_byte(char *buf, u8 byte) | 380 | static inline char *hex_byte_pack(char *buf, u8 byte) |
370 | { | 381 | { |
371 | *buf++ = hex_asc_hi(byte); | 382 | *buf++ = hex_asc_hi(byte); |
372 | *buf++ = hex_asc_lo(byte); | 383 | *buf++ = hex_asc_lo(byte); |
373 | return buf; | 384 | return buf; |
374 | } | 385 | } |
375 | 386 | ||
387 | static inline char * __deprecated pack_hex_byte(char *buf, u8 byte) | ||
388 | { | ||
389 | return hex_byte_pack(buf, byte); | ||
390 | } | ||
391 | |||
376 | extern int hex_to_bin(char ch); | 392 | extern int hex_to_bin(char ch); |
377 | extern void hex2bin(u8 *dst, const char *src, size_t count); | 393 | extern int __must_check hex2bin(u8 *dst, const char *src, size_t count); |
378 | 394 | ||
379 | /* | 395 | /* |
380 | * General tracing related utility functions - trace_printk(), | 396 | * General tracing related utility functions - trace_printk(), |
@@ -419,8 +435,8 @@ extern void tracing_start(void); | |||
419 | extern void tracing_stop(void); | 435 | extern void tracing_stop(void); |
420 | extern void ftrace_off_permanent(void); | 436 | extern void ftrace_off_permanent(void); |
421 | 437 | ||
422 | static inline void __attribute__ ((format (printf, 1, 2))) | 438 | static inline __printf(1, 2) |
423 | ____trace_printk_check_format(const char *fmt, ...) | 439 | void ____trace_printk_check_format(const char *fmt, ...) |
424 | { | 440 | { |
425 | } | 441 | } |
426 | #define __trace_printk_check_format(fmt, args...) \ | 442 | #define __trace_printk_check_format(fmt, args...) \ |
@@ -459,13 +475,11 @@ do { \ | |||
459 | __trace_printk(_THIS_IP_, fmt, ##args); \ | 475 | __trace_printk(_THIS_IP_, fmt, ##args); \ |
460 | } while (0) | 476 | } while (0) |
461 | 477 | ||
462 | extern int | 478 | extern __printf(2, 3) |
463 | __trace_bprintk(unsigned long ip, const char *fmt, ...) | 479 | int __trace_bprintk(unsigned long ip, const char *fmt, ...); |
464 | __attribute__ ((format (printf, 2, 3))); | ||
465 | 480 | ||
466 | extern int | 481 | extern __printf(2, 3) |
467 | __trace_printk(unsigned long ip, const char *fmt, ...) | 482 | int __trace_printk(unsigned long ip, const char *fmt, ...); |
468 | __attribute__ ((format (printf, 2, 3))); | ||
469 | 483 | ||
470 | extern void trace_dump_stack(void); | 484 | extern void trace_dump_stack(void); |
471 | 485 | ||
@@ -494,8 +508,8 @@ __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); | |||
494 | 508 | ||
495 | extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode); | 509 | extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode); |
496 | #else | 510 | #else |
497 | static inline int | 511 | static inline __printf(1, 2) |
498 | trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); | 512 | int trace_printk(const char *fmt, ...); |
499 | 513 | ||
500 | static inline void tracing_start(void) { } | 514 | static inline void tracing_start(void) { } |
501 | static inline void tracing_stop(void) { } | 515 | static inline void tracing_stop(void) { } |
@@ -646,29 +660,6 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
646 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | 660 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
647 | (type *)( (char *)__mptr - offsetof(type,member) );}) | 661 | (type *)( (char *)__mptr - offsetof(type,member) );}) |
648 | 662 | ||
649 | struct sysinfo; | ||
650 | extern int do_sysinfo(struct sysinfo *info); | ||
651 | |||
652 | #endif /* __KERNEL__ */ | ||
653 | |||
654 | #define SI_LOAD_SHIFT 16 | ||
655 | struct sysinfo { | ||
656 | long uptime; /* Seconds since boot */ | ||
657 | unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ | ||
658 | unsigned long totalram; /* Total usable main memory size */ | ||
659 | unsigned long freeram; /* Available memory size */ | ||
660 | unsigned long sharedram; /* Amount of shared memory */ | ||
661 | unsigned long bufferram; /* Memory used by buffers */ | ||
662 | unsigned long totalswap; /* Total swap space size */ | ||
663 | unsigned long freeswap; /* swap space still available */ | ||
664 | unsigned short procs; /* Number of current processes */ | ||
665 | unsigned short pad; /* explicit padding for m68k */ | ||
666 | unsigned long totalhigh; /* Total high memory size */ | ||
667 | unsigned long freehigh; /* Available high memory size */ | ||
668 | unsigned int mem_unit; /* Memory unit size in bytes */ | ||
669 | char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ | ||
670 | }; | ||
671 | |||
672 | #ifdef __CHECKER__ | 663 | #ifdef __CHECKER__ |
673 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) | 664 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) |
674 | #define BUILD_BUG_ON_ZERO(e) (0) | 665 | #define BUILD_BUG_ON_ZERO(e) (0) |
@@ -736,4 +727,27 @@ extern int __build_bug_on_failed; | |||
736 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD | 727 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD |
737 | #endif | 728 | #endif |
738 | 729 | ||
730 | struct sysinfo; | ||
731 | extern int do_sysinfo(struct sysinfo *info); | ||
732 | |||
733 | #endif /* __KERNEL__ */ | ||
734 | |||
735 | #define SI_LOAD_SHIFT 16 | ||
736 | struct sysinfo { | ||
737 | long uptime; /* Seconds since boot */ | ||
738 | unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ | ||
739 | unsigned long totalram; /* Total usable main memory size */ | ||
740 | unsigned long freeram; /* Available memory size */ | ||
741 | unsigned long sharedram; /* Amount of shared memory */ | ||
742 | unsigned long bufferram; /* Memory used by buffers */ | ||
743 | unsigned long totalswap; /* Total swap space size */ | ||
744 | unsigned long freeswap; /* swap space still available */ | ||
745 | unsigned short procs; /* Number of current processes */ | ||
746 | unsigned short pad; /* explicit padding for m68k */ | ||
747 | unsigned long totalhigh; /* Total high memory size */ | ||
748 | unsigned long freehigh; /* Available high memory size */ | ||
749 | unsigned int mem_unit; /* Memory unit size in bytes */ | ||
750 | char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ | ||
751 | }; | ||
752 | |||
739 | #endif | 753 | #endif |