From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id 4967947CD for ; Wed, 20 Apr 2016 13:44:28 +0200 (CEST) Received: by mail-wm0-f46.google.com with SMTP id 127so10945155wmz.0 for ; Wed, 20 Apr 2016 04:44:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LbAh0JOmaWNwsrF0g+n5CxBwe3+rMXWG9t2+k7emmjE=; b=08xKL7L7Hf9Z7SMopVPix2ajw50IQAOrkjoEQ4p++NMT+jUpJoEOFFeJOc5ZKbdD/h OvZ6A3M9mv3F2Q1c9SMix50BJCc2UmPq68f6wnZ7T7HaYVJyYp6CxkjaY2kP1lbNVgxg oCEfK9mJAsFlrArs1+HDOWTXpBLQu9nR5Dwg+rRxXBc1g/FG75SkU/+hZNlRcC5k0TWp 26tujiq3MHvO3aEQvRBoyIzondN5U/bSO+ibmFxwqCHCpDAXAN7d3aerAJWkGyI0l1xe bt/YHqFxSmH4HLgMdgbYJfF6PSMnvJ2rdFgWMWN9aWn/aoFdn/8jEEMHoKWxUEyi5nAn Ql9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LbAh0JOmaWNwsrF0g+n5CxBwe3+rMXWG9t2+k7emmjE=; b=MyLsYbDGi4MXCE0U53A8sLOUl5tsdL3LfDydjUiQo++LNvKyGFW005wIokc+cxLroK eTcoc2TlyZIXFTIH9MDOueNuSspGE7fhW5aS+VCpRYqq9SLr0d8Qoq2FPy1TPlyWL0kA xi3+PAiTrbBKoO29iVdETplG/xcfZFGgEvDEJU1t9DST2581zqZK5LctGWmjWYW9huvD MBW7zajY0MYHbyP6AZ7tun610G5KsLT9AJ6wv9tzM4WldnvaQWGdGTSQfSCpapn8u7Vh xHbbMqPi7ZehXONvvXjPUwh7KWvCYa2WNrNLunVLm4V7dFn9wze86qpNofJTLB6qZRxL q5Sg== X-Gm-Message-State: AOPr4FUdRP8piC5/mQLUzV5kE6P6XfBOaYjXpmlGxDXr5OkrIvKJQnDhFaD/RJfYuP667jxh X-Received: by 10.194.87.103 with SMTP id w7mr8301529wjz.13.1461152668127; Wed, 20 Apr 2016 04:44:28 -0700 (PDT) Received: from gloops.dev.6wind.com (144.77.126.78.rev.sfr.net. [78.126.77.144]) by smtp.gmail.com with ESMTPSA id m6sm5195708wje.21.2016.04.20.04.44.27 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Apr 2016 04:44:27 -0700 (PDT) From: David Marchand To: dev@dpdk.org Cc: thomas.monjalon@6wind.com, viktorin@rehivetech.com Date: Wed, 20 Apr 2016 13:44:05 +0200 Message-Id: <1461152657-19969-6-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461152657-19969-1-git-send-email-david.marchand@6wind.com> References: <1454076516-21591-1-git-send-email-david.marchand@6wind.com> <1461152657-19969-1-git-send-email-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH v2 05/17] eal: introduce init macros X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2016 11:44:28 -0000 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 Signed-off-by: David Marchand --- lib/librte_eal/common/include/rte_dev.h | 4 ++-- lib/librte_eal/common/include/rte_eal.h | 3 +++ lib/librte_eal/common/include/rte_pci.h | 7 +++++++ lib/librte_eal/common/include/rte_tailq.h | 4 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index f1b5507..85e48f2 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -179,8 +179,8 @@ int rte_eal_vdev_init(const char *name, const char *args); int rte_eal_vdev_uninit(const char *name); #define PMD_REGISTER_DRIVER(d)\ -void devinitfn_ ##d(void);\ -void __attribute__((constructor, used)) devinitfn_ ##d(void)\ +RTE_INIT(devinitfn_ ##d);\ +static void devinitfn_ ##d(void)\ {\ rte_eal_driver_register(&d);\ } diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h index a71d6f5..186f3c6 100644 --- a/lib/librte_eal/common/include/rte_eal.h +++ b/lib/librte_eal/common/include/rte_eal.h @@ -252,6 +252,9 @@ static inline int rte_gettid(void) return RTE_PER_LCORE(_thread_id); } +#define RTE_INIT(func) \ +static void __attribute__((constructor, used)) func(void) + #ifdef __cplusplus } #endif 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) \ +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); \ -- 1.9.1