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.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 7c4e8f1f72d8..d23123238534 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -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