diff options
Diffstat (limited to 'include/linux/kernel.h')
| -rw-r--r-- | include/linux/kernel.h | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index b6de9a6f7018..5a9d9059520b 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
| @@ -56,6 +56,8 @@ | |||
| 56 | 56 | ||
| 57 | #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) | 57 | #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) |
| 58 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) | 58 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) |
| 59 | |||
| 60 | /* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */ | ||
| 59 | #define roundup(x, y) ( \ | 61 | #define roundup(x, y) ( \ |
| 60 | { \ | 62 | { \ |
| 61 | const typeof(y) __y = y; \ | 63 | const typeof(y) __y = y; \ |
| @@ -141,9 +143,22 @@ extern int _cond_resched(void); | |||
| 141 | 143 | ||
| 142 | #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) | 144 | #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) |
| 143 | 145 | ||
| 144 | #define abs(x) ({ \ | 146 | /* |
| 145 | long __x = (x); \ | 147 | * abs() handles unsigned and signed longs, ints, shorts and chars. For all |
| 146 | (__x < 0) ? -__x : __x; \ | 148 | * input types abs() returns a signed long. |
| 149 | * abs() should not be used for 64-bit types (s64, u64, long long) - use abs64() | ||
| 150 | * for those. | ||
| 151 | */ | ||
| 152 | #define abs(x) ({ \ | ||
| 153 | long ret; \ | ||
| 154 | if (sizeof(x) == sizeof(long)) { \ | ||
| 155 | long __x = (x); \ | ||
| 156 | ret = (__x < 0) ? -__x : __x; \ | ||
| 157 | } else { \ | ||
| 158 | int __x = (x); \ | ||
| 159 | ret = (__x < 0) ? -__x : __x; \ | ||
| 160 | } \ | ||
| 161 | ret; \ | ||
| 147 | }) | 162 | }) |
| 148 | 163 | ||
| 149 | #define abs64(x) ({ \ | 164 | #define abs64(x) ({ \ |
| @@ -263,6 +278,7 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
| 263 | } | 278 | } |
| 264 | 279 | ||
| 265 | extern int hex_to_bin(char ch); | 280 | extern int hex_to_bin(char ch); |
| 281 | extern void hex2bin(u8 *dst, const char *src, size_t count); | ||
| 266 | 282 | ||
| 267 | /* | 283 | /* |
| 268 | * General tracing related utility functions - trace_printk(), | 284 | * General tracing related utility functions - trace_printk(), |
| @@ -584,6 +600,13 @@ struct sysinfo { | |||
| 584 | #define NUMA_BUILD 0 | 600 | #define NUMA_BUILD 0 |
| 585 | #endif | 601 | #endif |
| 586 | 602 | ||
| 603 | /* This helps us avoid #ifdef CONFIG_COMPACTION */ | ||
| 604 | #ifdef CONFIG_COMPACTION | ||
| 605 | #define COMPACTION_BUILD 1 | ||
| 606 | #else | ||
| 607 | #define COMPACTION_BUILD 0 | ||
| 608 | #endif | ||
| 609 | |||
| 587 | /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ | 610 | /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ |
| 588 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD | 611 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD |
| 589 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD | 612 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD |
