{"id":17753,"url":"https://patchwork.libcamera.org/api/patches/17753/?format=json","web_url":"https://patchwork.libcamera.org/patch/17753/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20221103132041.64644-2-umang.jain@ideasonboard.com>","date":"2022-11-03T13:20:37","name":"[libcamera-devel,v3,1/5] libcamera: base: semaphore: Apply clang thread safety annotation","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"8330acd3aba46121b2a46c7051cb8378a060601e","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":{"id":12,"url":"https://patchwork.libcamera.org/api/users/12/?format=json","username":"uajain","first_name":"Umang","last_name":"Jain","email":"umang.jain@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/17753/mbox/","series":[{"id":3596,"url":"https://patchwork.libcamera.org/api/series/3596/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3596","date":"2022-11-03T13:20:36","name":"Apply clang thread safety annotation libcamera-core and v4l2","version":3,"mbox":"https://patchwork.libcamera.org/series/3596/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17753/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17753/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 F1EFBC3285\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  3 Nov 2022 13:20:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7E72A63081;\n\tThu,  3 Nov 2022 14:20:53 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1088261F42\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  3 Nov 2022 14:20:52 +0100 (CET)","from umang.jainideasonboard.com (unknown [103.251.226.107])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D98334B2;\n\tThu,  3 Nov 2022 14:20:49 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1667481653;\n\tbh=xehfdJ8bkEZHFwHbUtXONtyLqRSwjY8EfbL0qgWYzUc=;\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=GihTOB2QJ/H/SHN+TdjwvQwsA/l8Bq/QDrc1rc3FLyKJmROjAloI056cuLRGPiFXS\n\t6kPAI6kaAD58E1Ro3S/JLL8YNjJo/xvLnylGjJzA0TUzsuNzcPhAKzrFtpN6fYToaW\n\tYh5d5drT6/h0UlBYvUiU794X1E62FHWRUg2ZV24G5vjt7KxIoQc8ZPf9k8I9iWhqVT\n\teFvZJ060i2FJWqDvLWuuQ/DasHOcZ71V7jufzbi1DMa6PBvt7pwjHbDyAfmvhvvrNQ\n\tinFzZMNoeLx63m+jcWa+bNwKrlgejCg46mHKp/fGCGTimBqgmNyRHe2P3hWiRpu4Ct\n\tdMUMAuJG7NusQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1667481651;\n\tbh=xehfdJ8bkEZHFwHbUtXONtyLqRSwjY8EfbL0qgWYzUc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=SXqdvjWpzyYQgdeN0iqQUH9qOzfNoHK2gcIspM32p58uUGcVbLfUkXQlHJHUPCr4K\n\tD71z1IvYb4whWEL2I0FXRYWFfLklEMdLYQUNUHL9Cbb4M9g58nymlf+jyHllfHQD0N\n\tlfFj/S9x890xfrnEjGOzDieqPNXc29f2AxaIPXIg="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"SXqdvjWp\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  3 Nov 2022 18:50:37 +0530","Message-Id":"<20221103132041.64644-2-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.37.3","In-Reply-To":"<20221103132041.64644-1-umang.jain@ideasonboard.com>","References":"<20221103132041.64644-1-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 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>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n include/libcamera/base/semaphore.h | 10 +++++-----\n src/libcamera/base/semaphore.cpp   |  4 +++-\n 2 files changed, 8 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..6217e386 100644\n--- a/src/libcamera/base/semaphore.cpp\n+++ b/src/libcamera/base/semaphore.cpp\n@@ -56,7 +56,9 @@ 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_) {\n+\t\treturn available_ >= n;\n+\t});\n \tavailable_ -= n;\n }\n \n","prefixes":["libcamera-devel","v3","1/5"]}