From patchwork Thu Jun 16 14:06:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreyansh Jain X-Patchwork-Id: 13918 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id D3434C760; Thu, 16 Jun 2016 16:06:54 +0200 (CEST) Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0087.outbound.protection.outlook.com [65.55.169.87]) by dpdk.org (Postfix) with ESMTP id B8B88C70E for ; Thu, 16 Jun 2016 16:06:49 +0200 (CEST) Received: from BLUPR0301CA0039.namprd03.prod.outlook.com (10.162.113.177) by CO2PR03MB2373.namprd03.prod.outlook.com (10.166.93.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.523.12; Thu, 16 Jun 2016 14:06:48 +0000 Received: from BL2FFO11FD035.protection.gbl (2a01:111:f400:7c09::144) by BLUPR0301CA0039.outlook.office365.com (2a01:111:e400:5259::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.517.8 via Frontend Transport; Thu, 16 Jun 2016 14:06:48 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; 6wind.com; dkim=none (message not signed) header.d=none; 6wind.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD035.mail.protection.outlook.com (10.173.161.131) with Microsoft SMTP Server (TLS) id 15.1.511.7 via Frontend Transport; Thu, 16 Jun 2016 14:06:48 +0000 Received: from Tophie.ap.freescale.net (Tophie.ap.freescale.net [10.232.14.199]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u5GE6Xo6026530; Thu, 16 Jun 2016 07:06:45 -0700 From: Shreyansh Jain To: CC: , , David Marchand Date: Thu, 16 Jun 2016 19:36:39 +0530 Message-ID: <1466086011-11920-6-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1466086011-11920-1-git-send-email-shreyansh.jain@nxp.com> References: <1454076516-21591-1-git-send-email-david.marchand@6wind.com> <1466086011-11920-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131105596082601236; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(47776003)(97736004)(69596002)(2950100001)(2351001)(48376002)(104016004)(5008740100001)(356003)(106466001)(229853001)(50226002)(50466002)(77096005)(105606002)(19580405001)(19580395003)(8936002)(6806005)(189998001)(33646002)(50986999)(81166006)(8676002)(85426001)(4326007)(586003)(11100500001)(68736007)(92566002)(2906002)(5003940100001)(110136002)(36756003)(87936001)(86362001)(76176999)(81156014); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR03MB2373; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; CAT:NONE; LANG:en; CAT:NONE; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD035; 1:dB9rBndsuc4N2Vtk5cXp6CXvZIo2ROGPOTT/w6Pp01CzI1MKd6u3215Hqh8t6shGIjodOquHE7VeCj2BWG4bLyh8aGE69LK7WWrFiGSV4ftyaXxBFPUafsDElFm9q5GCnokrCz97L1mfrYANJ3JVCANRoKsZKcJe7YPh24aypgFb1ApWXP2oHn+9CaaZcUJ9HI3iGTEK03EOabgJHcDbBn5P4X+/YF3wgbLSmUbSllJnwyikMpv9rfmTHKN0kOu854JiZNWw238lgRvPWxshiaoyPTh5sPsGpHcW5cuATa4FCyQtk+YwFSjOzLQtLWDyMmiWHtS6D5m3rzypApLBlmYRcdyOdLZh+6yPMiC+svD/qEt4OJkHCPiTSUS3MahMRBX5WEjMivCJE6gPX+GLeB5pKuc4Y0jUR4aT2JHlQJmOKpj+Fxnaov893srFL8c4BrzrRMbUBPITT6rnZlQF4iKJBuGO3qHKuB4wjOEuQRkK/DsfEMkUkFP9Co58ykIoWDy8/WHxR4sgA1vIoJGMNWyV71J2a0vOIDI9BYdz1sXvqp7ygqw8eAIwvEspZD+QGounj0/aQN4DhDdgJWOCfQ== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: c170a53a-efb6-4f06-5bb3-08d395ef7506 X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2373; 2:evwGlswfQG34tm4xpkrjBHve1Cq8BlqxFtqYWW0a2I4hvHYCBBtc1yA5Qt+NVlrkrLxS5Z1csO4tdWwqNSXk2EF2KBVSpwW6SajgDAmPgnNFmM9lhu4g1/m/bIpbYW4XSvBYw5MN97UEpoi7pBnPqYwBZ9gC1cowBn0Qn+PYtWq8cAdbeJtHwDcDrhy6nKEI; 3:HSi0FmocPqn91pHS+AtklzFs0w0eNRt2HiDevi1ZPANVEJ/21COxl664XG8B5qIUZsi4x8hMfMP3bw0gtpP+Lva0BmC5MDjpBHLOZeU9VFeAJJi2ZywRns2jjmpD+EF8o9tiZaycE4O+nMd/AmLOzm2l7seHTke82cVZCAjkf7C6ZNOocZXMCWL6puReWxp0pIqvXtoIyA1TLSodEcwmqsrpAhWtTOkU0zpvRv7B0lM= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR03MB2373; X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2373; 25:/zSrxwctdSvX7GEohNjoiHEFMTWJd9FINEl7yt3lA7hhMHoQiAPPNAj6yLOhMkvLBRSGeo1eM/+/kOlICONg/Q/ljJKfCuxKx1pkMM8mXvq1zbsiwnbI0ri9kJOOBIctj/ZXgM8CtHQDF/6IS2Ex+r72yFdSRxhl+TF0QsBui6P6t9WTWVHXxIYPYdL0UG6QYnOsWNhfMSZjhqgYTeBIG7/QUljOYhGd2hBOv3o6ky8r1S0lJbskFABQQuOomff55FTFAYfAgaM6Rh93cOwDtiUcR+2lHafWqB2XluCuEAtxw9/1xJ7Gidgv+DNOgBavLRNSwvvbODDWInON1E/mufvhEDMylQAv5um5kWXEeGIDLE9YSGTaKlz8ZbIeopm7KTHL1uDUY2Tj/mZriOCW7WE56VhuQHb05CL9vpFx8ungQ+ev5/cwYnKh9doboOc+Wz/bwtW+xef2zVh0QbT2jgfaFqOMp/pBdJbd+QWOMr3Syr409Sf+kp/VJG4xAKi2R/OhBciqbaDaWJgVkh3TP9U6DADYAIOqqB3oFSv/2F2TMcp1ugLELhn/1aHzZgKCISwTwwqoQnduOISn2nkua945laChcgpEpCYjMnD4ggURlGGTAh4nYwLCLNIYZYo6HNJUQ4PobENSaVm9PO8GD1ttPXYYRw5MW2pRSGHDKyO6knS6ZM7TZoS1KfjKbpJVqGr8hPy0CnpxBUwyd5Xu8g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(13018025)(13017025)(13015025)(13024025)(13023025)(10201501046)(3002001)(6055026); SRVR:CO2PR03MB2373; BCL:0; PCL:0; RULEID:(400006); SRVR:CO2PR03MB2373; X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2373; 4:r1D56iHYQGsZIKMLaKA5G1YCNiwlS0KDkV4hddJ82opIRCI07lMskPlp87fHcRMZgSBRAWAZcpweb4YG+jpJ+jq50f94wDANlNjM45j5jhEinx7ny6Qw1LgxqSyTYJZ5CQSdn/KoS1ruaOfdKZBug8SkNJGeVLdZMYPsvc+EDZv63UrJAsaC8LYAa0Xv2pjbg7PMmP2CmYgqI9Lx5n29g4+/PaNy/szWDhj4mciVMdkIgzpJcbR8cGmiIqhopUlmEy4sd5uE22iGNfq2IwtThhTuC5mpIVLiVvdI7oAqKT+4/zVckVDDSZqLXI84BS6GgBDyaNi4+mNfffEUswKyPW6FMBhmJxWIHS61RStJ8BxFCbqV5ALhPjsCBjYH3GlNesaoh09fSbmEc0Zca/tlwN86jdcbcekzv24Menjc+LXlBGG7CV/GBuwoO4wONw/Us1TgO5iaMH5h+HgsRVDCN66JzTpkcclz0PLlg7HvAaM= X-Forefront-PRVS: 09752BC779 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR03MB2373; 23:gYVpkxOEqcIyZLcUf1Mw6RekE8uW2lgQWnjmI5Gt6?= =?us-ascii?Q?7TkmdBhG9AeJlJ/jF+C0DsXVF4mPzO5/bcDNu4zKkPNZamyKSlhSO2/R26/7?= =?us-ascii?Q?timxbc6FKfignmAefMVVNLee0Ea8hs5z2Kbk8vTFuNjOyfg0STlm20f9R9U6?= =?us-ascii?Q?vFYp+kFOQe1+COhyDKcifHk5LC6m6ncb6wqNWUnaQh1A+v6RXntvGgf0sdLh?= =?us-ascii?Q?NFBtHuu2fiBLuHwVnlD45CssOvi+U5SbjkLSfZbN/TWlQk1eE2mX8apPjAM4?= =?us-ascii?Q?Xh6xHhhEQPukm9JzNgAx7oR5H57NsfinEEMCbkwyJiKkM3ECJz/Bhwillr5/?= =?us-ascii?Q?wlxfcDRFmjho4jZM00SqnPQOnlnkHCo/lYM/IvR7VwKM7MNs/0liZo6MxjTX?= =?us-ascii?Q?nKgI0cF/slGC4TCNpyoUaGjBA1xdbZIn/h+pViMMQumn6B8e1lAXCj4Jwt4E?= =?us-ascii?Q?0Zg7DwvueAsixgkjGXF84h5u9JiWWIWz/VgmRP95vlFK4p7hZ5H0M4DLXKkB?= =?us-ascii?Q?DPZM+HHVduhpCWiygM6J5l45oCPP4iq4ChLPw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9oETjMaOwnmA=; 5:O/DeIoLsFPDxNneDHDLiYFJUcPMzOUlFLCTEgRwJAvYoL2tGKvLhC1gikqQYiGVM5CmO89Iok+o+HkT91ahwsz48ov9zJyxb5Qc+TMEpfa7BhCA/CgwUOsd1+h4jNUDPEOd2eobHKNOID/xDffqdHV40DQxDzuas7TO2LaAfCx0=; 24:8EHZQe3+amhcJH9XpMDiIlNSxPLRIo+yRBa6NKqpQzGp0LtmNor4/UZkz4fjpm0jBJhHLLMNf7ONr2ojJ/+ZWK9kVt1cu/McBGMhLM9rwlc=; 7:DGtEUnAfp395BjKXdoERU5UxCWq0HhkRc5jnaOopfj5iXSsPoTXbgHyVHBUDQ42qRQCivBJCo1+5ku8q3RjuzoT47VexYXPb4sy0fLq4i07d1bbGJ9qJNAi4VtdYMhzQJvKI/jBGYKkFZc0TCd8Uxwkx+F+RJhamDUokAxUHDVbZXmJGKxgRopcPXy1vxVo5x3QWStQMh5V/jWIfQImXjg== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2016 14:06:48.0261 (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.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR03MB2373 Subject: [dpdk-dev] [PATCH v3 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: David Marchand 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 fa74962..d7df1d9 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -470,6 +470,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); \