aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-09-08 21:05:24 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-09-08 21:09:46 -0700
commit91179071fb767ce93b4a44c373c749057a7a7afa (patch)
tree8e8e3064df361a92d007840a889658e83231e0da
parent36b86591d37cfe120f63ae27218264506750da51 (diff)
downloadlwip-91179071fb767ce93b4a44c373c749057a7a7afa.tar.gz
lwip-91179071fb767ce93b4a44c373c749057a7a7afa.tar.xz
lwip-91179071fb767ce93b4a44c373c749057a7a7afa.zip
stddef.h: add container_of()
Add the container_of() macro. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--com32/include/stddef.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/com32/include/stddef.h b/com32/include/stddef.h
index 125d2352..f52d62f3 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 */