From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4CFABA0524 for ; Fri, 5 Feb 2021 12:19:31 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C5BF4067B; Fri, 5 Feb 2021 12:19:31 +0100 (CET) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mails.dpdk.org (Postfix) with ESMTP id 7309D4067B for ; Fri, 5 Feb 2021 12:19:29 +0100 (CET) Received: by mail-wm1-f44.google.com with SMTP id 190so5725793wmz.0 for ; Fri, 05 Feb 2021 03:19:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hCf65dBj/Jmmxd7CG7PNhIcnNgN8Cd3zfXiziMjuGt0=; b=Lhg34lh6OVU0pKKrrWZVliPzzNHelTpi9D4kuXJAr1msH3lO3n/SA3lh8EZjEyYBfN OzzLXpUuoZlUPHxhTWA8df9wDzenpP1Z+IhbanM+FEt8c37FHB7FwtfQMhqxUes3vFYn 7fqt2muuyyjj4tgtfYIZZKgNDi4oXl0Pv1ig3zwlaqiEVU5CaGpDos1s2iOgqX6+L3MZ XKTbbXJis/3+bWa1l6h6hUBlA6+YojB3l9SW7YFqU3LWO8KSpHNMDEAaExjDVxR4fjrw S22Px7OgXfh4n0WCWwW0MjIs5NAv5csDQfiR2M723Ha0Nyg24Jvib+2iFQXvTzo9gkRS UTrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hCf65dBj/Jmmxd7CG7PNhIcnNgN8Cd3zfXiziMjuGt0=; b=r0OQmxPGi9AQLEkQuOEyIAAdL2KKo6kkRuNLakoV5w0LO0u3rVipQtsiFHg0jhvlWl AUuj5RXwq6OP9Jw2OsShvDPtN9zwAmOglfXp9LkqJLW55j9kggxqfPxwoU5sybK2Uhdr /7+0RwjJISejTk0HGWABeCbKq0PRN+30nQntT9QLuy6PA021bFEzsxZRD5UTYjehqhQh n7fJoPToIrE7NCkS+QGR4k40jgnOKnZVkXMFm5k37tzKGXFeju5FZC+S/eBYZMPVcbp4 H/b7VDLcC9WqH0MnOdPNAjrKPw027iRWGwGomxWR1bAVKB8IxNRdqq/DF6Al+YEZRDCV CcuA== X-Gm-Message-State: AOAM532Vy0Hf8fF3YKybz5Py1UKO6pfuqwUBp/2Bm800hXyfPH+PWNPb bY22PBHljnT/GWnIpZwXJ1I= X-Google-Smtp-Source: ABdhPJxUQqUd3kyRNEPXS8udz2akGOPLzVPyp4YOft8hU7U+WX2Xl/1BjMVb+D60hhrxz+qNJroj6w== X-Received: by 2002:a1c:220a:: with SMTP id i10mr3099382wmi.102.1612523969039; Fri, 05 Feb 2021 03:19:29 -0800 (PST) Received: from localhost ([2a01:4b00:f419:6f00:7a8e:ed70:5c52:ea3]) by smtp.gmail.com with ESMTPSA id s23sm8399903wmc.35.2021.02.05.03.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 03:19:27 -0800 (PST) From: luca.boccassi@gmail.com To: Dmitry Kozlyuk Cc: Thomas Monjalon , dpdk stable Date: Fri, 5 Feb 2021 11:14:47 +0000 Message-Id: <20210205111920.1272063-1-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'eal/windows: fix build with MinGW-w64 8' has been queued to stable release 20.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/07/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/ab9b79cd737dabf9eb032ca1f328e79f5df85397 Thanks. Luca Boccassi --- >From ab9b79cd737dabf9eb032ca1f328e79f5df85397 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlyuk Date: Tue, 1 Dec 2020 19:39:58 +0300 Subject: [PATCH] eal/windows: fix build with MinGW-w64 8 [ upstream commit 93bf432dd58236235e8a930a108dbcaee81fc5fc ] MinGW-w64 above 8.0.0 exposes VirtualAlloc2() API in headers, but lacks it in import libraries. Hence, availability of this API at compile-time can't be used to choose between locating VirtualAlloc2() manually or relying on the dynamic linker. Fix redefinition compile-time errors. Always link VirtualAlloc2() when using GCC. Fixes: 2a5d547a4a9b ("eal/windows: implement basic memory management") Reported-by: Thomas Monjalon Signed-off-by: Dmitry Kozlyuk Tested-by: Thomas Monjalon --- lib/librte_eal/windows/eal_memory.c | 42 +++++++++++++++-------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/lib/librte_eal/windows/eal_memory.c b/lib/librte_eal/windows/eal_memory.c index 7f8d3c2fa4..2cf5a5e649 100644 --- a/lib/librte_eal/windows/eal_memory.c +++ b/lib/librte_eal/windows/eal_memory.c @@ -18,13 +18,12 @@ #include /* MinGW-w64 headers lack VirtualAlloc2() in some distributions. - * Provide a copy of definitions and code to load it dynamically. * Note: definitions are copied verbatim from Microsoft documentation * and don't follow DPDK code style. - * - * MEM_RESERVE_PLACEHOLDER being defined means VirtualAlloc2() is present too. */ -#ifndef MEM_PRESERVE_PLACEHOLDER +#ifndef MEM_EXTENDED_PARAMETER_TYPE_BITS + +#define MEM_EXTENDED_PARAMETER_TYPE_BITS 4 /* https://docs.microsoft.com/en-us/windows/win32/api/winnt/ne-winnt-mem_extended_parameter_type */ typedef enum MEM_EXTENDED_PARAMETER_TYPE { @@ -37,8 +36,6 @@ typedef enum MEM_EXTENDED_PARAMETER_TYPE { MemExtendedParameterMax } *PMEM_EXTENDED_PARAMETER_TYPE; -#define MEM_EXTENDED_PARAMETER_TYPE_BITS 4 - /* https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-mem_extended_parameter */ typedef struct MEM_EXTENDED_PARAMETER { struct { @@ -54,6 +51,8 @@ typedef struct MEM_EXTENDED_PARAMETER { } DUMMYUNIONNAME; } MEM_EXTENDED_PARAMETER, *PMEM_EXTENDED_PARAMETER; +#endif /* defined(MEM_EXTENDED_PARAMETER_TYPE_BITS) */ + /* https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualalloc2 */ typedef PVOID (*VirtualAlloc2_type)( HANDLE Process, @@ -65,17 +64,19 @@ typedef PVOID (*VirtualAlloc2_type)( ULONG ParameterCount ); -/* VirtualAlloc2() flags. */ +/* MinGW-w64 distributions, even those that declare VirtualAlloc2(), + * lack it in import libraries, which results in a failure at link time. + * Link it dynamically in such case. + */ +static VirtualAlloc2_type VirtualAlloc2_ptr; + +#ifdef RTE_TOOLCHAIN_GCC + #define MEM_COALESCE_PLACEHOLDERS 0x00000001 #define MEM_PRESERVE_PLACEHOLDER 0x00000002 #define MEM_REPLACE_PLACEHOLDER 0x00004000 #define MEM_RESERVE_PLACEHOLDER 0x00040000 -/* Named exactly as the function, so that user code does not depend - * on it being found at compile time or dynamically. - */ -static VirtualAlloc2_type VirtualAlloc2; - int eal_mem_win32api_init(void) { @@ -89,7 +90,7 @@ eal_mem_win32api_init(void) int ret = 0; /* Already done. */ - if (VirtualAlloc2 != NULL) + if (VirtualAlloc2_ptr != NULL) return 0; library = LoadLibraryA(library_name); @@ -98,9 +99,9 @@ eal_mem_win32api_init(void) return -1; } - VirtualAlloc2 = (VirtualAlloc2_type)( + VirtualAlloc2_ptr = (VirtualAlloc2_type)( (void *)GetProcAddress(library, function)); - if (VirtualAlloc2 == NULL) { + if (VirtualAlloc2_ptr == NULL) { RTE_LOG_WIN32_ERR("GetProcAddress(\"%s\", \"%s\")\n", library_name, function); @@ -117,14 +118,15 @@ eal_mem_win32api_init(void) #else -/* Stub in case VirtualAlloc2() is provided by the compiler. */ +/* Stub in case VirtualAlloc2() is provided by the toolchain. */ int eal_mem_win32api_init(void) { + VirtualAlloc2_ptr = VirtualAlloc2; return 0; } -#endif /* defined(MEM_RESERVE_PLACEHOLDER) */ +#endif /* defined(RTE_TOOLCHAIN_GCC) */ static HANDLE virt2phys_device = INVALID_HANDLE_VALUE; @@ -278,7 +280,7 @@ eal_mem_reserve(void *requested_addr, size_t size, int flags) process = GetCurrentProcess(); - virt = VirtualAlloc2(process, requested_addr, size, + virt = VirtualAlloc2_ptr(process, requested_addr, size, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER, PAGE_NOACCESS, NULL, 0); if (virt == NULL) { @@ -364,7 +366,7 @@ eal_mem_commit(void *requested_addr, size_t size, int socket_id) } flags = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES; - addr = VirtualAlloc2(process, requested_addr, size, + addr = VirtualAlloc2_ptr(process, requested_addr, size, flags, PAGE_READWRITE, ¶m, param_count); if (addr == NULL) { /* Logging may overwrite GetLastError() result. */ @@ -406,7 +408,7 @@ eal_mem_decommit(void *addr, size_t size) } flags = MEM_RESERVE | MEM_RESERVE_PLACEHOLDER; - stub = VirtualAlloc2( + stub = VirtualAlloc2_ptr( process, addr, size, flags, PAGE_NOACCESS, NULL, 0); if (stub == NULL) { /* We lost the race for the VA. */ -- 2.29.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-02-05 11:18:29.417643482 +0000 +++ 0001-eal-windows-fix-build-with-MinGW-w64-8.patch 2021-02-05 11:18:28.582686848 +0000 @@ -1 +1 @@ -From 93bf432dd58236235e8a930a108dbcaee81fc5fc Mon Sep 17 00:00:00 2001 +From ab9b79cd737dabf9eb032ca1f328e79f5df85397 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 93bf432dd58236235e8a930a108dbcaee81fc5fc ] + @@ -15 +16,0 @@ -Cc: stable@dpdk.org