From: Gaetan Rivet Date: Wed, 11 Jul 2018 21:44:56 +0000 (+0200) Subject: eal: introduce destructor macros X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a671f01fcc65a884122bf69a71553c533649eebb;p=dpdk.git eal: introduce destructor macros This macro adds symbols to the .fini section using the global RTE priorities, to ensure consistency. Signed-off-by: Gaetan Rivet Acked-by: Shreyansh Jain --- diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index a9df7c161a..687dcefa0b 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -111,6 +111,29 @@ static void __attribute__((constructor(RTE_PRIO(prio)), used)) func(void) #define RTE_INIT(func) \ RTE_INIT_PRIO(func, LAST) +/** + * 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(RTE_PRIO(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) \ + RTE_FINI_PRIO(func, LAST) + /** * Force a function to be inlined */