From 4dfd88c2c814020559f18d62b15e680f3c7a9b35 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C5=99emysl=20Janouch?=
Date: Sat, 2 Jan 2016 03:24:35 +0100
Subject: [PATCH] Add a CONTAINER_OF macro
---
liberty.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/liberty.c b/liberty.c
index 977a2e9..e21b699 100644
--- a/liberty.c
+++ b/liberty.c
@@ -112,6 +112,9 @@ extern char **environ;
#define STRINGIFY(x) #x
#define XSTRINGIFY(x) STRINGIFY (x)
+#define CONTAINER_OF(pointer, type, member) \
+ ((type *) ((char *) pointer - offsetof (type, member)))
+
// --- Logging -----------------------------------------------------------------
static void