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.h364
1 files changed, 108 insertions, 256 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 328bca609b9b..5a9d9059520b 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -4,6 +4,8 @@
4/* 4/*
5 * 'kernel.h' contains some often-used function prototypes etc 5 * 'kernel.h' contains some often-used function prototypes etc
6 */ 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))
7 9
8#ifdef __KERNEL__ 10#ifdef __KERNEL__
9 11
@@ -15,16 +17,14 @@
15#include <linux/bitops.h> 17#include <linux/bitops.h>
16#include <linux/log2.h> 18#include <linux/log2.h>
17#include <linux/typecheck.h> 19#include <linux/typecheck.h>
20#include <linux/printk.h>
18#include <linux/dynamic_debug.h> 21#include <linux/dynamic_debug.h>
19#include <asm/byteorder.h> 22#include <asm/byteorder.h>
20#include <asm/bug.h> 23#include <asm/bug.h>
21 24
22extern const char linux_banner[]; 25#define USHRT_MAX ((u16)(~0U))
23extern const char linux_proc_banner[]; 26#define SHRT_MAX ((s16)(USHRT_MAX>>1))
24 27#define SHRT_MIN ((s16)(-SHRT_MAX - 1))
25#define USHORT_MAX ((u16)(~0U))
26#define SHORT_MAX ((s16)(USHORT_MAX>>1))
27#define SHORT_MIN (-SHORT_MAX - 1)
28#define INT_MAX ((int)(~0U>>1)) 28#define INT_MAX ((int)(~0U>>1))
29#define INT_MIN (-INT_MAX - 1) 29#define INT_MIN (-INT_MAX - 1)
30#define UINT_MAX (~0U) 30#define UINT_MAX (~0U)
@@ -37,16 +37,39 @@ extern const char linux_proc_banner[];
37 37
38#define STACK_MAGIC 0xdeadbeef 38#define STACK_MAGIC 0xdeadbeef
39 39
40#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) 40#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
41#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) 41#define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask))
42#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)))
43#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) 43#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
44 44
45#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) 45#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
46 46
47/*
48 * This looks more complex than it should be. But we need to
49 * get the type for the ~ right in round_down (it needs to be
50 * as wide as the result!), and we want to evaluate the macro
51 * arguments just once each.
52 */
53#define __round_mask(x, y) ((__typeof__(x))((y)-1))
54#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
55#define round_down(x, y) ((x) & ~__round_mask(x, y))
56
47#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) 57#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
48#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) 58#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
49#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)
50#define DIV_ROUND_CLOSEST(x, divisor)( \ 73#define DIV_ROUND_CLOSEST(x, divisor)( \
51{ \ 74{ \
52 typeof(divisor) __divisor = divisor; \ 75 typeof(divisor) __divisor = divisor; \
@@ -87,31 +110,6 @@ extern const char linux_proc_banner[];
87 */ 110 */
88#define lower_32_bits(n) ((u32)(n)) 111#define lower_32_bits(n) ((u32)(n))
89 112
90#define KERN_EMERG "<0>" /* system is unusable */
91#define KERN_ALERT "<1>" /* action must be taken immediately */
92#define KERN_CRIT "<2>" /* critical conditions */
93#define KERN_ERR "<3>" /* error conditions */
94#define KERN_WARNING "<4>" /* warning conditions */
95#define KERN_NOTICE "<5>" /* normal but significant condition */
96#define KERN_INFO "<6>" /* informational */
97#define KERN_DEBUG "<7>" /* debug-level messages */
98
99/* Use the default kernel loglevel */
100#define KERN_DEFAULT "<d>"
101/*
102 * Annotation for a "continued" line of log printout (only done after a
103 * line that had no enclosing \n). Only to be used by core/arch code
104 * during early bootup (a continued line is not SMP-safe otherwise).
105 */
106#define KERN_CONT "<c>"
107
108extern int console_printk[];
109
110#define console_loglevel (console_printk[0])
111#define default_message_loglevel (console_printk[1])
112#define minimum_console_loglevel (console_printk[2])
113#define default_console_loglevel (console_printk[3])
114
115struct completion; 113struct completion;
116struct pt_regs; 114struct pt_regs;
117struct user; 115struct user;
@@ -124,7 +122,7 @@ extern int _cond_resched(void);
124#endif 122#endif
125 123
126#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP 124#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
127 void __might_sleep(char *file, int line, int preempt_offset); 125 void __might_sleep(const char *file, int line, int preempt_offset);
128/** 126/**
129 * might_sleep - annotation for functions that can sleep 127 * might_sleep - annotation for functions that can sleep
130 * 128 *
@@ -138,14 +136,33 @@ extern int _cond_resched(void);
138# define might_sleep() \ 136# define might_sleep() \
139 do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0) 137 do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0)
140#else 138#else
141 static inline void __might_sleep(char *file, int line, int preempt_offset) { } 139 static inline void __might_sleep(const char *file, int line,
140 int preempt_offset) { }
142# define might_sleep() do { might_resched(); } while (0) 141# define might_sleep() do { might_resched(); } while (0)
143#endif 142#endif
144 143
145#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)
146 145
147#define abs(x) ({ \ 146/*
148 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); \
149 (__x < 0) ? -__x : __x; \ 166 (__x < 0) ? -__x : __x; \
150 }) 167 })
151 168
@@ -159,11 +176,12 @@ static inline void might_fault(void)
159#endif 176#endif
160 177
161extern struct atomic_notifier_head panic_notifier_list; 178extern struct atomic_notifier_head panic_notifier_list;
162extern long (*panic_blink)(long time); 179extern long (*panic_blink)(int state);
163NORET_TYPE void panic(const char * fmt, ...) 180NORET_TYPE void panic(const char * fmt, ...)
164 __attribute__ ((NORET_AND format (printf, 1, 2))) __cold; 181 __attribute__ ((NORET_AND format (printf, 1, 2))) __cold;
165extern void oops_enter(void); 182extern void oops_enter(void);
166extern void oops_exit(void); 183extern void oops_exit(void);
184void print_oops_end_marker(void);
167extern int oops_may_print(void); 185extern int oops_may_print(void);
168NORET_TYPE void do_exit(long error_code) 186NORET_TYPE void do_exit(long error_code)
169 ATTRIB_NORET; 187 ATTRIB_NORET;
@@ -173,10 +191,10 @@ extern unsigned long simple_strtoul(const char *,char **,unsigned int);
173extern long simple_strtol(const char *,char **,unsigned int); 191extern long simple_strtol(const char *,char **,unsigned int);
174extern unsigned long long simple_strtoull(const char *,char **,unsigned int); 192extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
175extern long long simple_strtoll(const char *,char **,unsigned int); 193extern long long simple_strtoll(const char *,char **,unsigned int);
176extern int strict_strtoul(const char *, unsigned int, unsigned long *); 194extern int __must_check strict_strtoul(const char *, unsigned int, unsigned long *);
177extern int strict_strtol(const char *, unsigned int, long *); 195extern int __must_check strict_strtol(const char *, unsigned int, long *);
178extern int strict_strtoull(const char *, unsigned int, unsigned long long *); 196extern int __must_check strict_strtoull(const char *, unsigned int, unsigned long long *);
179extern int strict_strtoll(const char *, unsigned int, long long *); 197extern int __must_check strict_strtoll(const char *, unsigned int, long long *);
180extern int sprintf(char * buf, const char * fmt, ...) 198extern int sprintf(char * buf, const char * fmt, ...)
181 __attribute__ ((format (printf, 2, 3))); 199 __attribute__ ((format (printf, 2, 3)));
182extern int vsprintf(char *buf, const char *, va_list) 200extern int vsprintf(char *buf, const char *, va_list)
@@ -210,95 +228,8 @@ extern int func_ptr_is_kernel_text(void *ptr);
210struct pid; 228struct pid;
211extern struct pid *session_of_pgrp(struct pid *pgrp); 229extern struct pid *session_of_pgrp(struct pid *pgrp);
212 230
213/*
214 * FW_BUG
215 * Add this to a message where you are sure the firmware is buggy or behaves
216 * really stupid or out of spec. Be aware that the responsible BIOS developer
217 * should be able to fix this issue or at least get a concrete idea of the
218 * problem by reading your message without the need of looking at the kernel
219 * code.
220 *
221 * Use it for definite and high priority BIOS bugs.
222 *
223 * FW_WARN
224 * Use it for not that clear (e.g. could the kernel messed up things already?)
225 * and medium priority BIOS bugs.
226 *
227 * FW_INFO
228 * Use this one if you want to tell the user or vendor about something
229 * suspicious, but generally harmless related to the firmware.
230 *
231 * Use it for information or very low priority BIOS bugs.
232 */
233#define FW_BUG "[Firmware Bug]: "
234#define FW_WARN "[Firmware Warn]: "
235#define FW_INFO "[Firmware Info]: "
236
237#ifdef CONFIG_PRINTK
238asmlinkage int vprintk(const char *fmt, va_list args)
239 __attribute__ ((format (printf, 1, 0)));
240asmlinkage int printk(const char * fmt, ...)
241 __attribute__ ((format (printf, 1, 2))) __cold;
242
243extern int __printk_ratelimit(const char *func);
244#define printk_ratelimit() __printk_ratelimit(__func__)
245extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
246 unsigned int interval_msec);
247
248extern int printk_delay_msec;
249
250/*
251 * Print a one-time message (analogous to WARN_ONCE() et al):
252 */
253#define printk_once(x...) ({ \
254 static bool __print_once; \
255 \
256 if (!__print_once) { \
257 __print_once = true; \
258 printk(x); \
259 } \
260})
261
262void log_buf_kexec_setup(void);
263#else
264static inline int vprintk(const char *s, va_list args)
265 __attribute__ ((format (printf, 1, 0)));
266static inline int vprintk(const char *s, va_list args) { return 0; }
267static inline int printk(const char *s, ...)
268 __attribute__ ((format (printf, 1, 2)));
269static inline int __cold printk(const char *s, ...) { return 0; }
270static inline int printk_ratelimit(void) { return 0; }
271static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \
272 unsigned int interval_msec) \
273 { return false; }
274
275/* No effect, but we still get type checking even in the !PRINTK case: */
276#define printk_once(x...) printk(x)
277
278static inline void log_buf_kexec_setup(void)
279{
280}
281#endif
282
283extern int printk_needs_cpu(int cpu);
284extern void printk_tick(void);
285
286extern void asmlinkage __attribute__((format(printf, 1, 2)))
287 early_printk(const char *fmt, ...);
288
289unsigned long int_sqrt(unsigned long); 231unsigned long int_sqrt(unsigned long);
290 232
291static inline void console_silent(void)
292{
293 console_loglevel = 0;
294}
295
296static inline void console_verbose(void)
297{
298 if (console_loglevel)
299 console_loglevel = 15;
300}
301
302extern void bust_spinlocks(int yes); 233extern void bust_spinlocks(int yes);
303extern void wake_up_klogd(void); 234extern void wake_up_klogd(void);
304extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ 235extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */
@@ -333,22 +264,7 @@ extern enum system_states {
333#define TAINT_OVERRIDDEN_ACPI_TABLE 8 264#define TAINT_OVERRIDDEN_ACPI_TABLE 8
334#define TAINT_WARN 9 265#define TAINT_WARN 9
335#define TAINT_CRAP 10 266#define TAINT_CRAP 10
336 267#define TAINT_FIRMWARE_WORKAROUND 11
337extern void dump_stack(void) __cold;
338
339enum {
340 DUMP_PREFIX_NONE,
341 DUMP_PREFIX_ADDRESS,
342 DUMP_PREFIX_OFFSET
343};
344extern void hex_dump_to_buffer(const void *buf, size_t len,
345 int rowsize, int groupsize,
346 char *linebuf, size_t linebuflen, bool ascii);
347extern void print_hex_dump(const char *level, const char *prefix_str,
348 int prefix_type, int rowsize, int groupsize,
349 const void *buf, size_t len, bool ascii);
350extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
351 const void *buf, size_t len);
352 268
353extern const char hex_asc[]; 269extern const char hex_asc[];
354#define hex_asc_lo(x) hex_asc[((x) & 0x0f)] 270#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
@@ -361,92 +277,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
361 return buf; 277 return buf;
362} 278}
363 279
364#ifndef pr_fmt 280extern int hex_to_bin(char ch);
365#define pr_fmt(fmt) fmt 281extern void hex2bin(u8 *dst, const char *src, size_t count);
366#endif
367
368#define pr_emerg(fmt, ...) \
369 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
370#define pr_alert(fmt, ...) \
371 printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
372#define pr_crit(fmt, ...) \
373 printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
374#define pr_err(fmt, ...) \
375 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
376#define pr_warning(fmt, ...) \
377 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
378#define pr_notice(fmt, ...) \
379 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
380#define pr_info(fmt, ...) \
381 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
382#define pr_cont(fmt, ...) \
383 printk(KERN_CONT fmt, ##__VA_ARGS__)
384
385/* pr_devel() should produce zero code unless DEBUG is defined */
386#ifdef DEBUG
387#define pr_devel(fmt, ...) \
388 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
389#else
390#define pr_devel(fmt, ...) \
391 ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
392#endif
393
394/* If you are writing a driver, please use dev_dbg instead */
395#if defined(DEBUG)
396#define pr_debug(fmt, ...) \
397 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
398#elif defined(CONFIG_DYNAMIC_DEBUG)
399/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
400#define pr_debug(fmt, ...) \
401 dynamic_pr_debug(fmt, ##__VA_ARGS__)
402#else
403#define pr_debug(fmt, ...) \
404 ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
405#endif
406
407/*
408 * ratelimited messages with local ratelimit_state,
409 * no local ratelimit_state used in the !PRINTK case
410 */
411#ifdef CONFIG_PRINTK
412#define printk_ratelimited(fmt, ...) ({ \
413 static struct ratelimit_state _rs = { \
414 .interval = DEFAULT_RATELIMIT_INTERVAL, \
415 .burst = DEFAULT_RATELIMIT_BURST, \
416 }; \
417 \
418 if (!__ratelimit(&_rs)) \
419 printk(fmt, ##__VA_ARGS__); \
420})
421#else
422/* No effect, but we still get type checking even in the !PRINTK case: */
423#define printk_ratelimited printk
424#endif
425
426#define pr_emerg_ratelimited(fmt, ...) \
427 printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
428#define pr_alert_ratelimited(fmt, ...) \
429 printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
430#define pr_crit_ratelimited(fmt, ...) \
431 printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
432#define pr_err_ratelimited(fmt, ...) \
433 printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
434#define pr_warning_ratelimited(fmt, ...) \
435 printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
436#define pr_notice_ratelimited(fmt, ...) \
437 printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
438#define pr_info_ratelimited(fmt, ...) \
439 printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
440/* no pr_cont_ratelimited, don't do that... */
441/* If you are writing a driver, please use dev_dbg instead */
442#if defined(DEBUG)
443#define pr_debug_ratelimited(fmt, ...) \
444 printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
445#else
446#define pr_debug_ratelimited(fmt, ...) \
447 ({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \
448 ##__VA_ARGS__); 0; })
449#endif
450 282
451/* 283/*
452 * General tracing related utility functions - trace_printk(), 284 * General tracing related utility functions - trace_printk(),
@@ -479,14 +311,18 @@ static inline void tracing_off(void) { }
479static inline void tracing_off_permanent(void) { } 311static inline void tracing_off_permanent(void) { }
480static inline int tracing_is_on(void) { return 0; } 312static inline int tracing_is_on(void) { return 0; }
481#endif 313#endif
314
315enum ftrace_dump_mode {
316 DUMP_NONE,
317 DUMP_ALL,
318 DUMP_ORIG,
319};
320
482#ifdef CONFIG_TRACING 321#ifdef CONFIG_TRACING
483extern void tracing_start(void); 322extern void tracing_start(void);
484extern void tracing_stop(void); 323extern void tracing_stop(void);
485extern void ftrace_off_permanent(void); 324extern void ftrace_off_permanent(void);
486 325
487extern void
488ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
489
490static inline void __attribute__ ((format (printf, 1, 2))) 326static inline void __attribute__ ((format (printf, 1, 2)))
491____trace_printk_check_format(const char *fmt, ...) 327____trace_printk_check_format(const char *fmt, ...)
492{ 328{
@@ -560,10 +396,8 @@ __ftrace_vbprintk(unsigned long ip, const char *fmt, va_list ap);
560extern int 396extern int
561__ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); 397__ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap);
562 398
563extern void ftrace_dump(void); 399extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode);
564#else 400#else
565static inline void
566ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
567static inline int 401static inline int
568trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); 402trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
569 403
@@ -581,21 +415,10 @@ ftrace_vprintk(const char *fmt, va_list ap)
581{ 415{
582 return 0; 416 return 0;
583} 417}
584static inline void ftrace_dump(void) { } 418static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
585#endif /* CONFIG_TRACING */ 419#endif /* CONFIG_TRACING */
586 420
587/* 421/*
588 * Display an IP address in readable format.
589 */
590
591#define NIPQUAD(addr) \
592 ((unsigned char *)&addr)[0], \
593 ((unsigned char *)&addr)[1], \
594 ((unsigned char *)&addr)[2], \
595 ((unsigned char *)&addr)[3]
596#define NIPQUAD_FMT "%u.%u.%u.%u"
597
598/*
599 * min()/max()/clamp() macros that also do 422 * min()/max()/clamp() macros that also do
600 * strict type-checking.. See the 423 * strict type-checking.. See the
601 * "unnecessary" pointer comparison. 424 * "unnecessary" pointer comparison.
@@ -612,6 +435,34 @@ static inline void ftrace_dump(void) { }
612 (void) (&_max1 == &_max2); \ 435 (void) (&_max1 == &_max2); \
613 _max1 > _max2 ? _max1 : _max2; }) 436 _max1 > _max2 ? _max1 : _max2; })
614 437
438#define min3(x, y, z) ({ \
439 typeof(x) _min1 = (x); \
440 typeof(y) _min2 = (y); \
441 typeof(z) _min3 = (z); \
442 (void) (&_min1 == &_min2); \
443 (void) (&_min1 == &_min3); \
444 _min1 < _min2 ? (_min1 < _min3 ? _min1 : _min3) : \
445 (_min2 < _min3 ? _min2 : _min3); })
446
447#define max3(x, y, z) ({ \
448 typeof(x) _max1 = (x); \
449 typeof(y) _max2 = (y); \
450 typeof(z) _max3 = (z); \
451 (void) (&_max1 == &_max2); \
452 (void) (&_max1 == &_max3); \
453 _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \
454 (_max2 > _max3 ? _max2 : _max3); })
455
456/**
457 * min_not_zero - return the minimum that is _not_ zero, unless both are zero
458 * @x: value1
459 * @y: value2
460 */
461#define min_not_zero(x, y) ({ \
462 typeof(x) __x = (x); \
463 typeof(y) __y = (y); \
464 __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
465
615/** 466/**
616 * clamp - return a value clamped to a given range with strict typechecking 467 * clamp - return a value clamped to a given range with strict typechecking
617 * @val: current value 468 * @val: current value
@@ -704,12 +555,6 @@ extern int do_sysinfo(struct sysinfo *info);
704 555
705#endif /* __KERNEL__ */ 556#endif /* __KERNEL__ */
706 557
707#ifndef __EXPORTED_HEADERS__
708#ifndef __KERNEL__
709#warning Attempt to use kernel headers from user space, see http://kernelnewbies.org/KernelHeaders
710#endif /* __KERNEL__ */
711#endif /* __EXPORTED_HEADERS__ */
712
713#define SI_LOAD_SHIFT 16 558#define SI_LOAD_SHIFT 16
714struct sysinfo { 559struct sysinfo {
715 long uptime; /* Seconds since boot */ 560 long uptime; /* Seconds since boot */
@@ -755,6 +600,13 @@ struct sysinfo {
755#define NUMA_BUILD 0 600#define NUMA_BUILD 0
756#endif 601#endif
757 602
603/* This helps us avoid #ifdef CONFIG_COMPACTION */
604#ifdef CONFIG_COMPACTION
605#define COMPACTION_BUILD 1
606#else
607#define COMPACTION_BUILD 0
608#endif
609
758/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ 610/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
759#ifdef CONFIG_FTRACE_MCOUNT_RECORD 611#ifdef CONFIG_FTRACE_MCOUNT_RECORD
760# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD 612# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD