summaryrefslogtreecommitdiff
path: root/include/util.h
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2020-05-14 10:16:37 -0700
committerCommit Bot <commit-bot@chromium.org>2020-05-15 03:03:15 +0000
commitf21e39083c70a3a04aed865cef65ce4ef95d78b8 (patch)
tree88488d70442770d1db63805532902eefaf5f4e99 /include/util.h
parentbca6d843094cbc8bc49aea01c87b8338b529fd7b (diff)
downloadchrome-ec-f21e39083c70a3a04aed865cef65ce4ef95d78b8.tar.gz
common/util: Add is_aligned
Helper function to check power-of-two alignment. BRANCH=none BUG=b:155229277, b:156501835 TEST=make buildall -j TEST=make run-utils Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Iadcdaeb59e496f10035bd6c7f9660a3cc33a4898 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2202849 Commit-Queue: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'include/util.h')
-rw-r--r--include/util.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/util.h b/include/util.h
index ed5ed26142..7c7e356592 100644
--- a/include/util.h
+++ b/include/util.h
@@ -187,6 +187,15 @@ int get_next_bit(uint32_t *mask);
bool bytes_are_trivial(const uint8_t *buffer, size_t size);
/**
+ * Checks if address is power-of-two aligned to specified alignment.
+ *
+ * @param addr address
+ * @param align power-of-two alignment
+ * @return true if addr is aligned to align, false otherwise
+ */
+bool is_aligned(uint32_t addr, uint32_t align);
+
+/**
* Reverse's the byte-order of the provided buffer.
*/
void reverse(void *dest, size_t len);