at v2.6.31-rc3 21 lines 584 B view raw
1#ifndef PERF_LINUX_KERNEL_H_ 2#define PERF_LINUX_KERNEL_H_ 3 4#ifndef offsetof 5#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) 6#endif 7 8#ifndef container_of 9/** 10 * container_of - cast a member of a structure out to the containing structure 11 * @ptr: the pointer to the member. 12 * @type: the type of the container struct this is embedded in. 13 * @member: the name of the member within the struct. 14 * 15 */ 16#define container_of(ptr, type, member) ({ \ 17 const typeof(((type *)0)->member) * __mptr = (ptr); \ 18 (type *)((char *)__mptr - offsetof(type, member)); }) 19#endif 20 21#endif