diff options
author | Tom Hughes <tomhughes@chromium.org> | 2020-05-14 10:16:37 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-15 03:03:15 +0000 |
commit | f21e39083c70a3a04aed865cef65ce4ef95d78b8 (patch) | |
tree | 88488d70442770d1db63805532902eefaf5f4e99 /include | |
parent | bca6d843094cbc8bc49aea01c87b8338b529fd7b (diff) | |
download | chrome-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')
-rw-r--r-- | include/util.h | 9 |
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); |