From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0046.outbound.protection.outlook.com [104.47.41.46]) by dpdk.org (Postfix) with ESMTP id 1EB5E5584 for ; Fri, 16 Dec 2016 14:08:55 +0100 (CET) Received: from BN3PR0301CA0057.namprd03.prod.outlook.com (10.160.152.153) by CY1PR0301MB0748.namprd03.prod.outlook.com (10.160.159.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.771.8; Fri, 16 Dec 2016 13:08:55 +0000 Received: from BN1BFFO11FD042.protection.gbl (2a01:111:f400:7c10::1:188) by BN3PR0301CA0057.outlook.office365.com (2a01:111:e400:401e::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.771.8 via Frontend Transport; Fri, 16 Dec 2016 13:08:54 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com;nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD042.mail.protection.outlook.com (10.58.144.105) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.771.7 via Frontend Transport; Fri, 16 Dec 2016 13:08:53 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:890; Count:10 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id uBGD8BtC028345; Fri, 16 Dec 2016 06:08:48 -0700 From: Shreyansh Jain To: , CC: , , , Jan Blunck , Jan Viktorin , Shreyansh Jain Date: Fri, 16 Dec 2016 18:40:42 +0530 Message-ID: <1481893853-31790-2-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481893853-31790-1-git-send-email-shreyansh.jain@nxp.com> References: <1481636232-2300-1-git-send-email-shreyansh.jain@nxp.com> <1481893853-31790-1-git-send-email-shreyansh.jain@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131263673338599855; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(336005)(39410400002)(39450400003)(39400400002)(39850400002)(39860400002)(39380400002)(39840400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(5001770100001)(86362001)(50986999)(189998001)(4326007)(2906002)(626004)(76176999)(97736004)(47776003)(105606002)(106466001)(356003)(305945005)(104016004)(68736007)(77096006)(38730400001)(81156014)(8936002)(81166006)(48376002)(50466002)(6666003)(5003940100001)(8676002)(33646002)(2950100002)(36756003)(85426001)(92566002)(5660300001)(50226002)(8666005)(7059030)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB0748; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD042; 1:rGEyLS7/dcVTk8NB2xo+EGNEbtPpAHCHNYX9TvKkkuk5WiGl1kYoXHgG9Qf0BPSSHAxtFHty0lp7tf7gZL+IJt220ZYogxl41Fxd9GWqZfamqp5VDY3cA0eQGiKZLCB/ve2ZngHGl1kEHkAgsAJPU9Xr2S/PK6piq+I4lYHDkh4lDYwUU190EBZY+fHsJAsndFG6uqCNyAKb+bvJQAxy8QIFeEyu2C0F2tml/k93iHL4oTvz5Okz7RgE3T2j2hXzDi2BIH3svxTp+yCJlR3CJhMDwoE0V3ZFoeNRjeo9/8C0Wq5fSnFFjqI78usXJaCh5bpb4R+ws1rDx9sp1xM+0STFWT8apGtOyADl8lySEj+NCm6mzQQd9BvSndUaO12itojcIvTxRFdyK9LwtznsO4HRhWfuRuxyO35pFQE3az8qlhCRqHksqLUXI3ZOkWIQKCaPRCui1sFEAbXsCd1NRPOp1AA9mcgVvbhfCrkGRTHwmJ0aWBwJgVbRo/Sh1yvR5MAVPU3QC0PUzJhhp8VxRa3YFqNzWer4DukSv8UcgCfQlyGdUkOJ31law8ol+LGTtjE6AvtR7UqqBIeqrkIHTCavgMT6KNTdftPLwUMBfrP8DECCN2QtSaV98XxU1Tybs12NYLGiX44P3Isp6y4ePBRjmkTFlRdcPlV6dlbwSvZZB7hQufxMfEZw8gUoazI6hNR4mP+El2kvoebWd7DKGJTwyHgTQbHTGl0DpurOBFOtL71ugIiR1WsBoHFvy0lVjNLDWm430Mm8sTgfcBu/kg== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: ba15c4ce-9f0c-4df4-99af-08d425b4afb9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY1PR0301MB0748; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0748; 3:n9DRsfxf/lONxM//CuwcKQSe3iaXkte1+ku7OOdRkAL9xZN1wWAsCrUMYsZGgwie2+Aow9LCW8quiFWO/6xV90UNJd022HF+OPFY8UisRy1tZJ/LCdU7k2U0SeeyL3pBrfjZTbH5kkP52ESKJmHHRvYH0Me32ZlWttG+DzHjsRGIMUDzSbkSXGgYKDT5w7nfznofNh9y3ZWGwxcGfaPCNlgQFf2aJzfgFORI+vnaiJUy38PgAmXbqPXxZz7OSglZS22wO8V92a+DKbC17wW9MG6+Su6UtoJbbbeg6Tv/h2AwD1Pn/m+rg/KigycTVlNvP9PJy4wQhPvaSEDhIERanrogBlrkb1ka8XYJ8hr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tYqSS2l5Iees3N8N9aYM4dEwN00KRxr9I8bzrG9U+dt86iF8GT+uWDxzcWgaUJEaesvLfqvyh3g6aPcyzfuvSthJJsr/dk+voywy00NbFadKb2kZxzXmHlCBMVZN+JOEyQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(5005006)(13017025)(8121501046)(13023025)(13024025)(13018025)(13015025)(10201501046)(3002001)(6055026)(6096035)(20161123556025)(20161123559025)(20161123565025)(20161123561025)(20161123563025); SRVR:CY1PR0301MB0748; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB0748; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0748; 4:CGTHw6MWzcQa27Sq8JJ10jKTGKuM5QjX612VljnJhONnGX2Yp6SadStq7nvlej3r0B9v9lvFLR8Vz1hARgpfk/JoUHQ287kY/RuqZ8vsHWVEqX4XWVVXKT2RbKpbKKLva+7nqXJe+p7aDreUxSekGLIA5CWwdpLc9z5XXYmBQbm8dsKcL873GjfLXwK30wjN4GHnXWdY1Fw1YOJWZ0btc1RS/hsX5v17gAd/awG3YMoppOjuRZEnuvepuo1tmns5BvwwqJ6qeZLIP8jU19WkWckiDTi+3f+RGDxcogwjLNscFOL1mu2/rRTF5N/8aTbmt1EbiGcmV89ux/Mq+Wu6EgMplZV/xNsby7OWlufSGQiq2N7QzfMEffnH6MCo30SeFP8tKJMHhln3oUa4ZfKc1SsHW6FRW46Ff0ODgcckn8J7wgKRihBfgbLtTliY8owzWbxGYPHXGKz1+jv0MFfXHq7V73JrvwfHwZItzin9rUSoOGknEYuSrsyZLevbZLUYXLfBm3WFfn3N0R36FNDWBjl8WUQWUAgTAx1j1ZH20tFOpP9Cw6FKadwwiYlVcYhfvdpa0o2LGjnL1ju3EWsh+yb1oO1CbVU799D/RabO6SVXXqo+SouyaswBC3fGnC/H2O06wV8kFSMc0QX79IhAIBdZk84DefMVR625bRnevJ3jZF2se73LUGP/aqNBQmV1Z3OFxn2WbO65556tIbElJzWkFrjBHUHOzUO8XsXYHkabRSEBmPwbFn7az91AApHV X-Forefront-PRVS: 01583E185C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB0748; 23:pgs47Aejyclc3P3xcLwK03lx3hfobtMuxuahuAX?= =?us-ascii?Q?Wmcq0B1TbG9WplIFavgbfE6kTcFxY/i3CPDV8Gs054p+9u4eJUwULkbTzaha?= =?us-ascii?Q?IpA0M6MMiPXaKq37+OEb0Ytit0JWvnM+2M1oVSncTeyX3rXfDeihTJVdZ9eJ?= =?us-ascii?Q?hGpXXFH0m6Nt+fALJbsNWLUV3xP2pG2oA6pBZFDJL8XL7A8yrzra0b+bn5/v?= =?us-ascii?Q?rYNZPM0g1tSQDXdKlOQ7NIEAb/27J45u7MvmO7VJtcKAsCHtGVsyg+Z5LDes?= =?us-ascii?Q?WAEh+UqWg4+p6VhH3f0aub0QRgwDx30IehtR03XuDLCY7goJaDKsWMUMJfZg?= =?us-ascii?Q?ZlifzVfH4bVWz/rG9nylUoA++GuTC2az2Py5LmbstYBuX3KUiSY8/acju8n+?= =?us-ascii?Q?Pgwl9edvkh23vo/leFGQSKmazs5zF9yyMUK2G8msWtJ3+H2q/S6Lfe4Xy31D?= =?us-ascii?Q?gLxM1d8Rytj+XazFp441Hbvz96OJCr5Le7n5sjH+YUFf0Gq8GczLXeIjPfyo?= =?us-ascii?Q?HGn5j8aw5vpMsYuRnCqe2pzrBcedZ0/C0X47ubxhvMvZni84zj51xCZQVCBb?= =?us-ascii?Q?nyRjVpcxTgYcAB7EyJJiqaepzf2r1WTLo2ZuLFfyLNzJhlspb0yqVBOOpOwi?= =?us-ascii?Q?Pipx/uleoDyoiiqEEZQvul2g50Rx5D/Vl56xDb7ttZ/MI+A2WS0/cyi1AvS4?= =?us-ascii?Q?HyAb3PGZnF6Bw/P034k1yKltnMV2LZ+5B9GRr8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fFYzSOEMBkCYxos2EJdzp6c59xeF9y75kVzbNt3HDmZ/3xw1HzD+FYKUnW+Bq3rM9bMi1TSIVbS; 5:uhPCbTdn0j/gH37OAgSpro8xKyyvbgPGtOGMovJdCFJPSq4K3MC0xyqdwMQffu4WOLYrp5dnL93HtjR2jyzBjXoha3BOASaT4vsM0bZxR8BCVm7k71yxKsx78PauL6/LD/20FOqS7WQKjlP81p2oTGK79EyAQ7h8Nfq3JIQ/oFKHamoDa0ZQPuavdA+cCyLJ; 24:Pob8uZU4b9pp/7u1QEa2tsC2Dl6P/qt6FvNAcvVERJ6Mn4w9ghmX4FVog7k6Dlb+QYo3EhaQs6LbVSCY89fZ389C50Af3gqwNdHFBgS59cw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0748; 7:ShdIqXbnh3WVER2WNnTjfgmDIgBwzxZUTeC+gpD4sbH4zA+3lCy7Zki3TvCdcGMPYRHQqcRIBLfetkIeLnA2zEDydkPU1lX6/f6V5nZntw9B+7FYMFt0h/2vypQuBV9Yi93WK5To75ecDuF93LCOvteeZXC0yTotylPEvXcwMLiSZ8OdtF8jORd+B/PepSb4orI7oRcLWw744JYUUoqXDzO1Hw3ZJKEQWJ9m7xl4zp5P2rRsOAN51NWMpGmzX6RYQgeayzb/E/+nxQXyvURvpqF68Uj9oA2YvNITSjoLdiOcH0meE/6exzicYi2G3fd059jHZlkI7/QPPGwYiBHjnRm3Plsswn6J70A8RVyr3iWmenPR0BOUfIdSAm9h067w1fsFYvqkoOrzK/Nq0g08nxMbK1cCzf2j9bGzzEjJdO558GlbLLXCynCAqtAtfVFGDXDtcGzx80MI5uOajnIcPw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2016 13:08:53.6727 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0748 Subject: [dpdk-dev] [PATCH v3 01/12] eal: define container_of macro X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2016 13:08:56 -0000 From: Jan Blunck This macro is based on Jan Viktorin's original patch but also checks the type of the passed pointer against the type of the member. Signed-off-by: Jan Viktorin Signed-off-by: Shreyansh Jain [jblunck@infradead.org: add type checking and __extension__] Signed-off-by: Jan Blunck --- lib/librte_eal/common/include/rte_common.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index db5ac91..8dda3e2 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -331,6 +331,26 @@ rte_bsf32(uint32_t v) #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) #endif +/** + * Return pointer to the wrapping struct instance. + * + * Example: + * + * struct wrapper { + * ... + * struct child c; + * ... + * }; + * + * struct child *x = obtain(...); + * struct wrapper *w = container_of(x, struct wrapper, c); + */ +#ifndef container_of +#define container_of(ptr, type, member) __extension__ ({ \ + typeof(((type *)0)->member) *_ptr = (ptr); \ + (type *)(((char *)_ptr) - offsetof(type, member)); }) +#endif + #define _RTE_STR(x) #x /** Take a macro value and get a string version of it */ #define RTE_STR(x) _RTE_STR(x) -- 2.7.4