From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH 03/15] pmd: Add PMD_REGISTER_DRIVER macro Date: Wed, 16 Apr 2014 13:52:49 +0200 Message-ID: <1462763.GWB5SR3fGh@xps13> References: <1397585169-14537-1-git-send-email-nhorman@tuxdriver.com> <1397585169-14537-4-git-send-email-nhorman@tuxdriver.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev-VfR2kkLFssw@public.gmane.org To: Neil Horman Return-path: In-Reply-To: <1397585169-14537-4-git-send-email-nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 2014-04-15 14:05, Neil Horman: > Rather than have each driver have to remember to add a constructor to it to > make sure its gets registered properly, wrap that process up in a macro to > make registration a one line affair. This also sets the stage for us to > make registration of vdev pmds and physical pmds a uniform process > > Signed-off-by: Neil Horman Could you explain why having a macro is better than an explicit constructor function? > +enum rte_pmd_driver_type { > + PMD_VDEV = 1 > +}; > + > +extern void rte_eal_nonpci_dev_init_register(const char *name, int > (*dev_initfn)(const char *, const char *)); +#define PMD_REGISTER_DRIVER(d, > t)\ > +void devinitfn_ ##d(void);\ > +void __attribute__((constructor, used)) devinitfn_ ##d(void)\ > +{\ > + enum rte_pmd_driver_type _t = (t);\ > + switch(_t)\ > + {\ > + case PMD_VDEV:\ > + rte_eal_vdev_driver_register(&d);\ > + break;\ > + };\ Are you sure this switch is needed? You are removing it in patch 7. If someone else think this macro is a good idea, or not, speak now :) -- Thomas