From patchwork Mon Jun 20 16:50:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 16288 X-Patchwork-Delegate: umang.jain@ideasonboard.com 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 480ECBE173 for ; Mon, 20 Jun 2022 16:50:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0004765638; Mon, 20 Jun 2022 18:50:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655743841; bh=29qR+ILEBTk8VYV8GzzLgjKDhkhjUBFhr2ov/cZBsTQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=YFI7m0KgE2EO6DY38TSlS9DIYBFlEheAzK4AnY+VgY4jqvOYBS1BxiLf4I+4t94Cd uhmvz4r06MN6zY/ts1XT70aM0m4CF3ghGGJ6xwJSjouTorGfnDLmhMXorhHIpw9Wiz SZoHuSXYWz1/G1otQuB8BfdMGirQmJ70p2XNGjtbYVnLth+j7LyBgetOhTo6Xr9yub nfKL+Z44ObkNZhe4uo5ZtRV0e+iIJUxS2436rAw023ObeQisakJgF3SMPF7V+wZvef p4Er9DaqC1X7JxE73mGe0nPktyKRnXBxFyYbR3JN8iMLCDeMh35kdJ7U/64AvyYvk6 SdyT/QMwZP2nA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F88B65632 for ; Mon, 20 Jun 2022 18:50:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="QOT0c5Q1"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [IPv6:2401:4900:1f3f:e389:cb58:4104:f66:a571]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2F999883; Mon, 20 Jun 2022 18:50:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655743839; bh=29qR+ILEBTk8VYV8GzzLgjKDhkhjUBFhr2ov/cZBsTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QOT0c5Q1VFVv/gfasX6LGvJQP8WlUmZH3PmoYTIolf6LgxjSZQW6baGJcWPD2kKOy 9I0YK1QiwH0nOClv3E8Nz7ozRXHdXBti0O+5nIlw1B0FZ5OsTlH75n8NSM71KfQUuZ U/2G/DnCJV+6qQoRRnOkNn9B1/LoUSXWBoLg/QJw= To: libcamera-devel@lists.libcamera.org Date: Mon, 20 Jun 2022 22:20:23 +0530 Message-Id: <20220620165027.549085-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220620165027.549085-1-umang.jain@ideasonboard.com> References: <20220620165027.549085-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/5] 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: , X-Patchwork-Original-From: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Hirokazu Honda This annotates member functions and variables of Semaphore by clang thread safety annotations. Signed-off-by: Hirokazu Honda Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart --- 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; }