From patchwork Thu Jun 17 09:31:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 462132 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp276865jae; Thu, 17 Jun 2021 02:50:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0FDZxF+WDQzLHAAEpkxkDb+oSlMOELR6L+XcWXBez+wb50wdc/qhCSuk5peaa56gGfhTp X-Received: by 2002:a02:c88a:: with SMTP id m10mr3848045jao.136.1623923411787; Thu, 17 Jun 2021 02:50:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623923411; cv=none; d=google.com; s=arc-20160816; b=bwU2jTd77eNCtcsAM2OpXIzHEmhwHapLWT4iiuaMmawRtwqdSTfokuV4UnKwob4Lk6 Or77KHUONcwUMf2HPC595qrOHMDxlxK75x9lD+fyfkE7NpbNUV5/zWHk3v5E9gOwF50N 0QayD7U/G7egG96YLpLu4M26PGh+Spmq2xJnRDhNAAHCpwjfa8X9pkH4krJem+wplvfs QqrYHHKUDzY/azx2dK5egCl05P9Jf7BNEFKag01sp1OSPixCOSosvHUoBIgV8L4LGwSI VBytMkdnxoPB455ADMcQWbsS8AmWnhYB/qc3aJqeMopwAAPqwjVUKcgQCD7alB/HphK3 MB/Q== 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=JNJr/AA+BlXc1zPZLzRJ8Y7azIDxrXiDPF6G2uWQRjc=; b=y0Ej128YDGr810Mbr54BUyIzqIycM+NUOL98/PVTM4amn0dSmbBw9WoviyPl3/3npC 69/TQlh4D23BofvWws3IY48ykI+N43objlkNu7xSeHOsURvYDkXpsYHo3hByVEJXaqzw Yup6pELSgGTtB9/9fcfsDiO663LnrsfuEK24pcCDon2b8IcrrHyFSnz+iSc9BgHKs5OF cIJKsfqzZmMnTguVl547OWMJvJZPw2D0Oewn52CtV5pEiLO8AK0L8zNsCP0RbMyZfl8h StecztrszR2eYdkIOAXk805jI31V4GMZiW83f1tma3W73YlGebjOVelIEtudtQVQGKQW Uhcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=hEkuoq0t; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l18si5870312jak.5.2021.06.17.02.50.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Jun 2021 02:50:11 -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=fail header.i=@gmail.com header.s=20161025 header.b=hEkuoq0t; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:36738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltof5-0000LG-0X for patch@linaro.org; Thu, 17 Jun 2021 05:50:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltoNd-0003EJ-3w for qemu-devel@nongnu.org; Thu, 17 Jun 2021 05:32:10 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]:40605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltoNb-0006Q3-Ec for qemu-devel@nongnu.org; Thu, 17 Jun 2021 05:32:08 -0400 Received: by mail-ej1-x630.google.com with SMTP id my49so8697533ejc.7 for ; Thu, 17 Jun 2021 02:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JNJr/AA+BlXc1zPZLzRJ8Y7azIDxrXiDPF6G2uWQRjc=; b=hEkuoq0tnrqsRmZtsbEJNE6inmjPOnQS34lWm2RdrqkF9aBR9NUjW/aDSmhPhitmkW jXttsQa0lUVesQIuhDoQzLdId64d0Z3Evexpzh7KKGp9Dsg6s9uqv4UHNQzVwTSamVFP DpvEvzUQkSWHa98fZxxIlRRZOK+MwKs6k5gqzv9QlPltrayKTWN82gUscBcorll8Ck9N ukWx4lMtHZ9PdyiPUjFLkf2OWrm4L5zTa13xWK3T1XHEtCpfcsW3s0XUiL1Jn8CLD1/x vViEP2jYwkP6eHQzv6vbYEe5nYW2ia/cDXY55+qvQnRuHMye1o0D9fAb5hcgjRT4zX3q VDMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=JNJr/AA+BlXc1zPZLzRJ8Y7azIDxrXiDPF6G2uWQRjc=; b=fK5ZvBIy7QCy5En+/O9SxxZNdxFXpe8iIgCOG50sOXrpJnStk0zaBMuiWuzk6rdQvA Qr8WfUXOYe4xpQ7NQEwtoNSvfWcF74Q5fy5AttcFNy3Iyv0HAYdJiMb4N0bcMu0Bv1cy 7JXBpizDTwiTTsk6USvhLF9Sh76uXVHCwmt3bZ+LRA5IW8YqDpA4n7zA6M2UFnoDa998 +sXB3OwACjGNkB8EsvRqLgD8nBXuimtxMYL8rslm7Pv7zJ+Txyf0l7m5E6WWncS94A1S dYRSfeHbibYdYHumCV12IORf7enBQiFEHUC7bSkCRildTwUeqZuqKq+MrB8xK4PSjtz0 LTFg== X-Gm-Message-State: AOAM532KSBMUOHRlEgte5orFyrNJW1EWApbRj/p2Jb0FuGkwp3St9iTD bMwtLvdQkJSw9hVIxetKvZdP7W+Pmp8= X-Received: by 2002:a17:907:1c9e:: with SMTP id nb30mr4278702ejc.0.1623922326208; Thu, 17 Jun 2021 02:32:06 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id m18sm3328140ejx.56.2021.06.17.02.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 02:32:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 42/45] util: Use unique type for QemuRecMutex in thread-posix.h Date: Thu, 17 Jun 2021 11:31:31 +0200 Message-Id: <20210617093134.900014-43-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617093134.900014-1-pbonzini@redhat.com> References: <20210617093134.900014-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x630.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson We will shortly convert lockable.h to _Generic, and we cannot have two compatible types in the same expansion. Wrap QemuMutex in a struct, and unwrap in qemu-thread-posix.c. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée Reviewed-by: Thomas Huth Message-Id: <20210614233143.1221879-6-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- include/qemu/thread-posix.h | 10 ++++++++-- util/qemu-thread-posix.c | 12 ++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) -- 2.31.1 diff --git a/include/qemu/thread-posix.h b/include/qemu/thread-posix.h index cf8bc90468..b792e6ef37 100644 --- a/include/qemu/thread-posix.h +++ b/include/qemu/thread-posix.h @@ -4,8 +4,6 @@ #include #include -typedef QemuMutex QemuRecMutex; - struct QemuMutex { pthread_mutex_t lock; #ifdef CONFIG_DEBUG_MUTEX @@ -15,6 +13,14 @@ struct QemuMutex { bool initialized; }; +/* + * QemuRecMutex cannot be a typedef of QemuMutex lest we have two + * compatible cases in _Generic. See qemu/lockable.h. + */ +typedef struct QemuRecMutex { + QemuMutex m; +} QemuRecMutex; + struct QemuCond { pthread_cond_t cond; bool initialized; diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index d990826ed8..fd9d714038 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -116,32 +116,32 @@ void qemu_rec_mutex_init(QemuRecMutex *mutex) pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - err = pthread_mutex_init(&mutex->lock, &attr); + err = pthread_mutex_init(&mutex->m.lock, &attr); pthread_mutexattr_destroy(&attr); if (err) { error_exit(err, __func__); } - mutex->initialized = true; + mutex->m.initialized = true; } void qemu_rec_mutex_destroy(QemuRecMutex *mutex) { - qemu_mutex_destroy(mutex); + qemu_mutex_destroy(&mutex->m); } void qemu_rec_mutex_lock_impl(QemuRecMutex *mutex, const char *file, int line) { - qemu_mutex_lock_impl(mutex, file, line); + qemu_mutex_lock_impl(&mutex->m, file, line); } int qemu_rec_mutex_trylock_impl(QemuRecMutex *mutex, const char *file, int line) { - return qemu_mutex_trylock_impl(mutex, file, line); + return qemu_mutex_trylock_impl(&mutex->m, file, line); } void qemu_rec_mutex_unlock_impl(QemuRecMutex *mutex, const char *file, int line) { - qemu_mutex_unlock_impl(mutex, file, line); + qemu_mutex_unlock_impl(&mutex->m, file, line); } void qemu_cond_init(QemuCond *cond)