From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id C8CF4282 for ; Tue, 14 Feb 2017 15:36:17 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id u63so3858273wmu.2 for ; Tue, 14 Feb 2017 06:36:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id; bh=2Zo8FTuGBJKmBtEPAVjr5M8Ef/i6yHTHhtCLnLrBJV0=; b=ABi7/DPUG34XpQ2LvWIhM0N3fJLED/bRqJaB/wlJl9+HgpWBvf3UEkyeAm6EkdQd6m 7yScpxvckKF+F8MS7r6xkIW06OOjPz7m6C7uUH9fdpVjU2KaiKjmuxUxbNkWcTOES9eb iajRfTxJY2OXjrFnEsHMH7VTlsBM9zzJSIWFEpdax2XJ04NWfeGp0AypAVhSWXG5Ef7Y 8ENA9crfc/saywHolD9QtFuX+I9DJGYWcjXmV1/bislc/vH7RdeRD85wRqlT6ZsbR9XZ kWOKGVrC21GXqBqxIxr9DgCI64wVGw5eBG58jYmOZCGH6WUWSVA6ZwG1uzAxvyjBVeL7 s40g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id; bh=2Zo8FTuGBJKmBtEPAVjr5M8Ef/i6yHTHhtCLnLrBJV0=; b=jwOPwtdM3DlUQQdTVVqMgu7k8KhtotzqgKMmTHAryt1oErbTq0dy9sc2K7BMcTST6a yfLbjhdkvQwOxV3A+Bk1bodxn8yZa5PDvZ6gqz6HhcBaNPcMmxTrxJBCVWoXJbV+Vokt 7h9CdJMEynAEjuW31q8NILOofUbNtWgmmbeYKQ0/cmDS4I9mDOrcFw8OFNVS7BBk5AGg Wp/ETXzXmcIK2FlL4S911jxZQgnZhZ2JcwJ8ZLgRIV2+9IVmK4Z+MYXVPIb6Cy0DCZJH ur4vkW7c4cgcuIs2WHaZ+y63PpbwdOdhLuLU2RxxA6YHVVtEOwmwMJ9ADKvAh0PvNFns Ln3w== X-Gm-Message-State: AMke39kQULRomBfuO76yEOHl5Jp36vg3DJ1GZmKLrF1UQm9h3SA6mnHhJXqGScV6MtermQ== X-Received: by 10.28.212.84 with SMTP id l81mr3843025wmg.119.1487082977425; Tue, 14 Feb 2017 06:36:17 -0800 (PST) Received: from weierstrass.local.net ([91.200.109.169]) by smtp.gmail.com with ESMTPSA id z134sm3718236wmc.20.2017.02.14.06.36.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Feb 2017 06:36:16 -0800 (PST) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Date: Tue, 14 Feb 2017 15:36:05 +0100 Message-Id: <1487082966-21074-1-git-send-email-jblunck@infradead.org> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH 1/2] Fix container_of() macro to work with const members 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, 14 Feb 2017 14:36:17 -0000 This fixes the usage of structure members that are declared const to get a pointer to the embedding parent structure. Signed-off-by: Jan Blunck --- lib/librte_eal/common/include/rte_common.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index 8dda3e2..c421708 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -347,8 +347,9 @@ rte_bsf32(uint32_t v) */ #ifndef container_of #define container_of(ptr, type, member) __extension__ ({ \ - typeof(((type *)0)->member) *_ptr = (ptr); \ - (type *)(((char *)_ptr) - offsetof(type, member)); }) + const typeof(((type *)0)->member) *_ptr = (ptr); \ + (type *)(((uintptr_t)_ptr) - offsetof(type, member)); \ + }) #endif #define _RTE_STR(x) #x -- 2.7.4