Hi Michał,
On 04/02/2019 02:36 AM, Michał 'Khorne' Lowas-Rzechonek wrote:
From: Michał Lowas-Rzechonek
<michal.lowas-rzechonek(a)silvair.com>
The macro is useful when e.g. scheduling timeouts, where l_timeout
passed to l_timeout_notify_cb_t is a member of a larger object, and we
would like to access this object while passing something else as
user_data.
---
ell/util.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/ell/util.h b/ell/util.h
index c4ba7f8..95503de 100644
--- a/ell/util.h
+++ b/ell/util.h
@@ -35,6 +35,11 @@
extern "C" {
#endif
+#define l_container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) ); \
+ })
+
Is this a copy-paste of the container_of in private.h? If so, I'm fine
with this, but you might as well get rid of the one in private.h and
make the rest of ell use this one.
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
Regards,
-Denis