kernel.h 584 B

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