From patchwork Tue Sep 24 17:24:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2000 Return-Path: Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D7CDD60BCF for ; Tue, 24 Sep 2019 19:23:28 +0200 (CEST) X-Originating-IP: 213.45.248.89 Received: from uno.homenet.telecomitalia.it (host89-248-dynamic.45-213-r.retail.telecomitalia.it [213.45.248.89]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 9017F60005 for ; Tue, 24 Sep 2019 17:23:28 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 24 Sep 2019 19:24:43 +0200 Message-Id: <20190924172503.30864-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924172503.30864-1-jacopo@jmondi.org> References: <20190924172503.30864-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 01/21] libcamera: utils: Provide an ALIGN macro X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Sep 2019 17:23:29 -0000 Signed-off-by: Jacopo Mondi --- src/libcamera/include/utils.h | 2 ++ src/libcamera/utils.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h index 52eee8ac2804..08323966b44e 100644 --- a/src/libcamera/include/utils.h +++ b/src/libcamera/include/utils.h @@ -63,6 +63,8 @@ using time_point = std::chrono::steady_clock::time_point; struct timespec duration_to_timespec(const duration &value); std::string time_point_to_string(const time_point &time); +#define ALIGN(_s, _a) (((_s) + (_a - 1)) & ~(_a - 1)) + } /* namespace utils */ } /* namespace libcamera */ diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp index 928db254ec67..c3188bfff03d 100644 --- a/src/libcamera/utils.cpp +++ b/src/libcamera/utils.cpp @@ -143,6 +143,17 @@ std::string time_point_to_string(const time_point &time) return ossTimestamp.str(); } +/** + * \def ALIGN(_s, _a) + * \brief Align a size to a boundary + * \param[in] _s The size to align + * \param[in] _a The boundary to align size to + * + * Align the provide size \a _s to a the provided boundary. The request + * alignement should be a power of 2, and the aligned size is up aligned to + * the given boundary. + */ + } /* namespace utils */ } /* namespace libcamera */