aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h31
1 files changed, 27 insertions, 4 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 6002ae76785c..343df9ef2412 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -48,6 +48,12 @@ extern const char linux_proc_banner[];
48#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) 48#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
49#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) 49#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
50#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) 50#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
51#define DIV_ROUND_CLOSEST(x, divisor)( \
52{ \
53 typeof(divisor) __divisor = divisor; \
54 (((x) + ((__divisor) / 2)) / (__divisor)); \
55} \
56)
51 57
52#define _RET_IP_ (unsigned long)__builtin_return_address(0) 58#define _RET_IP_ (unsigned long)__builtin_return_address(0)
53#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) 59#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
@@ -141,6 +147,15 @@ extern int _cond_resched(void);
141 (__x < 0) ? -__x : __x; \ 147 (__x < 0) ? -__x : __x; \
142 }) 148 })
143 149
150#ifdef CONFIG_PROVE_LOCKING
151void might_fault(void);
152#else
153static inline void might_fault(void)
154{
155 might_sleep();
156}
157#endif
158
144extern struct atomic_notifier_head panic_notifier_list; 159extern struct atomic_notifier_head panic_notifier_list;
145extern long (*panic_blink)(long time); 160extern long (*panic_blink)(long time);
146NORET_TYPE void panic(const char * fmt, ...) 161NORET_TYPE void panic(const char * fmt, ...)
@@ -188,6 +203,8 @@ extern unsigned long long memparse(const char *ptr, char **retptr);
188extern int core_kernel_text(unsigned long addr); 203extern int core_kernel_text(unsigned long addr);
189extern int __kernel_text_address(unsigned long addr); 204extern int __kernel_text_address(unsigned long addr);
190extern int kernel_text_address(unsigned long addr); 205extern int kernel_text_address(unsigned long addr);
206extern int func_ptr_is_kernel_text(void *ptr);
207
191struct pid; 208struct pid;
192extern struct pid *session_of_pgrp(struct pid *pgrp); 209extern struct pid *session_of_pgrp(struct pid *pgrp);
193 210
@@ -338,13 +355,13 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
338 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) 355 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
339 356
340/* If you are writing a driver, please use dev_dbg instead */ 357/* If you are writing a driver, please use dev_dbg instead */
341#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG) 358#if defined(DEBUG)
359#define pr_debug(fmt, ...) \
360 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
361#elif defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
342#define pr_debug(fmt, ...) do { \ 362#define pr_debug(fmt, ...) do { \
343 dynamic_pr_debug(pr_fmt(fmt), ##__VA_ARGS__); \ 363 dynamic_pr_debug(pr_fmt(fmt), ##__VA_ARGS__); \
344 } while (0) 364 } while (0)
345#elif defined(DEBUG)
346#define pr_debug(fmt, ...) \
347 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
348#else 365#else
349#define pr_debug(fmt, ...) \ 366#define pr_debug(fmt, ...) \
350 ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) 367 ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
@@ -459,6 +476,12 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
459 __val = __val < __min ? __min: __val; \ 476 __val = __val < __min ? __min: __val; \
460 __val > __max ? __max: __val; }) 477 __val > __max ? __max: __val; })
461 478
479
480/*
481 * swap - swap value of @a and @b
482 */
483#define swap(a, b) ({ typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; })
484
462/** 485/**
463 * container_of - cast a member of a structure out to the containing structure 486 * container_of - cast a member of a structure out to the containing structure
464 * @ptr: the pointer to the member. 487 * @ptr: the pointer to the member.