From patchwork Fri Dec 3 16:46:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 15014 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 20A40BF415 for ; Fri, 3 Dec 2021 16:46:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C8B4860868; Fri, 3 Dec 2021 17:46:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Hqrp0BWW"; dkim-atps=neutral Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3B51560725 for ; Fri, 3 Dec 2021 17:46:28 +0100 (CET) Received: by mail-pf1-x42e.google.com with SMTP id g19so3428253pfb.8 for ; Fri, 03 Dec 2021 08:46:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y52fm6Sy+pHSqMgq0LX0xKuz3zoSutkdmb2WDagTxcM=; b=Hqrp0BWW8/0cDa0fZAaeq/nY4o21bqDjLbxTaIhJTIap8i/bQJtdPkFKJidn6uWZY5 AMYQxq10qOpveemj8Cj2H9lqWH/7ctcVt2jMvxXd2ImjmBQQpBCLl3bDpLDN6eC5A9E4 J3/8Pw0Q9uf59mVYxvvrU9ctjdpdoor+urYQ8= 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=Y52fm6Sy+pHSqMgq0LX0xKuz3zoSutkdmb2WDagTxcM=; b=aqg8JIZBaxj00FtSdq7ZGWFXk/uGUmX0Ci3FWGHkuKLrN9TxQVFNycadyXEpoLhHd3 +ed9ef7/NJ3ALYGgudNE+BU+5FKbgRgLrKnElxNyG8ef3Y4rPI6dZg83tgvU01DVZg+P 81iaMcsvmHtOPE3nNCSFB1vmHuJ1oZHQPGgEp3jYLJLyM9q6awFHEYJhQYnxtRJG2gom OaaVCYEW3OjMuZnUxbAcUxHjJDCHHNQGblv/DzH/R8K/6FlNTvMrxEBS3O4pXM4hBQ/7 6N9KtZlEvdCiMYnIqWaD+gLlwr/0olITLhOc29HNIUCUPNNx+cDCKu1CXr5eN4dJDcJi DGoQ== X-Gm-Message-State: AOAM530Tb/vR24yHI4VrnfJ8fpUjrdoCMNlPeGfG8nhuqzRkuDvQylMj 7LC0QyoKhkkFT65OdttrS3cq3n6UBaKbBQ== X-Google-Smtp-Source: ABdhPJyDxW4hSLL2pwHyCHCUemjXMmGhrweF0gIunMOn07Ji3Kp6ix3c3jyMLiQe4x8oyjJNQMQKnQ== X-Received: by 2002:a05:6a00:2401:b0:4a8:909:1d01 with SMTP id z1-20020a056a00240100b004a809091d01mr20179154pfh.83.1638549986587; Fri, 03 Dec 2021 08:46:26 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:cd78:3a5f:d792:6177]) by smtp.gmail.com with ESMTPSA id h18sm4123149pfh.172.2021.12.03.08.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 08:46:26 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Dec 2021 01:46:13 +0900 Message-Id: <20211203164619.1541033-2-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.384.gca35af8252-goog In-Reply-To: <20211203164619.1541033-1-hiroh@chromium.org> References: <20211203164619.1541033-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/7] libcamera: base: semaphore: Apply clang thread safety annotation X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This annotates member functions and variables of Semaphore by clang thread safety annotations. Signed-off-by: Hirokazu Honda --- include/libcamera/base/semaphore.h | 10 +++++----- src/libcamera/base/semaphore.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/libcamera/base/semaphore.h b/include/libcamera/base/semaphore.h index c11e8dd1..f1052317 100644 --- a/include/libcamera/base/semaphore.h +++ b/include/libcamera/base/semaphore.h @@ -18,15 +18,15 @@ class Semaphore public: Semaphore(unsigned int n = 0); - unsigned int available(); - void acquire(unsigned int n = 1); - bool tryAcquire(unsigned int n = 1); - void release(unsigned int n = 1); + unsigned int available() LIBCAMERA_TSA_EXCLUDES(mutex_); + void acquire(unsigned int n = 1) LIBCAMERA_TSA_EXCLUDES(mutex_); + bool tryAcquire(unsigned int n = 1) LIBCAMERA_TSA_EXCLUDES(mutex_); + void release(unsigned int n = 1) LIBCAMERA_TSA_EXCLUDES(mutex_); private: Mutex mutex_; ConditionVariable cv_; - unsigned int available_; + unsigned int available_ LIBCAMERA_TSA_GUARDED_BY(mutex_); }; } /* namespace libcamera */ diff --git a/src/libcamera/base/semaphore.cpp b/src/libcamera/base/semaphore.cpp index 4fe30293..1e1c2efa 100644 --- a/src/libcamera/base/semaphore.cpp +++ b/src/libcamera/base/semaphore.cpp @@ -56,7 +56,7 @@ unsigned int Semaphore::available() void Semaphore::acquire(unsigned int n) { MutexLocker locker(mutex_); - cv_.wait(locker, [&] { return available_ >= n; }); + cv_.wait(locker, [&]() LIBCAMERA_TSA_REQUIRES(mutex_) { return available_ >= n; }); available_ -= n; }