diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/asm-generic/vmlinux.lds.h | 7 | ||||
| -rw-r--r-- | include/linux/gfp.h | 2 | ||||
| -rw-r--r-- | include/linux/kernel.h | 32 | ||||
| -rw-r--r-- | include/linux/kmemcheck.h | 2 | ||||
| -rw-r--r-- | include/linux/module.h | 27 | ||||
| -rw-r--r-- | include/linux/moduleparam.h | 6 | ||||
| -rw-r--r-- | include/linux/virtio_config.h | 5 |
7 files changed, 70 insertions, 11 deletions
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 68649336c4ad..6ebb81030d2d 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
| @@ -364,6 +364,13 @@ | |||
| 364 | VMLINUX_SYMBOL(__start___param) = .; \ | 364 | VMLINUX_SYMBOL(__start___param) = .; \ |
| 365 | *(__param) \ | 365 | *(__param) \ |
| 366 | VMLINUX_SYMBOL(__stop___param) = .; \ | 366 | VMLINUX_SYMBOL(__stop___param) = .; \ |
| 367 | } \ | ||
| 368 | \ | ||
| 369 | /* Built-in module versions. */ \ | ||
| 370 | __modver : AT(ADDR(__modver) - LOAD_OFFSET) { \ | ||
| 371 | VMLINUX_SYMBOL(__start___modver) = .; \ | ||
| 372 | *(__modver) \ | ||
| 373 | VMLINUX_SYMBOL(__stop___modver) = .; \ | ||
| 367 | . = ALIGN((align)); \ | 374 | . = ALIGN((align)); \ |
| 368 | VMLINUX_SYMBOL(__end_rodata) = .; \ | 375 | VMLINUX_SYMBOL(__end_rodata) = .; \ |
| 369 | } \ | 376 | } \ |
diff --git a/include/linux/gfp.h b/include/linux/gfp.h index a3b148a91874..0b84c61607e8 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h | |||
| @@ -249,7 +249,7 @@ static inline enum zone_type gfp_zone(gfp_t flags) | |||
| 249 | ((1 << ZONES_SHIFT) - 1); | 249 | ((1 << ZONES_SHIFT) - 1); |
| 250 | 250 | ||
| 251 | if (__builtin_constant_p(bit)) | 251 | if (__builtin_constant_p(bit)) |
| 252 | MAYBE_BUILD_BUG_ON((GFP_ZONE_BAD >> bit) & 1); | 252 | BUILD_BUG_ON((GFP_ZONE_BAD >> bit) & 1); |
| 253 | else { | 253 | else { |
| 254 | #ifdef CONFIG_DEBUG_VM | 254 | #ifdef CONFIG_DEBUG_VM |
| 255 | BUG_ON((GFP_ZONE_BAD >> bit) & 1); | 255 | BUG_ON((GFP_ZONE_BAD >> bit) & 1); |
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index d07d8057e440..e2f4d6af2125 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
| @@ -575,12 +575,6 @@ struct sysinfo { | |||
| 575 | 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.. */ |
| 576 | }; | 576 | }; |
| 577 | 577 | ||
| 578 | /* Force a compilation error if condition is true */ | ||
| 579 | #define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition)) | ||
| 580 | |||
| 581 | /* Force a compilation error if condition is constant and true */ | ||
| 582 | #define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)])) | ||
| 583 | |||
| 584 | /* 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 */ |
| 585 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ | 579 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ |
| 586 | BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) | 580 | BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) |
| @@ -592,6 +586,32 @@ struct sysinfo { | |||
| 592 | #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) | 586 | #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) |
| 593 | #define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) | 587 | #define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) |
| 594 | 588 | ||
| 589 | /** | ||
| 590 | * BUILD_BUG_ON - break compile if a condition is true. | ||
| 591 | * @cond: 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 | ||
| 607 | extern 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 | |||
| 595 | /* Trap pasters of __FUNCTION__ at compile-time */ | 615 | /* Trap pasters of __FUNCTION__ at compile-time */ |
| 596 | #define __FUNCTION__ (__func__) | 616 | #define __FUNCTION__ (__func__) |
| 597 | 617 | ||
diff --git a/include/linux/kmemcheck.h b/include/linux/kmemcheck.h index 08d7dc4ddf40..39f8453239f7 100644 --- a/include/linux/kmemcheck.h +++ b/include/linux/kmemcheck.h | |||
| @@ -76,7 +76,7 @@ bool kmemcheck_is_obj_initialized(unsigned long addr, size_t size); | |||
| 76 | \ | 76 | \ |
| 77 | _n = (long) &((ptr)->name##_end) \ | 77 | _n = (long) &((ptr)->name##_end) \ |
| 78 | - (long) &((ptr)->name##_begin); \ | 78 | - (long) &((ptr)->name##_begin); \ |
| 79 | MAYBE_BUILD_BUG_ON(_n < 0); \ | 79 | BUILD_BUG_ON(_n < 0); \ |
| 80 | \ | 80 | \ |
| 81 | kmemcheck_mark_initialized(&((ptr)->name##_begin), _n); \ | 81 | kmemcheck_mark_initialized(&((ptr)->name##_begin), _n); \ |
| 82 | } while (0) | 82 | } while (0) |
diff --git a/include/linux/module.h b/include/linux/module.h index 8b17fd8c790d..e7c6385c6683 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
| @@ -58,6 +58,12 @@ struct module_attribute { | |||
| 58 | void (*free)(struct module *); | 58 | void (*free)(struct module *); |
| 59 | }; | 59 | }; |
| 60 | 60 | ||
| 61 | struct module_version_attribute { | ||
| 62 | struct module_attribute mattr; | ||
| 63 | const char *module_name; | ||
| 64 | const char *version; | ||
| 65 | }; | ||
| 66 | |||
| 61 | struct module_kobject | 67 | struct module_kobject |
| 62 | { | 68 | { |
| 63 | struct kobject kobj; | 69 | struct kobject kobj; |
| @@ -161,7 +167,28 @@ extern struct module __this_module; | |||
| 161 | Using this automatically adds a checksum of the .c files and the | 167 | Using this automatically adds a checksum of the .c files and the |
| 162 | local headers in "srcversion". | 168 | local headers in "srcversion". |
| 163 | */ | 169 | */ |
| 170 | |||
| 171 | #if defined(MODULE) || !defined(CONFIG_SYSFS) | ||
| 164 | #define MODULE_VERSION(_version) MODULE_INFO(version, _version) | 172 | #define MODULE_VERSION(_version) MODULE_INFO(version, _version) |
| 173 | #else | ||
| 174 | #define MODULE_VERSION(_version) \ | ||
| 175 | extern ssize_t __modver_version_show(struct module_attribute *, \ | ||
| 176 | struct module *, char *); \ | ||
| 177 | static struct module_version_attribute __modver_version_attr \ | ||
| 178 | __used \ | ||
| 179 | __attribute__ ((__section__ ("__modver"),aligned(sizeof(void *)))) \ | ||
| 180 | = { \ | ||
| 181 | .mattr = { \ | ||
| 182 | .attr = { \ | ||
| 183 | .name = "version", \ | ||
| 184 | .mode = S_IRUGO, \ | ||
| 185 | }, \ | ||
| 186 | .show = __modver_version_show, \ | ||
| 187 | }, \ | ||
| 188 | .module_name = KBUILD_MODNAME, \ | ||
| 189 | .version = _version, \ | ||
| 190 | } | ||
| 191 | #endif | ||
| 165 | 192 | ||
| 166 | /* Optional firmware file (or files) needed by the module | 193 | /* Optional firmware file (or files) needed by the module |
| 167 | * format is simply firmware file name. Multiple firmware | 194 | * format is simply firmware file name. Multiple firmware |
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 112adf8bd47d..07b41951e3fa 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h | |||
| @@ -16,15 +16,17 @@ | |||
| 16 | /* Chosen so that structs with an unsigned long line up. */ | 16 | /* Chosen so that structs with an unsigned long line up. */ |
| 17 | #define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long)) | 17 | #define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long)) |
| 18 | 18 | ||
| 19 | #ifdef MODULE | ||
| 20 | #define ___module_cat(a,b) __mod_ ## a ## b | 19 | #define ___module_cat(a,b) __mod_ ## a ## b |
| 21 | #define __module_cat(a,b) ___module_cat(a,b) | 20 | #define __module_cat(a,b) ___module_cat(a,b) |
| 21 | #ifdef MODULE | ||
| 22 | #define __MODULE_INFO(tag, name, info) \ | 22 | #define __MODULE_INFO(tag, name, info) \ |
| 23 | static const char __module_cat(name,__LINE__)[] \ | 23 | static const char __module_cat(name,__LINE__)[] \ |
| 24 | __used __attribute__((section(".modinfo"), unused, aligned(1))) \ | 24 | __used __attribute__((section(".modinfo"), unused, aligned(1))) \ |
| 25 | = __stringify(tag) "=" info | 25 | = __stringify(tag) "=" info |
| 26 | #else /* !MODULE */ | 26 | #else /* !MODULE */ |
| 27 | #define __MODULE_INFO(tag, name, info) | 27 | /* This struct is here for syntactic coherency, it is not used */ |
| 28 | #define __MODULE_INFO(tag, name, info) \ | ||
| 29 | struct __module_cat(name,__LINE__) {} | ||
| 28 | #endif | 30 | #endif |
| 29 | #define __MODULE_PARM_TYPE(name, _type) \ | 31 | #define __MODULE_PARM_TYPE(name, _type) \ |
| 30 | __MODULE_INFO(parmtype, name##type, #name ":" _type) | 32 | __MODULE_INFO(parmtype, name##type, #name ":" _type) |
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h index 0093dd7c1d6f..800617b4ddd5 100644 --- a/include/linux/virtio_config.h +++ b/include/linux/virtio_config.h | |||
| @@ -109,7 +109,10 @@ static inline bool virtio_has_feature(const struct virtio_device *vdev, | |||
| 109 | unsigned int fbit) | 109 | unsigned int fbit) |
| 110 | { | 110 | { |
| 111 | /* Did you forget to fix assumptions on max features? */ | 111 | /* Did you forget to fix assumptions on max features? */ |
| 112 | MAYBE_BUILD_BUG_ON(fbit >= 32); | 112 | if (__builtin_constant_p(fbit)) |
| 113 | BUILD_BUG_ON(fbit >= 32); | ||
| 114 | else | ||
| 115 | BUG_ON(fbit >= 32); | ||
| 113 | 116 | ||
| 114 | if (fbit < VIRTIO_TRANSPORT_F_START) | 117 | if (fbit < VIRTIO_TRANSPORT_F_START) |
| 115 | virtio_check_driver_offered_feature(vdev, fbit); | 118 | virtio_check_driver_offered_feature(vdev, fbit); |
