Patch Detail
Show a patch.
GET /api/patches/343/?format=api
{ "id": 343, "url": "https://patchwork.libcamera.org/api/patches/343/?format=api", "web_url": "https://patchwork.libcamera.org/patch/343/", "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": "<20190123082830.10572-1-laurent.pinchart@ideasonboard.com>", "date": "2019-01-23T08:28:30", "name": "[libcamera-devel] libcamera: utils: Add arithmetic operators for struct timespec", "commit_ref": null, "pull_url": null, "state": "rfc", "archived": true, "hash": "c2cd4320f325e88137efee162167ba1fa1ec8642", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": { "id": 14, "url": "https://patchwork.libcamera.org/api/users/14/?format=api", "username": "pinchartl", "first_name": "Laurent", "last_name": "Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "mbox": "https://patchwork.libcamera.org/patch/343/mbox/", "series": [ { "id": 119, "url": "https://patchwork.libcamera.org/api/series/119/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=119", "date": "2019-01-23T08:28:30", "name": "[libcamera-devel] libcamera: utils: Add arithmetic operators for struct timespec", "version": 1, "mbox": "https://patchwork.libcamera.org/series/119/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/343/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/343/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C6F9A60B1B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Jan 2019 09:28:34 +0100 (CET)", "from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 36C7923A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Jan 2019 09:28:34 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1548232114;\n\tbh=WLcLTZS08IfFQZrFk4yWNn4aAHXSPVnPQxcQuTuBqJg=;\n\th=From:To:Subject:Date:From;\n\tb=qrV35qMSK2JlGb8tN5/5+b15xofoJtzbuL3hzhApW0Pt36dkc8X4yriN7hqba1LYr\n\tXJt9sGyMw//gwzHyGHTfaz+H3WfTGP8e7485xXVkCA40eXFDw+QFKe7hIO80hEqOe2\n\tOoWqniARBUoKjF8HWm5h1pmH6aUuMjgOIbyA73c8=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 23 Jan 2019 10:28:30 +0200", "Message-Id": "<20190123082830.10572-1-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.19.2", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH] libcamera: utils: Add arithmetic\n\toperators for struct timespec", "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": "Wed, 23 Jan 2019 08:28:35 -0000" }, "content": "Implement additions and subtraction of struct timespec through\nnon-member operators to simplify timespec handling.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n\nI wrote this code while working on EINTR handling for the event\ndispatcher, and later refactored the implementation in a way that\ndoesn't make use of these operators anymore. I thought they could still\nbe useful as reference for later use. This patch is thus not meant to be\nmerged now, but can be picked up later if anyone needs it.\n\n src/libcamera/include/utils.h | 6 +++++\n src/libcamera/meson.build | 1 +\n src/libcamera/utils.cpp | 46 +++++++++++++++++++++++++++++++++++\n 3 files changed, 53 insertions(+)\n create mode 100644 src/libcamera/utils.cpp", "diff": "diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\nindex 73fa2e69b029..7df20976f36f 100644\n--- a/src/libcamera/include/utils.h\n+++ b/src/libcamera/include/utils.h\n@@ -8,6 +8,7 @@\n #define __LIBCAMERA_UTILS_H__\n \n #include <memory>\n+#include <time.h>\n \n #define ARRAY_SIZE(a)\t(sizeof(a) / sizeof(a[0]))\n \n@@ -24,6 +25,11 @@ std::unique_ptr<T> make_unique(Args&&... args)\n \n } /* namespace utils */\n \n+struct timespec &operator+=(struct timespec &lhs, const struct timespec &rhs);\n+struct timespec operator+(struct timespec lhs, const struct timespec &rhs);\n+struct timespec &operator-=(struct timespec &lhs, const struct timespec &rhs);\n+struct timespec operator-(struct timespec lhs, const struct timespec &rhs);\n+\n } /* namespace libcamera */\n \n #endif /* __LIBCAMERA_UTILS_H__ */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex f9f25c0ecf15..72d4a194e19a 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -11,6 +11,7 @@ libcamera_sources = files([\n 'pipeline_handler.cpp',\n 'signal.cpp',\n 'timer.cpp',\n+ 'utils.cpp',\n 'v4l2_device.cpp',\n ])\n \ndiff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\nnew file mode 100644\nindex 000000000000..5014b27d8c7d\n--- /dev/null\n+++ b/src/libcamera/utils.cpp\n@@ -0,0 +1,46 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * utils.cpp - Miscellaneous utility functions\n+ */\n+\n+#include \"utils.h\"\n+\n+namespace libcamera {\n+\n+struct timespec &operator+=(struct timespec &lhs, const struct timespec &rhs)\n+{\n+\tlhs.tv_sec += rhs.tv_sec;\n+\tlhs.tv_nsec += rhs.tv_nsec;\n+\tif (lhs.tv_nsec >= 1000000000) {\n+\t\tlhs.tv_sec++;\n+\t\tlhs.tv_nsec -= 1000000000;\n+\t}\n+\n+\treturn lhs;\n+}\n+\n+struct timespec operator+(struct timespec lhs, const struct timespec &rhs)\n+{\n+\treturn lhs += rhs;\n+}\n+\n+struct timespec &operator-=(struct timespec &lhs, const struct timespec &rhs)\n+{\n+\tlhs.tv_sec -= rhs.tv_sec;\n+\tlhs.tv_nsec -= rhs.tv_nsec;\n+\tif (lhs.tv_nsec < 0) {\n+\t\tlhs.tv_sec--;\n+\t\tlhs.tv_nsec += 1000000000;\n+\t}\n+\n+\treturn lhs;\n+}\n+\n+struct timespec operator-(struct timespec lhs, const struct timespec &rhs)\n+{\n+\treturn lhs - rhs;\n+}\n+\n+} /* namespace libcamera */\n", "prefixes": [ "libcamera-devel" ] }