summaryrefslogtreecommitdiff
path: root/lib/zebra.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/zebra.h')
-rw-r--r--lib/zebra.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/zebra.h b/lib/zebra.h
index 98428eaab2..9ac96372ff 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -365,6 +365,22 @@ struct in_pktinfo {
_a < _b ? _a : _b; \
})
+#ifndef offsetof
+#ifdef __compiler_offsetof
+#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
+#else
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+#endif
+
+#ifndef container_of
+#define container_of(ptr, type, member) \
+ ({ \
+ const typeof(((type *)0)->member) *__mptr = (ptr); \
+ (type *)((char *)__mptr - offsetof(type, member)); \
+ })
+#endif
+
#define ZEBRA_NUM_OF(x) (sizeof (x) / sizeof (x[0]))
/* For old definition. */