From patchwork Wed Apr 20 18:06:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563985 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4409498map; Wed, 20 Apr 2022 11:22:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCI8UBnk2uFZBiLNsIZDkEzKsDjNpj1TDpxwFLZtRgB0UbiH+Tow2PR9bva7E2EoJoh7J2 X-Received: by 2002:a25:b92:0:b0:641:d7cc:8ee1 with SMTP id 140-20020a250b92000000b00641d7cc8ee1mr21928063ybl.243.1650478949989; Wed, 20 Apr 2022 11:22:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478949; cv=none; d=google.com; s=arc-20160816; b=ue1/B8E56nzBJQJOiRsxp8FXb+1jSozzqWsiyhRqJ0AfLXmS1YSpe8zQa28Imsg5eG 4xJfVxPlQqHNqjdOn4E/3gqe2vXIwQyyCXxijDdZRvjrUYBvONuw83zJXRFWMsKK5mZC ome2DTlbZ8WtKKqJJwT+6+2Rh4nIgvSD9ryV1RPy8XBOn7KiM4DKDji5cUcv/sA/ypgz ckNeJmzAhacAMbZpUzu12qUGfMieNQWk7BAji+vyEo+cp61o52+y8IhF/Nouiycz4cye tTTKP4DGnG0Pl8As7wp34PBhZJVHaBDpMjOQ0D8t9tl4z0+6nefmBG3sr6D/Jpr3P12l AXgg== 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=U9WvSSPQfsR19RuOaY3NyKfhfBva7JRzInAY9nQW5DY=; b=uf8182prbDv6Rp9qxjkxnxCKDj5EUmcfD/sJ2sw2OxJeXCSNULpiW8LhzdfcWuSpcX hJQxpDqLb0tb1VtNG0XrdSId1oBoImnimZllNoFtjJI12FOPjAczwF0K3+UiJhm3CfWO a7CZRxP2Qah9Dgnu9Ey74z7gqqAmzFE7zh03D9p/LonvVaToFOpV7upfeVzvok67JZPT LTXb8evrKFHbegxG1qUInRSNEu1E/sG5W8QWvEs7sLItgmTZsrTjLHpM5D5fNZCCZ4U0 mlDXQxBlKm7UiM6mI2GPAdvSs6ve+ypGL9PChp521bFOdWTWmElkSGTRPRDqL8jqJD0J grSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hAFXpV1t; 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 4-20020a250a04000000b00641199e4635si478933ybk.668.2022.04.20.11.22.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:22:29 -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=hAFXpV1t; 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]:40384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEyD-0005MO-Ev for patch@linaro.org; Wed, 20 Apr 2022 14:22:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEj4-000675-7O for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:50 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:46003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEj2-0001Li-JY for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:49 -0400 Received: by mail-pf1-x42b.google.com with SMTP id h1so2659593pfv.12 for ; Wed, 20 Apr 2022 11:06:48 -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=U9WvSSPQfsR19RuOaY3NyKfhfBva7JRzInAY9nQW5DY=; b=hAFXpV1t8Uno/zs89Clh7l9W6Ia24SYh7+sjTyrIXlA1IrCok6ZXF7QzD9OMMgwLSs xADe0miOaI7Y/FaOoDnHx/3e0k4n9nBlXj7pkyDKB3GD71elasMHwjVQhaqF7x3XtHYm Y7oRI+7C55n28Muc/A4cSwS1XVRHF4Vr/jtr13tHypZEk2c/y8CkB6Tvm4xlzRti5VnS XKRoAYllehsorSqwYWTPva1eu4+M4HMmonIW9js7H4Zvx+KPV4HxxFvyKFurYluN+ITc e+mUyB8xgnbBku4ZneUh26XPScwN0L0KnLWxroT/lueOiMeuoipS+hDxolM5h+XY8Hk+ X6sQ== 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=U9WvSSPQfsR19RuOaY3NyKfhfBva7JRzInAY9nQW5DY=; b=ycNYXesIkamYJ6qQhUBbC4pdjdWAvNC/+F1w3rlMfb6sna3sT31j6HVMEYfDcE/ieK 0dW1wxCk07ptD6g5UOL5TwUMftCWDtBudmAptn6yD0/DajWKoetB5+kCjzifyJ4AZvxG 5o9PBVvVu2EXNugCGMgf7hOV7YR03yVa6jU0wqKooI7cCS+CpncfYs+/nUPmwJNN5x8S 23jNFnaSJLtEg5hO5j7BGNC7C4BQuxq8c0RnD/Hhopy2r54lYyJbEykPyAiygl7SKEc5 okrnqKZj+L4fkTPU1YmgkbX9FKsgneb4YWt40ZNWzKQwQhgfLBhjJIvFxzSAVgRakpYT sCdA== X-Gm-Message-State: AOAM532dF71XDyyRKN6wdEftoZw/AOdCrDrXpqeLgBIvJ44NZeMl+58X JTbliuzK/WOQJRsVCrmhkQ4pVKzK/nM4Ng== X-Received: by 2002:a63:5917:0:b0:39c:c450:3143 with SMTP id n23-20020a635917000000b0039cc4503143mr20409939pgb.531.1650478007104; Wed, 20 Apr 2022 11:06:47 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 26/39] sysemu/os-win32: Test for and use _lock_file/_unlock_file Date: Wed, 20 Apr 2022 11:06:05 -0700 Message-Id: <20220420180618.1183855-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: =?utf-8?q?Alex_Benn=C3=A9e?= 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. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-27-richard.henderson@linaro.org> --- 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 6ba60950c8..d083c6b7bf 100644 --- a/meson.build +++ b/meson.build @@ -2030,6 +2030,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 3c74a78e33..edc3b38a57 100644 --- a/include/sysemu/os-win32.h +++ b/include/sysemu/os-win32.h @@ -109,20 +109,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