From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id 6BA4A558B for ; Thu, 17 Nov 2016 13:06:50 +0100 (CET) Received: by mail-wm0-f67.google.com with SMTP id g23so20695372wme.1 for ; Thu, 17 Nov 2016 04:06:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Hup6H7ebV8OFRfZcCHL6wsWZwlLnfZqcTVzez/xV5Ng=; b=lkUjKZM5V+VyrT+zGTWIiL6hjJ4Lhl2+Jh/owDl/ms2bqJTGFVOZb2jn7hXxIEmq4u LUIDgCAohS2Fkl7TfUI/hX96zjksjYQ7HlfXLYtZiKimSMcO189FQzALlTu2uyqF/6G2 ptTu0TtLlwsIVDW9KB2kRo8ViHzzyI9hqFEhzQjEzNxPJYB48UL14o+ddqC3IZhv23FR Lw0CAO6NbZWW/hTcJqzSXM8A+EYmyJ54nmsBUGaH1GM7voYsFRMbX+3IWT5TW6bEzN5g LEPMLPO9Wtfiwe4FUe0HIMlSIxFfq41R+3aAtQPdjE4uT04qHN56k1me0Nsav2ogSy/C 1zGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=Hup6H7ebV8OFRfZcCHL6wsWZwlLnfZqcTVzez/xV5Ng=; b=A6HDudplnWXTtxEmsKkrvRj7pqJJEogNyPDxRWF6GqOX/FQ9EWX+cXc7xMvX3S1Tv9 vk4jhCRcMhQcx07DQKD0AYbiYKgga+NSzdo8jXxAsBwGuWxd4T/nH0tXVG2XPRBVq/xy p6YB7F3Da1p7CHNCqZFT9ZVKAb/LXDz3LqAF5ntdKT4ozIExSfS+N0lfsNegeODeWpAz sddAA8JyJq19mPXHWo0ibSH5IFxm6l10ZfgeMfTaXp9lxkevldprR3dzltVKhAGpk6MM cHWKewjyi5HCG9rKVERitsTxBfu9AZAo6xX3GMNh7omJl6ljphSeM6ylLKSyCoybRc1N Uduw== X-Gm-Message-State: ABUngveotQItKXYJwfHZWkBtsEzTtfvpIJQfqs8Nf+GQrwpExxEWTlQ41HmshwPN9FEhu2hatbnvbesVDT/KdQ== X-Received: by 10.28.104.213 with SMTP id d204mr2440417wmc.101.1479384410042; Thu, 17 Nov 2016 04:06:50 -0800 (PST) MIME-Version: 1.0 Sender: jblunck@gmail.com Received: by 10.28.191.8 with HTTP; Thu, 17 Nov 2016 04:06:49 -0800 (PST) In-Reply-To: <1479360605-20558-2-git-send-email-shreyansh.jain@nxp.com> References: <1479360605-20558-1-git-send-email-shreyansh.jain@nxp.com> <1479360605-20558-2-git-send-email-shreyansh.jain@nxp.com> From: Jan Blunck Date: Thu, 17 Nov 2016 13:06:49 +0100 X-Google-Sender-Auth: td3yJqs1GXbQZT8Yo-tjJ2CdS64 Message-ID: To: Shreyansh Jain Cc: David Marchand , dev@dpdk.org, Jan Viktorin Content-Type: text/plain; charset=UTF-8 Subject: Re: [dpdk-dev] [RFC PATCH 1/6] eal: define container 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: Thu, 17 Nov 2016 12:06:50 -0000 On Thu, Nov 17, 2016 at 6:30 AM, Shreyansh Jain wrote: > From: Jan Viktorin > > Signed-off-by: Jan Viktorin > Signed-off-by: Shreyansh Jain > --- > lib/librte_eal/common/include/rte_common.h | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h > index db5ac91..8152bd9 100644 > --- a/lib/librte_eal/common/include/rte_common.h > +++ b/lib/librte_eal/common/include/rte_common.h > @@ -331,6 +331,24 @@ 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(p, type, member) \ > + ((type *) (((char *) (p)) - offsetof(type, member))) Are there any reasons why you choose to implement this in a non-type safe way? Catching obvious bugs at compile time is in the interest of us and our users from my point of view. > +#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 >