aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2012-03-26 11:18:44 -0400
committerIngo Molnar <mingo@kernel.org>2012-03-26 11:19:03 -0400
commit7fd52392c56361a40f0c630a82b36b95ca31eac6 (patch)
tree14091de24c6b28ea4cae9826f98aeedb7be091f5 /include/linux/kernel.h
parentb01c3a0010aabadf745f3e7fdb9cab682e0a28a2 (diff)
parente22057c8599373e5caef0bc42bdb95d2a361ab0d (diff)
Merge branch 'linus' into perf/urgent
Merge reason: we need to fix a non-trivial merge conflict. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h72
1 files changed, 6 insertions, 66 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 5582c7985567..92c10262d346 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -20,7 +20,6 @@
20#include <linux/printk.h> 20#include <linux/printk.h>
21#include <linux/dynamic_debug.h> 21#include <linux/dynamic_debug.h>
22#include <asm/byteorder.h> 22#include <asm/byteorder.h>
23#include <asm/bug.h>
24 23
25#define USHRT_MAX ((u16)(~0U)) 24#define USHRT_MAX ((u16)(~0U))
26#define SHRT_MAX ((s16)(USHRT_MAX>>1)) 25#define SHRT_MAX ((s16)(USHRT_MAX>>1))
@@ -312,6 +311,8 @@ extern long long simple_strtoll(const char *,char **,unsigned int);
312#define strict_strtoull kstrtoull 311#define strict_strtoull kstrtoull
313#define strict_strtoll kstrtoll 312#define strict_strtoll kstrtoll
314 313
314extern int num_to_str(char *buf, int size, unsigned long long num);
315
315/* lib/printf utilities */ 316/* lib/printf utilities */
316 317
317extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...); 318extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...);
@@ -328,10 +329,10 @@ extern __printf(2, 3)
328char *kasprintf(gfp_t gfp, const char *fmt, ...); 329char *kasprintf(gfp_t gfp, const char *fmt, ...);
329extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); 330extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args);
330 331
331extern int sscanf(const char *, const char *, ...) 332extern __scanf(2, 3)
332 __attribute__ ((format (scanf, 2, 3))); 333int sscanf(const char *, const char *, ...);
333extern int vsscanf(const char *, const char *, va_list) 334extern __scanf(2, 0)
334 __attribute__ ((format (scanf, 2, 0))); 335int vsscanf(const char *, const char *, va_list);
335 336
336extern int get_option(char **str, int *pint); 337extern int get_option(char **str, int *pint);
337extern char *get_options(const char *str, int nints, int *ints); 338extern char *get_options(const char *str, int nints, int *ints);
@@ -678,67 +679,6 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
678 const typeof( ((type *)0)->member ) *__mptr = (ptr); \ 679 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
679 (type *)( (char *)__mptr - offsetof(type,member) );}) 680 (type *)( (char *)__mptr - offsetof(type,member) );})
680 681
681#ifdef __CHECKER__
682#define BUILD_BUG_ON_NOT_POWER_OF_2(n)
683#define BUILD_BUG_ON_ZERO(e) (0)
684#define BUILD_BUG_ON_NULL(e) ((void*)0)
685#define BUILD_BUG_ON(condition)
686#define BUILD_BUG() (0)
687#else /* __CHECKER__ */
688
689/* Force a compilation error if a constant expression is not a power of 2 */
690#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \
691 BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
692
693/* Force a compilation error if condition is true, but also produce a
694 result (of value 0 and type size_t), so the expression can be used
695 e.g. in a structure initializer (or where-ever else comma expressions
696 aren't permitted). */
697#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
698#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
699
700/**
701 * BUILD_BUG_ON - break compile if a condition is true.
702 * @condition: the condition which the compiler should know is false.
703 *
704 * If you have some code which relies on certain constants being equal, or
705 * other compile-time-evaluated condition, you should use BUILD_BUG_ON to
706 * detect if someone changes it.
707 *
708 * The implementation uses gcc's reluctance to create a negative array, but
709 * gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments
710 * to inline functions). So as a fallback we use the optimizer; if it can't
711 * prove the condition is false, it will cause a link error on the undefined
712 * "__build_bug_on_failed". This error message can be harder to track down
713 * though, hence the two different methods.
714 */
715#ifndef __OPTIMIZE__
716#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
717#else
718extern int __build_bug_on_failed;
719#define BUILD_BUG_ON(condition) \
720 do { \
721 ((void)sizeof(char[1 - 2*!!(condition)])); \
722 if (condition) __build_bug_on_failed = 1; \
723 } while(0)
724#endif
725
726/**
727 * BUILD_BUG - break compile if used.
728 *
729 * If you have some code that you expect the compiler to eliminate at
730 * build time, you should use BUILD_BUG to detect if it is
731 * unexpectedly used.
732 */
733#define BUILD_BUG() \
734 do { \
735 extern void __build_bug_failed(void) \
736 __linktime_error("BUILD_BUG failed"); \
737 __build_bug_failed(); \
738 } while (0)
739
740#endif /* __CHECKER__ */
741
742/* Trap pasters of __FUNCTION__ at compile-time */ 682/* Trap pasters of __FUNCTION__ at compile-time */
743#define __FUNCTION__ (__func__) 683#define __FUNCTION__ (__func__)
744 684