Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Enumerations
bug.h File Reference
#include <asm/bug.h>

Go to the source code of this file.


#define BUILD_BUG_ON_NOT_POWER_OF_2(n)   BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
#define BUILD_BUG_ON_ZERO(e)   (sizeof(struct { int:-!!(e); }))
#define BUILD_BUG_ON_NULL(e)   ((void *)sizeof(struct { int:-!!(e); }))
#define BUILD_BUG_ON_INVALID(e)   ((void)(sizeof((__force long)(e))))
#define BUILD_BUG_ON(condition)   ((void)sizeof(char[1 - 2*!!(condition)]))
#define BUILD_BUG()


enum  bug_trap_type { BUG_TRAP_TYPE_NONE = 0, BUG_TRAP_TYPE_WARN = 1, BUG_TRAP_TYPE_BUG = 2 }

Macro Definition Documentation

#define BUILD_BUG ( )
do { \
extern void __build_bug_failed(void) \
__linktime_error("BUILD_BUG failed"); \
__build_bug_failed(); \
} while (0)

BUILD_BUG - break compile if used.

If you have some code that you expect the compiler to eliminate at build time, you should use BUILD_BUG to detect if it is unexpectedly used.

Definition at line 74 of file bug.h.

#define BUILD_BUG_ON (   condition)    ((void)sizeof(char[1 - 2*!!(condition)]))

BUILD_BUG_ON - break compile if a condition is true. : the condition which the compiler should know is false.

If you have some code which relies on certain constants being equal, or other compile-time-evaluated condition, you should use BUILD_BUG_ON to detect if someone changes it.

The implementation uses gcc's reluctance to create a negative array, but gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments to inline functions). So as a fallback we use the optimizer; if it can't prove the condition is false, it will cause a link error on the undefined "__build_bug_on_failed". This error message can be harder to track down though, hence the two different methods.

Definition at line 57 of file bug.h.

#define BUILD_BUG_ON_INVALID (   e)    ((void)(sizeof((__force long)(e))))

Definition at line 39 of file bug.h.

#define BUILD_BUG_ON_NOT_POWER_OF_2 (   n)    BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))

Definition at line 24 of file bug.h.

#define BUILD_BUG_ON_NULL (   e)    ((void *)sizeof(struct { int:-!!(e); }))

Definition at line 32 of file bug.h.

#define BUILD_BUG_ON_ZERO (   e)    (sizeof(struct { int:-!!(e); }))

Definition at line 31 of file bug.h.

Enumeration Type Documentation


Definition at line 6 of file bug.h.