From patchwork Fri Jun 11 23:33:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 458527 Delivered-To: patch@linaro.org Received: by 2002:a17:907:7409:0:0:0:0 with SMTP id gj9csp701334ejc; Fri, 11 Jun 2021 16:37:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlW0oaQqu1d/cGoHyG+4xb93vA4iueZ5du6gMgPmTlogmpClBR093pL+9dC8ihuFWU84ED X-Received: by 2002:aed:2162:: with SMTP id 89mr6277394qtc.182.1623454651509; Fri, 11 Jun 2021 16:37:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623454651; cv=none; d=google.com; s=arc-20160816; b=PVkcYkh+BczzFHMh/mqvLHBJrdvtp5yA3/xK1bq0xc+SfuZkzXNWXQTQfow8rWzVTp 94F0Tmz+ZqRFijM0yfLxE0QsiQPraIRPkMuPANA3I66IyKWLwQybuw1FUOLf+Yv6hTM5 vc1dgyaJw+tq+tOM96HvoCzHbvSsqZ0ABxMll8lejl7DlO+36UJyxtLwlzxbLtfNIp0V 0mCwypDu2S6ia/VzAAnqqcqYVJfGaWl1KIjRy/o2BYIpSYCdOz52nMCguALVL++22oec g2cBdXal3dQLUSqERC7Ruwkq2Tx8fIYlqmEPlx82ln2feIYq0bkPYCiZR2DxdMhyxHce +8lw== 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=z8lCeI6CyIoQ0CotuHE5M+TRtTyS3/YGRMYX2q8e+24=; b=uKx+4kRJ0lytWpGA/CjfXjCImqc0DkGAxL3Vum9v8MwnfmlVJ9Ymz6ylMUs2nn8fP+ Thr9E7+bp1RYfYiZrTJtIRAamriWf1TfXkA4vh3kisQ1X2NwWgRDMrfVFbJ7wcwkkh32 yaZDngWHZlwDMgAwO6tn/jQAHqNSOfRScu1rrf/W0cEchF1Zy9DLqokiJ/67z3m7kzgs lKXgH8Y0aoGeTyROcOy2CjE+qogY3T7CPrZV6hrCZkBX8jYgyyn+AvYyEf5bRM05BcsR Wov/sgxjTu9b9E25xlUJtosvujnuJn7aBpXGXt2gp2700KoZRCvh0n2l9wLRRP7kzqH8 DtBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="kby2S/sp"; 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=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l23si4672711qkk.182.2021.06.11.16.37.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Jun 2021 16:37:31 -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=@linaro.org header.s=google header.b="kby2S/sp"; 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=linaro.org Received: from localhost ([::1]:35252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrqiQ-0001hY-SX for patch@linaro.org; Fri, 11 Jun 2021 19:37:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46032) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrqey-0004Jt-5k for qemu-devel@nongnu.org; Fri, 11 Jun 2021 19:33:56 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:45988) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lrqeu-0006QQ-H3 for qemu-devel@nongnu.org; Fri, 11 Jun 2021 19:33:55 -0400 Received: by mail-pg1-x533.google.com with SMTP id q15so3633835pgg.12 for ; Fri, 11 Jun 2021 16:33:52 -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=z8lCeI6CyIoQ0CotuHE5M+TRtTyS3/YGRMYX2q8e+24=; b=kby2S/spQhVox3R8AU7UJp27SrU3Qr5u/xqdVI55zkBDOj+mEfYe3u+z3VchWX0al/ y+cIJREEgWGm3xvS3y0Xml7KFBQJEMqTcGOyDWEgf8w7Y0no00lqkLqJUgYVy+9nieZO gJvVgnDgwIbsweGSM4S9olcBT7jh+mley4QyYFA9rXnhgMiR4ZbyHf/S2ZSe8KwZ5uVY a8UhknRfq5aRz5GUiBvuSEbLs1xfMW/5kYw31YDxLl0ZSdYTKBtYL6xV8n0SE9QSwnkp NEVu4ejUwKWo3vmTIzvMMafeLB9aa34g961zl4LM0nblO/0cT0K5M7TU1jKqJqtFY0Cl bd6A== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=z8lCeI6CyIoQ0CotuHE5M+TRtTyS3/YGRMYX2q8e+24=; b=mQMaNJqnMfFdy8B5KzWzkcGJZHdZkxaUdEW7jeQoi9Q6V1jqiyUFoyTYZDejAkl6Re fpgJKOnwDnNJ/FmFv2ltKD/6rrNVFvWev6JxxPPZUioNAf1qa5oqlcUis+awnIbbhyVt 3G/b/7GXIjZp5o1CsvJmvg7pzMduOkIHM4jRmJCHRWcidb8QwKwx9OiFppO+oga3Bp8P mbSbjKN4g/4kBOiR6DVRgKYOi4LyRI80mXQZ5jd6Xj41GI96LIXsI57lOdF3dH09uC6B Hi1FxqP5J5Pq424yY25Yk/W1XjfQ5msxvNoFOer8Mda2TfB9dI6pSeZthtUwSI7smdY9 gjOw== X-Gm-Message-State: AOAM533Dzq2BDSFL8CMyRbWdPw744ht18jgsCQuVYgMnTd2K1Pvswx9j CbeV00R4KSbfzYgWQkVCHJXdvBwBRO12kw== X-Received: by 2002:a63:c047:: with SMTP id z7mr5957626pgi.186.1623454431216; Fri, 11 Jun 2021 16:33:51 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id m134sm6349606pfd.148.2021.06.11.16.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 16:33:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 5/8] util: Use unique type for QemuRecMutex in thread-posix.h Date: Fri, 11 Jun 2021 16:33:44 -0700 Message-Id: <20210611233347.653129-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210611233347.653129-1-richard.henderson@linaro.org> References: <20210611233347.653129-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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 autolearn=ham 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: pbonzini@redhat.com, thuth@redhat.com, ehabkost@redhat.com, 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 --- include/qemu/thread-posix.h | 10 ++++++++-- util/qemu-thread-posix.c | 12 ++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) -- 2.25.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)