diff options
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 2aa3d4b000e6..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,6 +206,25 @@ extern int _cond_resched(void); | |||
193 | (__x < 0) ? -__x : __x; \ | 206 | (__x < 0) ? -__x : __x; \ |
194 | }) | 207 | }) |
195 | 208 | ||
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 | |||
196 | #if defined(CONFIG_MMU) && \ | 228 | #if defined(CONFIG_MMU) && \ |
197 | (defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP)) | 229 | (defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP)) |
198 | void might_fault(void); | 230 | void might_fault(void); |