[syslinux:lwip] stddef.h: add container_of()

syslinux-bot for H. Peter Anvin hpa at zytor.com
Fri Apr 22 20:05:04 PDT 2011


Commit-ID:  40cf260af8496f44958216ae34807f2ea74c76e5
Gitweb:     http://syslinux.zytor.com/commit/40cf260af8496f44958216ae34807f2ea74c76e5
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Tue, 8 Sep 2009 21:05:24 -0700
Committer:  Eric W. Biederman <ebiederm at xmission.com>
CommitDate: Fri, 8 Apr 2011 14:38:11 -0700

stddef.h: add container_of()

Add the container_of() macro.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 com32/include/stddef.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/com32/include/stddef.h b/com32/include/stddef.h
index 125d235..f52d62f 100644
--- a/com32/include/stddef.h
+++ b/com32/include/stddef.h
@@ -21,4 +21,12 @@
 #undef offsetof
 #define offsetof(t,m) ((size_t)&((t *)0)->m)
 
+#undef container_of
+/*
+ * The container_of construct: if p is a pointer to member m of
+ * container class c, then return a pointer to the container of which
+ * *p is a member.
+ */
+#define container_of(p, c, m) ((c *)((char *)(p) - offsetof(c,m)))
+
 #endif /* _STDDEF_H */



More information about the Syslinux-commits mailing list