{"id":16288,"url":"https://patchwork.libcamera.org/api/1.1/patches/16288/?format=json","web_url":"https://patchwork.libcamera.org/patch/16288/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220620165027.549085-2-umang.jain@ideasonboard.com>","date":"2022-06-20T16:50:23","name":"[libcamera-devel,v2,1/5] libcamera: base: semaphore: Apply clang thread safety annotation","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"c52c7e170fe6dd8219344cab76566079478e925a","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/1.1/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":{"id":12,"url":"https://patchwork.libcamera.org/api/1.1/users/12/?format=json","username":"uajain","first_name":"Umang","last_name":"Jain","email":"umang.jain@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/16288/mbox/","series":[{"id":3196,"url":"https://patchwork.libcamera.org/api/1.1/series/3196/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3196","date":"2022-06-20T16:50:22","name":"Apply clang thread safety annotation libcamera-core and v4l2","version":2,"mbox":"https://patchwork.libcamera.org/series/3196/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16288/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16288/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 480ECBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Jun 2022 16:50:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0004765638;\n\tMon, 20 Jun 2022 18:50:40 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F88B65632\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jun 2022 18:50:39 +0200 (CEST)","from perceval.ideasonboard.com (unknown\n\t[IPv6:2401:4900:1f3f:e389:cb58:4104:f66:a571])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2F999883;\n\tMon, 20 Jun 2022 18:50:37 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655743841;\n\tbh=29qR+ILEBTk8VYV8GzzLgjKDhkhjUBFhr2ov/cZBsTQ=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=YFI7m0KgE2EO6DY38TSlS9DIYBFlEheAzK4AnY+VgY4jqvOYBS1BxiLf4I+4t94Cd\n\tuhmvz4r06MN6zY/ts1XT70aM0m4CF3ghGGJ6xwJSjouTorGfnDLmhMXorhHIpw9Wiz\n\tSZoHuSXYWz1/G1otQuB8BfdMGirQmJ70p2XNGjtbYVnLth+j7LyBgetOhTo6Xr9yub\n\tnfKL+Z44ObkNZhe4uo5ZtRV0e+iIJUxS2436rAw023ObeQisakJgF3SMPF7V+wZvef\n\tp4Er9DaqC1X7JxE73mGe0nPktyKRnXBxFyYbR3JN8iMLCDeMh35kdJ7U/64AvyYvk6\n\tSdyT/QMwZP2nA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655743839;\n\tbh=29qR+ILEBTk8VYV8GzzLgjKDhkhjUBFhr2ov/cZBsTQ=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=QOT0c5Q1VFVv/gfasX6LGvJQP8WlUmZH3PmoYTIolf6LgxjSZQW6baGJcWPD2kKOy\n\t9I0YK1QiwH0nOClv3E8Nz7ozRXHdXBti0O+5nIlw1B0FZ5OsTlH75n8NSM71KfQUuZ\n\tU/2G/DnCJV+6qQoRRnOkNn9B1/LoUSXWBoLg/QJw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"QOT0c5Q1\"; dkim-atps=neutral","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 1/5] libcamera: base: semaphore: Apply\n\tclang thread safety annotation","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Umang Jain <umang.jain@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Hirokazu Honda <hiroh@chromium.org>\n\nThis annotates member functions and variables of Semaphore by\nclang thread safety annotations.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n include/libcamera/base/semaphore.h | 10 +++++-----\n src/libcamera/base/semaphore.cpp   |  2 +-\n 2 files changed, 6 insertions(+), 6 deletions(-)","diff":"diff --git a/include/libcamera/base/semaphore.h b/include/libcamera/base/semaphore.h\nindex c11e8dd1..f1052317 100644\n--- a/include/libcamera/base/semaphore.h\n+++ b/include/libcamera/base/semaphore.h\n@@ -18,15 +18,15 @@ class Semaphore\n public:\n \tSemaphore(unsigned int n = 0);\n \n-\tunsigned int available();\n-\tvoid acquire(unsigned int n = 1);\n-\tbool tryAcquire(unsigned int n = 1);\n-\tvoid release(unsigned int n = 1);\n+\tunsigned int available() LIBCAMERA_TSA_EXCLUDES(mutex_);\n+\tvoid acquire(unsigned int n = 1) LIBCAMERA_TSA_EXCLUDES(mutex_);\n+\tbool tryAcquire(unsigned int n = 1) LIBCAMERA_TSA_EXCLUDES(mutex_);\n+\tvoid release(unsigned int n = 1) LIBCAMERA_TSA_EXCLUDES(mutex_);\n \n private:\n \tMutex mutex_;\n \tConditionVariable cv_;\n-\tunsigned int available_;\n+\tunsigned int available_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/base/semaphore.cpp b/src/libcamera/base/semaphore.cpp\nindex 4fe30293..1e1c2efa 100644\n--- a/src/libcamera/base/semaphore.cpp\n+++ b/src/libcamera/base/semaphore.cpp\n@@ -56,7 +56,7 @@ unsigned int Semaphore::available()\n void Semaphore::acquire(unsigned int n)\n {\n \tMutexLocker locker(mutex_);\n-\tcv_.wait(locker, [&] { return available_ >= n; });\n+\tcv_.wait(locker, [&]() LIBCAMERA_TSA_REQUIRES(mutex_) { return available_ >= n; });\n \tavailable_ -= n;\n }\n \n","prefixes":["libcamera-devel","v2","1/5"]}