diff options
Diffstat (limited to 'include/linux/kernel.h')
| -rw-r--r-- | include/linux/kernel.h | 62 |
1 files changed, 21 insertions, 41 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 792bf0aa779..75d81f157d2 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | #include <linux/compiler.h> | 14 | #include <linux/compiler.h> |
| 15 | #include <linux/bitops.h> | 15 | #include <linux/bitops.h> |
| 16 | #include <linux/log2.h> | 16 | #include <linux/log2.h> |
| 17 | #include <linux/typecheck.h> | ||
| 18 | #include <linux/ratelimit.h> | ||
| 17 | #include <asm/byteorder.h> | 19 | #include <asm/byteorder.h> |
| 18 | #include <asm/bug.h> | 20 | #include <asm/bug.h> |
| 19 | 21 | ||
| @@ -46,6 +48,9 @@ extern const char linux_proc_banner[]; | |||
| 46 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) | 48 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) |
| 47 | #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) | 49 | #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) |
| 48 | 50 | ||
| 51 | #define _RET_IP_ (unsigned long)__builtin_return_address(0) | ||
| 52 | #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) | ||
| 53 | |||
| 49 | #ifdef CONFIG_LBD | 54 | #ifdef CONFIG_LBD |
| 50 | # include <asm/div64.h> | 55 | # include <asm/div64.h> |
| 51 | # define sector_div(a, b) do_div(a, b) | 56 | # define sector_div(a, b) do_div(a, b) |
| @@ -70,6 +75,12 @@ extern const char linux_proc_banner[]; | |||
| 70 | */ | 75 | */ |
| 71 | #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) | 76 | #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) |
| 72 | 77 | ||
| 78 | /** | ||
| 79 | * lower_32_bits - return bits 0-31 of a number | ||
| 80 | * @n: the number we're accessing | ||
| 81 | */ | ||
| 82 | #define lower_32_bits(n) ((u32)(n)) | ||
| 83 | |||
| 73 | #define KERN_EMERG "<0>" /* system is unusable */ | 84 | #define KERN_EMERG "<0>" /* system is unusable */ |
| 74 | #define KERN_ALERT "<1>" /* action must be taken immediately */ | 85 | #define KERN_ALERT "<1>" /* action must be taken immediately */ |
| 75 | #define KERN_CRIT "<2>" /* critical conditions */ | 86 | #define KERN_CRIT "<2>" /* critical conditions */ |
| @@ -97,6 +108,13 @@ struct completion; | |||
| 97 | struct pt_regs; | 108 | struct pt_regs; |
| 98 | struct user; | 109 | struct user; |
| 99 | 110 | ||
| 111 | #ifdef CONFIG_PREEMPT_VOLUNTARY | ||
| 112 | extern int _cond_resched(void); | ||
| 113 | # define might_resched() _cond_resched() | ||
| 114 | #else | ||
| 115 | # define might_resched() do { } while (0) | ||
| 116 | #endif | ||
| 117 | |||
| 100 | /** | 118 | /** |
| 101 | * might_sleep - annotation for functions that can sleep | 119 | * might_sleep - annotation for functions that can sleep |
| 102 | * | 120 | * |
| @@ -107,13 +125,6 @@ struct user; | |||
| 107 | * be bitten later when the calling function happens to sleep when it is not | 125 | * be bitten later when the calling function happens to sleep when it is not |
| 108 | * supposed to. | 126 | * supposed to. |
| 109 | */ | 127 | */ |
| 110 | #ifdef CONFIG_PREEMPT_VOLUNTARY | ||
| 111 | extern int _cond_resched(void); | ||
| 112 | # define might_resched() _cond_resched() | ||
| 113 | #else | ||
| 114 | # define might_resched() do { } while (0) | ||
| 115 | #endif | ||
| 116 | |||
| 117 | #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP | 128 | #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP |
| 118 | void __might_sleep(char *file, int line); | 129 | void __might_sleep(char *file, int line); |
| 119 | # define might_sleep() \ | 130 | # define might_sleep() \ |
| @@ -171,7 +182,7 @@ extern int vsscanf(const char *, const char *, va_list) | |||
| 171 | 182 | ||
| 172 | extern int get_option(char **str, int *pint); | 183 | extern int get_option(char **str, int *pint); |
| 173 | extern char *get_options(const char *str, int nints, int *ints); | 184 | extern char *get_options(const char *str, int nints, int *ints); |
| 174 | extern unsigned long long memparse(char *ptr, char **retptr); | 185 | extern unsigned long long memparse(const char *ptr, char **retptr); |
| 175 | 186 | ||
| 176 | extern int core_kernel_text(unsigned long addr); | 187 | extern int core_kernel_text(unsigned long addr); |
| 177 | extern int __kernel_text_address(unsigned long addr); | 188 | extern int __kernel_text_address(unsigned long addr); |
| @@ -184,15 +195,9 @@ asmlinkage int vprintk(const char *fmt, va_list args) | |||
| 184 | __attribute__ ((format (printf, 1, 0))); | 195 | __attribute__ ((format (printf, 1, 0))); |
| 185 | asmlinkage int printk(const char * fmt, ...) | 196 | asmlinkage int printk(const char * fmt, ...) |
| 186 | __attribute__ ((format (printf, 1, 2))) __cold; | 197 | __attribute__ ((format (printf, 1, 2))) __cold; |
| 187 | extern int log_buf_get_len(void); | ||
| 188 | extern int log_buf_read(int idx); | ||
| 189 | extern int log_buf_copy(char *dest, int idx, int len); | ||
| 190 | 198 | ||
| 191 | extern int printk_ratelimit_jiffies; | 199 | extern struct ratelimit_state printk_ratelimit_state; |
| 192 | extern int printk_ratelimit_burst; | ||
| 193 | extern int printk_ratelimit(void); | 200 | extern int printk_ratelimit(void); |
| 194 | extern int __ratelimit(int ratelimit_jiffies, int ratelimit_burst); | ||
| 195 | extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst); | ||
| 196 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, | 201 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, |
| 197 | unsigned int interval_msec); | 202 | unsigned int interval_msec); |
| 198 | #else | 203 | #else |
| @@ -202,18 +207,13 @@ static inline int vprintk(const char *s, va_list args) { return 0; } | |||
| 202 | static inline int printk(const char *s, ...) | 207 | static inline int printk(const char *s, ...) |
| 203 | __attribute__ ((format (printf, 1, 2))); | 208 | __attribute__ ((format (printf, 1, 2))); |
| 204 | static inline int __cold printk(const char *s, ...) { return 0; } | 209 | static inline int __cold printk(const char *s, ...) { return 0; } |
| 205 | static inline int log_buf_get_len(void) { return 0; } | ||
| 206 | static inline int log_buf_read(int idx) { return 0; } | ||
| 207 | static inline int log_buf_copy(char *dest, int idx, int len) { return 0; } | ||
| 208 | static inline int printk_ratelimit(void) { return 0; } | 210 | static inline int printk_ratelimit(void) { return 0; } |
| 209 | static inline int __printk_ratelimit(int ratelimit_jiffies, \ | ||
| 210 | int ratelimit_burst) { return 0; } | ||
| 211 | static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ | 211 | static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ |
| 212 | unsigned int interval_msec) \ | 212 | unsigned int interval_msec) \ |
| 213 | { return false; } | 213 | { return false; } |
| 214 | #endif | 214 | #endif |
| 215 | 215 | ||
| 216 | extern void __attribute__((format(printf, 1, 2))) | 216 | extern void asmlinkage __attribute__((format(printf, 1, 2))) |
| 217 | early_printk(const char *fmt, ...); | 217 | early_printk(const char *fmt, ...); |
| 218 | 218 | ||
| 219 | unsigned long int_sqrt(unsigned long); | 219 | unsigned long int_sqrt(unsigned long); |
| @@ -444,26 +444,6 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
| 444 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | 444 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
| 445 | (type *)( (char *)__mptr - offsetof(type,member) );}) | 445 | (type *)( (char *)__mptr - offsetof(type,member) );}) |
| 446 | 446 | ||
| 447 | /* | ||
| 448 | * Check at compile time that something is of a particular type. | ||
| 449 | * Always evaluates to 1 so you may use it easily in comparisons. | ||
| 450 | */ | ||
| 451 | #define typecheck(type,x) \ | ||
| 452 | ({ type __dummy; \ | ||
| 453 | typeof(x) __dummy2; \ | ||
| 454 | (void)(&__dummy == &__dummy2); \ | ||
| 455 | 1; \ | ||
| 456 | }) | ||
| 457 | |||
| 458 | /* | ||
| 459 | * Check at compile time that 'function' is a certain type, or is a pointer | ||
| 460 | * to that type (needs to use typedef for the function type.) | ||
| 461 | */ | ||
| 462 | #define typecheck_fn(type,function) \ | ||
| 463 | ({ typeof(type) __tmp = function; \ | ||
| 464 | (void)__tmp; \ | ||
| 465 | }) | ||
| 466 | |||
| 467 | struct sysinfo; | 447 | struct sysinfo; |
| 468 | extern int do_sysinfo(struct sysinfo *info); | 448 | extern int do_sysinfo(struct sysinfo *info); |
| 469 | 449 | ||
