Patch Detail
Show a patch.
GET /api/patches/23873/?format=api
{ "id": 23873, "url": "https://patchwork.libcamera.org/api/patches/23873/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23873/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20250721104622.1550908-6-barnabas.pocze@ideasonboard.com>", "date": "2025-07-21T10:46:05", "name": "[RFC,v2,05/22] libcamera: base: cxx20: Add `has_single_bit()`", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "afbfc4e7a00b1ec6f9d8513cf786f83d35f04f59", "submitter": { "id": 216, "url": "https://patchwork.libcamera.org/api/people/216/?format=api", "name": "Barnabás Pőcze", "email": "barnabas.pocze@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/23873/mbox/", "series": [ { "id": 5305, "url": "https://patchwork.libcamera.org/api/series/5305/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5305", "date": "2025-07-21T10:46:00", "name": "libcamera: Add `MetadataList`", "version": 2, "mbox": "https://patchwork.libcamera.org/series/5305/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/23873/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23873/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 ED021C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Jul 2025 10:46:39 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6BB6C68FFB;\n\tMon, 21 Jul 2025 12:46:39 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C218068FE0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Jul 2025 12:46:28 +0200 (CEST)", "from pb-laptop.local (185.221.140.39.nat.pool.zt.hu\n\t[185.221.140.39])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E79C17950\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Jul 2025 12:45:51 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"epioFT+a\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753094752;\n\tbh=q42MWjiF1smGvfBFyYnYrRO46RI1BzKstFXLMKUF1p0=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=epioFT+aM8ywyD1zkU1NqgqocU+HvbnVizP4NgVeiNnctxKdGExVrmcoLyQloHPns\n\tIcTC6ApD6z9DCg3GD6FE+wRTaGdBRzsPkJR8xjo7dlYveGqiTpXGmKoLGU93xaqDYc\n\t/Qv4tcha0209p4S/HABareGKVo++Zu6nDRh0X/TA=", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[RFC PATCH v2 05/22] libcamera: base: cxx20: Add `has_single_bit()`", "Date": "Mon, 21 Jul 2025 12:46:05 +0200", "Message-ID": "<20250721104622.1550908-6-barnabas.pocze@ideasonboard.com>", "X-Mailer": "git-send-email 2.50.1", "In-Reply-To": "<20250721104622.1550908-1-barnabas.pocze@ideasonboard.com>", "References": "<20250721104622.1550908-1-barnabas.pocze@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "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": "`has_single_bit()` checks if the given unsigned integer has a single\nbit set, that is, whether the number is a power of two or not.\n\nNot all requirements of the C++20 standard are implemented.\n\nSee https://en.cppreference.com/w/cpp/numeric/has_single_bit\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n include/libcamera/base/details/cxx20.h | 10 ++++++++++\n 1 file changed, 10 insertions(+)", "diff": "diff --git a/include/libcamera/base/details/cxx20.h b/include/libcamera/base/details/cxx20.h\nindex 2d26db53e..8bf45ff11 100644\n--- a/include/libcamera/base/details/cxx20.h\n+++ b/include/libcamera/base/details/cxx20.h\n@@ -7,9 +7,19 @@\n \n #pragma once\n \n+#include <type_traits>\n+\n namespace libcamera::details::cxx20 {\n \n template<typename T> struct type_identity { using type = T; };\n template<typename T> using type_identity_t = typename type_identity<T>::type;\n \n+template<typename T>\n+constexpr bool has_single_bit(T x) noexcept\n+{\n+\tstatic_assert(std::is_unsigned_v<T>);\n+\n+\treturn x != 0 && (x & (x - 1)) == 0;\n+}\n+\n } /* namespace libcamera::details::cxx20 */\n", "prefixes": [ "RFC", "v2", "05/22" ] }