diff options
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index d4e98d13eff4..196d1ea86df0 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -29,6 +29,19 @@ | |||
29 | #define ULLONG_MAX (~0ULL) | 29 | #define ULLONG_MAX (~0ULL) |
30 | #define SIZE_MAX (~(size_t)0) | 30 | #define SIZE_MAX (~(size_t)0) |
31 | 31 | ||
32 | #define U8_MAX ((u8)~0U) | ||
33 | #define S8_MAX ((s8)(U8_MAX>>1)) | ||
34 | #define S8_MIN ((s8)(-S8_MAX - 1)) | ||
35 | #define U16_MAX ((u16)~0U) | ||
36 | #define S16_MAX ((s16)(U16_MAX>>1)) | ||
37 | #define S16_MIN ((s16)(-S16_MAX - 1)) | ||
38 | #define U32_MAX ((u32)~0U) | ||
39 | #define S32_MAX ((s32)(U32_MAX>>1)) | ||
40 | #define S32_MIN ((s32)(-S32_MAX - 1)) | ||
41 | #define U64_MAX ((u64)~0ULL) | ||
42 | #define S64_MAX ((s64)(U64_MAX>>1)) | ||
43 | #define S64_MIN ((s64)(-S64_MAX - 1)) | ||
44 | |||
32 | #define STACK_MAGIC 0xdeadbeef | 45 | #define STACK_MAGIC 0xdeadbeef |
33 | 46 | ||
34 | #define REPEAT_BYTE(x) ((~0ul / 0xff) * (x)) | 47 | #define REPEAT_BYTE(x) ((~0ul / 0xff) * (x)) |
@@ -193,7 +206,27 @@ extern int _cond_resched(void); | |||
193 | (__x < 0) ? -__x : __x; \ | 206 | (__x < 0) ? -__x : __x; \ |
194 | }) | 207 | }) |
195 | 208 | ||
196 | #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP) | 209 | /** |
210 | * reciprocal_scale - "scale" a value into range [0, ep_ro) | ||
211 | * @val: value | ||
212 | * @ep_ro: right open interval endpoint | ||
213 | * | ||
214 | * Perform a "reciprocal multiplication" in order to "scale" a value into | ||
215 | * range [0, ep_ro), where the upper interval endpoint is right-open. | ||
216 | * This is useful, e.g. for accessing a index of an array containing | ||
217 | * ep_ro elements, for example. Think of it as sort of modulus, only that | ||
218 | * the result isn't that of modulo. ;) Note that if initial input is a | ||
219 | * small value, then result will return 0. | ||
220 | * | ||
221 | * Return: a result based on val in interval [0, ep_ro). | ||
222 | */ | ||
223 | static inline u32 reciprocal_scale(u32 val, u32 ep_ro) | ||
224 | { | ||
225 | return (u32)(((u64) val * ep_ro) >> 32); | ||
226 | } | ||
227 | |||
228 | #if defined(CONFIG_MMU) && \ | ||
229 | (defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP)) | ||
197 | void might_fault(void); | 230 | void might_fault(void); |
198 | #else | 231 | #else |
199 | static inline void might_fault(void) { } | 232 | static inline void might_fault(void) { } |
@@ -393,6 +426,15 @@ extern int panic_on_oops; | |||
393 | extern int panic_on_unrecovered_nmi; | 426 | extern int panic_on_unrecovered_nmi; |
394 | extern int panic_on_io_nmi; | 427 | extern int panic_on_io_nmi; |
395 | extern int sysctl_panic_on_stackoverflow; | 428 | extern int sysctl_panic_on_stackoverflow; |
429 | /* | ||
430 | * Only to be used by arch init code. If the user over-wrote the default | ||
431 | * CONFIG_PANIC_TIMEOUT, honor it. | ||
432 | */ | ||
433 | static inline void set_arch_panic_timeout(int timeout, int arch_default_timeout) | ||
434 | { | ||
435 | if (panic_timeout == arch_default_timeout) | ||
436 | panic_timeout = timeout; | ||
437 | } | ||
396 | extern const char *print_tainted(void); | 438 | extern const char *print_tainted(void); |
397 | enum lockdep_ok { | 439 | enum lockdep_ok { |
398 | LOCKDEP_STILL_OK, | 440 | LOCKDEP_STILL_OK, |