summaryrefslogtreecommitdiffstats
path: root/include/c.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/c.h')
-rw-r--r--include/c.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/c.h b/include/c.h
index c4a95aa2b..073615ef3 100644
--- a/include/c.h
+++ b/include/c.h
@@ -104,6 +104,14 @@
_max1 > _max2 ? _max1 : _max2; })
#endif
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
+#define container_of(ptr, type, member) ({ \
+ const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+
#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
# ifdef HAVE___PROGNAME
extern char *__progname;