From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet Subject: Re: [PATCH v2 01/18] eal: introduce dtor macros Date: Thu, 22 Mar 2018 16:56:43 +0100 Message-ID: <20180322155643.nrfkxosktvt67gik@bidouze.vm.6wind.com> References: <20180322135114.GB6272@hmswarspite.think-freely.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Cc: dev@dpdk.org To: Neil Horman 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 43C6B4C76 for ; Thu, 22 Mar 2018 16:56:59 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id v21so5712555wmc.1 for ; Thu, 22 Mar 2018 08:56:59 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20180322135114.GB6272@hmswarspite.think-freely.org> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, Mar 22, 2018 at 09:51:14AM -0400, Neil Horman wrote: > On Wed, Mar 21, 2018 at 06:15:22PM +0100, Gaetan Rivet wrote: > > Signed-off-by: Gaetan Rivet > > --- > > lib/librte_eal/common/include/rte_common.h | 23 +++++++++++++++++++++++ > > 1 file changed, 23 insertions(+) > > > > diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h > > index c7803e41c..500fc3adb 100644 > > --- a/lib/librte_eal/common/include/rte_common.h > > +++ b/lib/librte_eal/common/include/rte_common.h > > @@ -105,6 +105,29 @@ static void __attribute__((constructor, used)) func(void) > > static void __attribute__((constructor(prio), used)) func(void) > > > > /** > > + * Run after main() with high priority. > > + * > > + * The destructor will be run *before* prioritized destructors. > > + * > > + * @param func > > + * Destructor function name. > > + */ > > +#define RTE_FINI(func) \ > > +static void __attribute__((destructor, used)) func(void) > > + > > +/** > > + * Run after main() with low priority. > > + * > > + * @param func > > + * Destructor function name. > > + * @param prio > > + * Priority number must be above 100. > > + * Lowest number is the last to run. > > + */ > > +#define RTE_FINI_PRIO(func, prio) \ > > +static void __attribute__((destructor(prio), used)) func(void) > > + > > +/** > Additionally, it might be nice to further abstract the destructor priority to > fixed levels so that people aren't always trying to guess what the right magic > number should be. I.e. create several destructor macros of the form: > RTE_FINI_ > > Where name is a meaningfull term like FINAL, PMD, EARLY, or some such set that > implies a priority value encoded within the macro definition. That would also > eliminate the need to create a BUILD BUG macro if the priority was specified to > be too low > > Neil > Good idea, and I agree that we need helpers on this. Not sure about _FINAL and _EARLY however. I will propose a patch as a response to this mail, let me know if that's what you had in mind. -- Gaëtan Rivet 6WIND