+namespace lttng {
+namespace utils {
+template <class Parent, class Member>
+Parent *container_of(const Member *member, const Member Parent::*ptr_to_member)
+{
+ const Parent *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<Parent *>(address_of_parent);
+}
+} /* namespace utils */
+} /* namespace lttng */
+