From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0061.outbound.protection.outlook.com [104.47.36.61]) by dpdk.org (Postfix) with ESMTP id 679565598 for ; Sun, 4 Dec 2016 11:09:04 +0100 (CET) Received: from BLUPR0301CA0020.namprd03.prod.outlook.com (10.162.113.158) by BY2PR0301MB0741.namprd03.prod.outlook.com (10.160.63.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.747.13; Sun, 4 Dec 2016 10:09:03 +0000 Received: from BY2FFO11OLC008.protection.gbl (2a01:111:f400:7c0c::140) by BLUPR0301CA0020.outlook.office365.com (2a01:111:e400:5259::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.761.9 via Frontend Transport; Sun, 4 Dec 2016 10:09:02 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) 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.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 BY2FFO11OLC008.mail.protection.outlook.com (10.1.14.255) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.734.4 via Frontend Transport; Sun, 4 Dec 2016 10:09:01 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:773; Count:10 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id uB4A8pK5019825; Sun, 4 Dec 2016 03:08:58 -0700 From: Shreyansh Jain To: CC: , , Jan Blunck , Jan Viktorin , Shreyansh Jain Date: Sun, 4 Dec 2016 15:41:16 +0530 Message-ID: <1480846288-2517-2-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480846288-2517-1-git-send-email-shreyansh.jain@nxp.com> References: <1480846288-2517-1-git-send-email-shreyansh.jain@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131253197419834531; (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)(336004)(339900001)(199003)(189002)(104016004)(50226002)(39380400001)(5003940100001)(81156014)(76176999)(39400400001)(189998001)(38730400001)(86362001)(36756003)(50986999)(39410400001)(47776003)(8936002)(8666005)(81166006)(8676002)(356003)(68736007)(110136003)(2351001)(6916009)(305945005)(92566002)(33646002)(2950100002)(6666003)(97736004)(7846002)(106466001)(69596002)(105606002)(5660300001)(50466002)(2906002)(626004)(77096006)(4326007)(85426001)(39450400002)(48376002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB0741; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC008; 1:N/jc4zUOYMMmhihmJxB7Ku6SWO0/hLfsqInmGNApugq34NTFbtTDxBdh8Uzp3B1nizHy1XaXei6Uo135L35WhMsuZHqQ7XhIex2Dr9NLp55GNtq/NDHF5FvR2bGqY8m7068BvaKDuE661jBDFJ8TFTZGWIckzQAZBjbuRhiVikLNniKrwux9Xi8vG/DNvJkMarPmiMfL6mkNFMDq4yHJ92kxog70qIGuAbFM6TKccumx1TA9sElD/1R1RtgYrzrnQ/qRxkEG7z1JcoB9qYAHtBu7hOJdvnh1XwMEot58ucHAKtCO10zi8EdDM1/KS1T7NrN2uoQe6oaNQZtW4fkxsGPfAkjcqRySE0+URRMkJ2DjGTyutkkxKC7hnBbzj/I2cpkp4TVI6ZXqWC8Xn9SrEiNqkiWZ8czo64d7ktxPlKUGJ+CBifnRfPrDO+KU+5ilXXt6uGzOxPQEL9mhOFYNpLTAfp25VNMyAm12QuIF1wCQRIs4PMYvWyI09xRCJ+CMnH+QsFk+7qyGXUPHq02XHKFNDc4dXUmNDtuEo3KCWt9ISdXqFQ0BMqemGDD5/95Y/KsWkoQwlIlDXR3AGkB7QDr/Pgd22+icuvW5/LxlRpNrkUFM35Ngv7IioE9T1O3l/DqfebVPXymw8w56cWUTKVjOJxfXrlD2+rmLjOMDNeJkWDTjbFXXdi2V/6o90wvH4uAiyPcNnc+p2eqOgh0S2jndwSrScztvmUbHFxh/px0= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 4d5af448-bbde-4814-eca3-08d41c2d924e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BY2PR0301MB0741; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0741; 3:OYdm0j5wllMfmuJBbMreqZ8DSKcYd2MMplaadLdJUXZIB4B0a5HYzY9fu5hpkREJDT1txaiKdOh4jtVmMFmrvi5hwwR5Q+zhLt19PTsm49p+1HBLEObAMo/UFRcpQ5d4OQymdQBj3CbjpVsn69fiZqjsOkcPtprxzvglR4UoFbMPhO+48saqxd14jj1njikaKGSZMRi2o3xrXKeSl9tuFWsb1A907vMJkctZs/puLVo2LgFD8v7jZpjCw1Q36bA226DjLdhg3xC/DF4P9xR/z2GLzRCQflhZtTiag6J5+cTh12OU0hsJFHF+TG0UXyi/Mj12LWaL1HJXlhEJasptnhZ4TZ6zmiSD/LfBbA4oilBKlX/2Wv5HGz0DCFi24W70 X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0741; 25:xqfAoz11rWNYxjje0COfsSdvR9rHEX4vtSqDNuX+rVQ3Q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mgzZuidfXxYruF/4ry4K/FGsRdM= 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)(13017025)(13015025)(13023025)(13024025)(13018025)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6096035)(20161123561025)(20161123559025)(20161123556025)(20161123563025)(20161123565025); SRVR:BY2PR0301MB0741; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR0301MB0741; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0741; 4:bif3DSgj7pUHM37zJP9tOredGoqGaOc+mvHgzYUURlTRh4AAreXMtozK5u5OMzmopGEr+Iey6fc7FsAVmU70Ec/xUIW0T9rjcZA4P20QNM6YoZWhF0BozP1JHosQ1/d1tkjdJM3z4Zjii9fweNveku2syP27KYecXIh4yPi3dq/UA6GFMEY8kcUIVidx5pGNuJaEjCQJd+ONSbpZ91J18SytcwjOs0TTBJQKByyYDVx0/UAeaLzIdSwbD9mrk5K8r5EYxhsI+e08iC0fWc+s9jxjuvw3fcO6x67Ttc7M1MrZ7hKF2v5S4URAqZUjVeh+YeSTDOPLPbwhWgvLE+pxQ7uhkPgCkb0cyzXHxglGVA82IC2dWC3L+0FzQGuZ4lfc/eF9MGJfbZdkLGoEfC74SERnBA4PEXKCPwy2CkkN+x/A2LCrADAPPoNn8waZVsUzNdeO3ixgUFYZIlYZdKYal9lbFGHlGWNkr2JK7FI7a4Y1c7mQrMckZQGfZ2AMmjM3aTFapD/vXsXBnjOzEc05UnYdyBBQNO37UhDnlkCYTrkpeyNRrcns41kihuIW8e2JoliLM67ngscWw0FrkDEeAUbNAJgV+WJFQAE6nUGN4cWZTNsNSbSdwaQIzAznEjUIKf2OtJ8TS9MyK9HQ82B8Ha17EgkaF1LNs1Hmz8BYo5mzpn8McfIZ8RiKnGQIUZ1Wr1zfu/vJ8gTak90QPVtt5XU/cwcJZvg2P4nq68vsZVESWiD6IXKroykzlJkwYT6T X-Forefront-PRVS: 014617085B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0301MB0741; 23:QjBrTewFRPf31zYLbWu8mH2F4zML8jHIQI4uOBb?= =?us-ascii?Q?dsX0xM+ATFVUa/mfkKtNsXBap/RxdwKL18i3xoW8H3z/hgXojZAZirizeU1p?= =?us-ascii?Q?DjBcNThnl8RrOSA4bjM3Zo+7JW4VFV6Whir3jnXq+VTtaaSziUZTiQgiK5MD?= =?us-ascii?Q?qOnpZPebQkiVqihCx5IdPcFxBE8efMdT+F5GHlisRKf8PMCaCUTUQpEIU6mm?= =?us-ascii?Q?M2i46Pv8eHEPVh2UiMgkp7TN/emR/XDsf0dqJmad/flWTHRNPEyvCfEKK7MS?= =?us-ascii?Q?uulpejpIY2TRmngO9GPkFX2CW4QxQ/zyf25RjdFTX9OXkhpicNDCjwwbeLQr?= =?us-ascii?Q?ZgdpkxP6AbLYVWZQ8OdnTTy1dIsQ5pvnPcV6nWIxdVxrjn4JlF5FdJ442Rgf?= =?us-ascii?Q?2lyEH7kyElKDSNS0wGuDjHWQNb2OUnH/t28aaMLbb5OO1YIx6CTnXmeiSrvZ?= =?us-ascii?Q?0YgVc2zxjgFXbJWefYP6wLjWYRF1WsyhzNYHQYeSvoucYzh7UnsNWFHJQ5Dv?= =?us-ascii?Q?N4UIQas0hxqZ817Gn/bGB0P2V3a1ETp4rK4+Pa+B8o/my2xBqLgNCla3Axl+?= =?us-ascii?Q?3m3oM0oH9/LezNQtZYrVRlimz3RuVCcI/JKRN9+wJ1EaJmq+9dd6AZ2QvZx+?= =?us-ascii?Q?oGHMVhOCb3m1kOvw3NkPfV9G2xjERFbbJKU8Ofr5JCIrh65FVGlTo5RhsI3v?= =?us-ascii?Q?Q1PioZZ5t3H2+52gnpPS88O+SU2AhXcfOelZmCFE6saVJ2mutNOboLiidwLh?= =?us-ascii?Q?AypoAmtRPHW/MGpbu+EaLUDr0OQZfzgcHsdcS76K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APpyN+Q5GTWCMUCv+JG7169pIrtJRp6+vuAdrtylUf5xThcGnkhWMZxVM3Xs7ufjjVPEB/CF5NqrkxXuav1pmCi/P0+qk5bVPH5hnUwsKCBFCHmbZGn++ZewUtgLOT268oZJbIM9nYtTTlUC/5Y8LgUEia4qMYXPiUWerhCWdrmRt; 24:JBPnpo/izW7kNnTgMRYg6tzepbHAGzh0M5VgvuufBulH/ci08+XuMbz2jB4COwoGX7uzK4XYn1SNV1od1oiWIwQiegn53fMTff/jOdceg6k= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0741; 7:TESZz2DsI3grQF4Q5XPXdALthg8J30IQa3hpxn6xVzt91Jclnr9ala/YaVsLWeKoe9friwqcAgpqgAk8cseqgn8DzoKbfrqYggrO+qAApaU10/dD5nbR7MzfQ7WvI1lME1KrXeG2IZplEAO/dy0SOu+uGwHXdlpXQUI9Eya+BXFKMILs3zRlJpcRRg2Zsln5nhzl1cd7SuRm9IiLvJmnp2YWPChGJg4dJDteDat8ESPgABiYGzkZRlwq2qy0fmfOQ0JCb5xj8dQfTmAOSWiPnBcbWq8moIMp6yG0e8wsupPcyg499hXasAYldWeK4Xc+y/+ZeF8T4zB3DjfWHnqC3HzudZjztGMYbZ2SK2E4hdeJEEnNfm8Jov701jdBT6l/ErDHspd6LTsCaX0Ucg1j7IV81pySI829sJ6484pTGOXRo5MHwckV3WXsG4H5V10haHfSZDhfM5EyzoQOrpdClA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2016 10:09:01.5310 (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: BY2PR0301MB0741 Subject: [dpdk-dev] [PATCH 01/13] 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: Sun, 04 Dec 2016 10:09:05 -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