Patch Detail
Show a patch.
GET /api/1.1/patches/14930/?format=api
{ "id": 14930, "url": "https://patchwork.libcamera.org/api/1.1/patches/14930/?format=api", "web_url": "https://patchwork.libcamera.org/patch/14930/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20211201070728.3114247-5-hiroh@chromium.org>", "date": "2021-12-01T07:07:20", "name": "[libcamera-devel,v4,04/12] libcamera: base: Add thread safety annotation macros", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "8002765e49fd7a23f7f9a69ae96080e7f2fd6469", "submitter": { "id": 63, "url": "https://patchwork.libcamera.org/api/1.1/people/63/?format=api", "name": "Hirokazu Honda", "email": "hiroh@chromium.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/14930/mbox/", "series": [ { "id": 2789, "url": "https://patchwork.libcamera.org/api/1.1/series/2789/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2789", "date": "2021-12-01T07:07:16", "name": "Introduce clang thread safety annotations", "version": 4, "mbox": "https://patchwork.libcamera.org/series/2789/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/14930/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/14930/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 E1590BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 1 Dec 2021 07:07:45 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9D2A560718;\n\tWed, 1 Dec 2021 08:07:45 +0100 (CET)", "from mail-pf1-x436.google.com (mail-pf1-x436.google.com\n\t[IPv6:2607:f8b0:4864:20::436])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5FA546072E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 1 Dec 2021 08:07:43 +0100 (CET)", "by mail-pf1-x436.google.com with SMTP id n26so23435997pff.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 23:07:43 -0800 (PST)", "from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:3892:a049:59ba:c772])\n\tby smtp.gmail.com with ESMTPSA id\n\tm10sm16598962pgv.75.2021.11.30.23.07.40\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 30 Nov 2021 23:07:41 -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=\"MXf5iUhT\"; 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=bCrfFSftCVaNJq0QCqjXOGL5JcW2aZUftTC49vcY4y4=;\n\tb=MXf5iUhToaeQIMMYQWbh2guGRwZZIu56+6CpObuXv5jz0lpp802Zhm18DONFvBm9Y8\n\tvtv7kHoeSTESNrqci48EGlDyTN8+GYbtw3ZC7uKhiSCIdseTG9bUQTDmuz83ojo0mqRZ\n\tH1mKLVLKIyCD8/nEAqlXDFnz0kNw/te5X2Lvc=", "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=bCrfFSftCVaNJq0QCqjXOGL5JcW2aZUftTC49vcY4y4=;\n\tb=iJa7f2KJqpQU+Em/sJFrhi11B5SxTKy+jgrDzt+NRiSXwHVHNNp7qeAelTGMWt1dgF\n\tV+VZ+RQi2oINwU0J5ApkYa3j3SOJr+L8Ukq842zTU0vEf15QKApsmMK0KnNaVteCkbCo\n\tY4usXxiF0HDk6EkI6CKny+D3QnXxgSgtIWvN0hn8to/i/9QUeD1xexV5WkvmYQ2P9dCF\n\tP6vD4HqkYb/VTzV1L72Xh59yUTr8abfdlN0GtB9CkNpFPKrG5b3zrCpn1cIe8bYIlaL1\n\tAEtAdfrmgAfOHniXoanEvWdosHN3T8JiKghNvSXkf2bs63Opz50zDmPYfja7HfgDnI09\n\trowA==", "X-Gm-Message-State": "AOAM533PTERgfpryy/RmyMRf6LMnpXCEvsW7POdN+OR5wGwdZ3Egn2v1\n\tSpETMobwrN7gXwFZcXF64HX0SVC3fhJLeA==", "X-Google-Smtp-Source": "ABdhPJwLckxkPYHfAuQC1a49ViG5gITt17rlGYhmqrk0G3pNbxPyHUlGk4sVjwaMR8qi4ibqOiyoWg==", "X-Received": "by 2002:a63:6947:: with SMTP id\n\te68mr3324861pgc.292.1638342461639; \n\tTue, 30 Nov 2021 23:07:41 -0800 (PST)", "From": "Hirokazu Honda <hiroh@chromium.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 1 Dec 2021 16:07:20 +0900", "Message-Id": "<20211201070728.3114247-5-hiroh@chromium.org>", "X-Mailer": "git-send-email 2.34.0.rc2.393.gf8c9666880-goog", "In-Reply-To": "<20211201070728.3114247-1-hiroh@chromium.org>", "References": "<20211201070728.3114247-1-hiroh@chromium.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 04/12] libcamera: base: Add thread\n\tsafety annotation macros", "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": "Clang compiler is able to do a thread safety analysis with\nannotations [1]. This introduces the thread safety annotation\nmacros and also enable the analysis by adding -Wthread-safety\nif a clang compiler is used.\n\n[1] https://clang.llvm.org/docs/ThreadSafetyAnalysis.html.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/base/meson.build | 1 +\n include/libcamera/base/thread_annotations.h | 80 +++++++++++++++++++++\n meson.build | 1 +\n 3 files changed, 82 insertions(+)\n create mode 100644 include/libcamera/base/thread_annotations.h", "diff": "diff --git a/include/libcamera/base/meson.build b/include/libcamera/base/meson.build\nindex 525aba9d..1a71ce5a 100644\n--- a/include/libcamera/base/meson.build\n+++ b/include/libcamera/base/meson.build\n@@ -19,6 +19,7 @@ libcamera_base_headers = files([\n 'signal.h',\n 'span.h',\n 'thread.h',\n+ 'thread_annotations.h',\n 'timer.h',\n 'utils.h',\n ])\ndiff --git a/include/libcamera/base/thread_annotations.h b/include/libcamera/base/thread_annotations.h\nnew file mode 100644\nindex 00000000..e81929f6\n--- /dev/null\n+++ b/include/libcamera/base/thread_annotations.h\n@@ -0,0 +1,80 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Google Inc.\n+ *\n+ * thread_annotation.h - Macro of Clang thread safety analysis\n+ */\n+\n+#pragma once\n+\n+/*\n+ * Enable thread safety attributes only with clang.\n+ * The attributes can be safely erased when compiling with other compilers.\n+ */\n+#if defined(__clang__) && !defined(SWIG)\n+#define LIBCAMERA_TSA_ATTRIBUTE__(x) __attribute__((x))\n+#else\n+#define LIBCAMERA_TSA_ATTRIBUTE__(x) /* no-op */\n+#endif\n+\n+/* See https://clang.llvm.org/docs/ThreadSafetyAnalysis.html for these usages. */\n+\n+#define LIBCAMERA_TSA_CAPABILITY(x)\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(capability(x))\n+\n+#define LIBCAMERA_TSA_SCOPED_CAPABILITY\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(scoped_lockable)\n+\n+#define LIBCAMERA_TSA_GUARDED_BY(x)\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(guarded_by(x))\n+\n+#define LIBCAMERA_TSA_PT_GUARDED_BY(x)\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(pt_guarded_by(x))\n+\n+#define LIBCAMERA_TSA_ACQUIRED_BEFORE(...)\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(acquired_before(__VA_ARGS__))\n+\n+#define LIBCAMERA_TSA_ACQUIRED_AFTER(...)\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(acquired_after(__VA_ARGS__))\n+\n+#define LIBCAMERA_TSA_REQUIRES(...)\t\t\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(requires_capability(__VA_ARGS__))\n+\n+#define LIBCAMERA_TSA_REQUIRES_SHARED(...)\t\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))\n+\n+#define LIBCAMERA_TSA_ACQUIRE(...)\t\t\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(acquire_capability(__VA_ARGS__))\n+\n+#define LIBCAMERA_TSA_ACQUIRE_SHARED(...)\t\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))\n+\n+#define LIBCAMERA_TSA_RELEASE(...)\t\t\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(release_capability(__VA_ARGS__))\n+\n+#define LIBCAMERA_TSA_RELEASE_SHARED(...)\t\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))\n+\n+#define LIBCAMERA_TSA_RELEASE_GENERIC(...)\t\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(release_generic_capability(__VA_ARGS__))\n+\n+#define LIBCAMERA_TSA_TRY_ACQUIRE(...)\t\t\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))\n+\n+#define LIBCAMERA_TSA_TRY_ACQUIRE_SHARED(...)\t\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))\n+\n+#define LIBCAMERA_TSA_EXCLUDES(...)\t\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(locks_excluded(__VA_ARGS__))\n+\n+#define LIBCAMERA_TSA_ASSERT_CAPABILITY(x)\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(assert_capability(x))\n+\n+#define LIBCAMERA_TSA_ASSERT_SHARED_CAPABILITY(x)\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(assert_shared_capability(x))\n+\n+#define LIBCAMERA_TSA_RETURN_CAPABILITY(x)\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(lock_returned(x))\n+\n+#define LIBCAMERA_TSA_NO_THREAD_SAFETY_ANALYSIS\t\t\t\\\n+\tLIBCAMERA_TSA_ATTRIBUTE__(no_thread_safety_analysis)\ndiff --git a/meson.build b/meson.build\nindex 7892a9e3..7147a108 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -72,6 +72,7 @@ if cc.get_id() == 'clang'\n \n cpp_arguments += [\n '-Wextra-semi',\n+ '-Wthread-safety',\n ]\n endif\n \n", "prefixes": [ "libcamera-devel", "v4", "04/12" ] }