From patchwork Sun Mar 20 17:11:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553196 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp883605mag; Sun, 20 Mar 2022 10:32:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXnDIcIKeghHo0Vwjbr9U0c5rf6x5iNpZZXmkMVbuzu5UCSerw3fJHtlvWrnMi1tlo0slH X-Received: by 2002:a37:86c2:0:b0:506:cfe7:ce67 with SMTP id i185-20020a3786c2000000b00506cfe7ce67mr10854523qkd.564.1647797546275; Sun, 20 Mar 2022 10:32:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647797546; cv=none; d=google.com; s=arc-20160816; b=T8WlC1E+W0mey2t4YXo9XcE88yflZu0Jka6TyNx5KtVk5mn7oyHIZfB3SET08KIlUc He++U1ZIGsjfeDUfdzazbTQDRn/N/t/GHM+QJmPbpfcXXRcPzVmfmBVV/L0LKsQ8P6gL yiVxFFzX6BbPldFrPfZiILegrTz7um8YMIngYd5euJb/3qhA2B2LEjGFCZ2CmHroULXf voIn3CeMd9xv/a5KVcgkI6/GIYHuJRwVcTB1ni5E3+f+JQUnGgmZU08c8tVkY39P1Xbg IIZXzJdJIiRA2FMuyJHSWRIYTiKJCCu2kam3K8aMwUOQ0XJn5hq9xu9WuizeVtei343C tFhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Hu9aRYzYIgbIdzSTEVhW4soYbAG6jLfuaaPgAkD8sGQ=; b=zvBAiNVurhOdlNUnIxLKQkcyqQL+1++U4S6VBlNtEKJv4Dbp8PiQCr+S00HrWG3J4B s007FMBoQsGKDPDvT3sRn9tzRXlTr4ZvrM09/0H5P1ezNCFo01ee2bxyHOXBirhti8qS 7mtE/tIqaApEEgg9Cxz2vd4KONgoNm9/Jt2Lx4SrtBXNNPvLtMPl40hvBTH7WJM8vo1T IgH0Uh6dlliE17BoFLp904+y+OF6n9W9v5MbFzylp64EYk09uth9IPD/u+3SjHagICfH R7RzzYKLQWUoIVEz63Zd3bXzAm66ZQ2gz7M9wubbqNoJYEHxZ+D6LlKkBOAt1Dgcej5r +kaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qh8huIxA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c10-20020ac87dca000000b002e1fbf3bf3csi1446840qte.301.2022.03.20.10.32.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:32:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qh8huIxA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVzPl-0003Rd-TG for patch@linaro.org; Sun, 20 Mar 2022 13:32:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz61-00005p-5U for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:01 -0400 Received: from [2607:f8b0:4864:20::629] (port=38687 helo=mail-pl1-x629.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5y-0003UG-VD for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:12:00 -0400 Received: by mail-pl1-x629.google.com with SMTP id n18so10885446plg.5 for ; Sun, 20 Mar 2022 10:11:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hu9aRYzYIgbIdzSTEVhW4soYbAG6jLfuaaPgAkD8sGQ=; b=Qh8huIxAEYt/Z5x1IVM0vM3opFwm3z+Tgu5TIUEWkya8omECsefqapLtx7I/4ytWK7 YOJnoofFhl9GTJqGxChRneDsU/CzxiBWaYYikeeurItuT8UVJHh8Yo33Jl/6yaJGYykC cRwxxOsOYfc/Rji252uBe6/LlTUli+HPrPSMlqqMnLrTPS7mSlBwsfyhvglNNCpLHpMl WsPGiKysbeKAjL2InlufLz25KM++AUG1r5D5akLelTIisvVJvE5JwGPNhQPUneOnCgYy i1ZKgkSuBdC9xZawhzNm1U4lX1ddclFvm0vg2nBQXzmRlsxY/5r+bmt6l4+H/f4A1CJf UEYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hu9aRYzYIgbIdzSTEVhW4soYbAG6jLfuaaPgAkD8sGQ=; b=Qm+Rof4+u7rBTwCAi6n6CumiLEA/6eYHXP2vEwzasNoKoOSUbg5HwXW6K/QPNywCxB e2AMleDLRKYFT3rSv01AgGsm4H1MZsFQypWEaecUuRH/GwmRpxI/H+D6AXnpu8oxYSVU kaoAl3/cpB85ZNnOtME/IqIEpXwJk6exBzcFRFras7B7pI7V0symMlVWPv67SSTmAPsl WhEOdjAHUMoQU+4EZ4HXVJN6+lN0NT9RrCdcmRu/QIOhs8tPJxjsn/V9riWbHIBbw8LM JrXa5AZAnWCoKwbtY8651b/Gqd23H5UOvnAx7zQHDQXMedY10ouKxVcV00a9A1FTIzSW I5MA== X-Gm-Message-State: AOAM530idZg8+4cYROCrAm4zalQk++pE5/XaRh9iG/6GGEKcS/bzO6Ar nBvhVvqnOFWls8kT/rgaCrkfyojHwVTOUw== X-Received: by 2002:a17:90b:4b83:b0:1c7:2497:3800 with SMTP id lr3-20020a17090b4b8300b001c724973800mr31537pjb.225.1647796317666; Sun, 20 Mar 2022 10:11:57 -0700 (PDT) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id q12-20020a17090aa00c00b001bc6f1baaaesm17149697pjp.39.2022.03.20.10.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 23/36] sysemu/os-win32: Test for and use _lock_file/_unlock_file Date: Sun, 20 Mar 2022 10:11:22 -0700 Message-Id: <20220320171135.2704502-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220320171135.2704502-1-richard.henderson@linaro.org> References: <20220320171135.2704502-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::629 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The bug referenced in os-win32.h was fixed in mingw-w64 v6. According to repology, version 5 used by ubuntu 18, which is not yet out of support, so provide a meson link test for it. Signed-off-by: Richard Henderson --- meson.build | 12 ++++++++++++ include/sysemu/os-win32.h | 16 +++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 282e7c4650..f22a09dac5 100644 --- a/meson.build +++ b/meson.build @@ -2018,6 +2018,18 @@ foreach k, v: config_host endif endforeach +# Older versions of MinGW do not import _lock_file and _unlock_file properly. +# This was fixed for v6.0.0 with commit b48e3ac8969d. +if targetos == 'windows' + config_host_data.set('HAVE__LOCK_FILE', cc.links(''' + #include + int main(void) { + _lock_file(NULL); + _unlock_file(NULL); + return 0; + }''', name: '_lock_file and _unlock_file')) +endif + ######################## # Target configuration # ######################## diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h index 770752222a..649f417d39 100644 --- a/include/sysemu/os-win32.h +++ b/include/sysemu/os-win32.h @@ -113,20 +113,22 @@ static inline char *realpath(const char *path, char *resolved_path) return resolved_path; } -/* ??? Mingw appears to export _lock_file and _unlock_file as the functions - * with which to lock a stdio handle. But something is wrong in the markup, - * either in the header or the library, such that we get undefined references - * to "_imp___lock_file" etc when linking. Since we seem to have no other - * alternative, and the usage within the logging functions isn't critical, - * ignore FILE locking. +/* + * Older versions of MinGW do not import _lock_file and _unlock_file properly. + * This was fixed for v6.0.0 with commit b48e3ac8969d. */ - static inline void qemu_flockfile(FILE *f) { +#ifdef HAVE__LOCK_FILE + _lock_file(f); +#endif } static inline void qemu_funlockfile(FILE *f) { +#ifdef HAVE__LOCK_FILE + _unlock_file(f); +#endif } /* We wrap all the sockets functions so that we can