aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-01-02 03:24:35 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2016-01-03 23:35:21 +0100
commit4dfd88c2c814020559f18d62b15e680f3c7a9b35 (patch)
treec5f97d2a17c58b6cf506e10d4d5f77db90a21163
parentb5724a654a4aadeabcfa3de3847768239931c687 (diff)
downloadliberty-4dfd88c2c814020559f18d62b15e680f3c7a9b35.tar.gz
liberty-4dfd88c2c814020559f18d62b15e680f3c7a9b35.tar.xz
liberty-4dfd88c2c814020559f18d62b15e680f3c7a9b35.zip
Add a CONTAINER_OF macro
-rw-r--r--liberty.c3
1 files changed, 3 insertions, 0 deletions
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