Patch Detail
Show a patch.
GET /api/patches/25635/?format=api
{ "id": 25635, "url": "https://patchwork.libcamera.org/api/patches/25635/?format=api", "web_url": "https://patchwork.libcamera.org/patch/25635/", "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": "<20260106165754.1759831-6-barnabas.pocze@ideasonboard.com>", "date": "2026-01-06T16:57:37", "name": "[v4,05/22] libcamera: base: cxx20: Add `has_single_bit()`", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "cf573de55999ae9aeab89592ed1f3ad655624383", "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/25635/mbox/", "series": [ { "id": 5688, "url": "https://patchwork.libcamera.org/api/series/5688/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5688", "date": "2026-01-06T16:57:32", "name": "libcamera: Add `MetadataList`", "version": 4, "mbox": "https://patchwork.libcamera.org/series/5688/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/25635/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/25635/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 19FB8BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 6 Jan 2026 16:58:13 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A71D261FD6;\n\tTue, 6 Jan 2026 17:58:04 +0100 (CET)", "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 393FC61F9F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 6 Jan 2026 17:57:59 +0100 (CET)", "from pb-laptop.local (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2DCDD16CD;\n\tTue, 6 Jan 2026 17:57:38 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ngl+TCMg\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1767718658;\n\tbh=mkcW4kOYD2jP66GKK3ji8SaLitSezNm7hJvxYbBYpC0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ngl+TCMgutPonxKXPhXK/PTSS1GuqGqmSESqTEg4MGyDlqtPfVmvnLh+UjEySgqtP\n\t2cJVJnFPgoi6gZuW8i3kE5uqJC277NQka5oj6+23quUs1tXEFUJ6X1b7NzH+B1GTbW\n\tYo5k5I5CBQni4Z8uyolLHK8G4XC7H/xTNuYGG5/M=", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Paul Elder <paul.elder@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>", "Subject": "[PATCH v4 05/22] libcamera: base: cxx20: Add `has_single_bit()`", "Date": "Tue, 6 Jan 2026 17:57:37 +0100", "Message-ID": "<20260106165754.1759831-6-barnabas.pocze@ideasonboard.com>", "X-Mailer": "git-send-email 2.52.0", "In-Reply-To": "<20260106165754.1759831-1-barnabas.pocze@ideasonboard.com>", "References": "<20260106165754.1759831-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>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/base/internal/cxx20.h | 16 ++++++++++++++++\n 1 file changed, 16 insertions(+)", "diff": "diff --git a/include/libcamera/base/internal/cxx20.h b/include/libcamera/base/internal/cxx20.h\nindex 1f4caf56f..d47168a70 100644\n--- a/include/libcamera/base/internal/cxx20.h\n+++ b/include/libcamera/base/internal/cxx20.h\n@@ -7,6 +7,8 @@\n \n #pragma once\n \n+#include <type_traits>\n+\n /**\n * \\internal\n * \\file cxx20.h\n@@ -39,4 +41,18 @@ template<typename T> struct type_identity {\n */\n template<typename T> using type_identity_t = typename type_identity<T>::type;\n \n+/**\n+ * \\internal\n+ * \\brief std::has_single_bit()\n+ *\n+ * Implementation of std::has_single_bit() for C++17.\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::internal::cxx20 */\n", "prefixes": [ "v4", "05/22" ] }