From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0077.outbound.protection.outlook.com [104.47.40.77]) by dpdk.org (Postfix) with ESMTP id 6414C5A49 for ; Fri, 26 Aug 2016 15:57:45 +0200 (CEST) Received: from BY2PR03CA041.namprd03.prod.outlook.com (10.141.249.14) by SN2PR03MB1886.namprd03.prod.outlook.com (10.164.114.146) with Microsoft SMTP Server (TLS) id 15.1.434.16; Fri, 26 Aug 2016 13:57:42 +0000 Received: from BN1AFFO11OLC004.protection.gbl (2a01:111:f400:7c10::148) by BY2PR03CA041.outlook.office365.com (2a01:111:e400:2c5d::14) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.599.9 via Frontend Transport; Fri, 26 Aug 2016 13:57:42 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com;nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11OLC004.mail.protection.outlook.com (10.58.53.75) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.587.6 via Frontend Transport; Fri, 26 Aug 2016 13:57:42 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u7QDvHph023630; Fri, 26 Aug 2016 06:57:39 -0700 From: Shreyansh Jain To: CC: , , , , Shreyansh Jain Date: Fri, 26 Aug 2016 19:26:44 +0530 Message-ID: <1472219823-29486-7-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472219823-29486-1-git-send-email-shreyansh.jain@nxp.com> References: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> <1472219823-29486-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131166934624006482; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(575784001)(68736007)(19580395003)(2906002)(106466001)(77096005)(92566002)(19580405001)(229853001)(2351001)(8936002)(81166006)(50226002)(50986999)(48376002)(36756003)(76176999)(626004)(104016004)(86362001)(5003940100001)(87936001)(105606002)(97736004)(110136002)(33646002)(4326007)(8666005)(50466002)(305945005)(7846002)(85426001)(47776003)(11100500001)(8676002)(189998001)(81156014)(2950100001)(5660300001)(356003)(586003)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR03MB1886; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11OLC004; 1:Kf3p6hevePmaZU8DNwInI4+STybNcNM9fAfXxiqC59c5TWWllGInPhvE7Z04pi0crXzlO5ZZN2L4cdB9js4D+pv2cv2Zges66E2QOJs/KRxT3QM14uXS+CjuahBFdNilPFP24auLveCtBeUtivwhL10iTLHnreoffNWV2/r1TxxngRxgYaGDkAqYCut2pEZLom/L6qwPLum0HR8BFuDt8mmrNX4K7pOXu8A778SwXJ3fYVDOsNmfr0WyfzgXeBT5Nk1VJfE+XmHEG1tBmDuNQ+52paL7NIe/iJOiAAAqYqBz49p6y5RC+i+TXixQnAOMsV/dyqJpyEo5A08f6tnAxYCB4TXK22CC+IRz1WlLHYw6vSPQezWahp4SsRL9+PcHMzJFoYExKEpa0uDOfDsP3BkfBCP4KI8VPtoGJ6/MSpZ71UZWcTGD7pKqQGi0d62xQraATy58FL/tAS/aapYcjMOpEzH9PFffamJ6Ug+cLWJt8BaW/x6sZg2K+J2WYszusn2t60L8HwsTbSUSTbUoY2ET1j6zzXRRHN5T+PgbVQ5Vr2KnD77N0st6oWA3Rh5bDWBnJONjFoSQhYykLYR9GH5vko6PiKChAcAe3NetTrdMmyCjROFtchzO+2/NIaT9S22TeTsvnJru0Jrjlkpm75cYXqG5iHlHZIy9NxILgqqufs76nTncvorDSrz8FhU9td7haCLgsyk6BlZmNR9sbQHon6J+yDRQ3ccvefniPq4= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 56028dc6-269d-4ed1-7152-08d3cdb8f301 X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB1886; 2:wvQwCckmHzfgkADEj5Pj9MFePGgInkU6uqVLZBxBUmF/oXjbYmjm+LirSwUMY3XMYNozzy7drngPblslbt08L6HjwBUIl/0jB15PPM3s8QNZACeC696ivo8slUFzMjDfDUU8JEEAblV0UFNSu/7Bc82S3A7BCxQhVI8Es/gtfCoNs1hjTCJf4sPG2E7upfAt; 3:wAuRP28R9x7kiMQahN92s1shGFTyVCBmZVbnCJtIQwkmzz0mC2KSKfpExjNnF/Q750gpZYwc6M6QK0CHipyOfRyeIw20i+50VzSn6hTqWAJcBP+Jef46W1cK1Mj8n/wzdR/WPduSlACJeiERGTLkLcgX8/KDHhRAnbViqLjhk8MC+GTye7fXEl9iXDan+GyNJc8IvjNT7UOL24hNKYFuld7NNY4tmi7VYDOXZ2SLrkU=; 25:7za4z8bo4xfgX/xgN6ZPoofG7hTH39MwjIdKVYr8aMUDY42iOnWFq0Aspg37Q03rQUwyCPKHq5o3OdhAmhSJxrp4G8vTu2LvzLd0EME8mE/svkS8wafv/kGotN+G6/jbQiEEOiuRxDE69W24/8AXY6sQv9xd0Rguy+Kz7lDFqrj6+0FYjyk+Y9v2lYmv42Gj7dyUH1E4oVVjJqQHickp33tHvKjh1Y03ZOa7L/Q9Lsl4jtprpXat3q0vLpx7mbNX X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN2PR03MB1886; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13024025)(13023025)(13017025)(13018025)(13015025)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:SN2PR03MB1886; BCL:0; PCL:0; RULEID:(400006); SRVR:SN2PR03MB1886; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB1886; 4:ii9EpmXM0LMcqHWzXPSAihGWMFzZnQhSpUeXKHoX5D04xq6PVF8sTsxdOi7bwgjyww25FG6MZWFtvfbvutMB5RqlCCCfLiwpmT2tpd7Vh6csp70uwtfV9VbRgZcq87Iy3pfHBUlWwFlF/wVeMfd6aUmXN3nhvuarxfob70CNw55Bee3mOO9kvY9ubNSixixsFnjmJMGheH++0/xKREJ4pz1SMs1cykxwfxuOP8akPZJriNVndC8ZJao4boKHi3hk5QyOrvfrYfr1Qal4+xc/Ptg3Zjl1MUspF3zwQyFdXuKjLMmlbM5w6/qxSzG96wta4/DT2Ri5Ch9TckKpYjPFAS+sMMQMkcFEDdEclUGJ1xfsyGFUDwRm/N4ATTCMNoL08Sn9L92y3uqBBU/aOB1obZZ9jtv1XMMggGAOH6sZ5WzR/Q1F1AKv/Oh1gNARIqnzadoHh6Ducycl3Pp3FJNMLV40Zy6UZA+G49EGefQjeLrXpDhopz9hbSbUgV5y4Pjl8KR688VKRhh21bJJjw/AfA== X-Forefront-PRVS: 00462943DE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN2PR03MB1886; 23:SO4pWfIzwqmqnr9KiTB+WxHN1KCQpZyZHTezj6P6S?= =?us-ascii?Q?C5oWxogtWzdG/AhtTIu44R554tKacqBPLoB7M9ytoqjkz3UogM0br4Ul70+3?= =?us-ascii?Q?RJLeQq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BEwqpc?= =?us-ascii?Q?J9VR0bWroY2I1AJHfw4ALXn3EyyZn8tiqSXUYld975ixpz7F1Iz83l3goYqt?= =?us-ascii?Q?0BQtQ7BGAmuX2ImNoI5MPxtZJWUMarIpTalpLAqwXakKinpqsvvHHgUpxim8?= =?us-ascii?Q?sE1xggFcTN5UKU/BbpIzMLrTUNx3thMpDcZt9ZnkeomtrbOLgcT1etCcSNBb?= =?us-ascii?Q?DO6MNF9SvmrXJ9suGx4uxyjnxgNTTJsdsD1Bo8LExAr5q9jaPRbfEFTOg=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB1886; 5:aXNeq/RdzpSBpbGTYCfsRGuToobR3mrGxCM9p9rx8bM920PnDGWZgHNvPRZKTa6n+6iYQlMV0/DXgNrqA/4C991zaSayadW/0ZpuDLmTgtTWRH79KFANkHC0QTdi0l+LZ9DoIFFC6mDE5n1Ofqj49/cfmmLNIWP2JuMxWHTe5j8=; 24:voMpag7vH6JY5koDCjZ3vCZhF74M7yPIHsak5Gj7YQUH47jQwm4plYC+VH9r64ssYuizAqTgDDa78GPJS6lLqJGxLuuQHngDKQzSREwkQ8Y= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2016 13:57:42.2290 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB1886 Subject: [dpdk-dev] [PATCH v8 06/25] 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: Fri, 26 Aug 2016 13:57:46 -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). DRIVER_REGISTER_PCI is added as a helper for pci drivers. Suggested-by: Jan Viktorin Signed-off-by: David Marchand Signed-off-by: Shreyansh Jain --- 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 | 10 ++++++++++ lib/librte_eal/common/include/rte_tailq.h | 4 ++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index 95789f9..994650b 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -185,8 +185,8 @@ static const char DRIVER_EXPORT_NAME_ARRAY(this_pmd_name, idx) \ __attribute__((used)) = RTE_STR(name) #define PMD_REGISTER_DRIVER(drv, nm)\ -void devinitfn_ ##drv(void);\ -void __attribute__((constructor, used)) devinitfn_ ##drv(void)\ +RTE_INIT(devinitfn_ ##drv);\ +static void devinitfn_ ##drv(void)\ {\ (drv).name = RTE_STR(nm);\ rte_eal_driver_register(&drv);\ 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 fa74962..cf673e4 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -470,6 +470,16 @@ void rte_eal_pci_dump(FILE *f); */ void rte_eal_pci_register(struct rte_pci_driver *driver); +/** Helper for PCI device registeration from driver (eth, crypto) instance */ +#define DRIVER_REGISTER_PCI(nm, pci_drv) \ +RTE_INIT(pciinitfn_ ##nm); \ +static void pciinitfn_ ##nm(void) \ +{ \ + (pci_drv).name = RTE_STR(nm);\ + rte_eal_pci_register(&pci_drv); \ +}\ +DRIVER_EXPORT_NAME(nm, __COUNTER__) + /** * 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 cc3c0f1..cc386e4 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); \ -- 2.7.4