[libcamera-devel] [PATCH 01/21] libcamera: utils: Provide an ALIGN macro

Jacopo Mondi jacopo at jmondi.org
Tue Sep 24 19:24:43 CEST 2019


Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
 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 */
-- 
2.23.0



More information about the libcamera-devel mailing list