From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0080.outbound.protection.outlook.com [104.47.34.80]) by dpdk.org (Postfix) with ESMTP id E0AEC5582 for ; Tue, 22 Nov 2016 11:01:49 +0100 (CET) Received: from BN6PR03CA0044.namprd03.prod.outlook.com (10.175.124.30) by BN6PR03MB2466.namprd03.prod.outlook.com (10.168.223.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.747.10; Tue, 22 Nov 2016 10:01:47 +0000 Received: from BN1AFFO11FD034.protection.gbl (2a01:111:f400:7c10::188) by BN6PR03CA0044.outlook.office365.com (2603:10b6:404:10c::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.734.8 via Frontend Transport; Tue, 22 Nov 2016 10:01:48 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; infradead.org; dkim=none (message not signed) header.d=none;infradead.org; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11FD034.mail.protection.outlook.com (10.58.52.158) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.734.4 via Frontend Transport; Tue, 22 Nov 2016 10:01:47 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:844; Count:13 Received: from [10.232.14.87] ([10.232.14.87]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id uAMA1hMU009964; Tue, 22 Nov 2016 03:01:44 -0700 To: Jan Blunck References: <1479747322-5774-1-git-send-email-jblunck@infradead.org> CC: , , Jan Viktorin From: Shreyansh Jain Message-ID: Date: Tue, 22 Nov 2016 15:33:58 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 MIME-Version: 1.0 In-Reply-To: <1479747322-5774-1-git-send-email-jblunck@infradead.org> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-IncomingHeaderCount: 13 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131242825077992825; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(336004)(377454003)(199003)(189002)(24454002)(104016004)(64126003)(47776003)(65806001)(356003)(68736007)(86362001)(50986999)(31696002)(76176999)(65956001)(54356999)(229853002)(626004)(33646002)(81156014)(38730400001)(4001350100001)(97736004)(8676002)(81166006)(105606002)(106466001)(110136003)(92566002)(23746002)(77096005)(50466002)(230700001)(6666003)(2950100002)(6916009)(87936001)(36756003)(5660300001)(305945005)(7846002)(85426001)(189998001)(8936002)(4326007)(65826007)(31686004)(69596002)(2906002)(83506001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2466; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD034; 1:jhbzKupKQn5eV6328Ae0zcbsbVzsVlA9MYrsYuRtvvZwCFB80dlSI4QoqWhwbqdLOfh8D2TjNOWJi5W5Cl1PkvZAp3mM3tMtHmD/UbFROho4oHY8CgV9Ak3UNWiwHc3gNeD+GoSu6zvv+m5zrZlV28vkd2kqE9wcL6tYwIzeWQj8GYYptAmL75VXI61W2nY66zVO6DdRdk4VCufEimS3p1Wx5aDiwPl+IfWUyR+tVuXhiStMsO8m3aveF4CA0u+g+1zaN8NEOrgIQb/lXNdWTcLKWvSrTjl8F1Jqc3RFHW3rrVrghsy6AoEx5L6kv3/DdkZFsMcghBGjOVhwclra2gRaKShcWugKnK8rmB8T9Jnv0bnTEm2n5HdkIWSEdmjA4fS2zpkS8IJniqDDKcpqRi5ZaVMpG7yY248oB7hSZ1gWI51izoMQWHZKfHs38fa/fsmUeUXUJ7LFOmA7anBSK+ipZVDqkxnHimZ47YbAoG0bvW5MJKxP6iF7PsgOFtfQ8xNgmlUGzdnyAX3TrNfGM6XtgFcyW61Qc/cPJ33lR6AcL4kiSZlYmCrmcK76+4UR3OGmKotWJWGuJb6LcWJf3KVp6CLfPuXOEf5a+V3rXio= X-MS-Office365-Filtering-Correlation-Id: 3098a486-3e1e-403b-4c17-08d412be928c X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BN6PR03MB2466; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2466; 3:e2VBxx4rQbtBoVJHXrDL5BBSflBq10wF0MlOXOlKaRkivoTZcM3slSBYJlwNV8xqbm4k50cONNj+B3xsFtc+gV/Fx8HX9iN8kLaCJKPq+Spt4ZpvptO8WDM7kOacD5mQ6098ywe876ITLSS1JXW0jsRX6s54EQe5yywgjZIggF1P59mvcB8ShC+TJ9U5ZRHskl2RWO6pBsoTqrDaMt/HJr4QPxU+fxz3QFYnhf5LAO5wOdt5omUH2qA4vuW/e1Hy8L3FCC4HM3KfNr9c+dL3cTArr/2Qqp0XKKiMJimUBTpYdvjX9Zw2Lhm9c+KC6odF62X/IFB3EhF6ln2Az6dqwJwxAmouz3Lk4RmsKYUhTb4= X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2466; 25:9SDj6db2eQ+6+JqUPfPmRjdjDuhX9F5LENHEWlGEyylD0frJi1wIThfDv6P3moUGjio4zOCMIkZMbQ2ARu/kP54xi1Krco/fxeADV86b2mqVaHgEU1Kzq0951YJZrgdC5qZ9+6F2/yDeE8lz2RwxdWLvchKvBZWj4xoeJGRstV4/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hrGZ7gnrzND6J+opoiJdtZKMJcAe+hwh+cTRZx91H31TjgpTV/4u7OIEjcnT+gkcPI5mVLxp03aST28f509411WEYGfodm+1ufNrxrHuac3HV9EhMsLdIOXFsdw+5bm2ERby9h4V1GJpNPWulHl3MyRANB1UnBM3SXcYBxkQps2KJHNx7bthGoE9NxIbIUkVC89pxJ3+zxibRDDdKVhFxq+tYLeEbR1k65nH3xeQTWzIbTPFSpeu+FzwVHoe/6sqOMkMMAU+jP5wfVuazTycAL/dQZCQL7Qz5AN9DJ/sdjds8bCFS2jZIwC75oVM7YpxN8hO2EFemkqgNi5KS3TxtMDRUy9im5NiGmkD0wNKtQpa3HPM6HN0xGFIJPBCdsvAsDJwUfvNmu//qJWkL3M592MBeBptbeNURZnA6nAxJuSWyS7kqUypAR96j+qH1lv/SWPR99VpNDHa4nqLNbPLQoPRr0b9ssJ7A== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095035)(601004)(2401047)(8121501046)(5005006)(13023025)(13024025)(13017025)(13018025)(13015025)(3002001)(10201501046)(6055026)(6096035); SRVR:BN6PR03MB2466; BCL:0; PCL:0; RULEID:(400006); SRVR:BN6PR03MB2466; X-Forefront-PRVS: 0134AD334F X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1; BN6PR03MB2466; 23:BekN9VlXuZ0YvDYSARtF9VsPgSBQzncO/fzqt?= =?Windows-1252?Q?CYswIAW5gD+1nCWxtwbjEAy6SE4/TZI4VAQ8QeorQ2+YPWaJ/FWzZRcd?= =?Windows-1252?Q?df75hSUetrVSEk9UWMMkyC8VwBWmwmyRnPJb6Ug0nG825d+NLzgEv/v8?= =?Windows-1252?Q?aGfe7vs3G3Gl9DKhcHuYaCraUbX1NqDBefqPt6ePf5AWobeAejHYgr/c?= =?Windows-1252?Q?ZSpinV6iRUMta6mjmJJ5RngFl1Sq1oRFlScCmsLzMP4BdqgBcHZToHaS?= =?Windows-1252?Q?6gLhkHN42XvoShU2p3PxxKvKqloBuU6RxbgFqZK5kEI/uf9A5830vFrD?= =?Windows-1252?Q?Ge8eNV0YSw3Jhit0+HN3SBNW75MhbP64koDZWN0A/XX1JOodcswNb/k6?= =?Windows-1252?Q?SjLUZwnNpO8bEheBCNoqIynxd1bsM1vaexgRd/GeSFYfFPm8vDUqC6bq?= =?Windows-1252?Q?qAf0bwSPVduNiFEdqAW8CDeFgeeG+q4ErKwcsR9ROBVRvq9sSJb5j22z?= =?Windows-1252?Q?FsKPzl2+sJ/D5Aqqu58VCcRmsnEdU55bu8eeHwvB5kY2DkXAKNA9/zdQ?= =?Windows-1252?Q?My3XvyTcALKMNcf6mQrzWlojr0AU9kMZR6GkK6SCAhdw1PYEyIThqrrz?= =?Windows-1252?Q?4lVOHuOvayXz1mx3aU35sSxD05rCANxLvCGcCEdOREyPC/XCh42g791a?= =?Windows-1252?Q?R8aG/Kfw5TExAQtmonifyH//eR0PQoxeKGzvyDkRAL1KiE3QupZO6Oxo?= =?Windows-1252?Q?1AD+kmQhnjtujngYqnowF2dqXOjYigXf+/KztVCgEiytFBOAiSma+vo0?= =?Windows-1252?Q?K9KqFGLpAjw4opxmaefURLvrqXXgjX45rtvwory8Vi2LO7u5NA/33kKt?= =?Windows-1252?Q?s8sLmtZB9fUr7g8Eg1OurGPk1kxoAv9LePgcV12kUBHThIbWpTpFbBFM?= =?Windows-1252?Q?ujS88i4rB/4nkRsGOh+rosabmOJvvmh6DDzLy1pOcDVM/iGmob/iWqTS?= =?Windows-1252?Q?WH10FzldlZlTbxNYeLd/4+n1Te5nVLVfVI8kV6rkPx0PI7afmhbXtQbN?= =?Windows-1252?Q?0bVqFHY3XGhpxpTVy2YQyqyf+J+UQnYEoo076NlpJ+IeHRYH2e/LLT9h?= =?Windows-1252?Q?KmxJI8jcjTlroAORYaueWNaZCEEbtBRWkrNhzlS3ed1xb1GuBN7JpWCW?= =?Windows-1252?Q?OO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WdmNK4BTY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2466; 7:O2oAa1Zf4UjsWBuB6nsuzBtXkrzSA9FJsL8gztuXNrnz+rHW9fl7BConOcKf9P9QYe8ioCJgasUjqSJyLI6jRnbhz3UYgjikP17rGPeUTKAgSjn5wsh5KDWc602X/wcuZWPHgrumInf67nI1oZu8i7vyBOTEJfnLvog/OK7pY+shsEDbFc/o1PoJCSnxm//q7h9SdCeg4QdMTi5pMfI4376CD5ipxQuutFaRRDrMLdBrOiER8iyXB9kel0ipkgRDVH3bMB8grKrWMLsY23zlVI16Z4AToE7zzu0EW5GZ89EYzK/zESUbQ9U52yx/hwwu76aad9GhbTVTCt8sPzs7uf132A04CRQlcIhumUZXStrKCxN5MFlb5hc6MFU+ODZDAZ6StfYDAwdkcpT8BtEv3NWT4o2yyVrQ1YZLNM+mHqHWGbDG7MOYrUoAJ5KHXHQi+WtyMIny3BFz5xD3tuUIpw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2016 10:01:47.5652 (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.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2466 Subject: Re: [dpdk-dev] [PATCH v2 1/8] eal: define container_of macro X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Nov 2016 10:01:50 -0000 On Monday 21 November 2016 10:25 PM, Jan Blunck wrote: > 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) > I will start using this in my patchset. Acked-by: Shreyansh Jain