From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from wes1-so2.wedos.net (wes1-so2.wedos.net [46.28.106.16]) by dpdk.org (Postfix) with ESMTP id 5B7AA2A5D for ; Wed, 20 Apr 2016 14:35:37 +0200 (CEST) Received: from pcviktorin.fit.vutbr.cz (pcviktorin.fit.vutbr.cz [147.229.13.147]) by wes1-so2.wedos.net (Postfix) with ESMTPSA id 3qqhDn0LKNz2P4; Wed, 20 Apr 2016 14:35:37 +0200 (CEST) Date: Wed, 20 Apr 2016 14:33:32 +0200 From: Jan Viktorin To: David Marchand Cc: dev@dpdk.org, thomas.monjalon@6wind.com Message-ID: <20160420143332.7484e602@pcviktorin.fit.vutbr.cz> In-Reply-To: <1461152657-19969-6-git-send-email-david.marchand@6wind.com> References: <1454076516-21591-1-git-send-email-david.marchand@6wind.com> <1461152657-19969-1-git-send-email-david.marchand@6wind.com> <1461152657-19969-6-git-send-email-david.marchand@6wind.com> Organization: RehiveTech MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2 05/17] eal: introduce init macros 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: Wed, 20 Apr 2016 12:35:37 -0000 Hello, just an idea... On Wed, 20 Apr 2016 13:44:05 +0200 David Marchand wrote: > Introduce a RTE_INIT macro used to mark an init function as a constructor. > Current eal macros have been converted to use this (no functional impact). > RTE_EAL_PCI_REGISTER is added as a helper for pci drivers. > > Suggested-by: Jan Viktorin > Signed-off-by: David Marchand > --- [...] > diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h > index e692094..f99b33a 100644 > --- a/lib/librte_eal/common/include/rte_pci.h > +++ b/lib/librte_eal/common/include/rte_pci.h > @@ -471,6 +471,13 @@ void rte_eal_pci_dump(FILE *f); > */ > void rte_eal_pci_register(struct rte_pci_driver *driver); > > +#define RTE_EAL_PCI_REGISTER(name, d) \ What about a simple version with just a single argument? #define RTE_EAL_PCI_REGISTER(name) RTE_INIT(pciinitfn_ ##name); \ static void pciinitfn_ ##name(void) \ { \ rte_eal_pci_register(&(name).pci_drv); \ } Then the name pci_drv would be mandatory... But anyway, the 'name' and 'd' are usually duplicates. Regards Jan > +RTE_INIT(pciinitfn_ ##name); \ > +static void pciinitfn_ ##name(void) \ > +{ \ > + rte_eal_pci_register(&d); \ > +} > + > /** > * Unregister a PCI driver. > * > diff --git a/lib/librte_eal/common/include/rte_tailq.h b/lib/librte_eal/common/include/rte_tailq.h > index 4a686e6..71ed3bb 100644 > --- a/lib/librte_eal/common/include/rte_tailq.h > +++ b/lib/librte_eal/common/include/rte_tailq.h > @@ -148,8 +148,8 @@ struct rte_tailq_head *rte_eal_tailq_lookup(const char *name); > int rte_eal_tailq_register(struct rte_tailq_elem *t); > > #define EAL_REGISTER_TAILQ(t) \ > -void tailqinitfn_ ##t(void); \ > -void __attribute__((constructor, used)) tailqinitfn_ ##t(void) \ > +RTE_INIT(tailqinitfn_ ##t); \ > +static void tailqinitfn_ ##t(void) \ > { \ > if (rte_eal_tailq_register(&t) < 0) \ > rte_panic("Cannot initialize tailq: %s\n", t.name); \