diff options
Diffstat (limited to 'common/util.c')
-rw-r--r-- | common/util.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/common/util.c b/common/util.c index 6188afc937..d60fcd95d5 100644 --- a/common/util.c +++ b/common/util.c @@ -568,6 +568,12 @@ bool is_aligned(uint32_t addr, uint32_t align) return (addr & (align - 1)) == 0; } +int alignment_log2(unsigned int x) +{ + ASSERT(x != 0); /* ctz(0) is undefined */ + return __builtin_ctz(x); +} + /****************************************************************************/ /* stateful conditional stuff */ |