[dpdk-dev] [PATCH v2 05/17] eal: introduce init macros
Jan Viktorin
viktorin at rehivetech.com
Wed Apr 20 14:33:32 CEST 2016
Hello,
just an idea...
On Wed, 20 Apr 2016 13:44:05 +0200
David Marchand <david.marchand at 6wind.com> 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 <viktorin at rehivetech.com>
> Signed-off-by: David Marchand <david.marchand at 6wind.com>
> ---
[...]
> 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); \
More information about the dev
mailing list