From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0076.outbound.protection.outlook.com [104.47.32.76]) by dpdk.org (Postfix) with ESMTP id 9C2952C8 for ; Tue, 13 Dec 2016 14:34:42 +0100 (CET) Received: from DM2PR03CA0048.namprd03.prod.outlook.com (10.141.96.47) by CY1PR0301MB0746.namprd03.prod.outlook.com (10.160.159.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.771.8; Tue, 13 Dec 2016 13:34:41 +0000 Received: from BN1AFFO11FD048.protection.gbl (2a01:111:f400:7c10::194) by DM2PR03CA0048.outlook.office365.com (2a01:111:e400:2428::47) 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; Tue, 13 Dec 2016 13:34:41 +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 BN1AFFO11FD048.mail.protection.outlook.com (10.58.53.63) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.761.6 via Frontend Transport; Tue, 13 Dec 2016 13:34:41 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:887; 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 uBDDYRw5005048; Tue, 13 Dec 2016 06:34:36 -0700 From: Shreyansh Jain To: , CC: , , , Jan Blunck , Jan Viktorin , Shreyansh Jain Date: Tue, 13 Dec 2016 19:07:01 +0530 Message-ID: <1481636232-2300-2-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481636232-2300-1-git-send-email-shreyansh.jain@nxp.com> References: <1480846288-2517-1-git-send-email-shreyansh.jain@nxp.com> <1481636232-2300-1-git-send-email-shreyansh.jain@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131261096812797173; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(979002)(6009001)(336005)(7916002)(39450400003)(39380400002)(39410400002)(39860400002)(39850400002)(39400400002)(39840400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(47776003)(8936002)(8676002)(97736004)(5003940100001)(81166006)(33646002)(5001770100001)(81156014)(85426001)(626004)(5660300001)(106466001)(189998001)(4326007)(6666003)(105606002)(2950100002)(48376002)(86362001)(36756003)(76176999)(50986999)(2906002)(8666005)(356003)(38730400001)(50226002)(77096006)(104016004)(50466002)(68736007)(92566002)(305945005)(7059030)(2101003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB0746; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD048; 1:/kvOzdRQPRz2/X9RjXVNZDIO1g33DSCYeQyumeBK1P+SuflNdsiVKoL2cfT2Qmby4ZNhA3XUOAGre7nU0sA/2nv5H5yBq6IZPSWw3Opf3mNv6HfKkH6kOiZf4ZJOs5K60q3hRE8Kzd/olydWzC0gmOQeIZMuW2o8XZW2vDug6910ukFmFlw4F0sIETSabmqt0lJD8htw1jcA1//uBb8/QjHAeYcSWhMgYPu0bhPigXchhrBnxvrrarBvU4uSFEBukn3wJCCdJYmaGDLJn1XRK4KEPKt9jfbpH+ZtHOzfuU/+s1lcDC9QMem2APzeliA+zgamPo1FVVQfojmcecmzqjYGFY1cG6HVwDWcjnI8EkINy3WJJXyekv6JxKCsZ8cUEmpKq1XY8sbmRkLuv5hkFS7iRK7/aOwBtTBqIypa66dW5FlQh0sGKHF5qSChiHnrrI6K3jkxULZlMc6tt5LkEBcDgXkCIfktEpA5kJabW+Oxyo6Ml0ZChIMYRyCsBSePO3Qs9e8Eoi7tDs2apBBxV9YnTL5XhXo2BCXyuYJXY2syzcotEjhxYlLrghSbG39Is1Ajq2F6l6vSPeHLjBnt2NoWjudLjXkjLr6dHt2VKLhX8VEg0ItUNhxqb6pNL8XU4jKVnmIktESG8xzW0yZYZGKyzNa57e1/tUUJtYiJ1PTmQViP1F0jPyRDMkQ+FCuf6rhlQufOOC6KFNmREer38zhdwymfko37PprM28PUXiowq3/A1MwIJcSzIZ60iDBylcvIoFqua+2BbEdZcR7IRg== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 61f9f157-5966-49fd-7b96-08d4235ccacf X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY1PR0301MB0746; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0746; 3:HqtUQcl6G2ZgZV0MS8X3ckvVpNKxITax/tMMqfoW8IwCDj6gryUhN7ajZrs/2L6fpxarYyXsEmORm951MHNykXRh+Pz2uIiCFAQdROldqHlT1zORb7+kZnkOtpFo1Htcd1RuFtGsyNDhKx1/9dYo5juDL7qYF4w/iq/RB21dF/uxC5FuIgq2ZfT6+vwr6oueIq2tmIlJRBnrZymgCjmfjtur97Jfb2SY2zuy29bNqiR7b4lXfK2IrB40NjpZO7QDSJpvkKXKJ1Idy7NyaEFJksomfpLA3f6ClhO+GT8gjAzv+ApICl8IUpCAvHiyU3SaQG7Cw42KsId+00jYTGncCl8VKhptaJsZr05DffAsg9pHZnefmCwVhPq3Qj5t6asA X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0746; 25:96Kx3j3VWNrZBLhdPP7W9WIZzunmJP6iCB9yt2gjfLskRvlYBUC9Ygsuf3tUpb3EOzHspahfa3bbWg23seBBewQO/Gbrm9mTwzjlVHREfSviFeNr4ZPhkd+J2+KiaTOnkygKq3ywh/A3+YGB9MCIM4FQeN5aGWoeQtygrOrdYO92JzlV+q9iSGgWgxVv9XNDiu5QX30tGKqOwagUKGOG/jPf1sDftUBO9YK53jC7v9+p/mwJJDucUPB0AQDO9MM1VoHTfpQkyFUY5WPBpp/TgFiEmxMOuGPP4X/JX2ioygSUETspToPHI59fWMdzYF8TsjBw/IIOEKKZLoVR8iSuP9zTm0l5vekKtK2tgzGm6t8opMAPayh+T1xeRW5cHiR8/dtZS9+9jbZG4KoxWZGUJupYQS6JgLfRYHFaPVemTDNxu57YbSEWB08BlRjka+1tDhaMCSDTWZkP+OTThTxZzmDZRxbc9wpmmAgLHVcqK4K90lXKHjBaUNf1CZ1APEdmxRHTChWE3xuPmeX90lvHg15QWAv5v1NpglzsFzENQmr300aqIuUCtyQAcfmKH4zNDsfw8pAJ11BSZG/60v+bJcNwxmZsKLo21q/ZcUjk0RheIfxC+/szToaS7z2aDDdJ2ZWFWUJw3gYrqBb/kmyw3kvnXEKZTuzJfHmDHjclAiabkXLVrjhwelv5C8vrW8yM/TTj/CUMOL50AVfJaQqw65TGEcKuU4rY4htUuHBIDytRT6X2sayK4nNkt938fXINS7Xna4bUTuLsMj+MYTubrA== X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0746; 31:/1cNtGzxUydrSTbOyzRMZjL637cnTs+2fLSboAUKWmE9vk4fe+F0w3qu4vTKMwx56bdMgr6jf6lUZ+SfevnqprPhkrguV3og4Pfp+rwcLNei8kUepmCOT+ntD5NxZDjNtvfG+lWd2DNAHAhRvn18JQDLxGLkJwjHqiN/tLIa2hyPGousr8yyoUojRYy8GUZNNSJvy9iBtwLIJLG2xuUjs3fg/gc7tnZyPB/e3yx7O0+/Aoy2urJy5iH7tt0GC54S+h2piwS9nC3ByNMQ0X2X7hY5D1kuE0e9B5NDVWCIEPE= 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)(13018025)(13015025)(13024025)(13023025)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6096035)(20161123563025)(20161123559025)(20161123565025)(20161123561025)(20161123556025); SRVR:CY1PR0301MB0746; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB0746; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0746; 4:+IkzGSXlhhIvfaHq1QF3E9TLorsSEVMYx5o1l0frPwBE6kkqnjTjMC2ShoqThsE3bJNERaBHybHRTwnnF1Rf8xJFQ/R/EvtbVnH1hjDFvcvA3Nrp3bC3oODLA/irDcqRQw8T3O7five++V7lt7l7YN4x0VhmQdrNPnjZwyuNuy3/lS8sYgbyj97yCSXjpYhPC97I/Nj0vbaJdxSax/oMuu1OAmA2VFKgsAmBNphaHrhbnQigMdXFBFbt65NfGa8//yOUT0wCL+Rjj2gRE++KxR/f/Mu5p7Bto30NFruYQ22B9KLRxNHduRMjMo5DhON8gJfAfPcbLQ/jgPyvOt1bn2Eanj6SsezvoTVNsYQgkHw95WSQdjqphRl94DHIgQSnZAzmXrru9MFfNRqizN9+97XIaAgpMMZaVQ9/oNtOiCI4COIGpZIyZXXKAUZ3UdPx5RHFnAv8QyRfTFRVMAM1p4cXKBDU0LuSHvUEIO0/QAKSMDuFPnGtzyKm0gvFRl5H1UMY5cWF+T/7TOkejevSGvCpHR8uKTOqwOOzwg9zvSvCbIrcHId1qZfZGAz/2fn8WXFaVjnvBHz6f3gEHYyqOi2rE99aTmSCpwQ51z0jWDpYUBtDJU8bfR3qqfSxXrd66sNmkurGEQ4OBxC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VqC7qWBsoV9KBvWA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2016 13:34:41.0925 (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: CY1PR0301MB0746 Subject: [dpdk-dev] [PATCH v2 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: Tue, 13 Dec 2016 13:34:43 -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 [shreyansh.jain@nxp.com: Fix checkpatch error] Signed-off-by: Shreyansh Jain [jblunck@infradead.org: add type checking and __extension__] Signed-off-by: Jan Blunck -- v2: - fix checkpatch error --- lib/librte_eal/common/include/rte_common.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index db5ac91..3eb8d11 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -331,6 +331,27 @@ 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