at v6.16 583 B view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef _TOOLS_LINUX_CONTAINER_OF_H 3#define _TOOLS_LINUX_CONTAINER_OF_H 4 5#ifndef container_of 6/** 7 * container_of - cast a member of a structure out to the containing structure 8 * @ptr: the pointer to the member. 9 * @type: the type of the container struct this is embedded in. 10 * @member: the name of the member within the struct. 11 * 12 */ 13#define container_of(ptr, type, member) ({ \ 14 const typeof(((type *)0)->member) * __mptr = (ptr); \ 15 (type *)((char *)__mptr - offsetof(type, member)); }) 16#endif 17 18#endif /* _TOOLS_LINUX_CONTAINER_OF_H */