From nobody Wed Feb 11 07:13:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1650222690; cv=none; d=zohomail.com; s=zohoarc; b=lWE3W4//ozJYepmFnN8bhBluzyRq8ji6e+n2EbyiBX1BbHCbat6SL2iaG5D6MXSsAHIFyI/4S02LtLUrOddx8GVoFFur4kb7Rlt41VeDNSPUYQ5BMIHrRZzBbp4+1v0Ic8oOna41z9S6UYbKcTvgWEIwcrXaFh6tBgcPftgHiA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650222690; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6Sm3bJ8lkkLDndaTXu2LI7WsKQhrLWIrMlSZhSEKk0s=; b=FBVY2npzJzXPHYfkm1HlOlKxK91JKAKiX0EGELi2FdvKS6CQkzVdnO3lgwsQG7THeQgYDVn3KaTZ+wj6+EAYpRKepvZnhtbHlPiQWTK9l2nO31E4WkCOkpdx7BbM0cXefpEi8tZd2SOXvXUYrsaAKv3Nt2Dg2NzUB8biQN8ilCk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1650222690633678.427303802635; Sun, 17 Apr 2022 12:11:30 -0700 (PDT) Received: from localhost ([::1]:50806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngAIz-00082a-Jt for importer@patchew.org; Sun, 17 Apr 2022 15:11:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ng9fb-0000UG-6q for qemu-devel@nongnu.org; Sun, 17 Apr 2022 14:30:52 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:40654) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ng9fY-0001pU-JT for qemu-devel@nongnu.org; Sun, 17 Apr 2022 14:30:46 -0400 Received: by mail-pj1-x102d.google.com with SMTP id md20-20020a17090b23d400b001cb70ef790dso15555409pjb.5 for ; Sun, 17 Apr 2022 11:30:43 -0700 (PDT) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id on10-20020a17090b1d0a00b001d08a7d569csm8154011pjb.56.2022.04.17.11.30.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 11:30:42 -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=6Sm3bJ8lkkLDndaTXu2LI7WsKQhrLWIrMlSZhSEKk0s=; b=eRHWF7Wh8H7SW5zhV2PWB+0Tcv/jH8IDVbSOvtLvZFcowUiJblDlc6mdhLLHGX1IkU Cxt29do+9KGTVxgeb1swWxD6hHnjglmEjYOxj1vFV7v2XtLha8RCLXJGIxZdPTOTQqYc F7sF+Zx5TWr8/pwFz75yP5QbXtOcmg6RR/a/rldtWVDenRamkSYHMcPLPiE16Yaovg0s O/duVtAsOULBXxUWdOFkECUY38aIMF4cBsDUZxFNQ4nA97TK1hzdVyxBwfaAicL7nXh4 b4nGs/bCTJyXU6SQ3RqeYq+T+Mc4XkhrLH6Ll/EAQn5Q7ACgBDTC2ijEBI+Cn+vUu5HX 0ebQ== 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=6Sm3bJ8lkkLDndaTXu2LI7WsKQhrLWIrMlSZhSEKk0s=; b=BJ5u36gJkjFyGZw0/eQNj0jslBE5KgaDKv+Qu+E6PKiTu8cDN0CpKV/16wEJrHcoiU f49a0DdyWOite1sHTPAmlcbB46xgWgO6cnSn0ItSTV9sC5udznI96it7tuDA9CD7+DY8 azlT9VbUcbdyNLevGFTlpMCz27bQHdHxxPABvXOpAKknTILyyeKliDEtJKJLTE4hzuKb GZf0vH2EUts/Spk6C78CuRKouV16jUUuzOjDLfkg0hY4kvUO4fjEPPRw+u+WJZy2YV7p nlwB/EOgqFWjkEeSsSUqkVVg1pLb2oHZN09wFamfoi+5skucyM6ZFfIxcN2Rw7dKwLOz Rs/A== X-Gm-Message-State: AOAM5336YTVEvuY9uq8ZntWNWrDyi4YnNlebjY8AZx5dK297hgPc/B42 W8OCzk7jw3KGtZmVlSNhhtrExj4hov7rQw== X-Google-Smtp-Source: ABdhPJw7YoeLp0uPIlNqbAbwf41SNIhhG0ftPtRqNx5yyvQZxmKnEQ/vihqQ5KgJuz6i3QLd+bd3SQ== X-Received: by 2002:a17:903:1212:b0:156:3ddc:84bd with SMTP id l18-20020a170903121200b001563ddc84bdmr7716980plh.70.1650220242830; Sun, 17 Apr 2022 11:30:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 26/39] sysemu/os-win32: Test for and use _lock_file/_unlock_file Date: Sun, 17 Apr 2022 11:30:06 -0700 Message-Id: <20220417183019.755276-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220417183019.755276-1-richard.henderson@linaro.org> References: <20220417183019.755276-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1650222691964100001 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=C3=A9e 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 861de93c4f..1b8b65f171 100644 --- a/meson.build +++ b/meson.build @@ -2054,6 +2054,18 @@ foreach k, v: config_host endif endforeach =20 +# Older versions of MinGW do not import _lock_file and _unlock_file proper= ly. +# This was fixed for v6.0.0 with commit b48e3ac8969d. +if targetos =3D=3D '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; } =20 -/* ??? 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 marku= p, - * either in the header or the library, such that we get undefined referen= ces - * 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 prope= rly. + * 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 } =20 static inline void qemu_funlockfile(FILE *f) { +#ifdef HAVE__LOCK_FILE + _unlock_file(f); +#endif } =20 /* We wrap all the sockets functions so that we can --=20 2.25.1