Message ID | 20210302152510.15116-3-rpalethorpe@suse.com |
---|---|
State | Changes Requested |
Headers | show |
Series | CGroup API rewrite | expand |
On Tue, Mar 2, 2021 at 11:28 PM Richard Palethorpe <rpalethorpe@suse.com> wrote: > Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com> > --- > include/tst_common.h | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/include/tst_common.h b/include/tst_common.h > index fd7a900d4..317925d1d 100644 > --- a/include/tst_common.h > +++ b/include/tst_common.h > @@ -83,4 +83,9 @@ > #define TST_RES_SUPPORTS_TCONF_TFAIL_TINFO_TPASS_TWARN(condition) \ > TST_BUILD_BUG_ON(condition) > > +#define tst_container_of(ptr, type, member) ({ \ > What about using uppercase here? i.e TST_CONTAINER_OF(...) > + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ > + (type *)( (char *)__mptr - offsetof(type,member) ); \ > +}) > + > #endif /* TST_COMMON_H__ */ > -- > 2.30.0 > >
diff --git a/include/tst_common.h b/include/tst_common.h index fd7a900d4..317925d1d 100644 --- a/include/tst_common.h +++ b/include/tst_common.h @@ -83,4 +83,9 @@ #define TST_RES_SUPPORTS_TCONF_TFAIL_TINFO_TPASS_TWARN(condition) \ TST_BUILD_BUG_ON(condition) +#define tst_container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) ); \ +}) + #endif /* TST_COMMON_H__ */
Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com> --- include/tst_common.h | 5 +++++ 1 file changed, 5 insertions(+)