Patch Detail
Show a patch.
GET /api/patches/1679/?format=api
{ "id": 1679, "url": "https://patchwork.libcamera.org/api/patches/1679/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1679/", "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": "<20190713113946.25744-1-niklas.soderlund@ragnatech.se>", "date": "2019-07-13T11:39:46", "name": "[libcamera-devel] libcamera: utils: Add clamp()", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "bc47847644ec1b3f9a3436f4fcb0a18ee50c254f", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/1679/mbox/", "series": [ { "id": 428, "url": "https://patchwork.libcamera.org/api/series/428/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=428", "date": "2019-07-13T11:39:46", "name": "[libcamera-devel] libcamera: utils: Add clamp()", "version": 1, "mbox": "https://patchwork.libcamera.org/series/428/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1679/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1679/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C2FC60E40\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 13 Jul 2019 13:39:58 +0200 (CEST)", "from localhost.localdomain (unknown [126.209.254.147])\n\tby bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid ebdafb60-a562-11e9-8d05-005056917f90;\n\tSat, 13 Jul 2019 13:39:55 +0200 (CEST)" ], "X-Halon-ID": "ebdafb60-a562-11e9-8d05-005056917f90", "Authorized-sender": "niklas@soderlund.pp.se", "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 13 Jul 2019 20:39:46 +0900", "Message-Id": "<20190713113946.25744-1-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.22.0", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH] libcamera: utils: Add clamp()", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.23", "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>", "X-List-Received-Date": "Sat, 13 Jul 2019 11:39:58 -0000" }, "content": "C++11 does not support std::clamp(), add a custom implementation in\nutils.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/include/utils.h | 7 +++++++\n src/libcamera/utils.cpp | 9 +++++++++\n 2 files changed, 16 insertions(+)", "diff": "diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\nindex 97bd470a45b050ef..beb2ce3ff7da9352 100644\n--- a/src/libcamera/include/utils.h\n+++ b/src/libcamera/include/utils.h\n@@ -7,6 +7,7 @@\n #ifndef __LIBCAMERA_UTILS_H__\n #define __LIBCAMERA_UTILS_H__\n \n+#include <algorithm>\n #include <memory>\n \n #define ARRAY_SIZE(a)\t(sizeof(a) / sizeof(a[0]))\n@@ -45,6 +46,12 @@ unsigned int set_overlap(InputIt1 first1, InputIt1 last1,\n \treturn count;\n }\n \n+/* C++11 doesn't provide std::clamp */\n+template <typename T>\n+T clamp(const T& v, const T& lo, const T& hi) {\n+\treturn std::max(lo, std::min(v, hi));\n+}\n+\n } /* namespace utils */\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\nindex ef365366f29b426e..b0ca3565ee5a0d83 100644\n--- a/src/libcamera/utils.cpp\n+++ b/src/libcamera/utils.cpp\n@@ -85,6 +85,15 @@ char *secure_getenv(const char *name)\n * \\return The number of elements in the intersection of the two ranges\n */\n \n+/**\n+ * \\fn libcamera::utils::clamp(const T& v, const T& lo, const T& hi)\n+ * \\param[in] v The value to clamp\n+ * \\param[in] lo The lower boundary to clamp v to\n+ * \\param[in] hi The higher boundary to clamp v to\n+ *\n+ * \\return lo if v is less than lo, hi if v is greater than hi, otherwise v\n+ */\n+\n } /* namespace utils */\n \n } /* namespace libcamera */\n", "prefixes": [ "libcamera-devel" ] }