+namespace lttng {
+namespace utils {
+template <class ParentType, class MemberType>
+ParentType *container_of(const MemberType *member, const MemberType ParentType::*ptr_to_member)
+{
+ const ParentType *dummy_parent = nullptr;
+ auto *offset_of_member = reinterpret_cast<const char *>(&(dummy_parent->*ptr_to_member));
+ auto address_of_parent = reinterpret_cast<const char *>(member) - offset_of_member;
+
+ return reinterpret_cast<ParentType *>(address_of_parent);
+}
+} /* namespace utils */
+} /* namespace lttng */
+