summaryrefslogtreecommitdiffstats
path: root/lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib.h')
-rw-r--r--lib.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib.h b/lib.h
index 9e71b5f9..dc90aa23 100644
--- a/lib.h
+++ b/lib.h
@@ -46,6 +46,10 @@ typedef double_uintptr_t dbl_ucnum;
#define coerce(TYPE, EXPR) ((TYPE) (EXPR))
#endif
+#define container(PTR, TYPE, MEMB) \
+ convert(TYPE *, \
+ convert(mem_t *, (PTR)) - offsetof(TYPE, MEMB))
+
#if __STDC_VERSION__ >= 199901L
#define FLEX_ARRAY
#else