{"id":15014,"url":"https://patchwork.libcamera.org/api/1.1/patches/15014/?format=json","web_url":"https://patchwork.libcamera.org/patch/15014/","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":"<20211203164619.1541033-2-hiroh@chromium.org>","date":"2021-12-03T16:46:13","name":"[libcamera-devel,1/7] libcamera: base: semaphore: Apply clang thread safety annotation","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"c52c7e170fe6dd8219344cab76566079478e925a","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15014/mbox/","series":[{"id":2812,"url":"https://patchwork.libcamera.org/api/1.1/series/2812/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2812","date":"2021-12-03T16:46:12","name":"Apply clang thread safety annotation libcamera-core and v4l2","version":1,"mbox":"https://patchwork.libcamera.org/series/2812/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15014/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15014/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 20A40BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 Dec 2021 16:46:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C8B4860868;\n\tFri,  3 Dec 2021 17:46:31 +0100 (CET)","from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com\n\t[IPv6:2607:f8b0:4864:20::42e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3B51560725\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Dec 2021 17:46:28 +0100 (CET)","by mail-pf1-x42e.google.com with SMTP id g19so3428253pfb.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 03 Dec 2021 08:46:28 -0800 (PST)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:cd78:3a5f:d792:6177])\n\tby smtp.gmail.com with ESMTPSA id\n\th18sm4123149pfh.172.2021.12.03.08.46.25\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 03 Dec 2021 08:46:26 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"Hqrp0BWW\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=Y52fm6Sy+pHSqMgq0LX0xKuz3zoSutkdmb2WDagTxcM=;\n\tb=Hqrp0BWW8/0cDa0fZAaeq/nY4o21bqDjLbxTaIhJTIap8i/bQJtdPkFKJidn6uWZY5\n\tAMYQxq10qOpveemj8Cj2H9lqWH/7ctcVt2jMvxXd2ImjmBQQpBCLl3bDpLDN6eC5A9E4\n\tJ3/8Pw0Q9uf59mVYxvvrU9ctjdpdoor+urYQ8=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=Y52fm6Sy+pHSqMgq0LX0xKuz3zoSutkdmb2WDagTxcM=;\n\tb=aqg8JIZBaxj00FtSdq7ZGWFXk/uGUmX0Ci3FWGHkuKLrN9TxQVFNycadyXEpoLhHd3\n\t+ed9ef7/NJ3ALYGgudNE+BU+5FKbgRgLrKnElxNyG8ef3Y4rPI6dZg83tgvU01DVZg+P\n\t81iaMcsvmHtOPE3nNCSFB1vmHuJ1oZHQPGgEp3jYLJLyM9q6awFHEYJhQYnxtRJG2gom\n\tOaaVCYEW3OjMuZnUxbAcUxHjJDCHHNQGblv/DzH/R8K/6FlNTvMrxEBS3O4pXM4hBQ/7\n\t6N9KtZlEvdCiMYnIqWaD+gLlwr/0olITLhOc29HNIUCUPNNx+cDCKu1CXr5eN4dJDcJi\n\tDGoQ==","X-Gm-Message-State":"AOAM530Tb/vR24yHI4VrnfJ8fpUjrdoCMNlPeGfG8nhuqzRkuDvQylMj\n\t7LC0QyoKhkkFT65OdttrS3cq3n6UBaKbBQ==","X-Google-Smtp-Source":"ABdhPJyDxW4hSLL2pwHyCHCUemjXMmGhrweF0gIunMOn07Ji3Kp6ix3c3jyMLiQe4x8oyjJNQMQKnQ==","X-Received":"by 2002:a05:6a00:2401:b0:4a8:909:1d01 with SMTP id\n\tz1-20020a056a00240100b004a809091d01mr20179154pfh.83.1638549986587; \n\tFri, 03 Dec 2021 08:46:26 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 1/7] 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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"This annotates member functions and variables of Semaphore by\nclang thread safety annotations.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\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","1/7"]}