From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2708CA09E7; Tue, 8 Dec 2020 08:47:25 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2D10F72DE; Tue, 8 Dec 2020 08:47:23 +0100 (CET) Received: from new4-smtp.messagingengine.com (new4-smtp.messagingengine.com [66.111.4.230]) by dpdk.org (Postfix) with ESMTP id 7BE9298 for ; Tue, 8 Dec 2020 08:47:21 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id E226A5804DF; Tue, 8 Dec 2020 02:47:19 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 08 Dec 2020 02:47:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=fm2; bh= vSD2lIsbZHsHAuFYrbYAyoRd2I62EPYOKXYREmt/VDc=; b=YbQWfAH7k4R09vct 1NCnjarX5xuAZzrCk5WA2lalRwv+twg6qRCDif1ijvmIULnf6qYWw3NybYevYjxW 7f/Osgrap/e/rCgfD7aDSYC0sbjSBp2ItGTpFE71JSVZBm9nZG7m68YQF8z643la mLvNe2w9gOI4n11k1iS4P9KIJGoS77ULlVULWku2tf6w1YiTzhuUpMbYQBYfktZp B0DSe7xjmdyCVYEp3ufzeKy+v41SYTshlJCTdhHTT+P+nlO46lyFoXLPWe2K/44G Uz8E5M1hQsMQPYI9db/efoVkmZ0R6FQ5wQ7FhylVs02pmYoe4Ls4DPNHPFGcwGXv z7rzag== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=vSD2lIsbZHsHAuFYrbYAyoRd2I62EPYOKXYREmt/V Dc=; b=ZET7vFfeGx74IJRmhszkaGV6cz9wKADUt8dYeeQGiFQwXbjPNk+7y4Z1o SjeS2Bc8//G6NG8y7gEd+bUBLvH49u65pUxykq9y0vgFjQwajmIQblW0oUj44qDD UaDtfog0ogfzepdTef3ImEBnKLDm97Tx6jCG/hIjYwno9rWVeHcDYsZOIx/ef/Jy Ci1K35FVrQMUbm4C4ZRBpOiRkWScYnyF2wPugCTtVS4ZrnMCJKosHdJaT33uSL4t C+7znV2JckBYjxD00UP2c/LZyRmJjC2FW3RGg3fi91v5Fs8+Mm1Z2atrdYQa7aif TCnq5l5G31vNIp9KdGUxqKf6vTRmQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudejhedguddufecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedugefgvdefudfftdefgeelgffhueekgfffhfeujedtteeutdej ueeiiedvffegheenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr lhhonhdrnhgvth X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 044DB1080059; Tue, 8 Dec 2020 02:47:17 -0500 (EST) From: Thomas Monjalon To: Narcisa Ana Maria Vasile Cc: "dev@dpdk.org" , Dmitry Kozlyuk , "Kadam, Pallavi" , "Dmitry Malloy (MESHCHANINOV)" , Omar Cardona , Harini Ramakrishnan , Khoa To , Jie Zhou , Tal Shnaiderman , "ranjit. menon" , Tyler Retzlaff Date: Tue, 08 Dec 2020 08:47:15 +0100 Message-ID: <3322289.gH0BhIt9ao@thomas> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] Importing DATA into the application X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 08/12/2020 08:03, Narcisa Ana Maria Vasile: > Hi, > > While using the DPDK libs as DLLs, I've ran into some access violation errors. I believe they are caused by some incorrect imports. > In Windows, accessing an imported variable is done either by using __declspec(dllimport), or by using an extra level of indirection[1]. Why coding on Windows is so complex? > Some examples of variables in DPDK that are not declared correctly: > rte_cycles.h: extern void (*rte_delay_us)(unsigned int us); > rte_mempool.h: extern struct rte_mempool_ops_table rte_mempool_ops_table; > rte_lcore.h: RTE_DECLARE_PER_LCORE(unsigned, _lcore_id); (Which expands to extern __thread unsigned per_lcore__lcore_id) > > To fix this, we need to add the __declspec(dllimport) keyword to the declarations of these symbols. Also, we need to consider that the symbols can be used both internally(in the same module) and externally (imported by other modules). > We can define a macro that will tell if the symbol is used internally or is imported by a different DLL. Example: > > #ifdef RTE_INTERNAL > extern void (*rte_delay_us)(unsigned int us); > #else > __declspec(dllimport) void (*rte_delay_us)(unsigned int us); > #endif > > We can then hide the Windows-specific keywords under a new macro, such as: > #define RTE_IMPORT __declspec(dllimport) > > However, there are a few issues to consider: > * We cannot add __declspec(dllimport) when declaring per_lcore__lcore_id for example. We cannot have both __thread and __declspec(dllimport) (can't import thread local variables). We cannot export a TLS variable? It looks to be a serious issue. > Have you discussed/run into these issues before? Let me know what you think. Curiously it has never been discussed in 2 years of DPDK porting to Windows. Thanks for raising.