util: common: Move container_of macro to common.h 07/270007/3
authorChanwoo Choi <cw00.choi@samsung.com>
Mon, 24 Jan 2022 06:47:35 +0000 (15:47 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 24 Jan 2022 09:23:58 +0000 (18:23 +0900)
Change-Id: I02fc5d60110132481719ded0d805dc88e12b9d2a
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
include/util/common.h
src/pass/pass.h

index d0f0100cc0c0e5d07fa542abbe16820e44bd62d3..40b75a38af569b380076b211dbfd157dbced989a 100644 (file)
@@ -94,6 +94,12 @@ typedef unsigned long long uint64;
 #define USEC_TO_MSEC(x)                ((double)x/1000)
 #endif
 
+#ifndef container_of
+#define container_of(ptr, type, member) ({                     \
+       const typeof(((type *)0)->member) *__mptr = (ptr);      \
+       (type *)((char *)__mptr - offsetof(type, member)); })
+#endif
+
 int sys_get_str(const char *fname, char *str);
 
 const char *get_string_from_object(json_object *obj, const char *key);
index e7272ccd78f8725953b5aa7cf2d7380ad3c65a40..0b43ad6fa4abcd111d5428fbe48f3fe556b70588 100644 (file)
@@ -658,8 +658,4 @@ struct pass {
        struct pass_resource *res;
 };
 
-#define container_of(ptr, type, member) ({                     \
-       const typeof(((type *)0)->member) *__mptr = (ptr);      \
-       (type *)((char *)__mptr - offsetof(type, member)); })
-
 #endif /* __pass__ */