diff options
Diffstat (limited to 'include/linux/kernel.h')
| -rw-r--r-- | include/linux/kernel.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 7c4e8f1f72d8..941dc0a5a877 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
| @@ -666,7 +666,7 @@ do { \ | |||
| 666 | * your code. (Extra memory is used for special buffers that are | 666 | * your code. (Extra memory is used for special buffers that are |
| 667 | * allocated when trace_printk() is used.) | 667 | * allocated when trace_printk() is used.) |
| 668 | * | 668 | * |
| 669 | * A little optization trick is done here. If there's only one | 669 | * A little optimization trick is done here. If there's only one |
| 670 | * argument, there's no need to scan the string for printf formats. | 670 | * argument, there's no need to scan the string for printf formats. |
| 671 | * The trace_puts() will suffice. But how can we take advantage of | 671 | * The trace_puts() will suffice. But how can we take advantage of |
| 672 | * using trace_puts() when trace_printk() has only one argument? | 672 | * using trace_puts() when trace_printk() has only one argument? |
| @@ -966,6 +966,22 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
| 966 | "pointer type mismatch in container_of()"); \ | 966 | "pointer type mismatch in container_of()"); \ |
| 967 | ((type *)(__mptr - offsetof(type, member))); }) | 967 | ((type *)(__mptr - offsetof(type, member))); }) |
| 968 | 968 | ||
| 969 | /** | ||
| 970 | * container_of_safe - cast a member of a structure out to the containing structure | ||
| 971 | * @ptr: the pointer to the member. | ||
| 972 | * @type: the type of the container struct this is embedded in. | ||
| 973 | * @member: the name of the member within the struct. | ||
| 974 | * | ||
| 975 | * If IS_ERR_OR_NULL(ptr), ptr is returned unchanged. | ||
| 976 | */ | ||
| 977 | #define container_of_safe(ptr, type, member) ({ \ | ||
| 978 | void *__mptr = (void *)(ptr); \ | ||
| 979 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ | ||
| 980 | !__same_type(*(ptr), void), \ | ||
| 981 | "pointer type mismatch in container_of()"); \ | ||
| 982 | IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) : \ | ||
| 983 | ((type *)(__mptr - offsetof(type, member))); }) | ||
| 984 | |||
| 969 | /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ | 985 | /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ |
| 970 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD | 986 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD |
| 971 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD | 987 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD |
