aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h100
1 files changed, 13 insertions, 87 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index f2085b541a24..645231c373c8 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -1,6 +1,8 @@
1#ifndef _LINUX_KERNEL_H 1#ifndef _LINUX_KERNEL_H
2#define _LINUX_KERNEL_H 2#define _LINUX_KERNEL_H
3 3
4#include <linux/sysinfo.h>
5
4/* 6/*
5 * 'kernel.h' contains some often-used function prototypes etc 7 * 'kernel.h' contains some often-used function prototypes etc
6 */ 8 */
@@ -20,7 +22,6 @@
20#include <linux/printk.h> 22#include <linux/printk.h>
21#include <linux/dynamic_debug.h> 23#include <linux/dynamic_debug.h>
22#include <asm/byteorder.h> 24#include <asm/byteorder.h>
23#include <asm/bug.h>
24 25
25#define USHRT_MAX ((u16)(~0U)) 26#define USHRT_MAX ((u16)(~0U))
26#define SHRT_MAX ((s16)(USHRT_MAX>>1)) 27#define SHRT_MAX ((s16)(USHRT_MAX>>1))
@@ -312,6 +313,8 @@ extern long long simple_strtoll(const char *,char **,unsigned int);
312#define strict_strtoull kstrtoull 313#define strict_strtoull kstrtoull
313#define strict_strtoll kstrtoll 314#define strict_strtoll kstrtoll
314 315
316extern int num_to_str(char *buf, int size, unsigned long long num);
317
315/* lib/printf utilities */ 318/* lib/printf utilities */
316 319
317extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...); 320extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...);
@@ -427,16 +430,10 @@ extern int __must_check hex2bin(u8 *dst, const char *src, size_t count);
427 * Most likely, you want to use tracing_on/tracing_off. 430 * Most likely, you want to use tracing_on/tracing_off.
428 */ 431 */
429#ifdef CONFIG_RING_BUFFER 432#ifdef CONFIG_RING_BUFFER
430void tracing_on(void);
431void tracing_off(void);
432/* trace_off_permanent stops recording with no way to bring it back */ 433/* trace_off_permanent stops recording with no way to bring it back */
433void tracing_off_permanent(void); 434void tracing_off_permanent(void);
434int tracing_is_on(void);
435#else 435#else
436static inline void tracing_on(void) { }
437static inline void tracing_off(void) { }
438static inline void tracing_off_permanent(void) { } 436static inline void tracing_off_permanent(void) { }
439static inline int tracing_is_on(void) { return 0; }
440#endif 437#endif
441 438
442enum ftrace_dump_mode { 439enum ftrace_dump_mode {
@@ -446,6 +443,10 @@ enum ftrace_dump_mode {
446}; 443};
447 444
448#ifdef CONFIG_TRACING 445#ifdef CONFIG_TRACING
446void tracing_on(void);
447void tracing_off(void);
448int tracing_is_on(void);
449
449extern void tracing_start(void); 450extern void tracing_start(void);
450extern void tracing_stop(void); 451extern void tracing_stop(void);
451extern void ftrace_off_permanent(void); 452extern void ftrace_off_permanent(void);
@@ -530,6 +531,11 @@ static inline void tracing_start(void) { }
530static inline void tracing_stop(void) { } 531static inline void tracing_stop(void) { }
531static inline void ftrace_off_permanent(void) { } 532static inline void ftrace_off_permanent(void) { }
532static inline void trace_dump_stack(void) { } 533static inline void trace_dump_stack(void) { }
534
535static inline void tracing_on(void) { }
536static inline void tracing_off(void) { }
537static inline int tracing_is_on(void) { return 0; }
538
533static inline int 539static inline int
534trace_printk(const char *fmt, ...) 540trace_printk(const char *fmt, ...)
535{ 541{
@@ -675,67 +681,6 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
675 const typeof( ((type *)0)->member ) *__mptr = (ptr); \ 681 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
676 (type *)( (char *)__mptr - offsetof(type,member) );}) 682 (type *)( (char *)__mptr - offsetof(type,member) );})
677 683
678#ifdef __CHECKER__
679#define BUILD_BUG_ON_NOT_POWER_OF_2(n)
680#define BUILD_BUG_ON_ZERO(e) (0)
681#define BUILD_BUG_ON_NULL(e) ((void*)0)
682#define BUILD_BUG_ON(condition)
683#define BUILD_BUG() (0)
684#else /* __CHECKER__ */
685
686/* Force a compilation error if a constant expression is not a power of 2 */
687#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \
688 BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
689
690/* Force a compilation error if condition is true, but also produce a
691 result (of value 0 and type size_t), so the expression can be used
692 e.g. in a structure initializer (or where-ever else comma expressions
693 aren't permitted). */
694#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
695#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
696
697/**
698 * BUILD_BUG_ON - break compile if a condition is true.
699 * @condition: the condition which the compiler should know is false.
700 *
701 * If you have some code which relies on certain constants being equal, or
702 * other compile-time-evaluated condition, you should use BUILD_BUG_ON to
703 * detect if someone changes it.
704 *
705 * The implementation uses gcc's reluctance to create a negative array, but
706 * gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments
707 * to inline functions). So as a fallback we use the optimizer; if it can't
708 * prove the condition is false, it will cause a link error on the undefined
709 * "__build_bug_on_failed". This error message can be harder to track down
710 * though, hence the two different methods.
711 */
712#ifndef __OPTIMIZE__
713#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
714#else
715extern int __build_bug_on_failed;
716#define BUILD_BUG_ON(condition) \
717 do { \
718 ((void)sizeof(char[1 - 2*!!(condition)])); \
719 if (condition) __build_bug_on_failed = 1; \
720 } while(0)
721#endif
722
723/**
724 * BUILD_BUG - break compile if used.
725 *
726 * If you have some code that you expect the compiler to eliminate at
727 * build time, you should use BUILD_BUG to detect if it is
728 * unexpectedly used.
729 */
730#define BUILD_BUG() \
731 do { \
732 extern void __build_bug_failed(void) \
733 __linktime_error("BUILD_BUG failed"); \
734 __build_bug_failed(); \
735 } while (0)
736
737#endif /* __CHECKER__ */
738
739/* Trap pasters of __FUNCTION__ at compile-time */ 684/* Trap pasters of __FUNCTION__ at compile-time */
740#define __FUNCTION__ (__func__) 685#define __FUNCTION__ (__func__)
741 686
@@ -758,27 +703,8 @@ extern int __build_bug_on_failed;
758# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD 703# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
759#endif 704#endif
760 705
761struct sysinfo;
762extern int do_sysinfo(struct sysinfo *info); 706extern int do_sysinfo(struct sysinfo *info);
763 707
764#endif /* __KERNEL__ */ 708#endif /* __KERNEL__ */
765 709
766#define SI_LOAD_SHIFT 16
767struct sysinfo {
768 long uptime; /* Seconds since boot */
769 unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
770 unsigned long totalram; /* Total usable main memory size */
771 unsigned long freeram; /* Available memory size */
772 unsigned long sharedram; /* Amount of shared memory */
773 unsigned long bufferram; /* Memory used by buffers */
774 unsigned long totalswap; /* Total swap space size */
775 unsigned long freeswap; /* swap space still available */
776 unsigned short procs; /* Number of current processes */
777 unsigned short pad; /* explicit padding for m68k */
778 unsigned long totalhigh; /* Total high memory size */
779 unsigned long freehigh; /* Available high memory size */
780 unsigned int mem_unit; /* Memory unit size in bytes */
781 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
782};
783
784#endif 710#endif