[Libwebsockets] [PATCH 1/3] add container_of() macro

Alejandro Mery amery at geeks.cl
Sun Dec 7 03:36:11 CET 2014


to be used to remove cast abuse and finding parent structs later

Signed-off-by: Alejandro Mery <amery at geeks.cl>
---
 lib/private-libwebsockets.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h
index c4550e9..de43ec4 100755
--- a/lib/private-libwebsockets.h
+++ b/lib/private-libwebsockets.h
@@ -209,6 +209,12 @@ typedef unsigned __int64 u_int64_t;
 #include <endian.h>
 #endif
 
+#include <stddef.h>
+
+#ifndef container_of
+#define container_of(P,T,M)	((T *)((char *)(P) - offsetof(T, M)))
+#endif
+
 #if defined(__QNX__)
 	#include <gulliver.h>
 	#if defined(__LITTLEENDIAN__)
-- 
2.2.0




More information about the Libwebsockets mailing list