diff options
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index edef168a0406..450092c1e35f 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -173,6 +173,11 @@ extern int _cond_resched(void); | |||
173 | (__x < 0) ? -__x : __x; \ | 173 | (__x < 0) ? -__x : __x; \ |
174 | }) | 174 | }) |
175 | 175 | ||
176 | #define abs64(x) ({ \ | ||
177 | s64 __x = (x); \ | ||
178 | (__x < 0) ? -__x : __x; \ | ||
179 | }) | ||
180 | |||
176 | #ifdef CONFIG_PROVE_LOCKING | 181 | #ifdef CONFIG_PROVE_LOCKING |
177 | void might_fault(void); | 182 | void might_fault(void); |
178 | #else | 183 | #else |
@@ -203,10 +208,10 @@ extern unsigned long simple_strtoul(const char *,char **,unsigned int); | |||
203 | extern long simple_strtol(const char *,char **,unsigned int); | 208 | extern long simple_strtol(const char *,char **,unsigned int); |
204 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); | 209 | extern unsigned long long simple_strtoull(const char *,char **,unsigned int); |
205 | extern long long simple_strtoll(const char *,char **,unsigned int); | 210 | extern long long simple_strtoll(const char *,char **,unsigned int); |
206 | extern int strict_strtoul(const char *, unsigned int, unsigned long *); | 211 | extern int __must_check strict_strtoul(const char *, unsigned int, unsigned long *); |
207 | extern int strict_strtol(const char *, unsigned int, long *); | 212 | extern int __must_check strict_strtol(const char *, unsigned int, long *); |
208 | extern int strict_strtoull(const char *, unsigned int, unsigned long long *); | 213 | extern int __must_check strict_strtoull(const char *, unsigned int, unsigned long long *); |
209 | extern int strict_strtoll(const char *, unsigned int, long long *); | 214 | extern int __must_check strict_strtoll(const char *, unsigned int, long long *); |
210 | extern int sprintf(char * buf, const char * fmt, ...) | 215 | extern int sprintf(char * buf, const char * fmt, ...) |
211 | __attribute__ ((format (printf, 2, 3))); | 216 | __attribute__ ((format (printf, 2, 3))); |
212 | extern int vsprintf(char *buf, const char *, va_list) | 217 | extern int vsprintf(char *buf, const char *, va_list) |
@@ -277,6 +282,11 @@ asmlinkage int vprintk(const char *fmt, va_list args) | |||
277 | asmlinkage int printk(const char * fmt, ...) | 282 | asmlinkage int printk(const char * fmt, ...) |
278 | __attribute__ ((format (printf, 1, 2))) __cold; | 283 | __attribute__ ((format (printf, 1, 2))) __cold; |
279 | 284 | ||
285 | /* | ||
286 | * Please don't use printk_ratelimit(), because it shares ratelimiting state | ||
287 | * with all other unrelated printk_ratelimit() callsites. Instead use | ||
288 | * printk_ratelimited() or plain old __ratelimit(). | ||
289 | */ | ||
280 | extern int __printk_ratelimit(const char *func); | 290 | extern int __printk_ratelimit(const char *func); |
281 | #define printk_ratelimit() __printk_ratelimit(__func__) | 291 | #define printk_ratelimit() __printk_ratelimit(__func__) |
282 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, | 292 | extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, |
@@ -651,6 +661,24 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
651 | (void) (&_max1 == &_max2); \ | 661 | (void) (&_max1 == &_max2); \ |
652 | _max1 > _max2 ? _max1 : _max2; }) | 662 | _max1 > _max2 ? _max1 : _max2; }) |
653 | 663 | ||
664 | #define min3(x, y, z) ({ \ | ||
665 | typeof(x) _min1 = (x); \ | ||
666 | typeof(y) _min2 = (y); \ | ||
667 | typeof(z) _min3 = (z); \ | ||
668 | (void) (&_min1 == &_min2); \ | ||
669 | (void) (&_min1 == &_min3); \ | ||
670 | _min1 < _min2 ? (_min1 < _min3 ? _min1 : _min3) : \ | ||
671 | (_min2 < _min3 ? _min2 : _min3); }) | ||
672 | |||
673 | #define max3(x, y, z) ({ \ | ||
674 | typeof(x) _max1 = (x); \ | ||
675 | typeof(y) _max2 = (y); \ | ||
676 | typeof(z) _max3 = (z); \ | ||
677 | (void) (&_max1 == &_max2); \ | ||
678 | (void) (&_max1 == &_max3); \ | ||
679 | _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \ | ||
680 | (_max2 > _max3 ? _max2 : _max3); }) | ||
681 | |||
654 | /** | 682 | /** |
655 | * min_not_zero - return the minimum that is _not_ zero, unless both are zero | 683 | * min_not_zero - return the minimum that is _not_ zero, unless both are zero |
656 | * @x: value1 | 684 | * @x: value1 |