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.h60
1 files changed, 51 insertions, 9 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d0fbc043de60..2fe6e84894a4 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -143,9 +143,22 @@ extern int _cond_resched(void);
143 143
144#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)
145 145
146#define abs(x) ({ \ 146/*
147 long __x = (x); \ 147 * abs() handles unsigned and signed longs, ints, shorts and chars. For all
148 (__x < 0) ? -__x : __x; \ 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; \
149 }) 162 })
150 163
151#define abs64(x) ({ \ 164#define abs64(x) ({ \
@@ -230,6 +243,8 @@ extern int test_taint(unsigned flag);
230extern unsigned long get_taint(void); 243extern unsigned long get_taint(void);
231extern int root_mountflags; 244extern int root_mountflags;
232 245
246extern bool early_boot_irqs_disabled;
247
233/* Values used for system_state */ 248/* Values used for system_state */
234extern enum system_states { 249extern enum system_states {
235 SYSTEM_BOOTING, 250 SYSTEM_BOOTING,
@@ -560,12 +575,6 @@ struct sysinfo {
560 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.. */
561}; 576};
562 577
563/* Force a compilation error if condition is true */
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 */ 578/* Force a compilation error if a constant expression is not a power of 2 */
570#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ 579#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \
571 BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) 580 BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
@@ -577,6 +586,32 @@ struct sysinfo {
577#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) 586#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
578#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) 587#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
579 588
589/**
590 * BUILD_BUG_ON - break compile if a condition is true.
591 * @condition: 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
607extern 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
580/* Trap pasters of __FUNCTION__ at compile-time */ 615/* Trap pasters of __FUNCTION__ at compile-time */
581#define __FUNCTION__ (__func__) 616#define __FUNCTION__ (__func__)
582 617
@@ -587,6 +622,13 @@ struct sysinfo {
587#define NUMA_BUILD 0 622#define NUMA_BUILD 0
588#endif 623#endif
589 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
590/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ 632/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
591#ifdef CONFIG_FTRACE_MCOUNT_RECORD 633#ifdef CONFIG_FTRACE_MCOUNT_RECORD
592# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD 634# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD