From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 2/7] API: Add macro for the container_of trick
Date: Tue, 27 Apr 2021 13:03:21 +0200 [thread overview]
Message-ID: <YIfveS/5sIwHP7FG@yuki> (raw)
In-Reply-To: <87o8e1m5zs.fsf@suse.de>
Hi!
> >> ---
> >> 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) ({ \
> >> + const typeof( ((type *)0)->member ) *__mptr = (ptr); \
> >> + (type *)( (char *)__mptr - offsetof(type,member) ); \
> >> +})
> >>
> >
> > I'd suggest defining it as uppercase 'TST_CONTAINER_OF(...)' to respect
> > other macro's naming policy in tst_common.h.
>
> I don't mind either way. I suspect it is lower case to match offsetof
> and maybe it is expected to become a compiler intrinsic. Perhaps we
> should remove the tst_. WDYT Cyril??
I think that it makes sense to use the same name as in the Linux kernel
since the macro is well known there. I would go just with container_of()
in this case.
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2021-04-27 11:03 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-12 14:54 [LTP] [PATCH v3 0/7] CGroup API rewrite Richard Palethorpe
2021-04-12 14:55 ` [LTP] [PATCH v3 1/7] API: Add safe openat, printfat, readat and unlinkat Richard Palethorpe
2021-04-16 6:59 ` Li Wang
2021-04-26 15:07 ` Richard Palethorpe
2021-04-12 14:55 ` [LTP] [PATCH v3 2/7] API: Add macro for the container_of trick Richard Palethorpe
2021-04-16 7:01 ` Li Wang
2021-04-26 15:15 ` Richard Palethorpe
2021-04-27 11:03 ` Cyril Hrubis [this message]
2021-04-12 14:55 ` [LTP] [PATCH v3 3/7] Add new CGroups APIs Richard Palethorpe
2021-04-14 15:39 ` Cyril Hrubis
2021-04-15 13:10 ` Richard Palethorpe
2021-04-16 5:00 ` Li Wang
2021-04-26 16:39 ` Richard Palethorpe
2021-04-16 6:57 ` Li Wang
2021-04-26 16:01 ` Richard Palethorpe
2021-04-12 14:55 ` [LTP] [PATCH v3 4/7] Add new CGroups API library tests Richard Palethorpe
2021-04-16 7:22 ` Li Wang
2021-04-12 14:55 ` [LTP] [PATCH v3 5/7] docs: Update CGroups API Richard Palethorpe
2021-04-16 8:11 ` Li Wang
2021-04-26 16:44 ` Richard Palethorpe
2021-04-12 14:55 ` [LTP] [PATCH v3 6/7] mem: Convert tests to new " Richard Palethorpe
2021-04-12 14:55 ` [LTP] [PATCH v3 7/7] madvise06: Convert " Richard Palethorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YIfveS/5sIwHP7FG@yuki \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox