From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gaetan Rivet Subject: [PATCH v11 06/25] eal: introduce dtor macros Date: Wed, 11 Jul 2018 23:44:56 +0200 Message-ID: <0d2e618f68d5d7f5028a26681ca67cdcdcf3b0e6.1531345404.git.gaetan.rivet@6wind.com> References: Cc: Gaetan Rivet To: dev@dpdk.org Return-path: Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by dpdk.org (Postfix) with ESMTP id C155C1B539 for ; Wed, 11 Jul 2018 23:45:45 +0200 (CEST) Received: by mail-wr1-f51.google.com with SMTP id c4-v6so6928684wrs.12 for ; Wed, 11 Jul 2018 14:45:45 -0700 (PDT) In-Reply-To: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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 434adfd45..0dd832728 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 */ -- 2.18.0