diff options
author | Anton Staaf <robotboy@chromium.org> | 2014-07-23 14:06:47 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-09-18 02:59:24 +0000 |
commit | a6da62d284be2c7344f774b9c1da2274b85b3af2 (patch) | |
tree | b25cddc5767430bb3749783c3e5a9efce81f28c5 /include/util.h | |
parent | eff864775f25f16480955ebde7234219c6e03948 (diff) | |
download | chrome-ec-a6da62d284be2c7344f774b9c1da2274b85b3af2.tar.gz |
Queue: Add functionality needed by new USART stream driver
Previously there was no way to remove multiple units at a time
from the queue, and the queue was wasting an entry to disambiguate
full from empty. There was also no way to get the free entry
count from the queue, only the ability to query if it was above
a required amount. The queue was also storing its constant
compile time configuration as well as its dynamic state in the
same structure. This wasted RAM on configuration information
that doesn't change.
This refactor fixes these issues, making the queue suitable for
use in the new USART stream driver.
Signed-off-by: Anton Staaf <robotboy@chromium.org>
BRANCH=None
BUG=None
TEST=make buildall -j
Change-Id: I284cee52d8189928dbc4c499f87ab34e14019e5a
Reviewed-on: https://chromium-review.googlesource.com/210533
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'include/util.h')
-rw-r--r-- | include/util.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/util.h b/include/util.h index e952123e37..c012470a47 100644 --- a/include/util.h +++ b/include/util.h @@ -56,6 +56,9 @@ #define NULL ((void *)0) #endif +/* True of x is a power of two */ +#define POWER_OF_TWO(x) (x && !(x & (x - 1))) + /** * macros for integer division with various rounding variants * default integer division rounds down. |