From: Chanwoo Choi Date: Mon, 24 Jan 2022 06:47:35 +0000 (+0900) Subject: util: common: Move container_of macro to common.h X-Git-Tag: submit/tizen/20220302.025412~54 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ab4e35fcaff02635e91c2f02a9f5ae2a509b22f0;p=platform%2Fcore%2Fsystem%2Fpass.git util: common: Move container_of macro to common.h Change-Id: I02fc5d60110132481719ded0d805dc88e12b9d2a Signed-off-by: Chanwoo Choi --- diff --git a/include/util/common.h b/include/util/common.h index d0f0100..40b75a3 100644 --- a/include/util/common.h +++ b/include/util/common.h @@ -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); diff --git a/src/pass/pass.h b/src/pass/pass.h index e7272cc..0b43ad6 100644 --- a/src/pass/pass.h +++ b/src/pass/pass.h @@ -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__ */